diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-04-14 14:03:29 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-04-14 14:03:29 +0100 |
commit | cf8c82e1abd1961dcb88446acb84e70ca94819cf (patch) | |
tree | 866915284ebbb2a1c2c97848934f325be803a3d6 | |
parent | 11c59d1895064cdaaaaa25abfbaf04493807fed8 (diff) |
convert annotation menus to .ui
Change-Id: If827a4fb31473bf60d7619f83a5399939cdfc57a
-rw-r--r-- | sd/UIConfig_simpress.mk | 2 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationmanager.cxx | 96 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotations.hrc | 4 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotations.src | 114 | ||||
-rw-r--r-- | sd/uiconfig/simpress/ui/annotationmenu.ui | 107 | ||||
-rw-r--r-- | sd/uiconfig/simpress/ui/annotationtagmenu.ui | 47 |
6 files changed, 221 insertions, 149 deletions
diff --git a/sd/UIConfig_simpress.mk b/sd/UIConfig_simpress.mk index 1056b0faa987..a6ebd013f086 100644 --- a/sd/UIConfig_simpress.mk +++ b/sd/UIConfig_simpress.mk @@ -106,6 +106,8 @@ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/simpress,\ )) $(eval $(call gb_UIConfig_add_uifiles,modules/simpress,\ + sd/uiconfig/simpress/ui/annotationmenu \ + sd/uiconfig/simpress/ui/annotationtagmenu \ sd/uiconfig/simpress/ui/currentmastermenu \ sd/uiconfig/simpress/ui/customanimationspanel \ sd/uiconfig/simpress/ui/customanimationspanelhorizontal \ 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," ; diff --git a/sd/uiconfig/simpress/ui/annotationmenu.ui b/sd/uiconfig/simpress/ui/annotationmenu.ui new file mode 100644 index 000000000000..b5bf418e9784 --- /dev/null +++ b/sd/uiconfig/simpress/ui/annotationmenu.ui @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.0 --> +<interface> + <requires lib="gtk+" version="3.10"/> + <object class="GtkMenu" id="menu"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkMenuItem" id="reply"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Reply</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkSeparatorMenuItem" id="menuitem1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + </child> + <child> + <object class="GtkCheckMenuItem" id="bold"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Bold</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkCheckMenuItem" id="italic"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Italic</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkCheckMenuItem" id="underline"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Underline</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkCheckMenuItem" id="strike"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Strikethrough</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkSeparatorMenuItem" id="menuitem2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="copy"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Copy</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="paste"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Paste</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkSeparatorMenuItem" id="menuitem3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="delete"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Delete Comment</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="deleteby"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Delete All Comments b_y %1</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="deleteall"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Delete _All Comments</property> + <property name="use_underline">True</property> + </object> + </child> + </object> +</interface> diff --git a/sd/uiconfig/simpress/ui/annotationtagmenu.ui b/sd/uiconfig/simpress/ui/annotationtagmenu.ui new file mode 100644 index 000000000000..f65dea877a7e --- /dev/null +++ b/sd/uiconfig/simpress/ui/annotationtagmenu.ui @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.0 --> +<interface> + <requires lib="gtk+" version="3.10"/> + <object class="GtkMenu" id="menu"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkMenuItem" id="reply"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Reply</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkSeparatorMenuItem" id="menuitem1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="delete"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_Delete Comment</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="deleteby"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Delete All Comments b_y %1</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="deleteall"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Delete _All Comments</property> + <property name="use_underline">True</property> + </object> + </child> + </object> +</interface> |