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

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
jfpetit
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

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

Post by jfpetit »

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

  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
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

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

Post by JohnSUN-Pensioner »

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
jfpetit
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

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

Post by jfpetit »

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
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

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

Post by JohnSUN-Pensioner »

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
jfpetit
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

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

Post by jfpetit »

No it does not works
I used shape.anchortype:=1; with 0,1,4 according to enum TextContentAnchorType.
OpenOffice 3.4.1
Windows XP
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

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

Post by JohnSUN-Pensioner »

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
jfpetit
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

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

Post by jfpetit »

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
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

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

Post by JohnSUN-Pensioner »

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
jfpetit
Posts: 13
Joined: Tue Dec 04, 2012 10:48 am

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

Post by jfpetit »

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
Post Reply