[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sw/qa writerfilter/source

Michael Stahl mstahl at redhat.com
Wed Mar 12 03:49:36 PDT 2014


 sw/qa/extras/ooxmlimport/data/rhbz1075124.docx           |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                 |   16 ++++++++++
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |   24 +++++++--------
 writerfilter/source/dmapper/TablePropertiesHandler.cxx   |    4 +-
 4 files changed, 30 insertions(+), 14 deletions(-)

New commits:
commit 2e558f32ef79948858723b9781fbd388850b462b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Mar 11 22:36:35 2014 +0100

    rhbz#1075124: writerfilter: fix tables with negative left margin
    
    SvxBoxItem::nLeftDist is unsigned; the bugdoc sets a very large value
    due to wrap-around which causes the table content not to be displayed.
    
    DomainMapperTableHandler::endTableGetTableStyle() tweaks the
    rInfo.nLeftBorderDistance by adding half the border line width to it,
    which makes it positive; at that point the value has already been used
    to init table::TableBorderDistances, so move that downward so it gets
    the positive value too.
    
    Change-Id: Ied2331b93f2e95845d7e8b2cc06e89e1ab24296e
    (cherry picked from commit 76aa23c59b4c81ea7b9d974a1a0a9e39c6bf8741)
    Reviewed-on: https://gerrit.libreoffice.org/8537
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/ooxmlimport/data/rhbz1075124.docx b/sw/qa/extras/ooxmlimport/data/rhbz1075124.docx
new file mode 100644
index 0000000..3b31701
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/rhbz1075124.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 5e161cc..1a2ee5f 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -40,6 +40,7 @@
 #include <com/sun/star/view/XFormLayerAccess.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/table/TableBorder2.hpp>
+#include <com/sun/star/table/TableBorderDistances.hpp>
 #include <com/sun/star/text/SizeType.hpp>
 #include <com/sun/star/xml/dom/XDocument.hpp>
 
@@ -201,6 +202,21 @@ DECLARE_OOXMLIMPORT_TEST(testRhbz988516, "rhbz988516.docx")
             getProperty<OUString>(getParagraph(3), "NumberingStyleName"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testRhbz1075124, "rhbz1075124.docx")
+{
+    // negative left margin on table wrapped around to 64k unsigned
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent,
+            uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(
+            xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(-243),
+            getProperty<sal_Int32>(xTables->getByIndex(0), "LeftMargin"));
+    table::TableBorderDistances dists(
+            getProperty<table::TableBorderDistances>(xTables->getByIndex(0),
+                "TableBorderDistances"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(26), dists.LeftDistance);
+}
+
 DECLARE_OOXMLIMPORT_TEST(testFdo49940, "fdo49940.docx")
 {
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 0827cc9..64289c4 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -406,18 +406,6 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
         m_aTableProperties->getValue( TablePropertyMap::CELL_MAR_BOTTOM,
                                      rInfo.nBottomBorderDistance );
 
-        table::TableBorderDistances aDistances;
-        aDistances.IsTopDistanceValid =
-        aDistances.IsBottomDistanceValid =
-        aDistances.IsLeftDistanceValid =
-        aDistances.IsRightDistanceValid = sal_True;
-        aDistances.TopDistance = static_cast<sal_Int16>( rInfo.nTopBorderDistance );
-        aDistances.BottomDistance = static_cast<sal_Int16>( rInfo.nBottomBorderDistance );
-        aDistances.LeftDistance = static_cast<sal_Int16>( rInfo.nLeftBorderDistance );
-        aDistances.RightDistance = static_cast<sal_Int16>( rInfo.nRightBorderDistance );
-
-        m_aTableProperties->Insert( PROP_TABLE_BORDER_DISTANCES, uno::makeAny( aDistances ) );
-
         if (rFrameProperties.hasElements())
             lcl_DecrementHoriOrientPosition(rFrameProperties, rInfo.nLeftBorderDistance);
 
@@ -477,6 +465,18 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
         lcl_debug_TableBorder(aTableBorder);
 #endif
 
+        table::TableBorderDistances aDistances;
+        aDistances.IsTopDistanceValid =
+        aDistances.IsBottomDistanceValid =
+        aDistances.IsLeftDistanceValid =
+        aDistances.IsRightDistanceValid = sal_True;
+        aDistances.TopDistance = static_cast<sal_Int16>( rInfo.nTopBorderDistance );
+        aDistances.BottomDistance = static_cast<sal_Int16>( rInfo.nBottomBorderDistance );
+        aDistances.LeftDistance = static_cast<sal_Int16>( rInfo.nLeftBorderDistance );
+        aDistances.RightDistance = static_cast<sal_Int16>( rInfo.nRightBorderDistance );
+
+        m_aTableProperties->Insert( PROP_TABLE_BORDER_DISTANCES, uno::makeAny( aDistances ) );
+
         // Table position in Office is computed in 2 different ways :
         // - top level tables: the goal is to have in-cell text starting at table indent pos (tblInd),
         //   so table's position depends on table's cells margin
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
index 6854f92..7a6eab6 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -307,8 +307,8 @@ namespace dmapper {
                    if (m_pCurrentInteropGrabBag)
                        m_pCurrentInteropGrabBag->push_back(pHandler->getInteropGrabBag());
                    TablePropertyMapPtr pTblIndMap(new TablePropertyMap);
-                   sal_uInt32 nTblInd = pHandler->getMeasureValue();
-                   pTblIndMap->setValue( TablePropertyMap::LEFT_MARGIN, nTblInd);
+                   sal_Int32 nTblInd = pHandler->getMeasureValue();
+                   pTblIndMap->setValue(TablePropertyMap::LEFT_MARGIN, nTblInd);
                    insertTableProps(pTblIndMap);
                }
            }


More information about the Libreoffice-commits mailing list