diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-06-13 23:49:59 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-06-17 18:42:06 +0200 |
commit | 6c0e1270889deb513f961f864dfc1c02ee8705f4 (patch) | |
tree | 3022b60ca3b2aedcfcb3b528efc88cc77b1c7f20 | |
parent | 8ba3116a8f09650b47aa69cf3d828ca0b5f6b51e (diff) |
fdo#70578: writerfilter RTF import: by default style is para style 0
quoth the spec:
"For <style>, both <styledef> and <stylename> are optional; the default
is paragraph style 0."
Of course in order to do that we need to add support for at least
recognizing the \dsN and \tsN keywords to override the default, so that
table styles don't become paragraph styles.
Change-Id: Ic100768581f9e8c327063ff776fbd61ac4242483
-rw-r--r-- | sw/qa/extras/rtfimport/data/fdo70578.rtf | 11 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 11 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 24 |
3 files changed, 46 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo70578.rtf b/sw/qa/extras/rtfimport/data/fdo70578.rtf new file mode 100644 index 000000000000..b2a4ea826a7d --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo70578.rtf @@ -0,0 +1,11 @@ +{\rtf1\ansi +{\fonttbl +{\f30\fswiss\fcharset0\fprq2{\*\panose 020b0706040902060204}Haettenschweiler;} +} +{\stylesheet +{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;} +{\s16\qc \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 +\f30\fs44\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext16 Subtitle;} +} +\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 2eba05aa0861..3699db8ded84 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1143,6 +1143,17 @@ DECLARE_RTFIMPORT_TEST(testFdo62044, "fdo62044.rtf") CPPUNIT_ASSERT_EQUAL(10.f, getProperty<float>(xPropertySet, "CharHeight")); // Was 18, i.e. reset back to original value. } +DECLARE_RTFIMPORT_TEST(testFdo70578, "fdo70578.rtf") +{ + // Style without explicit \s0 was not imported as the default style + uno::Reference<beans::XPropertySet> xPropertySet( + getStyles("ParagraphStyles")->getByName("Subtitle"), uno::UNO_QUERY); + uno::Reference<style::XStyle> xStyle(xPropertySet, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Standard"), xStyle->getParentStyle()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPropertySet, "ParaTopMargin")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPropertySet, "ParaBottomMargin")); +} + DECLARE_RTFIMPORT_TEST(testPoshPosv, "posh-posv.rtf") { CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty<sal_Int16>(getShape(1), "HoriOrient")); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 0f29107a786f..2d2dad7be690 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -3609,6 +3609,23 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_RPrBase_rStyle, RTFValue::Pointer_t(new RTFValue(aName))); } break; + case RTF_DS: + if (m_aStates.top().nDestinationState == DESTINATION_STYLESHEET || m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY) + { + m_nCurrentStyleIndex = nParam; + RTFValue::Pointer_t pValue(new RTFValue(-42)); // TODO no value in enum StyleType? + m_aStates.top().aTableAttributes.set( + NS_ooxml::LN_CT_Style_type, pValue); // section style + } + break; + case RTF_TS: + if (m_aStates.top().nDestinationState == DESTINATION_STYLESHEET || m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY) + { + m_nCurrentStyleIndex = nParam; + RTFValue::Pointer_t pValue(new RTFValue(-43)); // FIXME the correct value would be 3 but maybe table styles mess things up in dmapper, be cautious and disable them for now + m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Style_type, pValue); // table style + } + break; case RTF_DEFF: m_nDefaultFontIndex = nParam; break; @@ -4651,6 +4668,13 @@ int RTFDocumentImpl::pushState() break; case DESTINATION_STYLESHEET: m_aStates.top().nDestinationState = DESTINATION_STYLEENTRY; + { + // the *default* is \s0 i.e. paragraph style default + // this will be overwritten by \sN \csN \dsN \tsN + m_nCurrentStyleIndex = 0; + RTFValue::Pointer_t pValue(new RTFValue(1)); + m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Style_type, pValue); + } break; case DESTINATION_FIELDRESULT: case DESTINATION_SHAPETEXT: |