sw/qa/extras/uiwriter/data/tdf142700.fodt     |   40 +++++++++++++++++++++++
 sw/qa/extras/uiwriter/uiwriter2.cxx           |   44 ++++++++++++++++++++++++++
 sw/source/core/doc/DocumentRedlineManager.cxx |    4 ++
 sw/source/core/inc/frame.hxx                  |    1 
 sw/source/core/layout/paintfrm.cxx            |   15 ++++++++
 5 files changed, 104 insertions(+)

New commits:
commit ad16387653f8e0d310a5eb44bce9fa8df27253c8
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Mon Jun 28 15:49:37 2021 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Jun 29 09:32:19 2021 +0200

    tdf#142698 sw: fix reject of deleted images anchored to-char
    
    Strikethrough of deleted images wasn't removed by reject
    of the tracked deletion, if the image anchored to character
    wasn't in same text line as the deleted text.
    
    Follow-up to commit 1610eeef6f2312616fe5d3535475f27f7896bef8
    "tdf#142196 sw: crossing out images anchored to character".
    
    Change-Id: I9c7f742942bec90d4c5c65f1bc40a7923353560b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118030
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/qa/extras/uiwriter/data/tdf142700.fodt 
b/sw/qa/extras/uiwriter/data/tdf142700.fodt
new file mode 100644
index 000000000000..16064a644f52
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf142700.fodt
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+<office:styles>
+  <style:style style:name="Graphics" style:family="graphic">
+   <style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" 
svg:y="0cm" style:wrap="dynamic" style:number-wrapped-paragraphs="no-limit" 
style:wrap-contour="false" style:vertical-pos="top" 
style:vertical-rel="paragraph" style:horizontal-pos="center" 
style:horizontal-rel="paragraph"/>
+  </style:style>
+ </office:styles>
+ <office:automatic-styles>
+  <style:style style:name="fr1" style:family="graphic" 
style:parent-style-name="Graphics">
+   <style:graphic-properties style:wrap="parallel" 
style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" 
style:vertical-pos="from-top" style:vertical-rel="paragraph" 
style:horizontal-pos="from-left" style:horizontal-rel="paragraph" 
style:mirror="none" fo:clip="rect(0cm, 0cm, 0cm, 0cm)" draw:luminance="0%" 
draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" 
draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" 
draw:color-mode="standard" draw:wrap-influence-on-position="once-concurrent" 
loext:allow-overlap="true"/>
+  </style:style>
+  <style:style style:name="dp1" style:family="drawing-page">
+   <style:drawing-page-properties draw:background-size="full"/>
+  </style:style>
+ </office:automatic-styles>
+ <office:master-styles>
+  <style:master-page style:name="Standard" draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+  <office:text>
+   <text:tracked-changes text:track-changes="false">
+    <text:changed-region xml:id="ct94919822029600" text:id="ct94919822029600">
+     <text:deletion>
+      <office:change-info>
+       <dc:creator>X</dc:creator>
+       <dc:date>2021-05-07T17:32:23</dc:date>
+      </office:change-info>
+     </text:deletion>
+    </text:changed-region>
+   </text:tracked-changes>
+   <text:p text:style-name="Standard"><text:change-start 
text:change-id="ct94919822029600"/>Lorem <draw:frame draw:style-name="fr1" 
draw:name="Image1" text:anchor-type="char" svg:x="4.89cm" svg:y="0.499cm" 
svg:width="6.541cm" svg:height="3.32cm" draw:z-index="0"><draw:image 
draw:mime-type="image/png">
+      
<office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAAAmJLR0QA/4ePzL8AAAAJcEhZ
+       cwAACxMAAAsTAQCanBgAAAAHdElNRQflBQYKGR4LTuGQAAAACklEQVQI12M4DwAA0QDQfVbA
+       HQAAAABJRU5ErkJggg==
+      </office:binary-data>
+     </draw:image>
+    </draw:frame>ipsum <text:change-end 
text:change-id="ct94919822029600"/>dolor sit amet, consectetuer adipiscing 
elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar 
ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis 
urna.</text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 54a907c3e26e..73735854caa2 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -2401,6 +2401,50 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf142196)
     assertXPath(pXmlDoc2, "//line", 0);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf142700)
+{
+    SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf142700.fodt");
+
+    //turn on red-lining and show changes
+    pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | 
RedlineFlags::ShowDelete
+                                                      | 
RedlineFlags::ShowInsert);
+    CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+                           pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+    CPPUNIT_ASSERT_MESSAGE(
+        "redlines should be visible",
+        
IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+    // Dump the rendering of the first page as an XML file.
+    SwDocShell* pShell = pDoc->GetDocShell();
+    std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+    MetafileXmlDump dumper;
+
+    xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    // (2 lines = crossing out of the deleted image + 1 line for the
+    // vertical "changed line" indicator before the paragraph line)
+    assertXPath(pXmlDoc, "//line", 3);
+
+    // check line color
+    assertXPath(pXmlDoc, 
"/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/linecolor", 1);
+    // tdf#142128 This was NON_PRINTING_CHARACTER_COLOR (#268bd2)
+    assertXPath(
+        pXmlDoc,
+        
"/metafile/push[1]/push[1]/push[1]/push[3]/push[1]/push[1]/linecolor[@color='#268bd2']",
 0);
+
+    // reject deletion of the image
+    IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess());
+    rIDRA.AcceptAllRedline(false);
+
+    xMetaFile = pShell->GetPreviewMetaFile();
+    xmlDocUniquePtr pXmlDoc2 = dumpAndParse(dumper, *xMetaFile);
+
+    // no crossing out and vertical "changed line" indicator
+    // This was 2 (not removed strikethrough)
+    assertXPath(pXmlDoc2, "//line", 0);
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf139120)
 {
     SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf54819.fodt");
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index 2699b1818560..a8c8044c86c5 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -195,6 +195,8 @@ void UpdateFramesForAddDeleteRedline(SwDoc & rDoc, SwPaM 
const& rPam)
                 {
                     frames.push_back(pFrame);
                 }
+                // set anchored objects as deleted
+                pFrame->SetDrawObjsAsDeleted(true);
             }
             if (frames.empty())
             {
@@ -289,6 +291,8 @@ void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, SwPaM 
const& rPam)
                 {
                     frames.push_back(pFrame);
                 }
+                // set anchored objects as not deleted
+                pFrame->SetDrawObjsAsDeleted(false);
             }
             if (frames.empty())
             {
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index 02efa581ba7f..65936fb9bce3 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -562,6 +562,7 @@ public:
     void  RemoveFly( SwFlyFrame *pToRemove );
     const SwSortedObjs *GetDrawObjs() const { return m_pDrawObjs.get(); }
           SwSortedObjs *GetDrawObjs()       { return m_pDrawObjs.get(); }
+    void SetDrawObjsAsDeleted( bool bDeleted ); // change tracking of objects 
anchored to character
     // #i28701# - change purpose of method and adjust its name
     void InvalidateObjs( const bool _bNoInvaOfAsCharAnchoredObjs = true );
 
diff --git a/sw/source/core/layout/paintfrm.cxx 
b/sw/source/core/layout/paintfrm.cxx
index d8a293c54ca1..c42afecddd77 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3965,6 +3965,21 @@ private:
 
 }
 
+// set strikethrough for deleted objects anchored to character
+void SwFrame::SetDrawObjsAsDeleted( bool bDeleted )
+{
+    if ( SwSortedObjs *pObjs = GetDrawObjs() )
+    {
+        for (SwAnchoredObject* pAnchoredObj : *pObjs)
+        {
+            if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
+            {
+                pFly->SetDeleted(bDeleted);
+            }
+        }
+    }
+}
+
 void SwFlyFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const) const
 {
     //optimize thumbnail generation and store procedure to improve odt saving 
performance, #i120030#
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to