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

Header/Footer: implement the header creation when clicking on +

Remaining UI bug: the cursor should be placed in the newly created
footer when creating a footer. It's currently set to the header.
üst 79f53401
...@@ -31,10 +31,13 @@ ...@@ -31,10 +31,13 @@
#include <fmthdft.hxx> #include <fmthdft.hxx>
#include <HeaderFooterWin.hxx> #include <HeaderFooterWin.hxx>
#include <pagefrm.hxx> #include <pagefrm.hxx>
#include <view.hxx>
#include <viewopt.hxx> #include <viewopt.hxx>
#include <wrtsh.hxx>
#include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/color/bcolortools.hxx> #include <basegfx/color/bcolortools.hxx>
#include <editeng/ulspitem.hxx>
#include <svtools/svtdata.hxx> #include <svtools/svtdata.hxx>
#include <svtools/svtools.hrc> #include <svtools/svtools.hrc>
#include <vcl/decoview.hxx> #include <vcl/decoview.hxx>
...@@ -101,6 +104,7 @@ class SwHeaderFooterButton : public MenuButton ...@@ -101,6 +104,7 @@ class SwHeaderFooterButton : public MenuButton
~SwHeaderFooterButton( ); ~SwHeaderFooterButton( );
virtual void Paint( const Rectangle& rRect ); virtual void Paint( const Rectangle& rRect );
virtual void MouseButtonDown( const MouseEvent& rMEvt );
}; };
...@@ -205,6 +209,32 @@ bool SwHeaderFooterWin::IsEmptyHeaderFooter( ) ...@@ -205,6 +209,32 @@ bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
return bResult; 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 ) : SwHeaderFooterButton::SwHeaderFooterButton( SwHeaderFooterWin* pWindow ) :
MenuButton( pWindow ), MenuButton( pWindow ),
m_pWindow( pWindow ) m_pWindow( pWindow )
...@@ -254,4 +284,15 @@ void SwHeaderFooterButton::Paint( const Rectangle& ) ...@@ -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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -60,8 +60,9 @@ public: ...@@ -60,8 +60,9 @@ public:
bool IsEmptyHeaderFooter( ); bool IsEmptyHeaderFooter( );
const SwPageFrm* GetPageFrame( ) { return m_pPageFrm; }; const SwPageFrm* GetPageFrame( ) { return m_pPageFrm; };
void ChangeHeaderOrFooter( );
private: private:
MenuButton* GetMenuButton(); MenuButton* GetMenuButton( );
}; };
#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