Insert picture - Writer - Delphi

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Benobo
Posts: 1
Joined: Mon Dec 08, 2014 1:23 pm

Insert picture - Writer - Delphi

Post by Benobo »

Hello,

I have a problem when I try to put a picture inside a Writer document with Delphi.
I get an error message "The Variant does not contain an Object type" at the level of the line monImage.Position:= positionImage;
When I remove that line the picture is placed on the page but I try to put it at the right location.
I can read the values (X & Y) of positionImage.
So I do not understand where is the problem.

Code: Select all

Procedure Insert_Picture(File_Name: String);
Var
 monImage, positionImage: Variant;
begin

       myCursor.gotoNextParagraph(False);

       positionImage:= CreateUnoStruct('com.sun.star.awt.Point',0);
       positionImage[0].X:= 4000;
       positionImage[0].Y:= 4000;

       monImage:= MyDocument.createInstance('com.sun.star.drawing.GraphicObjectShape');
       monImage.GraphicURL:= ConvertToURL(File_Name);

       monImage.AnchorType:= 0;

       myText.insertTextContent(myCursor, monImage, false);
       resizeImageByDPI(monImage, 5500);

       -----> monImage.Position:= positionImage; <------------

    end;
end;
If somebody could solve that problem, it shoud be very helpful.

Thank you.

Benoît
OpenOffice 3.4.1 on Windows 7
Post Reply