diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-04-12 14:30:36 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-04-12 14:43:05 +0100 |
commit | d74689c15170b5bad3e2230b4ea99bb1d9dd1e60 (patch) | |
tree | be281eb744f56052ebaa061049919051fb2dc9d3 /sw | |
parent | 4f55dfb564e56515b6ebb4d10b089f67ad628fb6 (diff) |
convert header/footer menu to .ui
Change-Id: Ia1aed81bfd806fbca78acc3b23886056a23ade4d
Diffstat (limited to 'sw')
-rw-r--r-- | sw/UIConfig_swriter.mk | 1 | ||||
-rw-r--r-- | sw/inc/cmdid.h | 4 | ||||
-rw-r--r-- | sw/inc/swcommands.h | 3 | ||||
-rw-r--r-- | sw/source/ui/app/mn.src | 23 | ||||
-rw-r--r-- | sw/source/uibase/docvw/HeaderFooterWin.cxx | 138 | ||||
-rw-r--r-- | sw/source/uibase/inc/HeaderFooterWin.hxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/inc/popup.hrc | 3 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/headerfootermenu.ui | 31 |
8 files changed, 101 insertions, 107 deletions
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index 81d073621edd..66e19966b996 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -149,6 +149,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\ sw/uiconfig/swriter/ui/frmtypepage \ sw/uiconfig/swriter/ui/frmurlpage \ sw/uiconfig/swriter/ui/gotopagedialog \ + sw/uiconfig/swriter/ui/headerfootermenu \ sw/uiconfig/swriter/ui/indexentry \ sw/uiconfig/swriter/ui/inputfielddialog \ sw/uiconfig/swriter/ui/inputwinmenu \ diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 9e718b820487..0b2662a3089d 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -711,10 +711,6 @@ #define FN_REPLY (FN_NOTES+7) #define FN_FORMAT_ALL_NOTES (FN_NOTES+8) -#define FN_HEADERFOOTER_EDIT (FN_HEADERFOOTER+1) -#define FN_HEADERFOOTER_DELETE (FN_HEADERFOOTER+2) -#define FN_HEADERFOOTER_BORDERBACK (FN_HEADERFOOTER+3) - // Region: Parameter #define FN_PARAM_MOVE_COUNT (FN_PARAM+2) #define FN_PARAM_MOVE_SELECTION (FN_PARAM+3) diff --git a/sw/inc/swcommands.h b/sw/inc/swcommands.h index d1ad3e7a5ba4..e726c818344e 100644 --- a/sw/inc/swcommands.h +++ b/sw/inc/swcommands.h @@ -32,9 +32,6 @@ #define CMD_FN_REDLINE_REJECT_DIRECT ".uno:RejectTrackedChange" #define CMD_FN_REDLINE_NEXT_CHANGE ".uno:NextTrackedChange" #define CMD_FN_REDLINE_PREV_CHANGE ".uno:PreviousTrackedChange" -#define CMD_FN_HEADERFOOTER_EDIT ".uno:HeaderFooterEdit" -#define CMD_FN_HEADERFOOTER_DELETE ".uno:HeaderFooterDelete" -#define CMD_FN_HEADERFOOTER_BORDERBACK ".uno:HeaderFooterBorderBackground" #endif diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src index fe71b4d08838..984e7ebf55b7 100644 --- a/sw/source/ui/app/mn.src +++ b/sw/source/ui/app/mn.src @@ -89,27 +89,4 @@ Menu MN_ANNOTATION_BUTTON }; }; -Menu MN_HEADERFOOTER_BUTTON -{ - ItemList = - { - MenuItem - { - Identifier = FN_HEADERFOOTER_EDIT ; - HelpID = CMD_FN_HEADERFOOTER_EDIT ; - }; - MenuItem - { - Identifier = FN_HEADERFOOTER_BORDERBACK ; - HelpID = CMD_FN_HEADERFOOTER_BORDERBACK ; - Text [ en-US ] = "Border and Background..." ; - }; - MenuItem - { - Identifier = FN_HEADERFOOTER_DELETE ; - HelpID = CMD_FN_HEADERFOOTER_DELETE ; - }; - }; -}; - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/docvw/HeaderFooterWin.cxx b/sw/source/uibase/docvw/HeaderFooterWin.cxx index f686d8c4fc04..85e2836ab08e 100644 --- a/sw/source/uibase/docvw/HeaderFooterWin.cxx +++ b/sw/source/uibase/docvw/HeaderFooterWin.cxx @@ -126,8 +126,9 @@ namespace SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwFrame *pFrame, bool bHeader ) : SwFrameMenuButtonBase( pEditWin, pFrame ), + m_aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/swriter/ui/headerfootermenu.ui", ""), m_bIsHeader( bHeader ), - m_pPopupMenu( nullptr ), + m_pPopupMenu(m_aBuilder.get_menu("menu")), m_pLine( nullptr ), m_bIsAppearing( false ), m_nFadeRate( 100 ), @@ -143,19 +144,17 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwFrame *pFrame m_pLine = VclPtr<SwDashedLine>::Create(GetEditWin(), &SwViewOption::GetHeaderFooterMarkColor); m_pLine->SetZOrder(this, ZOrderFlags::Before); - // Create and set the PopupMenu - m_pPopupMenu = VclPtr<PopupMenu>::Create(SW_RES(MN_HEADERFOOTER_BUTTON)); - + // set the PopupMenu // Rewrite the menu entries' text if (m_bIsHeader) { - m_pPopupMenu->SetItemText(FN_HEADERFOOTER_EDIT, SW_RESSTR(STR_FORMAT_HEADER)); - m_pPopupMenu->SetItemText(FN_HEADERFOOTER_DELETE, SW_RESSTR(STR_DELETE_HEADER)); + m_pPopupMenu->SetItemText(m_pPopupMenu->GetItemId("edit"), SW_RESSTR(STR_FORMAT_HEADER)); + m_pPopupMenu->SetItemText(m_pPopupMenu->GetItemId("delete"), SW_RESSTR(STR_DELETE_HEADER)); } else { - m_pPopupMenu->SetItemText(FN_HEADERFOOTER_EDIT, SW_RESSTR(STR_FORMAT_FOOTER)); - m_pPopupMenu->SetItemText(FN_HEADERFOOTER_DELETE, SW_RESSTR(STR_DELETE_FOOTER)); + m_pPopupMenu->SetItemText(m_pPopupMenu->GetItemId("edit"), SW_RESSTR(STR_FORMAT_FOOTER)); + m_pPopupMenu->SetItemText(m_pPopupMenu->GetItemId("delete"), SW_RESSTR(STR_DELETE_FOOTER)); } SetPopupMenu(m_pPopupMenu); @@ -171,7 +170,8 @@ SwHeaderFooterWin::~SwHeaderFooterWin( ) void SwHeaderFooterWin::dispose() { - m_pPopupMenu.disposeAndClear(); + m_pPopupMenu.clear(); + m_aBuilder.disposeBuilder(); m_pLine.disposeAndClear(); SwFrameMenuButtonBase::dispose(); } @@ -402,78 +402,70 @@ bool SwHeaderFooterWin::IsEmptyHeaderFooter( ) return bResult; } -void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot ) +void SwHeaderFooterWin::ExecuteCommand(const OString& rIdent) { SwView& rView = GetEditWin()->GetView(); SwWrtShell& rSh = rView.GetWrtShell(); const OUString& rStyleName = GetPageFrame()->GetPageDesc()->GetName(); - switch ( nSlot ) + if (rIdent == "edit") + { + OString sPageId = m_bIsHeader ? OString("header") : OString("footer"); + rView.GetDocShell()->FormatPage(rStyleName, sPageId, rSh); + } + else if (rIdent == "borderback") { - case FN_HEADERFOOTER_EDIT: + const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc(); + const SwFrameFormat& rMaster = pDesc->GetMaster(); + SwFrameFormat* pHFFormat = const_cast< SwFrameFormat* >( rMaster.GetFooter().GetFooterFormat() ); + if ( m_bIsHeader ) + pHFFormat = const_cast< SwFrameFormat* >( rMaster.GetHeader().GetHeaderFormat() ); + + SfxItemPool* pPool = pHFFormat->GetAttrSet().GetPool(); + SfxItemSet aSet( *pPool, + RES_BACKGROUND, RES_BACKGROUND, + RES_BOX, RES_BOX, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, + RES_SHADOW, RES_SHADOW, 0 ); + + aSet.Put( pHFFormat->GetAttrSet() ); + + // Create a box info item... needed by the dialog + SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); + const SfxPoolItem *pBoxInfo; + if ( SfxItemState::SET == pHFFormat->GetAttrSet().GetItemState( SID_ATTR_BORDER_INNER, + true, &pBoxInfo) ) + aBoxInfo = *static_cast<const SvxBoxInfoItem*>(pBoxInfo); + + aBoxInfo.SetTable( false ); + aBoxInfo.SetDist( true); + aBoxInfo.SetMinDist( false ); + aBoxInfo.SetDefDist( MIN_BORDER_DIST ); + aBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISABLE ); + aSet.Put( aBoxInfo ); + + if ( svx::ShowBorderBackgroundDlg( this, &aSet, true ) ) { - OString sPageId = m_bIsHeader ? OString("header") : OString("footer"); - rView.GetDocShell()->FormatPage(rStyleName, sPageId, rSh); - } - break; - case FN_HEADERFOOTER_BORDERBACK: - { - const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc(); - const SwFrameFormat& rMaster = pDesc->GetMaster(); - SwFrameFormat* pHFFormat = const_cast< SwFrameFormat* >( rMaster.GetFooter().GetFooterFormat() ); - if ( m_bIsHeader ) - pHFFormat = const_cast< SwFrameFormat* >( rMaster.GetHeader().GetHeaderFormat() ); - - SfxItemPool* pPool = pHFFormat->GetAttrSet().GetPool(); - SfxItemSet aSet( *pPool, - RES_BACKGROUND, RES_BACKGROUND, - RES_BOX, RES_BOX, - SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, - RES_SHADOW, RES_SHADOW, 0 ); - - aSet.Put( pHFFormat->GetAttrSet() ); - - // Create a box info item... needed by the dialog - SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); - const SfxPoolItem *pBoxInfo; - if ( SfxItemState::SET == pHFFormat->GetAttrSet().GetItemState( SID_ATTR_BORDER_INNER, - true, &pBoxInfo) ) - aBoxInfo = *static_cast<const SvxBoxInfoItem*>(pBoxInfo); - - aBoxInfo.SetTable( false ); - aBoxInfo.SetDist( true); - aBoxInfo.SetMinDist( false ); - aBoxInfo.SetDefDist( MIN_BORDER_DIST ); - aBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISABLE ); - aSet.Put( aBoxInfo ); - - if ( svx::ShowBorderBackgroundDlg( this, &aSet, true ) ) - { - const SfxPoolItem* pItem; - if ( SfxItemState::SET == aSet.GetItemState( RES_BACKGROUND, false, &pItem ) ) { - pHFFormat->SetFormatAttr( *pItem ); - rView.GetDocShell()->SetModified(); - } - - if ( SfxItemState::SET == aSet.GetItemState( RES_BOX, false, &pItem ) ) { - pHFFormat->SetFormatAttr( *pItem ); - rView.GetDocShell()->SetModified(); - } - - if ( SfxItemState::SET == aSet.GetItemState( RES_SHADOW, false, &pItem ) ) { - pHFFormat->SetFormatAttr( *pItem ); - rView.GetDocShell()->SetModified(); - } + const SfxPoolItem* pItem; + if ( SfxItemState::SET == aSet.GetItemState( RES_BACKGROUND, false, &pItem ) ) { + pHFFormat->SetFormatAttr( *pItem ); + rView.GetDocShell()->SetModified(); + } + + if ( SfxItemState::SET == aSet.GetItemState( RES_BOX, false, &pItem ) ) { + pHFFormat->SetFormatAttr( *pItem ); + rView.GetDocShell()->SetModified(); + } + + if ( SfxItemState::SET == aSet.GetItemState( RES_SHADOW, false, &pItem ) ) { + pHFFormat->SetFormatAttr( *pItem ); + rView.GetDocShell()->SetModified(); } } - break; - case FN_HEADERFOOTER_DELETE: - { - rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, false, true ); - } - break; - default: - break; + } + else if (rIdent == "delete") + { + rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, false, true ); } } @@ -498,7 +490,7 @@ void SwHeaderFooterWin::MouseButtonDown( const MouseEvent& rMEvt ) void SwHeaderFooterWin::Select() { - ExecuteCommand(GetCurItemId()); + ExecuteCommand(GetCurItemIdent()); } IMPL_LINK_NOARG(SwHeaderFooterWin, FadeHandler, Timer *, void) diff --git a/sw/source/uibase/inc/HeaderFooterWin.hxx b/sw/source/uibase/inc/HeaderFooterWin.hxx index ab4d4d343a6e..da51beef7ab5 100644 --- a/sw/source/uibase/inc/HeaderFooterWin.hxx +++ b/sw/source/uibase/inc/HeaderFooterWin.hxx @@ -10,7 +10,7 @@ #define INCLUDED_SW_SOURCE_UIBASE_INC_HEADERFOOTERWIN_HXX #include <FrameControl.hxx> - +#include <vcl/builder.hxx> #include <vcl/menubtn.hxx> /** Class for the header and footer separator control window. @@ -20,6 +20,7 @@ */ class SwHeaderFooterWin : public SwFrameMenuButtonBase { + VclBuilder m_aBuilder; OUString m_sLabel; bool m_bIsHeader; VclPtr<PopupMenu> m_pPopupMenu; @@ -45,7 +46,7 @@ public: bool IsHeader() { return m_bIsHeader; }; bool IsEmptyHeaderFooter( ); - void ExecuteCommand(sal_uInt16 nSlot); + void ExecuteCommand(const OString &rIdent); void SetReadonly( bool bReadonly ) override; diff --git a/sw/source/uibase/inc/popup.hrc b/sw/source/uibase/inc/popup.hrc index 9f12daf1a534..0bc6595a6eb3 100644 --- a/sw/source/uibase/inc/popup.hrc +++ b/sw/source/uibase/inc/popup.hrc @@ -23,9 +23,8 @@ #include "rcid.hrc" #define MN_ANNOTATION_BUTTON (RC_POPUPS_BEGIN + 0) -#define MN_HEADERFOOTER_BUTTON (RC_POPUPS_BEGIN + 1) -#if MN_HEADERFOOTER_BUTTON > RC_POPUPS_END +#if MN_ANNOTATION_BUTTON > RC_POPUPS_END #error Resource-Id Ueberlauf in #file, #line #endif diff --git a/sw/uiconfig/swriter/ui/headerfootermenu.ui b/sw/uiconfig/swriter/ui/headerfootermenu.ui new file mode 100644 index 000000000000..2a775010ff0d --- /dev/null +++ b/sw/uiconfig/swriter/ui/headerfootermenu.ui @@ -0,0 +1,31 @@ +<?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="edit"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="borderback"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Border and Background...</property> + <property name="use_underline">True</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="delete"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_underline">True</property> + </object> + </child> + </object> +</interface> |