summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2025-01-07 11:58:19 +0900
committerTomaž Vajngerl <quikee@gmail.com>2025-01-07 05:43:58 +0100
commitd3afb7acebc023340aef5d70d4f35cecb359cd54 (patch)
tree441e9248d291ec87ad891ae311d61b33cd48fef4 /sd
parentc034a21f359db6bd8ba7b4938d4501bbcc87e21d (diff)
tdf#164529 support annotation selection with edit (trigger pop-up)
In some instances we want to select the annotation and edit them at the same time - trigger pop-up. This change adds back support for that. Also properly close the pop-ups when the view shell and window are destroyed. Change-Id: I17abeb39a7500001b148b8923eb9028d297a40a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179664 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/core/sdpage2.cxx4
-rw-r--r--sd/source/ui/annotations/annotationmanager.cxx33
-rw-r--r--sd/source/ui/annotations/annotationwindow.hxx2
-rw-r--r--sd/source/ui/func/fusel.cxx5
-rw-r--r--sd/source/ui/inc/annotationmanager.hxx3
5 files changed, 35 insertions, 12 deletions
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index 794b30f2c592..08194915d4a0 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -603,9 +603,7 @@ void SdPage::removeAnnotationNoNotify(rtl::Reference<sdr::annotation::Annotation
SdrObject* pObject = GetObj(nObjectIndex);
if (pObject->isAnnotationObject() && pObject->getAnnotationData()->mxAnnotation == xAnnotation)
{
- auto& pAnnotationPopup = pObject->getAnnotationData()->mpAnnotationPopup;
- if (pAnnotationPopup)
- pAnnotationPopup->closePopup();
+ pObject->getAnnotationData()->closePopup();
RemoveObject(nObjectIndex);
}
}
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index ec876c667aaa..7c8de65421bd 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/office/XAnnotationAccess.hpp>
#include <comphelper/lok.hxx>
#include <svx/svxids.hrc>
+#include <svx/svditer.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
@@ -208,6 +209,22 @@ void AnnotationManagerImpl::init()
// WeakComponentImplHelper
void AnnotationManagerImpl::disposing (std::unique_lock<std::mutex>&)
{
+ for (sal_uInt16 i = 0; i < mpDoc->GetPageCount(); i++)
+ {
+ SdrPage* pPage = mpDoc->GetPage(i);
+ SdrObjListIter aIterator(pPage, SdrIterMode::DeepWithGroups);
+ while (aIterator.IsMore())
+ {
+ SdrObject* pObject = aIterator.Next();
+ if (pObject)
+ {
+ auto& xAnnotationData = pObject->getAnnotationData();
+ if (xAnnotationData)
+ xAnnotationData->closePopup();
+ }
+ }
+ }
+
try
{
uno::Reference<document::XEventBroadcaster> xModel (mrBase.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW);
@@ -875,9 +892,19 @@ void AnnotationManagerImpl::SelectNextAnnotation(bool bForward)
while( true );
}
-void AnnotationManagerImpl::SelectAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, bool /*bEdit*/)
+void AnnotationManagerImpl::SelectAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, bool bEdit)
{
mxSelectedAnnotation = xAnnotation;
+ if (bEdit)
+ {
+ SdrObject* pObject = xAnnotation->findAnnotationObject();
+ if (pObject)
+ {
+ auto& pAnnotationData = pObject->getAnnotationData();
+ if (pAnnotationData)
+ pAnnotationData->openPopup();
+ }
+ }
}
void AnnotationManagerImpl::GetSelectedAnnotation( rtl::Reference<sdr::annotation::Annotation>& xAnnotation )
@@ -1292,9 +1319,9 @@ void AnnotationManager::GetAnnotationState(SfxItemSet& rItemSet)
mxImpl->GetAnnotationState(rItemSet);
}
-void AnnotationManager::SelectAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation)
+void AnnotationManager::SelectAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, bool bEdit)
{
- mxImpl->SelectAnnotation(xAnnotation);
+ mxImpl->SelectAnnotation(xAnnotation, bEdit);
}
} // end sd
diff --git a/sd/source/ui/annotations/annotationwindow.hxx b/sd/source/ui/annotations/annotationwindow.hxx
index 31f82348b371..d7f3d98e10b0 100644
--- a/sd/source/ui/annotations/annotationwindow.hxx
+++ b/sd/source/ui/annotations/annotationwindow.hxx
@@ -105,6 +105,7 @@ private:
public:
AnnotationWindow(weld::Window* pParent, const ::tools::Rectangle& rRect, DrawDocShell* pDocShell,
const rtl::Reference<sdr::annotation::Annotation>& xAnnotation);
+ ~AnnotationWindow();
void connect_closed(const Link<weld::Popover&, void>& rLink) { mxPopover->connect_closed(rLink); }
@@ -131,7 +132,6 @@ public:
OutlinerView* GetOutlinerView() { return mpOutlinerView.get();}
::Outliner* GetOutliner() { return mpOutliner.get();}
- ~AnnotationWindow();
void SetColor();
};
diff --git a/sd/source/ui/func/fusel.cxx b/sd/source/ui/func/fusel.cxx
index bc2da0ced224..aa43a76ee91b 100644
--- a/sd/source/ui/func/fusel.cxx
+++ b/sd/source/ui/func/fusel.cxx
@@ -869,10 +869,7 @@ bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
{
auto* pDrawViewShell = dynamic_cast<DrawViewShell*>(mpViewShell);
if (pDrawViewShell && pDrawViewShell->getAnnotationManagerPtr())
- {
- pDrawViewShell->getAnnotationManagerPtr()->SelectAnnotation(pAnnotationData->mxAnnotation);
- }
- pAnnotationData->openPopup();
+ pDrawViewShell->getAnnotationManagerPtr()->SelectAnnotation(pAnnotationData->mxAnnotation, true);
}
return true;
}
diff --git a/sd/source/ui/inc/annotationmanager.hxx b/sd/source/ui/inc/annotationmanager.hxx
index 25bf5503384e..b9af2ecca1b3 100644
--- a/sd/source/ui/inc/annotationmanager.hxx
+++ b/sd/source/ui/inc/annotationmanager.hxx
@@ -42,7 +42,8 @@ public:
void ExecuteAnnotation(SfxRequest const& rRequest);
void GetAnnotationState(SfxItemSet& rItemSet);
- void SelectAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation);
+ void SelectAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation,
+ bool bEdit = false);
private:
::rtl::Reference<AnnotationManagerImpl> mxImpl;