diff options
author | László Németh <nemeth@numbertext.org> | 2021-08-16 14:42:01 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-08-17 16:36:41 +0200 |
commit | 15f340f35cd9dc635d0507ca7de9d11227ae9922 (patch) | |
tree | 1bd176a83ce5e8bb45cb3b2b7d60f76c09a0d366 /sw | |
parent | 77ed538bcc9ff445462fd8c4c1c055b6e8dd2ce4 (diff) |
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 <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf126206.docx | bin | 0 -> 12509 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 35 |
3 files changed, 43 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf126206.docx b/sw/qa/extras/ooxmlexport/data/tdf126206.docx Binary files differnew file mode 100644 index 000000000000..166125e7a738 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf126206.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 431d5d71753d..92a841b826f8 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 5dd987b252a9..c447bf7a60c8 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -180,7 +180,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; @@ -2756,6 +2756,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(); @@ -3172,6 +3177,34 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData) : 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; |