Kaydet (Commit) d1eb536c authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#69893 fix SwWrtShell::SelAll() to work with empty table at doc start

In theory, it was a problem to have the table cursor around when having
the selection outside the table; but it didn't cause a problem so far.
However, when the table has one or more empty cells, we really need to
leave table mode, otherwise only the table gets selected.

Change-Id: I766903ed624b9338f0612697b4c03f44de1d2e41
üst ed279043
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <swmodeltestbase.hxx> #include <swmodeltestbase.hxx>
#include <ndtxt.hxx> #include <ndtxt.hxx>
#include <wrtsh.hxx>
#include "UndoManager.hxx" #include "UndoManager.hxx"
...@@ -21,10 +22,12 @@ public: ...@@ -21,10 +22,12 @@ public:
//Regression test of fdo#70143 //Regression test of fdo#70143
//EDITING: undo search&replace corrupt text when searching backward //EDITING: undo search&replace corrupt text when searching backward
void testReplaceBackward(); void testReplaceBackward();
void testFdo69893();
CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward); CPPUNIT_TEST(testReplaceForward);
CPPUNIT_TEST(testReplaceBackward); CPPUNIT_TEST(testReplaceBackward);
CPPUNIT_TEST(testFdo69893);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -97,6 +100,19 @@ void SwUiWriterTest::testReplaceBackward() ...@@ -97,6 +100,19 @@ void SwUiWriterTest::testReplaceBackward()
CPPUNIT_ASSERT_EQUAL(ORIGINAL_REPLACE_CONTENT, pTxtNode->GetTxt()); CPPUNIT_ASSERT_EQUAL(ORIGINAL_REPLACE_CONTENT, pTxtNode->GetTxt());
} }
void SwUiWriterTest::testFdo69893()
{
SwDoc* pDoc = createDoc("fdo69893.odt");
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
pWrtShell->SelAll();
SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false);
SwTxtNode& rEnd = dynamic_cast<SwTxtNode&>(pShellCrsr->End()->nNode.GetNode());
// Selection did not include the para after table, this was "B1".
CPPUNIT_ASSERT_EQUAL(OUString("Para after table."), rEnd.GetTxt());
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -162,7 +162,13 @@ long SwWrtShell::SelAll() ...@@ -162,7 +162,13 @@ long SwWrtShell::SelAll()
bool bStartsWithTable = StartsWithTable(); bool bStartsWithTable = StartsWithTable();
if (bStartsWithTable) if (bStartsWithTable)
{
// Disable table cursor to make sure getShellCrsr() returns m_pCurCrsr, not m_pTblCrsr.
if (IsTableMode())
TblCrsrToCursor();
// Do the extended select all on m_pCurCrsr.
ExtendedSelectAll(/*bFootnotes =*/ false); ExtendedSelectAll(/*bFootnotes =*/ false);
}
if( pStartPos ) if( pStartPos )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment