sw/source/core/text/porfly.cxx |   20 ++++++++++++++++++++
 sw/source/core/text/porfly.hxx |    5 ++++-
 sw/source/core/text/porlay.cxx |   35 +++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 1 deletion(-)

New commits:
commit d845b91bcc6eb885c55494d4d4fab4ec09577e1d
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Fri Apr 30 12:27:43 2021 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Fri Apr 30 15:45:22 2021 +0200

    tdf#78864 sw track changes: cross out deleted images
    
    Show Changes mode shows deleted images with crossing
    out to allow differentiate deleted and inserted images
    during change tracking.
    
    See also commit d6322bcedc197a654abc7d64bfea8cf570f123bf
    (tdf#59463 track changes: record deletion of images).
    
    Change-Id: If9bc2252c6cdd06cbe267fe130023c416aa53ce7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114906
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index 212de1db0288..422e2ef36ee3 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -38,6 +38,7 @@
 #include "inftxt.hxx"
 
 #include <sortedobjs.hxx>
+#include <officecfg/Office/Common.hxx>
 
 /**
  * class SwFlyPortion => we expect a frame-locale SwRect!
@@ -222,6 +223,25 @@ void sw::FlyContentPortion::Paint(const SwTextPaintInfo& 
rInf) const
     {
         SwLayoutModeModifier aLayoutModeModifier(*rInf.GetOut());
         m_pFly->PaintSwFrame(const_cast<vcl::RenderContext&>(*rInf.GetOut()), 
aRect);
+
+        // track changes: cross out the image, if it is deleted
+        const SwFrame *pFrame = m_pFly->Lower();
+        if ( IsDeleted() && pFrame )
+        {
+            SwRect aPaintRect( pFrame->GetPaintArea() );
+
+            const AntialiasingFlags nFormerAntialiasing( 
rInf.GetOut()->GetAntialiasing() );
+            const bool bIsAntiAliasing = 
officecfg::Office::Common::Drawinglayer::AntiAliasing::get();
+            if ( bIsAntiAliasing )
+                
const_cast<vcl::RenderContext&>(*rInf.GetOut()).SetAntialiasing(AntialiasingFlags::Enable);
+            tools::Long startX = aPaintRect.Left(  ), endX = 
aPaintRect.Right();
+            tools::Long startY = aPaintRect.Top(  ),  endY = 
aPaintRect.Bottom();
+            
const_cast<vcl::RenderContext&>(*rInf.GetOut()).SetLineColor(NON_PRINTING_CHARACTER_COLOR);
+            
const_cast<vcl::RenderContext&>(*rInf.GetOut()).DrawLine(Point(startX, startY), 
Point(endX, endY));
+            
const_cast<vcl::RenderContext&>(*rInf.GetOut()).DrawLine(Point(startX, endY), 
Point(endX, startY));
+            if ( bIsAntiAliasing )
+                
const_cast<vcl::RenderContext&>(*rInf.GetOut()).SetAntialiasing(nFormerAntialiasing);
+        }
     }
     
const_cast<SwTextPaintInfo&>(rInf).GetRefDev()->SetLayoutMode(rInf.GetOut()->GetLayoutMode());
 
diff --git a/sw/source/core/text/porfly.hxx b/sw/source/core/text/porfly.hxx
index 480492f7a829..fdd974050513 100644
--- a/sw/source/core/text/porfly.hxx
+++ b/sw/source/core/text/porfly.hxx
@@ -44,7 +44,8 @@ public:
 class SwFlyCntPortion : public SwLinePortion
 {
     Point m_aRef;     // Relatively to this point we calculate the AbsPos
-    bool m_bMax;   // Line adjustment and height == line height
+    bool m_bMax;      // Line adjustment and height == line height
+    bool m_bDeleted;  // Part of tracked deletion: it needs strikethrough
     sw::LineAlign m_eAlign;
 
     virtual SdrObject* GetSdrObj(const SwTextFrame&) =0;
@@ -53,9 +54,11 @@ public:
     SwFlyCntPortion();
     const Point& GetRefPoint() const { return m_aRef; }
     bool IsMax() const { return m_bMax; }
+    bool IsDeleted() const { return m_bDeleted; }
     sw::LineAlign GetAlign() const { return m_eAlign; }
     void SetAlign(sw::LineAlign eAlign) { m_eAlign = eAlign; }
     void SetMax(bool bMax) { m_bMax = bMax; }
+    void SetDeleted(bool bDeleted) { m_bDeleted = bDeleted; }
     void SetBase(const SwTextFrame& rFrame, const Point& rBase, tools::Long 
nLnAscent, tools::Long nLnDescent, tools::Long nFlyAscent, tools::Long 
nFlyDescent, AsCharFlags nFlags);
     virtual bool Format(SwTextFormatInfo& rInf) override;
 };
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 225fd2081c3c..f4dc4bd46661 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -359,6 +359,7 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, 
SwTextFormatInfo &rInf )
 
     bool bHasBlankPortion = false;
     bool bHasOnlyBlankPortions = true;
+    bool bHasFlyContentPortion = false;
 
     if( mpNextPortion )
     {
@@ -445,6 +446,8 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, 
SwTextFormatInfo &rInf )
                     SetHanging(true);
                     rInf.GetParaPortion()->SetMargin();
                 }
+                else if( !bHasFlyContentPortion && pPos->IsFlyCntPortion() )
+                     bHasFlyContentPortion = true;
 
                 // To prevent that a paragraph-end-character does not change
                 // the line height through a Descent and thus causing the line
@@ -623,6 +626,38 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, 
SwTextFormatInfo &rInf )
         }
     }
     SetRedline( bHasRedline );
+
+    // set redline for as-char anchored portions
+    if ( bHasFlyContentPortion )
+    {
+        SwLinePortion *pPos = mpNextPortion;
+        TextFrameIndex nLineLength;
+        while ( pPos )
+        {
+            TextFrameIndex const nPorSttIdx = rInf.GetLineStart() + 
nLineLength;
+            nLineLength += pPos->GetLen();
+            if( pPos->IsFlyCntPortion() )
+            {
+                bool bDeleted = false;
+                if ( bHasRedline )
+                {
+                    OUString sRedlineText;
+                    bool bHasRedlineEnd;
+                    enum RedlineType eRedlineEnd;
+                    std::pair<SwTextNode const*, sal_Int32> const flyStart(
+                        rInf.GetTextFrame()->MapViewToModel(nPorSttIdx));
+                    std::pair<SwTextNode const*, sal_Int32> const flyEnd(
+                        rInf.GetTextFrame()->MapViewToModel(nPorSttIdx + 
pPos->GetLen()));
+                    bool bHasFlyRedline = 
rLine.GetRedln()->CheckLine(flyStart.first->GetIndex(),
+                        flyStart.second, flyEnd.first->GetIndex(), 
flyEnd.second, sRedlineText,
+                        bHasRedlineEnd, eRedlineEnd);
+                    bDeleted = bHasFlyRedline && eRedlineEnd == 
RedlineType::Delete;
+                }
+                static_cast<SwFlyCntPortion*>(pPos)->SetDeleted(bDeleted);
+            }
+            pPos = pPos->GetNextPortion();
+        }
+    }
 }
 
 // #i47162# - add optional parameter <_bNoFlyCntPorAndLinePor>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to