[Libreoffice-commits] .: 7 commits - sw/inc sw/sdi sw/source sw/uiconfig

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Thu Jun 30 08:57:26 PDT 2011


 sw/inc/cmdid.h                           |    1 
 sw/inc/comcore.hrc                       |    3 
 sw/inc/crsrsh.hxx                        |    5 
 sw/inc/fesh.hxx                          |    1 
 sw/inc/viewsh.hxx                        |    4 
 sw/sdi/_textsh.sdi                       |    6 +
 sw/sdi/swriter.sdi                       |   27 ++++
 sw/source/core/crsr/crsrsh.cxx           |   58 +++++++++-
 sw/source/core/doc/notxtfrm.cxx          |    7 +
 sw/source/core/frmedt/feshview.cxx       |   10 +
 sw/source/core/frmedt/fews.cxx           |   12 ++
 sw/source/core/inc/frame.hxx             |    4 
 sw/source/core/inc/hffrm.hxx             |    2 
 sw/source/core/layout/paintfrm.cxx       |  174 ++++++++++++++++++++++++++++++-
 sw/source/core/layout/trvlfrm.cxx        |   66 ++++++++---
 sw/source/core/layout/wsfrm.cxx          |   20 +++
 sw/source/core/text/frmpaint.cxx         |    6 +
 sw/source/core/view/viewsh.cxx           |    7 +
 sw/source/core/view/vnew.cxx             |    2 
 sw/source/ui/app/app.src                 |   10 +
 sw/source/ui/docvw/edtwin.cxx            |   18 +++
 sw/source/ui/inc/view.hxx                |    3 
 sw/source/ui/shells/textsh1.cxx          |   27 ++++
 sw/uiconfig/sglobal/menubar/menubar.xml  |    1 
 sw/uiconfig/swform/menubar/menubar.xml   |    1 
 sw/uiconfig/swreport/menubar/menubar.xml |    1 
 sw/uiconfig/swriter/menubar/menubar.xml  |    1 
 sw/uiconfig/swxform/menubar/menubar.xml  |    1 
 28 files changed, 448 insertions(+), 30 deletions(-)

New commits:
commit 63e236721967660f0bce9447a4308d1ebcbabf10
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Thu Jun 30 15:00:18 2011 +0200

    n#676858: ESC key to escape the header / footer edit mode
    
    Fixed another minor issue:
     * cursor remained in header / footer when escaping with a flying object
       selected. Cleared the flys selection before toggling the edition mode
       in the SwFEShell

diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index b8e95a9..fa2008c 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -772,6 +772,7 @@ public:
     bool IsVerticalModeAtNdAndPos( const SwTxtNode& _rTxtNode,
                                    const Point& _rDocPos ) const;
 
+    virtual void ToggleHeaderFooterEdit( );
 };
 
 #endif
diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx
index 6fe4bf0..282f7b6 100644
--- a/sw/source/core/frmedt/fews.cxx
+++ b/sw/source/core/frmedt/fews.cxx
@@ -1314,4 +1314,16 @@ void SwFEShell::MoveObjectIfActive( svt::EmbeddedObjectRef&, const Point& )
     // does not do anything, only avoids crash if the method is used for wrong shell
 }
 
+void SwFEShell::ToggleHeaderFooterEdit()
+{
+    // Clear objects selection
+    if ( Imp()->GetDrawView()->AreObjectsMarked() )
+    {
+        Imp()->GetDrawView()->UnmarkAll();
+        ClearMark();
+    }
+
+    SwCrsrShell::ToggleHeaderFooterEdit();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index c5899bf..6950554 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -1252,6 +1252,8 @@ void SwEditWin::ChangeDrawing( sal_uInt8 nDir )
 
 void SwEditWin::KeyInput(const KeyEvent &rKEvt)
 {
+    SwWrtShell &rSh = rView.GetWrtShell();
+
     if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE &&
         pApplyTempl && pApplyTempl->pFormatClipboard )
     {
@@ -1259,6 +1261,11 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
         SetApplyTemplate(SwApplyTemplate());
         rView.GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
     }
+    else if ( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE &&
+            rSh.IsHeaderFooterEdit( ) )
+    {
+        rSh.ToggleHeaderFooterEdit();
+    }
 
     SfxObjectShell *pObjSh = (SfxObjectShell*)rView.GetViewFrame()->GetObjectShell();
     if ( bLockInput || (pObjSh && pObjSh->GetProgress()) )
@@ -1270,7 +1277,6 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
         delete pShadCrsr, pShadCrsr = 0;
     aKeyInputFlushTimer.Stop();
 
-    SwWrtShell &rSh = rView.GetWrtShell();
     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly() &&
                           rSh.IsCrsrReadonly();
 
commit eec512ec032e02ef02918f866c4ac067ad5b8143
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Wed Jun 29 11:16:29 2011 +0200

    n#676858: Paint some separator for header / footer edit mode
    
    This separator needs improvements and discussion with UI people.

diff --git a/sw/inc/comcore.hrc b/sw/inc/comcore.hrc
index d92a2c3..e102a83 100644
--- a/sw/inc/comcore.hrc
+++ b/sw/inc/comcore.hrc
@@ -84,6 +84,9 @@
 #define STR_TABLE_NAME                      (RC_COMCORE_BEGIN + 46)
 #define STR_PARAGRAPH_UNDO                  (RC_COMCORE_BEGIN + 47)
 
+#define STR_HEADER                          (RC_COMCORE_BEGIN + 48)
+#define STR_FOOTER                          (RC_COMCORE_BEGIN + 49)
+
 // defines for the Autoformat Redline Comments
 #define STR_AUTOFMTREDL_DEL_EMPTY_PARA			0
 #define STR_AUTOFMTREDL_USE_REPLACE             1
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index fe422c9..99dc2dc 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -30,6 +30,7 @@
 
 #include <vector>
 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
 #include <svl/svarray.hxx>
 #include <editeng/borderline.hxx>
 #include "swtypes.hxx"	// fuer SwTwips
@@ -527,6 +528,7 @@ public:
     void PaintBorderLine( const SwRect&, const SwRect&, const SwPageFrm*,
                           const Color *pColor, const editeng::SvxBorderStyle = editeng::SOLID ) const;
 
+    drawinglayer::processor2d::BaseProcessor2D * CreateProcessor2D( ) const;
     void ProcessPrimitives( const drawinglayer::primitive2d::Primitive2DSequence& rSequence ) const;
 
     //Retouche, nicht im Bereich des uebergebenen Rect!
diff --git a/sw/source/core/inc/hffrm.hxx b/sw/source/core/inc/hffrm.hxx
index 74e633d..4933fa9 100644
--- a/sw/source/core/inc/hffrm.hxx
+++ b/sw/source/core/inc/hffrm.hxx
@@ -46,6 +46,8 @@ public:
                              sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False );
     virtual SwTwips ShrinkFrm( SwTwips, 
                                sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False );
+
+    virtual void Paint( const SwRect&, SwPrintData const*const pPrintData = NULL ) const;
 };
 
 class SwHeaderFrm: public SwHeadFootFrm
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 82a40f5..3425892 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -88,6 +88,8 @@
 #include <EnhancedPDFExportHelper.hxx>
 #include <fesh.hxx>
 #include <svx/svdpage.hxx>
+#include <hffrm.hxx>
+#include <fmtpdsc.hxx>
 // <--
 // --> OD #i76669#
 #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
@@ -111,14 +113,20 @@
 #include <drawinglayer/geometry/viewinformation2d.hxx>
 #include <drawinglayer/processor2d/baseprocessor2d.hxx>
 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
 #include <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
 #include <drawinglayer/primitive2d/discreteshadowprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
 #include <svx/sdr/contact/objectcontacttools.hxx>
 #include <svx/unoapi.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
 
 using namespace ::editeng;
 using namespace ::com::sun::star;
+using namespace ::drawinglayer;
 
 #define GETOBJSHELL()		((SfxObjectShell*)rSh.GetDoc()->GetDocShell())
 
@@ -3310,6 +3318,130 @@ void SwLayoutFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
     }
 }
 
+void SwHeadFootFrm::Paint( const SwRect& rRect, SwPrintData const*const pPrintData ) const
+{
+    if ( !pGlobalShell->GetViewOptions()->IsPrinting() &&
+         !pGlobalShell->GetViewOptions()->IsPDFExport() &&
+         !pGlobalShell->IsPreView() &&
+         pGlobalShell->IsHeaderFooterEdit( ) )
+    {
+        double nLineY = double( rRect.Bottom() );
+        String aText = SW_RESSTR( STR_HEADER );
+
+        if ( IsFooterFrm( ) )
+        {
+            nLineY = double( rRect.Top() );
+            aText = SW_RESSTR( STR_FOOTER );
+        }
+
+        const String aStyleName = FindPageFrm()->GetPageDesc()->GetName();
+        aText += aStyleName;
+
+        primitive2d::Primitive2DSequence aSeq( 4 );
+        processor2d::BaseProcessor2D* pProcessor = CreateProcessor2D();
+
+        // Colors
+        basegfx::BColor aLineColor( 3.0 / 255.0, 105.0 / 255.0, 163.0 / 255.0 );
+        basegfx::BColor aFillColor( 170.0 / 255.0, 220.0 / 255.0, 247.0 / 255.0 );
+
+        // Dashed line in twips
+        std::vector< double > aStrokePattern;
+        aStrokePattern.push_back( 110 );
+        aStrokePattern.push_back( 110 );
+
+
+        // Compute the dashed line primitive
+        basegfx::B2DPolygon aLinePolygon;
+        aLinePolygon.append( basegfx::B2DPoint( double( rRect.Left() ), nLineY ) );
+        aLinePolygon.append( basegfx::B2DPoint( double( rRect.Right() ), nLineY ) );
+
+        primitive2d::PolyPolygonStrokePrimitive2D * pLine =
+                new primitive2d::PolyPolygonStrokePrimitive2D (
+                    basegfx::B2DPolyPolygon( aLinePolygon ),
+                    attribute::LineAttribute( aLineColor, 20.0 ),
+                    attribute::StrokeAttribute( aStrokePattern ) );
+
+        aSeq[1] = primitive2d::Primitive2DReference( pLine );
+
+        // Compute the text primitive
+        basegfx::B2DVector aFontSize;
+
+        OutputDevice* pOut = pGlobalShell->GetOut();
+        Font aFont = pOut->GetSettings().GetStyleSettings().GetAppFont();
+        aFont.SetHeight( 8 * 20 ); // 8pt to twips
+
+        attribute::FontAttribute aFontAttr = primitive2d::getFontAttributeFromVclFont(
+                aFontSize, aFont, false, false );
+
+        FontMetric aFontMetric = pOut->GetFontMetric( aFont );
+
+        double nTextOffsetY = aFontMetric.GetHeight() - aFontMetric.GetDescent() + 70.0;
+        if ( IsFooterFrm( ) )
+            nTextOffsetY = - aFontMetric.GetDescent() - 70.0;
+        basegfx::B2DHomMatrix aTextMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
+                    aFontSize.getX(), aFontSize.getY(),
+                    rRect.Left() + 80.0, nLineY + nTextOffsetY ) );
+
+
+        primitive2d::TextSimplePortionPrimitive2D * pText =
+                new primitive2d::TextSimplePortionPrimitive2D(
+                    aTextMatrix,
+                    aText, 0, aText.Len(),
+                    std::vector< double >(),
+                    aFontAttr,
+                    lang::Locale(),
+                    aLineColor );
+        aSeq[3] = primitive2d::Primitive2DReference( pText );
+        basegfx::B2DRange aTextRange = pText->getB2DRange( pProcessor->getViewInformation2D() );
+
+        // Draw the polygon around the flag
+        basegfx::B2DPolygon aFlagPolygon;
+        basegfx::B2DVector aFlagVector( 0, 1 );
+
+        double nFlagHeight = aTextRange.getMaxY() - nLineY + 60.0;
+
+        if ( IsFooterFrm( ) )
+        {
+            aFlagVector = - aFlagVector;
+            nFlagHeight = nLineY - aTextRange.getMinY() + 60.0;
+        }
+        basegfx::B2DPoint aStartPt( aTextRange.getMinX() - 60.0, nLineY );
+        aFlagPolygon.append( aStartPt );
+        basegfx::B2DPoint aNextPt = aStartPt + aFlagVector * ( nFlagHeight );
+        aFlagPolygon.append( aNextPt );
+        aNextPt += ( aTextRange.getWidth() + 120.0 ) * basegfx::B2DVector( 1, 0 );
+        aFlagPolygon.append( aNextPt );
+        aNextPt.setY( nLineY );
+        aFlagPolygon.append( aNextPt );
+
+        // Compute the flag background color primitive
+        aSeq[0] = primitive2d::Primitive2DReference(
+                new primitive2d::PolyPolygonColorPrimitive2D(
+                    basegfx::B2DPolyPolygon( aFlagPolygon ),
+                    aFillColor ) );
+
+        primitive2d::PolygonHairlinePrimitive2D * pBoxLine = new primitive2d::PolygonHairlinePrimitive2D(
+                aFlagPolygon, aLineColor );
+        aSeq[2] = primitive2d::Primitive2DReference( pBoxLine );
+
+
+        // Compute the range to invalidate
+        basegfx::B2DRange aDrawRange = pLine->getB2DRange( pProcessor->getViewInformation2D() );
+        aDrawRange.expand( aTextRange );
+        aDrawRange.expand( pBoxLine->getB2DRange( pProcessor->getViewInformation2D() ) );
+
+        Rectangle aPaintRect(
+                long( aDrawRange.getMinX() ), long( aDrawRange.getMinY() ),
+                long( aDrawRange.getMaxX() ), long( aDrawRange.getMaxY() ) );
+
+        pGlobalShell->InvalidateWindows( aPaintRect );
+
+        pProcessor->process( aSeq );
+        delete pProcessor;
+    }
+    SwLayoutFrm::Paint( rRect, pPrintData );
+}
+
 /** FlyFrm::IsBackgroundTransparent - for feature #99657#
 
     OD 12.08.2002
@@ -4624,7 +4756,7 @@ const SwFrm* lcl_GetCellFrmForBorderAttrs( const SwFrm*         _pCellFrm,
     return pRet;
 }
 
-void SwFrm::ProcessPrimitives( const drawinglayer::primitive2d::Primitive2DSequence& rSequence ) const
+processor2d::BaseProcessor2D * SwFrm::CreateProcessor2D( ) const
 {
     basegfx::B2DRange aViewRange;
 
@@ -4637,10 +4769,14 @@ void SwFrm::ProcessPrimitives( const drawinglayer::primitive2d::Primitive2DSeque
             0.0,
             uno::Sequence< beans::PropertyValue >() );
 
-    drawinglayer::processor2d::BaseProcessor2D * pProcessor2D =
-            sdr::contact::createBaseProcessor2DFromOutputDevice(
+    return  sdr::contact::createBaseProcessor2DFromOutputDevice(
                     *getRootFrm()->GetCurrShell()->GetOut(),
                     aNewViewInfos );
+}
+
+void SwFrm::ProcessPrimitives( const drawinglayer::primitive2d::Primitive2DSequence& rSequence ) const
+{
+    processor2d::BaseProcessor2D * pProcessor2D = CreateProcessor2D();
 
     if ( pProcessor2D )
     {
diff --git a/sw/source/ui/app/app.src b/sw/source/ui/app/app.src
index 6771554..dcbbd41 100644
--- a/sw/source/ui/app/app.src
+++ b/sw/source/ui/app/app.src
@@ -410,6 +410,16 @@ String STR_EMPTYPAGE
     Text [ en-US ] = "blank page" ;
 };
 
+String STR_HEADER
+{
+    Text [ en-US ] = "Header: " ;
+};
+
+String STR_FOOTER
+{
+    Text [ en-US ] = "Footer: " ;
+};
+
 QueryBox MSG_CLPBRD_CLEAR
 {
     BUTTONS = WB_YES_NO ;
commit e5b47c184964060cb300a6483ae26ff0d5bfc41c
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Wed Jun 29 11:07:25 2011 +0200

    n#676858: added new menu entry for headers/footers edit mode

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index a97a48d..501c721 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -215,6 +215,7 @@ included in c-context files, so c++ style stuff will cause problems.
 #define FN_SELECT_INDEX 			 (FN_EDIT + 85)  /**/
 #define FN_UP						 (FN_EDIT + 86)  /**/
 
+#define FN_EDIT_HEADER_FOOTER        (FN_EDIT + 95) /* Toggle headers/footers edition*/
 #define FN_SELECT_PARA				 (FN_EDIT + 97) /* select paragraph*/
 
 #define FN_SELECT_CONTENT			 (FN_EDIT + 99) /* Navigator - Content Type */
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 780e1d8..3dc677e 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -190,6 +190,7 @@ 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
 
@@ -850,6 +851,8 @@ public:
     String GetCrsrDescr() const;
 
     SwRect GetRectOfCurrentChar();
+
+    virtual void ToggleHeaderFooterEdit( );
 };
 
 // Cursor Inlines:
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 98e6fba..322da74 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -564,7 +564,7 @@ public:
     const SwPostItMgr* GetPostItMgr() const { return (const_cast<ViewShell*>(this))->GetPostItMgr(); }
     SwPostItMgr* GetPostItMgr();
 
-    void ToggleHeaderFooterEdit( );
+    virtual void ToggleHeaderFooterEdit( );
     sal_Bool IsHeaderFooterEdit( ) const { return bHeaderFooterEdit; }
 };
 
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index 584e1fa..7fdd27d 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -373,6 +373,12 @@ interface BaseText
         StateMethod = GetState;
         DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR";
     ]
+    FN_EDIT_HEADER_FOOTER
+    [
+        ExecMethod = Execute ;
+        StateMethod = GetState;
+        DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR";
+    ]
     FN_TABLE_UNSET_READ_ONLY // status(final|play)
     [
         ExecMethod = Execute ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 36c45e4..152b3fd 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -10417,3 +10417,30 @@ SfxVoidItem NavigateForward FN_NAVIGATION_FORWARD
     ToolBoxConfig = TRUE,
     GroupId = GID_NAVIGATION;
 ]
+
+//--------------------------------------------------------------------------
+SfxVoidItem EditHeaderFooter FN_EDIT_HEADER_FOOTER
+[
+    /* flags: */
+    AutoUpdate = FALSE,
+    Cachable = Cachable,
+    FastCall = FALSE,
+    HasCoreId = FALSE,
+    HasDialog = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = TRUE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Asynchron;
+
+    Readonly = FALSE,
+
+    /* config: */
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = TRUE,
+    GroupId = GID_EDIT;
+]
+
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index d55c44d..33469f9 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2540,7 +2540,7 @@ void SwCrsrShell::ParkCrsr( const SwNodeIndex &rIdx )
 
 SwCrsrShell::SwCrsrShell( SwCrsrShell& rShell, Window *pInitWin )
     : ViewShell( rShell, pInitWin ),
-    SwModify( 0 ), pCrsrStk( 0 ), pBlockCrsr( 0 ), pTblCrsr( 0 ),
+    SwModify( 0 ), pCrsrStk( 0 ), pCrsrBack( 0 ), pBlockCrsr( 0 ), pTblCrsr( 0 ),
     pBoxIdx( 0 ), pBoxPtr( 0 ), nCrsrMove( 0 ), nBasicActionCnt( 0 ),
     eMvState( MV_NONE ),
     sMarkedListId(),
@@ -2568,7 +2568,7 @@ SwCrsrShell::SwCrsrShell( SwCrsrShell& rShell, Window *pInitWin )
 SwCrsrShell::SwCrsrShell( SwDoc& rDoc, Window *pInitWin,
                             const SwViewOption *pInitOpt )
     : ViewShell( rDoc, pInitWin, pInitOpt ),
-    SwModify( 0 ), pCrsrStk( 0 ), pBlockCrsr( 0 ), pTblCrsr( 0 ),
+    SwModify( 0 ), pCrsrStk( 0 ), pCrsrBack( 0 ), pBlockCrsr( 0 ), pTblCrsr( 0 ),
     pBoxIdx( 0 ), pBoxPtr( 0 ), nCrsrMove( 0 ), nBasicActionCnt( 0 ),
     eMvState( MV_NONE ), // state for crsr-travelling - GetCrsrOfst
     sMarkedListId(),
@@ -2630,6 +2630,9 @@ 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.
@@ -3441,4 +3444,46 @@ 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();
+        }
+
+        SetCrsrInHdFt();
+    }
+    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/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index a5bd4ea..82a40f5 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -2963,17 +2963,22 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
                 if ( pSh->Imp()->HasDrawView() )
                 {
                     // Loop over the drawing object to mark them as in or outside a group
-                    SdrObjList* pObjs = pSh->Imp()->GetPageView()->GetObjList();
-                    for ( sal_uInt32 i = 0; pObjs && i < pObjs->GetObjCount(); i++ )
+                    if ( !pGlobalShell->GetViewOptions()->IsPDFExport() &&
+                         !pGlobalShell->GetViewOptions()->IsPrinting() &&
+                         !pGlobalShell->IsPreView() )
                     {
-                        SdrObject* pDrawObj = pObjs->GetObj( i );
-                        const SwContact* pContact = ::GetUserCall( pDrawObj );
-                        const SwAnchoredObject* pObj = pContact->GetAnchoredObj( pDrawObj );
+                        SdrObjList* pObjs = pSh->Imp()->GetPageView()->GetObjList();
+                        for ( sal_uInt32 i = 0; pObjs && i < pObjs->GetObjCount(); i++ )
+                        {
+                            SdrObject* pDrawObj = pObjs->GetObj( i );
+                            const SwContact* pContact = ::GetUserCall( pDrawObj );
+                            const SwAnchoredObject* pObj = pContact->GetAnchoredObj( pDrawObj );
 
-                        bool bInHeaderFooter = pObj->GetAnchorFrm()->FindFooterOrHeader() != NULL;
-                        bool bHeaderFooterEdit = pSh->IsHeaderFooterEdit();
+                            bool bInHeaderFooter = pObj->GetAnchorFrm()->FindFooterOrHeader() != NULL;
+                            bool bHeaderFooterEdit = pSh->IsHeaderFooterEdit();
 
-                        pDrawObj->SetGhosted( bHeaderFooterEdit ^ bInHeaderFooter );
+                            pDrawObj->SetGhosted( bHeaderFooterEdit ^ bInHeaderFooter );
+                        }
                     }
 
                     pLines->LockLines( sal_True );
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index b49164d..9aafc0d 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -75,6 +75,7 @@
 #include <editeng/frmdiritem.hxx>
 // OD 2004-05-24 #i28701#
 #include <sortedobjs.hxx>
+#include <viewopt.hxx>
 
 
 using namespace ::com::sun::star;
@@ -132,14 +133,19 @@ void SwFrm::RegisterToFormat( SwFmt& rFmt )
 
 sal_uInt64 SwFrm::SetHeaderFooterEditMask( OutputDevice* pOut ) const
 {
-    ViewShell* pShell = getRootFrm()->GetCurrShell();
-    bool bInHdrFtr = FindFooterOrHeader( ) != NULL;
-    bool bEditHdrFtr = pShell->IsHeaderFooterEdit();
     sal_uInt64 nOldDrawMode = pOut->GetDrawMode();
-    if ( ( bInHdrFtr && !bEditHdrFtr ) || ( !bInHdrFtr && bEditHdrFtr ) )
-        pOut->SetDrawMode( DRAWMODE_GHOSTEDLINE | DRAWMODE_GHOSTEDFILL |
-                DRAWMODE_GHOSTEDTEXT | DRAWMODE_GHOSTEDBITMAP |
-                DRAWMODE_GHOSTEDGRADIENT );
+    ViewShell* pShell = getRootFrm()->GetCurrShell();
+    if ( !pShell->IsPreView() &&
+         !pShell->GetViewOptions()->IsPDFExport() &&
+         !pShell->GetViewOptions()->IsPrinting() )
+    {
+        bool bInHdrFtr = FindFooterOrHeader( ) != NULL;
+        bool bEditHdrFtr = pShell->IsHeaderFooterEdit();
+        if ( ( bInHdrFtr && !bEditHdrFtr ) || ( !bInHdrFtr && bEditHdrFtr ) )
+            pOut->SetDrawMode( DRAWMODE_GHOSTEDLINE | DRAWMODE_GHOSTEDFILL |
+                    DRAWMODE_GHOSTEDTEXT | DRAWMODE_GHOSTEDBITMAP |
+                    DRAWMODE_GHOSTEDGRADIENT );
+    }
 
     return nOldDrawMode;
 }
diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx
index 3ad74b1..016037a 100644
--- a/sw/source/ui/shells/textsh1.cxx
+++ b/sw/source/ui/shells/textsh1.cxx
@@ -819,6 +819,9 @@ void SwTextShell::Execute(SfxRequest &rReq)
             }
         }
         break;
+        case FN_EDIT_HEADER_FOOTER:
+            rWrtSh.ToggleHeaderFooterEdit();
+        break;
         case SID_ATTR_BRUSH_CHAR :
         case SID_ATTR_CHAR_SCALEWIDTH :
         case SID_ATTR_CHAR_ROTATED :
@@ -1565,6 +1568,24 @@ void SwTextShell::GetState( SfxItemSet &rSet )
                 }
             }
             break;
+            case FN_EDIT_HEADER_FOOTER:
+            {
+                SfxBoolItem aBool( nWhich, rSh.IsHeaderFooterEdit() );
+                rSet.Put( aBool );
+
+                bool bHasHeaderFooter = false;
+                for ( sal_uInt16 i = 0; !bHasHeaderFooter && i < rSh.GetPageDescCnt(); i++ )
+                {
+                    const SwPageDesc& rPageDesc = rSh.GetPageDesc( i );
+                    bHasHeaderFooter = rPageDesc.GetMaster().GetHeader().IsActive() ||
+                                       rPageDesc.GetMaster().GetFooter().IsActive() ||
+                                       rPageDesc.GetLeft().GetHeader().IsActive() ||
+                                       rPageDesc.GetLeft().GetFooter().IsActive();
+                }
+                if ( !bHasHeaderFooter )
+                    rSet.DisableItem( nWhich );
+            }
+            break;
             case SID_TRANSLITERATE_HALFWIDTH:
             case SID_TRANSLITERATE_FULLWIDTH:
             case SID_TRANSLITERATE_HIRAGANA:
@@ -1698,7 +1719,7 @@ void SwTextShell::ChangeHeaderOrFooter(
         {
             if( (bShowWarning && !bOn && GetActiveView() && GetActiveView() == &GetView() &&
                 (bHeader && aDesc.GetMaster().GetHeader().IsActive())) ||
-                (!bHeader && aDesc.GetMaster().GetFooter().IsActive()))
+                (!bHeader && aDesc.GetMaster().GetFooter().IsActive()) )
             {
                 bShowWarning = sal_False;
                 //Actions have to be closed while the dialog is showing
@@ -1732,9 +1753,13 @@ void SwTextShell::ChangeHeaderOrFooter(
                 rSh.ChgPageDesc( nFrom, aDesc );
 
                 if( !bCrsrSet && bOn )
+                {
+                    if ( !rSh.IsHeaderFooterEdit() )
+                        rSh.ToggleHeaderFooterEdit();
                     bCrsrSet = rSh.SetCrsrInHdFt(
                             !rStyleName.Len() ? USHRT_MAX : nFrom,
                             bHeader );
+                }
             }
         }
     }
diff --git a/sw/uiconfig/sglobal/menubar/menubar.xml b/sw/uiconfig/sglobal/menubar/menubar.xml
index e643158..9cd6d3c 100755
--- a/sw/uiconfig/sglobal/menubar/menubar.xml
+++ b/sw/uiconfig/sglobal/menubar/menubar.xml
@@ -90,6 +90,7 @@
       <menu:menuitem menu:id=".uno:EditGlossary"/>
       <menu:menuseparator/>
       <menu:menuitem menu:id=".uno:ChangeDatabaseField"/>
+      <menu:menuitem menu:id=".uno:EditHeaderFooter"/>
       <menu:menuitem menu:id=".uno:FieldDialog"/>
       <menu:menuitem menu:id=".uno:EditFootnote"/>
       <menu:menuitem menu:id=".uno:IndexEntryDialog"/>
diff --git a/sw/uiconfig/swform/menubar/menubar.xml b/sw/uiconfig/swform/menubar/menubar.xml
index 7e5f14f..d5e073f 100755
--- a/sw/uiconfig/swform/menubar/menubar.xml
+++ b/sw/uiconfig/swform/menubar/menubar.xml
@@ -90,6 +90,7 @@
       <menu:menuitem menu:id=".uno:EditGlossary"/>
       <menu:menuseparator/>
       <menu:menuitem menu:id=".uno:ChangeDatabaseField"/>
+      <menu:menuitem menu:id=".uno:EditHeaderFooter"/>
       <menu:menuitem menu:id=".uno:FieldDialog"/>
       <menu:menuitem menu:id=".uno:EditFootnote"/>
       <menu:menuitem menu:id=".uno:IndexEntryDialog"/>
diff --git a/sw/uiconfig/swreport/menubar/menubar.xml b/sw/uiconfig/swreport/menubar/menubar.xml
index 7e5f14f..d5e073f 100755
--- a/sw/uiconfig/swreport/menubar/menubar.xml
+++ b/sw/uiconfig/swreport/menubar/menubar.xml
@@ -90,6 +90,7 @@
       <menu:menuitem menu:id=".uno:EditGlossary"/>
       <menu:menuseparator/>
       <menu:menuitem menu:id=".uno:ChangeDatabaseField"/>
+      <menu:menuitem menu:id=".uno:EditHeaderFooter"/>
       <menu:menuitem menu:id=".uno:FieldDialog"/>
       <menu:menuitem menu:id=".uno:EditFootnote"/>
       <menu:menuitem menu:id=".uno:IndexEntryDialog"/>
diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml
index 02107d0..e7b7d7f 100755
--- a/sw/uiconfig/swriter/menubar/menubar.xml
+++ b/sw/uiconfig/swriter/menubar/menubar.xml
@@ -93,6 +93,7 @@
       <menu:menuitem menu:id=".uno:EditGlossary"/>
       <menu:menuseparator/>
       <menu:menuitem menu:id=".uno:ChangeDatabaseField"/>
+      <menu:menuitem menu:id=".uno:EditHeaderFooter"/>
       <menu:menuitem menu:id=".uno:FieldDialog"/>
       <menu:menuitem menu:id=".uno:EditFootnote"/>
       <menu:menuitem menu:id=".uno:IndexEntryDialog"/>
diff --git a/sw/uiconfig/swxform/menubar/menubar.xml b/sw/uiconfig/swxform/menubar/menubar.xml
index ff139ef..584955e 100755
--- a/sw/uiconfig/swxform/menubar/menubar.xml
+++ b/sw/uiconfig/swxform/menubar/menubar.xml
@@ -91,6 +91,7 @@
       <menu:menuitem menu:id=".uno:EditGlossary"/>
       <menu:menuseparator/>
       <menu:menuitem menu:id=".uno:ChangeDatabaseField"/>
+      <menu:menuitem menu:id=".uno:EditHeaderFooter"/>
       <menu:menuitem menu:id=".uno:FieldDialog"/>
       <menu:menuitem menu:id=".uno:EditFootnote"/>
       <menu:menuitem menu:id=".uno:IndexEntryDialog"/>
commit b16fc5540860e5260ef27dea99b7b289cdc00364
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Wed Jun 29 10:58:36 2011 +0200

    n#676858: ghost uneditable drawing objects

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 07a4369..a5bd4ea 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -86,6 +86,8 @@
 #include <svx/svdogrp.hxx>
 #include <sortedobjs.hxx>
 #include <EnhancedPDFExportHelper.hxx>
+#include <fesh.hxx>
+#include <svx/svdpage.hxx>
 // <--
 // --> OD #i76669#
 #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
@@ -2960,6 +2962,20 @@ SwRootFrm::Paint(SwRect const& rRect, SwPrintData const*const pPrintData) const
 
                 if ( pSh->Imp()->HasDrawView() )
                 {
+                    // Loop over the drawing object to mark them as in or outside a group
+                    SdrObjList* pObjs = pSh->Imp()->GetPageView()->GetObjList();
+                    for ( sal_uInt32 i = 0; pObjs && i < pObjs->GetObjCount(); i++ )
+                    {
+                        SdrObject* pDrawObj = pObjs->GetObj( i );
+                        const SwContact* pContact = ::GetUserCall( pDrawObj );
+                        const SwAnchoredObject* pObj = pContact->GetAnchoredObj( pDrawObj );
+
+                        bool bInHeaderFooter = pObj->GetAnchorFrm()->FindFooterOrHeader() != NULL;
+                        bool bHeaderFooterEdit = pSh->IsHeaderFooterEdit();
+
+                        pDrawObj->SetGhosted( bHeaderFooterEdit ^ bInHeaderFooter );
+                    }
+
                     pLines->LockLines( sal_True );
                     const IDocumentDrawModelAccess* pIDDMA = pSh->getIDocumentDrawModelAccess();
                     pSh->Imp()->PaintLayer( pIDDMA->GetHellId(),
commit 490520dac79c3c07a6051ac1ba8e1cb526b01a5d
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Wed Jun 29 10:47:12 2011 +0200

    n#676858: header, footer edition mode: updated paint methods

diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 59f7ecb..98e6fba 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -564,7 +564,7 @@ public:
     const SwPostItMgr* GetPostItMgr() const { return (const_cast<ViewShell*>(this))->GetPostItMgr(); }
     SwPostItMgr* GetPostItMgr();
 
-    void ToggleHeaderFooterEdit( ) { bHeaderFooterEdit = !bHeaderFooterEdit; }
+    void ToggleHeaderFooterEdit( );
     sal_Bool IsHeaderFooterEdit( ) const { return bHeaderFooterEdit; }
 };
 
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 41023eb..eaed5a5 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -248,6 +248,10 @@ void SwNoTxtFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
         return;
 
     const ViewShell* pSh = getRootFrm()->GetCurrShell();
+    OutputDevice *pOut = pSh->GetOut();
+
+    sal_uInt64 nOldDrawMode = SetHeaderFooterEditMask( pOut );
+
     if( !pSh->GetViewOptions()->IsGraphic() )
     {
         StopAnimation();
@@ -262,6 +266,7 @@ void SwNoTxtFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
                 aTxt = FindFlyFrm()->GetFmt()->GetName();
             lcl_PaintReplacement( Frm(), aTxt, *pSh, this, sal_False );
         }
+        pOut->SetDrawMode( nOldDrawMode );
         return;
     }
 
@@ -272,7 +277,6 @@ void SwNoTxtFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
 
     SfxProgress::EnterLock(); //Keine Progress-Reschedules im Paint (SwapIn)
 
-    OutputDevice *pOut = pSh->GetOut();
     pOut->Push();
     sal_Bool bClip = sal_True;
     PolyPolygon aPoly;
@@ -329,6 +333,7 @@ void SwNoTxtFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
         pGrfNd->SetFrameInPaint( sal_False );
 
     pOut->Pop();
+    pOut->SetDrawMode( nOldDrawMode );
     SfxProgress::LeaveLock();
 }
 
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index 664f28b..fe422c9 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -909,6 +909,8 @@ public:
     virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer);
     void dumpChildrenAsXml(xmlTextWriterPtr writer);
     bool IsCollapse() const;
+
+    sal_uInt64 SetHeaderFooterEditMask( OutputDevice* pOut ) const;
 };
 
 inline sal_Bool	SwFrm::IsInDocBody() const
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 246da89..07a4369 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3486,6 +3486,8 @@ void SwFlyFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
     aRect._Intersection( Frm() );
 
     OutputDevice* pOut = pGlobalShell->GetOut();
+    sal_uInt64 nOldDrawMode = SetHeaderFooterEditMask( pOut );
+
     pOut->Push( PUSH_CLIPREGION );
     pOut->SetClipRegion();
     const SwPageFrm* pPage = FindPageFrm();
@@ -3693,6 +3695,8 @@ void SwFlyFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
 
     pOut->Pop();
 
+    pOut->SetDrawMode( nOldDrawMode );
+
     if ( pProgress && pNoTxt )
         pProgress->Reschedule();
 }
@@ -3704,6 +3708,7 @@ void SwFlyFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
 
 void SwTabFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
 {
+    sal_uInt64 nOldDrawMode = SetHeaderFooterEditMask( pGlobalShell->GetOut() );
     if ( pGlobalShell->GetViewOptions()->IsTable() )
     {
         // #i29550#
@@ -3740,6 +3745,8 @@ void SwTabFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
                 DrawRect( pGlobalShell->GetOut(), aTabOutRect, COL_LIGHTGRAY );
     }
     ((SwTabFrm*)this)->ResetComplete();
+
+    pGlobalShell->GetOut()->SetDrawMode( nOldDrawMode );
 }
 
 /*************************************************************************
@@ -5779,6 +5786,9 @@ void SwFrm::PaintBackground( const SwRect &rRect, const SwPageFrm *pPage,
             aRect.Intersection( rRect );
 
             OutputDevice *pOut = pSh->GetOut();
+            sal_uInt64 nOldDrawMode = pOut->GetDrawMode();
+            if ( !IsPageFrm() && !IsRootFrm() )
+                SetHeaderFooterEditMask( pOut );
 
             if ( aRect.HasArea() )
             {
@@ -5817,6 +5827,7 @@ void SwFrm::PaintBackground( const SwRect &rRect, const SwPageFrm *pPage,
                 if( pCol )
                     delete pNewItem;
             }
+            pOut->SetDrawMode( nOldDrawMode );
         }
         else
             bLowMode = bLowerMode ? sal_True : sal_False;
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 346dea4..b49164d 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -130,6 +130,20 @@ void SwFrm::RegisterToFormat( SwFmt& rFmt )
     rFmt.Add( this );
 }
 
+sal_uInt64 SwFrm::SetHeaderFooterEditMask( OutputDevice* pOut ) const
+{
+    ViewShell* pShell = getRootFrm()->GetCurrShell();
+    bool bInHdrFtr = FindFooterOrHeader( ) != NULL;
+    bool bEditHdrFtr = pShell->IsHeaderFooterEdit();
+    sal_uInt64 nOldDrawMode = pOut->GetDrawMode();
+    if ( ( bInHdrFtr && !bEditHdrFtr ) || ( !bInHdrFtr && bEditHdrFtr ) )
+        pOut->SetDrawMode( DRAWMODE_GHOSTEDLINE | DRAWMODE_GHOSTEDFILL |
+                DRAWMODE_GHOSTEDTEXT | DRAWMODE_GHOSTEDBITMAP |
+                DRAWMODE_GHOSTEDGRADIENT );
+
+    return nOldDrawMode;
+}
+
 void SwFrm::CheckDir( sal_uInt16 nDir, sal_Bool bVert, sal_Bool bOnlyBiDi, sal_Bool bBrowse )
 {
     if( FRMDIR_ENVIRONMENT == nDir || ( bVert && bOnlyBiDi ) )
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index b5c7732..42ef504 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -567,6 +567,7 @@ sal_Bool SwTxtFrm::PaintEmpty( const SwRect &rRect, sal_Bool bCheck ) const
                 // Don't show the paragraph mark for collapsed paragraphs, when they are hidden
                 if ( EmptyHeight( ) > 1 )
                 {
+                    sal_uInt64 nOldDrawMode = SetHeaderFooterEditMask( pSh->GetOut() );
                     const XubString aTmp( CH_PAR );
                     SwDrawTextInfo aDrawInf( pSh, *pSh->GetOut(), 0, aTmp, 0, 1 );
                     aDrawInf.SetLeft( rRect.Left() );
@@ -582,6 +583,7 @@ sal_Bool SwTxtFrm::PaintEmpty( const SwRect &rRect, sal_Bool bCheck ) const
                     aDrawInf.SetSnapToGrid( sal_False );
 
                     pFnt->_DrawText( aDrawInf );
+                    pSh->GetOut()->SetDrawMode( nOldDrawMode );
                 }
                 delete pClip;
             }
@@ -697,6 +699,8 @@ void SwTxtFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
         OutputDevice* pOut = aInf.GetOut();
         const sal_Bool bOnWin = pSh->GetWin() != 0;
 
+        sal_uInt64 nOldDrawMode = SetHeaderFooterEditMask( pOut );
+
         SwSaveClip aClip( bOnWin || IsUndersized() ? pOut : 0 );
 
         // Ausgabeschleife: Fuer jede Zeile ... (die noch zu sehen ist) ...
@@ -728,6 +732,8 @@ void SwTxtFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
         if( rRepaint.HasArea() )
             rRepaint.Clear();
 
+        pOut->SetDrawMode( nOldDrawMode );
+
         UNDO_SWAP( this )
         (SwRect&)rRect = aOldRect;
 
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index bf21e62..b24ab08 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -77,6 +77,7 @@
 #include "../../ui/inc/view.hxx"
 #include <PostItMgr.hxx>
 #include <vcl/virdev.hxx>
+#include <rootfrm.hxx>
 
 #include <vcl/svapp.hxx>
 
@@ -96,6 +97,12 @@ TYPEINIT0(ViewShell);
 
 using namespace ::com::sun::star;
 
+void ViewShell::ToggleHeaderFooterEdit( ) {
+    bHeaderFooterEdit = !bHeaderFooterEdit;
+    // Repaint everything to update the colors of the selected area
+    Paint( VisArea().SVRect() );
+}
+
 //////////////////////////////////////////////////////////////////////////////
 // #i72754# 2nd set of Pre/PostPaints
 // This time it uses the lock counter (mPrePostPaintRegions empty/non-empty) to allow only one activation
commit aa1f9071e550b300a8b8d2aaf17a74f2ad829eee
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Wed Jun 29 10:38:19 2011 +0200

    fdo#36496, n#676858: background images shouldn't be selected before text

diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index b70d11c..41c4ada 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -58,6 +58,7 @@
 #include <crstate.hxx>
 #include <frmtool.hxx>
 #include <ndtxt.hxx>
+#include <dcontact.hxx>
 // OD 2004-05-24 #i28701#
 #include <sortedobjs.hxx>
 
@@ -65,6 +66,44 @@
 #include <cfloat>
 #include <swselectionlist.hxx>
 
+namespace {
+    bool lcl_GetCrsrOfst_Objects( const SwPageFrm* pPageFrm, bool bSearchBackground,
+           SwPosition *pPos, Point& rPoint, SwCrsrMoveState* pCMS )
+    {
+        bool bRet = false;
+        Point aPoint( rPoint );
+        SwOrderIter aIter( pPageFrm );
+        aIter.Top();
+        while ( aIter() )
+        {
+            const SwVirtFlyDrawObj* pObj =
+                                static_cast<const SwVirtFlyDrawObj*>(aIter());
+            const SwAnchoredObject* pAnchoredObj = GetUserCall( aIter() )->GetAnchoredObj( aIter() );
+            const SwFmtSurround& rSurround = pAnchoredObj->GetFrmFmt().GetSurround();
+            bool bInBackground = ( rSurround.GetSurround() == SURROUND_THROUGHT );
+
+            bool bBackgroundMatches = ( bInBackground && bSearchBackground ) ||
+                                      ( !bInBackground && !bSearchBackground );
+
+            const SwFlyFrm* pFly = pObj ? pObj->GetFlyFrm() : 0;
+            if ( pFly && bBackgroundMatches &&
+                 ( ( pCMS ? pCMS->bSetInReadOnly : false ) ||
+                   !pFly->IsProtected() ) &&
+                 pFly->GetCrsrOfst( pPos, aPoint, pCMS ) )
+            {
+                bRet = true;
+                break;
+            }
+
+            if ( pCMS && pCMS->bStop )
+                return false;
+            aIter.Prev();
+        }
+        return bRet;
+    }
+}
+
+
 //Fuer SwFlyFrm::GetCrsrOfst
 class SwCrsrOszControl
 {
@@ -166,26 +205,7 @@ sal_Bool SwPageFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
     //hineinsetzen, dadurch sollten alle Aenderungen unmoeglich sein.
     if ( GetSortedObjs() )
     {
-        SwOrderIter aIter( this );
-        aIter.Top();
-        while ( aIter() )
-        {
-            const SwVirtFlyDrawObj* pObj =
-                                static_cast<const SwVirtFlyDrawObj*>(aIter());
-            const SwFlyFrm* pFly = pObj ? pObj->GetFlyFrm() : 0;
-            if ( pFly &&
-                 ( ( pCMS ? pCMS->bSetInReadOnly : sal_False ) ||
-                   !pFly->IsProtected() ) &&
-                 pFly->GetCrsrOfst( pPos, aPoint, pCMS ) )
-            {
-                bRet = sal_True;
-                break;
-            }
-
-            if ( pCMS && pCMS->bStop )
-                return sal_False;
-            aIter.Prev();
-        }
+        bRet = lcl_GetCrsrOfst_Objects( this, false, pPos, rPoint, pCMS );
     }
 
     if ( !bRet )
@@ -222,6 +242,12 @@ sal_Bool SwPageFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
         }
     }
 
+    // Check objects in the background if nothing else matched
+    if ( !bRet && GetSortedObjs() )
+    {
+        bRet = lcl_GetCrsrOfst_Objects( this, true, pPos, rPoint, pCMS );
+    }
+
     if ( bRet )
         rPoint = aPoint;
 
commit 251f3e64a2c413d06dd8fe13a0d51e4e57dd87d0
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Wed Jun 29 10:31:24 2011 +0200

    n#676858: implement header / footer edition mode
    
    Prevent header / footer editing when editing the body and vice-versa.
    this commit simply adds the basic edition toggling using double-clicks.

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index b24d297..780e1d8 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -495,6 +495,8 @@ public:
     void SetReadOnlyAvailable( sal_Bool bFlag );
     sal_Bool IsOverReadOnlyPos( const Point& rPt ) const;
 
+    sal_Bool IsOverHeaderFooterPos( const Point& rPt ) const;
+
     // Methods for aFlyMacroLnk.
     void        SetFlyMacroLnk( const Link& rLnk ) { aFlyMacroLnk = rLnk; }
     const Link& GetFlyMacroLnk() const             { return aFlyMacroLnk; }
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index e5ea534..59f7ecb 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -156,6 +156,7 @@ class SW_DLLPUBLIC ViewShell : public Ring
     sal_Bool  bEnableSmooth    :1;  // Disable SmoothScroll, e.g. for drag
                                     // of scrollbars.
     sal_Bool  bEndActionByVirDev:1; // Paints from EndAction always via virtual device
+    sal_Bool  bHeaderFooterEdit;
                                     // (e.g. when browsing).
 
     // boolean, indicating that class in in constructor.
@@ -562,6 +563,9 @@ public:
 
     const SwPostItMgr* GetPostItMgr() const { return (const_cast<ViewShell*>(this))->GetPostItMgr(); }
     SwPostItMgr* GetPostItMgr();
+
+    void ToggleHeaderFooterEdit( ) { bHeaderFooterEdit = !bHeaderFooterEdit; }
+    sal_Bool IsHeaderFooterEdit( ) const { return bHeaderFooterEdit; }
 };
 
 //---- class CurrShell manages global ShellPointer -------------------
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index fc2f5a3..d55c44d 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2326,6 +2326,15 @@ sal_Bool SwCrsrShell::IsOverReadOnlyPos( const Point& rPt ) const
     return aPam.HasReadonlySel( GetViewOptions()->IsFormView() );
 }
 
+sal_Bool SwCrsrShell::IsOverHeaderFooterPos( const Point& rPt ) const
+{
+    Point aPt( rPt );
+    SwPaM aPam( *pCurCrsr->GetPoint() );
+    GetLayout()->GetCrsrOfst( aPam.GetPoint(), aPt );
+
+    return GetDoc()->IsInHeaderFooter( aPam.GetPoint()->nNode );
+}
+
 
     // returne die Anzahl der Cursor im Ring (Flag besagt ob man nur
     // aufgepspannte haben will - sprich etwas selektiert ist (Basic))
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index e45d3c5..1b38068 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -1194,6 +1194,16 @@ sal_Bool SwFEShell::ShouldObjectBeSelected(const Point& rPt)
                 }
             }
 
+            // Don't select header / footer objects in body edition and vice-versa
+            SwContact* pContact = static_cast<SwContact*>(pObj->GetUserCall());
+            const SwPosition& rPos = pContact->GetCntntAnchor();
+            bool bInHdrFtr = GetDoc()->IsInHeaderFooter( rPos.nNode );
+            if ( ( IsHeaderFooterEdit() && !bInHdrFtr ) ||
+                 ( !IsHeaderFooterEdit() && bInHdrFtr ) )
+            {
+                bRet = sal_False;
+            }
+
             if ( bRet )
             {
                 const SdrPage* pPage = pIDDMA->GetDrawModel()->GetPage(0);
diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx
index d7835a2..736c278 100644
--- a/sw/source/core/view/vnew.cxx
+++ b/sw/source/core/view/vnew.cxx
@@ -153,6 +153,7 @@ ViewShell::ViewShell( SwDoc& rDocument, Window *pWindow,
     mpTmpRef( 0 ),
     pOpt( 0 ),
     pAccOptions( new SwAccessibilityOptions ),
+    bHeaderFooterEdit( sal_False ),
     mpTargetPaintWindow(0),
     mpBufferedOut(0),
     pDoc( &rDocument ),
@@ -219,6 +220,7 @@ ViewShell::ViewShell( ViewShell& rShell, Window *pWindow,
     mpTmpRef( 0 ),
     pOpt( 0 ),
     pAccOptions( new SwAccessibilityOptions ),
+    bHeaderFooterEdit( sal_False ),
     mpTargetPaintWindow(0),
     mpBufferedOut(0),
     pDoc( rShell.GetDoc() ),
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 53a9238..c5899bf 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -2596,6 +2596,16 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
 
     const Point aDocPos( PixelToLogic( rMEvt.GetPosPixel() ) );
 
+    sal_Bool bOverHdrFtr = rSh.IsOverHeaderFooterPos( aDocPos );
+    if ( ( rSh.IsHeaderFooterEdit( ) && !bOverHdrFtr ) ||
+         ( !rSh.IsHeaderFooterEdit() && bOverHdrFtr ) )
+    {
+        if ( rMEvt.GetButtons() == MOUSE_LEFT && rMEvt.GetClicks( ) == 2 )
+            rSh.ToggleHeaderFooterEdit();
+        else
+            return;
+    }
+
     if ( IsChainMode() )
     {
         SetChainMode( sal_False );
diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx
index 07efed3..d73c9f3 100755
--- a/sw/source/ui/inc/view.hxx
+++ b/sw/source/ui/inc/view.hxx
@@ -283,8 +283,7 @@ class SW_DLLPUBLIC SwView: public SfxViewShell
                     bInDtor : 1, //detect destructor to prevent creating of sub shells while closing
                     bOldShellWasPagePreView : 1,
                     bIsPreviewDoubleClick : 1, // #i114045#
-                    bMakeSelectionVisible : 1 // transport the bookmark selection
-                    ;
+                    bMakeSelectionVisible : 1; // transport the bookmark selection
 
     // methods for searching
     // set search context


More information about the Libreoffice-commits mailing list