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

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Tue Sep 13 05:11:44 PDT 2011


 sw/inc/crsrsh.hxx                      |    3 -
 sw/inc/viewsh.hxx                      |    2 
 sw/source/core/crsr/crsrsh.cxx         |   51 ++-------------------
 sw/source/core/layout/paintfrm.cxx     |   31 ++++++++++---
 sw/source/ui/app/mn.src                |    2 
 sw/source/ui/docvw/HeaderFooterWin.cxx |   77 +++++++++++++++-----------------
 sw/source/ui/docvw/edtwin.cxx          |    5 ++
 sw/source/ui/inc/HeaderFooterWin.hxx   |    2 
 sw/source/ui/inc/textsh.hxx            |    1 
 sw/source/ui/inc/wrtsh.hxx             |    2 
 sw/source/ui/shells/textsh1.cxx        |   78 ---------------------------------
 sw/source/ui/shells/txtcrsr.cxx        |   12 ++++-
 sw/source/ui/wrtsh/wrtsh1.cxx          |   76 ++++++++++++++++++++++++++++++++
 13 files changed, 164 insertions(+), 178 deletions(-)

New commits:
commit 59585dab4bf00e4979fdfd8ce6c038ead143996e
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Tue Sep 13 14:05:45 2011 +0200

    Header/Footer: fixed the Ctrl+PgUp and Ctrl+PdDown behaviors
    
    When in a header and hitting Ctrl+PgDown, go to the end of the page if
    there is no footer in it instead of staying in the header. The same case
    for footers has been fixed too.
    
    Removed the cursor positioning hackery in ToggleHeaderFooterEdit(): this
    is now handled by the caller.
    
    Show the Header/Footer edition when hitting Ctrl+PgUp and Ctrl+PgDown
    and actually landing into a header or footer.

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 3dc677e..780e1d8 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -190,7 +190,6 @@ private:
     SwShellCrsr* pCurCrsr;      // current cursor
     SwShellCrsr* pCrsrStk;      // stack for the cursor
     SwVisCrsr *pVisCrsr;        // the visible cursor
-    SwShellCrsr* pCrsrBack;     // Backup cursor for header/footer edit mode
 
     IBlockCursor *pBlockCrsr;   // interface of cursor for block (=rectangular) selection
 
@@ -851,8 +850,6 @@ public:
     String GetCrsrDescr() const;
 
     SwRect GetRectOfCurrentChar();
-
-    virtual void ToggleHeaderFooterEdit( );
 };
 
 // Cursor Inlines:
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 3cb4748..8c2cab8 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -565,7 +565,7 @@ public:
     const SwPostItMgr* GetPostItMgr() const { return (const_cast<ViewShell*>(this))->GetPostItMgr(); }
     SwPostItMgr* GetPostItMgr();
 
-    virtual void ToggleHeaderFooterEdit( );
+    void ToggleHeaderFooterEdit( );
     sal_Bool IsHeaderFooterEdit( ) const { return bHeaderFooterEdit; }
     sal_Bool IsShowHeaderFooterSeparator( ) { return bShowHeaderFooterSeparator; }
     void SetShowHeaderFooterSeparator( sal_Bool bShow ) { bShowHeaderFooterSeparator = bShow; }
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 67bbdad..7339aba 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1320,6 +1320,11 @@ void SwCrsrShell::UpdateCrsr( sal_uInt16 eFlags, sal_Bool bIdleEnd )
         return;             // wenn nicht, dann kein Update !!
     }
 
+    bool bInHeaderFooter = IsInHeaderFooter( );
+    if ( ( bInHeaderFooter && !IsHeaderFooterEdit( ) ) ||
+       ( !bInHeaderFooter && IsHeaderFooterEdit( ) ) )
+        ToggleHeaderFooterEdit( );
+
     // #i27301#
     SwNotifyAccAboutInvalidTextSelections aInvalidateTextSelections( *this );
 
@@ -2545,7 +2550,7 @@ void SwCrsrShell::ParkCrsr( const SwNodeIndex &rIdx )
 
 SwCrsrShell::SwCrsrShell( SwCrsrShell& rShell, Window *pInitWin )
     : ViewShell( rShell, pInitWin ),
-    SwModify( 0 ), pCrsrStk( 0 ), pCrsrBack( 0 ), pBlockCrsr( 0 ), pTblCrsr( 0 ),
+    SwModify( 0 ), pCrsrStk( 0 ), pBlockCrsr( 0 ), pTblCrsr( 0 ),
     pBoxIdx( 0 ), pBoxPtr( 0 ), nCrsrMove( 0 ), nBasicActionCnt( 0 ),
     eMvState( MV_NONE ),
     sMarkedListId(),
@@ -2573,7 +2578,7 @@ SwCrsrShell::SwCrsrShell( SwCrsrShell& rShell, Window *pInitWin )
 SwCrsrShell::SwCrsrShell( SwDoc& rDoc, Window *pInitWin,
                             const SwViewOption *pInitOpt )
     : ViewShell( rDoc, pInitWin, pInitOpt ),
-    SwModify( 0 ), pCrsrStk( 0 ), pCrsrBack( 0 ), pBlockCrsr( 0 ), pTblCrsr( 0 ),
+    SwModify( 0 ), pCrsrStk( 0 ), pBlockCrsr( 0 ), pTblCrsr( 0 ),
     pBoxIdx( 0 ), pBoxPtr( 0 ), nCrsrMove( 0 ), nBasicActionCnt( 0 ),
     eMvState( MV_NONE ), // state for crsr-travelling - GetCrsrOfst
     sMarkedListId(),
@@ -2635,9 +2640,6 @@ SwCrsrShell::~SwCrsrShell()
         delete pCrsrStk;
     }
 
-    if( pCrsrBack )
-        delete pCrsrBack;
-
     // JP 27.07.98: Bug 54025 - ggfs. den HTML-Parser, der als Client in
     //              der CursorShell haengt keine Chance geben, sich an den
     //              TextNode zu haengen.
@@ -3450,43 +3452,4 @@ void SwCrsrShell::GetSmartTagTerm( const Point& rPt, SwRect& rSelectRect,
 }
 
 
-void SwCrsrShell::ToggleHeaderFooterEdit( )
-{
-    ViewShell::ToggleHeaderFooterEdit();
-
-    SET_CURR_SHELL( this );
-
-    if ( IsHeaderFooterEdit() )
-    {
-        pCrsrBack = new SwShellCrsr( *this, *pCurCrsr->GetPoint(),
-                                    pCurCrsr->GetPtPos() );
-
-        if ( pCurCrsr->HasMark() )
-        {
-            pCrsrBack->SetMark();
-            *pCrsrBack->GetMark() = *pCurCrsr->GetMark();
-        }
-    }
-    else
-    {
-        SwPosition& rPos = *pCurCrsr->GetPoint();
-        rPos.nNode = pCrsrBack->GetPoint()->nNode;
-        rPos.nContent = pCrsrBack->GetPoint()->nContent;
-
-        if ( pCrsrBack->HasMark( ) )
-        {
-            pCurCrsr->SetMark();
-            rPos = *pCurCrsr->GetMark();
-            rPos.nNode = pCrsrBack->GetMark()->nNode;
-            rPos.nContent = pCrsrBack->GetMark()->nContent;
-        }
-
-        delete pCrsrBack;
-        pCrsrBack = NULL;
-
-        UpdateCrsr( SwCrsrShell::SCROLLWIN | SwCrsrShell::CHKRANGE |
-                    SwCrsrShell::READONLY );
-    }
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index e7aa37d..8b1ccca 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -1312,6 +1312,11 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
     else if ( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE &&
             rSh.IsHeaderFooterEdit( ) )
     {
+        bool bHeader = FRMTYPE_HEADER & rSh.GetFrmType(0,sal_False);
+        if ( bHeader )
+            rSh.SttPg();
+        else
+            rSh.EndPg();
         rSh.ToggleHeaderFooterEdit();
     }
 
diff --git a/sw/source/ui/shells/txtcrsr.cxx b/sw/source/ui/shells/txtcrsr.cxx
index 2b27752..0be6917 100644
--- a/sw/source/ui/shells/txtcrsr.cxx
+++ b/sw/source/ui/shells/txtcrsr.cxx
@@ -293,7 +293,11 @@ void SwTextShell::ExecMoveMisc(SfxRequest &rReq)
             if ( FRMTYPE_HEADER & rSh.GetFrmType(0,sal_False) )
                 rSh.SttPg();
             else
-                rSh.GotoHeaderTxt();
+            {
+                bool bMoved = rSh.GotoHeaderTxt();
+                if ( !bMoved )
+                    rSh.SttPg();
+            }
             bSetRetVal = sal_False;
             break;
         case FN_TO_FOOTER:
@@ -301,7 +305,11 @@ void SwTextShell::ExecMoveMisc(SfxRequest &rReq)
             if ( FRMTYPE_FOOTER & rSh.GetFrmType(0,sal_False) )
                 rSh.EndPg();
             else
-                rSh.GotoFooterTxt();
+            {
+                bool bMoved = rSh.GotoFooterTxt();
+                if ( !bMoved )
+                    rSh.EndPg();
+            }
             bSetRetVal = sal_False;
             break;
         case FN_FOOTNOTE_TO_ANCHOR:
commit c0251bf65d1e972be395514724a413995ef53af8
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Tue Sep 13 11:32:11 2011 +0200

    Header/Footer: shared code for the insertion/removal
    
    Moved the ChangedHeaderOrFooter method from SwTextShell to SwWrtShell
    for it to be accessible from the SwHeaderFooterWin objects... and that
    method didn't really need to be in the root shell.
    
    That fixed a few quirks from the copied code in SwHeaderFooterWin.

diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src
index c63d6d0..4156ba2 100644
--- a/sw/source/ui/app/mn.src
+++ b/sw/source/ui/app/mn.src
@@ -1448,7 +1448,7 @@ Menu MN_HEADERFOOTER_BUTTON
         {
             Identifier = FN_HEADERFOOTER_DELETE ;
             HelpID = CMD_FN_HEADERFOOTER_DELETE ;
-            Text [ en-US ] = "Delete $1" ;
+            Text [ en-US ] = "Delete $1..." ;
         };
     };
 };
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index d7c9c84..6f59189 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -45,7 +45,6 @@
 
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <basegfx/color/bcolortools.hxx>
-#include <editeng/ulspitem.hxx>
 #include <svtools/svtdata.hxx>
 #include <vcl/decoview.hxx>
 #include <vcl/gradient.hxx>
@@ -184,7 +183,7 @@ void SwHeaderFooterWin::SetOffset( Point aOffset )
                      aTextPxRect.GetHeight() + TEXT_PADDING  * 2 );
 
     long nYFooterOff = 0;
-    if ( !IsHeader() )
+    if ( !m_bIsHeader )
         nYFooterOff = aBoxSize.Height();
 
     Point aBoxPos( aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
@@ -270,54 +269,29 @@ bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
     return bResult;
 }
 
-void SwHeaderFooterWin::ChangeHeaderOrFooter( bool bAdd )
-{
-    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( bAdd ) );
-    else
-        rMaster.SetFmtAttr( SwFmtFooter( bAdd ) );
-
-    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 )
 {
+    SwView& rView = m_pEditWin->GetView();
+    SwWrtShell& rSh = rView.GetWrtShell();
+
+    const String& rStyleName = GetPageFrame()->GetPageDesc()->GetName();
     switch ( nSlot )
     {
         case FN_HEADERFOOTER_EDIT:
             {
-                SwView& rView = m_pEditWin->GetView();
-                SwWrtShell& rSh = rView.GetWrtShell();
                 sal_uInt16 nPageId = TP_FOOTER_PAGE;
-                if ( IsHeader() )
+                if ( m_bIsHeader )
                     nPageId = TP_HEADER_PAGE;
 
                 rView.GetDocShell()->FormatPage(
-                        GetPageFrame()->GetPageDesc()->GetName(),
+                        rStyleName,
                         nPageId, &rSh );
             }
             break;
         case FN_HEADERFOOTER_DELETE:
-            ChangeHeaderOrFooter( false );
+            {
+                rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, false, true );
+            }
             break;
         default:
             break;
@@ -334,8 +308,11 @@ void SwHeaderFooterWin::MouseButtonDown( const MouseEvent& rMEvt )
 {
     if ( IsEmptyHeaderFooter( ) )
     {
-        // Add the header / footer
-        ChangeHeaderOrFooter( true );
+        SwView& rView = m_pEditWin->GetView();
+        SwWrtShell& rSh = rView.GetWrtShell();
+
+        const String& rStyleName = GetPageFrame()->GetPageDesc()->GetName();
+        rSh.ChangeHeaderOrFooter( rStyleName, m_bIsHeader, true, false );
     }
     else
         MenuButton::MouseButtonDown( rMEvt );
diff --git a/sw/source/ui/inc/HeaderFooterWin.hxx b/sw/source/ui/inc/HeaderFooterWin.hxx
index f805be2..50af8fd 100644
--- a/sw/source/ui/inc/HeaderFooterWin.hxx
+++ b/sw/source/ui/inc/HeaderFooterWin.hxx
@@ -31,7 +31,6 @@
 #include <pagedesc.hxx>
 
 #include <vcl/menubtn.hxx>
-#include <vcl/window.hxx>
 
 /** Class for the header and footer separator control window.
 
@@ -61,7 +60,6 @@ public:
     bool IsEmptyHeaderFooter( );
     const SwPageFrm* GetPageFrame( ) { return m_pPageFrm; };
 
-    void ChangeHeaderOrFooter( bool bAdd );
     void ExecuteCommand(sal_uInt16 nSlot);
 
     void SetReadonly( bool bReadonly );
diff --git a/sw/source/ui/inc/textsh.hxx b/sw/source/ui/inc/textsh.hxx
index 31a545a..aa08e8a 100644
--- a/sw/source/ui/inc/textsh.hxx
+++ b/sw/source/ui/inc/textsh.hxx
@@ -44,7 +44,6 @@ class SwTextShell: public SwBaseShell
     void InsertSymbol( SfxRequest& );
     void InsertHyperlink(const SvxHyperlinkItem& rHlnkItem);
     bool InsertMediaDlg( SfxRequest& );
-    void ChangeHeaderOrFooter(const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning);
 
 public:
     SFX_DECL_INTERFACE(SW_TEXTSHELL)
diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx
index e98afbd..735848f 100644
--- a/sw/source/ui/inc/wrtsh.hxx
+++ b/sw/source/ui/inc/wrtsh.hxx
@@ -485,6 +485,8 @@ typedef sal_Bool (SwWrtShell:: *FNSimpleMove)();
     sal_Bool GotoFld( const SwFmtFld& rFld );
     const SwRedline* GotoRedline( sal_uInt16 nArrPos, sal_Bool bSelect = sal_False);
 
+    void ChangeHeaderOrFooter(const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning);
+
 private:
 
     SW_DLLPRIVATE void  OpenMark();
diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx
index 739eaa6..7ccc72d 100644
--- a/sw/source/ui/shells/textsh1.cxx
+++ b/sw/source/ui/shells/textsh1.cxx
@@ -33,7 +33,6 @@
 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
 
 #include <comphelper/processfactory.hxx>
-#include <svx/dialogs.hrc>
 #include <hintids.hxx>
 #include <cmdid.h>
 #include <helpid.h>
@@ -50,13 +49,11 @@
 #include <sfx2/bindings.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/objitem.hxx>
-#include <vcl/msgbox.hxx>
 #include <vcl/unohelp2.hxx>
 #include <sfx2/request.hxx>
 #include <svl/eitem.hxx>
 #include <svl/macitem.hxx>
 #include <editeng/lrspitem.hxx>
-#include <editeng/ulspitem.hxx>
 #include <editeng/colritem.hxx>
 #include <editeng/tstpitem.hxx>
 #include <editeng/brshitem.hxx>
@@ -67,7 +64,6 @@
 #include <charfmt.hxx>
 #include <editeng/fontitem.hxx>
 #include <svx/SmartTagItem.hxx>
-#include <svx/dialmgr.hxx>
 #include <fmtinfmt.hxx>
 #include <swwait.hxx>
 #include <wrtsh.hxx>
@@ -76,7 +72,6 @@
 #include <viewopt.hxx>
 #include <uitool.hxx>
 #include <swevent.hxx>
-#include <fmthdft.hxx>
 #include <pagedesc.hxx>
 #include <textsh.hxx>
 #include <IMark.hxx>
@@ -1188,7 +1183,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
         sal_Bool bOn = sal_True;
         if( SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem))
             bOn = ((const SfxBoolItem*)pItem)->GetValue();
-        ChangeHeaderOrFooter(sStyleName, FN_INSERT_PAGEHEADER == nSlot, bOn, !rReq.IsAPI());
+        rWrtSh.ChangeHeaderOrFooter(sStyleName, FN_INSERT_PAGEHEADER == nSlot, bOn, !rReq.IsAPI());
         rReq.Done();
     }
     break;
@@ -1675,75 +1670,4 @@ void SwTextShell::GetState( SfxItemSet &rSet )
     }
 }
 
-/*
- *  Switch on/off header of footer of a page style - if an empty name is
- *  given all styles are changed
- */
-void SwTextShell::ChangeHeaderOrFooter(
-    const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning)
-{
-    SwWrtShell& rSh = GetShell();
-    rSh.addCurrentPosition();
-    rSh.StartAllAction();
-    rSh.StartUndo( UNDO_HEADER_FOOTER ); // #i7983#
-    sal_Bool bExecute = sal_True;
-    sal_Bool bCrsrSet = sal_False;
-    for( sal_uInt16 nFrom = 0, nTo = rSh.GetPageDescCnt();
-            nFrom < nTo; ++nFrom )
-    {
-        int bChgd = sal_False;
-        SwPageDesc aDesc( rSh.GetPageDesc( nFrom ));
-        String sTmp(aDesc.GetName());
-        if( !rStyleName.Len() || rStyleName == sTmp )
-        {
-            if( (bShowWarning && !bOn && GetActiveView() && GetActiveView() == &GetView() &&
-                (bHeader && aDesc.GetMaster().GetHeader().IsActive())) ||
-                (!bHeader && aDesc.GetMaster().GetFooter().IsActive()) )
-            {
-                bShowWarning = sal_False;
-                //Actions have to be closed while the dialog is showing
-                rSh.EndAllAction();
-
-                Window* pParent = &GetView().GetViewFrame()->GetWindow();
-                sal_Bool bRet = RET_YES == QueryBox( pParent, ResId( RID_SVXQBX_DELETE_HEADFOOT,
-                                        DIALOG_MGR() ) ).Execute();
-                bExecute = bRet;
-                rSh.StartAllAction();
-            }
-            if( bExecute )
-            {
-                bChgd = sal_True;
-                SwFrmFmt &rMaster = aDesc.GetMaster();
-                if(bHeader)
-                    rMaster.SetFmtAttr( SwFmtHeader( bOn ));
-                else
-                    rMaster.SetFmtAttr( SwFmtFooter( bOn ));
-                if( bOn )
-                {
-                    SvxULSpaceItem aUL(bHeader ? 0 : MM50, bHeader ? MM50 : 0, RES_UL_SPACE );
-                    SwFrmFmt* pFmt = bHeader ?
-                        (SwFrmFmt*)rMaster.GetHeader().GetHeaderFmt() :
-                        (SwFrmFmt*)rMaster.GetFooter().GetFooterFmt();
-                    pFmt->SetFmtAttr( aUL );
-                }
-            }
-            if( bChgd )
-            {
-                rSh.ChgPageDesc( nFrom, aDesc );
-
-                if( !bCrsrSet && bOn )
-                {
-                    if ( !rSh.IsHeaderFooterEdit() )
-                        rSh.ToggleHeaderFooterEdit();
-                    bCrsrSet = rSh.SetCrsrInHdFt(
-                            !rStyleName.Len() ? USHRT_MAX : nFrom,
-                            bHeader );
-                }
-            }
-        }
-    }
-    rSh.EndUndo( UNDO_HEADER_FOOTER ); // #i7983#
-    rSh.EndAllAction();
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx
index 94460f9..ec03fe4 100644
--- a/sw/source/ui/wrtsh/wrtsh1.cxx
+++ b/sw/source/ui/wrtsh/wrtsh1.cxx
@@ -38,6 +38,8 @@
 #include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/util/XModifiable.hpp>
 
+#include <svx/dialogs.hrc>
+
 #include <math.h>
 #include <hintids.hxx>
 #include <svx/svdview.hxx>
@@ -56,7 +58,9 @@
 #include <editeng/sizeitem.hxx>
 #include <editeng/brkitem.hxx>
 #include <editeng/svxacorr.hxx>
+#include <editeng/ulspitem.hxx>
 #include <vcl/graph.hxx>
+#include <vcl/msgbox.hxx>
 #include <sfx2/printer.hxx>
 #include <unotools/charclass.hxx>
 #include <comphelper/storagehelper.hxx>
@@ -65,6 +69,7 @@
 #include <svx/fontworkbar.hxx>
 #include <frmfmt.hxx>
 #include <fmtftn.hxx>
+#include <fmthdft.hxx>
 #include <fmtpdsc.hxx>
 #include <wdocsh.hxx>
 #include <basesh.hxx>
@@ -98,6 +103,7 @@
 #include <editeng/acorrcfg.hxx>
 #include <IMark.hxx>
 #include <sfx2/bindings.hxx>
+#include <svx/dialmgr.hxx>
 
 // -> #111827#
 #include <SwRewriter.hxx>
@@ -1814,4 +1820,74 @@ void SwWrtShell::SetReadonlyOption(sal_Bool bSet)
     ViewShell::SetReadonlyOption( bSet );
 }
 
+/*
+ *  Switch on/off header of footer of a page style - if an empty name is
+ *  given all styles are changed
+ */
+void SwWrtShell::ChangeHeaderOrFooter(
+    const String& rStyleName, sal_Bool bHeader, sal_Bool bOn, sal_Bool bShowWarning)
+{
+    addCurrentPosition();
+    StartAllAction();
+    StartUndo( UNDO_HEADER_FOOTER ); // #i7983#
+    sal_Bool bExecute = sal_True;
+    sal_Bool bCrsrSet = sal_False;
+    for( sal_uInt16 nFrom = 0, nTo = GetPageDescCnt();
+            nFrom < nTo; ++nFrom )
+    {
+        int bChgd = sal_False;
+        SwPageDesc aDesc( GetPageDesc( nFrom ));
+        String sTmp(aDesc.GetName());
+        if( !rStyleName.Len() || rStyleName == sTmp )
+        {
+            if( (bShowWarning && !bOn && GetActiveView() && GetActiveView() == &GetView() &&
+                (bHeader && aDesc.GetMaster().GetHeader().IsActive())) ||
+                (!bHeader && aDesc.GetMaster().GetFooter().IsActive()) )
+            {
+                bShowWarning = sal_False;
+                //Actions have to be closed while the dialog is showing
+                EndAllAction();
+
+                Window* pParent = &GetView().GetViewFrame()->GetWindow();
+                sal_Bool bRet = RET_YES == QueryBox( pParent, ResId( RID_SVXQBX_DELETE_HEADFOOT,
+                                        DIALOG_MGR() ) ).Execute();
+                bExecute = bRet;
+                StartAllAction();
+            }
+            if( bExecute )
+            {
+                bChgd = sal_True;
+                SwFrmFmt &rMaster = aDesc.GetMaster();
+                if(bHeader)
+                    rMaster.SetFmtAttr( SwFmtHeader( bOn ));
+                else
+                    rMaster.SetFmtAttr( SwFmtFooter( bOn ));
+                if( bOn )
+                {
+                    SvxULSpaceItem aUL(bHeader ? 0 : MM50, bHeader ? MM50 : 0, RES_UL_SPACE );
+                    SwFrmFmt* pFmt = bHeader ?
+                        (SwFrmFmt*)rMaster.GetHeader().GetHeaderFmt() :
+                        (SwFrmFmt*)rMaster.GetFooter().GetFooterFmt();
+                    pFmt->SetFmtAttr( aUL );
+                }
+            }
+            if( bChgd )
+            {
+                ChgPageDesc( nFrom, aDesc );
+
+                if( !bCrsrSet && bOn )
+                {
+                    if ( !IsHeaderFooterEdit() )
+                        ToggleHeaderFooterEdit();
+                    bCrsrSet = SetCrsrInHdFt(
+                            !rStyleName.Len() ? USHRT_MAX : nFrom,
+                            bHeader );
+                }
+            }
+        }
+    }
+    EndUndo( UNDO_HEADER_FOOTER ); // #i7983#
+    EndAllAction();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit c900069dee03c5ebf631a5862b94cd2962cbaea0
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Tue Sep 13 10:01:44 2011 +0200

    Header/Footer: display improvements
    
    Changed the following:
     + Draw a gradient in the separator tabs background
     + Draw a solid line under the dotted one to have a contrast for some page
       background colors.

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 38247ed..eee5966 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3279,31 +3279,48 @@ drawinglayer::primitive2d::Primitive2DSequence lcl_CreateHeaderFooterSeparatorPr
         const SwPageFrm* pPageFrm, double nLineY )
 {
     // Adjust the Y-coordinate of the line to the header/footer box
-    drawinglayer::primitive2d::Primitive2DSequence aSeq( 1 );
+    drawinglayer::primitive2d::Primitive2DSequence aSeq( 2 );
 
     basegfx::B2DPoint aLeft ( pPageFrm->Frm().Left(), nLineY );
     basegfx::B2DPoint aRight( pPageFrm->Frm().Right(), nLineY );
 
     basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
 
+    // Get a color for the contrast
+    basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aLineColor );
+    double nLuminance = aHslLine.getZ() * 2.5;
+    if ( nLuminance == 0 )
+        nLuminance = 0.5;
+    else if ( nLuminance >= 1.0 )
+        nLuminance = aHslLine.getZ() * 0.4;
+    aHslLine.setZ( nLuminance );
+    const basegfx::BColor aOtherColor = basegfx::tools::hsl2rgb( aHslLine );
+
+    // Compute the plain line
+    basegfx::B2DPolygon aLinePolygon;
+    aLinePolygon.append( aLeft );
+    aLinePolygon.append( aRight );
+
+    drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pPlainLine =
+        new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
+                aLinePolygon, aOtherColor );
+
+    aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pPlainLine );
+
+
     // Dashed line in twips
     std::vector< double > aStrokePattern;
     aStrokePattern.push_back( 40 );
     aStrokePattern.push_back( 40 );
 
-
     // Compute the dashed line primitive
-    basegfx::B2DPolygon aLinePolygon;
-    aLinePolygon.append( aLeft );
-    aLinePolygon.append( aRight );
-
     drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
             new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
                 basegfx::B2DPolyPolygon( aLinePolygon ),
                 drawinglayer::attribute::LineAttribute( aLineColor ),
                 drawinglayer::attribute::StrokeAttribute( aStrokePattern ) );
 
-    aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pLine );
+    aSeq[1] = drawinglayer::primitive2d::Primitive2DReference( pLine );
     return aSeq;
 }
 
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index 65b4176..d7c9c84 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -48,6 +48,7 @@
 #include <editeng/ulspitem.hxx>
 #include <svtools/svtdata.hxx>
 #include <vcl/decoview.hxx>
+#include <vcl/gradient.hxx>
 #include <vcl/menubtn.hxx>
 #include <vcl/svapp.hxx>
 
@@ -69,16 +70,35 @@ namespace
         return basegfx::tools::hsl2rgb( aHslLine );
     }
 
+    basegfx::BColor lcl_GetLighterGradientColor( basegfx::BColor aDarkColor )
+    {
+        basegfx::BColor aHslDark = basegfx::tools::rgb2hsl( aDarkColor );
+        double nLuminance = aHslDark.getZ() * 255 + 20;
+        aHslDark.setZ( nLuminance / 255.0 );
+        return basegfx::tools::hsl2rgb( aHslDark );
+    }
+
     void lcl_DrawBackground( OutputDevice* pOut, const Rectangle& rRect, bool bHeader )
     {
         // Colors
         basegfx::BColor aLineColor = SwViewOption::GetHeaderFooterMarkColor().getBColor();
         basegfx::BColor aFillColor = lcl_GetFillColor( aLineColor );
+        basegfx::BColor aLighterColor = lcl_GetLighterGradientColor( aFillColor );
+
+        // Draw the background gradient
+        Gradient aGradient;
+        if ( bHeader )
+            aGradient = Gradient( GRADIENT_LINEAR,
+                   Color( aLighterColor ), Color( aFillColor ) );
+        else
+            aGradient = Gradient( GRADIENT_LINEAR,
+                   Color( aFillColor ), Color( aLighterColor ) );
+
+        pOut->DrawGradient( rRect, aGradient );
 
-        // 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 ) );


More information about the Libreoffice-commits mailing list