summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/xmloff/xmlnume.hxx4
-rw-r--r--sw/qa/extras/odfexport/data/tdf57317_autoListName.odtbin0 -> 10953 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport2.cxx31
-rw-r--r--xmloff/source/style/xmlnume.cxx9
-rw-r--r--xmloff/source/text/XMLTextListAutoStylePool.cxx20
-rw-r--r--xmloff/source/text/txtstyle.cxx2
6 files changed, 55 insertions, 11 deletions
diff --git a/include/xmloff/xmlnume.hxx b/include/xmloff/xmlnume.hxx
index 68818f1076ff..85f78047ee80 100644
--- a/include/xmloff/xmlnume.hxx
+++ b/include/xmloff/xmlnume.hxx
@@ -63,9 +63,7 @@ public:
const css::uno::Reference< css::container::XIndexReplace > & xNumRule,
bool bOutline=false );
- void exportStyles( bool bUsed,
- XMLTextListAutoStylePool *pPool,
- bool bExportChapterNumbering );
+ void exportStyles(bool bUsed, bool bExportChapterNumbering);
void exportNumberingRule(
const OUString& rName, bool bIsHidden,
const css::uno::Reference< css::container::XIndexReplace > & xNumRule );
diff --git a/sw/qa/extras/odfexport/data/tdf57317_autoListName.odt b/sw/qa/extras/odfexport/data/tdf57317_autoListName.odt
new file mode 100644
index 000000000000..3aafbc519387
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/tdf57317_autoListName.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx
index 2a2f015f6b84..5d2f91b92d5d 100644
--- a/sw/qa/extras/odfexport/odfexport2.cxx
+++ b/sw/qa/extras/odfexport/odfexport2.cxx
@@ -94,6 +94,37 @@ DECLARE_ODFEXPORT_TEST(testTdf143605, "tdf143605.odt")
CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty<OUString>(getParagraph(1), "ListLabelString"));
}
+CPPUNIT_TEST_FIXTURE(Test, testTdf57317_autoListName)
+{
+ load(mpTestDocumentPath, "tdf57317_autoListName.odt");
+ // The list style (from styles.xml) overrides a duplicate named auto-style
+ //uno::Any aNumStyle = getStyles("NumberingStyles")->getByName("L1");
+ //CPPUNIT_ASSERT(aNumStyle.hasValue());
+ uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(">1<"), getProperty<OUString>(xPara, "ListLabelString"));
+ CPPUNIT_ASSERT_EQUAL(OUString("L1"), getProperty<OUString>(xPara, "NumberingStyleName"));
+
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:DefaultBullet", {});
+
+ // This was failing with a duplicate auto numbering style name of L1 instead of a unique name,
+ // thus it was showing the same info as before the bullet modification.
+ reload(mpFilter, "");
+ xPara.set(getParagraph(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara, "ListLabelString"));
+
+ uno::Reference<container::XIndexAccess> xLevels(xPara->getPropertyValue("NumberingRules"),
+ uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aProps;
+ xLevels->getByIndex(0) >>= aProps;
+ for (beans::PropertyValue const& rProp : std::as_const(aProps))
+ {
+ if (rProp.Name == "BulletChar")
+ return;
+ }
+ CPPUNIT_FAIL("no BulletChar property");
+}
+
CPPUNIT_TEST_FIXTURE(Test, testListFormatDocx)
{
loadAndReload("listformat.docx");
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 )