diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-05-22 11:13:12 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-05-22 22:24:41 +0200 |
commit | 80f7f3e8099e05632201d7b18de0112153ebc1ba (patch) | |
tree | ad0cc1669d0df2fc1a306cc7be8a6e472261375e /sw | |
parent | 1bd9747a126a3e82b6093c2b4af3b3a74774a3e9 (diff) |
split a piece of code out as a standalone GetOrCreateAnnotationWindow
Change-Id: I674d96976f265eeac719ed06a657af07aaae2325
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167931
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/PostItMgr.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/docvw/PostItMgr.cxx | 40 |
2 files changed, 26 insertions, 16 deletions
diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx index 2278ae05ea6f..1a6dac4a8f62 100644 --- a/sw/inc/PostItMgr.hxx +++ b/sw/inc/PostItMgr.hxx @@ -132,6 +132,8 @@ class SAL_DLLPUBLIC_RTTI SwPostItMgr final : public SfxListener SwSidebarItem* InsertItem( SfxBroadcaster* pItem, bool bCheckExistence, bool bFocus); void RemoveItem( SfxBroadcaster* pBroadcast ); + VclPtr<sw::annotation::SwAnnotationWin> GetOrCreateAnnotationWindow(SwSidebarItem& rItem); + public: SwPostItMgr(SwView* aDoc); virtual ~SwPostItMgr() override; diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index 32d0f938e71c..95eaea2a5557 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -695,6 +695,28 @@ void SwPostItMgr::PreparePageContainer() } } +VclPtr<SwAnnotationWin> SwPostItMgr::GetOrCreateAnnotationWindow(SwSidebarItem& rItem) +{ + VclPtr<SwAnnotationWin> pPostIt = rItem.mpPostIt; + if (!pPostIt) + { + pPostIt = rItem.GetSidebarWindow( mpView->GetEditWin(), + *this ); + pPostIt->InitControls(); + pPostIt->SetReadonly(mbReadOnly); + rItem.mpPostIt = pPostIt; + if (mpAnswer) + { + if (pPostIt->GetPostItField()->GetParentPostItId() != 0) //do we really have another note in front of this one + { + pPostIt->InitAnswer(*mpAnswer); + } + mpAnswer.reset(); + } + } + return rItem.mpPostIt; +} + void SwPostItMgr::LayoutPostIts() { const bool bLoKitActive = comphelper::LibreOfficeKit::isActive(); @@ -724,24 +746,9 @@ void SwPostItMgr::LayoutPostIts() for (auto const& pItem : pPage->mvSidebarItems) { - VclPtr<SwAnnotationWin> pPostIt = pItem->mpPostIt; - if (pItem->mbShow) { - if (!pPostIt) - { - pPostIt = pItem->GetSidebarWindow( mpView->GetEditWin(), - *this ); - pPostIt->InitControls(); - pPostIt->SetReadonly(mbReadOnly); - pItem->mpPostIt = pPostIt; - if (mpAnswer) - { - if (pPostIt->GetPostItField()->GetParentPostItId() != 0) //do we really have another note in front of this one - pPostIt->InitAnswer(*mpAnswer); - mpAnswer.reset(); - } - } + VclPtr<SwAnnotationWin> pPostIt = GetOrCreateAnnotationWindow(*pItem); pPostIt->SetChangeTracking( pItem->mLayoutStatus, @@ -808,6 +815,7 @@ void SwPostItMgr::LayoutPostIts() } else // we don't want to see it { + VclPtr<SwAnnotationWin> pPostIt = pItem->mpPostIt; if (pPostIt) pPostIt->HideNote(); } |