include/svx/svdpage.hxx | 4 ++-- sd/inc/Annotation.hxx | 2 +- sd/inc/sdpage.hxx | 2 +- sd/source/core/annotations/Annotation.cxx | 5 +++-- sd/source/core/sdpage2.cxx | 7 +++---- sd/source/filter/pdf/sdpdffilter.cxx | 3 +-- sd/source/ui/annotations/annotationmanager.cxx | 3 +-- sd/source/ui/unoidl/unopage.cxx | 4 +--- 8 files changed, 13 insertions(+), 17 deletions(-)
New commits: commit b7ba358d48c1419142f88b8121b848113969eaaf Author: Michael Weghorn <[email protected]> AuthorDate: Thu May 2 17:12:55 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Fri May 3 08:11:53 2024 +0200 sd, svx: Return new annotation instead of using out param Let `SdrPage::createAnnotation` et al. return the newly created annotation rather than using an out parameter, which makes this more straightforward. Change-Id: Iee0561859756522ef33680c2cc9b492541a31d5e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167019 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx index c8c7eecddd5c..0747c4625773 100644 --- a/include/svx/svdpage.hxx +++ b/include/svx/svdpage.hxx @@ -23,6 +23,7 @@ #include <svl/stylesheetuser.hxx> #include <vcl/prntypes.hxx> #include <svl/itemset.hxx> +#include <svx/annotation/Annotation.hxx> #include <svx/sdrpageuser.hxx> #include <svx/sdr/contact/viewobjectcontactredirector.hxx> #include <svx/sdrmasterpagedescriptor.hxx> @@ -40,7 +41,6 @@ namespace model { class Theme; } namespace reportdesign { class OSection; } namespace sdr::contact { class ViewContact; } -namespace sdr::annotation { class Annotation; } class SdrPage; class SdrModel; class SfxItemPool; @@ -555,7 +555,7 @@ public: void dumpAsXml(xmlTextWriterPtr pWriter) const override; - virtual void createAnnotation(rtl::Reference<sdr::annotation::Annotation>& /*xAnnotation*/) { assert(false); } + virtual rtl::Reference<sdr::annotation::Annotation> createAnnotation() { assert(false); return nullptr; } virtual void addAnnotation(rtl::Reference<sdr::annotation::Annotation> const& /*xAnnotation*/, int /*nIndex*/) { assert(false); } virtual void removeAnnotation(rtl::Reference<sdr::annotation::Annotation> const& /*xAnnotation*/) { assert(false); } diff --git a/sd/inc/Annotation.hxx b/sd/inc/Annotation.hxx index f19584525865..00a0b2a22af8 100644 --- a/sd/inc/Annotation.hxx +++ b/sd/inc/Annotation.hxx @@ -46,7 +46,7 @@ class SfxViewShell; namespace sd { -void createAnnotation(rtl::Reference<sdr::annotation::Annotation>& xAnnotation, SdPage* pPage); +rtl::Reference<sdr::annotation::Annotation> createAnnotation(SdPage* pPage); std::unique_ptr<SdrUndoAction> CreateUndoInsertOrRemoveAnnotation(rtl::Reference<sdr::annotation::Annotation>& xAnnotation, bool bInsert); diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx index efaf3fa876bf..5c393082ad40 100644 --- a/sd/inc/sdpage.hxx +++ b/sd/inc/sdpage.hxx @@ -364,7 +364,7 @@ public: */ bool IsPrecious() const { return mbIsPrecious; } - void createAnnotation(rtl::Reference<sdr::annotation::Annotation>& xAnnotation) override; + rtl::Reference<sdr::annotation::Annotation> createAnnotation() override; void addAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, int nIndex) override; void removeAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation) override; diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx index 8c3e76d6a95f..1d1786ff460c 100644 --- a/sd/source/core/annotations/Annotation.cxx +++ b/sd/source/core/annotations/Annotation.cxx @@ -61,10 +61,11 @@ protected: } -void createAnnotation(rtl::Reference<sdr::annotation::Annotation>& xAnnotation, SdPage* pPage ) +rtl::Reference<sdr::annotation::Annotation> createAnnotation(SdPage* pPage ) { - xAnnotation.set(new Annotation(comphelper::getProcessComponentContext(), pPage)); + rtl::Reference<Annotation> xAnnotation(new Annotation(comphelper::getProcessComponentContext(), pPage)); pPage->addAnnotation(xAnnotation, -1); + return xAnnotation; } Annotation::Annotation(const uno::Reference<uno::XComponentContext>& context, SdPage* pPage) diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx index 74d3dd94334f..e6dbc1f2a560 100644 --- a/sd/source/core/sdpage2.cxx +++ b/sd/source/core/sdpage2.cxx @@ -379,8 +379,7 @@ void SdPage::lateInit(const SdPage& rSrcPage) // annotations for (auto const& rSourceAnnotation : rSrcPage.maAnnotations) { - rtl::Reference<sdr::annotation::Annotation> aNewAnnotation; - createAnnotation(aNewAnnotation); + rtl::Reference<sdr::annotation::Annotation> aNewAnnotation = createAnnotation(); aNewAnnotation->setPosition(rSourceAnnotation->getPosition()); aNewAnnotation->setSize(rSourceAnnotation->getSize()); aNewAnnotation->setAuthor(rSourceAnnotation->getAuthor()); @@ -552,9 +551,9 @@ bool SdPage::Equals(const SdPage& rOtherPage) const return true; } -void SdPage::createAnnotation(rtl::Reference<sdr::annotation::Annotation>& xAnnotation) +rtl::Reference<sdr::annotation::Annotation> SdPage::createAnnotation() { - sd::createAnnotation(xAnnotation, this); + return sd::createAnnotation(this); } void SdPage::addAnnotation(rtl::Reference<sdr::annotation::Annotation> const& xAnnotation, int nIndex ) diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx index 70ebf0634b95..89ff0dd134db 100644 --- a/sd/source/filter/pdf/sdpdffilter.cxx +++ b/sd/source/filter/pdf/sdpdffilter.cxx @@ -93,8 +93,7 @@ bool SdPdfFilter::Import() for (auto const& rPDFAnnotation : rPDFGraphicResult.GetAnnotations()) { - rtl::Reference<sdr::annotation::Annotation> xAnnotation; - pPage->createAnnotation(xAnnotation); + rtl::Reference<sdr::annotation::Annotation> xAnnotation = pPage->createAnnotation(); xAnnotation->setAuthor(rPDFAnnotation.maAuthor); diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 622a1e5a2c10..0eb3adb2e977 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -493,8 +493,7 @@ void AnnotationManagerImpl::InsertAnnotation(const OUString& rText) } } - rtl::Reference<sdr::annotation::Annotation> xAnnotation; - pPage->createAnnotation(xAnnotation); + rtl::Reference<sdr::annotation::Annotation> xAnnotation = pPage->createAnnotation(); OUString sAuthor; if (comphelper::LibreOfficeKit::isActive()) diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index aad9521b33f3..1526d913661f 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -2529,9 +2529,7 @@ Reference< XAnnotation > SAL_CALL SdGenericDrawPage::createAndInsertAnnotation() if( !GetPage() ) throw DisposedException(); - rtl::Reference<sdr::annotation::Annotation> xRet; - GetPage()->createAnnotation(xRet); - return xRet; + return GetPage()->createAnnotation(); } void SAL_CALL SdGenericDrawPage::removeAnnotation(const Reference< XAnnotation > & annotation)
