Writer table column-resize

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

Writer table column-resize

Postby jj-guitar » Wed Apr 02, 2008 12:37 pm

Hi all, :)

i'm trying to resize the width of a cell in a row from java. Accessing the row and determing the actual positions of the array TableColumnSeparator is no problem:
Code: Select all   Expand viewCollapse view
   XTableRows rows = table.getRows();
   Object aRow = rows.getByIndex(row);
   XPropertySet psRow = OOBase.getProperties(aRow); // own method
   TableColumnSeparator[] colSeps = (TableColumnSeparator[])psRow.getPropertyValue("TableColumnSeparators");
   System.out.println(colSeps[0].Position);
   colSeps[0].Position += (short)111;
   System.out.println(colSeps[0].Position);

Changing the Position of colSeps[0] doesn't affect the table. It seems that the local (java) change of the position isn't communicated to the running openoffice. But even reassigning the separators array to the propertySet doesn't help.
Code: Select all   Expand viewCollapse view
   psRow.setPropertyValue("TableColumnSeparators", colSeps);

Why this? :(

thanks for reading, thinking and answering in advance ;)
jj-guitar
jj-guitar
 
Posts: 2
Joined: Thu Feb 07, 2008 6:58 pm

Re: writer table column-resize

Postby jj-guitar » Fri Apr 04, 2008 4:20 pm

Hi again,

i found out, that assigning changed ColSeparators to the tables PropertySet affects the colWidths - but this can only be done in a simple table. ColSeparators of the rows PropertySet sustained all my efforts to change them. :cry:

greets jj
jj-guitar
 
Posts: 2
Joined: Thu Feb 07, 2008 6:58 pm

Re: writer table column-resize

Postby bakshiabhishek » Wed Feb 25, 2009 3:48 pm

Hi,
Even I'm facing this issue. Is there a solution for this yet ?

The issue is :
Setting back the modified 'TableColumnSeparator[]' array as new property value , doesn't change the property.

Following Algo doesn't update the row property(TableColumnSeparators) value.

Code: Select all   Expand viewCollapse view
//Get the current value: This works and returns correct data
colSepsArray = (TableColumnSeparator[]) xRowProps.getPropertyValue("TableColumnSeparators");

//I modify the postions for each seprator in the array (all summing up to 10000)
:
colSepsArray[colIndex].Position = (short) Math.ceil(RelativeWidth);

//Set back the property for row
xRowProps.setPropertyValue("TableColumnSeparators", colSepsArrayNew);

//To check: I extract the property again: But these are still the same as were orignally.


Thanks in advance,
Abhishek.
OOo 3.0.X on MS Windows Vista + Linux
bakshiabhishek
 
Posts: 5
Joined: Wed Feb 25, 2009 3:25 pm

Re: Writer table column-resize

Postby bolehradsky » Wed Feb 09, 2011 2:06 pm

Code: Select all   Expand viewCollapse view
unoidl.com.sun.star.uno.XComponentContext localContext = uno.util.Bootstrap.bootstrap();
            unoidl.com.sun.star.lang.XMultiServiceFactory multiServiceFactory = (unoidl.com.sun.star.lang.XMultiServiceFactory)localContext.getServiceManager();
            XComponentLoader componentLoader =(XComponentLoader)multiServiceFactory.createInstance("com.sun.star.frame.Desktop");
            XComponent xComponent = componentLoader.loadComponentFromURL(
            "private:factory/swriter", //a blank writer document
            "_blank", 0, //into a blank frame use no searchflag
            new unoidl.com.sun.star.beans.PropertyValue[0]);//use no additional arguments.
            //object odtTbl = null;
            //odtTbl = ((XMultiServiceFactory)xComponent).createInstance("com.sun.star.text.TextTable");

            XTextDocument xTextDocument = (unoidl.com.sun.star.text.XTextDocument)xComponent;
            XText xText = xTextDocument.getText();
            XTextCursor xTextCursor = xText.createTextCursor();
           
            XPropertySet xTextCursorProps = (unoidl.com.sun.star.beans.XPropertySet) xTextCursor;
            XSimpleText xSimpleText = (XSimpleText)xText;
            XTextCursor xCursor = xSimpleText.createTextCursor();


            object objTextTable = null;
            objTextTable = ((XMultiServiceFactory)xComponent).createInstance("com.sun.star.text.TextTable");
            XTextTable xTextTable = (XTextTable)objTextTable;
            xTextTable.initialize(2,3);
            xText.insertTextContent(xCursor, xTextTable, false);

            XPropertySet xPS = (XPropertySet)objTextTable; 
            uno.Any xObj = xPS.getPropertyValue("TableColumnSeparators");
            TableColumnSeparator[] xSeparators = (TableColumnSeparator[])xObj.Value;  //!!!! xObj.Value

            xSeparators[0].Position = 2000; 
            xSeparators[1].Position = 3000;
            xPS.setPropertyValue("TableColumnSeparators", new uno.Any(typeof(TableColumnSeparator[]), xSeparators)); //!!!! TableColumnSeparator[]
Windows XP, OpenOffice 3.2.1
bolehradsky
 
Posts: 1
Joined: Wed Feb 09, 2011 2:03 pm

Re: Writer table column-resize

Postby eliphelet » Sun Aug 21, 2011 8:54 am

hi!
thank for your code. but when i run it, the line
"TableColumnSeparator[] xSeparators = (TableColumnSeparator[])xObj.Value;"
raise an error: "can not convert int16 to TableColumnSeparator[]"

can anyone help me?
openOffice 3 on windows 7
eliphelet
 
Posts: 5
Joined: Sun Aug 21, 2011 8:46 am


Return to External Programs

Who is online

Users browsing this forum: No registered users and 1 guest