tdf#142128 sw: set author-color strikethrough for deleted images

anchored to character during change tracking instead of
using always the same NON_PRINTING_CHARACTER_COLOR blue one.

Follow-up to commit 1610eeef6f2312616fe5d3535475f27f7896bef8
"tdf#142196 sw: crossing out images anchored to character".

Change-Id: I267a492dc6bb75327fb96ccdb51b784d00ba7a41
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116785
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 c87d0bd..ef40b19 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -2513,6 +2513,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf142196)
    // 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);
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index 399bbbe..47017e7 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -131,6 +131,7 @@ protected:
    bool m_bLayout :1;       ///< RndStdIds::FLY_AT_PAGE, RndStdIds::FLY_AT_FLY, at page or at frame
    bool m_bAutoPosition :1; ///< RndStdIds::FLY_AT_CHAR, anchored at character
    bool m_bDeleted :1;      ///< Anchored to a tracked deletion
    size_t m_nAuthor;        ///< Redline author index for colored crossing out

    friend class SwNoTextFrame; // is allowed to call NotifyBackground

@@ -217,6 +218,8 @@ public:
    bool IsFlyAtContentFrame() const { return m_bAtCnt; }
    bool IsDeleted() const { return m_bDeleted; }
    void SetDeleted(bool bDeleted) { m_bDeleted = bDeleted; }
    void SetAuthor( size_t nAuthor ) { m_nAuthor = nAuthor; }
    size_t GetAuthor() const { return m_nAuthor; }

    bool IsNotifyBack() const { return m_bNotifyBack; }
    void SetNotifyBack()      { m_bNotifyBack = true; }
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index bf01c3b..8181bd6 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -87,7 +87,8 @@ SwFlyFrame::SwFlyFrame( SwFlyFrameFormat *pFormat, SwFrame* pSib, SwFrame *pAnch
    m_bAtCnt( false ),
    m_bLayout( false ),
    m_bAutoPosition( false ),
    m_bDeleted (false ),
    m_bDeleted( false ),
    m_nAuthor( std::string::npos ),
    m_bValidContentPos( false )
{
    mnFrameType = SwFrameType::Fly;
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 4a9eb64..f5cb3c5 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -4222,11 +4222,11 @@ void SwFlyFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect const& 
    PaintDecorators();

    // crossing out for tracked deletion
    if ( IsDeleted() )
    if ( GetAuthor() != std::string::npos && IsDeleted() )
    {
        tools::Long startX = aRect.Left(  ), endX = aRect.Right();
        tools::Long startY = aRect.Top(  ),  endY = aRect.Bottom();
        rRenderContext.SetLineColor(NON_PRINTING_CHARACTER_COLOR);
        rRenderContext.SetLineColor( SwPostItMgr::GetColorAnchor(GetAuthor()) );
        rRenderContext.DrawLine(Point(startX, startY), Point(endX, endY));
        rRenderContext.DrawLine(Point(startX, endY), Point(endX, startY));
    }
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 9a162b6..f0a3a4e 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -670,20 +670,23 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf )
                        if ( auto pFly = dynamic_cast<SwFlyFrame *>( pAnchoredObj ) )
                        {
                            bool bDeleted = false;
                            size_t nAuthor = std::string::npos;
                            const SwFormatAnchor& rAnchor = pAnchoredObj->GetFrameFormat().GetAnchor();
                            if ( rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR )
                            {
                                SwPosition aAnchor = *rAnchor.GetContentAnchor();
                                const SwPaM aPam(aAnchor, aAnchor);
                                if ( rIDRA.HasRedline( aPam, RedlineType::Delete,
                                        /*bStartOrEndInRange=*/false) )
                                SwRedlineTable::size_type n = 0;
                                const SwRangeRedline* pFnd =
                                        rIDRA.GetRedlineTable().FindAtPosition( aAnchor, n );
                                if ( pFnd && RedlineType::Delete == pFnd->GetType() )
                                {
                                    bDeleted = true;
                                    nAuthor = pFnd->GetAuthor();
                                }
                            }
                            pFly->SetDeleted(bDeleted);
                            pFly->SetAuthor(nAuthor);
                        }

                    }
                }
            }