summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-06-26 15:47:54 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-10-22 16:00:53 +0200
commit884ea3678a43adadb065cd00df6b87f0695f8e52 (patch)
treeee951c5ce88189c6d8e80ed0dd26186d0b7edd36
parentfcbb426f2536e86aa4c3281825bc7b9a38ba43ba (diff)
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 (cherry picked from commit 55162d7422a3b175c7fe9c175e0dec91b1932b6a) Conflicts: sw/qa/extras/rtfimport/rtfimport.cxx Change-Id: I6631504c1aa9f2e0792a3469a5fdce5b7bd49518
-rw-r--r--sw/qa/extras/rtfimport/data/n823675.rtf27
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx22
-rw-r--r--writerfilter/CppunitTest_writerfilter_rtftok.mk1
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx17
4 files changed, 63 insertions, 4 deletions
diff --git a/sw/qa/extras/rtfimport/data/n823675.rtf b/sw/qa/extras/rtfimport/data/n823675.rtf
new file mode 100644
index 000000000000..a8a2bd313478
--- /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 687baacc6f48..7c27a3480ef2 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -6,6 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#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>
@@ -161,6 +162,7 @@ public:
void testFdo68291();
void testFdo69384();
void testFdo70221();
+ void testN823675();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -306,6 +308,7 @@ void Test::run()
{"fdo68291.odt", &Test::testFdo68291},
{"hello.rtf", &Test::testFdo69384},
{"fdo70221.rtf", &Test::testFdo70221},
+ {"n823675.rtf", &Test::testN823675},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1488,6 +1491,25 @@ void Test::testFdo70221()
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
}
+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 1043b7a0a8e6..13691197ded2 100644
--- a/writerfilter/CppunitTest_writerfilter_rtftok.mk
+++ b/writerfilter/CppunitTest_writerfilter_rtftok.mk
@@ -38,6 +38,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 5e7ea2ac984f..3cb949d9d59e 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2719,7 +2719,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;
@@ -2850,6 +2849,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);
@@ -2858,16 +2862,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;