sw/qa/extras/ooxmlimport/data/table-btlr-center.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 9 +++++++ writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 17 +++++++++++++++ writerfilter/source/dmapper/DomainMapperTableManager.cxx | 7 ++++++ writerfilter/source/dmapper/PropertyIds.cxx | 1 writerfilter/source/dmapper/PropertyIds.hxx | 1 6 files changed, 35 insertions(+)
New commits: commit c3d745207dcf023b96edf1426048c8ff96189470 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Jul 2 17:33:03 2014 +0200 bnc#865381 DOCX import: handle w:jc=center inside w:textDirection=btLr Change-Id: I102c70429457515b34e74cb8e82e1417e6276d1d (cherry picked from commit 3325e0f206ce864730468c3556ce06760042c157) Reviewed-on: https://gerrit.libreoffice.org/10049 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/sw/qa/extras/ooxmlimport/data/table-btlr-center.docx b/sw/qa/extras/ooxmlimport/data/table-btlr-center.docx new file mode 100644 index 0000000..79cb53e Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/table-btlr-center.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 88acef8..26e0e36 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -1703,6 +1703,15 @@ DECLARE_OOXMLIMPORT_TEST(testFootnote, "footnote.docx") CPPUNIT_ASSERT(aFootnote.endsWith("bar")); } +DECLARE_OOXMLIMPORT_TEST(testTableBtlrCenter, "table-btlr-center.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); + // Cell vertical alignment was NONE, should be CENTER. + CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER, getProperty<sal_Int16>(xTable->getCellByName("A2"), "VertOrient")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index 0827cc9..7b8d9cd 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -28,6 +28,8 @@ #include <com/sun/star/text/HoriOrientation.hpp> #include <com/sun/star/text/RelOrientation.hpp> #include <com/sun/star/text/SizeType.hpp> +#include <com/sun/star/text/VertOrientation.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> #include <dmapperLoggers.hxx> #ifdef DEBUG_DMAPPER_TABLE_HANDLER @@ -715,6 +717,21 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl } aCellIterator->get()->erase(PROP_HORIZONTAL_MERGE); } + + // Cell direction is not an UNO Property, either. + const PropertyMap::const_iterator aCellDirectionIter = aCellIterator->get()->find(PROP_CELL_DIRECTION); + if (aCellDirectionIter != aCellIterator->get()->end()) + { + if (aCellDirectionIter->second.getValue().get<sal_Int32>() == 3) + { + // btLr, so map ParagraphAdjust_CENTER to VertOrientation::CENTER. + uno::Reference<beans::XPropertySet> xPropertySet((*m_pTableSeq)[nRow][nCell][0], uno::UNO_QUERY); + if (xPropertySet->getPropertyValue("ParaAdjust").get<sal_Int16>() == style::ParagraphAdjust_CENTER) + aCellIterator->get()->Insert(PROP_VERT_ORIENT, uno::makeAny(text::VertOrientation::CENTER)); + } + aCellIterator->get()->erase(PROP_CELL_DIRECTION); + } + pSingleCellProperties[nCell] = aCellIterator->get()->GetPropertyValues(); #ifdef DEBUG_DMAPPER_TABLE_HANDLER dmapper_logger->endElement(); diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index 764a065..6a95be3 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -324,6 +324,13 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) case NS_ooxml::LN_CT_TcPrBase_textDirection: { TablePropertyMapPtr pPropMap( new TablePropertyMap ); + + // Remember the cell direction, so later in + // DomainMapperTableHandler::endTableGetCellProperties() can we + // handle the combination of the cell direction and paragraph + // alignment as necessary. + pPropMap->Insert(PROP_CELL_DIRECTION, uno::Any(sal_Int32(3))); + bool bInsertCellProps = true; switch ( nIntValue ) { diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index bacbcd3..d693ddb 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -346,6 +346,7 @@ const OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const case PROP_FOOTNOTE_LINE_RELATIVE_WIDTH: sName = "FootnoteLineRelativeWidth"; break; case PROP_HORIZONTAL_MERGE: sName = "HorizontalMerge"; break; case PROP_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING : sName = "ApplyParagraphMarkFormatToNumbering"; break; + case PROP_CELL_DIRECTION: sName = "CellDirection"; break; } ::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt = m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName )); diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx index a4e3621..1f63179 100644 --- a/writerfilter/source/dmapper/PropertyIds.hxx +++ b/writerfilter/source/dmapper/PropertyIds.hxx @@ -317,6 +317,7 @@ enum PropertyIds ,PROP_PARA_BOTTOM_MARGIN_AFTER_AUTO_SPACING ,PROP_HORIZONTAL_MERGE ,PROP_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING + ,PROP_CELL_DIRECTION }; struct PropertyNameSupplier_Impl; class PropertyNameSupplier _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits