diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-02-20 10:30:02 +0530 |
---|---|---|
committer | Pranav Kant <pranavk@collabora.co.uk> | 2017-02-20 14:07:21 +0530 |
commit | 2c58754fac268fe41c892e049a6a7a28e717cd72 (patch) | |
tree | 0ba6132b94ca25421584e60694c7a33e52991d4d | |
parent | 2613e93bd2e4f467214ae519e5472035c351eec5 (diff) |
sd lok: Allow specifying text in the insert uno command
Change-Id: Ia352f0ec073449422e7d0b1327bb85d9b04356c0
-rw-r--r-- | sd/source/ui/annotations/annotationmanager.cxx | 27 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationmanagerimpl.hxx | 2 |
2 files changed, 24 insertions, 5 deletions
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 1bef8877276f..56aaf8c8aa11 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -310,10 +310,23 @@ void AnnotationManagerImpl::ExecuteAnnotation(SfxRequest& rReq ) } } -void AnnotationManagerImpl::ExecuteInsertAnnotation(SfxRequest& /*rReq*/) +void AnnotationManagerImpl::ExecuteInsertAnnotation(SfxRequest& rReq) { - ShowAnnotations(true); - InsertAnnotation(); + if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations()) + ShowAnnotations(true); + + const SfxItemSet* pArgs = rReq.GetArgs(); + OUString sText; + if (pArgs) + { + const SfxPoolItem* pPoolItem = nullptr; + if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_TEXT, true, &pPoolItem)) + { + sText = static_cast<const SfxStringItem*>(pPoolItem)->GetValue(); + } + } + + InsertAnnotation(sText); } void AnnotationManagerImpl::ExecuteDeleteAnnotation(SfxRequest& rReq) @@ -364,7 +377,7 @@ void AnnotationManagerImpl::ExecuteDeleteAnnotation(SfxRequest& rReq) UpdateTags(); } -void AnnotationManagerImpl::InsertAnnotation() +void AnnotationManagerImpl::InsertAnnotation(const OUString& rText) { SdPage* pPage = GetCurrentPage(); if( pPage ) @@ -432,6 +445,12 @@ void AnnotationManagerImpl::InsertAnnotation() xAnnotation->setInitials( aUserOptions.GetID() ); } + if (!rText.isEmpty()) + { + Reference<XText> xText(xAnnotation->getTextRange()); + xText->setString(rText); + } + // set current author to new annotation xAnnotation->setAuthor( sAuthor ); // set current time to new annotation diff --git a/sd/source/ui/annotations/annotationmanagerimpl.hxx b/sd/source/ui/annotations/annotationmanagerimpl.hxx index 5ef5139749ff..03e05cfecbe7 100644 --- a/sd/source/ui/annotations/annotationmanagerimpl.hxx +++ b/sd/source/ui/annotations/annotationmanagerimpl.hxx @@ -73,7 +73,7 @@ public: void SelectAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation, bool bEdit = false ); void GetSelectedAnnotation( css::uno::Reference< css::office::XAnnotation >& xAnnotation ); - void InsertAnnotation(); + void InsertAnnotation(const OUString& rText); void DeleteAnnotation( const css::uno::Reference< css::office::XAnnotation >& xAnnotation ); void DeleteAnnotationsByAuthor( const OUString& sAuthor ); void DeleteAllAnnotations(); |