From dc557cd036e49f6d642bcdbd79a525371c7c513c Mon Sep 17 00:00:00 2001 From: Cédric Bosdonnat Date: Thu, 8 Sep 2011 14:27:28 +0200 Subject: Header/Footer: added the popup menu of the separator Removing the header/footer is working, but the edition still needs to be implemented --- sw/inc/cmdid.h | 5 +++ sw/inc/swcommands.h | 2 ++ sw/source/ui/app/mn.src | 19 ++++++++++++ sw/source/ui/docvw/HeaderFooterWin.cxx | 57 ++++++++++++++++++++++++++++------ sw/source/ui/inc/HeaderFooterWin.hxx | 4 ++- sw/source/ui/inc/popup.hrc | 3 +- 6 files changed, 78 insertions(+), 12 deletions(-) diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index ab78d6a5d62b..ae2a6ebccebc 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -67,6 +67,7 @@ included in c-context files, so c++ style stuff will cause problems. #define FN_EXTRA2 (SID_SW_START + 2200) #define FN_PARAM2 (SID_SW_START + 2400) #define FN_NOTES (SID_SW_START + 2500) +#define FN_HEADERFOOTER (SID_SW_START + 2600) /* More accurately, this range should be from FN_EXTRA2 to FN_PARAM2-1, but * FN_NUMBER_NEWSTART comes from FN_FORMAT2, and FN_PARAM_LINK_DISPLAY_NAME @@ -1014,6 +1015,10 @@ included in c-context files, so c++ style stuff will cause problems. #define FN_DELETE_COMMENT (FN_NOTES+6) #define FN_REPLY (FN_NOTES+7) + +#define FN_HEADERFOOTER_EDIT (FN_HEADERFOOTER+1) +#define FN_HEADERFOOTER_DELETE (FN_HEADERFOOTER+2) + /*-------------------------------------------------------------------- Region: Parameter --------------------------------------------------------------------*/ diff --git a/sw/inc/swcommands.h b/sw/inc/swcommands.h index 77b30ca59f7a..036abc820037 100644 --- a/sw/inc/swcommands.h +++ b/sw/inc/swcommands.h @@ -433,5 +433,7 @@ #define CMD_FN_REDLINE_REJECT_DIRECT ".uno:RejectTracedChange" #define CMD_FN_REMOVE_HYPERLINK ".uno:RemoveHyperlink" #define CMD_FN_COPY_HYPERLINK_LOCATION ".uno:CopyHyperlinkLocation" +#define CMD_FN_HEADERFOOTER_EDIT ".uno:HeaderFooterEdit" +#define CMD_FN_HEADERFOOTER_DELETE ".uno:HeaderFooterDelete" #endif diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src index 182b7e137604..e7a59f5c3a88 100644 --- a/sw/source/ui/app/mn.src +++ b/sw/source/ui/app/mn.src @@ -1434,6 +1434,25 @@ Menu MN_MEDIA_POPUPMENU }; }; +Menu MN_HEADERFOOTER_BUTTON +{ + ItemList = + { + MenuItem + { + Identifier = FN_HEADERFOOTER_EDIT ; + HelpID = CMD_FN_HEADERFOOTER_EDIT ; + Text [ en-US ] = "Edit" ; + }; + MenuItem + { + Identifier = FN_HEADERFOOTER_DELETE ; + HelpID = CMD_FN_HEADERFOOTER_DELETE ; + Text [ en-US ] = "Remove" ; + }; + }; +}; + Menu MN_TEXT_POPUPMENU BASE_TEXT_POPUPMENU_BEGIN BASE_TEXT_POPUPMENU_NOWEB diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx index 970767ae837f..1dffb6e35edb 100644 --- a/sw/source/ui/docvw/HeaderFooterWin.cxx +++ b/sw/source/ui/docvw/HeaderFooterWin.cxx @@ -26,7 +26,12 @@ * instead of those above. */ +#include #include +#include +#include + +#include #include #include #include @@ -39,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -98,11 +102,16 @@ namespace class SwHeaderFooterButton : public MenuButton { SwHeaderFooterWin* m_pWindow; + PopupMenu* m_pPopupMenu; public: SwHeaderFooterButton( SwHeaderFooterWin* pWindow ); ~SwHeaderFooterButton( ); + // overloaded methods + virtual void Select(); + + // overloaded methods virtual void Paint( const Rectangle& rRect ); virtual void MouseButtonDown( const MouseEvent& rMEvt ); }; @@ -209,7 +218,7 @@ bool SwHeaderFooterWin::IsEmptyHeaderFooter( ) return bResult; } -void SwHeaderFooterWin::ChangeHeaderOrFooter( ) +void SwHeaderFooterWin::ChangeHeaderOrFooter( bool bAdd ) { SwWrtShell& rSh = m_pEditWin->GetView().GetWrtShell(); rSh.addCurrentPosition(); @@ -220,29 +229,52 @@ void SwHeaderFooterWin::ChangeHeaderOrFooter( ) SwFrmFmt& rMaster = const_cast< SwFrmFmt& > (pPageDesc->GetMaster() ); if ( m_bIsHeader ) - rMaster.SetFmtAttr( SwFmtHeader( true ) ); + rMaster.SetFmtAttr( SwFmtHeader( bAdd ) ); else - rMaster.SetFmtAttr( SwFmtFooter( true ) ); + rMaster.SetFmtAttr( SwFmtFooter( bAdd ) ); - SvxULSpaceItem aUL( m_bIsHeader ? 0 : MM50, m_bIsHeader ? MM50 : 0, RES_UL_SPACE ); - SwFrmFmt* pFmt = m_bIsHeader ? - ( SwFrmFmt* )rMaster.GetHeader().GetHeaderFmt(): - ( SwFrmFmt* )rMaster.GetFooter().GetFooterFmt(); - pFmt->SetFmtAttr( aUL ); + if ( bAdd ) + { + SvxULSpaceItem aUL( m_bIsHeader ? 0 : MM50, m_bIsHeader ? MM50 : 0, RES_UL_SPACE ); + SwFrmFmt* pFmt = m_bIsHeader ? + ( SwFrmFmt* )rMaster.GetHeader().GetHeaderFmt(): + ( SwFrmFmt* )rMaster.GetFooter().GetFooterFmt(); + pFmt->SetFmtAttr( aUL ); + } rSh.EndUndo( UNDO_HEADER_FOOTER ); rSh.EndAllAction(); } +void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot ) +{ + switch ( nSlot ) + { + case FN_HEADERFOOTER_EDIT: + // TODO Implement me + break; + case FN_HEADERFOOTER_DELETE: + ChangeHeaderOrFooter( false ); + break; + default: + break; + } +} + SwHeaderFooterButton::SwHeaderFooterButton( SwHeaderFooterWin* pWindow ) : MenuButton( pWindow ), m_pWindow( pWindow ) { + // Create and set the PopupMenu + m_pPopupMenu = new PopupMenu( SW_RES( MN_HEADERFOOTER_BUTTON ) ); + // TODO Potentially rewrite the menu entries' text + SetPopupMenu( m_pPopupMenu ); } SwHeaderFooterButton::~SwHeaderFooterButton( ) { + delete m_pWindow; } void SwHeaderFooterButton::Paint( const Rectangle& ) @@ -289,10 +321,15 @@ void SwHeaderFooterButton::MouseButtonDown( const MouseEvent& rMEvt ) if ( m_pWindow->IsEmptyHeaderFooter( ) ) { // Add the header / footer - m_pWindow->ChangeHeaderOrFooter(); + m_pWindow->ChangeHeaderOrFooter( true ); } else MenuButton::MouseButtonDown( rMEvt ); } +void SwHeaderFooterButton::Select( ) +{ + m_pWindow->ExecuteCommand( GetCurItemId() ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx index d61ecdee048b..c3c21d500158 100644 --- a/sw/source/ui/inc/HeaderFooterWin.hxx +++ b/sw/source/ui/inc/HeaderFooterWin.hxx @@ -60,7 +60,9 @@ public: bool IsEmptyHeaderFooter( ); const SwPageFrm* GetPageFrame( ) { return m_pPageFrm; }; - void ChangeHeaderOrFooter( ); + void ChangeHeaderOrFooter( bool bAdd ); + void ExecuteCommand(sal_uInt16 nSlot); + private: MenuButton* GetMenuButton( ); }; diff --git a/sw/source/ui/inc/popup.hrc b/sw/source/ui/inc/popup.hrc index 62f210938a36..c7ec2cfe1916 100644 --- a/sw/source/ui/inc/popup.hrc +++ b/sw/source/ui/inc/popup.hrc @@ -48,8 +48,9 @@ #define MN_ANNOTATION_BUTTON (RC_POPUPS_BEGIN + 15) #define MN_REDCOMMENT_POPUPMENU (RC_POPUPS_BEGIN + 16) #define MN_REDCOMMENT_BUTTON (RC_POPUPS_BEGIN + 17) +#define MN_HEADERFOOTER_BUTTON (RC_POPUPS_BEGIN + 18) -#if MN_MEDIA_POPUPMENU > RC_POPUPS_END +#if MN_HEADERFOOTER_POPUPMENU > RC_POPUPS_END #error Resource-Id Ueberlauf in #file, #line #endif -- cgit