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

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Thu May 6 14:19:45 UTC 2021


 sw/qa/extras/ooxmlexport/data/tdf128913.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx        |    8 +++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   32 ++++++++++++++++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    1 
 writerfilter/source/dmapper/PropertyMap.cxx       |    4 ++
 5 files changed, 45 insertions(+)

New commits:
commit ed7271d9d44fe1a0195ae669644f23c01b6960d8
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Wed May 5 21:33:28 2021 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Thu May 6 16:19:05 2021 +0200

    tdf#128913 DOCX: import track changes of inline images
    
    Deleted images were imported as not deleted part of
    the document. Both deleted and inserted images lost
    their change tracking.
    
    
    Change-Id: Ia273d307d01c5ea535889bc9951084e96cd7fc50
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115178
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf128913.docx b/sw/qa/extras/ooxmlexport/data/tdf128913.docx
new file mode 100644
index 000000000000..42cc2d75d3ff
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf128913.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 3e34dd10946f..0dd8614cf156 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -1361,6 +1361,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf121176, "tdf121176.docx")
     CPPUNIT_ASSERT_EQUAL( OUString( "must" ), getRun( getParagraph( 1 ), 2 )->getString());
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf128913, "tdf128913.docx")
+{
+    xmlDocUniquePtr pXmlDoc = parseExport();
+    // w:ins and w:del are imported correctly, if they contain only inline images
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:ins/w:r/w:drawing/wp:inline/a:graphic");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:del/w:r/w:drawing/wp:inline/a:graphic");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf123054, "tdf123054.docx")
 {
     CPPUNIT_ASSERT_EQUAL(OUString("No Spacing"),
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index b0ef95e0a785..863526d814fd 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1834,6 +1834,24 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
                         }
                     }
 
+                    // apply redlines for inline images
+                    if (IsParaWithInlineObject())
+                    {
+                        for (const auto& rAnchored : rAppendContext.m_aAnchoredObjects)
+                        {
+                            // process only inline objects with redlining
+                            if (!rAnchored.m_xRedlineForInline)
+                                continue;
+
+                            // select the inline image and set its redline
+                            auto xAnchorRange = rAnchored.m_xAnchoredObject->getAnchor();
+                            uno::Reference< text::XTextCursor > xCursorOnImage =
+                                    xAnchorRange->getText()->createTextCursorByRange(xAnchorRange);
+                            xCursorOnImage->goRight(1, true);
+                            CreateRedline( xCursorOnImage, rAnchored.m_xRedlineForInline );
+                        }
+                    }
+
                     xTextRange = xTextAppend->finishParagraph( comphelper::containerToSequence(aProperties) );
                     m_xPreviousParagraph.set(xTextRange, uno::UNO_QUERY);
 
@@ -7060,7 +7078,21 @@ void  DomainMapper_Impl::ImportGraphic(const writerfilter::Reference< Properties
             m_aTextAppendStack.top().m_aAnchoredObjects.push_back(aInfo);
         }
         else if (eGraphicImportType == IMPORT_AS_DETECTED_INLINE)
+        {
             m_bParaWithInlineObject = true;
+
+            // store inline images with track changes, because the anchor point
+            // to set redlining is not available yet
+            if (!m_aTextAppendStack.empty() && !m_aRedlines.top().empty() )
+            {
+                // Remember this object is anchored to the current paragraph.
+                AnchoredObjectInfo aInfo;
+                aInfo.m_xAnchoredObject = xTextContent;
+                aInfo.m_xRedlineForInline = m_aRedlines.top().back();
+                m_aTextAppendStack.top().m_aAnchoredObjects.push_back(aInfo);
+            }
+
+        }
     }
 
     // Clear the reference, so in case the embedded object is inside a
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index c12d75e201fa..99d266968c72 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -420,6 +420,7 @@ struct AnchoredObjectInfo
 {
     css::uno::Reference<css::text::XTextContent> m_xAnchoredObject;
     sal_Int32 m_nLeftMargin = 0;
+    RedlineParamsPtr m_xRedlineForInline;
 };
 
 /// Stores info about objects anchored to a given paragraph.
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index cc556ddc6330..9b4c819e35cb 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1275,6 +1275,10 @@ void SectionPropertyMap::HandleIncreasedAnchoredObjectSpacing(DomainMapper_Impl&
         sal_Int32 nOpaqueCount = 0;
         for (const auto& rAnchored : rAnchor.m_aAnchoredObjects)
         {
+            // Ignore inline objects stored only for redlining.
+            if (rAnchored.m_xRedlineForInline)
+                continue;
+
             uno::Reference<beans::XPropertySet> xShape(rAnchored.m_xAnchoredObject, uno::UNO_QUERY);
             if (!xShape.is())
             {


More information about the Libreoffice-commits mailing list