[Solved] Writer: How to put a shape left in Cells table

Java, C++, C#, Delphi, ??? - Using the UNO bridges

[Solved] Writer: How to put a shape left in Cells table

Postby jfpetit » Mon Dec 10, 2012 1:43 pm

I create an OpenOffice document with Delphi. I insert a table in my document.
My question is : How to insert a shape in cells of the table on the left side of the cell.
This code put the shape center.
Code: Select all   Expand viewCollapse view
  TableCell:= Table.getCellByPosition(c-1, r-1);  //c r
    Shape:= Document.createInstance('com.sun.star.text.TextGraphicObject');
    objSize:= result.getsize;
    objSize.Width := w*35;  //40
    objSize.Height := h*35;   //40
    result.setSize(objSize) ;
    Fic := 'file:///'+StringReplace(nomfic, '\', '/', [rfReplaceAll, rfIgnoreCase]);
    Shape.GraphicURL := fic;
    TableCell.insertTextContent(TableCell, shape, false);

Thanks for help
Last edited by jfpetit on Wed Dec 12, 2012 10:50 am, edited 3 times in total.
OpenOffice 3.4.1
Windows XP
jfpetit
 
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

Re: Writer: How to put a shape in Cells table

Postby JohnSUN-Pensioner » Mon Dec 10, 2012 1:53 pm

Try to set property Anchor of Shape to the value TableCell.

PS. Oh, sorry! I missed word "Writer"!
Set AnchorType to AS_CHARACTER and align it to left
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
JohnSUN-Pensioner
Volunteer
 
Posts: 824
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Writer: How to put a shape in Cells table

Postby jfpetit » Mon Dec 10, 2012 2:32 pm

When I set AnchorType to AS_CHARACTER the shape does not appears in the cell?

shape.anchortype:=1; //AS_CHARACTER
TableCell.insertTextContent(TableCell, shape, false);
OpenOffice 3.4.1
Windows XP
jfpetit
 
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

Re: Writer: How to put a shape left in Cells table

Postby JohnSUN-Pensioner » Mon Dec 10, 2012 6:00 pm

I could be wrong, but it seems at Pitonyak saw that set the properties before inserting to the document does not make sense. Try these lines reversed.
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
JohnSUN-Pensioner
Volunteer
 
Posts: 824
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Writer: How to put a shape left in Cells table

Postby jfpetit » Mon Dec 10, 2012 7:13 pm

No it does not works
I used shape.anchortype:=1; with 0,1,4 according to enum TextContentAnchorType.
OpenOffice 3.4.1
Windows XP
jfpetit
 
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

Re: Writer: How to put a shape left in Cells table

Postby JohnSUN-Pensioner » Tue Dec 11, 2012 11:52 am

I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
JohnSUN-Pensioner
Volunteer
 
Posts: 824
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Writer: How to put a shape left in Cells table

Postby jfpetit » Tue Dec 11, 2012 6:41 pm

Sorry but I have not been able to run the example.
Do you know how to change the property HoriJustify of a Cell from XCell (TableCell) give by : TableCell:=Table.getCellByPosition(c-1, r-1);
Thanks for help
OpenOffice 3.4.1
Windows XP
jfpetit
 
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

Re: Writer: How to put a shape left in Cells table

Postby JohnSUN-Pensioner » Wed Dec 12, 2012 10:38 am

Unfortunately, I don't know how to change this option of paragraph too. (of paragraph, not of cell) ;)
What do you think about DispatchHelper? And about commands .uno:LeftPara, .uno:CenterPara, .uno:RightPara and .uno:JustifyPara?

But in fact that the style "Table Contents" after setting the anchor position of image to as_character align it well. By default - to left. But we can set any other value in template.
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
JohnSUN-Pensioner
Volunteer
 
Posts: 824
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Writer: How to put a shape left in Cells table

Postby jfpetit » Wed Dec 12, 2012 10:50 am

I found the solution. AnchorType: = 1 did not work because I done after a setString that crushed the shape.
Now I put the shape after the string and it works
Thanks for your help.
OpenOffice 3.4.1
Windows XP
jfpetit
 
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am


Return to External Programs

Who is online

Users browsing this forum: No registered users and 1 guest