Writer table column-resize

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
jj-guitar
Posts: 2
Joined: Thu Feb 07, 2008 6:58 pm

Writer table column-resize

Post by jj-guitar »

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

	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

	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

Post by jj-guitar »

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
bakshiabhishek
Posts: 5
Joined: Wed Feb 25, 2009 3:25 pm

Re: writer table column-resize

Post by bakshiabhishek »

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

//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
bolehradsky
Posts: 1
Joined: Wed Feb 09, 2011 2:03 pm

Re: Writer table column-resize

Post by bolehradsky »

Code: Select all

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
eliphelet
Posts: 5
Joined: Sun Aug 21, 2011 8:46 am

Re: Writer table column-resize

Post by eliphelet »

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