Kaydet (Commit) 76c0d0ab authored tarafından Miklos Vajna's avatar Miklos Vajna

RTF import: adapt getProperties() to createStyleProperties()

Change-Id: I8561aa1532a863bf7f8dd44fbd40e8e0187e4967
üst ed75aa27
{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0
{\stylesheet
{\ql \li0\ri0\sl240\slmult0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f40\fs18\lang1033\langfe1033\cgrid\langnp1033\langfenp1033
\snext0 \sqformat \spriority14 \styrsid11343869 Normal;}
{\*\cs73 \additive \rtlch\fcs1 \ab\af0 \ltrch\fcs0 \b
\sbasedon10 \sqformat \spriority22 \styrsid12276622 Strong;}
}
\pard
{\rtlch\fcs1 \ab\af40\afs18 \ltrch\fcs0
\cs73\b\f41\fs18\lang9\langfe1033\langnp9\insrsid12276622\charrsid12797106 bold}
\par
}
...@@ -1926,6 +1926,12 @@ DECLARE_RTFIMPORT_TEST(testFdo82078, "fdo82078.rtf") ...@@ -1926,6 +1926,12 @@ DECLARE_RTFIMPORT_TEST(testFdo82078, "fdo82078.rtf")
CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(getRun(getParagraph(1), 2), "CharWeight")); CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(getRun(getParagraph(1), 2), "CharWeight"));
} }
DECLARE_RTFIMPORT_TEST(testCsBold, "cs-bold.rtf")
{
// This was awt::FontWeight::NORMAL, i.e. the first run was bold, when it should be bold (applied character style without direct formatting).
CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(getParagraph(1), 1), "CharWeight"));
}
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -458,7 +458,17 @@ writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::getProperties(RT ...@@ -458,7 +458,17 @@ writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::getProperties(RT
RTFReferenceProperties& rCharProps = *(RTFReferenceProperties*)itChar->second.get(); RTFReferenceProperties& rCharProps = *(RTFReferenceProperties*)itChar->second.get();
RTFSprms& rCharStyleSprms = rCharProps.getSprms(); RTFSprms& rCharStyleSprms = rCharProps.getSprms();
for (RTFSprms::Iterator_t itSprm = rCharStyleSprms.begin(); itSprm != rCharStyleSprms.end(); ++itSprm) for (RTFSprms::Iterator_t itSprm = rCharStyleSprms.begin(); itSprm != rCharStyleSprms.end(); ++itSprm)
aStyleSprms.set(itSprm->first, itSprm->second); {
// createStyleProperties() puts properties to rPr, but here we need a flat list.
if (itSprm->first == NS_ooxml::LN_CT_Style_rPr)
{
RTFSprms& rRPrSprms = itSprm->second->getSprms();
for (RTFSprms::Iterator_t itRPrSprm = rRPrSprms.begin(); itRPrSprm != rRPrSprms.end(); ++itRPrSprm)
aStyleSprms.set(itRPrSprm->first, itRPrSprm->second);
}
else
aStyleSprms.set(itSprm->first, itSprm->second);
}
RTFSprms& rCharStyleAttributes = rCharProps.getAttributes(); RTFSprms& rCharStyleAttributes = rCharProps.getAttributes();
for (RTFSprms::Iterator_t itAttr = rCharStyleAttributes.begin(); itAttr != rCharStyleAttributes.end(); ++itAttr) for (RTFSprms::Iterator_t itAttr = rCharStyleAttributes.begin(); itAttr != rCharStyleAttributes.end(); ++itAttr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment