sw/qa/extras/rtfimport/data/fdo82071.rtf | 46 +++++++++++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 11 +++++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 5 ++ 3 files changed, 62 insertions(+)
New commits: commit 75d0cbb2e8f737e4c1721285a172618a1af78135 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Oct 14 22:09:03 2014 +0200 fdo#82071 RTF import: get rid of unexpected underlining in TOC field Regression from commit 9679e9c23216decb5f9f25f85b04cb3f25211111 (fdo#69649 Fix for pre-rendered Table Of Contents, 2013-12-30), now that we handle hand-edited TOC, it's necessary to properly track correctly if a property came from a style or as a direct formatting. Fix RTFDocumentImpl::getProperties() to detect direct formatting that cames from a char style and would result in attribute tokens. Change-Id: Iab5a14770de43249961c280a5dc698200abc8f49 diff --git a/sw/qa/extras/rtfimport/data/fdo82071.rtf b/sw/qa/extras/rtfimport/data/fdo82071.rtf new file mode 100644 index 0000000..776c2a9 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo82071.rtf @@ -0,0 +1,46 @@ +{\rtf1 +\noqfpromote +{\stylesheet +{\s19\ql \li0\ri0\sb240\widctlpar\tqr\tldot\tx9350\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 +\af0\afs24\alang1025 \ltrch\fcs0 \b\f40\fs22\lang1024\langfe1024\cgrid\noproof\langnp1033\langfenp1033 \sbasedon0 \snext24 \spriority39 toc 1;} +{\*\cs25 \additive \rtlch\fcs1 \af0 \ltrch\fcs0 \ul\cf2 \sbasedon10 Hyperlink;} +} +\pard\plain \ltrpar\s19\ql \li0\ri0\sb240\widctlpar\tqr\tldot\tx9350\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0 \b\f40\fs22\lang1024\langfe1024\cgrid\noproof\langnp1033\langfenp1033 +{\field\fldedit +{\*\fldinst +{\rtlch\fcs1 \ab\af1\afs32 \ltrch\fcs0 \b0\i\f41\fs28\kerning32\insrsid10439798\charrsid5798973 TOC \\o "1-3" \\h \\z \\u } +} +{\fldrslt +{\field\fldedit +{\*\fldinst +{\rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid7957398 HYPERLINK \\ +l "_Toc363816075" } +{\rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid7168667 +} +} +{\fldrslt +{\rtlch\fcs1 \af0 \ltrch\fcs0 +\cs25\ul\cf2\insrsid4260481\charrsid12675072 Chapter 1} +{\rtlch\fcs1 \af0 \ltrch\fcs0 \webhidden\insrsid4260481 \tab } +{\field +{\*\fldinst +{\rtlch\fcs1 \af0 \ltrch\fcs0 \webhidden\insrsid4260481 PAGEREF _Toc363816075 \\h } +{\rtlch\fcs1 \af0 \ltrch\fcs0 +\webhidden\insrsid7168667 +} +} +{\fldrslt +{\rtlch\fcs1 \af0 \ltrch\fcs0 \webhidden\insrsid4260481 1} +} +} +\sectd \ltrsect +\psz1\linex0\endnhere\titlepg\sectlinegrid360\sectdefaultcl\sectrsid204056\sftnbj } +} +\sectd \ltrsect\psz1\linex0\endnhere\titlepg\sectlinegrid360\sectdefaultcl\sectrsid204056\sftnbj +{\rtlch\fcs1 \af31507\afs22 \ltrch\fcs0 +\b0\loch\af31506\hich\af31506\dbch\af31505\insrsid4260481 +\par } +} +} +\pard\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 57717b7..5969c66 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -9,6 +9,7 @@ #include <swmodeltestbase.hxx> #include <com/sun/star/awt/FontDescriptor.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> #include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> @@ -1963,6 +1964,16 @@ DECLARE_RTFIMPORT_TEST(testFdo84679, "fdo84679.rtf") CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(getParagraphOfText(1, xCell->getText()), "ParaBottomMargin")); } +DECLARE_RTFIMPORT_TEST(testFdo82071, "fdo82071.rtf") +{ + // The problem was that in TOC, chapter names were underlined, but they should not be. + uno::Reference<text::XTextRange> xRun = getRun(getParagraph(2), 1); + // Make sure we test the right text portion. + CPPUNIT_ASSERT_EQUAL(OUString("Chapter 1"), xRun->getString()); + // This was awt::FontUnderline::SINGLE. + CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::NONE, getProperty<sal_Int16>(xRun, "CharUnderline")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 85884f94..ed963a3 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -464,9 +464,14 @@ writerfilter::Reference<Properties>::Pointer_t RTFDocumentImpl::getProperties(RT // createStyleProperties() puts properties to rPr, but here we need a flat list. if (itSprm->first == NS_ooxml::LN_CT_Style_rPr) { + // rPr can have both attributes and SPRM's, copy over both types. RTFSprms& rRPrSprms = itSprm->second->getSprms(); for (RTFSprms::Iterator_t itRPrSprm = rRPrSprms.begin(); itRPrSprm != rRPrSprms.end(); ++itRPrSprm) aStyleSprms.set(itRPrSprm->first, itRPrSprm->second); + + RTFSprms& rRPrAttributes = itSprm->second->getAttributes(); + for (RTFSprms::Iterator_t itRPrAttribute = rRPrAttributes.begin(); itRPrAttribute != rRPrAttributes.end(); ++itRPrAttribute) + aStyleAttributes.set(itRPrAttribute->first, itRPrAttribute->second); } else aStyleSprms.set(itSprm->first, itSprm->second); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits