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

Pranav Kant pranavk at collabora.co.uk
Mon Feb 20 08:36:18 UTC 2017


 sd/source/ui/annotations/annotationmanager.cxx     |   36 +++++++++++++++++++--
 sd/source/ui/annotations/annotationmanagerimpl.hxx |    2 +
 svx/sdi/svx.sdi                                    |    2 -
 3 files changed, 37 insertions(+), 3 deletions(-)

New commits:
commit 2613e93bd2e4f467214ae519e5472035c351eec5
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Mon Feb 20 10:15:28 2017 +0530

    sd lok: Support deleting annotations by id
    
    Change-Id: Id415fcbe8ad478c022bce23158699a17f031c1f9

diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 70d53da..1bef887 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -61,6 +61,7 @@
 #include <editeng/udlnitem.hxx>
 #include <editeng/crossedoutitem.hxx>
 
+#include <svx/postattr.hxx>
 #include <svx/svdetc.hxx>
 
 #include "annotationmanager.hxx"
@@ -68,6 +69,7 @@
 #include "annotationwindow.hxx"
 #include "annotations.hrc"
 
+#include "Annotation.hxx"
 #include "ToolBarManager.hxx"
 #include "DrawDocShell.hxx"
 #include "DrawViewShell.hxx"
@@ -244,6 +246,30 @@ void SAL_CALL AnnotationManagerImpl::disposing( const css::lang::EventObject& /*
 {
 }
 
+Reference<XAnnotation> AnnotationManagerImpl::GetAnnotationById(sal_uInt32 nAnnotationId)
+{
+    SdPage* pPage = nullptr;
+    do
+    {
+        pPage = GetNextPage(pPage, true);
+        if( pPage && !pPage->getAnnotations().empty() )
+        {
+            AnnotationVector aAnnotations(pPage->getAnnotations());
+            for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); ++iter )
+            {
+                Reference<XAnnotation> xAnnotation(*iter);
+                if( sd::getAnnotationId(xAnnotation) == nAnnotationId )
+                {
+                    return xAnnotation;
+                }
+            }
+        }
+    } while( pPage );
+
+    Reference<XAnnotation> xAnnotationEmpty;
+    return xAnnotationEmpty;
+}
+
 void AnnotationManagerImpl::ShowAnnotations( bool bShow )
 {
     // enforce show annotations if a new annotation is inserted
@@ -315,14 +341,19 @@ void AnnotationManagerImpl::ExecuteDeleteAnnotation(SfxRequest& rReq)
     case SID_DELETE_POSTIT:
         {
             Reference< XAnnotation > 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;
+                if( SfxItemState::SET == pArgs->GetItemState( SID_ATTR_POSTIT_ID, true, &pPoolItem ) )
+                    nId = static_cast<const SvxPostItIdItem*>(pPoolItem)->GetValue().toUInt32();
             }
 
-            if( !xAnnotation.is() )
+            if (nId != 0)
+                xAnnotation = GetAnnotationById(nId);
+            else if( !xAnnotation.is() )
                 GetSelectedAnnotation( xAnnotation );
 
             DeleteAnnotation( xAnnotation );
@@ -576,7 +607,8 @@ void AnnotationManagerImpl::GetAnnotationState(SfxItemSet& rSet)
     Reference< XAnnotation > xAnnotation;
     GetSelectedAnnotation( xAnnotation );
 
-    if( !xAnnotation.is() || bReadOnly )
+    // Don't disable SID_DELETE_POSTIT slot in case of LOK
+    if( (!xAnnotation.is() && !comphelper::LibreOfficeKit::isActive()) || bReadOnly )
         rSet.DisableItem( SID_DELETE_POSTIT );
 
     SdPage* pPage = nullptr;
diff --git a/sd/source/ui/annotations/annotationmanagerimpl.hxx b/sd/source/ui/annotations/annotationmanagerimpl.hxx
index b860118..5ef5139 100644
--- a/sd/source/ui/annotations/annotationmanagerimpl.hxx
+++ b/sd/source/ui/annotations/annotationmanagerimpl.hxx
@@ -128,6 +128,8 @@ private:
     bool mbPopupMenuActive;
     ImplSVEvent * mnUpdateTagsEvent;
     vcl::Font maFont;
+
+    css::uno::Reference<css::office::XAnnotation> GetAnnotationById(sal_uInt32 nAnnotationId);
 };
 
 OUString getAnnotationDateTimeString( const css::uno::Reference< css::office::XAnnotation >& xAnnotation );
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index ca91a73..bf93a6e 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -4609,7 +4609,7 @@ SfxVoidItem ReplyToAnnotation SID_REPLYTO_POSTIT
 
 
 SfxVoidItem DeleteAnnotation SID_DELETE_POSTIT
-()
+(SvxPostItIdItem Id SID_ATTR_POSTIT_ID)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,


More information about the Libreoffice-commits mailing list