From 46dc9f3bbac67e9240adc44ab017f905482ef786 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Mon, 22 Aug 2022 12:52:22 -0400 Subject: tdf#57317 odf export: avoid autolist conflict with NumberingStyles Somehow you can have autoStyles writing into the styles.xml. Well, the code to prevent duplicates for that needs to exist for autoStyles written into document.xml as well. Change-Id: I9602b7023a1ef009ad644374dc5081afb8a76916 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138703 Tested-by: Jenkins Reviewed-by: Justin Luth --- xmloff/source/style/xmlnume.cxx | 9 ++------- xmloff/source/text/XMLTextListAutoStylePool.cxx | 20 ++++++++++++++++++++ xmloff/source/text/txtstyle.cxx | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx index 682fc648af41..9ec9350374db 100644 --- a/xmloff/source/style/xmlnume.cxx +++ b/xmloff/source/style/xmlnume.cxx @@ -782,9 +782,7 @@ void SvxXMLNumRuleExport::exportOutline() } } -void SvxXMLNumRuleExport::exportStyles( bool bUsed, - XMLTextListAutoStylePool *pPool, - bool bExportChapterNumbering ) +void SvxXMLNumRuleExport::exportStyles( bool bUsed, bool bExportChapterNumbering ) { if( bExportChapterNumbering ) exportOutline(); @@ -821,11 +819,8 @@ void SvxXMLNumRuleExport::exportStyles( bool bUsed, xStyles->getByIndex( i ) >>= xStyle; if( !bUsed || xStyle->isInUse() ) - { exportStyle( xStyle ); - if( pPool ) - pPool->RegisterName( xStyle->getName() ); - } + } } diff --git a/xmloff/source/text/XMLTextListAutoStylePool.cxx b/xmloff/source/text/XMLTextListAutoStylePool.cxx index 893fdbdc5a4a..1e6cfdc368d8 100644 --- a/xmloff/source/text/XMLTextListAutoStylePool.cxx +++ b/xmloff/source/text/XMLTextListAutoStylePool.cxx @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -160,6 +162,24 @@ XMLTextListAutoStylePool::XMLTextListAutoStylePool( SvXMLExport& rExp ) : if( bStylesOnly ) sPrefix = "ML"; + Reference xFamiliesSupp(rExport.GetModel(), UNO_QUERY); + SAL_WARN_IF(!xFamiliesSupp.is(), "xmloff", "getStyleFamilies() from XModel failed for export!"); + Reference< XNameAccess > xFamilies; + if (xFamiliesSupp.is()) + xFamilies = xFamiliesSupp->getStyleFamilies(); + + Reference xStyles; + static const OUStringLiteral aNumberStyleName(u"NumberingStyles"); + if (xFamilies.is() && xFamilies->hasByName(aNumberStyleName)) + xFamilies->getByName(aNumberStyleName) >>= xStyles; + + const sal_Int32 nStyles = xStyles.is() ? xStyles->getCount() : 0; + for (sal_Int32 i = 0; i < nStyles; i++) + { + Reference xStyle; + xStyles->getByIndex(i) >>= xStyle; + RegisterName(xStyle->getName()); + } } XMLTextListAutoStylePool::~XMLTextListAutoStylePool() diff --git a/xmloff/source/text/txtstyle.cxx b/xmloff/source/text/txtstyle.cxx index fd04a925bc35..4cc211dcff0b 100644 --- a/xmloff/source/text/txtstyle.cxx +++ b/xmloff/source/text/txtstyle.cxx @@ -108,7 +108,7 @@ void XMLTextParagraphExport::exportStyleAttributes( void XMLTextParagraphExport::exportNumStyles( bool bUsed ) { SvxXMLNumRuleExport aNumRuleExport( GetExport() ); - aNumRuleExport.exportStyles( bUsed, &maListAutoPool, !IsBlockMode() ); + aNumRuleExport.exportStyles(bUsed, !IsBlockMode()); } void XMLTextParagraphExport::exportTextStyles( bool bUsed, bool bProg ) -- cgit