summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-06-13 23:49:59 +0200
committerMichael Stahl <mstahl@redhat.com>2014-06-17 18:44:31 +0200
commit051e6fefda2411d93cb4bbe4cb3bbbd60861d8fc (patch)
tree77d12f2bf458bcfb87c963ced600a132a85f7371
parentc8921d9ef99b46761a630711ab17b3022d018db5 (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 (cherry picked from commit 6c0e1270889deb513f961f864dfc1c02ee8705f4)
-rw-r--r--sw/qa/extras/rtfimport/data/fdo70578.rtf11
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx11
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx24
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 8c8f0381a3ef..2e4c9335e8f9 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1138,6 +1138,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 aafc9726bed5..d8ad8d0f718b 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3624,6 +3624,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;
@@ -4666,6 +4683,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: