sw/qa/extras/ooxmlexport/data/tdf148132.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 32 ++++++++++ sw/qa/extras/rtfexport/data/numbering-font.rtf | 8 -- sw/qa/extras/rtfexport/rtfexport.cxx | 3 writerfilter/source/dmapper/DomainMapper.cxx | 14 ---- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 67 ---------------------- writerfilter/source/dmapper/DomainMapper_Impl.hxx | 2 writerfilter/source/rtftok/rtfdispatchvalue.cxx | 9 ++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 9 ++ 9 files changed, 54 insertions(+), 90 deletions(-)
New commits: commit 02f53bd61222d7999b847a22fd24d65195f129e5 Author: Vasily Melenchuk <vasily.melenc...@cib.de> AuthorDate: Wed May 11 09:44:22 2022 +0300 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu May 19 11:58:24 2022 +0200 tdf#148132: Revert "n#758883 dmapper: paragraph-level..." Seems original problem is no longer reprodicible with recent builds but ovewriting of numbering style params with inline values leads to another problems. Removing this mechanics do some impact on RTF filter: it tries to modify numbering styles, so this was also corrected. It is not ideal yet but looks better in support numbering char properties different from paragraph ones. This reverts commit 2123ede032ca64f696ef54af4ad3238974ca2b5d. Change-Id: If8c79d6191de13b2f09c128b59d17efcfdb1a4ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133877 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/data/tdf148132.docx b/sw/qa/extras/ooxmlexport/data/tdf148132.docx new file mode 100644 index 000000000000..6ee2359795a3 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf148132.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 5c25a3b5d369..8146e942ce5d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -15,8 +15,11 @@ #include <com/sun/star/util/XRefreshable.hpp> #include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/awt/FontWeight.hpp> #include <comphelper/scopeguard.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <officecfg/Office/Common.hxx> #include <o3tl/string_view.hxx> #include <comphelper/propertyvalue.hxx> @@ -824,6 +827,35 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf147978enhancedPathABVW) } } +DECLARE_OOXMLEXPORT_TEST(testTdf148132, "tdf148132.docx") +{ + { + uno::Reference<text::XTextRange> xParagraph = getParagraph(1); + auto xLevels = getProperty< uno::Reference<container::XIndexAccess> >(xParagraph, "NumberingRules"); + // Get level 2 char style + comphelper::SequenceAsHashMap levelProps(xLevels->getByIndex(1)); + OUString aCharStyleName = levelProps["CharStyleName"].get<OUString>(); + // Ensure that numbering in this paragraph is 24pt bold italic + // Previously it got overriden by paragraph properties and became 6pt, no bold, no italic + uno::Reference<beans::XPropertySet> xStyle(getStyles("CharacterStyles")->getByName(aCharStyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(24.f, getProperty<float>(xStyle, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xStyle, "CharWeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, getProperty<awt::FontSlant>(xStyle, "CharPosture")); + } + // And do the same for second paragraph. Numbering should be identical + { + uno::Reference<text::XTextRange> xParagraph = getParagraph(2); + auto xLevels = getProperty< uno::Reference<container::XIndexAccess> >(xParagraph, "NumberingRules"); + comphelper::SequenceAsHashMap levelProps(xLevels->getByIndex(1)); + OUString aCharStyleName = levelProps["CharStyleName"].get<OUString>(); + + uno::Reference<beans::XPropertySet> xStyle(getStyles("CharacterStyles")->getByName(aCharStyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(24.f, getProperty<float>(xStyle, "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xStyle, "CharWeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, getProperty<awt::FontSlant>(xStyle, "CharPosture")); + } +} + DECLARE_OOXMLEXPORT_TEST(testTdf135923, "tdf135923-min.docx") { uno::Reference<text::XText> xShape(getShape(1), uno::UNO_QUERY); diff --git a/sw/qa/extras/rtfexport/data/numbering-font.rtf b/sw/qa/extras/rtfexport/data/numbering-font.rtf index 46fdb7ed4d1e..8b57875c29bc 100644 --- a/sw/qa/extras/rtfexport/data/numbering-font.rtf +++ b/sw/qa/extras/rtfexport/data/numbering-font.rtf @@ -1,7 +1,7 @@ {\rtf1\adeflang1025\ansi\ansicpg1252\uc1\deff0\deflang1033 {\fonttbl {\f0\fbidi \froman\fcharset238\fprq2 Times New Roman;} -{\f40\fbidi \fswiss\fcharset238\fprq2 Verdana;} +{\f40\fbidi \fswiss\fcharset238\fprq2 Impact;} } {\*\listtable {\list\listtemplateid645944990 @@ -9,14 +9,12 @@ \levelfollow0\levelstartat1 {\leveltext\'02\'00.;} {\levelnumbers\'01;} -\rtlch \af0\afs18 \ltrch \fs18 \fi-360\li720\lin720 } +\f40\fs144\b0\i0\fi-360\li720\lin720 } {\listname ;} \listid1421871093} } {\*\listoverridetable {\listoverride\listid1421871093\listoverridecount0\ls30} } -\pard\plain Before.\par -\pard\plain \ls30\f40\fs18 First line.\par -\pard\plain After.\par +\pard\plain \ls30\f0\fs48\b\i First line.\par } diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 941b112bbdf0..dc5b3c0fb87c 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -872,7 +872,8 @@ DECLARE_RTFEXPORT_TEST(testNumberingFont, "numbering-font.rtf") uno::Reference<beans::XPropertySet> xStyle( getStyles("CharacterStyles")->getByName("ListLabel 1"), uno::UNO_QUERY); // This was Liberation Serif, i.e. custom font of the numbering itself ("1.\t") was lost on import. - CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty<OUString>(xStyle, "CharFontName")); + CPPUNIT_ASSERT_EQUAL(OUString("Impact"), getProperty<OUString>(xStyle, "CharFontName")); + CPPUNIT_ASSERT_EQUAL(72.f, getProperty<float>(xStyle, "CharHeight")); } CPPUNIT_TEST_FIXTURE(Test, testFdo82860) diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index f0ca81df7706..8f3815fa9abd 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -372,13 +372,6 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) if (m_pImpl->GetTopContext()) { m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME, uno::Any( sStringValue )); - if (m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH) && m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)->isSet(PROP_NUMBERING_RULES)) - { - // Font of the paragraph mark should be used for the numbering as well. - uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle()); - if (xCharStyle.is()) - xCharStyle->setPropertyValue("CharFontName", uno::Any(sStringValue)); - } } break; case NS_ooxml::LN_CT_Fonts_asciiTheme: @@ -1816,9 +1809,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) if( nSprmId != NS_ooxml::LN_EG_RPrBase_bCs ) rContext->Insert(PROP_CHAR_WEIGHT_ASIAN, aBold ); - uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle()); - if (xCharStyle.is()) - xCharStyle->setPropertyValue(getPropertyName(PROP_CHAR_WEIGHT), aBold); if (nSprmId == NS_ooxml::LN_EG_RPrBase_b) m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "b", OUString::number(nIntValue)); else if (nSprmId == NS_ooxml::LN_EG_RPrBase_bCs) @@ -1896,10 +1886,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) //Asian get the same value as Western rContext->Insert( PROP_CHAR_HEIGHT, aVal ); rContext->Insert( PROP_CHAR_HEIGHT_ASIAN, aVal ); - - uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle()); - if (xCharStyle.is()) - xCharStyle->setPropertyValue(getPropertyName(PROP_CHAR_HEIGHT), aVal); } m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, (nSprmId == NS_ooxml::LN_EG_RPrBase_sz ? OUString("sz") : OUString("szCs")), OUString::number(nIntValue)); } diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 63cb83c2e1a0..cca5d67adf5a 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2096,8 +2096,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con { aProperties = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(pPropertyMap->GetPropertyValues()); } - // TODO: this *should* work for RTF but there are test failures, maybe rtftok doesn't distinguish between formatting for the paragraph marker and for the paragraph as a whole; needs investigation - if (pPropertyMap && IsOOXMLImport()) + if (pPropertyMap) { // tdf#64222 filter out the "paragraph marker" formatting and // set it as a separate paragraph property, not a empty hint at @@ -8341,70 +8340,6 @@ uno::Reference<container::XIndexAccess> DomainMapper_Impl::GetCurrentNumberingRu return xRet; } -uno::Reference<beans::XPropertySet> DomainMapper_Impl::GetCurrentNumberingCharStyle() -{ - uno::Reference<beans::XPropertySet> xRet; - try - { - sal_Int32 nListLevel = -1; - uno::Reference<container::XIndexAccess> xLevels; - if ( GetTopContextType() == CONTEXT_PARAGRAPH ) - xLevels = GetCurrentNumberingRules(&nListLevel); - if (!xLevels.is()) - { - if (IsOOXMLImport()) - return xRet; - - PropertyMapPtr pContext = m_pTopContext; - if (IsRTFImport() && !IsOpenField()) - { - // 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. - // We know that the formatting inside a field won't affect the - // paragraph marker formatting, though. - pContext = GetTopContextOfType(CONTEXT_PARAGRAPH); - if (!pContext) - return xRet; - } - - // In case numbering rules is not found via a style, try the direct formatting instead. - std::optional<PropertyMap::Property> oProp = pContext->getProperty(PROP_NUMBERING_RULES); - if (oProp) - { - xLevels.set(oProp->second, uno::UNO_QUERY); - // Found the rules, then also try to look up our numbering level. - oProp = pContext->getProperty(PROP_NUMBERING_LEVEL); - if (oProp) - oProp->second >>= nListLevel; - else - nListLevel = 0; - } - - if (!xLevels.is()) - return xRet; - } - uno::Sequence<beans::PropertyValue> aProps; - xLevels->getByIndex(nListLevel) >>= aProps; - auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps), - [](const beans::PropertyValue& rProp) { return rProp.Name == "CharStyleName"; }); - if (pProp != std::cend(aProps)) - { - OUString aCharStyle; - pProp->Value >>= aCharStyle; - uno::Reference<container::XNameAccess> xCharacterStyles; - uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY); - uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies(); - xStyleFamilies->getByName("CharacterStyles") >>= xCharacterStyles; - xRet.set(xCharacterStyles->getByName(aCharStyle), uno::UNO_QUERY_THROW); - } - } - catch( const uno::Exception& ) - { - } - return xRet; -} - SectionPropertyMap * DomainMapper_Impl::GetSectionContext() { SectionPropertyMap* pSectionContext = nullptr; diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 5a48e26fe73b..27e5457c2772 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -1056,8 +1056,6 @@ public: } SectionPropertyMap * GetSectionContext(); - /// If the current paragraph has a numbering style associated, this method returns its character style (part of the numbering rules) - css::uno::Reference<css::beans::XPropertySet> GetCurrentNumberingCharStyle(); /// If the current paragraph has a numbering style associated, this method returns its numbering rules css::uno::Reference<css::container::XIndexAccess> GetCurrentNumberingRules(sal_Int32* pListLevel); diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx index ca092fb66a37..eb5370223aaa 100644 --- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx +++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx @@ -194,7 +194,14 @@ bool RTFDocumentImpl::dispatchCharacterSprmValue(RTFKeyword nKeyword, int nParam } if (nSprm > 0) { - m_aStates.top().getCharacterSprms().set(nSprm, pIntValue); + if (m_aStates.top().getDestination() == Destination::LISTLEVEL) + { + m_aStates.top().getTableSprms().set(nSprm, pIntValue); + } + else + { + m_aStates.top().getCharacterSprms().set(nSprm, pIntValue); + } return true; } diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 662f68bbda5e..ebd3922de22a 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1971,7 +1971,14 @@ RTFError RTFDocumentImpl::dispatchToggle(RTFKeyword nKeyword, bool bParam, int n } if (nSprm >= 0) { - m_aStates.top().getCharacterSprms().set(nSprm, pBoolValue); + if (m_aStates.top().getDestination() == Destination::LISTLEVEL) + { + m_aStates.top().getTableSprms().set(nSprm, pBoolValue); + } + else + { + m_aStates.top().getCharacterSprms().set(nSprm, pBoolValue); + } return RTFError::OK; }