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 <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index ef40b19..736704b 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -2473,6 +2473,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf142130)
    // vertical "changed line" indicator before the two paragraph 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 71a7021..b999e3d 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -39,6 +39,7 @@

#include <sortedobjs.hxx>
#include <officecfg/Office/Common.hxx>
#include <PostItMgr.hxx>

/**
 * class SwFlyPortion => we expect a frame-locale SwRect!
@@ -226,7 +227,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() );

@@ -236,7 +237,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 )
@@ -270,6 +272,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)
{
    mnLineLength = TextFrameIndex(1);
diff --git a/sw/source/core/text/porfly.hxx b/sw/source/core/text/porfly.hxx
index fdd9740..a519c11 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 f0a3a4e..95809ed 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -642,6 +642,7 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf )
            if( pPos->IsFlyCntPortion() )
            {
                bool bDeleted = false;
                size_t nAuthor = std::string::npos;
                if ( bHasRedline )
                {
                    OUString sRedlineText;
@@ -651,10 +652,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);
            }
            // anchored to characters
            else if ( pPos->IsFlyPortion() )
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index faeb0fb..d4ced03 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -941,13 +941,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;
@@ -978,6 +978,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 0d0e013..087df8b 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -119,7 +119,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() {