Kaydet (Commit) dc557cd0 authored tarafından Cédric Bosdonnat's avatar Cédric Bosdonnat

Header/Footer: added the popup menu of the separator

Removing the header/footer is working, but the edition still needs to be
implemented
üst 14727e63
...@@ -67,6 +67,7 @@ included in c-context files, so c++ style stuff will cause problems. ...@@ -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_EXTRA2 (SID_SW_START + 2200)
#define FN_PARAM2 (SID_SW_START + 2400) #define FN_PARAM2 (SID_SW_START + 2400)
#define FN_NOTES (SID_SW_START + 2500) #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 /* 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 * 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. ...@@ -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_DELETE_COMMENT (FN_NOTES+6)
#define FN_REPLY (FN_NOTES+7) #define FN_REPLY (FN_NOTES+7)
#define FN_HEADERFOOTER_EDIT (FN_HEADERFOOTER+1)
#define FN_HEADERFOOTER_DELETE (FN_HEADERFOOTER+2)
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
Region: Parameter Region: Parameter
--------------------------------------------------------------------*/ --------------------------------------------------------------------*/
......
...@@ -433,5 +433,7 @@ ...@@ -433,5 +433,7 @@
#define CMD_FN_REDLINE_REJECT_DIRECT ".uno:RejectTracedChange" #define CMD_FN_REDLINE_REJECT_DIRECT ".uno:RejectTracedChange"
#define CMD_FN_REMOVE_HYPERLINK ".uno:RemoveHyperlink" #define CMD_FN_REMOVE_HYPERLINK ".uno:RemoveHyperlink"
#define CMD_FN_COPY_HYPERLINK_LOCATION ".uno:CopyHyperlinkLocation" #define CMD_FN_COPY_HYPERLINK_LOCATION ".uno:CopyHyperlinkLocation"
#define CMD_FN_HEADERFOOTER_EDIT ".uno:HeaderFooterEdit"
#define CMD_FN_HEADERFOOTER_DELETE ".uno:HeaderFooterDelete"
#endif #endif
...@@ -1434,6 +1434,25 @@ Menu MN_MEDIA_POPUPMENU ...@@ -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 Menu MN_TEXT_POPUPMENU
BASE_TEXT_POPUPMENU_BEGIN BASE_TEXT_POPUPMENU_BEGIN
BASE_TEXT_POPUPMENU_NOWEB BASE_TEXT_POPUPMENU_NOWEB
......
...@@ -26,7 +26,12 @@ ...@@ -26,7 +26,12 @@
* instead of those above. * instead of those above.
*/ */
#include <app.hrc>
#include <docvw.hrc> #include <docvw.hrc>
#include <popup.hrc>
#include <svtools/svtools.hrc>
#include <cmdid.h>
#include <edtwin.hxx> #include <edtwin.hxx>
#include <fmthdft.hxx> #include <fmthdft.hxx>
#include <HeaderFooterWin.hxx> #include <HeaderFooterWin.hxx>
...@@ -39,7 +44,6 @@ ...@@ -39,7 +44,6 @@
#include <basegfx/color/bcolortools.hxx> #include <basegfx/color/bcolortools.hxx>
#include <editeng/ulspitem.hxx> #include <editeng/ulspitem.hxx>
#include <svtools/svtdata.hxx> #include <svtools/svtdata.hxx>
#include <svtools/svtools.hrc>
#include <vcl/decoview.hxx> #include <vcl/decoview.hxx>
#include <vcl/menubtn.hxx> #include <vcl/menubtn.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
...@@ -98,11 +102,16 @@ namespace ...@@ -98,11 +102,16 @@ namespace
class SwHeaderFooterButton : public MenuButton class SwHeaderFooterButton : public MenuButton
{ {
SwHeaderFooterWin* m_pWindow; SwHeaderFooterWin* m_pWindow;
PopupMenu* m_pPopupMenu;
public: public:
SwHeaderFooterButton( SwHeaderFooterWin* pWindow ); SwHeaderFooterButton( SwHeaderFooterWin* pWindow );
~SwHeaderFooterButton( ); ~SwHeaderFooterButton( );
// overloaded <MenuButton> methods
virtual void Select();
// overloaded <Window> methods
virtual void Paint( const Rectangle& rRect ); virtual void Paint( const Rectangle& rRect );
virtual void MouseButtonDown( const MouseEvent& rMEvt ); virtual void MouseButtonDown( const MouseEvent& rMEvt );
}; };
...@@ -209,7 +218,7 @@ bool SwHeaderFooterWin::IsEmptyHeaderFooter( ) ...@@ -209,7 +218,7 @@ bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
return bResult; return bResult;
} }
void SwHeaderFooterWin::ChangeHeaderOrFooter( ) void SwHeaderFooterWin::ChangeHeaderOrFooter( bool bAdd )
{ {
SwWrtShell& rSh = m_pEditWin->GetView().GetWrtShell(); SwWrtShell& rSh = m_pEditWin->GetView().GetWrtShell();
rSh.addCurrentPosition(); rSh.addCurrentPosition();
...@@ -220,29 +229,52 @@ void SwHeaderFooterWin::ChangeHeaderOrFooter( ) ...@@ -220,29 +229,52 @@ void SwHeaderFooterWin::ChangeHeaderOrFooter( )
SwFrmFmt& rMaster = const_cast< SwFrmFmt& > (pPageDesc->GetMaster() ); SwFrmFmt& rMaster = const_cast< SwFrmFmt& > (pPageDesc->GetMaster() );
if ( m_bIsHeader ) if ( m_bIsHeader )
rMaster.SetFmtAttr( SwFmtHeader( true ) ); rMaster.SetFmtAttr( SwFmtHeader( bAdd ) );
else else
rMaster.SetFmtAttr( SwFmtFooter( true ) ); rMaster.SetFmtAttr( SwFmtFooter( bAdd ) );
SvxULSpaceItem aUL( m_bIsHeader ? 0 : MM50, m_bIsHeader ? MM50 : 0, RES_UL_SPACE ); if ( bAdd )
SwFrmFmt* pFmt = m_bIsHeader ? {
( SwFrmFmt* )rMaster.GetHeader().GetHeaderFmt(): SvxULSpaceItem aUL( m_bIsHeader ? 0 : MM50, m_bIsHeader ? MM50 : 0, RES_UL_SPACE );
( SwFrmFmt* )rMaster.GetFooter().GetFooterFmt(); SwFrmFmt* pFmt = m_bIsHeader ?
pFmt->SetFmtAttr( aUL ); ( SwFrmFmt* )rMaster.GetHeader().GetHeaderFmt():
( SwFrmFmt* )rMaster.GetFooter().GetFooterFmt();
pFmt->SetFmtAttr( aUL );
}
rSh.EndUndo( UNDO_HEADER_FOOTER ); rSh.EndUndo( UNDO_HEADER_FOOTER );
rSh.EndAllAction(); 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 ) : SwHeaderFooterButton::SwHeaderFooterButton( SwHeaderFooterWin* pWindow ) :
MenuButton( pWindow ), MenuButton( pWindow ),
m_pWindow( 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( ) SwHeaderFooterButton::~SwHeaderFooterButton( )
{ {
delete m_pWindow;
} }
void SwHeaderFooterButton::Paint( const Rectangle& ) void SwHeaderFooterButton::Paint( const Rectangle& )
...@@ -289,10 +321,15 @@ void SwHeaderFooterButton::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -289,10 +321,15 @@ void SwHeaderFooterButton::MouseButtonDown( const MouseEvent& rMEvt )
if ( m_pWindow->IsEmptyHeaderFooter( ) ) if ( m_pWindow->IsEmptyHeaderFooter( ) )
{ {
// Add the header / footer // Add the header / footer
m_pWindow->ChangeHeaderOrFooter(); m_pWindow->ChangeHeaderOrFooter( true );
} }
else else
MenuButton::MouseButtonDown( rMEvt ); MenuButton::MouseButtonDown( rMEvt );
} }
void SwHeaderFooterButton::Select( )
{
m_pWindow->ExecuteCommand( GetCurItemId() );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -60,7 +60,9 @@ public: ...@@ -60,7 +60,9 @@ public:
bool IsEmptyHeaderFooter( ); bool IsEmptyHeaderFooter( );
const SwPageFrm* GetPageFrame( ) { return m_pPageFrm; }; const SwPageFrm* GetPageFrame( ) { return m_pPageFrm; };
void ChangeHeaderOrFooter( ); void ChangeHeaderOrFooter( bool bAdd );
void ExecuteCommand(sal_uInt16 nSlot);
private: private:
MenuButton* GetMenuButton( ); MenuButton* GetMenuButton( );
}; };
......
...@@ -48,8 +48,9 @@ ...@@ -48,8 +48,9 @@
#define MN_ANNOTATION_BUTTON (RC_POPUPS_BEGIN + 15) #define MN_ANNOTATION_BUTTON (RC_POPUPS_BEGIN + 15)
#define MN_REDCOMMENT_POPUPMENU (RC_POPUPS_BEGIN + 16) #define MN_REDCOMMENT_POPUPMENU (RC_POPUPS_BEGIN + 16)
#define MN_REDCOMMENT_BUTTON (RC_POPUPS_BEGIN + 17) #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 #error Resource-Id Ueberlauf in #file, #line
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment