From ffb1fe4f434a48358a18c0af2c44a112d9ad04be Mon Sep 17 00:00:00 2001 From: Marco Cecchetti Date: Wed, 19 Oct 2016 22:00:04 +0200 Subject: LOK: Calc: show/hide a note does not perform any tile invalidation Change-Id: Ia904b6bbe82c395299b269ddbde523d19bf486bc Reviewed-on: https://gerrit.libreoffice.org/30099 Tested-by: Jenkins Reviewed-by: Marco Cecchetti --- sc/source/ui/docshell/docfunc.cxx | 2 ++ sc/source/ui/inc/tabview.hxx | 1 + sc/source/ui/view/tabview5.cxx | 45 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 3a5eaee43c94..7dab24bc113f 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -1221,6 +1221,8 @@ bool ScDocFunc::ShowNote( const ScAddress& rPos, bool bShow ) if (rDoc.IsStreamValid(rPos.Tab())) rDoc.SetStreamValid(rPos.Tab(), false); + ScTabView::OnLOKNoteStateChanged(pNote); + rDocShell.SetDocumentModified(); return true; diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index 948f599a30df..5afc3d3920eb 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -584,6 +584,7 @@ public: void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector* pRanges ); /// @see ScModelObj::getRowColumnHeaders(). OUString getRowColumnHeaders(const Rectangle& rRectangle); + static void OnLOKNoteStateChanged(const ScPostIt* pNote); }; #endif diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index a528e511e479..fe837a7794d8 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -47,6 +48,7 @@ #include "AccessibilityHints.hxx" #include "docsh.hxx" #include "viewuno.hxx" +#include "postit.hxx" #include #include @@ -645,4 +647,47 @@ void ScTabView::ResetBrushDocument() } } +void ScTabView::OnLOKNoteStateChanged(const ScPostIt* pNote) +{ + if (!comphelper::LibreOfficeKit::isActive()) + return; + + const SdrCaptionObj* pCaption = pNote->GetCaption(); + if (!pCaption) return; + + Rectangle aRect = pCaption->GetLogicRect(); + basegfx::B2DRange aTailRange = pCaption->getTailPolygon().getB2DRange(); + Rectangle aTailRect(aTailRange.getMinX(), aTailRange.getMinY(), + aTailRange.getMaxX(), aTailRange.getMaxY()); + aRect.Union( aTailRect ); + + // This is a temporary workaround: sometime in tiled rendering mode + // the tip of the note arrow is misplaced by a fixed offset. + // The value used below is enough to get the tile, where the arrow tip is + // placed, invalidated. + const int nBorderSize = 200; + Rectangle aInvalidRect = aRect; + aInvalidRect.Left() -= nBorderSize; + aInvalidRect.Right() += nBorderSize; + aInvalidRect.Top() -= nBorderSize; + aInvalidRect.Bottom() += nBorderSize; + + SfxViewShell* pViewShell = SfxViewShell::GetFirst(); + while (pViewShell) + { + ScTabViewShell* pTabViewShell = dynamic_cast(pViewShell); + if (pTabViewShell) + { + for (auto& pWin: pTabViewShell->pGridWin) + { + if (pWin && pWin->IsVisible()) + { + pWin->Invalidate(aInvalidRect); + } + } + } + pViewShell = SfxViewShell::GetNext(*pViewShell); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit