summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-02-03 17:21:32 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-02-04 13:38:27 +0100
commit60d097b1672bc4773ae90efc2e3250c9d6176f45 (patch)
treeaf0651405c571bf295ffe8da27f60a41b5863f02
parent8289795cfe2cbc22571be6408ec0018808b18213 (diff)
DOCX export: fix table style config handling wrt nested tables
The bugdoc had 2 tables: both using the TableGrid table style, but one had a direct formatting to disable all borders. The second was in the A1 cell of the first, and given that the table style config state was not separated for nested tables, the border settings of the inner table affected the settings of the later cells of the outer table. (cherry picked from commit 2d87b09e6e675dd593e26cb266deb4ea91f0e7a7) Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport14.cxx Change-Id: Ie7897bc661d9f47ca9f5c1b3ed1c439ef0406037 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87966 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sw/qa/extras/ooxmlexport/data/table-style-conf-nested.docxbin0 -> 13167 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport13.cxx25
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx21
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx2
4 files changed, 39 insertions, 9 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/table-style-conf-nested.docx b/sw/qa/extras/ooxmlexport/data/table-style-conf-nested.docx
new file mode 100644
index 000000000000..e35612addc1b
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/table-style-conf-nested.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 2026124121f4..dcb0f4703cb6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -30,10 +30,12 @@
#include <editsh.hxx>
#include <frmatr.hxx>
+char const DATA_DIRECTORY[] = "/sw/qa/extras/ooxmlexport/data/";
+
class Test : public SwModelTestBase
{
public:
- Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
+ Test() : SwModelTestBase(DATA_DIRECTORY, "Office Open XML Text") {}
protected:
/**
@@ -456,6 +458,27 @@ CPPUNIT_TEST_FIXTURE(SwModelTestBase, testUserField)
assertXPath(pXmlDoc, "//w:docVars/w:docVar", "val", "bar");
}
+CPPUNIT_TEST_FIXTURE(SwModelTestBase, testTableStyleConfNested)
+{
+ // Create the doc model.
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "table-style-conf-nested.docx";
+ loadURL(aURL, nullptr);
+
+ // Export to docx.
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("Office Open XML Text");
+ xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+ validate(maTempFile.GetFileName(), test::OOXML);
+ mbExported = true;
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ CPPUNIT_ASSERT(pXmlDoc);
+ // Without the accompanying fix in place, this test would have failed, as the custom table cell
+ // border properties were lost, so the outer A2 cell started to have borders, not present in the
+ // doc model.
+ assertXPath(pXmlDoc, "//w:body/w:tbl/w:tr/w:tc[2]/w:tcPr/w:tcBorders/w:top", "val", "nil");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 8ea9ec639f2d..a8c2c08fcfe1 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3558,7 +3558,8 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point
const SvxBoxItem& rDefaultBox = (*tableFirstCells.rbegin())->getTableBox( )->GetFrameFormat( )->GetBox( );
{
// The cell borders
- impl_borders( m_pSerializer, rBox, lcl_getTableCellBorderOptions(bEcma), m_aTableStyleConf );
+ impl_borders(m_pSerializer, rBox, lcl_getTableCellBorderOptions(bEcma),
+ m_aTableStyleConfs.back());
}
TableBackgrounds( pTableTextNodeInfoInner );
@@ -3597,6 +3598,8 @@ void DocxAttributeOutput::InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t
void DocxAttributeOutput::StartTable( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner )
{
+ m_aTableStyleConfs.push_back({});
+
// In case any paragraph SDT's are open, close them here.
EndParaSdtBlock();
@@ -3630,7 +3633,7 @@ void DocxAttributeOutput::EndTable()
// Cleans the table helper
m_xTableWrt.reset(nullptr);
- m_aTableStyleConf.clear();
+ m_aTableStyleConfs.pop_back();
}
void DocxAttributeOutput::StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t const & pTableTextNodeInfoInner )
@@ -3863,7 +3866,8 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
// We should clear the TableStyle map. In case of Table inside multiple tables it contains the
// table border style of the previous table.
- m_aTableStyleConf.clear();
+ std::map<SvxBoxItemLine, css::table::BorderLine2>& rTableStyleConf = m_aTableStyleConfs.back();
+ rTableStyleConf.clear();
// Extract properties from grab bag
for( const auto & rGrabBagElement : aGrabBag )
@@ -3876,13 +3880,16 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
FSEND );
}
else if( rGrabBagElement.first == "TableStyleTopBorder" )
- m_aTableStyleConf[ SvxBoxItemLine::TOP ] = rGrabBagElement.second.get<table::BorderLine2>();
+ rTableStyleConf[SvxBoxItemLine::TOP] = rGrabBagElement.second.get<table::BorderLine2>();
else if( rGrabBagElement.first == "TableStyleBottomBorder" )
- m_aTableStyleConf[ SvxBoxItemLine::BOTTOM ] = rGrabBagElement.second.get<table::BorderLine2>();
+ rTableStyleConf[SvxBoxItemLine::BOTTOM]
+ = rGrabBagElement.second.get<table::BorderLine2>();
else if( rGrabBagElement.first == "TableStyleLeftBorder" )
- m_aTableStyleConf[ SvxBoxItemLine::LEFT ] = rGrabBagElement.second.get<table::BorderLine2>();
+ rTableStyleConf[SvxBoxItemLine::LEFT]
+ = rGrabBagElement.second.get<table::BorderLine2>();
else if( rGrabBagElement.first == "TableStyleRightBorder" )
- m_aTableStyleConf[ SvxBoxItemLine::RIGHT ] = rGrabBagElement.second.get<table::BorderLine2>();
+ rTableStyleConf[SvxBoxItemLine::RIGHT]
+ = rGrabBagElement.second.get<table::BorderLine2>();
else if (rGrabBagElement.first == "TableStyleLook")
{
FastAttributeList* pAttributeList = FastSerializerHelper::createAttrList();
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 7bbb2554a96d..8994517184fa 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -945,7 +945,7 @@ private:
/// Currently paragraph SDT has a <w:id> child element.
bool m_bParagraphSdtHasId;
- std::map<SvxBoxItemLine, css::table::BorderLine2> m_aTableStyleConf;
+ std::vector<std::map<SvxBoxItemLine, css::table::BorderLine2>> m_aTableStyleConfs;
public:
DocxAttributeOutput( DocxExport &rExport, const ::sax_fastparser::FSHelperPtr& pSerializer, oox::drawingml::DrawingML* pDrawingML );