summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-09-08 12:01:50 +0200
committerCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-09-08 15:42:58 +0200
commit14727e633fa8fcc684ad08804b473eaf6006f0d4 (patch)
tree8f244b6b843e44d4128531cba7302c999891e279
parent79f53401c6801e240800fb6e1eaae8f55974f9c6 (diff)
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.
-rw-r--r--sw/source/ui/docvw/HeaderFooterWin.cxx41
-rw-r--r--sw/source/ui/inc/HeaderFooterWin.hxx3
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