Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


I noticed a strange behaviour when using macros to insert rows into a text table that contains a nested table. Depending on the location of the nested table, adding a row into the outer table may actually add it to the inner table. I wrote a simple test to demonstrate the problem.

Two macros - test_insert_1 and test_insert_2 are identical except that they insert a child table into different cells of the outer table. When afterwards I try to insert a row into the outer table in one case I end up with the extra row in the inner table instead. Running the top level subroutine test_insert_row and calling either test_insert_1 or test_insert_2 should demonstrate the problem.

I am running
    Version 4.0.2.2 (Build ID: 400m0(Build:2)) on Ubuntu

Thanks



sub test_insert_row
    If ThisComponent.TextTables.hasByName("Table1") Then
ThisComponent.Text.removeTextContent(ThisComponent.TextTables.getByName("Table1"))
    End If

    test_insert_1  'This works as expected
    'test_insert_2  'This does not
End sub


sub test_insert_1
    Dim outer    As Object
    Dim inner    As Object
    Dim cell     As Object

    outer = ThisComponent.createInstance("com.sun.star.text.TextTable")
    inner = ThisComponent.createInstance("com.sun.star.text.TextTable")
ThisComponent.Text.getEnd().getText().insertTextContent(ThisComponent.Text.getEnd(), outer, False)

    cell = outer.getCellByPosition(1,1)
    cell.getText().insertTextContent(cell.getText().getEnd(), inner, False)

    MsgBox "Before insert " & outer.getRows().getCount()
    outer.getRows().insertByIndex(outer.getRows().getcount(), 1)
    MsgBox "After insert " & outer.getRows().getCount()
end sub

sub test_insert_2
    Dim outer    As Object
    Dim inner    As Object
    Dim cell     As Object

    outer = ThisComponent.createInstance("com.sun.star.text.TextTable")
    inner = ThisComponent.createInstance("com.sun.star.text.TextTable")
ThisComponent.Text.getEnd().getText().insertTextContent(ThisComponent.Text.getEnd(), outer, False)

    cell = outer.getCellByPosition(0,1)
    cell.getText().insertTextContent(cell.getText().getEnd(), inner, False)

    MsgBox "Before insert " & outer.getRows().getCount()
    outer.getRows().insertByIndex(outer.getRows().getcount(), 1)
    MsgBox "After insert " & outer.getRows().getCount()
end sub



--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.