diff options
-rw-r--r-- | sw/source/ui/docvw/HeaderFooterWin.cxx | 41 | ||||
-rw-r--r-- | sw/source/ui/inc/HeaderFooterWin.hxx | 3 |
2 files changed, 43 insertions, 1 deletions
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx index d5e317f06156..970767ae837f 100644 --- a/sw/source/ui/docvw/HeaderFooterWin.cxx +++ b/sw/source/ui/docvw/HeaderFooterWin.cxx @@ -31,10 +31,13 @@ #include <fmthdft.hxx> #include <HeaderFooterWin.hxx> #include <pagefrm.hxx> +#include <view.hxx> #include <viewopt.hxx> +#include <wrtsh.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/color/bcolortools.hxx> +#include <editeng/ulspitem.hxx> #include <svtools/svtdata.hxx> #include <svtools/svtools.hrc> #include <vcl/decoview.hxx> @@ -101,6 +104,7 @@ class SwHeaderFooterButton : public MenuButton ~SwHeaderFooterButton( ); virtual void Paint( const Rectangle& rRect ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); }; @@ -205,6 +209,32 @@ bool SwHeaderFooterWin::IsEmptyHeaderFooter( ) return bResult; } +void SwHeaderFooterWin::ChangeHeaderOrFooter( ) +{ + SwWrtShell& rSh = m_pEditWin->GetView().GetWrtShell(); + rSh.addCurrentPosition(); + rSh.StartAllAction(); + rSh.StartUndo( UNDO_HEADER_FOOTER ); + + const SwPageDesc* pPageDesc = GetPageFrame()->GetPageDesc(); + SwFrmFmt& rMaster = const_cast< SwFrmFmt& > (pPageDesc->GetMaster() ); + + if ( m_bIsHeader ) + rMaster.SetFmtAttr( SwFmtHeader( true ) ); + else + rMaster.SetFmtAttr( SwFmtFooter( true ) ); + + 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(); +} + SwHeaderFooterButton::SwHeaderFooterButton( SwHeaderFooterWin* pWindow ) : MenuButton( pWindow ), m_pWindow( pWindow ) @@ -254,4 +284,15 @@ void SwHeaderFooterButton::Paint( const Rectangle& ) } } +void SwHeaderFooterButton::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if ( m_pWindow->IsEmptyHeaderFooter( ) ) + { + // Add the header / footer + m_pWindow->ChangeHeaderOrFooter(); + } + else + MenuButton::MouseButtonDown( rMEvt ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx index cd2991adc810..d61ecdee048b 100644 --- a/sw/source/ui/inc/HeaderFooterWin.hxx +++ b/sw/source/ui/inc/HeaderFooterWin.hxx @@ -60,8 +60,9 @@ public: bool IsEmptyHeaderFooter( ); const SwPageFrm* GetPageFrame( ) { return m_pPageFrm; }; + void ChangeHeaderOrFooter( ); private: - MenuButton* GetMenuButton(); + MenuButton* GetMenuButton( ); }; #endif |