diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-07-21 08:07:27 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-07-21 11:18:36 +0200 |
commit | 1dce9ee7e12871ee63434499db805e806b9e9d3c (patch) | |
tree | ff9706b895c0aa79489c1ff624116ed10ffd4c1e /sw/qa/core | |
parent | bc6e6fe77f089ccfc6b94bbf80538f674e412118 (diff) |
sw content controls, plain text: apply formatting to the entire contents
The difference between normal (rich text) content control and a plain
text one is that if you try to format a subset of the contents, that's
possible in the rich text case, but the plain text case extends the
formatted range to the entire content control.
Handle this in SwTextNode::InsertHint(), similar to how it's done for
input fields.
Change-Id: I9a1ad0095f0ca810da24d5c4ce4aa48d1ac59225
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137280
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa/core')
-rw-r--r-- | sw/qa/core/unocore/unocore.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 9ec8b0a340b1..f588821181c0 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -19,6 +19,7 @@ #include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> #include <vcl/errinf.hxx> +#include <editeng/wghtitem.hxx> #include <wrtsh.hxx> #include <unotextrange.hxx> @@ -710,6 +711,25 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlPlainText) = static_cast<SwFormatContentControl&>(pTextContentControl->GetAttr()); std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl(); CPPUNIT_ASSERT(pContentControl->GetPlainText()); + + // Now check if the char index range 2-4 is extended to 0-6 when we apply formatting: + pWrtShell->SttEndDoc(/*bStt=*/true); + // Select "es" from "<dummy>test<dummy>". + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 2, /*bBasicCall=*/false); + SfxItemSetFixed<RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT> aSet(pWrtShell->GetAttrPool()); + SvxWeightItem aItem(WEIGHT_BOLD, RES_CHRATR_WEIGHT); + aSet.Put(aItem); + pWrtShell->SetAttrSet(aSet); + pAttr = pTextNode->GetTextAttrAt(2, RES_TXTATR_AUTOFMT); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 + // - Actual : 2 + // i.e. the plain text content control now had 3 portions (<dummy>t<b>es</b>t<dummy>), instead + // of one (<b><dummy>test<dummy></b>). + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), pAttr->GetStart()); + CPPUNIT_ASSERT(pAttr->End()); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6), *pAttr->End()); } CPPUNIT_PLUGIN_IMPLEMENT(); |