sw/qa/extras/ooxmlexport/data/tdf126206.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx   |    9 ++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   35 ++++++++++++++++++++++++++-
 3 files changed, 43 insertions(+), 1 deletion(-)

New commits:
commit b82cf004e3ccc41c54d40379009bd4f4f7411c43
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Mon Aug 16 14:42:01 2021 +0200
Commit:     Balazs Varga <varga.bala...@nisz.hu>
CommitDate: Thu Oct 21 13:26:23 2021 +0200

    tdf#143911 DOCX: export character formatting changes
    
    of text portions (instead of losing them completely,
    resulting missing rejection of tracked formatting changes
    later).
    
    Follow-up to commit 0115a77eb84afb0d820d8e23f45e49b30b82a8d3
    "tdf#50447 sw: track changes of character formatting" and
    commit 5322663f8234836a6a4aaaed025c158fd7e8b67a%5E%21
    "tdf#126206 DOCX: add rejection of character formatting changes".
    
    Change-Id: I7f00774875fe06d21865d9468fc1a63bd11d91ee
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120568
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit 15f340f35cd9dc635d0507ca7de9d11227ae9922)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123860
    Tested-by: Balazs Varga <varga.bala...@nisz.hu>
    Reviewed-by: Balazs Varga <varga.bala...@nisz.hu>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf126206.docx 
b/sw/qa/extras/ooxmlexport/data/tdf126206.docx
new file mode 100644
index 000000000000..166125e7a738
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf126206.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index dadb213a625b..a729642e05b5 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -1036,6 +1036,15 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf124491, 
"tdf124491.docx")
     assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/*/*/w:rPrChange", 0);
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf143911, "tdf126206.docx")
+{
+    xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+    // export format change of text portions
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:rPr/w:rPrChange");
+    // This was without tracked bold formatting
+    assertXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:r[2]/w:rPr/w:rPrChange/w:rPr/w:b");
+}
+
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf105485, "tdf105485.docx")
 {
     xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index be5c99f7f1c3..b8b2e13f3043 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -179,7 +179,7 @@ const sal_Int32 Tag_EndRun_1 = 9;
 const sal_Int32 Tag_EndRun_2 = 10;
 const sal_Int32 Tag_StartRunProperties = 11;
 const sal_Int32 Tag_InitCollectedRunProperties = 12;
-//static const sal_Int32 Tag_Redline_1 = 13;
+const sal_Int32 Tag_Redline_1 = 13;
 const sal_Int32 Tag_Redline_2 = 14;
 const sal_Int32 Tag_TableDefinition = 15;
 const sal_Int32 Tag_OutputFlyFrame = 16;
@@ -2721,6 +2721,11 @@ void DocxAttributeOutput::EndRunProperties( const 
SwRedlineData* pRedlineData )
 {
     // Call the 'Redline' function. This will add redline (change-tracking) 
information that regards to run properties.
     // This includes changes like 'Bold', 'Underline', 'Strikethrough' etc.
+
+    // If there is RedlineData present, call WriteCollectedRunProperties() for 
writing rPr before calling Redline().
+    // As there will be another rPr for redline and LO might mix both.
+    if(pRedlineData)
+        WriteCollectedRunProperties();
     Redline( pRedlineData );
 
     WriteCollectedRunProperties();
@@ -3121,6 +3126,34 @@ void DocxAttributeOutput::Redline( const SwRedlineData* 
pRedlineData)
                 FSNS( XML_w, XML_author ), rAuthor,
                 FSNS( XML_w, XML_date ), aDate );
 
+        // Check if there is any extra data stored in the redline object
+        if (pRedlineData->GetExtraData())
+        {
+            const SwRedlineExtraData* pExtraData = 
pRedlineData->GetExtraData();
+            const SwRedlineExtraData_FormatColl* pFormattingChanges = 
dynamic_cast<const SwRedlineExtraData_FormatColl*>(pExtraData);
+
+            // Check if the extra data is of type 'formatting changes'
+            if (pFormattingChanges)
+            {
+                 // Get the item set that holds all the changes properties
+                const SfxItemSet *pChangesSet = 
pFormattingChanges->GetItemSet();
+                if (pChangesSet)
+                {
+                    m_pSerializer->mark(Tag_Redline_1);
+
+                    m_pSerializer->startElementNS(XML_w, XML_rPr);
+
+                    // Output the redline item set
+                    if (pChangesSet)
+                        m_rExport.OutputItemSet( *pChangesSet, false, true, 
i18n::ScriptType::LATIN, m_rExport.m_bExportModeRTF );
+
+                    m_pSerializer->endElementNS( XML_w, XML_rPr );
+
+                    m_pSerializer->mergeTopMarks(Tag_Redline_1, 
sax_fastparser::MergeMarks::PREPEND);
+                }
+            }
+        }
+
         m_pSerializer->endElementNS( XML_w, XML_rPrChange );
         break;
 

Reply via email to