summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2022-08-22 12:52:22 -0400
committerJustin Luth <jluth@mail.com>2022-08-23 04:09:04 +0200
commit46dc9f3bbac67e9240adc44ab017f905482ef786 (patch)
treec8140a7662fdf4c7260b19bb124e7ebaf83c23f5 /xmloff
parent3cc6b870c48b23418f65d2c3cd6eab72ef0680de (diff)
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 <jluth@mail.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/style/xmlnume.cxx9
-rw-r--r--xmloff/source/text/XMLTextListAutoStylePool.cxx20
-rw-r--r--xmloff/source/text/txtstyle.cxx2
3 files changed, 23 insertions, 8 deletions
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 <tools/solar.h>
#include <o3tl/sorted_vector.hxx>
#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/ucb/XAnyCompareFactory.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/container/XIndexReplace.hpp>
@@ -160,6 +162,24 @@ XMLTextListAutoStylePool::XMLTextListAutoStylePool( SvXMLExport& rExp ) :
if( bStylesOnly )
sPrefix = "ML";
+ Reference<XStyleFamiliesSupplier> 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<XIndexAccess> 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> 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 )