summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2022-07-30 09:38:09 -0400
committerXisco Fauli <xiscofauli@libreoffice.org>2022-08-08 14:16:25 +0200
commit4663cde12ae413ca06c5799095a213950b83c2d6 (patch)
treeed868f2d5aaf67bcdf663cba84a3f615e979dcf1 /sw
parente264c555304cc82ce89248819f346c0957e3a5c0 (diff)
tdf#150197 sw: convert pre-defined num styles to ListFormat
Early in 7.x, allotropia introduced a generic list format string instead of prefix/suffix. Convert the pre-defined numbering formats to use that syntax as well. The problem was that ms export wasn't able to handle the old way of doing things any more. For example, if a user added numbering via the numbering style "Numbering 123", then on export the numbering string was lost. Change-Id: I11cd00280da2b464a9b00a5f0a8d72080f14e44c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137632 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Justin Luth <jluth@mail.com> (cherry picked from commit a106d5f75acc4a955f21583f58604ea2e7b4ce1a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137606 Tested-by: Jenkins Reviewed-by: Vasily Melenchuk <vasily.melenchuk@cib.de> (cherry picked from commit 5d72a000a0f9d127d1263a6df628898af08f14f9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137817
Diffstat (limited to 'sw')
-rw-r--r--sw/CppunitTest_sw_ooxmlexport18.mk18
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport18.cxx61
-rw-r--r--sw/source/core/doc/DocumentStylePoolManager.cxx16
4 files changed, 88 insertions, 8 deletions
diff --git a/sw/CppunitTest_sw_ooxmlexport18.mk b/sw/CppunitTest_sw_ooxmlexport18.mk
new file mode 100644
index 000000000000..cf085f8eb0f6
--- /dev/null
+++ b/sw/CppunitTest_sw_ooxmlexport18.mk
@@ -0,0 +1,18 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call sw_ooxmlexport_test,18))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sw_ooxmlexport18,\
+ officecfg/registry \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index e883a47cf59b..d5c5cfe5dd6e 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -89,6 +89,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_ooxmlexport15 \
CppunitTest_sw_ooxmlexport16 \
CppunitTest_sw_ooxmlexport17 \
+ CppunitTest_sw_ooxmlexport18 \
CppunitTest_sw_ooxmlexport_template \
CppunitTest_sw_ooxmlfieldexport \
CppunitTest_sw_ooxmllinks \
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
new file mode 100644
index 000000000000..40a3a0d80c45
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swmodeltestbase.hxx>
+
+#include <queue>
+
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/text/XFootnotesSupplier.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XTextFieldsSupplier.hpp>
+#include <com/sun/star/text/XTextField.hpp>
+#include <com/sun/star/util/XRefreshable.hpp>
+
+
+#include <comphelper/propertysequence.hxx>
+#include <comphelper/scopeguard.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <o3tl/string_view.hxx>
+#include <comphelper/propertyvalue.hxx>
+
+#include <unotxdoc.hxx>
+#include <docsh.hxx>
+
+constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/extras/ooxmlexport/data/";
+
+class Test : public SwModelTestBase
+{
+public:
+ Test() : SwModelTestBase(DATA_DIRECTORY, "Office Open XML Text") {}
+};
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf150197_predefinedNumbering)
+{
+ createSwDoc();
+
+ // The exact numbering style doesn't matter - just any non-bullet pre-defined numbering style.
+ uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence({
+ { "Style", uno::Any(OUString("Numbering 123")) },
+ { "FamilyName", uno::Any(OUString("NumberingStyles")) },
+ });
+ dispatchCommand(mxComponent, ".uno:StyleApply", aPropertyValues);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty<OUString>(getParagraph(1), "ListLabelString"));
+
+ reload("Office Open XML Text", "");
+ CPPUNIT_ASSERT_EQUAL(OUString("1."), getProperty<OUString>(getParagraph(1), "ListLabelString"));
+}
+
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx
index 42e05e0a9aad..1dc1885c8e98 100644
--- a/sw/source/core/doc/DocumentStylePoolManager.cxx
+++ b/sw/source/core/doc/DocumentStylePoolManager.cxx
@@ -1951,7 +1951,6 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
aFormat.SetCharFormat( pNumCFormat );
aFormat.SetStart( 1 );
aFormat.SetIncludeUpperLevels( 1 );
- aFormat.SetSuffix( "." );
static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
{
@@ -1972,6 +1971,7 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
for (sal_uInt16 n = 0; n < MAXLEVEL; ++n, ++pArr)
{
+ aFormat.SetListFormat("", ".", n);
if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{
aFormat.SetAbsLSpace( *pArr + 357 ); // 357 is indent of 0.63 cm
@@ -2004,7 +2004,6 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
aFormat.SetCharFormat( pNumCFormat );
aFormat.SetStart( 1 );
aFormat.SetIncludeUpperLevels( 1 );
- aFormat.SetSuffix( "." );
if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
{
@@ -2014,6 +2013,7 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
sal_uInt16 nSpace = 357; // indent of 0.63 cm
for (sal_uInt16 n = 0; n < MAXLEVEL; ++n)
{
+ aFormat.SetListFormat("", ".", n);
if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{
nSpace += pArr[ n ];
@@ -2041,7 +2041,6 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
aFormat.SetCharFormat( pNumCFormat );
aFormat.SetStart( 1 );
aFormat.SetIncludeUpperLevels( 1 );
- aFormat.SetSuffix( "." );
tools::Long const nOffs = 397; // 0.70 cm
@@ -2057,6 +2056,7 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
for (sal_uInt16 n = 0; n < MAXLEVEL; ++n)
{
+ aFormat.SetListFormat("", ".", n);
if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{
aFormat.SetAbsLSpace( (n+1) * nOffs + 357 ); // 357 is indent of 0.63 cm
@@ -2081,7 +2081,6 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
aFormat.SetCharFormat( pNumCFormat );
aFormat.SetStart( 1 );
aFormat.SetIncludeUpperLevels( 1 );
- aFormat.SetSuffix( "." );
aFormat.SetNumAdjust( SvxAdjust::Right );
static const sal_uInt16 aAbsSpace[ MAXLEVEL ] =
@@ -2103,7 +2102,7 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
for (sal_uInt16 n = 0; n < MAXLEVEL; ++n, ++pArr)
{
-
+ aFormat.SetListFormat("", ".", n);
if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{
aFormat.SetAbsLSpace( *pArr );
@@ -2135,8 +2134,8 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
aFormat.SetNumberingType(SVX_NUM_ROMAN_LOWER);
aFormat.SetStart( 1 );
aFormat.SetIncludeUpperLevels( 1 );
- aFormat.SetSuffix( "." );
aFormat.SetNumAdjust( SvxAdjust::Right );
+ aFormat.SetListFormat("", ".", 0);
if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
{
@@ -2160,6 +2159,7 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
aFormat.SetIncludeUpperLevels( 1 );
aFormat.SetStart( 1 );
+ aFormat.SetListFormat("", ".", 1);
if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{
@@ -2176,9 +2176,9 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
pNewRule->Set( 1, aFormat );
aFormat.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER);
- aFormat.SetSuffix(OUString(u')'));
aFormat.SetIncludeUpperLevels( 1 );
aFormat.SetStart( 3 );
+ aFormat.SetListFormat("", u")", 2);
if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{
@@ -2210,10 +2210,10 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId )
aFormat.SetFirstLineIndent( - nOffs );
}
- aFormat.SetSuffix( OUString() );
for (sal_uInt16 n = 3; n < MAXLEVEL; ++n)
{
aFormat.SetStart( n+1 );
+ aFormat.SetListFormat("", "", n);
if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
{