Kaydet (Commit) 7f697ec2 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Miklos Vajna

tdf#103961 writerfilter: parentless styles need pPrDefault(s)

It is possible for paragraph styles to be based on -none-.
In those cases, the DocDefaults must be applied.

Change-Id: I5b3458384c6473f3aaf64e5f274372d291ff824d
Reviewed-on: https://gerrit.libreoffice.org/57371
Tested-by: Jenkins
Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst a98d071d
...@@ -727,6 +727,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf117504_numberingIndent, "tdf117504_numberingInde ...@@ -727,6 +727,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf117504_numberingIndent, "tdf117504_numberingInde
{ {
OUString sName = getProperty<OUString>(getParagraph(1), "NumberingStyleName"); OUString sName = getProperty<OUString>(getParagraph(1), "NumberingStyleName");
CPPUNIT_ASSERT_MESSAGE("Paragraph has numbering style", !sName.isEmpty()); CPPUNIT_ASSERT_MESSAGE("Paragraph has numbering style", !sName.isEmpty());
uno::Reference<beans::XPropertySet> xPropertySet(
getStyles("ParagraphStyles")->getByName("Revision"), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty<sal_Int32>(xPropertySet, "ParaBottomMargin"));
xPropertySet.set(getStyles("ParagraphStyles")->getByName("Body Note"), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPropertySet, "ParaBottomMargin"));
} }
DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx") DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx")
......
...@@ -317,20 +317,23 @@ void PropertyMap::dumpXml() const ...@@ -317,20 +317,23 @@ void PropertyMap::dumpXml() const
} }
#endif #endif
void PropertyMap::InsertProps( const PropertyMapPtr& rMap ) void PropertyMap::InsertProps( const PropertyMapPtr& rMap, const bool bOverwrite )
{ {
if ( rMap ) if ( rMap )
{ {
for ( const auto& rPropPair : rMap->m_vMap ) for ( const auto& rPropPair : rMap->m_vMap )
m_vMap[rPropPair.first] = rPropPair.second; {
if ( bOverwrite || !m_vMap.count(rPropPair.first) )
m_vMap[rPropPair.first] = rPropPair.second;
}
insertTableProperties( rMap.get() ); insertTableProperties( rMap.get(), bOverwrite );
Invalidate(); Invalidate();
} }
} }
void PropertyMap::insertTableProperties( const PropertyMap* ) void PropertyMap::insertTableProperties( const PropertyMap*, const bool )
{ {
#ifdef DEBUG_WRITERFILTER #ifdef DEBUG_WRITERFILTER
TagLogger::getInstance().element( "PropertyMap.insertTableProperties" ); TagLogger::getInstance().element( "PropertyMap.insertTableProperties" );
...@@ -1825,7 +1828,7 @@ void TablePropertyMap::setValue( TablePropertyMapTarget eWhich, sal_Int32 nSet ) ...@@ -1825,7 +1828,7 @@ void TablePropertyMap::setValue( TablePropertyMapTarget eWhich, sal_Int32 nSet )
OSL_FAIL( "invalid TablePropertyMapTarget" ); OSL_FAIL( "invalid TablePropertyMapTarget" );
} }
void TablePropertyMap::insertTableProperties( const PropertyMap* pMap ) void TablePropertyMap::insertTableProperties( const PropertyMap* pMap, const bool bOverwrite )
{ {
#ifdef DEBUG_WRITERFILTER #ifdef DEBUG_WRITERFILTER
TagLogger::getInstance().startElement( "TablePropertyMap.insertTableProperties" ); TagLogger::getInstance().startElement( "TablePropertyMap.insertTableProperties" );
...@@ -1838,7 +1841,7 @@ void TablePropertyMap::insertTableProperties( const PropertyMap* pMap ) ...@@ -1838,7 +1841,7 @@ void TablePropertyMap::insertTableProperties( const PropertyMap* pMap )
for ( sal_Int32 eTarget = TablePropertyMapTarget_START; for ( sal_Int32 eTarget = TablePropertyMapTarget_START;
eTarget < TablePropertyMapTarget_MAX; ++eTarget ) eTarget < TablePropertyMapTarget_MAX; ++eTarget )
{ {
if ( pSource->m_aValidValues[eTarget].bValid ) if ( pSource->m_aValidValues[eTarget].bValid && (bOverwrite || !m_aValidValues[eTarget].bValid) )
{ {
m_aValidValues[eTarget].bValid = true; m_aValidValues[eTarget].bValid = true;
m_aValidValues[eTarget].nValue = pSource->m_aValidValues[eTarget].nValue; m_aValidValues[eTarget].nValue = pSource->m_aValidValues[eTarget].nValue;
......
...@@ -141,8 +141,8 @@ public: ...@@ -141,8 +141,8 @@ public:
// Remove a named property from *this, does nothing if the property id has not been set // Remove a named property from *this, does nothing if the property id has not been set
void Erase( PropertyIds eId); void Erase( PropertyIds eId);
// Imports properties from pMap, overwriting those with the same PropertyIds as the current map // Imports properties from pMap
void InsertProps( const tools::SvRef< PropertyMap >& rMap ); void InsertProps( const tools::SvRef< PropertyMap >& rMap, const bool bOverwrite = true );
// Returns a copy of the property if it exists, .first is its PropertyIds and .second is its Value (type css::uno::Any) // Returns a copy of the property if it exists, .first is its PropertyIds and .second is its Value (type css::uno::Any)
boost::optional< Property > getProperty( PropertyIds eId ) const; boost::optional< Property > getProperty( PropertyIds eId ) const;
...@@ -154,7 +154,7 @@ public: ...@@ -154,7 +154,7 @@ public:
void SetFootnote( const css::uno::Reference< css::text::XFootnote >& xF ) { m_xFootnote = xF; } void SetFootnote( const css::uno::Reference< css::text::XFootnote >& xF ) { m_xFootnote = xF; }
virtual void insertTableProperties( const PropertyMap* ); virtual void insertTableProperties( const PropertyMap*, const bool bOverwrite = true );
const std::vector< RedlineParamsPtr >& Redlines() const { return m_aRedlines; } const std::vector< RedlineParamsPtr >& Redlines() const { return m_aRedlines; }
...@@ -557,7 +557,7 @@ public: ...@@ -557,7 +557,7 @@ public:
bool getValue( TablePropertyMapTarget eWhich, sal_Int32& nFill ); bool getValue( TablePropertyMapTarget eWhich, sal_Int32& nFill );
void setValue( TablePropertyMapTarget eWhich, sal_Int32 nSet ); void setValue( TablePropertyMapTarget eWhich, sal_Int32 nSet );
virtual void insertTableProperties( const PropertyMap* ) override; virtual void insertTableProperties( const PropertyMap*, const bool bOverwrite = true ) override;
}; };
typedef tools::SvRef< TablePropertyMap > TablePropertyMapPtr; typedef tools::SvRef< TablePropertyMap > TablePropertyMapPtr;
......
...@@ -994,6 +994,10 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) ...@@ -994,6 +994,10 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
} }
else if( bParaStyle ) else if( bParaStyle )
{ {
// Paragraph styles that don't inherit from some parent need to apply the DocDefaults
if ( sConvertedStyleName != "Standard" )
pEntry->pProperties->InsertProps( m_pImpl->m_pDefaultParaProps, /*bAllowOverwrite=*/false );
//now it's time to set the default parameters - for paragraph styles //now it's time to set the default parameters - for paragraph styles
//Fonts: Western first entry in font table //Fonts: Western first entry in font table
//CJK: second entry //CJK: second entry
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment