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>
This commit is contained in:
Tomaž Vajngerl
2025-01-07 05:43:58 +01:00
committed by Tomaž Vajngerl
parent c034a21f35
commit d3afb7aceb
6 changed files with 44 additions and 12 deletions
@@ -19,6 +19,8 @@ namespace sdr::annotation
class ObjectAnnotationData
{
public:
~ObjectAnnotationData() { closePopup(); }
/// The annotation
rtl::Reference<sdr::annotation::Annotation> mxAnnotation;
@@ -31,6 +33,13 @@ public:
if (mpAnnotationPopup)
mpAnnotationPopup->openPopup();
}
/// Close popup for the annotation
void closePopup()
{
if (mpAnnotationPopup)
mpAnnotationPopup->closePopup();
}
};
}
+1 -3
View File
@@ -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);
}
}
+30 -3
View File
@@ -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
@@ -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();
};
+1 -4
View File
@@ -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;
}
+2 -1
View File
@@ -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;