From 497b4ff54b8d0afddb8c6e66d4de0187e4fda949 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 21 Jul 2015 09:04:44 +0200 Subject: tdf#89702 DOCX import: fix too large bullet character MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit c1f8437dbed0e8b989e41a345ef7e658a6e8a4cd (fdo#83465 RTF import: handle font of numbering, 2014-09-25), changed the "get the me character style of the current numbering's current level" member function to be successfull even in case we're inside a DOCX run, not when we're inside a DOCX paragraph, but outside runs. While this is necessary for RTF, the side effect of this was that unwanted run properties started to affect the above mentioned character style in case of DOCX. Fix the problem by enabling the "in paragraph and run" looking for RTF only. Change-Id: I610bfce6cec15b918fe547402360f5a894401f7e (cherry picked from commit fc7c1a07d0d5e21a4e1533a0e5b0ac256763f973) Reviewed-on: https://gerrit.libreoffice.org/17323 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/qa/extras/ooxmlimport/data/tdf89702.docx | Bin 0 -> 13147 bytes sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 14 ++++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 16 ++++++++++------ 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 sw/qa/extras/ooxmlimport/data/tdf89702.docx diff --git a/sw/qa/extras/ooxmlimport/data/tdf89702.docx b/sw/qa/extras/ooxmlimport/data/tdf89702.docx new file mode 100644 index 000000000000..5542d1cbe575 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf89702.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 2bac72a10ed9..b4f85571a7fa 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -2735,6 +2735,20 @@ DECLARE_OOXMLIMPORT_TEST(testTdf90611, "tdf90611.docx") CPPUNIT_ASSERT_EQUAL(10.f, getProperty(getParagraphOfText(1, xFootnoteText), "CharHeight")); } +DECLARE_OOXMLIMPORT_TEST(testTdf89702, "tdf89702.docx") +{ + // Get the first paragraph's numbering style's 2nd level's character style name. + uno::Reference xParagraph = getParagraph(1); + auto xLevels = getProperty< uno::Reference >(xParagraph, "NumberingRules"); + uno::Sequence aLevel; + xLevels->getByIndex(1) >>= aLevel; // 2nd level + OUString aCharStyleName = std::find_if(aLevel.begin(), aLevel.end(), [](const beans::PropertyValue& rValue) { return rValue.Name == "CharStyleName"; })->Value.get(); + + // Make sure that the font name is Arial, this was Verdana. + uno::Reference xStyle(getStyles("CharacterStyles")->getByName(aCharStyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty(xStyle, "CharFontName")); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 5ff66e97ac26..515d6fe0514c 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -5042,12 +5042,16 @@ uno::Reference DomainMapper_Impl::GetCurrentNumberingCharSt uno::Reference xLevels = GetCurrentNumberingRules(&nListLevel); if (!xLevels.is()) { - // Looking up the paragraph context explicitly (and not just taking - // the top context) is necessary for RTF, where formatting of a run - // and of the paragraph mark is not separated. - PropertyMapPtr pContext = GetTopContextOfType(CONTEXT_PARAGRAPH); - if (!pContext) - return xRet; + PropertyMapPtr pContext = m_pTopContext; + if (IsRTFImport()) + { + // Looking up the paragraph context explicitly (and not just taking + // the top context) is necessary for RTF, where formatting of a run + // and of the paragraph mark is not separated. + pContext = GetTopContextOfType(CONTEXT_PARAGRAPH); + if (!pContext) + return xRet; + } // In case numbering rules is not found via a style, try the direct formatting instead. boost::optional oProp = pContext->getProperty(PROP_NUMBERING_RULES); -- cgit