| View previous topic :: View next topic |
| Author |
Message |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
pasha_golub General User


Joined: 29 Jun 2004 Posts: 24 Location: Ukraine
|
Posted: Tue Jul 27, 2004 11:10 pm Post subject: |
|
|
Thanks for all. I need some time to check all possible missunderstandings. Any way, I'll post result of my research in this thread. Thanks again. _________________ Nullus est in vitae sensus, ipsa vera est sensus! |
|
| Back to top |
|
 |
pasha_golub General User


Joined: 29 Jun 2004 Posts: 24 Location: Ukraine
|
Posted: Wed Jul 28, 2004 6:15 pm Post subject: |
|
|
Well, I decide to test this code in VBA.
So we have:
| Code: | Sub OO()
Dim objServiceManager As Object
Dim objDesktop As Object
Dim args(0) As Object
Dim Doc As Object
Dim oStruct As Object
Set objServiceManager = CreateObject("com.sun.star.ServiceManager")
Set objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
Set Doc = objDesktop.loadComponentFromURL("private:factory/sdraw", "_blank", 0, args)
Dim DrawPage As Object
Set DrawPage = Doc.getDrawPages.getByIndex(0)
Dim Ellipse As Object
Set Ellipse = Doc.createInstance("com.sun.star.drawing.EllipseShape")
Set oStruct = objServiceManager.Bridge_GetStruct("com.sun.star.awt.Point")
oStruct.x = 1000
oStruct.y = 2000
Ellipse.Position = oStruct
Set oStruct = objServiceManager.Bridge_GetStruct("com.sun.star.awt.Size")
oStruct.width = 1000
oStruct.height = 2000
Ellipse.Size = oStruct
Ellipse.FillStyle = 1 'Solid
Ellipse.FillColor = hFF0000
Call DrawPage.Add(Ellipse)
Set oStruct = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oStruct.Name = "FilterName"
oStruct.Value = "BMP - MS Windows"
Set args(0) = oStruct
Call Doc.storeAsUrl("file:///C:/Test.bmp", args())
Call objDesktop.terminate
End Sub |
But in this case at line with StoreAsUrl I have Runtime error 1001: 'com.sun.star.io.IOException'.
I'm absolutely confused and even don't know what to do. I checked this code many times comparing samples on this forum and mine.
Please tell me what's wrong?  _________________ Nullus est in vitae sensus, ipsa vera est sensus! |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
pasha_golub General User


Joined: 29 Jun 2004 Posts: 24 Location: Ukraine
|
Posted: Tue Aug 03, 2004 12:35 am Post subject: |
|
|
Oh, now I see the problem - there are another export filters.
As I said before I look for way to save drawing in not native format, but the only thing that I found was idea that there is another way for exporting drawings. I was thinking that some ExportTo... method must exists.
As it was found out (by you ) I must use another filter names only. Thanks a lot. _________________ Nullus est in vitae sensus, ipsa vera est sensus! |
|
| Back to top |
|
 |
pasha_golub General User


Joined: 29 Jun 2004 Posts: 24 Location: Ukraine
|
Posted: Thu Aug 05, 2004 3:10 am Post subject: |
|
|
Well, hi. It's me again.
I solved this problem for VB script, like this:
| Code: |
Sub OO()
Dim objServiceManager As Object
Dim objDesktop As Object
Dim args(0) As Object
Dim Doc As Object
Dim oStruct As Object
Set objServiceManager = CreateObject("com.sun.star.ServiceManager")
Set objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
Set Doc = objDesktop.loadComponentFromURL("private:factory/sdraw", "_blank", 0, args)
Dim DrawPage As Object
Set DrawPage = Doc.getDrawPages.getByIndex(0)
Dim Ellipse As Object
Set Ellipse = Doc.createInstance("com.sun.star.drawing.EllipseShape")
Set oStruct = objServiceManager.Bridge_GetStruct("com.sun.star.awt.Point")
oStruct.x = 1000
oStruct.y = 2000
Ellipse.Position = oStruct
Set oStruct = objServiceManager.Bridge_GetStruct("com.sun.star.awt.Size")
oStruct.width = 1000
oStruct.height = 2000
Ellipse.Size = oStruct
Ellipse.FillStyle = 1 'Solid
Ellipse.FillColor = hFF0000
Call DrawPage.Add(Ellipse)
Set oStruct = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oStruct.Name = "FilterName"
oStruct.Value = "draw_bmp_Export"
Set args(0) = oStruct
Call Doc.storeToUrl("file:///C:/Test.bmp", args())
Call objDesktop.terminate
End Sub
|
Works just fine. But I can't do the same in Delphi. I am sick and tired of this. Anybody, please help
| Code: |
var
Form1: TForm1;
StarOffice, StarDesktop, DrawDoc, DrawPage: Variant;
implementation
{$R *.dfm}
function MakePoint(const X, Y: integer):variant;
var Struct: variant;
begin
Struct := StarOffice.Bridge_GetStruct('com.sun.star.awt.Point');
Struct.X := X;
Struct.Y := Y;
Result := Struct;
end;
function MakeSize(const Width, Height: integer):variant;
var Struct: variant;
begin
Struct := StarOffice.Bridge_GetStruct('com.sun.star.awt.Size');
Struct.Width := Width;
Struct.Height := Height;
Result := Struct;
end;
function Connect: boolean;
begin
if VarIsEmpty(StarOffice) then
StarOffice := CreateOleObject('com.sun.star.ServiceManager');
StarDesktop := StarOffice.createInstance('com.sun.star.frame.Desktop');
Result := not (VarIsEmpty(StarOffice) or VarIsNull(StarOffice));
end;
function CreateDrawDocument: boolean;
begin
DrawDoc := StarDesktop.loadComponentFromURL( 'private:factory/sdraw', '_blank',
0, VarArrayCreate([0,-1],varVariant));
Result := not (VarIsEmpty(DrawDoc) or VarIsNull(DrawDoc));
DrawPage := DrawDoc.getDrawPages.getByIndex(0);
end;
function DrawRectangle(const X,Y,Width,Height: integer):variant;
begin
Result := DrawDoc.createInstance('com.sun.star.drawing.RectangleShape');
Result.Position := MakePoint(X,Y);
Result.Size := MakeSize(Width,Height);
DrawPage.Add(Result);
end;
function DrawEllipse(const X,Y,Width,Height: integer):variant;
begin
Result := DrawDoc.createInstance('com.sun.star.drawing.EllipseShape');
Result.Position := MakePoint(X,Y);
Result.Size := MakeSize(Width,Height);
DrawPage.Add(Result);
end;
function DrawTextShape(const X,Y,Width,Height: integer):variant;
begin
Result := DrawDoc.createInstance('com.sun.star.drawing.TextShape');
Result.Position := MakePoint(X,Y);
Result.Size := MakeSize(Width,Height);
DrawPage.Add(Result);
end;
{ Fill styles:
NONE the area is not filled.
SOLID use a solid color to fill the area.
GRADIENT use a gradient color to fill the area.
HATCH use a hatch to fill the area.
BITMAP use a bitmap to fill the area.}
const
OOfsNone = 0;
OOfsSolid = 1;
OOfsGradient = 2;
OOfsHatch = 3;
OOfsBitmap = 4;
{ Line styles:
NONE the line is hidden.
SOLID the line is solid.
DASH the line use dashes.}
const
OOlsNone = 0;
OOlsSolid = 1;
OOlsDash = 2;
{ Circle kinds:
FULL a full circle
SECTION a circle with a cut connected by a line
CUT a circle with a cut connected by two lines
ARC a circle with an open cut
}
const
OOckFull = 0;
OOckSection = 1;
OOckCut = 2;
OOckArc = 3;
procedure DrawSimplePieChart;
var Circle1, Square1, Text1: Variant;
begin
Circle1 := DrawEllipse(8000, 10000, 5000, 5000);
Circle1.LineStyle := OOlsSolid;
Circle1.LineWidth := 10;
Circle1.FillStyle := OOfsSolid;
Circle1.FillColor := $FF0000; //RGB notation
Circle1.CircleKind := OOckSection;
Circle1.CircleStartAngle := 0;
Circle1.CircleEndAngle := 1000;
Circle1 := DrawEllipse(8000, 10000, 5000, 5000);
Circle1.LineStyle := OOlsSolid;
Circle1.LineWidth := 10;
Circle1.FillStyle := OOfsSolid;
Circle1.FillColor := $0000FF; //RGB notation
Circle1.CircleKind := OOckSection;
Circle1.CircleStartAngle := 1000;
Circle1.CircleEndAngle := 36000;
Square1 := DrawRectangle(8000, 16000, 500, 500);
Square1.LineStyle := OOlsSolid;
Square1.LineWidth := 10;
Square1.FillStyle := OOfsSolid;
Square1.FillColor := $FF0000;
Square1 := DrawRectangle(8000, 17000, 500, 500);
Square1.LineStyle := OOlsSolid;
Square1.LineWidth := 10;
Square1.FillStyle := OOfsSolid;
Square1.FillColor := $0000FF;
Text1 := DrawTextShape(9000, 16000, 8000, 500);
Text1.LineStyle := OOlsNone;
Text1.FillStyle := OOfsNone;
Text1.Text.setString('SCO True statements');
Text1 := DrawTextShape(9000, 17000, 8000, 500);
Text1.LineStyle := 0;
Text1.FillStyle := 0;
Text1.Text.setString('SCO False statements');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Connect then
if CreateDrawDocument then
begin
Button2.Enabled := True;
DrawSimplePieChart;
end
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
StarDesktop.Terminate;
StarDesktop := UnAssigned;
StarOffice := UnAssigned;
end;
{$D+} {$L+}
function TForm1.MakePropertyValue(PropName:string; PropValue:variant):variant;
var Struct: variant;
begin
Struct := StarOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
Struct.Name := PropName;
Struct.Value := PropValue;
Result := Struct;
end;
procedure TForm1.Button3Click(Sender: TObject);
var VariantArr: variant;
begin
VariantArr := VarArrayCreate([0, 0], varVariant);
VariantArr[0] := MakePropertyValue('FilterName', 'draw_bmp_Export');
DrawDoc.StoreToURL('file:///c:/sco.bmp', VariantArr);
end;
end.
|
Produced file is not BMP valid file. But it may be opened by OOo. It seems to me that it was saved in native *.sxd format. Thus problem is in MakeProperty function. But this function work fine in another application.  _________________ Nullus est in vitae sensus, ipsa vera est sensus! |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Thu Aug 05, 2004 7:35 am Post subject: |
|
|
It looks to me like you use the correct name. I have not created a test case for this, but have you tried inspecting the returned argument array to make certain that it contains what you expect? _________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|