diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-11-08 11:59:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-11-09 07:00:22 +0100 |
commit | fd2988a5911758cc6c56942c235857fd9a327fd4 (patch) | |
tree | fd8e06edf4b533efd25d573c3a067e0b476c02fd /sd/source | |
parent | 9edefc2d441d6879cc64d6b18fabd5682d9e464c (diff) |
use more concrete sd::Annotation in AnnotationManagerImpl
instead of casting to and from the UNO type
Change-Id: Ia69865e1c4fb809e325335d33118287bcc692a39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159177
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/core/annotations/Annotation.cxx | 19 | ||||
-rw-r--r-- | sd/source/core/annotations/AnnotationEnumeration.cxx | 1 | ||||
-rw-r--r-- | sd/source/core/sdpage.cxx | 1 | ||||
-rw-r--r-- | sd/source/core/sdpage2.cxx | 14 | ||||
-rw-r--r-- | sd/source/filter/pdf/sdpdffilter.cxx | 10 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationmanager.cxx | 51 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationmanagerimpl.hxx | 14 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationtag.cxx | 17 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationtag.hxx | 8 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.cxx | 7 |
11 files changed, 77 insertions, 67 deletions
diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx index 432d38f9cb32..9faee9d7b701 100644 --- a/sd/source/core/annotations/Annotation.cxx +++ b/sd/source/core/annotations/Annotation.cxx @@ -108,7 +108,7 @@ protected: } -void createAnnotation(uno::Reference<office::XAnnotation>& xAnnotation, SdPage* pPage ) +void createAnnotation(rtl::Reference<Annotation>& xAnnotation, SdPage* pPage ) { xAnnotation.set( new Annotation(comphelper::getProcessComponentContext(), pPage)); @@ -409,10 +409,8 @@ UndoInsertOrRemoveAnnotation::UndoInsertOrRemoveAnnotation( Annotation& rAnnotat SdPage* pPage = rAnnotation.GetPage(); if( pPage ) { - uno::Reference<office::XAnnotation> xAnnotation( &rAnnotation ); - const AnnotationVector& rVec = pPage->getAnnotations(); - auto iter = std::find(rVec.begin(), rVec.end(), xAnnotation); + auto iter = std::find(rVec.begin(), rVec.end(), &rAnnotation); mnIndex += std::distance(rVec.begin(), iter); } } @@ -424,14 +422,14 @@ void UndoInsertOrRemoveAnnotation::Undo() if( !(pPage && pModel) ) return; - uno::Reference<office::XAnnotation> xAnnotation( mxAnnotation ); if( mbInsert ) { - pPage->removeAnnotation( xAnnotation ); + pPage->removeAnnotation( mxAnnotation ); } else { - pPage->addAnnotation( xAnnotation, mnIndex ); + pPage->addAnnotation( mxAnnotation, mnIndex ); + uno::Reference<office::XAnnotation> xAnnotation( mxAnnotation ); LOKCommentNotifyAll( CommentNotificationType::Add, xAnnotation ); } } @@ -443,16 +441,15 @@ void UndoInsertOrRemoveAnnotation::Redo() if( !(pPage && pModel) ) return; - uno::Reference<office::XAnnotation> xAnnotation( mxAnnotation ); - if( mbInsert ) { - pPage->addAnnotation( xAnnotation, mnIndex ); + pPage->addAnnotation( mxAnnotation, mnIndex ); + uno::Reference<office::XAnnotation> xAnnotation( mxAnnotation ); LOKCommentNotifyAll( CommentNotificationType::Add, xAnnotation ); } else { - pPage->removeAnnotation( xAnnotation ); + pPage->removeAnnotation( mxAnnotation ); } } diff --git a/sd/source/core/annotations/AnnotationEnumeration.cxx b/sd/source/core/annotations/AnnotationEnumeration.cxx index 5fae2422b8f4..c622b10383bb 100644 --- a/sd/source/core/annotations/AnnotationEnumeration.cxx +++ b/sd/source/core/annotations/AnnotationEnumeration.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/container/NoSuchElementException.hpp> #include <com/sun/star/office/XAnnotationEnumeration.hpp> +#include <Annotation.hxx> #include <AnnotationEnumeration.hxx> #include <sdpage.hxx> diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 3d6c20f09984..02609a7083fa 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -66,6 +66,7 @@ #include <o3tl/sorted_vector.hxx> #include <xmloff/autolayout.hxx> +#include <Annotation.hxx> #include <Outliner.hxx> #include <app.hrc> #include <createunopageimpl.hxx> diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx index 49c4133f3bb3..0195a5578acb 100644 --- a/sd/source/core/sdpage2.cxx +++ b/sd/source/core/sdpage2.cxx @@ -378,9 +378,9 @@ void SdPage::lateInit(const SdPage& rSrcPage) rSrcPage.cloneAnimations(*this); // annotations - for(const Reference< XAnnotation >& srcAnnotation : rSrcPage.maAnnotations) + for(const rtl::Reference< Annotation >& srcAnnotation : rSrcPage.maAnnotations) { - Reference< XAnnotation > ref; + rtl::Reference< Annotation > ref; createAnnotation(ref); ref->setPosition(srcAnnotation->getPosition()); ref->setSize(srcAnnotation->getSize()); @@ -553,12 +553,12 @@ bool SdPage::Equals(const SdPage& rOtherPage) const return true; } -void SdPage::createAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotation ) +void SdPage::createAnnotation( rtl::Reference< Annotation >& xAnnotation ) { sd::createAnnotation( xAnnotation, this ); } -void SdPage::addAnnotation( const Reference< XAnnotation >& xAnnotation, int nIndex ) +void SdPage::addAnnotation( const rtl::Reference< Annotation >& xAnnotation, int nIndex ) { if( (nIndex == -1) || (nIndex > static_cast<int>(maAnnotations.size())) ) { @@ -581,10 +581,10 @@ void SdPage::addAnnotation( const Reference< XAnnotation >& xAnnotation, int nIn NotifyDocumentEvent( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()), "OnAnnotationInserted", - Reference<XInterface>(xAnnotation, UNO_QUERY)); + Reference<XInterface>(static_cast<cppu::OWeakObject*>(xAnnotation.get()), UNO_QUERY)); } -void SdPage::removeAnnotation( const Reference< XAnnotation >& xAnnotation ) +void SdPage::removeAnnotation( const rtl::Reference< Annotation >& xAnnotation ) { if( getSdrModelFromSdrPage().IsUndoEnabled() ) { @@ -601,7 +601,7 @@ void SdPage::removeAnnotation( const Reference< XAnnotation >& xAnnotation ) NotifyDocumentEvent( static_cast< SdDrawDocument& >( getSdrModelFromSdrPage() ), "OnAnnotationRemoved", - Reference<XInterface>( xAnnotation, UNO_QUERY ) ); + Reference<XInterface>( static_cast<cppu::OWeakObject*>(xAnnotation.get()), UNO_QUERY ) ); } void SdPage::getGraphicsForPrefetch(std::vector<Graphic*>& graphics) const diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx index 35b1bffbcb73..c0800010e16a 100644 --- a/sd/source/filter/pdf/sdpdffilter.cxx +++ b/sd/source/filter/pdf/sdpdffilter.cxx @@ -93,7 +93,7 @@ bool SdPdfFilter::Import() for (auto const& rPDFAnnotation : rPDFGraphicResult.GetAnnotations()) { - uno::Reference<office::XAnnotation> xAnnotation; + rtl::Reference<sd::Annotation> xAnnotation; pPage->createAnnotation(xAnnotation); xAnnotation->setAuthor(rPDFAnnotation.maAuthor); @@ -111,10 +111,9 @@ bool SdPdfFilter::Import() if (rPDFAnnotation.mpMarker) { - auto* pAnnotation = static_cast<sd::Annotation*>(xAnnotation.get()); - pAnnotation->createCustomAnnotationMarker(); + xAnnotation->createCustomAnnotationMarker(); sd::CustomAnnotationMarker& rCustomAnnotationMarker - = pAnnotation->getCustomAnnotationMarker(); + = xAnnotation->getCustomAnnotationMarker(); rCustomAnnotationMarker.maLineColor = rPDFAnnotation.maColor; @@ -191,8 +190,7 @@ bool SdPdfFilter::Import() } else if (rPDFAnnotation.meSubType == vcl::pdf::PDFAnnotationSubType::FreeText) { - auto* pAnnotation = static_cast<sd::Annotation*>(xAnnotation.get()); - pAnnotation->setIsFreeText(true); + xAnnotation->setIsFreeText(true); } } } diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 5ec59e703452..339aefa7c576 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -248,7 +248,7 @@ void SAL_CALL AnnotationManagerImpl::disposing( const css::lang::EventObject& /* { } -Reference<XAnnotation> AnnotationManagerImpl::GetAnnotationById(sal_uInt32 nAnnotationId) +rtl::Reference<Annotation> AnnotationManagerImpl::GetAnnotationById(sal_uInt32 nAnnotationId) { SdPage* pPage = nullptr; do @@ -266,7 +266,7 @@ Reference<XAnnotation> AnnotationManagerImpl::GetAnnotationById(sal_uInt32 nAnno } } while( pPage ); - Reference<XAnnotation> xAnnotationEmpty; + rtl::Reference<Annotation> xAnnotationEmpty; return xAnnotationEmpty; } @@ -355,13 +355,20 @@ void AnnotationManagerImpl::ExecuteDeleteAnnotation(SfxRequest const & rReq) break; case SID_DELETE_POSTIT: { - Reference< XAnnotation > xAnnotation; + rtl::Reference< Annotation > xAnnotation; sal_uInt32 nId = 0; if( pArgs ) { const SfxPoolItem* pPoolItem = nullptr; if( SfxItemState::SET == pArgs->GetItemState( SID_DELETE_POSTIT, true, &pPoolItem ) ) - static_cast<const SfxUnoAnyItem*>(pPoolItem)->GetValue() >>= xAnnotation; + { + uno::Reference<XAnnotation> xTmpAnnotation; + if (static_cast<const SfxUnoAnyItem*>(pPoolItem)->GetValue() >>= xTmpAnnotation) + { + xAnnotation = dynamic_cast<Annotation*>(xTmpAnnotation.get()); + assert(bool(xAnnotation) == bool(xTmpAnnotation) && "must be of concrete type sd::Annoation"); + } + } if( SfxItemState::SET == pArgs->GetItemState( SID_ATTR_POSTIT_ID, true, &pPoolItem ) ) nId = static_cast<const SvxPostItIdItem*>(pPoolItem)->GetValue().toUInt32(); } @@ -490,7 +497,7 @@ void AnnotationManagerImpl::InsertAnnotation(const OUString& rText) } } - Reference< XAnnotation > xAnnotation; + rtl::Reference< Annotation > xAnnotation; pPage->createAnnotation( xAnnotation ); OUString sAuthor; @@ -530,7 +537,7 @@ void AnnotationManagerImpl::InsertAnnotation(const OUString& rText) void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest const & rReq ) { - Reference< XAnnotation > xAnnotation; + rtl::Reference< Annotation > xAnnotation; const SfxItemSet* pArgs = rReq.GetArgs(); OUString sReplyText; if( pArgs ) @@ -543,7 +550,14 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest const & rReq ) xAnnotation = GetAnnotationById(nReplyId); } else if( SfxItemState::SET == pArgs->GetItemState( rReq.GetSlot(), true, &pPoolItem ) ) - static_cast<const SfxUnoAnyItem*>( pPoolItem )->GetValue() >>= xAnnotation; + { + uno::Reference<XAnnotation> xTmpAnnotation; + if (static_cast<const SfxUnoAnyItem*>(pPoolItem)->GetValue() >>= xTmpAnnotation) + { + xAnnotation = dynamic_cast<Annotation*>(xTmpAnnotation.get()); + assert(bool(xAnnotation) == bool(xTmpAnnotation) && "must be of concrete type sd::Annoation"); + } + } if( SfxItemState::SET == pArgs->GetItemState( SID_ATTR_POSTIT_TEXT, true, &pPoolItem ) ) sReplyText = static_cast<const SvxPostItTextItem*>( pPoolItem )->GetValue(); @@ -614,7 +628,7 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest const & rReq ) SelectAnnotation( xAnnotation, true ); } -void AnnotationManagerImpl::DeleteAnnotation( const Reference< XAnnotation >& xAnnotation ) +void AnnotationManagerImpl::DeleteAnnotation( const rtl::Reference< Annotation >& xAnnotation ) { SdPage* pPage = GetCurrentPage(); @@ -642,10 +656,9 @@ void AnnotationManagerImpl::DeleteAnnotationsByAuthor( std::u16string_view sAuth { pPage = GetNextPage( pPage, true ); - if( pPage && !pPage->getAnnotations().empty() ) + if( pPage ) { - AnnotationVector aAnnotations( pPage->getAnnotations() ); - for( Reference< XAnnotation >& xAnnotation : aAnnotations ) + for( const rtl::Reference< Annotation >& xAnnotation : pPage->getAnnotations() ) { if( xAnnotation->getAuthor() == sAuthor ) { @@ -703,7 +716,7 @@ void AnnotationManagerImpl::GetAnnotationState(SfxItemSet& rSet) rSet.Put(SfxBoolItem(SID_TOGGLE_NOTES, mbShowAnnotations)); - Reference< XAnnotation > xAnnotation; + rtl::Reference< Annotation > xAnnotation; GetSelectedAnnotation( xAnnotation ); // Don't disable these slot in case of LOK, as postit doesn't need to @@ -742,7 +755,7 @@ void AnnotationManagerImpl::SelectNextAnnotation(bool bForward) { ShowAnnotations( true ); - Reference< XAnnotation > xCurrent; + rtl::Reference< Annotation > xCurrent; GetSelectedAnnotation( xCurrent ); SdPage* pPage = GetCurrentPage(); if( !pPage ) @@ -852,7 +865,7 @@ void AnnotationManagerImpl::onTagDeselected( AnnotationTag const & rTag ) } } -void AnnotationManagerImpl::SelectAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, bool bEdit /* = sal_False */ ) +void AnnotationManagerImpl::SelectAnnotation( const rtl::Reference< Annotation >& xAnnotation, bool bEdit /* = sal_False */ ) { mxSelectedAnnotation = xAnnotation; @@ -866,7 +879,7 @@ void AnnotationManagerImpl::SelectAnnotation( const css::uno::Reference< css::of } } -void AnnotationManagerImpl::GetSelectedAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotation ) +void AnnotationManagerImpl::GetSelectedAnnotation( rtl::Reference< Annotation >& xAnnotation ) { xAnnotation = mxSelectedAnnotation; } @@ -954,7 +967,7 @@ void AnnotationManagerImpl::CreateTags() rtl::Reference< AnnotationTag > xSelectedTag; - for (const css::uno::Reference< css::office::XAnnotation > & xAnnotation : mxCurrentPage->getAnnotations() ) + for (const rtl::Reference< Annotation > & xAnnotation : mxCurrentPage->getAnnotations() ) { Color aColor( GetColorLight( mpDoc->GetAnnotationAuthorIndex( xAnnotation->getAuthor() ) ) ); rtl::Reference< AnnotationTag > xTag( new AnnotationTag( *this, *xViewShell->GetView(), xAnnotation, aColor, nIndex++, maFont ) ); @@ -1029,7 +1042,7 @@ IMPL_LINK(AnnotationManagerImpl,EventMultiplexerListener, } } -void AnnotationManagerImpl::ExecuteAnnotationTagContextMenu(const Reference<XAnnotation>& xAnnotation, weld::Widget* pParent, const ::tools::Rectangle& rContextRect) +void AnnotationManagerImpl::ExecuteAnnotationTagContextMenu(const rtl::Reference<Annotation>& xAnnotation, weld::Widget* pParent, const ::tools::Rectangle& rContextRect) { SfxDispatcher* pDispatcher( getDispatcher( mrBase ) ); if( !pDispatcher ) @@ -1063,13 +1076,13 @@ void AnnotationManagerImpl::ExecuteAnnotationTagContextMenu(const Reference<XAnn if (sId == ".uno:ReplyToAnnotation") { - const SfxUnoAnyItem aItem( SID_REPLYTO_POSTIT, Any( xAnnotation ) ); + const SfxUnoAnyItem aItem( SID_REPLYTO_POSTIT, Any( css::uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(xAnnotation.get())) ) ); pDispatcher->ExecuteList(SID_REPLYTO_POSTIT, SfxCallMode::ASYNCHRON, { &aItem }); } else if (sId == ".uno:DeleteAnnotation") { - const SfxUnoAnyItem aItem( SID_DELETE_POSTIT, Any( xAnnotation ) ); + const SfxUnoAnyItem aItem( SID_REPLYTO_POSTIT, Any( css::uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(xAnnotation.get())) ) ); pDispatcher->ExecuteList(SID_DELETE_POSTIT, SfxCallMode::ASYNCHRON, { &aItem }); } diff --git a/sd/source/ui/annotations/annotationmanagerimpl.hxx b/sd/source/ui/annotations/annotationmanagerimpl.hxx index b5fa42001b11..bbcd5a852199 100644 --- a/sd/source/ui/annotations/annotationmanagerimpl.hxx +++ b/sd/source/ui/annotations/annotationmanagerimpl.hxx @@ -38,7 +38,7 @@ struct ImplSVEvent; namespace sd { - +class Annotation; class ViewShellBase; namespace tools { @@ -73,15 +73,15 @@ public: void SelectNextAnnotation(bool bForward); - void SelectAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, bool bEdit = false ); - void GetSelectedAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotation ); + void SelectAnnotation( const rtl::Reference< Annotation >& xAnnotation, bool bEdit = false ); + void GetSelectedAnnotation( rtl::Reference< Annotation >& xAnnotation ); void InsertAnnotation(const OUString& rText); - void DeleteAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation ); + void DeleteAnnotation( const rtl::Reference< Annotation >& xAnnotation ); void DeleteAnnotationsByAuthor( std::u16string_view sAuthor ); void DeleteAllAnnotations(); - void ExecuteAnnotationTagContextMenu(const css::uno::Reference<css::office::XAnnotation>& xAnnotation, weld::Widget* pParent, const ::tools::Rectangle& rContextRect); + void ExecuteAnnotationTagContextMenu(const rtl::Reference<Annotation>& xAnnotation, weld::Widget* pParent, const ::tools::Rectangle& rContextRect); static Color GetColorDark(sal_uInt16 aAuthorIndex); static Color GetColorLight(sal_uInt16 aAuthorIndex); @@ -121,13 +121,13 @@ private: css::uno::Reference< css::drawing::XDrawView > mxView; rtl::Reference< SdPage > mxCurrentPage; - css::uno::Reference< css::office::XAnnotation > mxSelectedAnnotation; + rtl::Reference< Annotation > mxSelectedAnnotation; bool mbShowAnnotations; ImplSVEvent * mnUpdateTagsEvent; vcl::Font maFont; - css::uno::Reference<css::office::XAnnotation> GetAnnotationById(sal_uInt32 nAnnotationId); + rtl::Reference<Annotation> GetAnnotationById(sal_uInt32 nAnnotationId); }; OUString getAnnotationDateTimeString( const css::uno::Reference< css::office::XAnnotation >& xAnnotation ); diff --git a/sd/source/ui/annotations/annotationtag.cxx b/sd/source/ui/annotations/annotationtag.cxx index 4b37ffaeea62..6bea2492725e 100644 --- a/sd/source/ui/annotations/annotationtag.cxx +++ b/sd/source/ui/annotations/annotationtag.cxx @@ -162,19 +162,19 @@ namespace { class AnnotationHdl : public SmartHdl { public: - AnnotationHdl( const SmartTagReference& xTag, const Reference< XAnnotation >& xAnnotation, const Point& rPnt ); + AnnotationHdl( const SmartTagReference& xTag, const rtl::Reference< Annotation >& xAnnotation, const Point& rPnt ); virtual void CreateB2dIAObject() override; virtual bool IsFocusHdl() const override; private: - Reference< XAnnotation > mxAnnotation; + rtl::Reference< sd::Annotation > mxAnnotation; rtl::Reference< AnnotationTag > mxTag; }; } -AnnotationHdl::AnnotationHdl( const SmartTagReference& xTag, const Reference< XAnnotation >& xAnnotation, const Point& rPnt ) +AnnotationHdl::AnnotationHdl( const SmartTagReference& xTag, const rtl::Reference< Annotation >& xAnnotation, const Point& rPnt ) : SmartHdl( xTag, rPnt, SdrHdlKind::SmartTag ) , mxAnnotation( xAnnotation ) , mxTag( dynamic_cast< AnnotationTag* >( xTag.get() ) ) @@ -225,11 +225,9 @@ void AnnotationHdl::CreateB2dIAObject() { std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject; - auto* pAnnotation = dynamic_cast<sd::Annotation*>(mxAnnotation.get()); - - if (pAnnotation && pAnnotation->hasCustomAnnotationMarker()) + if (mxAnnotation && mxAnnotation->hasCustomAnnotationMarker()) { - CustomAnnotationMarker& rCustomAnnotationMarker = pAnnotation->getCustomAnnotationMarker(); + CustomAnnotationMarker& rCustomAnnotationMarker = mxAnnotation->getCustomAnnotationMarker(); auto& rPolygons = rCustomAnnotationMarker.maPolygons; if (!rPolygons.empty()) @@ -274,7 +272,7 @@ bool AnnotationHdl::IsFocusHdl() const return true; } -AnnotationTag::AnnotationTag( AnnotationManagerImpl& rManager, ::sd::View& rView, const Reference< XAnnotation >& xAnnotation, Color const & rColor, int nIndex, const vcl::Font& rFont ) +AnnotationTag::AnnotationTag( AnnotationManagerImpl& rManager, ::sd::View& rView, const rtl::Reference< Annotation >& xAnnotation, Color const & rColor, int nIndex, const vcl::Font& rFont ) : SmartTag( rView ) , mrManager( rManager ) , mxAnnotation( xAnnotation ) @@ -525,8 +523,7 @@ BitmapEx AnnotationTag::CreateAnnotationBitmap( bool bSelected ) ScopedVclPtrInstance< VirtualDevice > pVDev; OUString sText; - auto* pAnnotation = dynamic_cast<sd::Annotation*>(mxAnnotation.get()); - if (pAnnotation && pAnnotation->isFreeText()) + if (mxAnnotation && mxAnnotation->isFreeText()) { sText = mxAnnotation->getTextRange()->getString(); } diff --git a/sd/source/ui/annotations/annotationtag.hxx b/sd/source/ui/annotations/annotationtag.hxx index 23dcde13a3a8..b5807a4b08d7 100644 --- a/sd/source/ui/annotations/annotationtag.hxx +++ b/sd/source/ui/annotations/annotationtag.hxx @@ -27,14 +27,14 @@ namespace com::sun::star::office { class XAnnotation; } namespace sd { - +class Annotation; class View; class AnnotationManagerImpl; class AnnotationTag final : public SmartTag { public: - AnnotationTag( AnnotationManagerImpl& rManager, ::sd::View& rView, const css::uno::Reference< css::office::XAnnotation >& xAnnotation, Color const & rColor, int nIndex, const vcl::Font& rFont ); + AnnotationTag( AnnotationManagerImpl& rManager, ::sd::View& rView, const rtl::Reference< Annotation >& xAnnotation, Color const & rColor, int nIndex, const vcl::Font& rFont ); virtual ~AnnotationTag() override; /// @return true if the SmartTag handled the event. @@ -58,7 +58,7 @@ public: BitmapEx CreateAnnotationBitmap(bool); - const css::uno::Reference< css::office::XAnnotation >& GetAnnotation() const { return mxAnnotation; } + const rtl::Reference< Annotation >& GetAnnotation() const { return mxAnnotation; } void OpenPopup( bool bEdit ); void ClosePopup(); @@ -74,7 +74,7 @@ private: DECL_LINK(PopupModeEndHdl, weld::Popover&, void); AnnotationManagerImpl& mrManager; - css::uno::Reference< css::office::XAnnotation > mxAnnotation; + rtl::Reference< Annotation > mxAnnotation; std::unique_ptr<AnnotationWindow> mpAnnotationWindow; Color maColor; int mnIndex; diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 802aab269e46..8ae4cd0818da 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2549,7 +2549,7 @@ void SdXImpressDocument::getPostIts(::tools::JsonWriter& rJsonWriter) pPage = static_cast<SdPage*>(mpDoc->GetPage(nPage)); const sd::AnnotationVector& aPageAnnotations = pPage->getAnnotations(); - for (const uno::Reference<office::XAnnotation>& xAnnotation : aPageAnnotations) + for (const rtl::Reference<Annotation>& xAnnotation : aPageAnnotations) { sal_uInt32 nID = sd::getAnnotationId(xAnnotation); OString nodeName = "comment" + OString::number(nID); diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index efaaec7105c2..6676eac3d1b7 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -41,6 +41,7 @@ #include <toolkit/helper/vclunohelper.hxx> #include <comphelper/diagnose_ex.hxx> #include <vcl/svapp.hxx> +#include <Annotation.hxx> #include <AnnotationEnumeration.hxx> #include <createunopageimpl.hxx> #include <unomodel.hxx> @@ -2523,14 +2524,16 @@ Reference< XAnnotation > SAL_CALL SdGenericDrawPage::createAndInsertAnnotation() if( !GetPage() ) throw DisposedException(); - Reference< XAnnotation > xRet; + rtl::Reference< sd::Annotation > xRet; GetPage()->createAnnotation(xRet); return xRet; } void SAL_CALL SdGenericDrawPage::removeAnnotation(const Reference< XAnnotation > & annotation) { - GetPage()->removeAnnotation(annotation); + rtl::Reference<sd::Annotation> xSdAnnotation = dynamic_cast<sd::Annotation*>(annotation.get()); + assert(bool(annotation) == bool(xSdAnnotation) && "must be of concrete type sd::Annoation"); + GetPage()->removeAnnotation(xSdAnnotation); } Reference< XAnnotationEnumeration > SAL_CALL SdGenericDrawPage::createAnnotationEnumeration() |