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

Miklos Vajna vmiklos at collabora.co.uk
Fri Sep 19 05:56:15 PDT 2014


 sw/qa/extras/ooxmlexport/data/table-alignment.docx     |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx               |   10 ++++++++++
 writerfilter/source/dmapper/ConversionHelper.cxx       |   12 +++++++++---
 writerfilter/source/dmapper/TablePropertiesHandler.cxx |    1 -
 writerfilter/source/rtftok/rtfdocumentimpl.cxx         |    6 +++---
 5 files changed, 22 insertions(+), 7 deletions(-)

New commits:
commit e85d8f9c5aadee9872ec6d7f33567f9ed84b478d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Sep 19 13:52:37 2014 +0200

    fdo#83728 DOCX import: fix table alignment
    
    Regression from 614b31615e69b527e669635245cf59faf9c9e2fc (Use
    NS_ooxml::LN_Value_ST_Jc_{right,end} constants, 2014-09-05), one more
    remnant from doctok.
    
    Change-Id: Ibab68eada337a3fe1bc919987a09a8b146f86ac9

diff --git a/sw/qa/extras/ooxmlexport/data/table-alignment.docx b/sw/qa/extras/ooxmlexport/data/table-alignment.docx
new file mode 100644
index 0000000..e1efaae
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/table-alignment.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 15e0eae..953a036 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -11,6 +11,7 @@
 
 #include <com/sun/star/awt/XBitmap.hpp>
 #include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
 #include <com/sun/star/text/XTextRangeCompare.hpp>
 
 #include <string>
@@ -232,6 +233,15 @@ DECLARE_OOXMLEXPORT_TEST(testDropdownInCell, "dropdown-in-cell.docx")
     CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextRangeCompare->compareRegionStarts(xAnchor, xCell));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTableAlignment, "table-alignment.docx")
+{
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+    // This was LEFT_AND_WIDTH, i.e. table alignment wasn't imported correctly.
+    CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::RIGHT, getProperty<sal_Int16>(xTable, "HoriOrient"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx
index 95d46f7..d2dd41e 100644
--- a/writerfilter/source/dmapper/ConversionHelper.cxx
+++ b/writerfilter/source/dmapper/ConversionHelper.cxx
@@ -252,9 +252,15 @@ sal_Int16 convertTableJustification( sal_Int32 nIntValue )
     sal_Int16 nOrient = text::HoriOrientation::LEFT_AND_WIDTH;
     switch( nIntValue )
     {
-        case 1 : nOrient = text::HoriOrientation::CENTER; break;
-        case 2 : nOrient = text::HoriOrientation::RIGHT; break;
-        case 0 :
+        case NS_ooxml::LN_Value_ST_Jc_center:
+            nOrient = text::HoriOrientation::CENTER;
+            break;
+        case NS_ooxml::LN_Value_ST_Jc_right:
+        case NS_ooxml::LN_Value_ST_Jc_end:
+            nOrient = text::HoriOrientation::RIGHT;
+            break;
+        case NS_ooxml::LN_Value_ST_Jc_left:
+        case NS_ooxml::LN_Value_ST_Jc_start:
         //no break
         default:;
 
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
index 6776a3a..1e3fa21 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -72,7 +72,6 @@ namespace dmapper {
             case NS_ooxml::LN_CT_TblPrBase_jc:
             case 0x5400: // sprmTJc
             {
-                //table justification 0: left, 1: center, 2: right
                 sal_Int16 nOrient = ConversionHelper::convertTableJustification( nIntValue );
                 TablePropertyMapPtr pTableMap( new TablePropertyMap );
                 pTableMap->setValue( TablePropertyMap::HORI_ORIENT, nOrient );
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 2b22101..2fdbccd 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2741,13 +2741,13 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
     switch (nKeyword)
     {
     case RTF_TRQL:
-        nParam = 0;
+        nParam = NS_ooxml::LN_Value_ST_Jc_left;
         break;
     case RTF_TRQC:
-        nParam = 1;
+        nParam = NS_ooxml::LN_Value_ST_Jc_center;
         break;
     case RTF_TRQR:
-        nParam = 2;
+        nParam = NS_ooxml::LN_Value_ST_Jc_right;
         break;
     default:
         break;


More information about the Libreoffice-commits mailing list