sw/qa/extras/rtfimport/data/n823675.rtf | 27 ++++++++++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 22 +++++++++++++++++++ writerfilter/CppunitTest_writerfilter_rtftok.mk | 1 writerfilter/source/rtftok/rtfdocumentimpl.cxx | 17 +++++++++++---- 4 files changed, 63 insertions(+), 4 deletions(-)
New commits: commit 0416ee7831fb8682a1ca1b90728aa32b9e976be1 Author: Miklos Vajna <[email protected]> Date: Wed Jun 26 15:47:54 2013 +0200 bnc#823675 RTF import: fix import of numbering bullet associated font There were multiple problems here: - \f had a special handler for the listlevel destination, \af had not - in case of multiple \f or \af, the first one is used for the bullet font - in case only \af is used for the bullet font, its value should be used for \f as well Change-Id: I6631504c1aa9f2e0792a3469a5fdce5b7bd49518 (cherry picked from commit 55162d7422a3b175c7fe9c175e0dec91b1932b6a) Conflicts: sw/qa/extras/rtfimport/rtfimport.cxx diff --git a/sw/qa/extras/rtfimport/data/n823675.rtf b/sw/qa/extras/rtfimport/data/n823675.rtf new file mode 100644 index 0000000..a8a2bd3 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/n823675.rtf @@ -0,0 +1,27 @@ +{\rtf1 +{\fonttbl +{\f0\fbidi \froman\fcharset0\fprq2 +Times New Roman;} +{\f2\fbidi \fmodern\fcharset0\fprq1 +Courier New;} +{\f3\fbidi \froman\fcharset2\fprq2 +Symbol;} +{\fdbminor\f31505\fbidi \froman\fcharset136\fprq2 +PMingLiU;} +} +{\*\listtable +{\list\listtemplateid1917372094 +{\listlevel\levelnfc23 +\leveljc0\levelfollow0\levelstartat0 +{\leveltext\'01\u-3913 ?;} +{\levelnumbers;} +\loch\af3\hich\af3\dbch\af31505 \fi-360\li720\lin720 } +\listid1377391170} +} +{\*\listoverridetable +{\listoverride\listid1377391170\listoverridecount0\ls1} +} +\pard\plain +\ls1 +This\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 84d59c0..9dfb1b6 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -25,6 +25,7 @@ * instead of those above. */ +#include <com/sun/star/awt/FontDescriptor.hpp> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> @@ -153,6 +154,7 @@ public: void testN825305(); void testParaBottomMargin(); void testN823655(); + void testN823675(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -275,6 +277,7 @@ void Test::run() {"n825305.rtf", &Test::testN825305}, {"para-bottom-margin.rtf", &Test::testParaBottomMargin}, {"n823655.rtf", &Test::testN823655}, + {"n823675.rtf", &Test::testN823675}, }; for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) { @@ -1278,6 +1281,25 @@ void Test::testN823655() CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates[0].Second.Value.get<sal_Int32>()); } +void Test::testN823675() +{ + uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aProps; + xLevels->getByIndex(0) >>= aProps; // 1st level + awt::FontDescriptor aFont; + + for (int i = 0; i < aProps.getLength(); ++i) + { + const beans::PropertyValue& rProp = aProps[i]; + + if (rProp.Name == "BulletFont") + aFont = rProp.Value.get<awt::FontDescriptor>(); + } + // This was empty, i.e. no font name was set for the bullet numbering. + CPPUNIT_ASSERT_EQUAL(OUString("Symbol"), aFont.Name); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/CppunitTest_writerfilter_rtftok.mk b/writerfilter/CppunitTest_writerfilter_rtftok.mk index ae981d8..b1ce12f 100644 --- a/writerfilter/CppunitTest_writerfilter_rtftok.mk +++ b/writerfilter/CppunitTest_writerfilter_rtftok.mk @@ -55,6 +55,7 @@ $(eval $(call gb_CppunitTest_use_ure,writerfilter_rtftok)) $(eval $(call gb_CppunitTest_use_components,writerfilter_rtftok,\ configmgr/source/configmgr \ + i18npool/util/i18npool \ svtools/util/svt \ ucb/source/core/ucb1 \ ucb/source/ucp/file/ucpfile1 \ diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 876ab9f..d3f73a6 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2658,7 +2658,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) // Trivial character sprms. switch (nKeyword) { - case RTF_AF: nSprm = (m_aStates.top().bIsCjk ? NS_sprm::LN_CRgFtc1 : NS_sprm::LN_CRgFtc2); break; case RTF_FS: nSprm = NS_sprm::LN_CHps; break; case RTF_AFS: nSprm = NS_sprm::LN_CHpsBi; break; case RTF_ANIMTEXT: nSprm = NS_sprm::LN_CSfxText; break; @@ -2746,6 +2745,11 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) switch (nKeyword) { case RTF_F: + case RTF_AF: + if (nKeyword == RTF_F) + nSprm = NS_sprm::LN_CRgFtc0; + else + nSprm = (m_aStates.top().bIsCjk ? NS_sprm::LN_CRgFtc1 : NS_sprm::LN_CRgFtc2); if (m_aStates.top().nDestinationState == DESTINATION_FONTTABLE || m_aStates.top().nDestinationState == DESTINATION_FONTENTRY) { m_aFontIndexes.push_back(nParam); @@ -2754,16 +2758,21 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) else if (m_aStates.top().nDestinationState == DESTINATION_LISTLEVEL) { RTFSprms aFontSprms; - aFontSprms.set(NS_sprm::LN_CRgFtc0, RTFValue::Pointer_t(new RTFValue(getFontIndex(nParam)))); + aFontSprms.set(nSprm, RTFValue::Pointer_t(new RTFValue(getFontIndex(nParam)))); + // In the context of listlevels, \af seems to imply \f. + if (nKeyword == RTF_AF) + aFontSprms.set(NS_sprm::LN_CRgFtc0, RTFValue::Pointer_t(new RTFValue(getFontIndex(nParam)))); RTFSprms aRunPropsSprms; aRunPropsSprms.set(NS_ooxml::LN_EG_RPrBase_rFonts, RTFValue::Pointer_t(new RTFValue(RTFSprms(), aFontSprms))); - m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Lvl_rPr, RTFValue::Pointer_t(new RTFValue(RTFSprms(), aRunPropsSprms))); + // If there are multiple \f or \af tokens, only handle the first one. + if (!m_aStates.top().aTableSprms.find(NS_ooxml::LN_CT_Lvl_rPr)) + m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Lvl_rPr, RTFValue::Pointer_t(new RTFValue(RTFSprms(), aRunPropsSprms))); } else { int nFontIndex = getFontIndex(nParam); RTFValue::Pointer_t pValue(new RTFValue(nFontIndex)); - m_aStates.top().aCharacterSprms.set(NS_sprm::LN_CRgFtc0, pValue); + m_aStates.top().aCharacterSprms.set(nSprm, pValue); m_aStates.top().nCurrentEncoding = getEncoding(nFontIndex); } break; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
