sw/qa/extras/rtfexport/data/tdf161864.rtf | 20 ++++++++++++++++ sw/qa/extras/rtfexport/rtfexport8.cxx | 23 +++++++++++++++++++ sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 17 ++++++++++++-- 3 files changed, 58 insertions(+), 2 deletions(-)
New commits: commit 0b7201bc4299f76c8a3e085f213ffeb7ea9e8556 Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Tue Jul 2 11:14:20 2024 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Mon Jul 15 21:12:06 2024 +0200 tdf#161864 Apply character properties to SYMBOL field In RTF import character attributes are applied to symbols imported from ield{ SYMBOL }. Change-Id: I088c47e799380813dce19fd9823cdba6b8048af1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169864 Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> Tested-by: Jenkins diff --git a/sw/qa/extras/rtfexport/data/tdf161864.rtf b/sw/qa/extras/rtfexport/data/tdf161864.rtf new file mode 100755 index 000000000000..785399acf3b9 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/tdf161864.rtf @@ -0,0 +1,20 @@ +{ tf1nsi\deff0deflang1025 +{onttbl +{2swissprq2charset0 Liberation Serif;} +{10nilprq2charset0 Mangal;} +} +{+{\stylesheet{\s0\snext0 owidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}+{\s15\sbasedon0\snext16\sb240\sa120\keepn\dbchf5\dbchf6fs28\loch 2s28 Heading;} +{\s16\sbasedon0\snext16\sb0\sa120 Text body;} +{\s17\sbasedon16\snext17\sb0\sa120\dbchf7 List;} +{\s18\sbasedon0\snext18\sb120\sa120 oline\i\dbchf7fs24is24 Caption;} +{\s19\sbasedon0\snext19 oline\dbchf7 Index;} +}{\info{uthor trent}{+iewscale100 +{\*\pgdsctbl +{\pgdsc0\pgdscuse195\pgwsxn11906\pghsxn16838\marglsxn1440\margrsxn1440\margtsxn1440\margbsxn1440\pgdscnxt0 Default;}} + ormshade{\*\pgdscno0}\paperh16838\paperw11906\margl1440\margr1440\margt1440\margb1440\sectd\sbknone\sectunlocked1\pgndec\pgwsxn11906\pghsxn16838\marglsxn1440\margrsxn1440\margtsxn1440\margbsxn1440 tnbjtnstart1tnrstconttnnarenddocftnrstcontftnstart1ftnnrlc +\pgndec\pard\plain \s0 owidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}+s8 {ield{\*ldinst SYMBOL 108 \f "Liberation Serif" \s 8}{ldrslt10s8}} First bullet in 4pt s22 {ield{\*ldinst SYMBOL 108 \f "Liberation Serif" \s 8}{ldrslt10s22}} second bullet in 11pts32 {ield{\*ldinst SYMBOL 108 \f "Liberation Serif" \s 16}{ ldrslt10s32}} last one in 16pt} +\par } diff --git a/sw/qa/extras/rtfexport/rtfexport8.cxx b/sw/qa/extras/rtfexport/rtfexport8.cxx index 28b755cd8f4a..a4457ef13aa8 100644 --- a/sw/qa/extras/rtfexport/rtfexport8.cxx +++ b/sw/qa/extras/rtfexport/rtfexport8.cxx @@ -582,6 +582,29 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf158982) verify(); } +CPPUNIT_TEST_FIXTURE(Test, testTdf161864) +{ + auto verify = [this]() { + //check bullet size at position 0, 22, 45 with 4/11/16 pt + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XText> xText = xTextDocument->getText(); + uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor(); + uno::Reference<beans::XPropertySet> xPropSet(xCursor, uno::UNO_QUERY); + xCursor->goRight(1, true); + CPPUNIT_ASSERT_EQUAL(uno::Any(float(4)), xPropSet->getPropertyValue(u"CharHeight"_ustr)); + xCursor->goRight(21, false); + xCursor->goRight(1, true); + CPPUNIT_ASSERT_EQUAL(uno::Any(float(11)), xPropSet->getPropertyValue(u"CharHeight"_ustr)); + xCursor->goRight(22, false); + xCursor->goRight(1, true); + CPPUNIT_ASSERT_EQUAL(uno::Any(float(16)), xPropSet->getPropertyValue(u"CharHeight"_ustr)); + }; + createSwDoc("tdf161864.rtf"); + verify(); + saveAndReload(mpFilter); + verify(); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 00c098a11b8e..5e01071bfa62 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -8316,8 +8316,6 @@ void DomainMapper_Impl::CloseFieldCommand() sFont = sFont.copy(0,sFont.getLength()-1); } - - if (xTextAppend.is()) { uno::Reference< text::XText > xText = xTextAppend->getText(); @@ -8336,6 +8334,21 @@ void DomainMapper_Impl::CloseFieldCommand() xProp->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME_COMPLEX), aVal); } + PropertyMapPtr pCharTopContext = GetTopContextOfType(CONTEXT_CHARACTER); + if (pCharTopContext.is()) + { + uno::Sequence<beans::PropertyValue> aValues + = pCharTopContext->GetPropertyValues( + /*bCharGrabBag=*/!IsInComments()); + OUString sFontName = getPropertyName(PROP_CHAR_FONT_NAME); + for (const beans::PropertyValue& rProperty : aValues) + { + if (!bHasFont || !rProperty.Name.startsWith(sFontName)) + xProp->setPropertyValue(rProperty.Name, rProperty.Value); + } + + } + } } }