1 Changes the way Impress docs write lists to odf
3 From: Thorsten Behrens <thb@openoffice.org>
8 sd/source/filter/xml/sdxmlwrp.cxx | 4 ++++
9 xmloff/inc/xmloff/xmlexp.hxx | 1 +
10 xmloff/source/core/xmlexp.cxx | 12 ++++++++++++
11 xmloff/source/text/XMLTextNumRuleInfo.cxx | 28 +++++++++++++++++++---------
12 xmloff/source/text/XMLTextNumRuleInfo.hxx | 12 +++++++++++-
13 xmloff/source/text/txtparae.cxx | 12 +++++++++---
14 6 files changed, 56 insertions(+), 13 deletions(-)
17 diff --git sd/source/filter/xml/sdxmlwrp.cxx sd/source/filter/xml/sdxmlwrp.cxx
18 index d9e5e0b..f5519f3 100644
19 --- sd/source/filter/xml/sdxmlwrp.cxx
20 +++ sd/source/filter/xml/sdxmlwrp.cxx
21 @@ -869,6 +869,7 @@ sal_Bool SdXMLFilter::Export()
22 { MAP_LEN( "ProgressMax" ), 0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
23 { MAP_LEN( "ProgressCurrent" ), 0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
24 { MAP_LEN( "UsePrettyPrinting"),0, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
25 + { MAP_LEN( "GenerousListLevels"),0, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
27 { MAP_LEN( "PageLayoutNames" ), 0, SEQTYPE(::getCppuType((const OUString*)0)), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
28 { MAP_LEN( "BaseURI" ), 0,
29 @@ -900,6 +901,9 @@ sal_Bool SdXMLFilter::Export()
30 sal_Bool bUsePrettyPrinting( aSaveOpt.IsPrettyPrinting() );
31 xInfoSet->setPropertyValue( sUsePrettyPrinting, makeAny( bUsePrettyPrinting ) );
33 + OUString sGenerousListLevels(RTL_CONSTASCII_USTRINGPARAM("GenerousListLevels"));
34 + xInfoSet->setPropertyValue( sGenerousListLevels, makeAny( true ) );
36 const uno::Reference < embed::XStorage >& xStorage = mrMedium.GetOutputStorage();
39 diff --git xmloff/inc/xmloff/xmlexp.hxx xmloff/inc/xmloff/xmlexp.hxx
40 index a5cd93b..5363551 100644
41 --- xmloff/inc/xmloff/xmlexp.hxx
42 +++ xmloff/inc/xmloff/xmlexp.hxx
43 @@ -109,6 +109,7 @@ namespace comphelper { class UnoInterfaceToUniqueIdentifierMapper; }
44 #define EXPORT_NODOCTYPE 0x0200
45 #define EXPORT_PRETTY 0x0400
46 #define EXPORT_SAVEBACKWARDCOMPATIBLE 0x0800
47 +#define EXPORT_GENEROUS_LIST_LEVELS 0x4000
48 #define EXPORT_OASIS 0x8000
49 #define EXPORT_ALL 0x7fff
51 diff --git xmloff/source/core/xmlexp.cxx xmloff/source/core/xmlexp.cxx
52 index 1dc010d..78487f1 100644
53 --- xmloff/source/core/xmlexp.cxx
54 +++ xmloff/source/core/xmlexp.cxx
55 @@ -136,6 +136,7 @@ const sal_Char *sOpenOfficeOrgProject ="OpenOffice.org_project";
56 #define XML_MODEL_SERVICE_CHART "com.sun.star.chart.ChartDocument"
58 #define XML_USEPRETTYPRINTING "UsePrettyPrinting"
59 +#define XML_GENEROUSLISTLEVELS "GenerousListLevels"
61 #define C2U(cChar) OUString( RTL_CONSTASCII_USTRINGPARAM(cChar) )
63 @@ -605,6 +606,17 @@ void SAL_CALL SvXMLExport::setSourceDocument( const uno::Reference< lang::XCompo
64 mnExportFlags &= ~EXPORT_PRETTY;
67 + OUString sGenerousListLevels(RTL_CONSTASCII_USTRINGPARAM(XML_GENEROUSLISTLEVELS));
68 + if (!xPropertySetInfo->hasPropertyByName(sGenerousListLevels)
69 + || !mxExportInfo->getPropertyValue(sGenerousListLevels).get<bool>())
71 + mnExportFlags &= ~EXPORT_GENEROUS_LIST_LEVELS;
75 + mnExportFlags |= EXPORT_GENEROUS_LIST_LEVELS;
78 if (mpNumExport && (mnExportFlags & (EXPORT_AUTOSTYLES | EXPORT_STYLES)))
80 OUString sWrittenNumberFormats(RTL_CONSTASCII_USTRINGPARAM(XML_WRITTENNUMBERSTYLES));
81 diff --git xmloff/source/text/XMLTextNumRuleInfo.cxx xmloff/source/text/XMLTextNumRuleInfo.cxx
82 index 8ee79a9..88e493e 100644
83 --- xmloff/source/text/XMLTextNumRuleInfo.cxx
84 +++ xmloff/source/text/XMLTextNumRuleInfo.cxx
85 @@ -55,6 +55,7 @@ XMLTextNumRuleInfo::XMLTextNumRuleInfo()
86 : msNumberingRules(RTL_CONSTASCII_USTRINGPARAM("NumberingRules"))
87 , msNumberingLevel(RTL_CONSTASCII_USTRINGPARAM("NumberingLevel"))
88 , msNumberingStartValue(RTL_CONSTASCII_USTRINGPARAM("NumberingStartValue"))
89 + , msNumberingType(RTL_CONSTASCII_USTRINGPARAM("NumberingType"))
90 , msParaIsNumberingRestart(RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart"))
91 , msNumberingIsNumber(RTL_CONSTASCII_USTRINGPARAM("NumberingIsNumber"))
92 , msNumberingIsOutline(RTL_CONSTASCII_USTRINGPARAM("NumberingIsOutline"))
93 @@ -68,6 +69,7 @@ XMLTextNumRuleInfo::XMLTextNumRuleInfo()
96 , mnListStartValue( -1 )
97 + , mnNumberingType( NumberingType::CHAR_SPECIAL )
99 , mbIsNumbered( sal_False )
100 , mbIsRestart( sal_False )
101 @@ -212,10 +214,9 @@ void XMLTextNumRuleInfo::Set(
102 const PropertyValue& rProp = pPropArray[i];
104 if ( rProp.Name == msPropNameStartWith )
106 rProp.Value >>= mnListLevelStartValue;
109 + else if ( rProp.Name == msNumberingType )
110 + rProp.Value >>= mnNumberingType;
113 // --> OD 2008-11-26 #158694#
114 @@ -236,20 +237,29 @@ void XMLTextNumRuleInfo::Set(
118 -sal_Bool XMLTextNumRuleInfo::BelongsToSameList( const XMLTextNumRuleInfo& rCmp ) const
119 +static inline bool IsNumbering(sal_Int16 nType)
121 + return nType != NumberingType::CHAR_SPECIAL && nType != NumberingType::BITMAP;
124 +sal_Bool XMLTextNumRuleInfo::BelongsToSameList( const XMLTextNumRuleInfo& rCmp, bool bIgnoreFormatting ) const
126 - sal_Bool bRet( sal_True );
127 // Currently only the text documents support <ListId>.
128 if ( rCmp.msListId.getLength() > 0 ||
129 msListId.getLength() > 0 )
131 - bRet = rCmp.msListId == msListId;
132 + return rCmp.msListId == msListId;
136 - bRet = HasSameNumRules( rCmp );
137 + if ( !bIgnoreFormatting )
139 + return HasSameNumRules( rCmp );
143 + return IsNumbering(mnNumberingType) == IsNumbering(rCmp.mnNumberingType);
150 diff --git xmloff/source/text/XMLTextNumRuleInfo.hxx xmloff/source/text/XMLTextNumRuleInfo.hxx
151 index d3066a0..b012cbe 100644
152 --- xmloff/source/text/XMLTextNumRuleInfo.hxx
153 +++ xmloff/source/text/XMLTextNumRuleInfo.hxx
156 #include <com/sun/star/uno/Reference.hxx>
157 #include <com/sun/star/container/XIndexReplace.hpp>
158 +#include <com/sun/star/style/NumberingType.hpp>
160 namespace com { namespace sun { namespace star {
161 namespace text { class XTextContent; }
162 @@ -52,6 +53,7 @@ class XMLTextNumRuleInfo
163 const ::rtl::OUString msNumberingRules;
164 const ::rtl::OUString msNumberingLevel;
165 const ::rtl::OUString msNumberingStartValue;
166 + const ::rtl::OUString msNumberingType;
167 const ::rtl::OUString msParaIsNumberingRestart;
168 const ::rtl::OUString msNumberingIsNumber;
169 const ::rtl::OUString msNumberingIsOutline;
170 @@ -70,6 +72,7 @@ class XMLTextNumRuleInfo
171 // paragraph's list attributes
172 ::rtl::OUString msListId;
173 sal_Int16 mnListStartValue;
174 + sal_Int16 mnNumberingType;
175 sal_Int16 mnListLevel;
176 sal_Bool mbIsNumbered;
177 sal_Bool mbIsRestart;
178 @@ -144,7 +147,12 @@ public:
182 - sal_Bool BelongsToSameList( const XMLTextNumRuleInfo& rCmp ) const;
183 + /** Compare num rules
185 + @param rCmp other numrule to compare with
186 + @param bIgnoreFormatting when true, different list styles still compare equal
188 + sal_Bool BelongsToSameList( const XMLTextNumRuleInfo& rCmp, bool bIgnoreFormatting ) const;
190 inline sal_Bool HasSameNumRules( const XMLTextNumRuleInfo& rCmp ) const
192 @@ -170,6 +178,7 @@ inline XMLTextNumRuleInfo& XMLTextNumRuleInfo::operator=(
193 mxNumRules = rInfo.mxNumRules;
194 msListId = rInfo.msListId;
195 mnListStartValue = rInfo.mnListStartValue;
196 + mnNumberingType = rInfo.mnNumberingType;
197 mnListLevel = rInfo.mnListLevel;
198 mbIsNumbered = rInfo.mbIsNumbered;
199 mbIsRestart = rInfo.mbIsRestart;
200 @@ -190,6 +199,7 @@ inline void XMLTextNumRuleInfo::Reset()
201 msNumRulesName = ::rtl::OUString();
202 msListId = ::rtl::OUString();
203 mnListStartValue = -1;
204 + mnNumberingType = ::com::sun::star::style::NumberingType::CHAR_SPECIAL;
206 // --> OD 2006-09-27 #i69627#
207 mbIsNumbered = mbIsRestart =
208 diff --git xmloff/source/text/txtparae.cxx xmloff/source/text/txtparae.cxx
209 index d5454fc..361200c 100644
210 --- xmloff/source/text/txtparae.cxx
211 +++ xmloff/source/text/txtparae.cxx
212 @@ -596,12 +596,16 @@ void XMLTextParagraphExport::exportListChange(
213 const XMLTextNumRuleInfo& rPrevInfo,
214 const XMLTextNumRuleInfo& rNextInfo )
216 + const bool bGenerousListLevels(
217 + GetExport().getExportFlags() & EXPORT_GENEROUS_LIST_LEVELS);
220 if ( rPrevInfo.GetLevel() > 0 )
222 bool bRootListToBeClosed = false;
223 sal_Int16 nListLevelsToBeClosed = 0;
224 - if ( !rNextInfo.BelongsToSameList( rPrevInfo ) ||
225 + if ( !rNextInfo.BelongsToSameList( rPrevInfo,
226 + bGenerousListLevels ) ||
227 rNextInfo.GetLevel() <= 0 )
229 // close complete previous list
230 @@ -644,7 +648,8 @@ void XMLTextParagraphExport::exportListChange(
232 bool bRootListToBeStarted = false;
233 sal_Int16 nListLevelsToBeOpened = 0;
234 - if ( !rPrevInfo.BelongsToSameList( rNextInfo ) ||
235 + if ( !rPrevInfo.BelongsToSameList( rNextInfo,
236 + bGenerousListLevels ) ||
237 rPrevInfo.GetLevel() <= 0 )
240 @@ -851,7 +856,8 @@ void XMLTextParagraphExport::exportListChange(
242 if ( rNextInfo.GetLevel() > 0 &&
243 rNextInfo.IsNumbered() &&
244 - rPrevInfo.BelongsToSameList( rNextInfo ) &&
245 + rPrevInfo.BelongsToSameList( rNextInfo,
246 + bGenerousListLevels ) &&
247 rPrevInfo.GetLevel() >= rNextInfo.GetLevel() )
249 // close previous list-item