diff options
author | Oliver Specht <oliver.specht@cib.de> | 2024-07-02 11:14:20 +0200 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2024-07-15 21:12:06 +0200 |
commit | 0b7201bc4299f76c8a3e085f213ffeb7ea9e8556 (patch) | |
tree | 4947b2ed1dec6cd7ffbc948313b0e331ae28398b | |
parent | 6113d5dc45232b602bee0e68cf7560d0b8656546 (diff) |
tdf#161864 Apply character properties to SYMBOL field
In RTF import character attributes are applied to symbols
imported from \field{ SYMBOL }.
Change-Id: I088c47e799380813dce19fd9823cdba6b8048af1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169864
Tested-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Tested-by: Jenkins
-rwxr-xr-x | sw/qa/extras/rtfexport/data/tdf161864.rtf | 20 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport8.cxx | 23 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 17 |
3 files changed, 58 insertions, 2 deletions
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 @@ +{\rtf1\ansi\deff0\adeflang1025
+{\fonttbl
+{\f2\fswiss\fprq2\fcharset0 Liberation Serif;}
+{\f10\fnil\fprq2\fcharset0 Mangal;}
+}
+{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
+{\stylesheet{\s0\snext0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang3081 Normal;}
+{\s15\sbasedon0\snext16\sb240\sa120\keepn\dbch\af5\dbch\af6\afs28\loch\f2\fs28 Heading;}
+{\s16\sbasedon0\snext16\sb0\sa120 Text body;}
+{\s17\sbasedon16\snext17\sb0\sa120\dbch\af7 List;}
+{\s18\sbasedon0\snext18\sb120\sa120\noline\i\dbch\af7\afs24\ai\fs24 Caption;}
+{\s19\sbasedon0\snext19\noline\dbch\af7 Index;}
+}{\info{\author trent}{\creatim\yr2012\mo11\dy30\hr14\min38}{\revtim\yr2012\mo11\dy30\hr14\min38}{\printim\yr0\mo0\dy0\hr0\min0}{\comment LibreOffice}{\vern3600}}\deftab720
+\viewscale100
+{\*\pgdsctbl
+{\pgdsc0\pgdscuse195\pgwsxn11906\pghsxn16838\marglsxn1440\margrsxn1440\margtsxn1440\margbsxn1440\pgdscnxt0 Default;}}
+\formshade{\*\pgdscno0}\paperh16838\paperw11906\margl1440\margr1440\margt1440\margb1440\sectd\sbknone\sectunlocked1\pgndec\pgwsxn11906\pghsxn16838\marglsxn1440\margrsxn1440\margtsxn1440\margbsxn1440\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
+\pgndec\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af8\langfe2052\dbch\af6\afs24\alang1081\loch\f0\fs24\lang3081\sl276\slmult1\ql\widctlpar\faauto\li0\ri0\lin0\rin0\fi0\sb0\sa200{{\*\bkmkstart Text11}{\*\bkmkstart Text1}{\*\bkmkstart Text1}{\*\bkmkend Text1}\langfe255\afs22\alang1025\rtlch \ltrch\loch\fs22\lang255\loch\f2
+\fs8 {\field{\*\fldinst SYMBOL 108 \\f "Liberation Serif" \\s 8}{\fldrslt\f10\fs8}} First bullet in 4pt \fs22 {\field{\*\fldinst SYMBOL 108 \\f "Liberation Serif" \\s 8}{\fldrslt\f10\fs22}} second bullet in 11pt\fs32 {\field{\*\fldinst SYMBOL 108 \\f "Liberation Serif" \\s 16}{\fldrslt\f10\fs32}} 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); + } + + } + } } } |