[Libreoffice-commits] core.git: Branch 'distro/suse/suse-3.6' - 3 commits - sw/source

Cédric Bosdonnat cedric.bosdonnat at free.fr
Thu Mar 7 03:10:15 PST 2013


 sw/source/core/crsr/crsrsh.cxx  |   34 ---
 sw/source/ui/docvw/edtwin.cxx   |  368 +++++++++++++++++++++++-----------------
 sw/source/ui/inc/edtwin.hxx     |    2 
 sw/source/ui/shells/txtcrsr.cxx |   19 ++
 4 files changed, 236 insertions(+), 187 deletions(-)

New commits:
commit 5f62f0d65d89627eea17bffcea5f2821f9869629
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Fri Nov 23 17:51:16 2012 +0100

    bnc#807777 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.
    
    (cherry picked from commit e8fbe97900f13305b17015d9044993bde4adab36)
    
    Conflicts:
    	sw/source/core/layout/trvlfrm.cxx
    	sw/source/ui/docvw/edtwin.cxx
    
    Change-Id: Ib5b53161c7af2c16f4df379382f2e53fc6d8092b

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 96e3f9c..814f677 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -2658,7 +2658,8 @@ 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 );
 
     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly();
     if (bOverHeaderFooterFly && (!bIsDocReadOnly && rSh.GetCurFld()))
@@ -2667,8 +2668,8 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
 
     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 )
@@ -4847,9 +4848,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 ) ) )
             {
@@ -5875,13 +5877,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 )
@@ -5902,6 +5904,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 22258b5..56cf88f 100644
--- a/sw/source/ui/inc/edtwin.hxx
+++ b/sw/source/ui/inc/edtwin.hxx
@@ -232,7 +232,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 b8f89be03838a046d86f6a1c77e5585140a82d5d
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Thu Nov 22 10:47:17 2012 +0100

    bnc#807777 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.
    
    (cherry picked from commit 7e2f98d0a0c4a0f36a94353a256e7cc5caa3113b)
    
    Conflicts:
    	sw/source/ui/docvw/edtwin.cxx
    
    Change-Id: Idb7f3520527a0cb6efe0ea41c62f452bc87c4e8d

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index f87c73e..96e3f9c 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -196,37 +196,6 @@ 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;
@@ -2686,9 +2655,28 @@ 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 );
+
+    sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly();
+    if (bOverHeaderFooterFly && (!bIsDocReadOnly && rSh.GetCurFld()))
+        // We have a field here, that should have priority over header/footer fly.
+        bOverHeaderFooterFly = false;
+
+    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 );
 
@@ -2757,11 +2745,6 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
         }
     }
 
-    sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly();
-    if ( (bIsDocReadOnly || !rSh.GetCurFld()) && lcl_CheckHeaderFooterClick( rSh, aDocPos, rMEvt.GetClicks() ) )
-        return;
-
-
     if ( IsChainMode() )
     {
         SetChainMode( sal_False );
@@ -2983,144 +2966,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 if ( rSh.IsSelFrmMode() &&
-                                  (aActHitType == SDRHIT_NONE ||
-                                   !rSh.IsInsideSelectedObj( aDocPos )))
+                        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 ) )
                         {
-                            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
+                        {
+                            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() )
@@ -3137,7 +3127,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)
@@ -3269,6 +3259,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
                     default:
                         return;
                 }
+            }
                 /* no break */
             case MOUSE_LEFT + KEY_SHIFT:
             case MOUSE_LEFT + KEY_SHIFT + KEY_MOD1:
@@ -4853,9 +4844,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())
@@ -5876,6 +5875,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 67af3ae..22258b5 100644
--- a/sw/source/ui/inc/edtwin.hxx
+++ b/sw/source/ui/inc/edtwin.hxx
@@ -231,6 +231,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 7b937e69516b46c7bfcf129afcfeccafa5308e29
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Wed Nov 21 16:07:34 2012 +0100

    bnc#807777 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.
    
    (cherry picked from commit 289185fd02d6d9734b6dbde01f15c4e6c5beacbb)
    
    Conflicts:
    	sw/source/core/crsr/crsrsh.cxx
    
    Change-Id: Ia62333b52c5d0659bbe7ec4fcfe6e664db132435

diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 1493d14..ce31ba8 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -686,22 +686,6 @@ int SwCrsrShell::SetCrsr( const Point &rLPt, sal_Bool bOnlyText, bool bBlock )
         // -> zurueck
         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 );
@@ -1334,24 +1318,6 @@ void SwCrsrShell::UpdateCrsr( sal_uInt16 eFlags, sal_Bool bIdleEnd )
         return;             // wenn nicht, dann kein 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 7de35b8..f87c73e 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -2727,8 +2727,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 e833708..9d3c8d0 100644
--- a/sw/source/ui/shells/txtcrsr.cxx
+++ b/sw/source/ui/shells/txtcrsr.cxx
@@ -362,6 +362,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