[Libreoffice-commits] .: 5 commits - sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Nov 23 11:25:46 PST 2012


 sw/source/core/crsr/crsrsh.cxx    |   34 ---
 sw/source/core/doc/notxtfrm.cxx   |    2 
 sw/source/core/inc/cellfrm.hxx    |    2 
 sw/source/core/inc/flyfrm.hxx     |    2 
 sw/source/core/inc/frame.hxx      |    2 
 sw/source/core/inc/layfrm.hxx     |    2 
 sw/source/core/inc/notxtfrm.hxx   |    2 
 sw/source/core/inc/pagefrm.hxx    |    2 
 sw/source/core/inc/rootfrm.hxx    |    2 
 sw/source/core/inc/txtfrm.hxx     |    2 
 sw/source/core/layout/trvlfrm.cxx |   96 ++++++----
 sw/source/core/layout/unusedf.cxx |    2 
 sw/source/core/text/frmcrsr.cxx   |    2 
 sw/source/core/text/xmldump.cxx   |    1 
 sw/source/ui/docvw/edtwin.cxx     |  360 ++++++++++++++++++++++----------------
 sw/source/ui/inc/edtwin.hxx       |    2 
 sw/source/ui/shells/txtcrsr.cxx   |   19 ++
 sw/source/ui/uiview/view.cxx      |   22 ++
 18 files changed, 330 insertions(+), 226 deletions(-)

New commits:
commit 0657fcc8c918aac0e99b5c2406328c175be606e7
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Fri Nov 23 17:56:33 2012 +0100

    Toggle Header/Footer edit when loading if needed
    
    Change-Id: Ia8b469ccbb2d41c70429c725708bc853edcdd537

diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx
index 2b01ba5..de4c07b 100644
--- a/sw/source/ui/uiview/view.cxx
+++ b/sw/source/ui/uiview/view.cxx
@@ -1388,6 +1388,28 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >
                     if(bOldShellWasPagePreView|| bIsOwnDocument)
                     {
                         pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
+
+                        // Update the shell to toggle Header/Footer edit if needed
+                        sal_Bool bInHeader = sal_True;
+                        if ( pWrtShell->IsInHeaderFooter( &bInHeader ) )
+                        {
+                            if ( !bInHeader )
+                            {
+                                pWrtShell->SetShowHeaderFooterSeparator( Footer, true );
+                                pWrtShell->SetShowHeaderFooterSeparator( Header, false );
+                            }
+                            else
+                            {
+                                pWrtShell->SetShowHeaderFooterSeparator( Header, true );
+                                pWrtShell->SetShowHeaderFooterSeparator( Footer, false );
+                            }
+
+                            // Force repaint
+                            pWrtShell->GetWin()->Invalidate();
+                        }
+                        if ( pWrtShell->IsInHeaderFooter() != pWrtShell->IsHeaderFooterEdit() )
+                            pWrtShell->ToggleHeaderFooterEdit();
+
                         if( bSelectObj )
                         {
                             pWrtShell->SelectObj( aCrsrPos );
commit e8fbe97900f13305b17015d9044993bde4adab36
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Fri Nov 23 17:51:16 2012 +0100

    fdo#52182: Fixed click in frames located in header/footer
    
    Using a distance to click to select the best object to select between
    normal text and background object.
    
    Change-Id: Ib5b53161c7af2c16f4df379382f2e53fc6d8092b

diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 423dc35..914e189 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -600,7 +600,7 @@ sal_Bool SwNoTxtFrm::GetCharRect( SwRect &rRect, const SwPosition& rPos,
 
 
 sal_Bool SwNoTxtFrm::GetCrsrOfst(SwPosition* pPos, Point& ,
-                             SwCrsrMoveState* ) const
+                             SwCrsrMoveState*, bool ) const
 {
     SwCntntNode* pCNd = (SwCntntNode*)GetNode();
     pPos->nNode = *pCNd;
diff --git a/sw/source/core/inc/cellfrm.hxx b/sw/source/core/inc/cellfrm.hxx
index 98a9713..050723c 100644
--- a/sw/source/core/inc/cellfrm.hxx
+++ b/sw/source/core/inc/cellfrm.hxx
@@ -39,7 +39,7 @@ public:
     SwCellFrm( const SwTableBox &, SwFrm*, bool bInsertContent = true );
     ~SwCellFrm();
 
-    virtual sal_Bool GetCrsrOfst( SwPosition *, Point&, SwCrsrMoveState* = 0 ) const;
+    virtual sal_Bool GetCrsrOfst( SwPosition *, Point&, SwCrsrMoveState* = 0, bool bTestBackground = false ) const;
     virtual void Paint( SwRect const&,
                         SwPrintData const*const pPrintData = NULL ) const;
     virtual void CheckDirection( sal_Bool bVert );
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index d3f62a6..abfd220 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -167,7 +167,7 @@ public:
                         SwPrintData const*const pPrintData = NULL ) const;
     virtual Size ChgSize( const Size& aNewSize );
     virtual sal_Bool GetCrsrOfst( SwPosition *, Point&,
-                              SwCrsrMoveState* = 0 ) const;
+                              SwCrsrMoveState* = 0, bool bTestBackground = false ) const;
 
     virtual void  CheckDirection( sal_Bool bVert );
     virtual void Cut();
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index b6db9cf..ebbde55 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -785,7 +785,7 @@ public:
     virtual bool    FillSelection( SwSelectionList& rList, const SwRect& rRect ) const;
 
     virtual sal_Bool    GetCrsrOfst( SwPosition *, Point&,
-                                 SwCrsrMoveState* = 0 ) const;
+                                 SwCrsrMoveState* = 0, bool bTestBackground = false ) const;
     virtual sal_Bool    GetCharRect( SwRect &, const SwPosition&,
                                  SwCrsrMoveState* = 0 ) const;
     virtual void Paint( SwRect const&,
diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx
index 14c03b0..829c7fc 100644
--- a/sw/source/core/inc/layfrm.hxx
+++ b/sw/source/core/inc/layfrm.hxx
@@ -92,7 +92,7 @@ public:
     virtual bool    FillSelection( SwSelectionList& rList, const SwRect& rRect ) const;
 
     virtual sal_Bool  GetCrsrOfst( SwPosition *, Point&,
-                               SwCrsrMoveState* = 0 ) const;
+                               SwCrsrMoveState* = 0, bool bTestBackground = false ) const;
 
     virtual void Cut();
     virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
diff --git a/sw/source/core/inc/notxtfrm.hxx b/sw/source/core/inc/notxtfrm.hxx
index cc680df..bce88c4 100644
--- a/sw/source/core/inc/notxtfrm.hxx
+++ b/sw/source/core/inc/notxtfrm.hxx
@@ -60,7 +60,7 @@ public:
     virtual sal_Bool GetCharRect( SwRect &, const SwPosition&,
                               SwCrsrMoveState* = 0) const;
     sal_Bool GetCrsrOfst(SwPosition* pPos, Point& aPoint,
-                     SwCrsrMoveState* = 0) const;
+                     SwCrsrMoveState* = 0, bool bTestBackground = false) const;
 
     const Size &GetGrfSize() const  { return GetSize(); }
     void GetGrfArea( SwRect &rRect, SwRect * = 0, bool bMirror = true ) const;
diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index 271e161..fc4d93c 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -180,7 +180,7 @@ public:
     void PlaceFly( SwFlyFrm* pFly, SwFlyFrmFmt* pFmt );
 
     virtual sal_Bool GetCrsrOfst( SwPosition *, Point&,
-                              SwCrsrMoveState* = 0 ) const;
+                              SwCrsrMoveState* = 0, bool bTestBackground = false ) const;
         // erfrage vom Client Informationen
     virtual bool GetInfo( SfxPoolItem& ) const;
 
diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index fafdb0c..02014dc 100644
--- a/sw/source/core/inc/rootfrm.hxx
+++ b/sw/source/core/inc/rootfrm.hxx
@@ -195,7 +195,7 @@ public:
           void     SetDrawPage( SdrPage* pNew ){ pDrawPage = pNew; }
 
     virtual sal_Bool  GetCrsrOfst( SwPosition *, Point&,
-                               SwCrsrMoveState* = 0 ) const;
+                               SwCrsrMoveState* = 0, bool bTestBackground = false ) const;
 
     virtual void Paint( SwRect const&,
                         SwPrintData const*const pPrintData = NULL ) const;
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index 3942759..cc1ceaf 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -277,7 +277,7 @@ public:
     //naechsten ist. Wenn der SPoint ausserhalb der SSize liegt,
     //liefert die Funktion sal_False, sal_True sonst.
     virtual sal_Bool GetCrsrOfst( SwPosition *, Point&,
-                                  SwCrsrMoveState* = 0) const;
+                                  SwCrsrMoveState* = 0, bool bTestBackground = false ) const;
 
     // GetKeyCrsrOfst sorgt dafuer, dass der Frame nicht gewechselt wird
     // (z.B. Wechsel in den zeichengebundenen Frame).
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 60660f1..856845f 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -29,6 +29,7 @@
 #include <hintids.hxx>
 #include <hints.hxx>
 #include <tools/bigint.hxx>
+#include <tools/line.hxx>
 #include <editeng/opaqitem.hxx>
 #include <editeng/protitem.hxx>
 #include <vcl/settings.hxx>
@@ -63,9 +64,11 @@
 #include <cfloat>
 #include <swselectionlist.hxx>
 
+#include <basegfx/numeric/ftools.hxx>
+
 namespace {
     bool lcl_GetCrsrOfst_Objects( const SwPageFrm* pPageFrm, bool bSearchBackground,
-           SwPosition *pPos, Point& rPoint, SwCrsrMoveState* pCMS, long& rSurface )
+           SwPosition *pPos, Point& rPoint, SwCrsrMoveState* pCMS  )
     {
         bool bRet = false;
         Point aPoint( rPoint );
@@ -89,7 +92,6 @@ namespace {
                    !pFly->IsProtected() ) &&
                  pFly->GetCrsrOfst( pPos, aPoint, pCMS ) )
             {
-                rSurface = pFly->Frm().Width() * pFly->Frm().Height();
                 bRet = true;
                 break;
             }
@@ -101,18 +103,19 @@ namespace {
         return bRet;
     }
 
-    long lcl_GetSurface( SwPosition* pPos )
+    double lcl_getDistance( const SwRect& rRect, const Point& rPoint )
     {
-        SwRect aArea;
-
-        SwNode& rNode = pPos->nNode.GetNode();
-
-        if ( rNode.IsCntntNode() )
-            aArea = rNode.GetCntntNode()->FindLayoutRect();
+        double nDist = 0.0;
 
-        // FIXME Handle the other kinds of nodes?
+        // If the point is inside the rectangle, then distance is 0
+        // Otherwise, compute the distance to the center of the rectangle.
+        if ( !rRect.IsInside( rPoint ) )
+        {
+            Line aLine( rPoint, rRect.Center( ) );
+            nDist = aLine.GetLength( );
+        }
 
-        return aArea.Height() * aArea.Width();
+        return nDist;
     }
 }
 
@@ -164,7 +167,7 @@ static SwCrsrOszControl aOszCtrl = { 0, 0, 0 };
 |*
 |*************************************************************************/
 sal_Bool SwLayoutFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
-                               SwCrsrMoveState* pCMS ) const
+                               SwCrsrMoveState* pCMS, bool ) const
 {
     sal_Bool bRet = sal_False;
     const SwFrm *pFrm = Lower();
@@ -199,7 +202,7 @@ sal_Bool SwLayoutFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
 |*************************************************************************/
 
 sal_Bool SwPageFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
-                             SwCrsrMoveState* pCMS ) const
+                             SwCrsrMoveState* pCMS, bool bTestBackground ) const
 {
     sal_Bool bRet     = sal_False;
     Point aPoint( rPoint );
@@ -220,14 +223,11 @@ sal_Bool SwPageFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
     //hineinsetzen, dadurch sollten alle Aenderungen unmoeglich sein.
     if ( GetSortedObjs() )
     {
-        long nObjSurface = 0; // Unused
-        bRet = lcl_GetCrsrOfst_Objects( this, false, pPos, rPoint, pCMS, nObjSurface );
+        bRet = lcl_GetCrsrOfst_Objects( this, false, pPos, rPoint, pCMS );
     }
 
     if ( !bRet )
     {
-        long nTextSurface = 0;
-        long nBackSurface = 0;
         SwPosition aBackPos( *pPos );
         SwPosition aTextPos( *pPos );
 
@@ -236,7 +236,6 @@ sal_Bool SwPageFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
         //aktuellen an. Mit Flys ist es dann allerdings vorbei.
         if ( SwLayoutFrm::GetCrsrOfst( &aTextPos, aPoint, pCMS ) )
         {
-            nTextSurface = lcl_GetSurface( &aTextPos );
             bTextRet = sal_True;
         }
         else
@@ -250,8 +249,6 @@ sal_Bool SwPageFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
             if ( pCMS && pCMS->bStop )
                 return sal_False;
 
-            nTextSurface = pCnt->Frm().Height() * pCnt->Frm().Width();
-
             OSL_ENSURE( pCnt, "Crsr is gone to a Black hole" );
             if( pCMS && pCMS->pFill && pCnt->IsTxtFrm() )
                 bTextRet = pCnt->GetCrsrOfst( &aTextPos, rPoint, pCMS );
@@ -270,11 +267,10 @@ sal_Bool SwPageFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
         // Check objects in the background if nothing else matched
         if ( GetSortedObjs() )
         {
-            bBackRet = lcl_GetCrsrOfst_Objects( this, true, &aBackPos, rPoint, pCMS, nBackSurface );
+            bBackRet = lcl_GetCrsrOfst_Objects( this, true, &aBackPos, rPoint, pCMS );
         }
 
-        // TODO Pick up the best approaching selection
-        if ( bTextRet && bBackRet && ( nTextSurface > nBackSurface ) )
+        if ( ( bTestBackground && bBackRet ) || !bTextRet )
         {
             bRet = bBackRet;
             pPos->nNode = aBackPos.nNode;
@@ -282,9 +278,49 @@ sal_Bool SwPageFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
         }
         else
         {
-            bRet = bTextRet;
-            pPos->nNode = aTextPos.nNode;
-            pPos->nContent = aTextPos.nContent;
+            /* In order to provide a selection as accurable as possible when we have both
+             * text and brackground object, then we compute the distance between both
+             * would-be positions and the click point. The shortest distance wins.
+             */
+            SwCntntNode* pTextNd = aTextPos.nNode.GetNode( ).GetCntntNode( );
+            double nTextDistance = 0;
+            bool bValidTextDistance = false;
+            if ( pTextNd )
+            {
+                SwCntntFrm* pTextFrm = pTextNd->getLayoutFrm( getRootFrm( ) );
+                SwRect rTextRect;
+                pTextFrm->GetCharRect( rTextRect, aTextPos );
+
+                nTextDistance = lcl_getDistance( rTextRect, rPoint );
+                bValidTextDistance = true;
+            }
+
+            double nBackDistance = 0;
+            bool bValidBackDistance = false;
+            SwCntntNode* pBackNd = aBackPos.nNode.GetNode( ).GetCntntNode( );
+            if ( pBackNd )
+            {
+                // FIXME There are still cases were we don't have the proper node here.
+                SwCntntFrm* pBackFrm = pBackNd->getLayoutFrm( getRootFrm( ) );
+                SwRect rBackRect;
+                pBackFrm->GetCharRect( rBackRect, aBackPos );
+
+                nBackDistance = lcl_getDistance( rBackRect, rPoint );
+                bValidBackDistance = true;
+            }
+
+            if ( bValidTextDistance && bValidBackDistance && basegfx::fTools::more( nTextDistance, nBackDistance ) )
+            {
+                bRet = bBackRet;
+                pPos->nNode = aBackPos.nNode;
+                pPos->nContent = aBackPos.nContent;
+            }
+            else
+            {
+                bRet = bTextRet;
+                pPos->nNode = aTextPos.nNode;
+                pPos->nContent = aTextPos.nContent;
+            }
         }
     }
 
@@ -360,7 +396,7 @@ bool SwRootFrm::FillSelection( SwSelectionList& aSelList, const SwRect& rRect) c
 |*
 |*************************************************************************/
 sal_Bool SwRootFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
-                             SwCrsrMoveState* pCMS ) const
+                             SwCrsrMoveState* pCMS, bool bTestBackground ) const
 {
     sal_Bool bOldAction = IsCallbackActionEnabled();
     ((SwRootFrm*)this)->SetCallbackActionEnabled( sal_False );
@@ -387,7 +423,7 @@ sal_Bool SwRootFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
     }
     if ( pPage )
     {
-        pPage->SwPageFrm::GetCrsrOfst( pPos, rPoint, pCMS );
+        pPage->SwPageFrm::GetCrsrOfst( pPos, rPoint, pCMS, bTestBackground );
     }
 
     ((SwRootFrm*)this)->SetCallbackActionEnabled( bOldAction );
@@ -412,7 +448,7 @@ sal_Bool SwRootFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
 |*
 |*************************************************************************/
 sal_Bool SwCellFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
-                             SwCrsrMoveState* pCMS ) const
+                             SwCrsrMoveState* pCMS, bool ) const
 {
     // cell frame does not necessarily have a lower (split table cell)
     if ( !Lower() )
@@ -489,7 +525,7 @@ sal_Bool SwCellFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
 //am weitesten oben liegt.
 
 sal_Bool SwFlyFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
-                            SwCrsrMoveState* pCMS ) const
+                            SwCrsrMoveState* pCMS, bool ) const
 {
     aOszCtrl.Entry( this );
 
diff --git a/sw/source/core/layout/unusedf.cxx b/sw/source/core/layout/unusedf.cxx
index d28eb5f..f12f19c 100644
--- a/sw/source/core/layout/unusedf.cxx
+++ b/sw/source/core/layout/unusedf.cxx
@@ -54,7 +54,7 @@ bool SwFrm::FillSelection( SwSelectionList& , const SwRect& ) const
     return false;
 }
 
-sal_Bool SwFrm::GetCrsrOfst( SwPosition *, Point&, SwCrsrMoveState*  ) const
+sal_Bool SwFrm::GetCrsrOfst( SwPosition *, Point&, SwCrsrMoveState*, bool  ) const
 {
     OSL_FAIL( "GetCrsrOfst of the base class, hi!" );
     return sal_False;
diff --git a/sw/source/core/text/frmcrsr.cxx b/sw/source/core/text/frmcrsr.cxx
index 9562f16..059499c 100644
--- a/sw/source/core/text/frmcrsr.cxx
+++ b/sw/source/core/text/frmcrsr.cxx
@@ -682,7 +682,7 @@ sal_Bool SwTxtFrm::_GetCrsrOfst(SwPosition* pPos, const Point& rPoint,
  *************************************************************************/
 
 sal_Bool SwTxtFrm::GetCrsrOfst(SwPosition* pPos, Point& rPoint,
-                               SwCrsrMoveState* pCMS ) const
+                               SwCrsrMoveState* pCMS, bool ) const
 {
     MSHORT nChgFrm = 2;
     if( pCMS )
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index e28afb1..99c4fbf 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -2779,11 +2779,12 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
     // How many clicks do we need to select a fly frame?
     FrameControlType eControl;
     bool bOverFly = false;
-    bool bOverHeaderFooterFly = IsOverHeaderFooterFly( aDocPos, eControl, bOverFly );
+    bool bPageAnchored = false;
+    bool bOverHeaderFooterFly = IsOverHeaderFooterFly( aDocPos, eControl, bOverFly, bPageAnchored );
     int nNbFlyClicks = 1;
     // !bOverHeaderFooterFly doesn't mean we have a frame to select
-    if ( ( rSh.IsHeaderFooterEdit( ) && !bOverHeaderFooterFly && bOverFly ) ||
-         ( !rSh.IsHeaderFooterEdit( ) && bOverHeaderFooterFly ) )
+    if ( !bPageAnchored && ( ( rSh.IsHeaderFooterEdit( ) && !bOverHeaderFooterFly && bOverFly ) ||
+         ( !rSh.IsHeaderFooterEdit( ) && bOverHeaderFooterFly ) ) )
     {
         nNbFlyClicks = 2;
         if ( _rMEvt.GetClicks( ) < nNbFlyClicks )
@@ -4964,9 +4965,10 @@ void SwEditWin::Command( const CommandEvent& rCEvt )
             // Don't trigger the command on a frame anchored to header/footer is not editing it
             FrameControlType eControl;
             bool bOverFly = false;
-            bool bOverHeaderFooterFly = IsOverHeaderFooterFly( aDocPos, eControl, bOverFly );
+            bool bPageAnchored = false;
+            bool bOverHeaderFooterFly = IsOverHeaderFooterFly( aDocPos, eControl, bOverFly, bPageAnchored );
             // !bOverHeaderFooterFly doesn't mean we have a frame to select
-            if ( rCEvt.IsMouseEvent( ) &&
+            if ( !bPageAnchored && rCEvt.IsMouseEvent( ) &&
                  ( ( rSh.IsHeaderFooterEdit( ) && !bOverHeaderFooterFly && bOverFly ) ||
                    ( !rSh.IsHeaderFooterEdit( ) && bOverHeaderFooterFly ) ) )
             {
@@ -5950,13 +5952,13 @@ bool SwEditWin::IsInHeaderFooter( const Point &rDocPt, FrameControlType &rContro
     return false;
 }
 
-bool SwEditWin::IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly ) const
+bool SwEditWin::IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const
 {
     bool bRet = false;
     Point aPt( rDocPos );
     SwWrtShell &rSh = rView.GetWrtShell();
     SwPaM aPam( *rSh.GetCurrentShellCursor().GetPoint() );
-    rSh.GetLayout()->GetCrsrOfst( aPam.GetPoint(), aPt );
+    rSh.GetLayout()->GetCrsrOfst( aPam.GetPoint(), aPt, NULL, true );
 
     const SwStartNode* pStartFly = aPam.GetPoint()->nNode.GetNode().FindFlyStartNode();
     if ( pStartFly )
@@ -5977,6 +5979,8 @@ bool SwEditWin::IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& r
                 else if ( bInFooter )
                     rControl = Footer;
             }
+            else
+                bPageAnchored = pFlyFmt->GetAnchor( ).GetAnchorId( ) == FLY_AT_PAGE;
         }
     }
     else
diff --git a/sw/source/ui/inc/edtwin.hxx b/sw/source/ui/inc/edtwin.hxx
index cdc9fdf..5c15e32 100644
--- a/sw/source/ui/inc/edtwin.hxx
+++ b/sw/source/ui/inc/edtwin.hxx
@@ -228,7 +228,7 @@ protected:
     /// Returns true if in header/footer area, or in the header/footer control.
     bool    IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const;
 
-    bool    IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly ) const;
+    bool    IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly, bool& bPageAnchored ) const;
 public:
 
     void            UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
commit 7d43a3b02fee1c89cf706e7f917ae5d462974fe5
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Fri Nov 23 16:34:58 2012 +0100

    Show typeid in layout xml dump for debugging purpose
    
    Change-Id: Ie36ba37d521b4a73455488cee61ef55a6fcc9c0f

diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index dc4c7c4..5decf30 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -365,6 +365,7 @@ void SwFrm::dumpAsXmlAttributes( xmlTextWriterPtr writer )
 {
     xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "ptr" ), "%p", this );
     xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "id" ), "%" SAL_PRIuUINT32, GetFrmId() );
+    xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "symbol" ), "%s", BAD_CAST( typeid( *this ).name( ) ) );
     if ( GetNext( ) )
         xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "next" ), "%" SAL_PRIuUINT32, GetNext()->GetFrmId() );
     if ( GetPrev( ) )
commit 7e2f98d0a0c4a0f36a94353a256e7cc5caa3113b
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Thu Nov 22 10:47:17 2012 +0100

    Header/Footer: fixed the selection of frames anchored to header/footer
    
    Now, double-click actually selects a frame anchored in header/footer.
    Code has been cleaned a bit as well.
    
    Change-Id: Idb7f3520527a0cb6efe0ea41c62f452bc87c4e8d

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index ab08495..e28afb1 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -199,37 +199,6 @@ static SfxShell* lcl_GetShellFromDispatcher( SwView& rView, TypeId nType );
 
 DBG_NAME(edithdl)
 
-namespace
-{
-    static bool lcl_CheckHeaderFooterClick( SwWrtShell& rSh, const Point &rDocPos, sal_uInt16 nClicks )
-    {
-        bool bRet = false;
-
-        sal_Bool bOverHdrFtr = rSh.IsOverHeaderFooterPos( rDocPos );
-        if ( ( rSh.IsHeaderFooterEdit( ) && !bOverHdrFtr ) ||
-             ( !rSh.IsHeaderFooterEdit() && bOverHdrFtr ) )
-        {
-            bRet = true;
-            // Check if there we are in a FlyFrm
-            Point aPt( rDocPos );
-            SwPaM aPam( *rSh.GetCurrentShellCursor().GetPoint() );
-            rSh.GetLayout()->GetCrsrOfst( aPam.GetPoint(), aPt );
-
-            const SwStartNode* pStartFly = aPam.GetPoint()->nNode.GetNode().FindFlyStartNode();
-            int nNbClicks = 1;
-            if ( pStartFly && !rSh.IsHeaderFooterEdit() )
-                nNbClicks = 2;
-
-            if ( nClicks == nNbClicks )
-            {
-                rSh.SwCrsrShell::SetCrsr( rDocPos );
-                bRet = false;
-            }
-        }
-        return bRet;
-    }
-}
-
 class SwAnchorMarker
 {
     SdrHdl* pHdl;
@@ -2807,9 +2776,22 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
 
     const Point aDocPos( PixelToLogic( rMEvt.GetPosPixel() ) );
 
-    // Are we clicking on a blank header/footer area?
+    // How many clicks do we need to select a fly frame?
     FrameControlType eControl;
-    if ( IsInHeaderFooter( aDocPos, eControl ) )
+    bool bOverFly = false;
+    bool bOverHeaderFooterFly = IsOverHeaderFooterFly( aDocPos, eControl, bOverFly );
+    int nNbFlyClicks = 1;
+    // !bOverHeaderFooterFly doesn't mean we have a frame to select
+    if ( ( rSh.IsHeaderFooterEdit( ) && !bOverHeaderFooterFly && bOverFly ) ||
+         ( !rSh.IsHeaderFooterEdit( ) && bOverHeaderFooterFly ) )
+    {
+        nNbFlyClicks = 2;
+        if ( _rMEvt.GetClicks( ) < nNbFlyClicks )
+            return;
+    }
+
+    // Are we clicking on a blank header/footer area?
+    if ( IsInHeaderFooter( aDocPos, eControl ) || bOverHeaderFooterFly )
     {
         const SwPageFrm* pPageFrm = rSh.GetLayout()->GetPageAtPos( aDocPos );
 
@@ -2878,9 +2860,6 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
         }
     }
 
-    if ( lcl_CheckHeaderFooterClick( rSh, aDocPos, rMEvt.GetClicks() ) )
-        return;
-
 
     if ( IsChainMode() )
     {
@@ -3103,144 +3082,151 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
             case MOUSE_LEFT:
             case MOUSE_LEFT + KEY_MOD1:
             case MOUSE_LEFT + KEY_MOD2:
-                switch ( nNumberOfClicks )
+            {
+
+                bool bHandledFlyClick = false;
+                if ( nNumberOfClicks == nNbFlyClicks )
                 {
-                    case 1:
+                    bHandledFlyClick = true;
+                    // only try to select frame, if pointer already was
+                    // switched accordingly
+                    if ( aActHitType != SDRHIT_NONE && !rSh.IsSelFrmMode() &&
+                        !GetView().GetViewFrame()->GetDispatcher()->IsLocked() &&
+                        !bExecDrawTextLink)
                     {
-                        UpdatePointer( aDocPos, rMEvt.GetModifier() );
-                        SwEditWin::nDDStartPosY = aDocPos.Y();
-                        SwEditWin::nDDStartPosX = aDocPos.X();
+                        // Test if there is a draw object at that position and if it should be selected.
+                        sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos);
 
-                        // hit an URL in DrawText object?
-                        if (bExecHyperlinks && pSdrView)
+                        if(bShould)
                         {
-                            SdrViewEvent aVEvt;
-                            pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
-
-                            if (aVEvt.eEvent == SDREVENT_EXECUTEURL)
-                                bExecDrawTextLink = sal_True;
-                        }
-
-                        SwContentAtPos aFieldAtPos ( SwContentAtPos::SW_FIELD );
+                            rView.NoRotate();
+                            rSh.HideCrsr();
 
-                        // only try to select frame, if pointer already was
-                        // switched accordingly
-                        if ( aActHitType != SDRHIT_NONE && !rSh.IsSelFrmMode() &&
-                            !GetView().GetViewFrame()->GetDispatcher()->IsLocked() &&
-                            !bExecDrawTextLink)
-                        {
-                            // Test if there is a draw object at that position and if it should be selected.
-                            sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos);
+                            sal_Bool bUnLockView = !rSh.IsViewLocked();
+                            rSh.LockView( sal_True );
+                            sal_Bool bSelObj = rSh.SelectObj( aDocPos,
+                                           rMEvt.IsMod1() ? SW_ENTER_GROUP : 0);
+                            if( bUnLockView )
+                                rSh.LockView( sal_False );
 
-                            if(bShould)
+                            if( bSelObj )
                             {
-                                rView.NoRotate();
-                                rSh.HideCrsr();
-
-                                sal_Bool bUnLockView = !rSh.IsViewLocked();
-                                rSh.LockView( sal_True );
-                                sal_Bool bSelObj = rSh.SelectObj( aDocPos,
-                                               rMEvt.IsMod1() ? SW_ENTER_GROUP : 0);
-                                if( bUnLockView )
-                                    rSh.LockView( sal_False );
-
-                                if( bSelObj )
+                                // if the frame was deselected in the macro
+                                // the cursor just has to be displayed again
+                                if( FRMTYPE_NONE == rSh.GetSelFrmType() )
+                                    rSh.ShowCrsr();
+                                else
                                 {
-                                    // if the frame was deselected in the macro
-                                    // the cursor just has to be displayed again
-                                    if( FRMTYPE_NONE == rSh.GetSelFrmType() )
-                                        rSh.ShowCrsr();
-                                    else
+                                    if (rSh.IsFrmSelected() && rView.GetDrawFuncPtr())
                                     {
-                                        if (rSh.IsFrmSelected() && rView.GetDrawFuncPtr())
-                                        {
-                                            rView.GetDrawFuncPtr()->Deactivate();
-                                            rView.SetDrawFuncPtr(NULL);
-                                            rView.LeaveDrawCreate();
-                                            rView.AttrChangedNotify( &rSh );
-                                        }
-
-                                        rSh.EnterSelFrmMode( &aDocPos );
-                                        bFrmDrag = sal_True;
-                                        UpdatePointer( aDocPos, rMEvt.GetModifier() );
+                                        rView.GetDrawFuncPtr()->Deactivate();
+                                        rView.SetDrawFuncPtr(NULL);
+                                        rView.LeaveDrawCreate();
+                                        rView.AttrChangedNotify( &rSh );
                                     }
-                                    return;
-                                }
-                                else
-                                    bOnlyText = static_cast< sal_Bool >(rSh.IsObjSelectable( aDocPos ));
 
-                                if (!rView.GetDrawFuncPtr())
-                                    rSh.ShowCrsr();
+                                    rSh.EnterSelFrmMode( &aDocPos );
+                                    bFrmDrag = sal_True;
+                                    UpdatePointer( aDocPos, rMEvt.GetModifier() );
+                                }
+                                return;
                             }
                             else
-                                bOnlyText = KEY_MOD1 != rMEvt.GetModifier();
+                                bOnlyText = static_cast< sal_Bool >(rSh.IsObjSelectable( aDocPos ));
+
+                            if (!rView.GetDrawFuncPtr())
+                                rSh.ShowCrsr();
+                        }
+                        else
+                            bOnlyText = KEY_MOD1 != rMEvt.GetModifier();
+                    }
+                    else if ( rSh.IsSelFrmMode() &&
+                              (aActHitType == SDRHIT_NONE ||
+                               !rSh.IsInsideSelectedObj( aDocPos )))
+                    {
+                        rView.NoRotate();
+                        SdrHdl *pHdl;
+                        if( !bIsDocReadOnly && !pAnchorMarker && 0 !=
+                            ( pHdl = pSdrView->PickHandle(aDocPos) ) &&
+                                ( pHdl->GetKind() == HDL_ANCHOR ||
+                                  pHdl->GetKind() == HDL_ANCHOR_TR ) )
+                        {
+                            pAnchorMarker = new SwAnchorMarker( pHdl );
+                            UpdatePointer( aDocPos, rMEvt.GetModifier() );
+                            return;
                         }
-                        else if ( rSh.IsSelFrmMode() &&
-                                  (aActHitType == SDRHIT_NONE ||
-                                   !rSh.IsInsideSelectedObj( aDocPos )))
+                        else
                         {
-                            rView.NoRotate();
-                            SdrHdl *pHdl;
-                            if( !bIsDocReadOnly && !pAnchorMarker && 0 !=
-                                ( pHdl = pSdrView->PickHandle(aDocPos) ) &&
-                                    ( pHdl->GetKind() == HDL_ANCHOR ||
-                                      pHdl->GetKind() == HDL_ANCHOR_TR ) )
+                            sal_Bool bUnLockView = !rSh.IsViewLocked();
+                            rSh.LockView( sal_True );
+                            sal_uInt8 nFlag = rMEvt.IsShift() ? SW_ADD_SELECT :0;
+                            if( rMEvt.IsMod1() )
+                                nFlag = nFlag | SW_ENTER_GROUP;
+
+                            if ( rSh.IsSelFrmMode() )
                             {
-                                pAnchorMarker = new SwAnchorMarker( pHdl );
-                                UpdatePointer( aDocPos, rMEvt.GetModifier() );
-                                return;
+                                rSh.UnSelectFrm();
+                                rSh.LeaveSelFrmMode();
+                                rView.AttrChangedNotify(&rSh);
                             }
-                            else
-                            {
-                                sal_Bool bUnLockView = !rSh.IsViewLocked();
-                                rSh.LockView( sal_True );
-                                sal_uInt8 nFlag = rMEvt.IsShift() ? SW_ADD_SELECT :0;
-                                if( rMEvt.IsMod1() )
-                                    nFlag = nFlag | SW_ENTER_GROUP;
 
-                                if ( rSh.IsSelFrmMode() )
-                                {
-                                    rSh.UnSelectFrm();
-                                    rSh.LeaveSelFrmMode();
-                                    rView.AttrChangedNotify(&rSh);
-                                }
-
-                                sal_Bool bSelObj = rSh.SelectObj( aDocPos, nFlag );
-                                if( bUnLockView )
-                                    rSh.LockView( sal_False );
+                            sal_Bool bSelObj = rSh.SelectObj( aDocPos, nFlag );
+                            if( bUnLockView )
+                                rSh.LockView( sal_False );
 
-                                if( !bSelObj )
+                            if( !bSelObj )
+                            {
+                                // move cursor here so that it is not drawn in the
+                                // frame first; ShowCrsr() happens in LeaveSelFrmMode()
+                                bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
+                                rSh.LeaveSelFrmMode();
+                                rView.AttrChangedNotify( &rSh );
+                                bCallBase = sal_False;
+                            }
+                            else
+                            {
+                                rSh.HideCrsr();
+                                rSh.EnterSelFrmMode( &aDocPos );
+                                rSh.SelFlyGrabCrsr();
+                                rSh.MakeSelVisible();
+                                bFrmDrag = sal_True;
+                                if( rSh.IsFrmSelected() &&
+                                    rView.GetDrawFuncPtr() )
                                 {
-                                    // move cursor here so that it is not drawn in the
-                                    // frame first; ShowCrsr() happens in LeaveSelFrmMode()
-                                    bValidCrsrPos = !(CRSR_POSCHG & rSh.SetCursor(&aDocPos, false));
-                                    rSh.LeaveSelFrmMode();
+                                    rView.GetDrawFuncPtr()->Deactivate();
+                                    rView.SetDrawFuncPtr(NULL);
+                                    rView.LeaveDrawCreate();
                                     rView.AttrChangedNotify( &rSh );
-                                    bCallBase = sal_False;
-                                }
-                                else
-                                {
-                                    rSh.HideCrsr();
-                                    rSh.EnterSelFrmMode( &aDocPos );
-                                    rSh.SelFlyGrabCrsr();
-                                    rSh.MakeSelVisible();
-                                    bFrmDrag = sal_True;
-                                    if( rSh.IsFrmSelected() &&
-                                        rView.GetDrawFuncPtr() )
-                                    {
-                                        rView.GetDrawFuncPtr()->Deactivate();
-                                        rView.SetDrawFuncPtr(NULL);
-                                        rView.LeaveDrawCreate();
-                                        rView.AttrChangedNotify( &rSh );
-                                    }
-                                    UpdatePointer( aDocPos, rMEvt.GetModifier() );
-                                    return;
                                 }
+                                UpdatePointer( aDocPos, rMEvt.GetModifier() );
+                                return;
                             }
                         }
+                    }
+                }
+
+                switch ( nNumberOfClicks )
+                {
+                    case 1:
+                    {
+                        UpdatePointer( aDocPos, rMEvt.GetModifier() );
+                        SwEditWin::nDDStartPosY = aDocPos.Y();
+                        SwEditWin::nDDStartPosX = aDocPos.X();
+
+                        // hit an URL in DrawText object?
+                        if (bExecHyperlinks && pSdrView)
+                        {
+                            SdrViewEvent aVEvt;
+                            pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
+
+                            if (aVEvt.eEvent == SDREVENT_EXECUTEURL)
+                                bExecDrawTextLink = sal_True;
+                        }
+
+                        SwContentAtPos aFieldAtPos ( SwContentAtPos::SW_FIELD );
 
                         // Are we selecting a field?
-                        else if ( rSh.GetContentAtPos( aDocPos, aFieldAtPos ) )
+                        if ( rSh.GetContentAtPos( aDocPos, aFieldAtPos ) )
                         {
                             // select work, AdditionalMode if applicable
                             if ( KEY_MOD1 == rMEvt.GetModifier() && !rSh.IsAddMode() )
@@ -3257,7 +3243,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
                     case 2:
                     {
                         bFrmDrag = sal_False;
-                        if ( !bIsDocReadOnly && rSh.IsInsideSelectedObj(aDocPos) &&
+                        if ( !bHandledFlyClick && !bIsDocReadOnly && rSh.IsInsideSelectedObj(aDocPos) &&
                              0 == rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) )
 
 /* this is no good, on the one hand GetSelectionType is used as flag field (take a look into the GetSelectionType method)
@@ -3389,6 +3375,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
                     default:
                         return;
                 }
+            }
                 /* no break */
             case MOUSE_LEFT + KEY_SHIFT:
             case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
@@ -4974,9 +4961,17 @@ void SwEditWin::Command( const CommandEvent& rCEvt )
             if ( !rCEvt.IsMouseEvent() )
                 aDocPos = rSh.GetCharRect().Center();
 
-            if (rCEvt.IsMouseEvent() && lcl_CheckHeaderFooterClick( rSh, aDocPos, 1 ) )
+            // Don't trigger the command on a frame anchored to header/footer is not editing it
+            FrameControlType eControl;
+            bool bOverFly = false;
+            bool bOverHeaderFooterFly = IsOverHeaderFooterFly( aDocPos, eControl, bOverFly );
+            // !bOverHeaderFooterFly doesn't mean we have a frame to select
+            if ( rCEvt.IsMouseEvent( ) &&
+                 ( ( rSh.IsHeaderFooterEdit( ) && !bOverHeaderFooterFly && bOverFly ) ||
+                   ( !rSh.IsHeaderFooterEdit( ) && bOverHeaderFooterFly ) ) )
+            {
                 return;
-
+            }
 
             if((!pChildWin || pChildWin->GetView() != &rView) &&
                 !rSh.IsDrawCreate() && !IsDrawAction())
@@ -5955,6 +5950,40 @@ bool SwEditWin::IsInHeaderFooter( const Point &rDocPt, FrameControlType &rContro
     return false;
 }
 
+bool SwEditWin::IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly ) const
+{
+    bool bRet = false;
+    Point aPt( rDocPos );
+    SwWrtShell &rSh = rView.GetWrtShell();
+    SwPaM aPam( *rSh.GetCurrentShellCursor().GetPoint() );
+    rSh.GetLayout()->GetCrsrOfst( aPam.GetPoint(), aPt );
+
+    const SwStartNode* pStartFly = aPam.GetPoint()->nNode.GetNode().FindFlyStartNode();
+    if ( pStartFly )
+    {
+        bOverFly = true;
+        SwFrmFmt* pFlyFmt = pStartFly->GetFlyFmt( );
+        if ( pFlyFmt )
+        {
+            const SwPosition* pAnchor = pFlyFmt->GetAnchor( ).GetCntntAnchor( );
+            if ( pAnchor )
+            {
+                bool bInHeader = pAnchor->nNode.GetNode( ).FindHeaderStartNode( ) != NULL;
+                bool bInFooter = pAnchor->nNode.GetNode( ).FindFooterStartNode( ) != NULL;
+
+                bRet = bInHeader || bInFooter;
+                if ( bInHeader )
+                    rControl = Header;
+                else if ( bInFooter )
+                    rControl = Footer;
+            }
+        }
+    }
+    else
+        bOverFly = false;
+    return bRet;
+}
+
 void SwEditWin::SetUseInputLanguage( sal_Bool bNew )
 {
     if ( bNew || bUseInputLanguage )
diff --git a/sw/source/ui/inc/edtwin.hxx b/sw/source/ui/inc/edtwin.hxx
index 2ff4e43..cdc9fdf 100644
--- a/sw/source/ui/inc/edtwin.hxx
+++ b/sw/source/ui/inc/edtwin.hxx
@@ -227,6 +227,8 @@ protected:
 
     /// Returns true if in header/footer area, or in the header/footer control.
     bool    IsInHeaderFooter( const Point &rDocPt, FrameControlType &rControl ) const;
+
+    bool    IsOverHeaderFooterFly( const Point& rDocPos, FrameControlType& rControl, bool& bOverFly ) const;
 public:
 
     void            UpdatePointer(const Point &, sal_uInt16 nButtons = 0);
commit 289185fd02d6d9734b6dbde01f15c4e6c5beacbb
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Wed Nov 21 16:07:34 2012 +0100

    Header/Footer: fixed click on frames over the header/footer area.
    
    The main problem here was due to the click to show the separator when
    there is no header or footer under the frame. That code was just exiting
    MouseButtonDown too early, which isn't good.
    
    Moved the seperators showing code out of the SwCrsrShell as it has no
    clue about the document-position and may lead to problems.
    
    Change-Id: Ia62333b52c5d0659bbe7ec4fcfe6e664db132435

diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 0b78ab9..191d02a 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -675,22 +675,6 @@ int SwCrsrShell::SetCrsr( const Point &rLPt, sal_Bool bOnlyText, bool bBlock )
         // same table column and not in header/footer -> back
         return bRet;
 
-    // toggle the header/footer mode if needed
-    bool bInHeaderFooter = pFrm && ( pFrm->IsHeaderFrm() || pFrm->IsFooterFrm() );
-    if ( bInHeaderFooter != IsHeaderFooterEdit() )
-        ToggleHeaderFooterEdit();
-    else
-    {
-        // Make sure we have the proper Header/Footer separators shown
-        // as these may be changed if clicking on an empty Header/Footer
-        SetShowHeaderFooterSeparator( Header, pFrm != NULL && pFrm->IsHeaderFrm( ) );
-        SetShowHeaderFooterSeparator( Footer, pFrm != NULL && pFrm->IsFooterFrm( ) );
-
-        // Repaint everything
-        GetWin()->Invalidate();
-    }
-
-
     if( pBlockCrsr && bBlock )
     {
         pBlockCrsr->setEndPoint( rLPt );
@@ -1314,24 +1298,6 @@ void SwCrsrShell::UpdateCrsr( sal_uInt16 eFlags, sal_Bool bIdleEnd )
         return; // if not then no update
     }
 
-    sal_Bool bInHeader= sal_True;
-    if ( IsInHeaderFooter( &bInHeader ) )
-    {
-        if ( !bInHeader )
-        {
-            SetShowHeaderFooterSeparator( Footer, true );
-            SetShowHeaderFooterSeparator( Header, false );
-        }
-        else
-        {
-            SetShowHeaderFooterSeparator( Header, true );
-            SetShowHeaderFooterSeparator( Footer, false );
-        }
-    }
-    if ( IsInHeaderFooter() != IsHeaderFooterEdit() )
-        ToggleHeaderFooterEdit();
-
-
     // #i27301#
     SwNotifyAccAboutInvalidTextSelections aInvalidateTextSelections( *this );
 
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 1565d13..ab08495 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -2848,8 +2848,33 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
 
             // Repaint everything
             Invalidate();
+        }
+        else
+        {
+            // Make sure we have the proper Header/Footer separators shown
+            // as these may be changed if clicking on an empty Header/Footer
+            rSh.SetShowHeaderFooterSeparator( Header, eControl == Header );
+            rSh.SetShowHeaderFooterSeparator( Footer, eControl == Footer );
 
-            return;
+            if ( !rSh.IsHeaderFooterEdit() )
+                rSh.ToggleHeaderFooterEdit();
+
+            // Repaint everything
+            rSh.GetWin()->Invalidate();
+        }
+    }
+    else
+    {
+        if ( rSh.IsHeaderFooterEdit( ) )
+            rSh.ToggleHeaderFooterEdit( );
+        else
+        {
+            // Make sure that the separators are hidden
+            rSh.SetShowHeaderFooterSeparator( Header, false );
+            rSh.SetShowHeaderFooterSeparator( Footer, false );
+
+            // Repaint everything
+            rSh.GetWin()->Invalidate();
         }
     }
 
diff --git a/sw/source/ui/shells/txtcrsr.cxx b/sw/source/ui/shells/txtcrsr.cxx
index eb1683d..d6837d4 100644
--- a/sw/source/ui/shells/txtcrsr.cxx
+++ b/sw/source/ui/shells/txtcrsr.cxx
@@ -360,6 +360,25 @@ void SwTextShell::ExecMoveMisc(SfxRequest &rReq)
         rReq.SetReturnValue(SfxBoolItem( nSlot, bRet ));
     rReq.Done();
 
+    sal_Bool bInHeader = sal_True;
+    if ( rSh.IsInHeaderFooter( &bInHeader ) )
+    {
+        if ( !bInHeader )
+        {
+            rSh.SetShowHeaderFooterSeparator( Footer, true );
+            rSh.SetShowHeaderFooterSeparator( Header, false );
+        }
+        else
+        {
+            rSh.SetShowHeaderFooterSeparator( Header, true );
+            rSh.SetShowHeaderFooterSeparator( Footer, false );
+        }
+
+        // Force repaint
+        rSh.GetWin()->Invalidate();
+    }
+    if ( rSh.IsInHeaderFooter() != rSh.IsHeaderFooterEdit() )
+        rSh.ToggleHeaderFooterEdit();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list