Bug 45644 - Inconsistent behavior of table.Borderline in Writer and Calc
Summary: Inconsistent behavior of table.Borderline in Writer and Calc
Status: RESOLVED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Extensions (show other bugs)
Version:
(earliest affected)
3.6.3.1 rc
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-05 03:23 UTC by Dietmar
Modified: 2016-09-19 16:48 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Basic macro containing some experiments with table borders (16.41 KB, application/vnd.oasis.opendocument.text)
2012-12-18 09:59 UTC, sasha.libreoffice
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dietmar 2012-02-05 03:23:06 UTC
see also https://issues.apache.org/ooo/show_bug.cgi?id=74826
the bug is still present in LibO 3.4.3
the bug has been transferred to Borderline2

I use an extension to assign borders to tables. Tables can be in WRITER and
CALC. Both use the structure com.sun.star.table.BorderLine, but the behavior is
different:
Take a Border with 2 lines, the first thicker than the other (e.g.
InnerLineWidth=35, OuterLineWidth=2, LineDistance=88).
Now assign this line to the bottom, left, top, right border of a cell in a
table.
In Writer: InnerLineWidth is allways thicker (35), OuterLineWidth always thin
(2).
In Calc: Top and left line width is always thicker(35), bottom and right thin
(2).

What to do:
- start writer or calc 
- (in writer create a table,) place the curser in a cell of a table
- start BorderLiner
- select a linestyle with 1 big and a small line (e.g. number 5) and width 5   (to easier see it)
- put focus on document
- press the keys ALT + 2 4 6 8
- this creates the border line around the cell
- note that it looks different in writer and in calc

- NB: the extension does not distinguish between tables in Calc and Writer,
nevertheless the result is different
Comment 1 sasha.libreoffice 2012-12-10 14:20:22 UTC
Thanks for bugreport
This problems still reproducible? For example in 3.6 version?
Comment 2 Dietmar 2012-12-11 20:27:51 UTC
just checked with 3.6.3.1, still there.

Using a line style with one thick and one thin line,
in Writer, the thin line is always on the inside of the cell,
in Calc it is always bottom and right.
Comment 3 sasha.libreoffice 2012-12-12 09:48:59 UTC
Thanks for additional testing. I have downloaded it from here:
http://extensions.openoffice.org/en/project/BorderLiner
And it written on Java. I hoped that it is on Basic. Therefore I can not debug it. 
May be author of this extension can somehow help?
Comment 4 Dietmar 2012-12-15 17:23:36 UTC
I am actually the author of the extension.
Here are the code snippets that are relevant:

In "Borders.java" in Function SetBordersSingleCell, e.g. for the bottom border which shows different behaviour:
    xTableProps.setPropertyValue("BottomBorder", sBorderWork);

sBorderWork is coming from GetBorderLine2:
           BL2.LineStyle = jBorderLiner.TB_SelectLS.GetLineStyle2();
           if (BL2.LineStyle == com.sun.star.table.BorderLineStyle.NONE) {
            	BL2.LineWidth = 0; }
           else { BL2.LineWidth = jBorderLiner.TB_SelectLW.GetLineWidth(); }
           BL2.Color = jBorderLiner.TB_SelectColor.GetColor();

up to here it is independant on the type of cell. The difference is just in xTableProps, which is coming from GetTheCell:
                                                                        // Calc
        if (xServiceInfo.supportsService("com.sun.star.sheet.SheetCell")  || 
            xServiceInfo.supportsService("com.sun.star.sheet.SheetCellRange")  || 
            xServiceInfo.supportsService("com.sun.star.sheet.SheetCellRanges")) {
            oCellRange = oSelection;

                                                // selected cells in text table
        else if (xServiceInfo.supportsService("com.sun.star.text.TextTableCursor")) {
            XTextViewCursorSupplier xTextViewCursorSupplier = 
                    (XTextViewCursorSupplier)UnoRuntime.queryInterface(
                    XTextViewCursorSupplier.class, xController);
            XTextViewCursor xTextViewCursor = xTextViewCursorSupplier.getViewCursor();
            XPropertySet xPropertySet =  (XPropertySet) UnoRuntime.queryInterface
                    (XPropertySet.class, xTextViewCursor); 
                    // NB: I might be in table (has value in "TextTable" or not
            if (sApplyTo == APPLYTO_TABLE) {            // get entire table 
                try {
                     Object oUnoObject = xPropertySet.getPropertyValue("TextTable");
                     oCellRange = (XTextTable) AnyConverter.toObject
                            (XTextTable.class, oUnoObject);
                } catch (com.sun.star.lang.IllegalArgumentException ex) {
                     ex.printStackTrace();
                } catch (UnknownPropertyException ex) {
                     ex.printStackTrace();
                } catch (WrappedTargetException ex) {
                     ex.printStackTrace();
                }
            }
            else {                                    // get only selected cells
                XTextTableCursor xTextTableCursor =  (XTextTableCursor) 
                    UnoRuntime.queryInterface(XTextTableCursor.class, oSelection);
                String sSelectedRange = xTextTableCursor.getRangeName(); // cells that are selected  
                        // NB: I might be in table (has value in "TextTable" or not
                try {
                    Object oUnoObject = xPropertySet.getPropertyValue("TextTable");
                    XTextTable xTextTable = (XTextTable) AnyConverter.toObject
                        (XTextTable.class, oUnoObject);
                     if (sSelectedRange.indexOf(":") < 0) { // single cell
                        oCellRange = xTextTable.getCellByName(sSelectedRange);    
                     }
                     else { // cell range
                        XCellRange xCellRange =  (XCellRange) 
                            UnoRuntime.queryInterface(XCellRange.class, xTextTable);
                        oCellRange = xCellRange.getCellRangeByName(sSelectedRange);    
                     }
                } catch (com.sun.star.lang.IllegalArgumentException ex) {
                     ex.printStackTrace();
                } catch (UnknownPropertyException ex) {
                     ex.printStackTrace();
                } catch (WrappedTargetException ex) {
                     ex.printStackTrace();
                }
            }
        }

Bottom line: no difference in applying the border style to text table cells and calc cells, but different results.

Hope this helps a bit.
Maybe you can try to reproduce in Basic, should be the same:
- assign a bottom border to a cell in calc,
- assign a bottom border to a cell in a text table.
Comment 5 sasha.libreoffice 2012-12-18 09:59:52 UTC
Created attachment 71717 [details]
Basic macro containing some experiments with table borders

I have done some experiments with table borders with Basic. In my case borders not work as expected. I do not know if it is bug in table or I working with borders in tables incorrectly.
Comment 6 Michael Meeks 2013-11-21 15:51:32 UTC
Calc cells and writer tables are different pieces of functionality.
I'd personally be surprised if they were visually identical when accessed like this programatically. Can you be more specific on your expectation ?
Comment 7 Robinson Tryon (qubit) 2013-11-21 18:06:50 UTC
(In reply to comment #6)
> ...Can you be more specific on your expectation ?

Status -> NEEDINFO
Comment 8 Dietmar 2013-11-24 12:28:56 UTC
(In reply to comment #6)
> Calc cells and writer tables are different pieces of functionality.
> I'd personally be surprised if they were visually identical when accessed
> like this programatically. Can you be more specific on your expectation ?

Well, they both respond to the command "BorderLineStyle", so programmatically the tables for Calc and Writer are the same.
Also, the characteristic "InnerLineWidth" is in reality the OuterLineWidth in Writer for a line at the bottom of a cell, just for a line at the top it is inner.

Anyway, changing this would probably involve too many changes in the code of LO and there is the new linestyle which sort of wraps this issue. Also developers obviously got used to it, so if you close with "wont fix", I don't mind.
Comment 9 Jean-Baptiste Faure 2014-01-02 22:13:46 UTC
(In reply to comment #8)
> [...]
> Anyway, changing this would probably involve too many changes in the code of
> LO and there is the new linestyle which sort of wraps this issue. Also
> developers obviously got used to it, so if you close with "wont fix", I
> don't mind.

Ok, closing as WontFix.
Please, feel free to reopen if I am wrong.

Best regards. JBF
Comment 10 Robinson Tryon (qubit) 2015-12-18 10:31:31 UTC Comment hidden (obsolete)
Comment 11 Xisco Faulí 2016-09-19 16:48:16 UTC Comment hidden (obsolete)