summaryrefslogtreecommitdiff
path: root/sw/qa/extras/rtfimport
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-06-17 18:40:04 +0200
committerMichael Stahl <mstahl@redhat.com>2014-06-17 18:42:07 +0200
commit1be0a3fa9ebb22b607c54b47739d4467acfed259 (patch)
tree2bbc7ba198f537bb058fb140a70b30146c8e2074 /sw/qa/extras/rtfimport
parent6c0e1270889deb513f961f864dfc1c02ee8705f4 (diff)
n#825305: writerfilter RTF import: override style properties like Word
It would certainly be immediately obvious to any reader of the RTF spec that \sN will apply the style with index N to the current paragraph. But actually, that is not what Word does when it reads \sN... what it really does is to apply the style with index N, and then for every attribute in that style, apply the same attribute with a default value to the paragraph, effectively overriding what's in the style. If that doesn't make any sense to you, well, have you heard the joke about how many Microsoft engineers it takes to change a light bulb? Also, \pard apparently implies \s0. To implement that, change RTFSprms::deduplicate() to recursively look for style SPRMs that are missing in the properties, and put in default ones, currently just for 2 keywords \sa and \sb. This requires changing deduplicate() to be const and return a new value, since it is no longer idempotent, as the erased SPRMs would get defaulted on the next run. While at it, fix RTFValue::equals() which did not compare m_sValue. This fixes the testParaBottomMargin test that was broken by the fix for fdo#70578. Change-Id: I4ced38628d76f6c41b488d608a804883493ff00b
Diffstat (limited to 'sw/qa/extras/rtfimport')
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx10
1 files changed, 10 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 3699db8ded84..79a449449c0e 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1173,8 +1173,18 @@ DECLARE_RTFIMPORT_TEST(testN825305, "n825305.rtf")
DECLARE_RTFIMPORT_TEST(testParaBottomMargin, "para-bottom-margin.rtf")
{
+ uno::Reference<beans::XPropertySet> xPropertySet(
+ getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(353),
+ getProperty<sal_Int32>(xPropertySet, "ParaBottomMargin"));
+
// This was 353, i.e. bottom margin of the paragraph was 0.35cm instead of 0.
+ // The reason why this is 0 despite the default style containing \sa200
+ // is that Word will actually interpret \sN (or \pard which apparently
+ // implies \s0) as "set style N and for every attribute of that style,
+ // set an attribute with default value on the paragraph"
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), getProperty<sal_Int32>(getParagraph(1), "ParaTopMargin"));
}
DECLARE_RTFIMPORT_TEST(testN823655, "n823655.rtf")