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.stahl@allotropia.de>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134636
diff --git a/sw/qa/extras/ooxmlexport/data/tdf148132.docx b/sw/qa/extras/ooxmlexport/data/tdf148132.docx
new file mode 100644
index 0000000..6ee2359
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf148132.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 9e17190..7915ade 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -16,9 +16,12 @@
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <com/sun/star/text/XTextField.hpp>
#include <com/sun/star/util/XRefreshable.hpp>
#include <com/sun/star/awt/FontSlant.hpp>
#include <com/sun/star/awt/FontWeight.hpp>
#include <comphelper/configuration.hxx>
#include <comphelper/scopeguard.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <officecfg/Office/Common.hxx>
#include <swmodeltestbase.hxx>
@@ -361,6 +364,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(testTdf148273_sectionBulletFormatLeak, "tdf148273_sectionBulletFormatLeak.docx")
{
// get a paragraph with bullet point after section break
diff --git a/sw/qa/extras/rtfexport/data/numbering-font.rtf b/sw/qa/extras/rtfexport/data/numbering-font.rtf
index 46fdb7e..8b57875 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 e9ddfdd..eb07cc5 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -869,7 +869,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"));
}
DECLARE_RTFEXPORT_TEST(testFdo82860, "fdo82860.odt")
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 7a4e47f..acb8f8c 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::makeAny( 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::makeAny(sStringValue));
}
}
break;
case NS_ooxml::LN_CT_Fonts_asciiTheme:
@@ -1790,9 +1783,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)
@@ -1870,10 +1860,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 de95db4..773fecd 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1987,8 +1987,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
@@ -7994,70 +7993,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 5140436..2abd229 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -1034,8 +1034,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 35d3e01..467ef85 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 0aa22aa..41fc0cd 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1972,7 +1972,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;
}