[Libreoffice-commits] .: 6 commits - sw/inc sw/source

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Thu Sep 8 06:44:01 PDT 2011


 sw/inc/cmdid.h                         |    5 
 sw/inc/docsh.hxx                       |    4 
 sw/inc/swabstdlg.hxx                   |    2 
 sw/inc/swcommands.h                    |    2 
 sw/source/core/layout/pagechg.cxx      |   13 +
 sw/source/core/layout/paintfrm.cxx     |   18 --
 sw/source/ui/app/docst.cxx             |    8 -
 sw/source/ui/app/mn.src                |   19 ++
 sw/source/ui/dialog/swdlgfact.cxx      |    4 
 sw/source/ui/dialog/swdlgfact.hxx      |    2 
 sw/source/ui/docvw/HeaderFooterWin.cxx |  253 +++++++++++++++++++++------------
 sw/source/ui/docvw/edtwin.cxx          |   55 ++++++-
 sw/source/ui/fmtui/tmpdlg.cxx          |    6 
 sw/source/ui/inc/HeaderFooterWin.hxx   |   16 +-
 sw/source/ui/inc/edtwin.hxx            |    5 
 sw/source/ui/inc/popup.hrc             |    3 
 sw/source/ui/inc/tmpdlg.hxx            |    2 
 sw/source/ui/shells/basesh.cxx         |    6 
 18 files changed, 294 insertions(+), 129 deletions(-)

New commits:
commit 91042f3f0a4328bc46e17e8b32d5021003fb7e04
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Thu Sep 8 15:38:50 2011 +0200

    Header/Footer: implement the edit menu item
    
    Opens the page style at the header or footer tab.

diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index 4f644af..96a1eaa 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -112,7 +112,7 @@ class SW_DLLPUBLIC SwDocShell: public SfxObjectShell, public SfxListener
     // Methods for StyleSheets
     SW_DLLPRIVATE sal_uInt16                    Edit( const String &rName, const String& rParent, sal_uInt16 nFamily,
                                     sal_uInt16 nMask, sal_Bool bNew,
-                                    sal_Bool bColumn = sal_False,
+                                    sal_uInt16 nPageId = 0,
                                     SwWrtShell* pActShell = 0,
                                     sal_Bool bBasic = sal_False );
     SW_DLLPRIVATE sal_uInt16                    Delete(const String &rName, sal_uInt16 nFamily);
@@ -254,7 +254,7 @@ public:
 
     // Display dialog for page style. If required display column page.
     void FormatPage( const String& rPage,
-                        sal_Bool bColumn = sal_False,
+                        sal_uInt16 nPageId = 0,
                         SwWrtShell*     pActShell = 0 );
 
     // #i59688#
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 13bf919..b928169 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -427,7 +427,7 @@ public:
                                                 Window*             pParent,
                                                 SfxStyleSheetBase&  rBase,
                                                 sal_uInt16              nRegion,
-                                                sal_Bool                bColumn = sal_False,
+                                                sal_uInt16              nPageId = 0,
                                                 SwWrtShell*         pActShell = 0,
                                                 sal_Bool                bNew = sal_False ) = 0; //add for SwTemplateDlg
     virtual AbstractGlossaryDlg*        CreateGlossaryDlg( int nResId,
diff --git a/sw/source/ui/app/docst.cxx b/sw/source/ui/app/docst.cxx
index 847e629..8455a40 100644
--- a/sw/source/ui/app/docst.cxx
+++ b/sw/source/ui/app/docst.cxx
@@ -508,7 +508,7 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq )
 
 
 sal_uInt16 SwDocShell::Edit( const String &rName, const String &rParent, sal_uInt16 nFamily, sal_uInt16 nMask,
-                         sal_Bool bNew, sal_Bool bColumn, SwWrtShell* pActShell,
+                         sal_Bool bNew, sal_uInt16 nPageId, SwWrtShell* pActShell,
                          sal_Bool bBasic )
 {
     OSL_ENSURE(GetWrtShell(), "No Shell, no Styles");
@@ -660,7 +660,7 @@ sal_uInt16 SwDocShell::Edit( const String &rName, const String &rParent, sal_uIn
         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
         OSL_ENSURE(pFact, "Dialogdiet fail!");
         SfxAbstractTabDialog* pDlg = pFact->CreateTemplateDialog( DLG_TEMPLATE_BASE,
-                                                    0, *(xTmp.get()), nFamily, bColumn,
+                                                    0, *(xTmp.get()), nFamily, nPageId,
                                                     pActShell ? pActShell : pWrtShell, bNew);
         OSL_ENSURE(pDlg, "Dialogdiet fail!");
         while (true)
@@ -1246,9 +1246,9 @@ void SwDocShell::_LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrent
 }
 
 
-void SwDocShell::FormatPage( const String& rPage, sal_Bool bColumn, SwWrtShell*     pActShell )
+void SwDocShell::FormatPage( const String& rPage, sal_uInt16 nPageId, SwWrtShell*     pActShell )
 {
-    Edit( rPage, aEmptyStr, SFX_STYLE_FAMILY_PAGE, 0, sal_False, bColumn, pActShell);
+    Edit( rPage, aEmptyStr, SFX_STYLE_FAMILY_PAGE, 0, sal_False, nPageId, pActShell);
 }
 
 Bitmap SwDocShell::GetStyleFamilyBitmap( SfxStyleFamily eFamily )
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index de00a12..8a5505a 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -1202,7 +1202,7 @@ SfxAbstractTabDialog* SwAbstractDialogFactory_Impl::CreateTemplateDialog( int nR
                                                 Window*             pParent,
                                                 SfxStyleSheetBase&  rBase,
                                                 sal_uInt16              nRegion,
-                                                sal_Bool                bColumn,
+                                                sal_uInt16              nPageId,
                                                 SwWrtShell*         pActShell,
                                                 sal_Bool                bNew ) //add for SwTemplateDlg
 {
@@ -1210,7 +1210,7 @@ SfxAbstractTabDialog* SwAbstractDialogFactory_Impl::CreateTemplateDialog( int nR
     switch ( nResId )
     {
         case DLG_TEMPLATE_BASE :
-            pDlg = new SwTemplateDlg( pParent, rBase, nRegion, bColumn, pActShell, bNew );
+            pDlg = new SwTemplateDlg( pParent, rBase, nRegion, nPageId, pActShell, bNew );
             break;
         default:
             break;
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 9b883ea..e13ccfd 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -506,7 +506,7 @@ public:
                                                 Window*             pParent,
                                                 SfxStyleSheetBase&  rBase,
                                                 sal_uInt16              nRegion,
-                                                sal_Bool                bColumn = sal_False,
+                                                sal_uInt16          nPageId = 0,
                                                 SwWrtShell*         pActShell = 0,
                                                 sal_Bool                bNew = sal_False ); //add for SwTemplateDlg
     virtual AbstractGlossaryDlg*        CreateGlossaryDlg( int nResId,
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index 1dffb6e..e926d54 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -28,10 +28,12 @@
 
 #include <app.hrc>
 #include <docvw.hrc>
+#include <globals.hrc>
 #include <popup.hrc>
 #include <svtools/svtools.hrc>
 
 #include <cmdid.h>
+#include <docsh.hxx>
 #include <edtwin.hxx>
 #include <fmthdft.hxx>
 #include <HeaderFooterWin.hxx>
@@ -252,7 +254,17 @@ void SwHeaderFooterWin::ExecuteCommand( sal_uInt16 nSlot )
     switch ( nSlot )
     {
         case FN_HEADERFOOTER_EDIT:
-            // TODO Implement me
+            {
+                SwView& rView = m_pEditWin->GetView();
+                SwWrtShell& rSh = rView.GetWrtShell();
+                sal_uInt16 nPageId = TP_FOOTER_PAGE;
+                if ( IsHeader() )
+                    nPageId = TP_HEADER_PAGE;
+
+                rView.GetDocShell()->FormatPage(
+                        GetPageFrame()->GetPageDesc()->GetName(),
+                        nPageId, &rSh );
+            }
             break;
         case FN_HEADERFOOTER_DELETE:
             ChangeHeaderOrFooter( false );
@@ -274,7 +286,7 @@ SwHeaderFooterButton::SwHeaderFooterButton( SwHeaderFooterWin* pWindow ) :
 
 SwHeaderFooterButton::~SwHeaderFooterButton( )
 {
-    delete m_pWindow;
+    delete m_pPopupMenu;
 }
 
 void SwHeaderFooterButton::Paint( const Rectangle& )
diff --git a/sw/source/ui/fmtui/tmpdlg.cxx b/sw/source/ui/fmtui/tmpdlg.cxx
index 55cf1cc..5f88ae7 100644
--- a/sw/source/ui/fmtui/tmpdlg.cxx
+++ b/sw/source/ui/fmtui/tmpdlg.cxx
@@ -97,7 +97,7 @@ extern SW_DLLPUBLIC SwWrtShell* GetActiveWrtShell();
 SwTemplateDlg::SwTemplateDlg(Window*            pParent,
                              SfxStyleSheetBase& rBase,
                              sal_uInt16             nRegion,
-                             sal_Bool               bColumn,
+                             sal_uInt16             nPageId,
                              SwWrtShell*        pActShell,
                              sal_Bool               bNew ) :
     SfxStyleDialog( pParent,
@@ -263,8 +263,8 @@ SwTemplateDlg::SwTemplateDlg(Window*            pParent,
             AddTabPage(TP_FOOTER_PAGE,      String(SW_RES(STR_PAGE_FOOTER)),
                                             SvxFooterPage::Create,
                                             SvxFooterPage::GetRanges );
-            if(bColumn)
-                SetCurPageId(TP_COLUMN);
+            if(nPageId)
+                SetCurPageId(nPageId);
 
             OSL_ENSURE(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE ), "GetTabPageCreatorFunc fail!");
             OSL_ENSURE(pFact->GetTabPageRangesFunc( RID_SVXPAGE_PAGE ), "GetTabPageRangesFunc fail!");
diff --git a/sw/source/ui/inc/tmpdlg.hxx b/sw/source/ui/inc/tmpdlg.hxx
index 966ec13..f76b2b0 100644
--- a/sw/source/ui/inc/tmpdlg.hxx
+++ b/sw/source/ui/inc/tmpdlg.hxx
@@ -51,7 +51,7 @@ public:
     SwTemplateDlg(  Window*             pParent,
                     SfxStyleSheetBase&  rBase,
                     sal_uInt16              nRegion,
-                    sal_Bool                bColumn = sal_False,
+                    sal_uInt16              nPageId = 0,
                     SwWrtShell*         pActShell = 0,
                     sal_Bool                bNew = sal_False );
 
diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx
index 4659fac..ce79ff3 100644
--- a/sw/source/ui/shells/basesh.cxx
+++ b/sw/source/ui/shells/basesh.cxx
@@ -2388,9 +2388,11 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
                 //temp. View, weil die Shell nach dem Dialog nicht mehr gueltig sein muss
                 //z.B. Kopfzeile ausschalten
                 SwView& rTempView = GetView();
+                sal_uInt16 nPageId = 0;
+                if ( nSlot == FN_FORMAT_PAGE_COLUMN_DLG )
+                    nPageId = TP_COLUMN ;
                 rTempView.GetDocShell()->FormatPage(rPageDesc.GetName(),
-                                    nSlot == FN_FORMAT_PAGE_COLUMN_DLG,
-                                    &rSh );
+                                    nPageId, &rSh );
                 rTempView.InvalidateRulerPos();
             }
         }
commit dc557cd036e49f6d642bcdbd79a525371c7c513c
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Thu Sep 8 14:27:28 2011 +0200

    Header/Footer: added the popup menu of the separator
    
    Removing the header/footer is working, but the edition still needs to be
    implemented

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index ab78d6a..ae2a6eb 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -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_PARAM2               (SID_SW_START + 2400)
 #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
  * 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.
 #define FN_DELETE_COMMENT           (FN_NOTES+6)
 #define FN_REPLY                    (FN_NOTES+7)
 
+
+#define FN_HEADERFOOTER_EDIT        (FN_HEADERFOOTER+1)
+#define FN_HEADERFOOTER_DELETE      (FN_HEADERFOOTER+2)
+
 /*--------------------------------------------------------------------
     Region: Parameter
  --------------------------------------------------------------------*/
diff --git a/sw/inc/swcommands.h b/sw/inc/swcommands.h
index 77b30ca..036abc8 100644
--- a/sw/inc/swcommands.h
+++ b/sw/inc/swcommands.h
@@ -433,5 +433,7 @@
 #define CMD_FN_REDLINE_REJECT_DIRECT                ".uno:RejectTracedChange"
 #define CMD_FN_REMOVE_HYPERLINK                     ".uno:RemoveHyperlink"
 #define CMD_FN_COPY_HYPERLINK_LOCATION              ".uno:CopyHyperlinkLocation"
+#define CMD_FN_HEADERFOOTER_EDIT                    ".uno:HeaderFooterEdit"
+#define CMD_FN_HEADERFOOTER_DELETE                  ".uno:HeaderFooterDelete"
 
 #endif
diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src
index 182b7e1..e7a59f5 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 970767a..1dffb6e 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 d61ecde..c3c21d5 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 62f2109..c7ec2cf 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
commit 14727e633fa8fcc684ad08804b473eaf6006f0d4
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Thu Sep 8 12:01:50 2011 +0200

    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.

diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index d5e317f..970767a 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 cd2991a..d61ecde 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
commit 79f53401c6801e240800fb6e1eaae8f55974f9c6
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Wed Sep 7 22:22:47 2011 +0200

    Header/Footer: just don't always drop and create SwHeaderFooterWin
    
    This minimizes the number of creation / deletion of SwHeaderFooterWin
    objects and simply updates the existing ones.

diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 38ed77b..263facb 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -45,6 +45,9 @@
 #include <tgrditem.hxx>
 #include <viewopt.hxx>
 #include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <edtwin.hxx>
 
 #include "viewimp.hxx"
 #include "viewopt.hxx"
@@ -277,6 +280,15 @@ SwPageFrm::SwPageFrm( SwFrmFmt *pFmt, SwFrm* pSib, SwPageDesc *pPgDsc ) :
 
 SwPageFrm::~SwPageFrm()
 {
+    // Cleanup the header-footer controls in the SwEditWin
+    ViewShell* pSh = getRootFrm()->GetCurrShell();
+    SwWrtShell* pWrtSh = dynamic_cast< SwWrtShell* >( pSh );
+    if ( pWrtSh )
+    {
+        SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
+        rEditWin.RemoveHeaderFooterControls( this );
+    }
+
     //FlyContainer entleeren, delete der Flys uebernimmt der Anchor
     //(Basisklasse SwFrm)
     if ( pSortedObjs )
@@ -299,7 +311,6 @@ SwPageFrm::~SwPageFrm()
         SwDoc *pDoc = GetFmt() ? GetFmt()->GetDoc() : NULL;
         if( pDoc && !pDoc->IsInDtor() )
         {
-            ViewShell *pSh = getRootFrm()->GetCurrShell();
             if ( pSh )
             {
                 SwViewImp *pImp = pSh->Imp();
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 4a67bb2..23c523e 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2788,7 +2788,7 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
     if ( pWrtSh )
     {
         SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
-        rEditWin.ClearHeaderFooterControls( );
+        rEditWin.HideHeaderFooterControls( );
     }
 
 
@@ -3415,11 +3415,8 @@ void SwPageFrm::PaintDecorators( ) const
                 long nXOff = std::min( aBodyRect.Right(), rVisArea.Right() );
 
                 long nHeaderYOff = aBodyRect.Top();
-                if ( rVisArea.IsInside( Point( rVisArea.Left(), nHeaderYOff ) ) )
-                {
-                    Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nHeaderYOff + nHalfThickness ) );
-                    rEditWin.AddHeaderFooterControl( this, true, nOutputOff );
-                }
+                Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nHeaderYOff + nHalfThickness ) );
+                rEditWin.SetHeaderFooterControl( this, true, nOutputOff );
 
                 pProcessor->process( lcl_CreateHeaderFooterSeparatorPrimitives(
                             this, double( nHeaderYOff ) ) );
@@ -3434,11 +3431,8 @@ void SwPageFrm::PaintDecorators( ) const
                 }
 
                 long nFooterYOff = aBodyRect.Bottom();
-                if ( rVisArea.IsInside( Point( rVisArea.Left(), nFooterYOff ) ) )
-                {
-                    Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nFooterYOff - nHalfThickness ) );
-                    rEditWin.AddHeaderFooterControl( this, false, nOutputOff );
-                }
+                nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nFooterYOff - nHalfThickness ) );
+                rEditWin.SetHeaderFooterControl( this, false, nOutputOff );
 
                 pProcessor->process( lcl_CreateHeaderFooterSeparatorPrimitives(
                             this, double( nFooterYOff ) ) );
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index 0665064..d5e317f 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -104,10 +104,7 @@ class SwHeaderFooterButton : public MenuButton
 };
 
 
-// the WB_MOVABLE flag is used here to avoid the window to appear on all desktops (on linux)
-// and the WB_OWNERDRAWDECORATION prevents the system to draw the window decorations.
-//
-SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader, Point aOffset ) :
+SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader ) :
     Window( pEditWin, WB_DIALOGCONTROL  ),
     m_pEditWin( pEditWin ),
     m_sLabel( ),
@@ -128,18 +125,35 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag
         m_sLabel = ResId::toString( SW_RES( STR_FOOTER_TITLE ) );
     sal_Int32 nPos = m_sLabel.lastIndexOf( rtl::OUString::createFromAscii( "%1" ) );
     m_sLabel = m_sLabel.replaceAt( nPos, 2, m_pPageFrm->GetPageDesc()->GetName() );
+}
+
+SwHeaderFooterWin::~SwHeaderFooterWin( )
+{
+    delete m_pButton;
+}
 
+MenuButton* SwHeaderFooterWin::GetMenuButton()
+{
+    if ( !m_pButton )
+        m_pButton = new SwHeaderFooterButton( this );
+
+    m_pButton->Show();
+
+    return m_pButton;
+}
+
+void SwHeaderFooterWin::SetOffset( Point aOffset )
+{
     // Compute the text size and get the box position & size from it
     Rectangle aTextRect;
     GetTextBoundRect( aTextRect, String( m_sLabel ) );
     Rectangle aTextPxRect = LogicToPixel( aTextRect );
 
-
     Size  aBoxSize ( aTextPxRect.GetWidth() + BUTTON_WIDTH + TEXT_PADDING * 2,
                      aTextPxRect.GetHeight() + TEXT_PADDING  * 2 );
 
     long nYFooterOff = 0;
-    if ( !bHeader )
+    if ( !IsHeader() )
         nYFooterOff = aBoxSize.Height();
 
     Point aBoxPos( aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
@@ -148,18 +162,10 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag
     // Set the position & Size of the window
     SetPosSizePixel( aBoxPos, aBoxSize );
 
-    // Add the menu button
+    // Set the button position and size
     Point aBtnPos( aBoxSize.getWidth() - BUTTON_WIDTH, 0 );
     Size aBtnSize( BUTTON_WIDTH, aBoxSize.getHeight() );
-
-    m_pButton = new SwHeaderFooterButton( this );
-    m_pButton->SetPosSizePixel( aBtnPos, aBtnSize );
-    m_pButton->Show();
-}
-
-SwHeaderFooterWin::~SwHeaderFooterWin( )
-{
-    delete m_pButton;
+    GetMenuButton()->SetPosSizePixel( aBtnPos, aBtnSize );
 }
 
 void SwHeaderFooterWin::Paint( const Rectangle& )
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 5dbfbd3..6b800f8 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -141,6 +141,8 @@
 
 #include <PostItMgr.hxx>
 
+#include <algorithm>
+
 #include "../../core/inc/rootfrm.hxx"
 
 using namespace sw::mark;
@@ -212,6 +214,17 @@ namespace
         }
         return bRet;
     }
+
+    class PageFramePredicate
+    {
+        const SwPageFrm* m_pToMatch;
+
+        public:
+            PageFramePredicate( const SwPageFrm* pPageFrm ) : m_pToMatch( pPageFrm ) { };
+
+            virtual bool operator()( boost::shared_ptr< SwHeaderFooterWin > pToCheck )
+                { return m_pToMatch == pToCheck->GetPageFrame(); };
+    };
 }
 
 class SwAnchorMarker
@@ -4559,6 +4572,7 @@ SwEditWin::SwEditWin(Window *pParent, SwView &rMyView):
 
 SwEditWin::~SwEditWin()
 {
+    aHeadFootControls.clear();
     aKeyInputTimer.Stop();
     delete pShadCrsr;
     delete pRowColumnSelectionStart;
@@ -5681,16 +5695,45 @@ Selection SwEditWin::GetSurroundingTextSelection() const
     }
 }
 
-void SwEditWin::AddHeaderFooterControl( const SwPageFrm* pPageFrm, bool bHeader, Point aOffset )
+void SwEditWin::SetHeaderFooterControl( const SwPageFrm* pPageFrm, bool bHeader, Point aOffset )
 {
-    boost::shared_ptr< SwHeaderFooterWin > pNewControl( new SwHeaderFooterWin( this, pPageFrm, bHeader, aOffset ) );
-    pNewControl->Show( );
-    aHeadFootControls.push_back( pNewControl );
+    // Check if we already have the control
+    boost::shared_ptr< SwHeaderFooterWin > pControl;
+    std::vector< boost::shared_ptr< SwHeaderFooterWin > >::iterator pIt = aHeadFootControls.begin();
+    while ( pIt != aHeadFootControls.end() && !pControl.get() )
+    {
+        if ( ( *pIt )->GetPageFrame( ) == pPageFrm &&
+             ( *pIt )->IsHeader( ) == bHeader )
+            pControl = *pIt;
+        pIt++;
+    }
+
+    if ( !pControl.get() )
+    {
+        boost::shared_ptr< SwHeaderFooterWin > pNewControl( new SwHeaderFooterWin( this, pPageFrm, bHeader ) );
+        pControl.swap( pNewControl );
+        aHeadFootControls.push_back( pControl );
+    }
+    pControl->SetOffset( aOffset );
+
+    pControl->Show( );
 }
 
-void SwEditWin::ClearHeaderFooterControls( )
+void SwEditWin::RemoveHeaderFooterControls( const SwPageFrm* pPageFrm )
 {
-    aHeadFootControls.clear();
+    aHeadFootControls.erase( remove_if( aHeadFootControls.begin(),
+                                        aHeadFootControls.end(),
+                                        PageFramePredicate( pPageFrm ) ), aHeadFootControls.end() );
+}
+
+void SwEditWin::HideHeaderFooterControls( )
+{
+    std::vector< boost::shared_ptr< SwHeaderFooterWin > >::iterator pIt = aHeadFootControls.begin();
+    while ( pIt != aHeadFootControls.end() )
+    {
+        ( *pIt )->Hide();
+        pIt++;
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx
index 42b80a1..cd2991a 100644
--- a/sw/source/ui/inc/HeaderFooterWin.hxx
+++ b/sw/source/ui/inc/HeaderFooterWin.hxx
@@ -30,6 +30,7 @@
 
 #include <pagedesc.hxx>
 
+#include <vcl/menubtn.hxx>
 #include <vcl/window.hxx>
 
 class SwHeaderFooterButton;
@@ -48,13 +49,19 @@ class SwHeaderFooterWin : public Window
     SwHeaderFooterButton* m_pButton;
 
 public:
-    SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader, Point aOffset );
+    SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader );
     ~SwHeaderFooterWin( );
 
+    void SetOffset( Point aOffset );
+
     virtual void Paint( const Rectangle& rRect );
 
     bool IsHeader() { return m_bIsHeader; };
     bool IsEmptyHeaderFooter( );
+    const SwPageFrm* GetPageFrame( ) { return m_pPageFrm; };
+
+private:
+    MenuButton* GetMenuButton();
 };
 
 #endif
diff --git a/sw/source/ui/inc/edtwin.hxx b/sw/source/ui/inc/edtwin.hxx
index 1c03d77..142514c 100644
--- a/sw/source/ui/inc/edtwin.hxx
+++ b/sw/source/ui/inc/edtwin.hxx
@@ -312,8 +312,9 @@ public:
     void        SetUseInputLanguage( sal_Bool bNew );
     sal_Bool    IsUseInputLanguage() const { return bUseInputLanguage; }
 
-    void AddHeaderFooterControl( const SwPageFrm* pPageFrm, bool bHeader, Point aOffset );
-    void ClearHeaderFooterControls( );
+    void SetHeaderFooterControl( const SwPageFrm* pPageFrm, bool bHeader, Point aOffset );
+    void RemoveHeaderFooterControls( const SwPageFrm* pPageFrm );
+    void HideHeaderFooterControls( );
 
     SwEditWin(Window *pParent, SwView &);
     virtual ~SwEditWin();
commit 1291efeee9ee4079e6bb38e0b06e9f73c365c7a0
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Wed Sep 7 18:03:59 2011 +0200

    Header/Footer: vertically center the text in the separator control

diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index 9ba49fc..0665064 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -168,10 +168,13 @@ void SwHeaderFooterWin::Paint( const Rectangle& )
     lcl_DrawBackground( this, aRect, m_bIsHeader );
 
     // Draw the text
+    Rectangle aTextRect;
+    GetTextBoundRect( aTextRect, String( m_sLabel ) );
+    Point aTextPos = aTextRect.TopLeft() + Point( TEXT_PADDING, 0 );
+
     basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
     SetTextColor( Color( aLineColor ) );
-    DrawText( Point( aRect.Left() + TEXT_PADDING, aRect.Top() + TEXT_PADDING ),
-           String( m_sLabel ) );
+    DrawText( aTextPos, String( m_sLabel ) );
 }
 
 bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
commit 4115a81bea06eb9cb3ea7b6d8819a35a8a8de52b
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Wed Sep 7 16:02:01 2011 +0200

    Header/Footer: Use a Window with WB_DIALOGCONTROL to fix loads of bugs
    
    Bugs fixed by this change:
      * The Header/footer window is now moving with the parent window
      * The Window rectangle is adapted to the parent area and doesn't go
        over the scrollbar
      * The windows are shown properly in all cases

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index e3146af..4a67bb2 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3414,7 +3414,6 @@ void SwPageFrm::PaintDecorators( ) const
                 const SwRect& rVisArea = pGlobalShell->VisArea();
                 long nXOff = std::min( aBodyRect.Right(), rVisArea.Right() );
 
-                // FIXME there are cases where the label isn't show but should be
                 long nHeaderYOff = aBodyRect.Top();
                 if ( rVisArea.IsInside( Point( rVisArea.Left(), nHeaderYOff ) ) )
                 {
@@ -3434,7 +3433,6 @@ void SwPageFrm::PaintDecorators( ) const
                     pFtnContFrm = pFtnContFrm->GetNext();
                 }
 
-                // FIXME there are cases where the label isn't show but should be
                 long nFooterYOff = aBodyRect.Bottom();
                 if ( rVisArea.IsInside( Point( rVisArea.Left(), nFooterYOff ) ) )
                 {
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index 271a7d7..9ba49fc 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -58,6 +58,38 @@ namespace
         aHslLine.setZ( nLuminance );
         return basegfx::tools::hsl2rgb( aHslLine );
     }
+
+    void lcl_DrawBackground( OutputDevice* pOut, const Rectangle& rRect, bool bHeader )
+    {
+        // Colors
+        basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
+        basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor );
+
+        // Draw the background rect
+        pOut->SetFillColor( Color ( aFillColor ) );
+        pOut->SetLineColor( Color ( aFillColor ) );
+        pOut->DrawRect( rRect );
+
+        // Draw the lines around the rect
+        pOut->SetLineColor( Color( aLineColor ) );
+        basegfx::B2DPolygon aPolygon;
+        aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Top() ) );
+        aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Bottom() ) );
+        pOut->DrawPolyLine( aPolygon, 1.0 );
+
+        aPolygon.clear();
+        aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Top() ) );
+        aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Bottom() ) );
+        pOut->DrawPolyLine( aPolygon, 1.0 );
+
+        long nYLine = rRect.Bottom();
+        if ( !bHeader )
+            nYLine = rRect.Top();
+        aPolygon.clear();
+        aPolygon.append( basegfx::B2DPoint( rRect.Left(), nYLine ) );
+        aPolygon.append( basegfx::B2DPoint( rRect.Right(), nYLine ) );
+        pOut->DrawPolyLine( aPolygon, 1.0 );
+    }
 }
 
 class SwHeaderFooterButton : public MenuButton
@@ -76,7 +108,7 @@ class SwHeaderFooterButton : public MenuButton
 // and the WB_OWNERDRAWDECORATION prevents the system to draw the window decorations.
 //
 SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPageFrm, bool bHeader, Point aOffset ) :
-    FloatingWindow( pEditWin, WB_SYSTEMWINDOW | WB_NOBORDER | WB_NOSHADOW | WB_MOVEABLE | WB_OWNERDRAWDECORATION  ),
+    Window( pEditWin, WB_DIALOGCONTROL  ),
     m_pEditWin( pEditWin ),
     m_sLabel( ),
     m_pPageFrm( pPageFrm ),
@@ -110,9 +142,8 @@ SwHeaderFooterWin::SwHeaderFooterWin( SwEditWin* pEditWin, const SwPageFrm* pPag
     if ( !bHeader )
         nYFooterOff = aBoxSize.Height();
 
-    Size aPosOffset ( pEditWin->GetOutOffXPixel(), pEditWin->GetOutOffYPixel() );
-    Point aBoxPos( aPosOffset.Width() + aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
-                   aPosOffset.Height() + aOffset.Y() - nYFooterOff );
+    Point aBoxPos( aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
+                   aOffset.Y() - nYFooterOff );
 
     // Set the position & Size of the window
     SetPosSizePixel( aBoxPos, aBoxSize );
@@ -131,40 +162,15 @@ SwHeaderFooterWin::~SwHeaderFooterWin( )
     delete m_pButton;
 }
 
-void SwHeaderFooterWin::Paint( const Rectangle& rRect )
+void SwHeaderFooterWin::Paint( const Rectangle& )
 {
-    // Colors
-    basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
-    basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor );
-
-    // Draw the background rect
-    SetFillColor( Color ( aFillColor ) );
-    SetLineColor( Color ( aFillColor ) );
-    DrawRect( rRect );
-
-    // Draw the lines around the rect
-    SetLineColor( Color( aLineColor ) );
-    basegfx::B2DPolygon aPolygon;
-    aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Top() ) );
-    aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Bottom() ) );
-    DrawPolyLine( aPolygon, 1.0 );
-
-    aPolygon.clear();
-    aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Top() ) );
-    aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Bottom() ) );
-    DrawPolyLine( aPolygon, 1.0 );
-
-    long nYLine = rRect.Bottom();
-    if ( !m_bIsHeader )
-        nYLine = rRect.Top();
-    aPolygon.clear();
-    aPolygon.append( basegfx::B2DPoint( rRect.Left(), nYLine ) );
-    aPolygon.append( basegfx::B2DPoint( rRect.Right(), nYLine ) );
-    DrawPolyLine( aPolygon, 1.0 );
+    const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
+    lcl_DrawBackground( this, aRect, m_bIsHeader );
 
     // Draw the text
+    basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
     SetTextColor( Color( aLineColor ) );
-    DrawText( Point( rRect.Left() + TEXT_PADDING, rRect.Top() + TEXT_PADDING ),
+    DrawText( Point( aRect.Left() + TEXT_PADDING, aRect.Top() + TEXT_PADDING ),
            String( m_sLabel ) );
 }
 
@@ -200,39 +206,13 @@ SwHeaderFooterButton::~SwHeaderFooterButton( )
 {
 }
 
-void SwHeaderFooterButton::Paint( const Rectangle& rRect )
+void SwHeaderFooterButton::Paint( const Rectangle& )
 {
-    // Colors
-    basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
-    basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor );
-
-    // Draw the background rect
-    SetFillColor( Color ( aFillColor ) );
-    SetLineColor( Color ( aFillColor ) );
-    DrawRect( rRect );
-
-    // Draw the lines around the rect
-    SetLineColor( Color( aLineColor ) );
-    basegfx::B2DPolygon aPolygon;
-    aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Top() ) );
-    aPolygon.append( basegfx::B2DPoint( rRect.Left(), rRect.Bottom() ) );
-    DrawPolyLine( aPolygon, 1.0 );
-
-    aPolygon.clear();
-    aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Top() ) );
-    aPolygon.append( basegfx::B2DPoint( rRect.Right(), rRect.Bottom() ) );
-    DrawPolyLine( aPolygon, 1.0 );
-
-    long nYLine = rRect.Bottom();
-    if ( !m_pWindow->IsHeader() )
-        nYLine = rRect.Top();
-    aPolygon.clear();
-    aPolygon.append( basegfx::B2DPoint( rRect.Left(), nYLine ) );
-    aPolygon.append( basegfx::B2DPoint( rRect.Right(), nYLine ) );
-    DrawPolyLine( aPolygon, 1.0 );
-
-
-    Rectangle aSymbolRect( rRect );
+    const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
+
+    lcl_DrawBackground( this, aRect, m_pWindow->IsHeader() );
+
+    Rectangle aSymbolRect( aRect );
     // 25% distance to the left and right button border
     const long nBorderDistanceLeftAndRight = ((aSymbolRect.GetWidth()*250)+500)/1000;
     aSymbolRect.Left()+=nBorderDistanceLeftAndRight;
@@ -249,9 +229,9 @@ void SwHeaderFooterButton::Paint( const Rectangle& rRect )
         SvtResId id( BMP_LIST_ADD );
         Image aPlusImg( id );
         Size aSize = aPlusImg.GetSizePixel();
-        Point aPt = rRect.TopLeft();
-        long nXOffset = ( rRect.GetWidth() - aSize.Width() ) / 2;
-        long nYOffset = ( rRect.GetHeight() - aSize.Height() ) / 2;
+        Point aPt = aRect.TopLeft();
+        long nXOffset = ( aRect.GetWidth() - aSize.Width() ) / 2;
+        long nYOffset = ( aRect.GetHeight() - aSize.Height() ) / 2;
         aPt += Point( nXOffset, nYOffset );
         DrawImage(aPt, aPlusImg);
     }
diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx
index e35bc9a..42b80a1 100644
--- a/sw/source/ui/inc/HeaderFooterWin.hxx
+++ b/sw/source/ui/inc/HeaderFooterWin.hxx
@@ -30,7 +30,7 @@
 
 #include <pagedesc.hxx>
 
-#include <vcl/floatwin.hxx>
+#include <vcl/window.hxx>
 
 class SwHeaderFooterButton;
 
@@ -39,7 +39,7 @@ class SwHeaderFooterButton;
     This control is showing the header / footer style name and provides
     a few useful actions to the user.
   */
-class SwHeaderFooterWin : public FloatingWindow
+class SwHeaderFooterWin : public Window
 {
     SwEditWin*            m_pEditWin;
     rtl::OUString         m_sLabel;


More information about the Libreoffice-commits mailing list