summaryrefslogtreecommitdiff
path: root/sd/source/ui/annotations
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-04-14 14:03:29 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-04-14 14:03:29 +0100
commitcf8c82e1abd1961dcb88446acb84e70ca94819cf (patch)
tree866915284ebbb2a1c2c97848934f325be803a3d6 /sd/source/ui/annotations
parent11c59d1895064cdaaaaa25abfbaf04493807fed8 (diff)
convert annotation menus to .ui
Change-Id: If827a4fb31473bf60d7619f83a5399939cdfc57a
Diffstat (limited to 'sd/source/ui/annotations')
-rw-r--r--sd/source/ui/annotations/annotationmanager.cxx96
-rw-r--r--sd/source/ui/annotations/annotations.hrc4
-rw-r--r--sd/source/ui/annotations/annotations.src114
3 files changed, 65 insertions, 149 deletions
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 465f83698382..b2680c08bf11 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -1089,6 +1089,34 @@ IMPL_LINK(AnnotationManagerImpl,EventMultiplexerListener,
}
}
+namespace
+{
+ sal_uInt16 IdentToSID(const OString& rIdent)
+ {
+ if (rIdent == "reply")
+ return SID_REPLYTO_POSTIT;
+ else if (rIdent == "delete")
+ return SID_DELETE_POSTIT;
+ else if (rIdent == "deleteby")
+ return SID_DELETEALLBYAUTHOR_POSTIT;
+ else if (rIdent == "deleteall")
+ return SID_DELETEALL_POSTIT;
+ else if (rIdent == "copy")
+ return SID_COPY;
+ else if (rIdent == "paste")
+ return SID_PASTE;
+ else if (rIdent == "bold")
+ return SID_ATTR_CHAR_WEIGHT;
+ else if (rIdent == "italic")
+ return SID_ATTR_CHAR_POSTURE;
+ else if (rIdent == "underline")
+ return SID_ATTR_CHAR_UNDERLINE;
+ else if (rIdent == "strike")
+ return SID_ATTR_CHAR_STRIKEOUT;
+ return 0;
+ }
+}
+
void AnnotationManagerImpl::ExecuteAnnotationContextMenu( const Reference< XAnnotation >& xAnnotation, vcl::Window* pParent, const ::tools::Rectangle& rContextRect, bool bButtonMenu /* = false */ )
{
SfxDispatcher* pDispatcher( getDispatcher( mrBase ) );
@@ -1102,32 +1130,38 @@ void AnnotationManagerImpl::ExecuteAnnotationContextMenu( const Reference< XAnno
if( bReadOnly && !pAnnotationWindow )
return;
- ScopedVclPtrInstance<PopupMenu> pMenu( SdResId( pAnnotationWindow ? RID_ANNOTATION_CONTEXTMENU : RID_ANNOTATION_TAG_CONTEXTMENU ) );
+ OUString sUIFile;
+ if (pAnnotationWindow)
+ sUIFile = "modules/simpress/ui/annotationmenu.ui";
+ else
+ sUIFile = "modules/simpress/ui/annotationtagmenu.ui";
+ VclBuilder aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), sUIFile, "");
+ VclPtr<PopupMenu> pMenu(aBuilder.get_menu("menu"));
SvtUserOptions aUserOptions;
OUString sCurrentAuthor( aUserOptions.GetFullName() );
OUString sAuthor( xAnnotation->getAuthor() );
- OUString aStr( pMenu->GetItemText( SID_DELETEALLBYAUTHOR_POSTIT ) );
+ OUString aStr(pMenu->GetItemText(pMenu->GetItemId("deleteby")));
OUString aReplace( sAuthor );
if( aReplace.isEmpty() )
aReplace = SD_RESSTR( STR_ANNOTATION_NOAUTHOR );
aStr = aStr.replaceFirst("%1", aReplace);
- pMenu->SetItemText( SID_DELETEALLBYAUTHOR_POSTIT, aStr );
- pMenu->EnableItem( SID_REPLYTO_POSTIT, (sAuthor != sCurrentAuthor) && !bReadOnly );
- pMenu->EnableItem( SID_DELETE_POSTIT, xAnnotation.is() && !bReadOnly );
- pMenu->EnableItem( SID_DELETEALLBYAUTHOR_POSTIT, !bReadOnly );
- pMenu->EnableItem( SID_DELETEALL_POSTIT, !bReadOnly );
+ pMenu->SetItemText(pMenu->GetItemId("deleteby"), aStr);
+ pMenu->EnableItem(pMenu->GetItemId("reply"), (sAuthor != sCurrentAuthor) && !bReadOnly);
+ pMenu->EnableItem(pMenu->GetItemId("delete"), xAnnotation.is() && !bReadOnly);
+ pMenu->EnableItem(pMenu->GetItemId("deleteby"), !bReadOnly);
+ pMenu->EnableItem(pMenu->GetItemId("deleteall"), !bReadOnly);
if( pAnnotationWindow )
{
if( pAnnotationWindow->IsProtected() || bReadOnly )
{
- pMenu->EnableItem( SID_ATTR_CHAR_WEIGHT, false );
- pMenu->EnableItem( SID_ATTR_CHAR_POSTURE, false );
- pMenu->EnableItem( SID_ATTR_CHAR_UNDERLINE, false );
- pMenu->EnableItem( SID_ATTR_CHAR_STRIKEOUT, false );
- pMenu->EnableItem( SID_PASTE, false );
+ pMenu->EnableItem(pMenu->GetItemId("bold"), false);
+ pMenu->EnableItem(pMenu->GetItemId("italic"), false);
+ pMenu->EnableItem(pMenu->GetItemId("underline"), false);
+ pMenu->EnableItem(pMenu->GetItemId("strike"), false);
+ pMenu->EnableItem(pMenu->GetItemId("paste"), false);
}
else
{
@@ -1136,51 +1170,50 @@ void AnnotationManagerImpl::ExecuteAnnotationContextMenu( const Reference< XAnno
if ( aSet.GetItemState( EE_CHAR_WEIGHT ) == SfxItemState::SET )
{
if( static_cast<const SvxWeightItem&>(aSet.Get( EE_CHAR_WEIGHT )).GetWeight() == WEIGHT_BOLD )
- pMenu->CheckItem( SID_ATTR_CHAR_WEIGHT );
+ pMenu->CheckItem(pMenu->GetItemId("bold"));
}
if ( aSet.GetItemState( EE_CHAR_ITALIC ) == SfxItemState::SET )
{
if( static_cast<const SvxPostureItem&>(aSet.Get( EE_CHAR_ITALIC )).GetPosture() != ITALIC_NONE )
- pMenu->CheckItem( SID_ATTR_CHAR_POSTURE );
+ pMenu->CheckItem(pMenu->GetItemId("italic"));
}
if ( aSet.GetItemState( EE_CHAR_UNDERLINE ) == SfxItemState::SET )
{
if( static_cast<const SvxUnderlineItem&>(aSet.Get( EE_CHAR_UNDERLINE )).GetLineStyle() != LINESTYLE_NONE )
- pMenu->CheckItem( SID_ATTR_CHAR_UNDERLINE );
+ pMenu->CheckItem(pMenu->GetItemId("underline"));
}
if ( aSet.GetItemState( EE_CHAR_STRIKEOUT ) == SfxItemState::SET )
{
if( static_cast<const SvxCrossedOutItem&>(aSet.Get( EE_CHAR_STRIKEOUT )).GetStrikeout() != STRIKEOUT_NONE )
- pMenu->CheckItem( SID_ATTR_CHAR_STRIKEOUT );
+ pMenu->CheckItem(pMenu->GetItemId("strike"));
}
TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pAnnotationWindow ) );
- pMenu->EnableItem( SID_PASTE, aDataHelper.GetFormatCount() != 0 );
+ pMenu->EnableItem(pMenu->GetItemId("paste"), aDataHelper.GetFormatCount() != 0);
}
- pMenu->EnableItem( SID_COPY, pAnnotationWindow->getView()->HasSelection() );
+ pMenu->EnableItem(pMenu->GetItemId("copy"), pAnnotationWindow->getView()->HasSelection());
}
- sal_uInt16 nId = 0;
-
// set slot images
Reference< css::frame::XFrame > xFrame( mrBase.GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface() );
if( xFrame.is() )
{
for( sal_uInt16 nPos = 0; nPos < pMenu->GetItemCount(); nPos++ )
{
- nId = pMenu->GetItemId( nPos );
- if( pMenu->IsItemEnabled( nId ) )
- {
- OUString sSlotURL( "slot:" );
- sSlotURL += OUString::number( nId);
-
- Image aImage( GetImage( xFrame, sSlotURL, false ) );
- if( !!aImage )
- pMenu->SetItemImage( nId, aImage );
- }
+ sal_uInt16 nId = pMenu->GetItemId( nPos );
+ if (!pMenu->IsItemEnabled(nId))
+ continue;
+ OString sIdent = pMenu->GetItemIdent(nId);
+ sal_uInt16 nSID = IdentToSID(sIdent);
+ OUString sSlotURL( "slot:" );
+ sSlotURL += OUString::number(nSID);
+
+ Image aImage( GetImage( xFrame, sSlotURL, false ) );
+ if( !!aImage )
+ pMenu->SetItemImage( nId, aImage );
}
}
@@ -1188,7 +1221,8 @@ void AnnotationManagerImpl::ExecuteAnnotationContextMenu( const Reference< XAnno
// allow suppressing closing of that window if needed
setPopupMenuActive(true);
- nId = pMenu->Execute( pParent, rContextRect, PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose );
+ sal_uInt16 nId = pMenu->Execute( pParent, rContextRect, PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose );
+ nId = IdentToSID(pMenu->GetItemIdent(nId));
// tdf#99388 and tdf#99712 reset flag, need to be done before reacting
// since closing it is one possible reaction
diff --git a/sd/source/ui/annotations/annotations.hrc b/sd/source/ui/annotations/annotations.hrc
index 246c911775ef..b14a1139552f 100644
--- a/sd/source/ui/annotations/annotations.hrc
+++ b/sd/source/ui/annotations/annotations.hrc
@@ -36,10 +36,6 @@
#define STR_ANNOTATION_UNDO_EDIT (RID_ANNOTATIONS_START+11)
#define STR_ANNOTATION_REPLY (RID_ANNOTATIONS_START+13)
-// menus
-#define RID_ANNOTATION_CONTEXTMENU (RID_ANNOTATIONS_START+0)
-#define RID_ANNOTATION_TAG_CONTEXTMENU (RID_ANNOTATIONS_START+1)
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/annotations/annotations.src b/sd/source/ui/annotations/annotations.src
index 3fd1b68bfe2c..05bfe4820d44 100644
--- a/sd/source/ui/annotations/annotations.src
+++ b/sd/source/ui/annotations/annotations.src
@@ -22,120 +22,6 @@
#include <svx/svxids.hrc>
#include "helpids.h"
-Menu RID_ANNOTATION_CONTEXTMENU
-{
- ItemList =
- {
- MenuItem
- {
- Identifier = SID_REPLYTO_POSTIT;
- HelpId = CMD_SID_REPLYTO_POSTIT ;
- Text [ en-US ] = "~Reply";
- };
- MenuItem
- {
- Separator = TRUE;
- };
- MenuItem
- {
- Identifier = SID_ATTR_CHAR_WEIGHT;
- HelpId = CMD_SID_ATTR_CHAR_WEIGHT ;
- Text [ en-US ] = "~Bold";
- };
- MenuItem
- {
- Identifier = SID_ATTR_CHAR_POSTURE;
- HelpId = CMD_SID_ATTR_CHAR_POSTURE;
- Text [ en-US ] = "~Italic";
- };
- MenuItem
- {
- Identifier = SID_ATTR_CHAR_UNDERLINE;
- HelpId = CMD_SID_ATTR_CHAR_UNDERLINE;
- Text [ en-US ] = "~Underline";
- };
- MenuItem
- {
- Identifier = SID_ATTR_CHAR_STRIKEOUT;
- HelpId = CMD_SID_ATTR_CHAR_STRIKEOUT;
- Text [ en-US ] = "~Strikethrough";
- };
- MenuItem
- {
- Separator = TRUE;
- };
- MenuItem
- {
- Identifier = SID_COPY ;
- HelpId = CMD_SID_COPY ;
- Text [ en-US ] = "~Copy" ;
- };
- MenuItem
- {
- Identifier = SID_PASTE ;
- HelpId = CMD_SID_PASTE ;
- Text [ en-US ] = "~Paste" ;
- };
- MenuItem
- {
- Separator = TRUE;
- };
- MenuItem
- {
- Identifier = SID_DELETE_POSTIT ;
- HelpId = CMD_SID_DELETE_POSTIT;
- Text [ en-US ] = "~Delete Comment" ;
- };
- MenuItem
- {
- Identifier = SID_DELETEALLBYAUTHOR_POSTIT ;
- HelpId = CMD_SID_DELETEALLBYAUTHOR_POSTIT;
- Text [ en-US ] = "Delete All Comments b~y %1" ;
- };
- MenuItem
- {
- Identifier = SID_DELETEALL_POSTIT;
- HelpId = CMD_SID_DELETEALL_POSTIT;
- Text [ en-US ] = "Delete ~All Comments" ;
- };
- };
-};
-
-Menu RID_ANNOTATION_TAG_CONTEXTMENU
-{
- ItemList =
- {
- MenuItem
- {
- Identifier = SID_REPLYTO_POSTIT;
- HelpId = CMD_SID_REPLYTO_POSTIT;
- Text [ en-US ] = "~Reply";
- };
- MenuItem
- {
- Separator = TRUE;
- };
- MenuItem
- {
- Identifier = SID_DELETE_POSTIT ;
- HelpId = CMD_SID_DELETE_POSTIT ;
- Text [ en-US ] = "~Delete Comment" ;
- };
- MenuItem
- {
- Identifier = SID_DELETEALLBYAUTHOR_POSTIT ;
- HelpId = CMD_SID_DELETEALLBYAUTHOR_POSTIT ;
- Text [ en-US ] = "Delete All Comments ~by %1" ;
- };
- MenuItem
- {
- Identifier = SID_DELETEALL_POSTIT;
- HelpId = CMD_SID_DELETEALL_POSTIT;
- Text [ en-US ] = "Delete ~All Comments" ;
- };
- };
-};
-
String STR_ANNOTATION_TODAY
{
Text [ en-US ] = "Today," ;