summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-09-08 14:27:28 +0200
committerCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-09-08 15:42:58 +0200
commitdc557cd036e49f6d642bcdbd79a525371c7c513c (patch)
tree503a86ebabfac2e60e9a9abc6197a7f5cf1f599f /sw/source
parent14727e633fa8fcc684ad08804b473eaf6006f0d4 (diff)
Header/Footer: added the popup menu of the separator
Removing the header/footer is working, but the edition still needs to be implemented
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/ui/app/mn.src19
-rw-r--r--sw/source/ui/docvw/HeaderFooterWin.cxx57
-rw-r--r--sw/source/ui/inc/HeaderFooterWin.hxx4
-rw-r--r--sw/source/ui/inc/popup.hrc3
4 files changed, 71 insertions, 12 deletions
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 <app.hrc>
#include <docvw.hrc>
+#include <popup.hrc>
+#include <svtools/svtools.hrc>
+
+#include <cmdid.h>
#include <edtwin.hxx>
#include <fmthdft.hxx>
#include <HeaderFooterWin.hxx>
@@ -39,7 +44,6 @@
#include <basegfx/color/bcolortools.hxx>
#include <editeng/ulspitem.hxx>
#include <svtools/svtdata.hxx>
-#include <svtools/svtools.hrc>
#include <vcl/decoview.hxx>
#include <vcl/menubtn.hxx>
#include <vcl/svapp.hxx>
@@ -98,11 +102,16 @@ namespace
class SwHeaderFooterButton : public MenuButton
{
SwHeaderFooterWin* m_pWindow;
+ PopupMenu* m_pPopupMenu;
public:
SwHeaderFooterButton( SwHeaderFooterWin* pWindow );
~SwHeaderFooterButton( );
+ // overloaded <MenuButton> methods
+ virtual void Select();
+
+ // overloaded <Window> 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