From 89d615360e80a13fff6bc69885e5780d8fedf149 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 29 Jul 2015 09:08:00 +0200 Subject: tdf#89954 sw: let annotation have CH_TXTATR_INWORD placeholder again Regression from commit 0761f81643a6890457e9ef7d913ab5c88c2593a4 (123792: complete annotations on text ranges feature, 2013-12-19), the problem was that while sw wanted CH_TXTATR_INWORD as a placeholder character for anchor positions that do not count as a word boundary, the commit changed GetCharOfTextAttr() so that annotations have CH_TXTATR_BREAKWORD as the placeholder. Fix the problem by reverting the last hunk of sw/source/core/txtnode/thints.cxx changes in that commit. Change-Id: Ia8c97efda9c1e90ae3c27ddb8247e3f3203a63fb --- sw/qa/extras/uiwriter/data/tdf89954.odt | Bin 0 -> 10022 bytes sw/qa/extras/uiwriter/uiwriter.cxx | 22 ++++++++++++++++++++++ sw/source/core/txtnode/thints.cxx | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 sw/qa/extras/uiwriter/data/tdf89954.odt diff --git a/sw/qa/extras/uiwriter/data/tdf89954.odt b/sw/qa/extras/uiwriter/data/tdf89954.odt new file mode 100644 index 000000000000..538d9780a2e6 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf89954.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index ebac88b905d1..8c06b0d22068 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -68,6 +68,7 @@ #include "com/sun/star/text/TextMarkupType.hpp" #include #include +#include static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/"; @@ -136,6 +137,7 @@ public: void testTextTableCellNames(); void testShapeAnchorUndo(); void testDde(); + void testTdf89954(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -197,6 +199,7 @@ public: CPPUNIT_TEST(testTextTableCellNames); CPPUNIT_TEST(testShapeAnchorUndo); CPPUNIT_TEST(testDde); + CPPUNIT_TEST(testTdf89954); CPPUNIT_TEST_SUITE_END(); private: @@ -2041,6 +2044,25 @@ void SwUiWriterTest::testDde() CPPUNIT_ASSERT(xField->getString().endsWith("asdf")); } +void SwUiWriterTest::testTdf89954() +{ + SwDoc* pDoc = createDoc("tdf89954.odt"); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->EndPara(); + SwXTextDocument* pXTextDocument = dynamic_cast(mxComponent.get()); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 't', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'e', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 's', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 't', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, '.', 0); + + SwNodeIndex aNodeIndex(pDoc->GetNodes().GetEndOfContent(), -1); + // Placeholder character for the comment anchor was ^A (CH_TXTATR_BREAKWORD), not (CH_TXTATR_INWORD). + // As a result, autocorrect did not turn the 't' input into 'T'. + OUString aExpected("Tes\xef\xbf\xb9t. Test.", 14, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_EQUAL(aExpected, aNodeIndex.GetNode().GetTextNode()->GetText()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 2b8c0f5a1040..59205c288e8c 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -3446,6 +3446,7 @@ sal_Unicode GetCharOfTextAttr( const SwTextAttr& rAttr ) { case RES_TXTATR_REFMARK: case RES_TXTATR_TOXMARK: + case RES_TXTATR_ANNOTATION: cRet = CH_TXTATR_INWORD; break; @@ -3454,7 +3455,6 @@ sal_Unicode GetCharOfTextAttr( const SwTextAttr& rAttr ) case RES_TXTATR_FTN: case RES_TXTATR_META: case RES_TXTATR_METAFIELD: - case RES_TXTATR_ANNOTATION: { cRet = CH_TXTATR_BREAKWORD; } -- cgit