[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 1 14:37:27 UTC 2019


 sw/qa/extras/ooxmlexport/data/tdf81100.docx       |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx        |    8 ++++++++
 sw/source/filter/ww8/docxtablestyleexport.cxx     |   22 ++++++++++++++++++++++
 writerfilter/source/dmapper/StyleSheetTable.cxx   |    2 +-
 writerfilter/source/dmapper/TblStylePrHandler.cxx |   11 +++++++++++
 5 files changed, 42 insertions(+), 1 deletion(-)

New commits:
commit 93ebf6a85f699e0594e05374ac37f8e582292d4f
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Thu Sep 26 12:43:02 2019 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Tue Oct 1 16:36:33 2019 +0200

    tdf#81100 DOCX: keep "repeat table header" table style setting
    
    during round trip by grab-bagging //tblStylePr/trPr/tblHeader.
    
    Change-Id: Id9d3150ca48031791aeda19c126bc4d4ac16fb8f
    Reviewed-on: https://gerrit.libreoffice.org/79597
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Tested-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf81100.docx b/sw/qa/extras/ooxmlexport/data/tdf81100.docx
new file mode 100644
index 000000000000..61038d190c7e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf81100.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 953f6d3de38b..47d5500a76f4 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -968,6 +968,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf58944RepeatingTableHeader, "tdf58944-repeating-t
                          parseDump("/root/page[2]/body/tab/row[2]/cell[1]/txt/text()"));
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf81100, "tdf81100.docx")
+{
+    xmlDocPtr pXmlDoc = parseExport("word/styles.xml");
+    CPPUNIT_ASSERT(pXmlDoc);
+    // keep "repeat table header" setting of table styles
+    assertXPath(pXmlDoc, "/w:styles/w:style/w:tblStylePr/w:trPr/w:tblHeader", 4);
+}
+
 DECLARE_OOXMLEXPORT_EXPORTONLY_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 050da668447c..b67151ed204b 100644
--- a/sw/source/filter/ww8/docxtablestyleexport.cxx
+++ b/sw/source/filter/ww8/docxtablestyleexport.cxx
@@ -66,6 +66,8 @@ public:
     void tableStylePSpacing(const uno::Sequence<beans::PropertyValue>& rSpacing);
     /// Export of w:tblPr.
     void tableStyleTablePr(const uno::Sequence<beans::PropertyValue>& rTablePr);
+    /// Export of w:trPr.
+    void tableStyleTrPr(const uno::Sequence<beans::PropertyValue>& rTrPr);
     /// Export of w:tcPr.
     void tableStyleTcPr(const uno::Sequence<beans::PropertyValue>& rTcPr);
     /// Export of w:tcBorders (and w:tblBorders).
@@ -551,6 +553,22 @@ void DocxTableStyleExport::Impl::tableStyleTablePr(
     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);
+
+    for (const auto& rProp : rTrPr)
+    {
+        if (rProp.Name == "tblHeader")
+            m_pSerializer->singleElementNS(XML_w, XML_tblHeader);
+    }
+
+    m_pSerializer->endElementNS(XML_w, XML_trPr);
+}
+
 void DocxTableStyleExport::Impl::tableStyleTcPr(const uno::Sequence<beans::PropertyValue>& rTcPr)
 {
     if (!rTcPr.hasElements())
@@ -592,6 +610,7 @@ void DocxTableStyleExport::Impl::tableStyleTableStylePr(
     uno::Sequence<beans::PropertyValue> aPPr;
     uno::Sequence<beans::PropertyValue> aRPr;
     uno::Sequence<beans::PropertyValue> aTablePr;
+    uno::Sequence<beans::PropertyValue> aTrPr;
     uno::Sequence<beans::PropertyValue> aTcPr;
     for (const auto& rProp : rTableStylePr)
     {
@@ -603,6 +622,8 @@ void DocxTableStyleExport::Impl::tableStyleTableStylePr(
             aRPr = rProp.Value.get<uno::Sequence<beans::PropertyValue>>();
         else if (rProp.Name == "tblPr")
             aTablePr = rProp.Value.get<uno::Sequence<beans::PropertyValue>>();
+        else if (rProp.Name == "trPr")
+            aTrPr = rProp.Value.get<uno::Sequence<beans::PropertyValue>>();
         else if (rProp.Name == "tcPr")
             aTcPr = rProp.Value.get<uno::Sequence<beans::PropertyValue>>();
     }
@@ -618,6 +639,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);
     }
+    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 5dcc856ca564..4b305abf17c6 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -577,7 +577,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 92b5e53cc7ee..c47042f30b53 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 );


More information about the Libreoffice-commits mailing list