summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-06-05 17:33:08 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-06-05 17:26:09 +0200
commite467cb52d68692e936eb07c2c1faa45f03dd1f82 (patch)
treeb47b6dd2dd777fef2c442ff7e67e27b341f83397 /sd
parent367ba88092fbc0ba06a7f77157cd012ff0fe3caf (diff)
annot: add {add,remove}Annotation that don't notify
Add addAnnotationNoNotify method, that doesn't broadcast that an annotation was added, and change addAnnotation to call the method and in addition call the broadcast bits. Previously all this had happened in the addAnnotation without the choice to not broadcast. Change removeAnnotation in a similar way. Change-Id: Ie15a386a8b8d4493d5b41fcbcb55924a693b46d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168429 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Jenkins
Diffstat (limited to 'sd')
-rw-r--r--sd/inc/sdpage.hxx5
-rw-r--r--sd/source/core/sdpage2.cxx51
2 files changed, 37 insertions, 19 deletions
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index 5c393082ad40..b0cb6f105c46 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -365,8 +365,11 @@ public:
bool IsPrecious() const { return mbIsPrecious; }
rtl::Reference<sdr::annotation::Annotation> createAnnotation() override;
- void addAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, int nIndex) override;
+ void addAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, int nIndex = -1) override;
+ void addAnnotationNoNotify(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, int nIndex = -1) override;
+
void removeAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation) override;
+ void removeAnnotationNoNotify(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation) override;
bool Equals(const SdPage&) const;
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index 359339c7ff11..915ed33e75a6 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -556,7 +556,17 @@ rtl::Reference<sdr::annotation::Annotation> SdPage::createAnnotation()
return sd::createAnnotation(this);
}
-void SdPage::addAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, int nIndex )
+void SdPage::addAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, int nIndex)
+{
+ addAnnotationNoNotify(xAnnotation, nIndex);
+
+ NotifyDocumentEvent(
+ static_cast<SdDrawDocument&>(getSdrModelFromSdrPage()),
+ u"OnAnnotationInserted"_ustr,
+ uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(xAnnotation.get()), UNO_QUERY));
+}
+
+void SdPage::addAnnotationNoNotify(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, int nIndex)
{
if ((nIndex == -1) || (nIndex > int(maAnnotations.size())))
{
@@ -564,44 +574,49 @@ void SdPage::addAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xA
}
else
{
- maAnnotations.insert( maAnnotations.begin() + nIndex, xAnnotation );
+ maAnnotations.insert(maAnnotations.begin() + nIndex, xAnnotation);
}
- if( getSdrModelFromSdrPage().IsUndoEnabled() )
+ SdrModel& rModel = getSdrModelFromSdrPage();
+
+ if (rModel.IsUndoEnabled())
{
rtl::Reference<sdr::annotation::Annotation> xUnconstAnnotation(xAnnotation);
std::unique_ptr<SdrUndoAction> pAction = CreateUndoInsertOrRemoveAnnotation(xUnconstAnnotation, true);
if (pAction)
- getSdrModelFromSdrPage().AddUndo( std::move(pAction) );
+ rModel.AddUndo(std::move(pAction));
}
SetChanged();
- getSdrModelFromSdrPage().SetChanged();
- NotifyDocumentEvent(
- static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()),
- u"OnAnnotationInserted"_ustr,
- Reference<XInterface>(static_cast<cppu::OWeakObject*>(xAnnotation.get()), UNO_QUERY));
}
void SdPage::removeAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation)
{
- if( getSdrModelFromSdrPage().IsUndoEnabled() )
+ removeAnnotationNoNotify(xAnnotation);
+
+ NotifyDocumentEvent(
+ static_cast<SdDrawDocument&>(getSdrModelFromSdrPage()),
+ u"OnAnnotationRemoved"_ustr,
+ uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(xAnnotation.get()), UNO_QUERY));
+}
+
+void SdPage::removeAnnotationNoNotify(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation)
+{
+ SdrModel& rModel = getSdrModelFromSdrPage();
+
+ if (rModel.IsUndoEnabled())
{
rtl::Reference<sdr::annotation::Annotation> xUnconstAnnotation(xAnnotation);
std::unique_ptr<SdrUndoAction> pAction = CreateUndoInsertOrRemoveAnnotation(xUnconstAnnotation, false);
- if( pAction )
- getSdrModelFromSdrPage().AddUndo( std::move(pAction) );
+ if (pAction)
+ rModel.AddUndo(std::move(pAction));
}
- sdr::annotation::AnnotationVector::iterator iterator = std::find(maAnnotations.begin(), maAnnotations.end(), xAnnotation);
+ auto iterator = std::find(maAnnotations.begin(), maAnnotations.end(), xAnnotation);
if (iterator != maAnnotations.end())
maAnnotations.erase(iterator);
- getSdrModelFromSdrPage().SetChanged();
- NotifyDocumentEvent(
- static_cast< SdDrawDocument& >( getSdrModelFromSdrPage() ),
- u"OnAnnotationRemoved"_ustr,
- Reference<XInterface>( static_cast<cppu::OWeakObject*>(xAnnotation.get()), UNO_QUERY ) );
+ rModel.SetChanged();
}
void SdPage::getGraphicsForPrefetch(std::vector<Graphic*>& graphics) const