summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2024-03-27 15:41:50 +0100
committerMiklos Vajna <vmiklos@collabora.com>2024-03-27 18:03:19 +0100
commit261999bc552516a7dae0f96895259485e9ac77a2 (patch)
tree491bc250cc2746f6019be4eaca344185c5861010
parent6ddc398095bcbb288b1ef1ec3f01a52a615672f8 (diff)
tdf#109272 sw: add form filling testcase
Open the document, press tab to switch to a field, start typing, nothing shows up. Looking at the doc model dump, it turns out we inserted characters between the field start and the field separator dummy characters, instead of the field separator and the field end ones, which is quite bad. Turns out that in the meantime commit c80606bb23fd42e41710d70a96b7ffaf948384a6 (tdf#109272: make sure that Delete / Backspace move cursor correctly, 2024-01-18) fixed this, kind of by accident: the comment says the motivation there was change tracking. Add a testcase to to make sure this now continues to work. Change-Id: I1a300d8064f7c2a30aafeefc6cb5612bfcd9a06a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165368 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/inc/crsrsh.hxx2
-rw-r--r--sw/qa/core/edit/data/delete-sel-normalize.odtbin0 -> 9769 bytes
-rw-r--r--sw/qa/core/edit/edit.cxx25
3 files changed, 26 insertions, 1 deletions
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index e330974a7dcc..5b0031882487 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -734,7 +734,7 @@ public:
bool GotoFormatContentControl(const SwFormatContentControl& rContentControl);
- void GotoFormControl(bool bNext);
+ SW_DLLPUBLIC void GotoFormControl(bool bNext);
static SwTextField* GetTextFieldAtPos(
const SwPosition* pPos,
diff --git a/sw/qa/core/edit/data/delete-sel-normalize.odt b/sw/qa/core/edit/data/delete-sel-normalize.odt
new file mode 100644
index 000000000000..d7113204ba80
--- /dev/null
+++ b/sw/qa/core/edit/data/delete-sel-normalize.odt
Binary files differ
diff --git a/sw/qa/core/edit/edit.cxx b/sw/qa/core/edit/edit.cxx
index 444887fbb0df..fa8fefa910c1 100644
--- a/sw/qa/core/edit/edit.cxx
+++ b/sw/qa/core/edit/edit.cxx
@@ -56,6 +56,31 @@ CPPUNIT_TEST_FIXTURE(Test, testAutocorrect)
emulateTyping(*pTextDoc, u"But not now - with ");
}
+CPPUNIT_TEST_FIXTURE(Test, testDeleteSelNormalize)
+{
+ // Given a read-only document with a fillable form, the placeholder text is selected:
+ createSwDoc("delete-sel-normalize.odt");
+ SwDoc* pDoc = getSwDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->SttEndDoc(/*bStt=*/true);
+ pWrtShell->GotoFormControl(/*bNext=*/true);
+
+ // When you press 'delete' to type some content instead:
+ pWrtShell->DelRight();
+
+ // Then make sure the position after the delete is correct:
+ SwPosition& rCursor = *pWrtShell->GetCursor()->GetPoint();
+ // The full text is "key <field start><field separator><field end>", so this marks the position
+ // after the field separator but before the field end.
+ sal_Int32 nExpectedCharPos = strlen("key **");
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 6
+ // - Actual : 5
+ // so we started to type between the field start and the field separator, nothing was visible on
+ // the screen.
+ CPPUNIT_ASSERT_EQUAL(nExpectedCharPos, rCursor.nContent.GetIndex());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */