summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-09-19 13:52:37 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-09-19 14:54:38 +0200
commite85d8f9c5aadee9872ec6d7f33567f9ed84b478d (patch)
tree29719883b88b09052e5fc24fac1add6ebaaeed34
parent879bfcbf84fc7b73b5475d3f02e98184a2065dc5 (diff)
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
-rw-r--r--sw/qa/extras/ooxmlexport/data/table-alignment.docxbin0 -> 13187 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx10
-rw-r--r--writerfilter/source/dmapper/ConversionHelper.cxx12
-rw-r--r--writerfilter/source/dmapper/TablePropertiesHandler.cxx1
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx6
5 files changed, 22 insertions, 7 deletions
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 000000000000..e1efaaefd56b
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/table-alignment.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 15e0eaedbf52..953a036249ea 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 95d46f70d16e..d2dd41e462e5 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 6776a3a15407..1e3fa21a9926 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 2b22101b3b1d..2fdbccd9cb61 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;