[Libreoffice-commits] core.git: sd/source

Pranav Kant pranavk at collabora.co.uk
Mon Feb 20 08:38:12 UTC 2017


 sd/source/ui/annotations/annotationmanager.cxx     |   27 +++++++++++++++++----
 sd/source/ui/annotations/annotationmanagerimpl.hxx |    2 -
 2 files changed, 24 insertions(+), 5 deletions(-)

New commits:
commit 2c58754fac268fe41c892e049a6a7a28e717cd72
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Mon Feb 20 10:30:02 2017 +0530

    sd lok: Allow specifying text in the insert uno command
    
    Change-Id: Ia352f0ec073449422e7d0b1327bb85d9b04356c0

diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 1bef887..56aaf8c 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 5ef5139..03e05cf 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();


More information about the Libreoffice-commits mailing list