summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-05-05 21:33:28 +0200
committerBalazs Varga <varga.balazs3@nisz.hu>2021-10-21 09:43:38 +0200
commit8983620fb92dec7c0723d85049e29cd22721839b (patch)
treef22254e099ca09f1b59ea91c4b687f0618c96f88
parente0a4f7e28bbfc589ca66893a65845b05c57481e2 (diff)
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@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123949 Tested-by: Balazs Varga <varga.balazs3@nisz.hu> Reviewed-by: Balazs Varga <varga.balazs3@nisz.hu>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf128913.docxbin0 -> 10392 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx8
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx32
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx1
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx4
5 files changed, 45 insertions, 0 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf128913.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index e367d767a46b..bece2a74e229 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -1407,6 +1407,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_EXPORTONLY_TEST(testTdf142387, "tdf142387.docx")
{
xmlDocUniquePtr pXmlDoc = parseExport();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3ae632e3f1a2..b040dbbaa040 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1826,6 +1826,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);
@@ -6880,7 +6898,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 6d9e2a948c16..ab83c8da8943 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -407,6 +407,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 13cefc9694ea..081009bd46bc 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1248,6 +1248,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())
{