Apache OpenOffice (AOO) Bugzilla – Issue 55575
setPropertyValue("TableColumnsSeparators",x) does not work
Last modified: 2024-01-23 15:12:53 UTC
hi all, the setPropertyValue functionality for setting TableColumnSeparator in a TextTable Object is not working as expected. It doesn't matter if you change the properties "isVisible" or "Position" or add a new TableColumnSeperator Object or reduce one, nothing seems to take effect. The Values are the same after "setPropertyValue" as before. Thanx a lot Bernhard Diemer
Sorry I mentioned the Worng Version : I'm using version 1.1 by now.
The following macro works for me: sub Main dim separator as new com.sun.star.text.TableColumnSeparator ' insert table xTextTable = ThisComponent.createInstance("com.sun.star.text.TextTable") xTextTable.initialize(3,5) xText = ThisComponent.Text xText.insertTextContent(xText, xTextTable, true) separatorArray = xTextTable.TableColumnSeparators ' change column separators for i = 0 to ubound(separatorArray) separator = separatorArray(i) separator.Position = separator.Position / 2 separatorArray(i) = separator next i ' write separators back xTextTable.TableColumnSeparators = separatorArray end sub
.
Created attachment 30232 [details] Own Porgramm Testing TableColumnSeperator
Hi sg, I'm sorry I have to reopen this one. After several tests I found the situation where it does really funny things. I Attached my own programm, which is loading an existing Open Office Document with an existing table named "b4it:spras", this table has 3 columns and 3 rows. in the second row the first and second cell is merged. It looks like : A1 B1 C1 A2 B2 C2 A3 B3 So even if I try to set the original value of the TableColumnSeparator Position to the Object it sets every time it is running another value !!! but only in the third row !!!! Hope you can help me out with this one. Thank you very much Best regards Bernhard Diemer
Created attachment 30319 [details] complex test case
Added complex test. To reproduce the bug, unpack the zip and go to complex/writer, type 'dmake' to build and 'dmake run' to execute. bug consists of several parts (documentation and code), concerning text tables with merged cells: - TableColumnSeparator.idl is not completed, at the end some text parts are missing. - the invisible text separator between the merged cells is not returnd with the column separators collection, but TableColumnSeparator.idl states that it should have been. - reading the column separators and writing back the same values results in a changed separator
Happens on all systems; set target; reassign to tl: one for you.
Because the original poster mention this behavior on version 1.1., I want to add that I got the same problems using 2.0.2 or 2.0.3., no matter if I use Basic or C++. Especially "reading the column separators and writing back the same values results in a changed separator" is very wired.
No more issues accepted for OOo 2.4 unless there are serious problems.
Hi, tableColumnSeperator works inconsistent. tested version aoo 3.4.1 linux i686 below program show correctly changed tables with 2,4,5,8 and 16 columns while tables with 3,6,7,9,10-15 columns do not: /** * ************************************************************ * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with this * work for additional information regarding copyright ownership. The ASF * licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. * ************************************************************ */ /* * TestOfficeUNOClientApp.java * * Created on 2013.08.28 - 07:27:15 * */ package com.example; import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; import com.sun.star.uno.XComponentContext; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.comp.helper.BootstrapException; import com.sun.star.frame.XComponentLoader; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.table.XCellRange; import com.sun.star.table.XTableRows; import com.sun.star.text.TableColumnSeparator; import com.sun.star.text.XText; import com.sun.star.text.XTextCursor; import com.sun.star.text.XTextDocument; import com.sun.star.text.XTextTable; import com.sun.star.uno.UnoRuntime; /** * * @author martin */ public class TestOfficeUNOClientApp { final static boolean DEBUG = true; /** * Creates a new instance of TestOfficeUNOClientApp */ public TestOfficeUNOClientApp() { } /** * @param args the command line arguments */ public static void main(String[] args) { XComponentContext xComponentContext = null; XMultiComponentFactory xMCF = null; Object desktop = null; XComponentLoader xComponentLoader = null; XComponent xWriterComponent = null; XTextDocument xTextDocument = null; XMultiServiceFactory docServiceFactory = null; // textcontent creator // get the remote office component context try { xComponentContext = Bootstrap.bootstrap(); if (xComponentContext == null) { System.err.println("ERROR: Could not bootstrap default Office."); } try { xMCF = xComponentContext.getServiceManager(); desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xComponentContext); xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop); PropertyValue[] loadProps = new PropertyValue[0]; // verkrijg een leeg document xWriterComponent = xComponentLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, loadProps); xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xWriterComponent); // verkrijg een pointer naar de bij document horende "Service Manager" docServiceFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument); XText xText = xTextDocument.getText(); for (int x = 2; x < 17; ++x) { Object textTable = docServiceFactory.createInstance("com.sun.star.text.TextTable"); XTextTable xTextTable = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, textTable); xTextTable.initialize(3, x); // Getting Doc cursor XTextCursor xTextCursor = xText.createTextCursor(); xTextCursor.collapseToEnd(); xTextCursor.gotoEnd(false); // Insert the table into the document xText.insertTextContent(xTextCursor, xTextTable, false); // set some id XCellRange xCellRange = (XCellRange) UnoRuntime.queryInterface(XCellRange.class, xTextTable); XText xCellText = (XText) UnoRuntime.queryInterface(XText.class, xCellRange.getCellByPosition(0, 0)); xCellText.setString(""+x); // rel width of table XPropertySet tableProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextTable); String ss = tableProps.getPropertyValue("TableColumnRelativeSum").toString(); short tabelRelWidth = Integer.decode("" + ss).shortValue(); // get the rows XTableRows xTableRows = xTextTable.getRows(); // only change row 1 XPropertySet xPropertySet1 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTableRows.getByIndex(1)); // get Property TableColumnSeparators TableColumnSeparator[] xTableColumnSeparator = (TableColumnSeparator[]) xPropertySet1.getPropertyValue("TableColumnSeparators"); if (DEBUG) { for (int y = 0; y < xTableColumnSeparator.length; ++y) { System.out.print("" + xTableColumnSeparator[y].Position + ","); } System.out.println("orginal"); } // make last smaller by half a box size short sTemp; sTemp = xTableColumnSeparator[xTableColumnSeparator.length - 1].Position; sTemp = (short) (sTemp + (tabelRelWidth - sTemp) / 2); //stupid shorts :( xTableColumnSeparator[xTableColumnSeparator.length - 1].Position = sTemp; xPropertySet1.setPropertyValue("TableColumnSeparators", (Object) xTableColumnSeparator); if (DEBUG) { // show them TableColumnSeparator[] xTableColumnSeparator2 = (TableColumnSeparator[]) xPropertySet1.getPropertyValue("TableColumnSeparators"); for (int yy = 0; yy < xTableColumnSeparator2.length; ++yy) { System.out.print("" + xTableColumnSeparator2[yy].Position + ","); } System.out.println("newly read"); } } } catch (Exception ex) { System.out.println("startOpenOffice:" + ex.getMessage()); } } catch (BootstrapException e) { e.printStackTrace(); } finally { System.exit(0); } } }
fails also on 4.0.0
(In reply to mjmb from comment #13) > tableColumnSeperator works inconsistent. tested version aoo 3.4.1 linux i686 > > below program show correctly changed tables with 2,4,5,8 and 16 columns > while tables with 3,6,7,9,10-15 columns do not: [skipping code] Code with so many shouldn't be included in a comment, but added to the bug as an attachment.
Created attachment 81448 [details] program showing failure of tableColumnSeperators
still exists in 4.1.3
I can confirm this Bug. The tablecolumnseparators can be set by a macro in OpenOffice Writer itself. The same way using -in my case VFP- by API/COM does not work. Using Xray I can see that the properties of TabbelColumnsaparators are not modified using VFP. I think the problem exists only in the commnication COM/API.
Hi, I looked at this example, translated it and it still does not work. https://wiki.openoffice.org/wiki/API/Samples/Java/Writer/TextTable Does this example work in Java or other languages?
fails in 4.1.6
(In reply to Jan Flikweert from comment #19) > Hi, > > I looked at this example, translated it and it still does not work. > > https://wiki.openoffice.org/wiki/API/Samples/Java/Writer/TextTable > > Does this example work in Java or other languages? No it does not. It uses 10 columns and that's a failing amount. See my previous remarks. It seems to be an initial setup problem. Workaround is to create a 'good' table first, join columns to get the desired amount. Tablecolumnseperators will than work fine.
fails in 4.1.15