summaryrefslogtreecommitdiff
path: root/sw/qa/extras/unowriter
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-05-12 14:59:43 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2021-05-12 19:18:26 +0200
commitc5e5467f6a13aba68b4706a4d7feb130e824bcc6 (patch)
treec5b382a9d5d50f894e96b42611fb570a3f094234 /sw/qa/extras/unowriter
parentf02a56b0f2a66b583e52dd91b548c666b3d4693c (diff)
tdf#137810 sw: fix SwXNumberingRules setting CharStyleName
During ODF import, due to removal of the pDocShell parameter, this hits else rCharStyleName = sCharFormatName; while setting the "CharStyleName" property and later GetNumberingRuleByIndex() prefers m_sNewCharStyleNames over the format set in the SwCharFormat?? Also, "BulletFontName" has a similar problem; otoh "HeadingStyleName" only makes sense on chapter numbering. The m_pDoc and m_pDocShell members are such a WTF. (regression from ae0e4a6ba9be2fa99ac2be8e20157806e36209b2) Change-Id: I9d4d4cd7aeb7e6e29221d53facaff213fd4e35a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115495 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw/qa/extras/unowriter')
-rw-r--r--sw/qa/extras/unowriter/unowriter.cxx33
1 files changed, 33 insertions, 0 deletions
diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx
index f0ed93e85941..dbee7d40a685 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -959,6 +959,39 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testImageCommentAtChar)
}
}
+CPPUNIT_TEST_FIXTURE(SwUnoWriter, testChapterNumberingCharStyle)
+{
+ loadURL("private:factory/swriter", nullptr);
+
+ uno::Reference<lang::XMultiServiceFactory> xDoc(mxComponent, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xStyle(
+ xDoc->createInstance("com.sun.star.style.CharacterStyle"), uno::UNO_QUERY);
+ uno::Reference<container::XNamed> xStyleN(xStyle, uno::UNO_QUERY);
+ xStyle->setPropertyValue("CharColor", uno::makeAny(sal_Int32(0x00FF0000)));
+ uno::Reference<style::XStyleFamiliesSupplier> xSFS(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XNameContainer> xStyles(
+ xSFS->getStyleFamilies()->getByName("CharacterStyles"), uno::UNO_QUERY);
+ xStyles->insertByName("red", uno::makeAny(xStyle));
+
+ uno::Reference<text::XChapterNumberingSupplier> xCNS(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexReplace> xOutline(xCNS->getChapterNumberingRules());
+ {
+ comphelper::SequenceAsHashMap hashMap(xOutline->getByIndex(0));
+ hashMap["CharStyleName"] <<= OUString("red");
+ uno::Sequence<beans::PropertyValue> props;
+ hashMap >> props;
+ xOutline->replaceByIndex(0, uno::makeAny(props));
+ }
+ // now rename the style
+ xStyleN->setName("reddishred");
+ {
+ comphelper::SequenceAsHashMap hashMap(xOutline->getByIndex(0));
+
+ // tdf#137810 this failed, was old value "red"
+ CPPUNIT_ASSERT_EQUAL(OUString("reddishred"), hashMap["CharStyleName"].get<OUString>());
+ }
+}
+
CPPUNIT_TEST_FIXTURE(SwUnoWriter, testViewCursorPageStyle)
{
// Load a document with 2 pages, but a single paragraph.