diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-05-12 16:31:53 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-05-12 18:29:07 +0200 |
commit | 32dab3228cd315437efe0c5b850d116235eaa797 (patch) | |
tree | fe0a2557e9cfeee968d4cbdc1d0b34de5603f5da /sw/qa/extras/ww8export | |
parent | 3f318b314eb161d293990efa401a626ed8017c87 (diff) |
sw content controls: fixes for the ending dummy char
- make sure the DOC/RTF export doesn't write the dummy char as-is
- let "enter" only insert a linebreak while inside a content control, to
ensure that the starting and ending dummy char stays inside the same
text node
- let deletion of the dummy character at the end behave the same as the
start dummy character: if trying to delete that single character, then
just move the cursor, don't delete it
- reject document insertion in the middle of a content control, similar
to input fields
Change-Id: I9b54ef50261e6b17f38eadadacfe1e1111199e96
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134239
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa/extras/ww8export')
-rw-r--r-- | sw/qa/extras/ww8export/ww8export2.cxx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx index d6523f172f57..40311d9e5298 100644 --- a/sw/qa/extras/ww8export/ww8export2.cxx +++ b/sw/qa/extras/ww8export/ww8export2.cxx @@ -1071,6 +1071,34 @@ DECLARE_WW8EXPORT_TEST(testTdf118412, "tdf118412.doc") CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1251), nBottomMargin); } +CPPUNIT_TEST_FIXTURE(Test, testContentControlExport) +{ + // Given a document with a (rich text) content control: + mxComponent = loadFromDesktop("private:factory/swriter"); + uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XText> xText = xTextDocument->getText(); + uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); + xText->insertString(xCursor, "test", /*bAbsorb=*/false); + xCursor->gotoStart(/*bExpand=*/false); + xCursor->gotoEnd(/*bExpand=*/true); + uno::Reference<text::XTextContent> xContentControl( + xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); + xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); + + // When saving that document to DOC and loading it back: + reload("MS Word 97", ""); + + // Then make sure the dummy character at the end is filtered out: + OUString aBodyText = getBodyText(); + // Without the accompanying fix in place, this test would have failed: + // - Expected: test + // - Actual : test<space> + // i.e. the CH_TXTATR_BREAKWORD at the end was written, then the import replaced that with a + // space. + CPPUNIT_ASSERT_EQUAL(OUString("test"), aBodyText); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |