sw/qa/extras/ooxmlexport/data/tblppr-shape.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 8 ++++++++ writerfilter/source/dmapper/DomainMapperTableManager.cxx | 9 ++++++++- writerfilter/source/dmapper/DomainMapperTableManager.hxx | 4 ++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 1 + 5 files changed, 21 insertions(+), 1 deletion(-)
New commits: commit c1e1757cdab6e61b94244761227b0a1f112e6b0c Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Nov 28 18:11:23 2014 +0100 DOCX import: ignore <w:tblpPr> in shape text Floating tables are kind of anchored objects, which are not supported in shape text by Word, so we should ignore their flotation on import as well. Note that there is no need for a setIsInShape(false) in PopShapeContext() as we pop the whole table manager from the stack anyway. Change-Id: Ie9e88d2c83c0c34a01922e6e89f69f6089585b4b diff --git a/sw/qa/extras/ooxmlexport/data/tblppr-shape.docx b/sw/qa/extras/ooxmlexport/data/tblppr-shape.docx new file mode 100644 index 0000000..470bce4 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tblppr-shape.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index 26f521b..7d4f988 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -713,6 +713,14 @@ DECLARE_OOXMLEXPORT_TEST(testHeaderBorder, "header-border.docx") } } +DECLARE_OOXMLEXPORT_TEST(testTblpprShape, "tblppr-shape.docx") +{ + // Unhandled exception due to unexpected w:tblpPr resulted in not importing page size, either. + uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); + // This was 2000, page width wasn't large enough. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2540), getProperty<sal_Int32>(xPageStyle, "LeftMargin")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index 3a9153c..1085a94 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -53,6 +53,7 @@ DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) : m_nHeaderRepeat(0), m_nTableWidth(0), m_bOOXML( bOOXML ), + m_bIsInShape(false), m_aTmpPosition(), m_aTmpTableProperties(), m_bPushCurrentWidth(false), @@ -432,7 +433,8 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) case NS_ooxml::LN_CT_TblPrBase_tblpPr: { writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); - if (pProperties.get()) + // Ignore <w:tblpPr> in shape text, those tables should be always non-floating ones. + if (!m_bIsInShape && pProperties.get()) { TablePositionHandlerPtr pHandler = m_aTmpPosition.back(); if ( !pHandler ) @@ -512,6 +514,11 @@ TablePositionHandler* DomainMapperTableManager::getCurrentTableRealPosition() return nullptr; } +void DomainMapperTableManager::setIsInShape(bool bIsInShape) +{ + m_bIsInShape = bIsInShape; +} + void DomainMapperTableManager::startLevel( ) { DomainMapperTableManager_Base_t::startLevel( ); diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx index e810a89..65aecc7 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx @@ -47,6 +47,8 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t sal_Int32 m_nHeaderRepeat; //counter of repeated headers - if == -1 then the repeating stops sal_Int32 m_nTableWidth; //might be set directly or has to be calculated from the column positions bool m_bOOXML; + /// Are we in a shape (text append stack is not empty) or in the body document? + bool m_bIsInShape; OUString m_sTableStyleName; /// Grab-bag of table look attributes for preserving. comphelper::SequenceAsHashMap m_aTableLook; @@ -161,6 +163,8 @@ public: return DomainMapperTableManager_Base_t::isInCell(); } + void setIsInShape(bool bIsInShape); + }; }} diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 462c449..1a1ccdc 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1961,6 +1961,7 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape uno::makeAny( true ) ); } m_bParaChanged = true; + getTableManager().setIsInShape(true); } catch ( const uno::Exception& e ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits