sw/qa/extras/uiwriter/uiwriter2.cxx |    5 +++++
 sw/source/core/text/porfly.cxx      |    7 +++++--
 sw/source/core/text/porfly.hxx      |    3 +++
 sw/source/core/text/porlay.cxx      |    4 +++-
 sw/source/core/text/redlnitr.cxx    |    6 ++++--
 sw/source/core/text/redlnitr.hxx    |    2 +-
 6 files changed, 21 insertions(+), 6 deletions(-)

New commits:
commit 7b6bf0525c4a4122ad813a9b7b1558832b772d93
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Mon Jun 7 17:56:42 2021 +0200
Commit:     Balazs Varga <varga.bala...@nisz.hu>
CommitDate: Thu Oct 21 11:30:00 2021 +0200

    tdf#142128 sw: set author-color strikethrough for AS_CHAR images
    
    (anchored as character) during change tracking instead of
    using always the same NON_PRINTING_CHARACTER_COLOR blue one.
    
    Follow-up to commit 76dc21860ce185bd5495adde8858d2f23284c78e
    "tdf#142128 sw: set author-color strikethrough for deleted images".
    
    Change-Id: I3fa02f6ec6cd1f71ae3b3c06644dd24f6c684f6f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116795
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123962
    Tested-by: Balazs Varga <varga.bala...@nisz.hu>
    Reviewed-by: Balazs Varga <varga.bala...@nisz.hu>

diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 259687baf470..1a6d455abfb3 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -2170,6 +2170,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf142130)
     // vertical lines before the two lines)
     assertXPath(pXmlDoc, "/metafile/push/push/push/line", 4);
 
+    // check line color
+    assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/linecolor", 5);
+    // tdf#142128 This was 3 (NON_PRINTING_CHARACTER_COLOR = #268bd2)
+    assertXPath(pXmlDoc, 
"/metafile/push[1]/push[1]/push[1]/linecolor[@color='#268bd2']", 0);
+
     // reject deletion of the second image
     IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess());
     rIDRA.AcceptAllRedline(false);
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index 11659a1ebc0e..5709cbee23e2 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -40,6 +40,7 @@
 
 #include <sortedobjs.hxx>
 #include <officecfg/Office/Common.hxx>
+#include <PostItMgr.hxx>
 
 /**
  * class SwFlyPortion => we expect a frame-locale SwRect!
@@ -227,7 +228,7 @@ void sw::FlyContentPortion::Paint(const SwTextPaintInfo& 
rInf) const
 
         // track changes: cross out the image, if it is deleted
         const SwFrame *pFrame = m_pFly->Lower();
-        if ( IsDeleted() && pFrame )
+        if ( GetAuthor() != std::string::npos && IsDeleted() && pFrame )
         {
             SwRect aPaintRect( pFrame->GetPaintArea() );
 
@@ -237,7 +238,8 @@ void sw::FlyContentPortion::Paint(const SwTextPaintInfo& 
rInf) const
                 
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()).SetLineColor(
+                SwPostItMgr::GetColorAnchor(GetAuthor()) );
             
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 )
@@ -271,6 +273,7 @@ void sw::DrawFlyCntPortion::Paint(const SwTextPaintInfo&) 
const
 SwFlyCntPortion::SwFlyCntPortion()
     : m_bMax(false)
     , m_bDeleted(false)
+    , m_nAuthor(std::string::npos)
     , m_eAlign(sw::LineAlign::NONE)
 {
     nLineLength = TextFrameIndex(1);
diff --git a/sw/source/core/text/porfly.hxx b/sw/source/core/text/porfly.hxx
index b83aab4a4c88..7c00db94a840 100644
--- a/sw/source/core/text/porfly.hxx
+++ b/sw/source/core/text/porfly.hxx
@@ -46,6 +46,7 @@ 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_bDeleted;  // Part of tracked deletion: it needs strikethrough
+    size_t m_nAuthor; // Redline author for color of the strikethrough
     sw::LineAlign m_eAlign;
 
     virtual SdrObject* GetSdrObj(const SwTextFrame&) =0;
@@ -55,6 +56,8 @@ public:
     const Point& GetRefPoint() const { return m_aRef; }
     bool IsMax() const { return m_bMax; }
     bool IsDeleted() const { return m_bDeleted; }
+    void SetAuthor(size_t nAuthor) { m_nAuthor = nAuthor; }
+    size_t GetAuthor() const { return m_nAuthor; }
     sw::LineAlign GetAlign() const { return m_eAlign; }
     void SetAlign(sw::LineAlign eAlign) { m_eAlign = eAlign; }
     void SetMax(bool bMax) { m_bMax = bMax; }
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 74cd12b372a6..1d200d0a061d 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -639,6 +639,7 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, 
SwTextFormatInfo &rInf )
             if( pPos->IsFlyCntPortion() )
             {
                 bool bDeleted = false;
+                size_t nAuthor = std::string::npos;
                 if ( bHasRedline )
                 {
                     OUString sRedlineText;
@@ -648,10 +649,11 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, 
SwTextFormatInfo &rInf )
                         rInf.GetTextFrame()->MapViewToModel(nPorSttIdx));
                     bool bHasFlyRedline = 
rLine.GetRedln()->CheckLine(flyStart.first->GetIndex(),
                         flyStart.second, flyStart.first->GetIndex(), 
flyStart.second, sRedlineText,
-                        bHasRedlineEnd, eRedlineEnd, /*bFullLine=*/false);
+                        bHasRedlineEnd, eRedlineEnd, 
/*pAuthorAtPos=*/&nAuthor);
                     bDeleted = bHasFlyRedline && eRedlineEnd == 
RedlineType::Delete;
                 }
                 static_cast<SwFlyCntPortion*>(pPos)->SetDeleted(bDeleted);
+                static_cast<SwFlyCntPortion*>(pPos)->SetAuthor(nAuthor);
             }
             pPos = pPos->GetNextPortion();
         }
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 0428122bf6b0..0ab78c6dc0d6 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -940,13 +940,13 @@ bool SwRedlineItr::ChkSpecialUnderline_() const
 bool SwRedlineItr::CheckLine(
         sal_uLong const nStartNode, sal_Int32 const nChkStart,
         sal_uLong const nEndNode, sal_Int32 nChkEnd, OUString& rRedlineText,
-        bool& bRedlineEnd, RedlineType& eRedlineEnd, bool bFullLine)
+        bool& bRedlineEnd, RedlineType& eRedlineEnd, size_t* pAuthorAtPos)
 {
     // note: previously this would return true in the (!m_bShow && m_pExt)
     // case, but surely that was a bug?
     if (m_nFirst == SwRedlineTable::npos || m_eMode != Mode::Show)
         return false;
-    if( nChkEnd == nChkStart && bFullLine ) // empty lines look one char 
further
+    if( nChkEnd == nChkStart && pAuthorAtPos == nullptr ) // empty lines look 
one char further
         ++nChkEnd;
     sal_Int32 nOldStart = m_nStart;
     sal_Int32 nOldEnd = m_nEnd;
@@ -977,6 +977,8 @@ bool SwRedlineItr::CheckLine(
                 eRedlineEnd = pRedline->GetType();
                 bRedlineEnd = true;
                 isBreak = true;
+                if (pAuthorAtPos)
+                    *pAuthorAtPos = pRedline->GetAuthor();
                 [[fallthrough]];
             case SwComparePosition::OverlapBefore:
             case SwComparePosition::CollideEnd:
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 0ba22030edbe..52bd8f1e4920 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -120,7 +120,7 @@ public:
         { return IsOn() && ChkSpecialUnderline_(); }
     bool CheckLine(sal_uLong nStartNode, sal_Int32 nChkStart, sal_uLong 
nEndNode,
         sal_Int32 nChkEnd, OUString& rRedlineText, bool& bRedlineEnd,
-        RedlineType& eRedlineEnd, bool bFullLine = true);
+        RedlineType& eRedlineEnd, size_t* pAuthorAtPos = nullptr);
     bool LeaveExtend(SwFont& rFnt, sal_uLong const nNode, sal_Int32 const nNew)
         { return m_pExt->Leave(rFnt, nNode, nNew); }
     bool ExtOn() {

Reply via email to