[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Mar 2 06:25:02 PST 2015


 sw/inc/crsrsh.hxx                 |    5 ++++-
 sw/source/core/crsr/crsrsh.cxx    |    4 ++--
 sw/source/core/crsr/crstrvl1.cxx  |    5 +++++
 sw/source/uibase/docvw/edtwin.cxx |    8 +++++++-
 4 files changed, 18 insertions(+), 4 deletions(-)

New commits:
commit 752b8e88f58d74ed75834fe1cc48395a0f14f8e0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Mar 2 14:54:21 2015 +0100

    SwEditWin: when tiled rendering, let double click select an empty cell
    
    When not tiled rendering and the user double-clicks on a word, then
    that's selected. If the double-click happens in an empty cell, nothing
    happens.
    
    When tiled rendering, still try to select a word, but if that doesn't
    work, then see if we are in a table, and then select just that cell.
    Then the user can use the usual selection handles to adjust the
    selection further.
    
    Change-Id: I6beabf5c73a02f1eb2ede6f8cf9062c1e6610e9e

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 13489ce..1fdef4b 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -157,7 +157,8 @@ public:
         SCROLLWIN   = (1 << 1),     ///< scroll window
         CHKRANGE    = (1 << 2),     ///< check overlapping PaMs
         NOCALRECT   = (1 << 3),     ///< don't recalculate CharRect
-        READONLY    = (1 << 4)      ///< make visible in spite of Readonly
+        READONLY    = (1 << 4),     ///< make visible in spite of Readonly
+        SELECTCELL  = (1 << 5)      ///< Create table cursor even if we don't span over multiple cells.
     };
 
 private:
@@ -729,6 +730,8 @@ public:
     bool GoStartSentence();
     bool GoEndSentence();
     bool SelectWord( const Point* pPt = 0 );
+    /// Creates table cursor even if we don't span over multiple cells.
+    void SelectCell();
     bool ExpandToSentenceBorders();
 
     // get position from current cursor
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 982a2ac..ce7dc5c 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1417,11 +1417,11 @@ void SwCrsrShell::UpdateCrsr( sal_uInt16 eFlags, bool bIdleEnd )
     // If the current cursor is in a table and point/mark in different boxes,
     // then the table mode is active (also if it is already active: m_pTblCrsr)
     SwPaM* pTstCrsr = getShellCrsr( true );
-    if( pTstCrsr->HasMark() && !m_pBlockCrsr &&
+    if( ( pTstCrsr->HasMark() || eFlags & SwCrsrShell::SELECTCELL ) && !m_pBlockCrsr &&
         mpDoc->IsIdxInTbl( pTstCrsr->GetPoint()->nNode ) &&
           ( m_pTblCrsr ||
             pTstCrsr->GetNode( true ).StartOfSectionNode() !=
-            pTstCrsr->GetNode( false ).StartOfSectionNode() ) && !mbSelectAll)
+            pTstCrsr->GetNode( false ).StartOfSectionNode() || eFlags & SwCrsrShell::SELECTCELL ) && !mbSelectAll)
     {
         SwShellCrsr* pITmpCrsr = getShellCrsr( true );
         Point aTmpPt( pITmpCrsr->GetPtPos() );
diff --git a/sw/source/core/crsr/crstrvl1.cxx b/sw/source/core/crsr/crstrvl1.cxx
index 699302a..d39e89c 100644
--- a/sw/source/core/crsr/crstrvl1.cxx
+++ b/sw/source/core/crsr/crstrvl1.cxx
@@ -81,6 +81,11 @@ bool SwCrsrShell::SelectWord( const Point* pPt )
     return m_pCurCrsr->SelectWord( this, pPt );
 }
 
+void SwCrsrShell::SelectCell()
+{
+    UpdateCrsr(SwCrsrShell::SELECTCELL);
+}
+
 bool SwCrsrShell::ExpandToSentenceBorders()
 {
     return m_pCurCrsr->ExpandToSentenceBorders();
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index bf0b28d..08105b9 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -3414,7 +3414,13 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
                             rSh.LeaveAddMode();
                         }
                         else
-                            rSh.SelWrd( &aDocPos );
+                        {
+                            if (!rSh.SelWrd(&aDocPos) && rSh.isTiledRendering())
+                                // Double click did not select any word: try to
+                                // select the current cell in case we are in a
+                                // table.
+                                rSh.SelectCell();
+                        }
                         bHoldSelection = true;
                         return;
                     }


More information about the Libreoffice-commits mailing list