Kaydet (Commit) c1e1757c authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst b2d3f9b5
......@@ -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: */
......@@ -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( );
......
......@@ -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);
};
}}
......
......@@ -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 )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment