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

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Fri Aug 26 08:35:39 PDT 2011


 sw/inc/crstate.hxx                |   38 ++++++++++----------
 sw/source/core/layout/flowfrm.cxx |    3 +
 sw/source/core/layout/trvlfrm.cxx |   69 ++++++++++++++++++++++++++++++--------
 sw/source/ui/docvw/edtwin.cxx     |   45 ++++++++++++++++++++----
 4 files changed, 113 insertions(+), 42 deletions(-)

New commits:
commit a6176612ff1a6a142a68964b2c0834d28125fc45
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Fri Aug 26 17:11:10 2011 +0200

    Header/Footer: Change the edition mode entering
    
    Single click on header / footer changes the edit mode. But double click
    is still needed to enter header / footer mode on objects flying on the
    main body to avoid mistakenly selecting them.

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 1f4a398..9be716f 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -179,6 +179,37 @@ SfxShell* lcl_GetShellFromDispatcher( SwView& rView, TypeId nType );
 
 DBG_NAME(edithdl)
 
+namespace
+{
+    bool lcl_CheckHeaderFooterClick( SwWrtShell& rSh, const Point aDocPos, sal_uInt16 nClicks )
+    {
+        bool bRet = false;
+
+        sal_Bool bOverHdrFtr = rSh.IsOverHeaderFooterPos( aDocPos );
+        if ( ( rSh.IsHeaderFooterEdit( ) && !bOverHdrFtr ) ||
+             ( !rSh.IsHeaderFooterEdit() && bOverHdrFtr ) )
+        {
+            bRet = true;
+            // Check if there we are in a FlyFrm
+            Point aPt( aDocPos );
+            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( aDocPos );
+                bRet = false;
+            }
+        }
+        return bRet;
+    }
+}
+
 class SwAnchorMarker
 {
     SdrHdl* pHdl;
@@ -2602,15 +2633,8 @@ 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.SwCrsrShell::SetCrsr( aDocPos );
-
+    if ( lcl_CheckHeaderFooterClick( rSh, aDocPos, rMEvt.GetClicks() ) )
         return;
-    }
 
     if ( IsChainMode() )
     {
@@ -4673,6 +4697,11 @@ void SwEditWin::Command( const CommandEvent& rCEvt )
             if (rView.GetPostItMgr()->IsHit(rCEvt.GetMousePosPixel()))
                 return;
 
+            if ( lcl_CheckHeaderFooterClick( rSh,
+                        PixelToLogic( rCEvt.GetMousePosPixel() ), 1 ) )
+                return;
+
+
             if((!pChildWin || pChildWin->GetView() != &rView) &&
                 !rSh.IsDrawCreate() && !IsDrawAction())
             {
commit 89aaee9adad9d0ceac5a6a422b415152abe74e8c
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Fri Aug 26 17:10:51 2011 +0200

    Header/Footer: changed GetCrsrOfst to be able to pick up background objects

diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index a508045..ad41abd 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -68,7 +68,7 @@
 
 namespace {
     bool lcl_GetCrsrOfst_Objects( const SwPageFrm* pPageFrm, bool bSearchBackground,
-           SwPosition *pPos, Point& rPoint, SwCrsrMoveState* pCMS )
+           SwPosition *pPos, Point& rPoint, SwCrsrMoveState* pCMS, long& rSurface )
     {
         bool bRet = false;
         Point aPoint( rPoint );
@@ -91,6 +91,7 @@ namespace {
                    !pFly->IsProtected() ) &&
                  pFly->GetCrsrOfst( pPos, aPoint, pCMS ) )
             {
+                rSurface = pFly->Frm().Width() * pFly->Frm().Height();
                 bRet = true;
                 break;
             }
@@ -101,6 +102,20 @@ namespace {
         }
         return bRet;
     }
+
+    long lcl_GetSurface( SwPosition* pPos, const SwPageFrm* pPageFrm )
+    {
+        SwRect aArea;
+
+        SwNode& rNode = pPos->nNode.GetNode();
+
+        if ( rNode.IsCntntNode() )
+            aArea = rNode.GetCntntNode()->FindLayoutRect();
+
+        // FIXME Handle the other kinds of nodes?
+
+        return aArea.Height() * aArea.Width();
+    }
 }
 
 
@@ -200,21 +215,31 @@ sal_Bool SwPageFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
         aPoint.Y() = Min( aPoint.Y(), Frm().Bottom() );
     }
 
+    long nTextSurface, nBackSurface = 0;
+    sal_Bool bTextRet, bBackRet = sal_False;
+
     //Koennte ein Freifliegender gemeint sein?
     //Wenn sein Inhalt geschuetzt werden soll, so ist nix mit Crsr
     //hineinsetzen, dadurch sollten alle Aenderungen unmoeglich sein.
     if ( GetSortedObjs() )
     {
-        bRet = lcl_GetCrsrOfst_Objects( this, false, pPos, rPoint, pCMS );
+        long nObjSurface = 0; // Unused
+        bRet = lcl_GetCrsrOfst_Objects( this, false, pPos, rPoint, pCMS, nObjSurface );
     }
 
     if ( !bRet )
     {
+        SwPosition aBackPos( *pPos );
+        SwPosition aTextPos( *pPos );
+
         //Wenn kein Cntnt unterhalb der Seite 'antwortet', so korrigieren
         //wir den StartPoint und fangen nochmal eine Seite vor der
         //aktuellen an. Mit Flys ist es dann allerdings vorbei.
-        if ( SwLayoutFrm::GetCrsrOfst( pPos, aPoint, pCMS ) )
-            bRet = sal_True;
+        if ( SwLayoutFrm::GetCrsrOfst( &aTextPos, aPoint, pCMS ) )
+        {
+            nTextSurface = lcl_GetSurface( &aTextPos, this );
+            bTextRet = sal_True;
+        }
         else
         {
             if ( pCMS && (pCMS->bStop || pCMS->bExactOnly) )
@@ -226,26 +251,42 @@ 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() )
-                bRet = pCnt->GetCrsrOfst( pPos, rPoint, pCMS );
+                bTextRet = pCnt->GetCrsrOfst( &aTextPos, rPoint, pCMS );
             else
-                bRet = pCnt->GetCrsrOfst( pPos, aPoint, pCMS );
+                bTextRet = pCnt->GetCrsrOfst( &aTextPos, aPoint, pCMS );
 
-            if ( !bRet )
+            if ( !bTextRet )
             {
                 // Set point to pCnt, delete mark
                 // this may happen, if pCnt is hidden
-                *pPos = SwPosition( *pCnt->GetNode(), SwIndex( (SwTxtNode*)pCnt->GetNode(), 0 ) );
-                bRet = sal_True;
+                aTextPos = SwPosition( *pCnt->GetNode(), SwIndex( (SwTxtNode*)pCnt->GetNode(), 0 ) );
+                bTextRet = sal_True;
             }
         }
-    }
 
-    // Check objects in the background if nothing else matched
-    if ( !bRet && GetSortedObjs() )
-    {
-        bRet = lcl_GetCrsrOfst_Objects( this, true, pPos, rPoint, pCMS );
+        // Check objects in the background if nothing else matched
+        if ( GetSortedObjs() )
+        {
+            bBackRet = lcl_GetCrsrOfst_Objects( this, true, &aBackPos, rPoint, pCMS, nBackSurface );
+        }
+
+        // TODO Pick up the best approaching selection
+        if ( bTextRet && bBackRet && ( nTextSurface < nBackSurface ) )
+        {
+            bRet = bBackRet;
+            pPos->nNode = aBackPos.nNode;
+            pPos->nContent = aBackPos.nContent;
+        }
+        else
+        {
+            bRet = bTextRet;
+            pPos->nNode = aTextPos.nNode;
+            pPos->nContent = aTextPos.nContent;
+        }
     }
 
     if ( bRet )
commit fe37a70e93db34a8124285a64ea62709c3b6043e
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Thu Aug 25 10:49:00 2011 +0200

    Moved a few bit-fields to booleans

diff --git a/sw/inc/crstate.hxx b/sw/inc/crstate.hxx
index 5baa14d..e8a518f 100644
--- a/sw/inc/crstate.hxx
+++ b/sw/inc/crstate.hxx
@@ -140,30 +140,30 @@ struct SwCrsrMoveState
     Point aRealHeight;          // contains then the position/height of the cursor
     CrsrMoveState eState;
     sal_uInt8            nCursorBidiLevel;
-    sal_Bool bStop          :1;
-    sal_Bool bRealHeight    :1;     // should the real height be calculated?
-    sal_Bool bFieldInfo     :1;     // should be fields recognized?
-    sal_Bool bPosCorr       :1;     // Point had to be corrected
-    sal_Bool bFtnNoInfo     :1;     // recognized footnote numbering
-    sal_Bool bExactOnly     :1;     // let GetCrsrOfst look for exact matches only,
-                                // i.e. never let it run into GetCntntPos
-    sal_Bool bFillRet       :1;     // only used temporary in FillMode
-    sal_Bool bSetInReadOnly :1;     // ReadOnly areas may be entered
-    sal_Bool bRealWidth     :1;     // Calculation of the width required
-    sal_Bool b2Lines        :1;     // Check 2line portions and fill p2Lines
-    sal_Bool bNoScroll      :1;     // No scrolling of undersized textframes
-    sal_Bool bPosMatchesBounds :1;  // GetCrsrOfst should not return the next
-                                // position if screen position is inside second
-                                // have of bound rect
-
-    sal_Bool bCntntCheck :1; // #i43742# Cursor position over content?
+    sal_Bool bStop;
+    sal_Bool bRealHeight;           // should the real height be calculated?
+    sal_Bool bFieldInfo;            // should be fields recognized?
+    sal_Bool bPosCorr;              // Point had to be corrected
+    sal_Bool bFtnNoInfo;            // recognized footnote numbering
+    sal_Bool bExactOnly;            // let GetCrsrOfst look for exact matches only,
+                                    // i.e. never let it run into GetCntntPos
+    sal_Bool bFillRet;              // only used temporary in FillMode
+    sal_Bool bSetInReadOnly;        // ReadOnly areas may be entered
+    sal_Bool bRealWidth;            // Calculation of the width required
+    sal_Bool b2Lines;               // Check 2line portions and fill p2Lines
+    sal_Bool bNoScroll;             // No scrolling of undersized textframes
+    sal_Bool bPosMatchesBounds;     // GetCrsrOfst should not return the next
+                                    // position if screen position is inside second
+                                    // have of bound rect
+
+    sal_Bool bCntntCheck;           // #i43742# Cursor position over content?
 
     // #i27615#
     /**
        cursor in front of label
      */
-    sal_Bool bInFrontOfLabel :1;
-    sal_Bool bInNumPortion   :1;     // point is in number portion #i23726#
+    sal_Bool bInFrontOfLabel;
+    sal_Bool bInNumPortion;         // point is in number portion #i23726#
     int nInNumPostionOffset;     // distance from number portion's start
 
     SwCrsrMoveState( CrsrMoveState eSt = MV_NONE ) :
commit bfee324db63b79d0aea767aa9797fb8aebd3c4d0
Author: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>
Date:   Tue Aug 23 14:10:48 2011 +0200

    Fixed SwFlowFrm constructor to initialize pPrecede to NULL

diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 9288e53..af62c78 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -81,7 +81,8 @@ sal_Bool SwFlowFrm::bMoveBwdJump = sal_False;
 
 SwFlowFrm::SwFlowFrm( SwFrm &rFrm ) :
     rThis( rFrm ),
-    pFollow( 0 )
+    pFollow( 0 ),
+    pPrecede( 0 )
 {
     bLockJoin = bIsFollow = bCntntLock = bOwnFtnNum =
         bFtnLock = bFlyLock = sal_False;


More information about the Libreoffice-commits mailing list