summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-02-20 10:15:28 +0530
committerAndras Timar <andras.timar@collabora.com>2017-02-28 11:11:17 +0100
commit4b725ebc4e2422bb09d837b657c4f4c96a5ab43d (patch)
tree270ed2e8804a097fdb6367cf78907a92caaf9121
parentfbd58517003bad10a17ddf7eba5387ce1a36d942 (diff)
sd lok: Support deleting annotations by id
Change-Id: Id415fcbe8ad478c022bce23158699a17f031c1f9 (cherry picked from commit 2613e93bd2e4f467214ae519e5472035c351eec5)
-rw-r--r--sd/source/ui/annotations/annotationmanager.cxx36
-rw-r--r--sd/source/ui/annotations/annotationmanagerimpl.hxx2
-rw-r--r--svx/sdi/svx.sdi2
3 files changed, 37 insertions, 3 deletions
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 63e54fdd82d5..69c774b0448c 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 04ceb976e5c0..ea17fb72f693 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 0ec02dfb659c..aa0f036bee95 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -4594,7 +4594,7 @@ SfxVoidItem ReplyToAnnotation SID_REPLYTO_POSTIT
SfxVoidItem DeleteAnnotation SID_DELETE_POSTIT
-()
+(SvxPostItIdItem Id SID_ATTR_POSTIT_ID)
[
AutoUpdate = FALSE,
FastCall = FALSE,