Issue 55575 - setPropertyValue("TableColumnsSeparators",x) does not work
Summary: setPropertyValue("TableColumnsSeparators",x) does not work
Status: CONFIRMED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-06 18:12 UTC by bdiemer
Modified: 2019-04-12 09:48 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Own Porgramm Testing TableColumnSeperator (10.87 KB, application/vnd.oasis.opendocument.text)
2005-10-08 13:35 UTC, bdiemer
no flags Details
complex test case (10.04 KB, application/x-compressed)
2005-10-11 15:47 UTC, steffen.grund
no flags Details
program showing failure of tableColumnSeperators (6.79 KB, text/plain)
2013-09-04 12:21 UTC, Martin
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description bdiemer 2005-10-06 18:12:58 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
Comment 1 bdiemer 2005-10-06 18:14:38 UTC
Sorry I mentioned the Worng Version : I'm using version 1.1 by now.
Comment 2 steffen.grund 2005-10-07 09:06:45 UTC
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
Comment 3 steffen.grund 2005-10-07 09:08:03 UTC
.
Comment 4 bdiemer 2005-10-08 13:35:31 UTC
Created attachment 30232 [details]
Own Porgramm Testing TableColumnSeperator
Comment 5 bdiemer 2005-10-08 13:43:30 UTC
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
Comment 6 steffen.grund 2005-10-11 15:47:15 UTC
Created attachment 30319 [details]
complex test case
Comment 7 steffen.grund 2005-10-11 15:59:37 UTC
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 
Comment 8 steffen.grund 2005-10-11 16:04:55 UTC
Happens on all systems; set target; reassign to tl: one for you.
Comment 9 thomas.lange 2006-06-20 14:22:25 UTC
.
Comment 10 martho 2006-07-21 14:34:16 UTC
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.
Comment 11 thomas.lange 2007-12-03 13:59:15 UTC
.
Comment 12 thomas.lange 2008-01-14 13:59:17 UTC
No more issues accepted for OOo 2.4 unless there are serious problems.
Comment 13 Martin 2013-08-28 07:05:42 UTC
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);
        }
    }
}
Comment 14 Martin 2013-08-29 15:53:51 UTC
fails also on 4.0.0
Comment 15 Ariel Constenla-Haile 2013-08-29 16:00:19 UTC
(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.
Comment 16 Martin 2013-09-04 12:21:36 UTC
Created attachment 81448 [details]
program showing failure of tableColumnSeperators
Comment 17 Martin 2017-03-22 10:31:32 UTC
still exists in 4.1.3
Comment 18 Jan Flikweert 2017-10-05 12:26:53 UTC
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.
Comment 19 Jan Flikweert 2017-10-13 16:02:38 UTC
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?
Comment 20 Martin 2019-04-11 11:59:50 UTC
fails in 4.1.6
Comment 21 Martin 2019-04-12 09:48:47 UTC
(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.