[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Sat Jan 3 04:09:51 PST 2015


 sw/qa/extras/odfimport/odfimport.cxx |   20 ++++++++++++++++----
 sw/qa/extras/uiwriter/uiwriter.cxx   |    3 ++-
 sw/source/uibase/wrtsh/select.cxx    |   21 +++++++++++++++++----
 3 files changed, 35 insertions(+), 9 deletions(-)

New commits:
commit fa39e7970496537258eaad1f5351db2d675225b6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sat Jan 3 11:40:41 2015 +0100

    fdo#72486 SwWrtShell::SelAll: if in table, then call extended select all ...
    
    ... only in case the whole table is already selected
    
    Change-Id: If7626954460e16945af6b21402a84e90c71ae138

diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index df84332..cf24c9a 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -398,7 +398,13 @@ DECLARE_ODFIMPORT_TEST(testFdo37606, "fdo37606.odt")
     SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false);
 
     {
-        pWrtShell->SelAll();
+        pWrtShell->SelAll(); // Selects A1.
+        SwTxtNode& rCellEnd = dynamic_cast<SwTxtNode&>(pShellCrsr->End()->nNode.GetNode());
+        // fdo#72486 This was "Hello.", i.e. a single select-all selected the whole document, not just the cell only.
+        CPPUNIT_ASSERT_EQUAL(OUString("A1"), rCellEnd.GetTxt());
+
+        pWrtShell->SelAll(); // Selects the whole table.
+        pWrtShell->SelAll(); // Selects the whole document.
         SwTxtNode& rStart = dynamic_cast<SwTxtNode&>(pShellCrsr->Start()->nNode.GetNode());
         CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart.GetTxt());
 
@@ -435,7 +441,9 @@ DECLARE_ODFIMPORT_TEST(testFdo37606Copy, "fdo37606.odt")
     CPPUNIT_ASSERT(pTxtDoc);
     SwWrtShell* pWrtShell = pTxtDoc->GetDocShell()->GetWrtShell();
     // Ctrl-A
-    pWrtShell->SelAll();
+    pWrtShell->SelAll(); // Selects A1.
+    pWrtShell->SelAll(); // Selects the whole table.
+    pWrtShell->SelAll(); // Selects the whole document.
 
     // Ctrl-C
     SwTransferable* pTransferable = new SwTransferable(*pWrtShell);
@@ -464,7 +472,9 @@ DECLARE_ODFIMPORT_TEST(testFdo69862, "fdo69862.odt")
     SwWrtShell* pWrtShell = pTxtDoc->GetDocShell()->GetWrtShell();
     SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false);
 
-    pWrtShell->SelAll();
+    pWrtShell->SelAll(); // Selects A1.
+    pWrtShell->SelAll(); // Selects the whole table.
+    pWrtShell->SelAll(); // Selects the whole document.
     SwTxtNode& rStart = dynamic_cast<SwTxtNode&>(pShellCrsr->Start()->nNode.GetNode());
     // This was "Footnote.", as Ctrl-A also selected footnotes, but it should not.
     CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart.GetTxt());
@@ -481,7 +491,9 @@ DECLARE_ODFIMPORT_TEST(testFdo69979, "fdo69979.odt")
     SwWrtShell* pWrtShell = pTxtDoc->GetDocShell()->GetWrtShell();
     SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false);
 
-    pWrtShell->SelAll();
+    pWrtShell->SelAll(); // Selects A1.
+    pWrtShell->SelAll(); // Selects the whole table.
+    pWrtShell->SelAll(); // Selects the whole document.
     SwTxtNode& rStart = dynamic_cast<SwTxtNode&>(pShellCrsr->Start()->nNode.GetNode());
     // This was "", as Ctrl-A also selected headers, but it should not.
     CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart.GetTxt());
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 0813dec..4c7611c 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -213,7 +213,8 @@ void SwUiWriterTest::testFdo69893()
     SwDoc* pDoc = createDoc("fdo69893.odt");
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
 
-    pWrtShell->SelAll();
+    pWrtShell->SelAll(); // A1 is empty -> selects the whole table.
+    pWrtShell->SelAll(); // Selects the whole document.
 
     SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false);
     SwTxtNode& rEnd = dynamic_cast<SwTxtNode&>(pShellCrsr->End()->nNode.GetNode());
diff --git a/sw/source/uibase/wrtsh/select.cxx b/sw/source/uibase/wrtsh/select.cxx
index a2a2f03..b1ad26d 100644
--- a/sw/source/uibase/wrtsh/select.cxx
+++ b/sw/source/uibase/wrtsh/select.cxx
@@ -132,7 +132,12 @@ long SwWrtShell::SelAll()
         boost::scoped_ptr<SwPosition> pStartPos;
         boost::scoped_ptr<SwPosition> pEndPos;
         SwShellCrsr* pTmpCrsr = 0;
-        if( !HasWholeTabSelection() )
+
+        // Query these early, before we move the cursor.
+        bool bHasWholeTabSelection = HasWholeTabSelection();
+        bool bIsCursorInTable = IsCrsrInTbl();
+
+        if (!bHasWholeTabSelection)
         {
             if ( IsSelection() && IsCrsrPtAtEnd() )
                 SwapPam();
@@ -157,8 +162,16 @@ long SwWrtShell::SelAll()
         SttSelect();
         GoEnd(true, &bMoveTable);
 
-        bool bStartsWithTable = StartsWithTable();
-        if (bStartsWithTable)
+        bool bNeedsExtendedSelectAll = StartsWithTable();
+
+        // If the cursor was in a table, then we only need the extended select
+        // all if the whole table is already selected, to still allow selecting
+        // only a single cell or a single table before selecting the whole
+        // document.
+        if (bNeedsExtendedSelectAll && bIsCursorInTable)
+            bNeedsExtendedSelectAll = bHasWholeTabSelection;
+
+        if (bNeedsExtendedSelectAll)
         {
             // Disable table cursor to make sure getShellCrsr() returns m_pCurCrsr, not m_pTblCrsr.
             if (IsTableMode())
@@ -185,7 +198,7 @@ long SwWrtShell::SelAll()
                 // In this both cases we select to the end of document
                 if( ( *pTmpCrsr->GetPoint() < *pEndPos ||
                     ( *pStartPos == *pTmpCrsr->GetMark() &&
-                      *pEndPos == *pTmpCrsr->GetPoint() ) ) && !bStartsWithTable)
+                      *pEndPos == *pTmpCrsr->GetPoint() ) ) && !bNeedsExtendedSelectAll)
                     SwCrsrShell::SttEndDoc(false);
             }
         }


More information about the Libreoffice-commits mailing list