[Libreoffice-commits] core.git: sw/qa writerfilter/source

Miklos Vajna vmiklos at suse.cz
Wed Aug 28 07:15:50 PDT 2013


 sw/qa/extras/ooxmlimport/data/table-auto-nested.docx     |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                 |   13 +++++++++++++
 writerfilter/source/dmapper/DomainMapperTableManager.cxx |    9 +++++++++
 3 files changed, 22 insertions(+)

New commits:
commit 76d1ca523ddcf89cc269fe51c70e66066943ef5a
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Aug 28 15:27:07 2013 +0200

    bnc#816593 DOCX import: fix auto table width wrt nested tables
    
    The bugdoc has a table with a single cell, and also a nested table in
    that cell. Both tables have auto width. The problem was that the width
    of the outer table was too large.
    
    There is a trick in DomainMapperTableManager::startLevel() to get the
    cell widths at the correct level: do the same in
    DomainMapperTableManager::endLevel(), and that'll fix the table width
    problem. (Because with that, the outer table will correctly have access
    to its cell width.)
    
    Change-Id: Ib750f0475364fd7e47c445cb54f2df34f3af085d

diff --git a/sw/qa/extras/ooxmlimport/data/table-auto-nested.docx b/sw/qa/extras/ooxmlimport/data/table-auto-nested.docx
new file mode 100755
index 0000000..85f47db
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/table-auto-nested.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index f79167b..3c13f05 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -127,6 +127,7 @@ public:
     void testFdo66474();
     void testGroupshapeRotation();
     void testBnc780044Spacing();
+    void testTableAutoNested();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -220,6 +221,7 @@ void Test::run()
         {"fdo66474.docx", &Test::testFdo66474},
         {"groupshape-rotation.docx", &Test::testGroupshapeRotation},
         {"bnc780044_spacing.docx", &Test::testBnc780044Spacing},
+        {"table-auto-nested.docx", &Test::testTableAutoNested},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1495,6 +1497,17 @@ void Test::testBnc780044Spacing()
     CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage());
 }
 
+void Test::testTableAutoNested()
+{
+    // This was 176, when compat option is not enabled, the auto paragraph bottom margin value was incorrect.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(494), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
+
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    // This was 115596, i.e. the width of the outer table was too large.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(23051), getProperty<sal_Int32>(xTables->getByIndex(1), "Width"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 80ffb48..ac75e07 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -483,7 +483,16 @@ void DomainMapperTableManager::endLevel( )
 {
     m_aTableGrid.pop_back( );
     m_aGridSpans.pop_back( );
+
+    // Do the same trick as in startLevel(): pop the value that was pushed too early.
+    boost::optional<sal_Int32> oCurrentWidth;
+    if (m_bPushCurrentWidth && !m_aCellWidths.empty() && !m_aCellWidths.back()->empty())
+        oCurrentWidth.reset(m_aCellWidths.back()->back());
     m_aCellWidths.pop_back( );
+    // And push it back to the right level.
+    if (oCurrentWidth)
+        m_aCellWidths.back()->push_back(*oCurrentWidth);
+
     m_nCell.pop_back( );
     m_nTableWidth = 0;
     m_nLayoutType = 0;


More information about the Libreoffice-commits mailing list