summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorHaidongWu <personal_wu@hotmail.com>2016-03-09 11:28:14 +0800
committerCaolán McNamara <caolanm@redhat.com>2016-05-05 14:35:13 +0000
commit9197d8219e4b3ba4612c777710d65d325170de82 (patch)
treeff3aaef68711ea85223b90f83609ebef85487f86 /sw/qa
parente26463e647c10a4db0612747f914a132f398dfb6 (diff)
tdf#98512 Fix the Undo action of insert an input field.
Reviewed-on: https://gerrit.libreoffice.org/23055 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Oliver Specht <oliver.specht@cib.de> (cherry picked from commit ed81bf39dd3431d28860fed6a2d4e8814126cc61) tdf#98512 sw: remove duplicate undo history add Follow-up to commit ed81bf39dd3431d28860fed6a2d4e8814126cc61. In almost all cases SetAttr() and InsertHint() will already add the history hint themselves, so this code in SwRegHistory::InsertItems() looks somewhat pointless as it inserts a duplicate. It turns out it's needed for hints that insert dummy characters, because firstly for the hints-without-end the NoteInHistory() was not called, and secondly when InsertText() inserts the dummy character it may actually delete the hints array if there are no pre-existing hints, and a new hints array will be created where the SwRegHistory isn't registered. It's not obvious how the hints array actually can become empty in SwTextNode::InsertText(). Let's fix that and assert instead that the history hint was inserted. (cherry picked from commit b44e70e3d17c79eaf78f9bfe8bd0275d7ed9325f) tdf#98512 sw: add unit test ... and fix the SAL_WARN not to warn spuriously. (cherry picked from commit 20ae3d14187dacce2c2a1d2eab389e6110fe8442) Change-Id: Ic951fc0d811e5cab39989285d34bdd2fff8f95fd Reviewed-on: https://gerrit.libreoffice.org/24664 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index c4adc563952b..9a3ce413fa1d 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -108,6 +108,7 @@ public:
void testFdo75110();
void testFdo75898();
void testFdo74981();
+ void testTdf98512();
void testShapeTextboxSelect();
void testShapeTextboxDelete();
void testCp1000071();
@@ -199,6 +200,7 @@ public:
CPPUNIT_TEST(testFdo75110);
CPPUNIT_TEST(testFdo75898);
CPPUNIT_TEST(testFdo74981);
+ CPPUNIT_TEST(testTdf98512);
CPPUNIT_TEST(testShapeTextboxSelect);
CPPUNIT_TEST(testShapeTextboxDelete);
CPPUNIT_TEST(testCp1000071);
@@ -681,6 +683,44 @@ void SwUiWriterTest::testFdo74981()
CPPUNIT_ASSERT(!pTextNode->HasHints());
}
+void SwUiWriterTest::testTdf98512()
+{
+ SwDoc* pDoc = createDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ SwInputFieldType *const pType(static_cast<SwInputFieldType*>(
+ pWrtShell->GetFieldType(0, RES_INPUTFLD)));
+ SwInputField aField1(pType, OUString("foo"), OUString("bar"), INP_TXT, 0);
+ pWrtShell->Insert(aField1);
+ pWrtShell->SttEndDoc(/*bStt=*/true);
+ SwInputField aField2(pType, OUString("baz"), OUString("quux"), INP_TXT, 0);
+ pWrtShell->Insert(aField2);
+ pWrtShell->SttEndDoc(/*bStt=*/true);
+ pWrtShell->SetMark();
+ pWrtShell->SttEndDoc(/*bStt=*/false);
+ OUString const expected1(
+ OUStringLiteral1<CH_TXT_ATR_INPUTFIELDSTART>() + "foo" + OUStringLiteral1<CH_TXT_ATR_INPUTFIELDEND>());
+ OUString const expected2(
+ OUStringLiteral1<CH_TXT_ATR_INPUTFIELDSTART>() + "baz" + OUStringLiteral1<CH_TXT_ATR_INPUTFIELDEND>()
+ + expected1);
+ CPPUNIT_ASSERT_EQUAL(expected2, pWrtShell->getShellCursor(false)->GetText());
+ sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
+ rUndoManager.Undo();
+ pWrtShell->SttEndDoc(/*bStt=*/true);
+ pWrtShell->SetMark();
+ pWrtShell->SttEndDoc(/*bStt=*/false);
+ CPPUNIT_ASSERT_EQUAL(expected1, pWrtShell->getShellCursor(false)->GetText());
+ rUndoManager.Redo();
+ pWrtShell->SttEndDoc(/*bStt=*/true);
+ pWrtShell->SetMark();
+ pWrtShell->SttEndDoc(/*bStt=*/false);
+ CPPUNIT_ASSERT_EQUAL(expected2, pWrtShell->getShellCursor(false)->GetText());
+ rUndoManager.Undo();
+ pWrtShell->SttEndDoc(/*bStt=*/true);
+ pWrtShell->SetMark();
+ pWrtShell->SttEndDoc(/*bStt=*/false);
+ CPPUNIT_ASSERT_EQUAL(expected1, pWrtShell->getShellCursor(false)->GetText());
+}
+
void SwUiWriterTest::testShapeTextboxSelect()
{
SwDoc* pDoc = createDoc("shape-textbox.odt");