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

Miklos Vajna vmiklos at collabora.co.uk
Mon Sep 30 03:29:26 PDT 2013


 sw/inc/crsrsh.hxx                        |    4 ++--
 sw/qa/extras/odfimport/data/fdo69862.odt |binary
 sw/qa/extras/odfimport/odfimport.cxx     |   19 +++++++++++++++++++
 sw/source/core/crsr/crsrsh.cxx           |   12 ++++++------
 sw/source/core/docnode/nodedump.cxx      |    6 ++++--
 sw/source/core/edit/eddel.cxx            |    2 +-
 sw/source/core/edit/edglss.cxx           |    2 +-
 sw/source/ui/wrtsh/select.cxx            |    2 +-
 8 files changed, 34 insertions(+), 13 deletions(-)

New commits:
commit 959711f1276106b0aaee69ab660f1b0d3ece5bbc
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 30 11:45:35 2013 +0200

    fdo#69862 SwCrsrShell::ExtendedSelectAll: don't always select footnotes
    
    ExtendedSelectAll() was originally invented to e.g. select the whole
    document, change the language of the selection and then inmediately
    (before the layout is updated) undo the selection.
    
    When using it for "select all and doc starts with a table" purposes,
    then footnotes shouldn't be selected, just like those are not selected
    either, when the doc starts with a normal paragraph. Their anchor is
    still selected, and that's enough to have correct delete and copy&paste.
    
    Change-Id: I4fc49db628054a4b8a46effc2d0328eaabcaa9f8

diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 9166edc..c01d3ea 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -326,9 +326,9 @@ public:
     // SelAll() selects the document body content
     // if ExtendedSelect() is called afterwards, the whole nodes array is selected
     // only for usage in special cases allowed!
-    void ExtendedSelectAll();
+    void ExtendedSelectAll(bool bFootnotes = true);
     /// If ExtendedSelectAll() was called and selection didn't change since then.
-    bool ExtendedSelectedAll();
+    bool ExtendedSelectedAll(bool bFootnotes = true);
     /// If document body starts with a table.
     bool StartsWithTable();
 
diff --git a/sw/qa/extras/odfimport/data/fdo69862.odt b/sw/qa/extras/odfimport/data/fdo69862.odt
new file mode 100644
index 0000000..aec48fd
Binary files /dev/null and b/sw/qa/extras/odfimport/data/fdo69862.odt differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 34d4f82..f541d22 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -36,6 +36,7 @@ public:
     void testFdo68839();
     void testFdo37606();
     void testFdo37606Copy();
+    void testFdo69862();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -62,6 +63,7 @@ void Test::run()
         {"fdo68839.odt", &Test::testFdo68839},
         {"fdo37606.odt", &Test::testFdo37606},
         {"fdo37606.odt", &Test::testFdo37606Copy},
+        {"fdo69862.odt", &Test::testFdo69862},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -426,6 +428,23 @@ void Test::testFdo37606Copy()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount());
 }
 
+void Test::testFdo69862()
+{
+    // The test doc is special in that it starts with a table and it also has a footnote.
+    SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+    SwWrtShell* pWrtShell = pTxtDoc->GetDocShell()->GetWrtShell();
+    SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false);
+
+    pWrtShell->SelAll();
+    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());
+
+    SwTxtNode& rEnd = dynamic_cast<SwTxtNode&>(pShellCrsr->End()->nNode.GetNode());
+    CPPUNIT_ASSERT_EQUAL(OUString("H" "\x01" "ello."), rEnd.GetTxt());
+
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index e64b63d..106e150 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -227,7 +227,7 @@ void SwCrsrShell::StartAction()
 
 void SwCrsrShell::EndAction( const sal_Bool bIdleEnd )
 {
-    comphelper::FlagRestorationGuard g(mbSelectAll, StartsWithTable() && ExtendedSelectedAll());
+    comphelper::FlagRestorationGuard g(mbSelectAll, StartsWithTable() && ExtendedSelectedAll(/*bFootnotes =*/ false));
     sal_Bool bVis = m_bSVCrsrVis;
 
     // Idle-formatting?
@@ -520,11 +520,11 @@ sal_Bool SwCrsrShell::SttEndDoc( sal_Bool bStt )
     return bRet;
 }
 
-void SwCrsrShell::ExtendedSelectAll()
+void SwCrsrShell::ExtendedSelectAll(bool bFootnotes)
 {
     SwNodes& rNodes = GetDoc()->GetNodes();
     SwPosition* pPos = m_pCurCrsr->GetPoint();
-    pPos->nNode = rNodes.GetEndOfPostIts();
+    pPos->nNode = bFootnotes ? rNodes.GetEndOfPostIts() : rNodes.GetEndOfInserts();
     pPos->nContent.Assign( rNodes.GoNext( &pPos->nNode ), 0 );
     pPos = m_pCurCrsr->GetMark();
     pPos->nNode = rNodes.GetEndOfContent();
@@ -532,10 +532,10 @@ void SwCrsrShell::ExtendedSelectAll()
     pPos->nContent.Assign( pCNd, pCNd ? pCNd->Len() : 0 );
 }
 
-bool SwCrsrShell::ExtendedSelectedAll()
+bool SwCrsrShell::ExtendedSelectedAll(bool bFootnotes)
 {
     SwNodes& rNodes = GetDoc()->GetNodes();
-    SwNodeIndex nNode = rNodes.GetEndOfPostIts();
+    SwNodeIndex nNode = bFootnotes ? rNodes.GetEndOfPostIts() : rNodes.GetEndOfInserts();
     SwCntntNode* pStart = rNodes.GoNext(&nNode);
 
     nNode = rNodes.GetEndOfContent();
@@ -1158,7 +1158,7 @@ sal_Bool SwCrsrShell::GoPrevCrsr()
 
 void SwCrsrShell::Paint( const Rectangle &rRect)
 {
-    comphelper::FlagRestorationGuard g(mbSelectAll, StartsWithTable() && ExtendedSelectedAll());
+    comphelper::FlagRestorationGuard g(mbSelectAll, StartsWithTable() && ExtendedSelectedAll(/*bFootnotes =*/ false));
     SET_CURR_SHELL( this );
 
     // always switch off all cursors when painting
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index e644b96..f6dd2f5 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -35,7 +35,7 @@
 
 void SwEditShell::DeleteSel( SwPaM& rPam, sal_Bool* pUndo )
 {
-    bool bSelectAll = StartsWithTable() && ExtendedSelectedAll();
+    bool bSelectAll = StartsWithTable() && ExtendedSelectedAll(/*bFootnotes =*/ false);
     // only for selections
     if( !rPam.HasMark() || *rPam.GetPoint() == *rPam.GetMark())
         return;
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx
index 1c1ecb1..9e58d51 100644
--- a/sw/source/core/edit/edglss.cxx
+++ b/sw/source/core/edit/edglss.cxx
@@ -210,7 +210,7 @@ sal_Bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd )
         bool bColSel = _GetCrsr()->IsColumnSelection();
         if( bColSel && pInsDoc->IsClipBoard() )
             pInsDoc->SetColumnSelection( true );
-        bool bSelectAll = StartsWithTable() && ExtendedSelectedAll();
+        bool bSelectAll = StartsWithTable() && ExtendedSelectedAll(/*bFootnotes =*/ false);
         {
         FOREACHPAM_START(GetCrsr())
 
diff --git a/sw/source/ui/wrtsh/select.cxx b/sw/source/ui/wrtsh/select.cxx
index 149d299..1e9262f 100644
--- a/sw/source/ui/wrtsh/select.cxx
+++ b/sw/source/ui/wrtsh/select.cxx
@@ -162,7 +162,7 @@ long SwWrtShell::SelAll()
 
         bool bStartsWithTable = StartsWithTable();
         if (bStartsWithTable)
-            ExtendedSelectAll();
+            ExtendedSelectAll(/*bFootnotes =*/ false);
 
         if( pStartPos )
         {
commit 23f5c0466f4a614405430a90453c047a63d637d7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 30 10:58:55 2013 +0200

    SwTxtNode::dumpAsXml: don't dereference these pointers unconditionally
    
    Change-Id: I1b65cd92b6a2afa36a0181ab9851cfb2e30a11c3

diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx
index cc8b410..d415784 100644
--- a/sw/source/core/docnode/nodedump.cxx
+++ b/sw/source/core/docnode/nodedump.cxx
@@ -282,8 +282,10 @@ void SwTxtNode::dumpAsXml( xmlTextWriterPtr w )
             writer.startElement("hint");
             SwTxtAttr* pHint = rHints.GetTextHint(i);
 
-            writer.writeFormatAttribute("start", TMP_FORMAT, *pHint->GetStart());
-            writer.writeFormatAttribute("end", TMP_FORMAT, *pHint->GetEnd());
+            if (pHint->GetStart())
+                writer.writeFormatAttribute("start", TMP_FORMAT, *pHint->GetStart());
+            if (pHint->GetEnd())
+                writer.writeFormatAttribute("end", TMP_FORMAT, *pHint->GetEnd());
 
             const char* pWhich = "???";
             switch (pHint->Which())


More information about the Libreoffice-commits mailing list