diff options
author | László Németh <nemeth@numbertext.org> | 2019-09-26 12:43:02 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-03-05 10:58:53 +0100 |
commit | 7792420601789c092c7a26262451b386a096d68b (patch) | |
tree | 8bd6bd1303315be0ad2927130f9f0a2d9059ab52 | |
parent | b110d14f4d7110ce4af2e938bde354b033615c88 (diff) |
tdf#81100 DOCX: keep "repeat table header" table style setting
during round trip by grab-bagging //tblStylePr/trPr/tblHeader.
(cherry picked from commit 93ebf6a85f699e0594e05374ac37f8e582292d4f)
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
sw/source/filter/ww8/docxtablestyleexport.cxx
Change-Id: Id9d3150ca48031791aeda19c126bc4d4ac16fb8f
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf81100.docx | bin | 0 -> 19329 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxtablestyleexport.cxx | 23 | ||||
-rw-r--r-- | writerfilter/source/dmapper/StyleSheetTable.cxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/TblStylePrHandler.cxx | 11 |
5 files changed, 43 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf81100.docx b/sw/qa/extras/ooxmlexport/data/tdf81100.docx Binary files differnew file mode 100644 index 000000000000..61038d190c7e --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf81100.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 018aa8ccfcb8..0736171dcfb0 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -931,6 +931,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf58944RepeatingTableHeader, "tdf58944-repeating-t parseDump("/root/page[2]/body/tab/row[2]/cell[1]/txt/text()")); } +DECLARE_OOXMLEXPORT_TEST(testTdf81100, "tdf81100.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/styles.xml"); + if (!pXmlDoc) + return; + // keep "repeat table header" setting of table styles + assertXPath(pXmlDoc, "/w:styles/w:style/w:tblStylePr/w:trPr/w:tblHeader", 4); +} + DECLARE_OOXMLEXPORT_TEST(testTdf121597TrackedDeletionOfMultipleParagraphs, "tdf121597.odt") { xmlDocPtr pXmlDoc = parseExport("word/document.xml"); diff --git a/sw/source/filter/ww8/docxtablestyleexport.cxx b/sw/source/filter/ww8/docxtablestyleexport.cxx index 3a48ebd2f76a..a23b24215f1b 100644 --- a/sw/source/filter/ww8/docxtablestyleexport.cxx +++ b/sw/source/filter/ww8/docxtablestyleexport.cxx @@ -61,6 +61,8 @@ public: void tableStylePSpacing(uno::Sequence<beans::PropertyValue>& rSpacing); /// Export of w:tblPr. void tableStyleTablePr(uno::Sequence<beans::PropertyValue>& rTablePr); + /// Export of w:trPr. + void tableStyleTrPr(const uno::Sequence<beans::PropertyValue>& rTrPr); /// Export of w:tcPr. void tableStyleTcPr(uno::Sequence<beans::PropertyValue>& rTcPr); /// Export of w:tcBorders (and w:tblBorders). @@ -552,6 +554,22 @@ void DocxTableStyleExport::Impl::tableStyleTablePr(uno::Sequence<beans::Property m_pSerializer->endElementNS(XML_w, XML_tblPr); } +void DocxTableStyleExport::Impl::tableStyleTrPr(const uno::Sequence<beans::PropertyValue>& rTrPr) +{ + if (!rTrPr.hasElements()) + return; + + m_pSerializer->startElementNS(XML_w, XML_trPr, FSEND); + + for (const auto& rProp : rTrPr) + { + if (rProp.Name == "tblHeader") + m_pSerializer->singleElementNS(XML_w, XML_tblHeader, FSEND); + } + + m_pSerializer->endElementNS(XML_w, XML_trPr); +} + void DocxTableStyleExport::Impl::tableStyleTcPr(uno::Sequence<beans::PropertyValue>& rTcPr) { if (!rTcPr.hasElements()) @@ -589,7 +607,7 @@ void DocxTableStyleExport::Impl::tableStyleTableStylePr( return; OUString aType; - uno::Sequence<beans::PropertyValue> aPPr, aRPr, aTablePr, aTcPr; + uno::Sequence<beans::PropertyValue> aPPr, aRPr, aTablePr, aTrPr, aTcPr; for (sal_Int32 i = 0; i < rTableStylePr.getLength(); ++i) { if (rTableStylePr[i].Name == "type") @@ -600,6 +618,8 @@ void DocxTableStyleExport::Impl::tableStyleTableStylePr( aRPr = rTableStylePr[i].Value.get<uno::Sequence<beans::PropertyValue>>(); else if (rTableStylePr[i].Name == "tblPr") aTablePr = rTableStylePr[i].Value.get<uno::Sequence<beans::PropertyValue>>(); + else if (rTableStylePr[i].Name == "trPr") + aTrPr = rTableStylePr[i].Value.get<uno::Sequence<beans::PropertyValue>>(); else if (rTableStylePr[i].Name == "tcPr") aTcPr = rTableStylePr[i].Value.get<uno::Sequence<beans::PropertyValue>>(); } @@ -616,6 +636,7 @@ void DocxTableStyleExport::Impl::tableStyleTableStylePr( // Even if we have an empty container, write it out, as Word does. m_pSerializer->singleElementNS(XML_w, XML_tblPr, FSEND); } + tableStyleTrPr(aTrPr); tableStyleTcPr(aTcPr); m_pSerializer->endElementNS(XML_w, XML_tblStylePr); diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 2d19297ad80f..08145c98ad2f 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -582,7 +582,7 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm) pProperties->resolve(*pTblStylePrHandler); StyleSheetEntry* pEntry = m_pImpl->m_pCurrentEntry.get(); TableStyleSheetEntry& rTableEntry = dynamic_cast<TableStyleSheetEntry&>(*pEntry); - rTableEntry.AppendInteropGrabBag(pTblStylePrHandler->getInteropGrabBag("tcPr")); + rTableEntry.AppendInteropGrabBag(pTblStylePrHandler->getInteropGrabBag((nSprmId == NS_ooxml::LN_CT_Style_tcPr) ? OUString("tcPr") : OUString("trPr"))); // This is a <w:tcPr> directly under <w:style>, so it affects the whole table. rTableEntry.pProperties->InsertProps(pTblStylePrHandler->getProperties()); diff --git a/writerfilter/source/dmapper/TblStylePrHandler.cxx b/writerfilter/source/dmapper/TblStylePrHandler.cxx index d2e5bb2054ce..cc4654d5de34 100644 --- a/writerfilter/source/dmapper/TblStylePrHandler.cxx +++ b/writerfilter/source/dmapper/TblStylePrHandler.cxx @@ -137,6 +137,7 @@ void TblStylePrHandler::lcl_sprm(Sprm & rSprm) bool bGrabBag = rSprm.getId() == NS_ooxml::LN_CT_PPrBase || rSprm.getId() == NS_ooxml::LN_EG_RPrBase || rSprm.getId() == NS_ooxml::LN_CT_TblPrBase || + rSprm.getId() == NS_ooxml::LN_CT_TrPrBase || rSprm.getId() == NS_ooxml::LN_CT_TcPrBase; if (bGrabBag) { @@ -151,12 +152,22 @@ void TblStylePrHandler::lcl_sprm(Sprm & rSprm) aSavedGrabBag.push_back(getInteropGrabBag("rPr")); else if (rSprm.getId() == NS_ooxml::LN_CT_TblPrBase) aSavedGrabBag.push_back(getInteropGrabBag("tblPr")); + else if (rSprm.getId() == NS_ooxml::LN_CT_TrPrBase) + aSavedGrabBag.push_back(getInteropGrabBag("trPr")); else if (rSprm.getId() == NS_ooxml::LN_CT_TcPrBase) aSavedGrabBag.push_back(getInteropGrabBag("tcPr")); std::swap(m_aInteropGrabBag, aSavedGrabBag); } } break; + case NS_ooxml::LN_CT_TrPrBase_tblHeader: + { + beans::PropertyValue aValue; + aValue.Name = "tblHeader"; + aValue.Value <<= true; + m_aInteropGrabBag.push_back(aValue); + } + break; default: // Tables specific properties have to handled here m_pTablePropsHandler->SetProperties( m_pProperties ); |