summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorOliver Specht <oliver.specht@cib.de>2025-02-19 14:18:39 +0100
committerGabor Kelemen <gabor.kelemen.extern@allotropia.de>2025-02-21 19:42:00 +0100
commit330efa9db365fbc28d825de2fe14162a692ffb2f (patch)
treecc4a1e64562872c5d024c43ac27ba4b5b35eee25 /sw
parentf70f5fad59e55abd15209128d7f14b3015e2958b (diff)
tdf#165333 RTF: import SYMBOL fields correctly
Úsing XTextAppend to insert SYMBOL fields fixes wrongly extended character properties. Change-Id: I14f187e63e2c72d3c2cf27ab99cdced108797057 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181892 Tested-by: Jenkins Tested-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de> Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfimport/data/165333.rtf12
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx11
-rw-r--r--sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx58
3 files changed, 56 insertions, 25 deletions
diff --git a/sw/qa/extras/rtfimport/data/165333.rtf b/sw/qa/extras/rtfimport/data/165333.rtf
new file mode 100644
index 000000000000..7834bfd178ef
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/165333.rtf
@@ -0,0 +1,12 @@
+{\rtf1
+
+{\stylesheet
+{\ql\fs72 Normal;}
+}
+
+\pard{\rtlch\fcs1 \ab\af40\afs12 \ltrch\fcs0
+\v\f40\fs12\cf1\insrsid12669988\charrsid9449667 \line }
+{\rtlch\fcs1 \af40\afs10 \ltrch\fcs0 \f40\fs10\insrsid12669988\charrsid11105138
+{\field{\*\fldinst SYMBOL 253 \\f "Wingdings" \\s 5}{\fldrslt\f10\fs10}}}\par
+
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 7a83bffe7b35..6b854306dbe3 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1984,6 +1984,17 @@ CPPUNIT_TEST_FIXTURE(Test, test118465Tdf)
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), getProperty<sal_Int32>(xTable, u"HeaderRowCount"_ustr));
}
+CPPUNIT_TEST_FIXTURE(Test, test165333Tdf)
+{
+ createSwDoc("165333.rtf");
+ uno::Reference<text::XTextRange> const xRun1(
+ getRun(uno::Reference<text::XTextRange>(getParagraphOrTable(1), uno::UNO_QUERY), 1));
+ CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xRun1, u"CharHidden"_ustr));
+ uno::Reference<text::XTextRange> const xRun2(
+ getRun(uno::Reference<text::XTextRange>(getParagraphOrTable(1), uno::UNO_QUERY), 2));
+ CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xRun2, u"CharHidden"_ustr));
+}
+
// tests should only be added to rtfIMPORT *if* they fail round-tripping in rtfEXPORT
} // 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 aff98b7790f0..393c451c5f9a 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
@@ -8445,38 +8445,46 @@ void DomainMapper_Impl::CloseFieldCommand()
if (xTextAppend.is())
{
- uno::Reference< text::XText > xText = xTextAppend->getText();
- uno::Reference< text::XTextCursor > xCrsr = xText->createTextCursor();
- if (xCrsr.is())
+ uno::Sequence<beans::PropertyValue> aValues(bHasFont ? 4 : 3);
+ beans::PropertyValue aCharSetVal;
+ aCharSetVal.Name = getPropertyName(PROP_CHAR_FONT_CHAR_SET);
+ aCharSetVal.Value <<= awt::CharSet::SYMBOL;
+ aValues.getArray()[0] = std::move(aCharSetVal);
+ if(bHasFont)
{
- xCrsr->gotoEnd(false);
- xText->insertString(xCrsr, sSymbol, true);
- uno::Reference< beans::XPropertySet > xProp( xCrsr, uno::UNO_QUERY );
- xProp->setPropertyValue(getPropertyName(PROP_CHAR_FONT_CHAR_SET), uno::Any(awt::CharSet::SYMBOL));
- if(bHasFont)
- {
- uno::Any aVal( sFont );
- xProp->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME), aVal);
- xProp->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME_ASIAN), aVal);
- xProp->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME_COMPLEX), aVal);
+ beans::PropertyValue aFontVal1;
+ beans::PropertyValue aFontVal2;
+ beans::PropertyValue aFontVal3;
+
+ aFontVal1.Name = getPropertyName(PROP_CHAR_FONT_NAME);
+ aFontVal1.Value <<= sFont;
+ aFontVal2.Name = getPropertyName(PROP_CHAR_FONT_NAME_ASIAN);
+ aFontVal2.Value <<= sFont;
+ aFontVal3.Name = getPropertyName(PROP_CHAR_FONT_NAME_COMPLEX);
+ aFontVal3.Value <<= sFont;
+
+ aValues.getArray()[1] = std::move(aFontVal1);
+ aValues.getArray()[2] = std::move(aFontVal2);
+ aValues.getArray()[3] = std::move(aFontVal3);
+ }
- }
- PropertyMapPtr pCharTopContext = GetTopContextOfType(CONTEXT_CHARACTER);
- if (pCharTopContext.is())
+ PropertyMapPtr pCharTopContext = GetTopContextOfType(CONTEXT_CHARACTER);
+ if (pCharTopContext.is())
+ {
+ uno::Sequence<beans::PropertyValue> aContextValues
+ = pCharTopContext->GetPropertyValues(
+ /*bCharGrabBag=*/!IsInComments());
+ OUString sFontName = getPropertyName(PROP_CHAR_FONT_NAME);
+ for (const beans::PropertyValue& rProperty : aContextValues)
{
- 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))
{
- if (!bHasFont || !rProperty.Name.startsWith(sFontName))
- xProp->setPropertyValue(rProperty.Name, rProperty.Value);
+ aValues.realloc(aValues.getLength() + 1);
+ aValues.getArray()[aValues.getLength() - 1] = rProperty;
}
-
}
-
}
+ xTextAppend->appendTextPortion(sSymbol, aValues);
}
}
}