summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-04-02 11:04:38 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-04-02 13:04:21 +0200
commitdb8b19a77ba0c115c1e0b0ad067ef433a3aa3a79 (patch)
tree74409f15241a7c378036bf9107f01e8c3a000504
parent354c9e03790f837cc2fa0d6b8474425612e182e6 (diff)
use more concrete UNO types in sd
Change-Id: Iea48c8750c940441c5687068317107a5932799e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165670 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sd/inc/Annotation.hxx10
-rw-r--r--sd/source/core/annotations/Annotation.cxx42
-rw-r--r--sd/source/ui/annotations/annotationmanager.cxx8
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx2
4 files changed, 19 insertions, 43 deletions
diff --git a/sd/inc/Annotation.hxx b/sd/inc/Annotation.hxx
index 12354e493ae4..965cbded3719 100644
--- a/sd/inc/Annotation.hxx
+++ b/sd/inc/Annotation.hxx
@@ -50,17 +50,13 @@ enum class CommentNotificationType { Add, Modify, Remove };
void createAnnotation( rtl::Reference< Annotation >& xAnnotation, SdPage* pPage );
-std::unique_ptr<SdrUndoAction> CreateUndoInsertOrRemoveAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, bool bInsert );
-
-sal_uInt32 getAnnotationId(const css::uno::Reference <css::office::XAnnotation>& xAnnotation);
-
-const SdPage* getAnnotationPage(const css::uno::Reference<css::office::XAnnotation>& xAnnotation);
+std::unique_ptr<SdrUndoAction> CreateUndoInsertOrRemoveAnnotation( const rtl::Reference< sd::Annotation >& xAnnotation, bool bInsert );
void LOKCommentNotify(CommentNotificationType nType, const SfxViewShell* pViewShell,
- css::uno::Reference<css::office::XAnnotation> const & rxAnnotation);
+ rtl::Reference<sd::Annotation> const & rxAnnotation);
void LOKCommentNotifyAll(CommentNotificationType nType,
- css::uno::Reference<css::office::XAnnotation> const & rxAnnotation);
+ rtl::Reference<sd::Annotation> const & rxAnnotation);
struct SD_DLLPUBLIC CustomAnnotationMarker
{
diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx
index 92bcbc28903d..fee7312bcca2 100644
--- a/sd/source/core/annotations/Annotation.cxx
+++ b/sd/source/core/annotations/Annotation.cxx
@@ -312,12 +312,11 @@ uno::Reference<text::XText> SAL_CALL Annotation::getTextRange()
return m_TextRange;
}
-std::unique_ptr<SdrUndoAction> CreateUndoInsertOrRemoveAnnotation( const uno::Reference<office::XAnnotation>& xAnnotation, bool bInsert )
+std::unique_ptr<SdrUndoAction> CreateUndoInsertOrRemoveAnnotation( const rtl::Reference<sd::Annotation>& xAnnotation, bool bInsert )
{
- Annotation* pAnnotation = dynamic_cast< Annotation* >( xAnnotation.get() );
- if( pAnnotation )
+ if( xAnnotation )
{
- return std::make_unique< UndoInsertOrRemoveAnnotation >( *pAnnotation, bInsert );
+ return std::make_unique< UndoInsertOrRemoveAnnotation >( *xAnnotation, bInsert );
}
else
{
@@ -325,26 +324,9 @@ std::unique_ptr<SdrUndoAction> CreateUndoInsertOrRemoveAnnotation( const uno::Re
}
}
-sal_uInt32 getAnnotationId(const uno::Reference<office::XAnnotation>& xAnnotation)
-{
- Annotation* pAnnotation = dynamic_cast<Annotation*>(xAnnotation.get());
- sal_uInt32 nId = 0;
- if (pAnnotation)
- nId = pAnnotation->GetId();
- return nId;
-}
-
-const SdPage* getAnnotationPage(const uno::Reference<office::XAnnotation>& xAnnotation)
-{
- Annotation* pAnnotation = dynamic_cast<Annotation*>(xAnnotation.get());
- if (pAnnotation)
- return pAnnotation->GetPage();
- return nullptr;
-}
-
namespace
{
-OString lcl_LOKGetCommentPayload(CommentNotificationType nType, uno::Reference<office::XAnnotation> const & rxAnnotation)
+OString lcl_LOKGetCommentPayload(CommentNotificationType nType, rtl::Reference<sd::Annotation> const & rxAnnotation)
{
::tools::JsonWriter aJsonWriter;
{
@@ -353,16 +335,16 @@ OString lcl_LOKGetCommentPayload(CommentNotificationType nType, uno::Reference<o
aJsonWriter.put("action", (nType == CommentNotificationType::Add ? "Add" :
(nType == CommentNotificationType::Remove ? "Remove" :
(nType == CommentNotificationType::Modify ? "Modify" : "???"))));
- aJsonWriter.put("id", sd::getAnnotationId(rxAnnotation));
+ aJsonWriter.put("id", rxAnnotation->GetId());
if (nType != CommentNotificationType::Remove && rxAnnotation.is())
{
- aJsonWriter.put("id", sd::getAnnotationId(rxAnnotation));
+ aJsonWriter.put("id", rxAnnotation->GetId());
aJsonWriter.put("author", rxAnnotation->getAuthor());
aJsonWriter.put("dateTime", utl::toISO8601(rxAnnotation->getDateTime()));
uno::Reference<text::XText> xText(rxAnnotation->getTextRange());
aJsonWriter.put("text", xText->getString());
- const SdPage* pPage = sd::getAnnotationPage(rxAnnotation);
+ const SdPage* pPage = rxAnnotation->GetPage();
aJsonWriter.put("parthash", pPage ? OString::number(pPage->GetHashCode()) : OString());
geometry::RealPoint2D const & rPoint = rxAnnotation->getPosition();
geometry::RealSize2D const & rSize = rxAnnotation->getSize();
@@ -377,7 +359,7 @@ OString lcl_LOKGetCommentPayload(CommentNotificationType nType, uno::Reference<o
}
} // anonymous ns
-void LOKCommentNotify(CommentNotificationType nType, const SfxViewShell* pViewShell, uno::Reference<office::XAnnotation> const & rxAnnotation)
+void LOKCommentNotify(CommentNotificationType nType, const SfxViewShell* pViewShell, rtl::Reference<sd::Annotation> const & rxAnnotation)
{
// callbacks only if tiled annotations are explicitly turned off by LOK client
if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations())
@@ -387,7 +369,7 @@ void LOKCommentNotify(CommentNotificationType nType, const SfxViewShell* pViewSh
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload);
}
-void LOKCommentNotifyAll(CommentNotificationType nType, uno::Reference<office::XAnnotation> const & rxAnnotation)
+void LOKCommentNotifyAll(CommentNotificationType nType, rtl::Reference<sd::Annotation> const & rxAnnotation)
{
// callbacks only if tiled annotations are explicitly turned off by LOK client
if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations())
@@ -432,8 +414,7 @@ void UndoInsertOrRemoveAnnotation::Undo()
else
{
pPage->addAnnotation( mxAnnotation, mnIndex );
- uno::Reference<office::XAnnotation> xAnnotation( mxAnnotation );
- LOKCommentNotifyAll( CommentNotificationType::Add, xAnnotation );
+ LOKCommentNotifyAll( CommentNotificationType::Add, mxAnnotation );
}
}
@@ -447,8 +428,7 @@ void UndoInsertOrRemoveAnnotation::Redo()
if( mbInsert )
{
pPage->addAnnotation( mxAnnotation, mnIndex );
- uno::Reference<office::XAnnotation> xAnnotation( mxAnnotation );
- LOKCommentNotifyAll( CommentNotificationType::Add, xAnnotation );
+ LOKCommentNotifyAll( CommentNotificationType::Add, mxAnnotation );
}
else
{
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 04be49385849..ed16758d4baf 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -235,9 +235,9 @@ void SAL_CALL AnnotationManagerImpl::notifyEvent( const css::document::EventObje
if ( aEvent.EventName == "OnAnnotationRemoved" )
{
Reference< XAnnotation > xAnnotation( aEvent.Source, uno::UNO_QUERY );
- if ( xAnnotation.is() )
+ if ( auto pAnnotation = dynamic_cast<sd::Annotation*>(xAnnotation.get()) )
{
- LOKCommentNotify(CommentNotificationType::Remove, &mrBase, xAnnotation);
+ LOKCommentNotify(CommentNotificationType::Remove, &mrBase, pAnnotation);
}
}
@@ -258,8 +258,8 @@ rtl::Reference<Annotation> AnnotationManagerImpl::GetAnnotationById(sal_uInt32 n
{
AnnotationVector aAnnotations(pPage->getAnnotations());
auto iter = std::find_if(aAnnotations.begin(), aAnnotations.end(),
- [nAnnotationId](const Reference<XAnnotation>& xAnnotation) {
- return sd::getAnnotationId(xAnnotation) == nAnnotationId;
+ [nAnnotationId](const rtl::Reference<sd::Annotation>& xAnnotation) {
+ return xAnnotation->GetId() == nAnnotationId;
});
if (iter != aAnnotations.end())
return *iter;
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 8139ea4686e3..6dbc5bd57a25 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2564,7 +2564,7 @@ void SdXImpressDocument::getPostIts(::tools::JsonWriter& rJsonWriter)
for (const rtl::Reference<Annotation>& xAnnotation : aPageAnnotations)
{
- sal_uInt32 nID = sd::getAnnotationId(xAnnotation);
+ sal_uInt32 nID = xAnnotation->GetId();
OString nodeName = "comment" + OString::number(nID);
auto commentNode = rJsonWriter.startNode(nodeName);
rJsonWriter.put("id", nID);