Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <editeng/numitem.hxx>
31 : :
32 : : #include <com/sun/star/text/HoriOrientation.hpp>
33 : : #include <com/sun/star/text/VertOrientation.hpp>
34 : : #include <com/sun/star/text/RelOrientation.hpp>
35 : : #include <editeng/brshitem.hxx>
36 : : #include <vcl/font.hxx>
37 : : #include <editeng/editids.hrc>
38 : : #include <editeng/editrids.hrc>
39 : : #include <editeng/numdef.hxx>
40 : : #include <vcl/graph.hxx>
41 : : #include <vcl/window.hxx>
42 : : #include <vcl/svapp.hxx>
43 : : #include <editeng/unolingu.hxx>
44 : : #include <com/sun/star/text/XNumberingFormatter.hpp>
45 : : #include <com/sun/star/text/DefaultNumberingProvider.hpp>
46 : : #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
47 : : #include <com/sun/star/style/NumberingType.hpp>
48 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
49 : : #include <com/sun/star/beans/PropertyValue.hpp>
50 : : #include <comphelper/processfactory.hxx>
51 : :
52 : : #include <editeng/unonrule.hxx>
53 : :
54 : : #define MM100_TO_TWIP(MM100) ((MM100*72L+63L)/127L)
55 : :
56 : : #define DEF_WRITER_LSPACE 500 //Standard Indentation
57 : : #define DEF_DRAW_LSPACE 800 //Standard Indentation
58 : :
59 : : #define NUMITEM_VERSION_01 0x01
60 : : #define NUMITEM_VERSION_02 0x02
61 : : #define NUMITEM_VERSION_03 0x03
62 : : #define NUMITEM_VERSION_04 0x04
63 : :
64 : : using namespace ::com::sun::star;
65 : : using namespace ::com::sun::star::lang;
66 : : using namespace ::com::sun::star::uno;
67 : : using namespace ::com::sun::star::text;
68 : : using namespace ::com::sun::star::beans;
69 : : using namespace ::com::sun::star::style;
70 : :
71 : : sal_Int32 SvxNumberType::nRefCount = 0;
72 : 159 : com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter> SvxNumberType::xFormatter = 0;
73 : 2625 : void lcl_getFormatter(com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter>& _xFormatter)
74 : : {
75 [ + + ]: 2625 : if(!_xFormatter.is())
76 : : {
77 : : try
78 : : {
79 [ + - ]: 59 : Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
80 [ + - ]: 59 : Reference<XDefaultNumberingProvider> xRet = text::DefaultNumberingProvider::create(xContext);
81 [ + - ][ + - ]: 59 : _xFormatter = Reference<XNumberingFormatter> (xRet, UNO_QUERY);
[ # # ]
82 : : }
83 : 0 : catch(const Exception&)
84 : : {
85 : : SAL_WARN("editeng", "service missing: \"com.sun.star.text.DefaultNumberingProvider\"");
86 : : }
87 : : }
88 : 2625 : }
89 : :
90 : 62905 : SvxNumberType::SvxNumberType(sal_Int16 nType) :
91 : : nNumType(nType),
92 : 62905 : bShowSymbol(sal_True)
93 : : {
94 : 62905 : nRefCount++;
95 : 62905 : }
96 : :
97 : 124801 : SvxNumberType::SvxNumberType(const SvxNumberType& rType) :
98 : : nNumType(rType.nNumType),
99 : 124801 : bShowSymbol(rType.bShowSymbol)
100 : : {
101 : 124801 : nRefCount++;
102 : 124801 : }
103 : :
104 : 186584 : SvxNumberType::~SvxNumberType()
105 : : {
106 [ + + ]: 186584 : if(!--nRefCount)
107 : 83 : xFormatter = 0;
108 : 186584 : }
109 : :
110 : 2625 : String SvxNumberType::GetNumStr( sal_uLong nNo ) const
111 : : {
112 [ + - ][ + - ]: 2625 : LanguageType eLang = Application::GetSettings().GetLanguage();
113 [ + - ]: 2625 : Locale aLocale = SvxCreateLocale(eLang);
114 [ + - ]: 2625 : return GetNumStr( nNo, aLocale );
115 : : }
116 : :
117 : 2625 : String SvxNumberType::GetNumStr( sal_uLong nNo, const Locale& rLocale ) const
118 : : {
119 : 2625 : lcl_getFormatter(xFormatter);
120 : 2625 : String aTmpStr;
121 [ - + ]: 2625 : if(!xFormatter.is())
122 : 0 : return aTmpStr;
123 : :
124 [ + - ]: 2625 : if(bShowSymbol)
125 : : {
126 [ - + ]: 2625 : switch(nNumType)
127 : : {
128 : : case NumberingType::CHAR_SPECIAL:
129 : : case NumberingType::BITMAP:
130 : 0 : break;
131 : : default:
132 : : {
133 : : // '0' allowed for ARABIC numberings
134 [ + + ][ - + ]: 2625 : if(NumberingType::ARABIC == nNumType && 0 == nNo )
135 [ # # ]: 0 : aTmpStr = '0';
136 : : else
137 : : {
138 [ + - ]: 2625 : Sequence< PropertyValue > aProperties(2);
139 [ + - ]: 2625 : PropertyValue* pValues = aProperties.getArray();
140 : 2625 : pValues[0].Name = rtl::OUString("NumberingType");
141 [ + - ]: 2625 : pValues[0].Value <<= nNumType;
142 : 2625 : pValues[1].Name = rtl::OUString("Value");
143 [ + - ]: 2625 : pValues[1].Value <<= (sal_Int32)nNo;
144 : :
145 : : try
146 : : {
147 [ + - ][ + - ]: 2625 : aTmpStr = xFormatter->makeNumberingString( aProperties, rLocale );
[ + - ][ # # ]
148 : : }
149 [ # # ]: 0 : catch(const Exception&)
150 : : {
151 [ + - ]: 2625 : }
152 : : }
153 : : }
154 : : }
155 : : }
156 : 2625 : return aTmpStr;
157 : : }
158 : :
159 : 54823 : SvxNumberFormat::SvxNumberFormat( sal_Int16 eType,
160 : : SvxNumPositionAndSpaceMode ePositionAndSpaceMode )
161 : : : SvxNumberType(eType),
162 : : eNumAdjust(SVX_ADJUST_LEFT),
163 : : nInclUpperLevels(0),
164 : : nStart(1),
165 : : cBullet(SVX_DEF_BULLET),
166 : : nBulletRelSize(100),
167 : : nBulletColor(COL_BLACK),
168 : : mePositionAndSpaceMode( ePositionAndSpaceMode ),
169 : : nFirstLineOffset(0),
170 : : nAbsLSpace(0),
171 : : nLSpace(0),
172 : : nCharTextDistance(0),
173 : : meLabelFollowedBy( LISTTAB ),
174 : : mnListtabPos( 0 ),
175 : : mnFirstLineIndent( 0 ),
176 : : mnIndentAt( 0 ),
177 : : pGraphicBrush(0),
178 : : eVertOrient(text::VertOrientation::NONE),
179 [ + - ]: 54823 : pBulletFont(0)
180 : : {
181 : 54823 : }
182 : :
183 : 121596 : SvxNumberFormat::SvxNumberFormat(const SvxNumberFormat& rFormat) :
184 : : SvxNumberType(rFormat),
185 : : mePositionAndSpaceMode( rFormat.mePositionAndSpaceMode ),
186 : : pGraphicBrush(0),
187 [ + - ]: 121596 : pBulletFont(0)
188 : : {
189 [ + - ]: 121596 : *this = rFormat;
190 : 121596 : }
191 : :
192 [ + - ]: 175706 : SvxNumberFormat::~SvxNumberFormat()
193 : : {
194 [ - + ][ # # ]: 175706 : delete pGraphicBrush;
195 [ + + ][ + - ]: 175706 : delete pBulletFont;
196 [ - + ]: 240902 : }
197 : :
198 : 0 : SvStream& SvxNumberFormat::Store(SvStream &rStream, FontToSubsFontConverter pConverter)
199 : : {
200 [ # # ][ # # ]: 0 : if(pConverter && pBulletFont)
201 : : {
202 [ # # ]: 0 : cBullet = ConvertFontToSubsFontChar(pConverter, cBullet);
203 [ # # ]: 0 : String sFontName = GetFontToSubsFontName(pConverter);
204 [ # # ][ # # ]: 0 : pBulletFont->SetName(sFontName);
[ # # ]
205 : : }
206 : :
207 [ # # ]: 0 : rStream << (sal_uInt16)NUMITEM_VERSION_04;
208 : :
209 [ # # ]: 0 : rStream << (sal_uInt16)GetNumberingType();
210 [ # # ]: 0 : rStream << (sal_uInt16)eNumAdjust;
211 [ # # ]: 0 : rStream << (sal_uInt16)nInclUpperLevels;
212 [ # # ]: 0 : rStream << nStart;
213 [ # # ]: 0 : rStream << (sal_uInt16)cBullet;
214 : :
215 [ # # ]: 0 : rStream << nFirstLineOffset;
216 [ # # ]: 0 : rStream << nAbsLSpace;
217 [ # # ]: 0 : rStream << nLSpace;
218 : :
219 [ # # ]: 0 : rStream << nCharTextDistance;
220 [ # # ]: 0 : rtl_TextEncoding eEnc = osl_getThreadTextEncoding();
221 [ # # ]: 0 : rStream.WriteUniOrByteString(sPrefix, eEnc);
222 [ # # ]: 0 : rStream.WriteUniOrByteString(sSuffix, eEnc);
223 [ # # ][ # # ]: 0 : rStream.WriteUniOrByteString(sCharStyleName, eEnc);
224 [ # # ]: 0 : if(pGraphicBrush)
225 : : {
226 [ # # ]: 0 : rStream << (sal_uInt16)1;
227 : :
228 : : // in SD or SI force bullet itself to be stored,
229 : : // for that purpose throw away link when link and graphic
230 : : // are present, so Brush save is forced
231 [ # # ][ # # ]: 0 : if(pGraphicBrush->GetGraphicLink() && pGraphicBrush->GetGraphic())
[ # # ][ # # ]
232 : : {
233 [ # # ]: 0 : String aEmpty;
234 [ # # ][ # # ]: 0 : pGraphicBrush->SetGraphicLink(aEmpty);
235 : : }
236 : :
237 [ # # ]: 0 : pGraphicBrush->Store(rStream, BRUSH_GRAPHIC_VERSION);
238 : : }
239 : : else
240 [ # # ]: 0 : rStream << (sal_uInt16)0;
241 : :
242 [ # # ]: 0 : rStream << (sal_uInt16)eVertOrient;
243 [ # # ]: 0 : if(pBulletFont)
244 : : {
245 [ # # ]: 0 : rStream << (sal_uInt16)1;
246 [ # # ]: 0 : rStream << *pBulletFont;
247 : : }
248 : : else
249 [ # # ]: 0 : rStream << (sal_uInt16)0;
250 [ # # ]: 0 : rStream << aGraphicSize;
251 : :
252 : 0 : Color nTempColor = nBulletColor;
253 [ # # ]: 0 : if(COL_AUTO == nBulletColor.GetColor())
254 : 0 : nTempColor = COL_BLACK;
255 [ # # ]: 0 : rStream << nTempColor;
256 [ # # ]: 0 : rStream << nBulletRelSize;
257 [ # # ]: 0 : rStream << (sal_uInt16)IsShowSymbol();
258 : :
259 [ # # ]: 0 : rStream << ( sal_uInt16 ) mePositionAndSpaceMode;
260 [ # # ]: 0 : rStream << ( sal_uInt16 ) meLabelFollowedBy;
261 [ # # ]: 0 : rStream << ( sal_Int32 ) mnListtabPos;
262 [ # # ]: 0 : rStream << ( sal_Int32 ) mnFirstLineIndent;
263 [ # # ]: 0 : rStream << ( sal_Int32 ) mnIndentAt;
264 : :
265 : 0 : return rStream;
266 : : }
267 : :
268 : 121842 : SvxNumberFormat& SvxNumberFormat::operator=( const SvxNumberFormat& rFormat )
269 : : {
270 [ - + ]: 121842 : if (& rFormat == this) { return *this; }
271 : :
272 : 121842 : SetNumberingType(rFormat.GetNumberingType());
273 : 121842 : eNumAdjust = rFormat.eNumAdjust ;
274 : 121842 : nInclUpperLevels = rFormat.nInclUpperLevels ;
275 : 121842 : nStart = rFormat.nStart ;
276 : 121842 : cBullet = rFormat.cBullet ;
277 : 121842 : mePositionAndSpaceMode = rFormat.mePositionAndSpaceMode;
278 : 121842 : nFirstLineOffset = rFormat.nFirstLineOffset;
279 : 121842 : nAbsLSpace = rFormat.nAbsLSpace ;
280 : 121842 : nLSpace = rFormat.nLSpace ;
281 : 121842 : nCharTextDistance = rFormat.nCharTextDistance ;
282 : 121842 : meLabelFollowedBy = rFormat.meLabelFollowedBy;
283 : 121842 : mnListtabPos = rFormat.mnListtabPos;
284 : 121842 : mnFirstLineIndent = rFormat.mnFirstLineIndent;
285 : 121842 : mnIndentAt = rFormat.mnIndentAt;
286 : 121842 : eVertOrient = rFormat.eVertOrient ;
287 : 121842 : sPrefix = rFormat.sPrefix ;
288 : 121842 : sSuffix = rFormat.sSuffix ;
289 : 121842 : aGraphicSize = rFormat.aGraphicSize ;
290 : 121842 : nBulletColor = rFormat.nBulletColor ;
291 : 121842 : nBulletRelSize = rFormat.nBulletRelSize;
292 : 121842 : SetShowSymbol(rFormat.IsShowSymbol());
293 : 121842 : sCharStyleName = rFormat.sCharStyleName;
294 [ - + ]: 121842 : DELETEZ(pGraphicBrush);
295 [ - + ]: 121842 : if(rFormat.pGraphicBrush)
296 : : {
297 [ # # ]: 0 : pGraphicBrush = new SvxBrushItem(*rFormat.pGraphicBrush);
298 [ # # ]: 0 : pGraphicBrush->SetDoneLink( STATIC_LINK( this, SvxNumberFormat, GraphicArrived) );
299 : : }
300 [ + + ]: 121842 : DELETEZ(pBulletFont);
301 [ + + ]: 121842 : if(rFormat.pBulletFont)
302 [ + - ]: 58999 : pBulletFont = new Font(*rFormat.pBulletFont);
303 : 121842 : return *this;
304 : : }
305 : :
306 : 40972 : sal_Bool SvxNumberFormat::operator==( const SvxNumberFormat& rFormat) const
307 : : {
308 [ + + ][ + - ]: 268006 : if( GetNumberingType() != rFormat.GetNumberingType() ||
[ + + ][ + - ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + - ]
[ + - ][ + + ]
[ + + ][ + - ]
[ + - + -
+ - + - +
- ][ + + +
- + + ]
[ + + ]
309 : : eNumAdjust != rFormat.eNumAdjust ||
310 : : nInclUpperLevels != rFormat.nInclUpperLevels ||
311 : : nStart != rFormat.nStart ||
312 : : cBullet != rFormat.cBullet ||
313 : : mePositionAndSpaceMode != rFormat.mePositionAndSpaceMode ||
314 : : nFirstLineOffset != rFormat.nFirstLineOffset ||
315 : : nAbsLSpace != rFormat.nAbsLSpace ||
316 : : nLSpace != rFormat.nLSpace ||
317 : : nCharTextDistance != rFormat.nCharTextDistance ||
318 : : meLabelFollowedBy != rFormat.meLabelFollowedBy ||
319 : : mnListtabPos != rFormat.mnListtabPos ||
320 : : mnFirstLineIndent != rFormat.mnFirstLineIndent ||
321 : : mnIndentAt != rFormat.mnIndentAt ||
322 : : eVertOrient != rFormat.eVertOrient ||
323 : 37878 : sPrefix != rFormat.sPrefix ||
324 : 37878 : sSuffix != rFormat.sSuffix ||
325 : 37878 : aGraphicSize != rFormat.aGraphicSize ||
326 : 37878 : nBulletColor != rFormat.nBulletColor ||
327 : : nBulletRelSize != rFormat.nBulletRelSize ||
328 : 37761 : IsShowSymbol() != rFormat.IsShowSymbol() ||
329 : 37761 : sCharStyleName != rFormat.sCharStyleName
330 : : )
331 : 3602 : return sal_False;
332 [ - + ][ # # ]: 37370 : if (
[ + - ][ + - ]
[ - + # # ]
[ - + ]
333 : 0 : (pGraphicBrush && !rFormat.pGraphicBrush) ||
334 : 37370 : (!pGraphicBrush && rFormat.pGraphicBrush) ||
335 : 0 : (pGraphicBrush && *pGraphicBrush != *rFormat.pGraphicBrush)
336 : : )
337 : : {
338 : 0 : return sal_False;
339 : : }
340 [ + + ][ + + ]: 54131 : if (
[ + + ][ + - ]
[ + + + + ]
[ + + ]
341 : 17298 : (pBulletFont && !rFormat.pBulletFont) ||
342 : 36833 : (!pBulletFont && rFormat.pBulletFont) ||
343 : 16761 : (pBulletFont && *pBulletFont != *rFormat.pBulletFont)
344 : : )
345 : : {
346 : 3574 : return sal_False;
347 : : }
348 : 40972 : return sal_True;
349 : : }
350 : :
351 : 60468 : void SvxNumberFormat::SetGraphicBrush( const SvxBrushItem* pBrushItem,
352 : : const Size* pSize, const sal_Int16* pOrient)
353 : : {
354 [ + - ]: 60468 : if(!pBrushItem)
355 : : {
356 [ - + ]: 60468 : delete pGraphicBrush;
357 : 60468 : pGraphicBrush = 0;
358 : : }
359 [ # # ][ # # ]: 0 : else if ( !pGraphicBrush || (pGraphicBrush && !(*pBrushItem == *pGraphicBrush)) )
[ # # ][ # # ]
360 : : {
361 [ # # ]: 0 : delete pGraphicBrush;
362 : 0 : pGraphicBrush = (SvxBrushItem*)pBrushItem->Clone();
363 [ # # ]: 0 : pGraphicBrush->SetDoneLink( STATIC_LINK( this, SvxNumberFormat, GraphicArrived) );
364 : : }
365 : :
366 [ + - ]: 60468 : if(pOrient)
367 : 60468 : eVertOrient = *pOrient;
368 : : else
369 : 0 : eVertOrient = text::VertOrientation::NONE;
370 [ + - ]: 60468 : if(pSize)
371 : 60468 : aGraphicSize = *pSize;
372 : : else
373 : 0 : aGraphicSize.Width() = aGraphicSize.Height() = 0;
374 : 60468 : }
375 : :
376 : 0 : void SvxNumberFormat::SetGraphic( const String& rName )
377 : : {
378 : : const String* pName;
379 [ # # ][ # # ]: 0 : if( pGraphicBrush &&
[ # # ][ # # ]
380 : 0 : 0 != (pName = pGraphicBrush->GetGraphicLink())
381 [ # # ]: 0 : && *pName == rName )
382 : 0 : return ;
383 : :
384 [ # # ][ # # ]: 0 : delete pGraphicBrush;
385 [ # # ]: 0 : String sTmp;
386 [ # # ][ # # ]: 0 : pGraphicBrush = new SvxBrushItem( rName, sTmp, GPOS_AREA, 0 );
387 [ # # ][ # # ]: 0 : pGraphicBrush->SetDoneLink( STATIC_LINK( this, SvxNumberFormat, GraphicArrived) );
388 [ # # ]: 0 : if( eVertOrient == text::VertOrientation::NONE )
389 : 0 : eVertOrient = text::VertOrientation::TOP;
390 : :
391 [ # # ]: 0 : aGraphicSize.Width() = aGraphicSize.Height() = 0;
392 : : }
393 : :
394 : 0 : void SvxNumberFormat::SetVertOrient(sal_Int16 eSet)
395 : : {
396 : 0 : eVertOrient = eSet;
397 : 0 : }
398 : :
399 : 120936 : sal_Int16 SvxNumberFormat::GetVertOrient() const
400 : : {
401 : 120936 : return eVertOrient;
402 : : }
403 : :
404 : 7299 : void SvxNumberFormat::SetBulletFont(const Font* pFont)
405 : : {
406 [ + + ]: 7299 : delete pBulletFont;
407 [ + - ][ + - ]: 7299 : pBulletFont = pFont ? new Font(*pFont): 0;
408 : 7299 : }
409 : :
410 : 22307 : SvxNumberFormat::SvxNumPositionAndSpaceMode SvxNumberFormat::GetPositionAndSpaceMode() const
411 : : {
412 : 22307 : return mePositionAndSpaceMode;
413 : : }
414 : 23010 : void SvxNumberFormat::SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode )
415 : : {
416 : 23010 : mePositionAndSpaceMode = ePositionAndSpaceMode;
417 : 23010 : }
418 : :
419 : 0 : short SvxNumberFormat::GetLSpace() const
420 : : {
421 [ # # ]: 0 : return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION ? nLSpace : 0;
422 : : }
423 : 6966 : short SvxNumberFormat::GetAbsLSpace() const
424 : : {
425 : : return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION
426 : : ? nAbsLSpace
427 [ + - ]: 6966 : : static_cast<short>( GetFirstLineIndent() + GetIndentAt() );
428 : : }
429 : 10956 : short SvxNumberFormat::GetFirstLineOffset() const
430 : : {
431 : : return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION
432 : : ? nFirstLineOffset
433 [ + - ]: 10956 : : static_cast<short>( GetFirstLineIndent() );
434 : : }
435 : 2665 : short SvxNumberFormat::GetCharTextDistance() const
436 : : {
437 [ + - ]: 2665 : return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION ? nCharTextDistance : 0;
438 : : }
439 : :
440 : 28887 : void SvxNumberFormat::SetLabelFollowedBy( const LabelFollowedBy eLabelFollowedBy )
441 : : {
442 : 28887 : meLabelFollowedBy = eLabelFollowedBy;
443 : 28887 : }
444 : 1154 : SvxNumberFormat::LabelFollowedBy SvxNumberFormat::GetLabelFollowedBy() const
445 : : {
446 : 1154 : return meLabelFollowedBy;
447 : : }
448 : 28977 : void SvxNumberFormat::SetListtabPos( const long nListtabPos )
449 : : {
450 : 28977 : mnListtabPos = nListtabPos;
451 : 28977 : }
452 : 926 : long SvxNumberFormat::GetListtabPos() const
453 : : {
454 : 926 : return mnListtabPos;
455 : : }
456 : 28980 : void SvxNumberFormat::SetFirstLineIndent( const long nFirstLineIndent )
457 : : {
458 : 28980 : mnFirstLineIndent = nFirstLineIndent;
459 : 28980 : }
460 : 3587 : long SvxNumberFormat::GetFirstLineIndent() const
461 : : {
462 : 3587 : return mnFirstLineIndent;
463 : : }
464 : 29070 : void SvxNumberFormat::SetIndentAt( const long nIndentAt )
465 : : {
466 : 29070 : mnIndentAt = nIndentAt;
467 : 29070 : }
468 : 2576 : long SvxNumberFormat::GetIndentAt() const
469 : : {
470 : 2576 : return mnIndentAt;
471 : : }
472 : :
473 : 0 : IMPL_STATIC_LINK( SvxNumberFormat, GraphicArrived, void *, EMPTYARG )
474 : : {
475 : : // if necessary, set the GrfSize:
476 [ # # ][ # # ]: 0 : if( !pThis->aGraphicSize.Width() || !pThis->aGraphicSize.Height() )
[ # # ]
477 : : {
478 : 0 : const Graphic* pGrf = pThis->pGraphicBrush->GetGraphic();
479 [ # # ]: 0 : if( pGrf )
480 : 0 : pThis->aGraphicSize = SvxNumberFormat::GetGraphicSizeMM100( pGrf );
481 : : }
482 : 0 : pThis->NotifyGraphicArrived();
483 : 0 : return 0;
484 : : }
485 : :
486 : 0 : void SvxNumberFormat::NotifyGraphicArrived()
487 : : {
488 : 0 : }
489 : :
490 : 0 : Size SvxNumberFormat::GetGraphicSizeMM100(const Graphic* pGraphic)
491 : : {
492 [ # # ]: 0 : const MapMode aMapMM100( MAP_100TH_MM );
493 [ # # ]: 0 : const Size& rSize = pGraphic->GetPrefSize();
494 : 0 : Size aRetSize;
495 [ # # ][ # # ]: 0 : if ( pGraphic->GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
[ # # ]
496 : : {
497 [ # # ]: 0 : OutputDevice* pOutDev = Application::GetDefaultDevice();
498 [ # # ]: 0 : MapMode aOldMap( pOutDev->GetMapMode() );
499 [ # # ]: 0 : pOutDev->SetMapMode( aMapMM100 );
500 [ # # ]: 0 : aRetSize = pOutDev->PixelToLogic( rSize );
501 [ # # ][ # # ]: 0 : pOutDev->SetMapMode( aOldMap );
502 : : }
503 : : else
504 [ # # ][ # # ]: 0 : aRetSize = OutputDevice::LogicToLogic( rSize, pGraphic->GetPrefMapMode(), aMapMM100 );
[ # # ]
505 [ # # ]: 0 : return aRetSize;
506 : : }
507 : :
508 : 0 : String SvxNumberFormat::CreateRomanString( sal_uLong nNo, sal_Bool bUpper )
509 : : {
510 : 0 : nNo %= 4000; // more can not be displayed
511 : : // i, ii, iii, iv, v, vi, vii, vii, viii, ix
512 : : // (Dummy),1000,500,100,50,10,5,1
513 : : const char *cRomanArr = bUpper
514 : : ? "MDCLXVI--" // +2 Dummy entries!
515 [ # # ]: 0 : : "mdclxvi--"; // +2 Dummy entries!
516 : :
517 : 0 : String sRet;
518 : 0 : sal_uInt16 nMask = 1000;
519 [ # # ]: 0 : while( nMask )
520 : : {
521 : 0 : sal_uInt8 nZahl = sal_uInt8(nNo / nMask);
522 : 0 : sal_uInt8 nDiff = 1;
523 : 0 : nNo %= nMask;
524 : :
525 [ # # ]: 0 : if( 5 < nZahl )
526 : : {
527 [ # # ]: 0 : if( nZahl < 9 )
528 [ # # ]: 0 : sRet += sal_Unicode(*(cRomanArr-1));
529 : 0 : ++nDiff;
530 : 0 : nZahl -= 5;
531 : : }
532 [ # # # # : 0 : switch( nZahl )
# # ]
533 : : {
534 [ # # ]: 0 : case 3: { sRet += sal_Unicode(*cRomanArr); }
535 [ # # ]: 0 : case 2: { sRet += sal_Unicode(*cRomanArr); }
536 [ # # ]: 0 : case 1: { sRet += sal_Unicode(*cRomanArr); }
537 : 0 : break;
538 : :
539 : : case 4: {
540 [ # # ]: 0 : sRet += sal_Unicode(*cRomanArr);
541 [ # # ]: 0 : sRet += sal_Unicode(*(cRomanArr-nDiff));
542 : : }
543 : 0 : break;
544 [ # # ]: 0 : case 5: { sRet += sal_Unicode(*(cRomanArr-nDiff)); }
545 : 0 : break;
546 : : }
547 : :
548 : 0 : nMask /= 10; // for the next decade
549 : 0 : cRomanArr += 2;
550 : : }
551 : 0 : return sRet;
552 : : }
553 : :
554 : 1160 : const String& SvxNumberFormat::GetCharFmtName()const
555 : : {
556 : 1160 : return sCharStyleName;
557 : : }
558 : :
559 : : sal_Int32 SvxNumRule::nRefCount = 0;
560 : : static SvxNumberFormat* pStdNumFmt = 0;
561 : : static SvxNumberFormat* pStdOutlineNumFmt = 0;
562 : 1245 : SvxNumRule::SvxNumRule( sal_uLong nFeatures,
563 : : sal_uInt16 nLevels,
564 : : sal_Bool bCont,
565 : : SvxNumRuleType eType,
566 : : SvxNumberFormat::SvxNumPositionAndSpaceMode
567 : : eDefaultNumberFormatPositionAndSpaceMode )
568 : : : nLevelCount(nLevels),
569 : : nFeatureFlags(nFeatures),
570 : : eNumberingType(eType),
571 : 1245 : bContinuousNumbering(bCont)
572 : : {
573 : 1245 : ++nRefCount;
574 [ + - ][ + - ]: 1245 : LanguageType eLang = Application::GetSettings().GetLanguage();
575 [ + - ]: 1245 : aLocale = SvxCreateLocale(eLang);
576 [ + + ]: 13695 : for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
577 : : {
578 [ + + ]: 12450 : if(i < nLevels)
579 : : {
580 [ + - ][ + - ]: 10654 : aFmts[i] = new SvxNumberFormat(SVX_NUM_CHARS_UPPER_LETTER);
581 : : // It is a distinction between writer and draw
582 [ + + ]: 10654 : if(nFeatures & NUM_CONTINUOUS)
583 : : {
584 [ + - ]: 1160 : if ( eDefaultNumberFormatPositionAndSpaceMode ==
585 : : SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
586 : : {
587 : 1160 : aFmts[i]->SetLSpace( MM100_TO_TWIP(DEF_WRITER_LSPACE) );
588 : 1160 : aFmts[i]->SetAbsLSpace( MM100_TO_TWIP(DEF_WRITER_LSPACE * (i+1)) );
589 : 1160 : aFmts[i]->SetFirstLineOffset(MM100_TO_TWIP(-DEF_WRITER_LSPACE));
590 : : }
591 [ # # ]: 0 : else if ( eDefaultNumberFormatPositionAndSpaceMode ==
592 : : SvxNumberFormat::LABEL_ALIGNMENT )
593 : : {
594 : : // first line indent of general numbering in inch: -0,25 inch
595 : 0 : const long cFirstLineIndent = -1440/4;
596 : : // indent values of general numbering in inch:
597 : : // 0,5 0,75 1,0 1,25 1,5
598 : : // 1,75 2,0 2,25 2,5 2,75
599 : 0 : const long cIndentAt = 1440/4;
600 [ # # ]: 0 : aFmts[i]->SetPositionAndSpaceMode( SvxNumberFormat::LABEL_ALIGNMENT );
601 [ # # ]: 0 : aFmts[i]->SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
602 [ # # ]: 0 : aFmts[i]->SetListtabPos( cIndentAt * (i+2) );
603 [ # # ]: 0 : aFmts[i]->SetFirstLineIndent( cFirstLineIndent );
604 [ # # ]: 0 : aFmts[i]->SetIndentAt( cIndentAt * (i+2) );
605 : : }
606 : : }
607 : : else
608 : : {
609 : 9494 : aFmts[i]->SetLSpace( DEF_DRAW_LSPACE );
610 : 9494 : aFmts[i]->SetAbsLSpace( DEF_DRAW_LSPACE * (i) );
611 : : }
612 : : }
613 : : else
614 : 1796 : aFmts[i] = 0;
615 : 12450 : aFmtsSet[i] = sal_False;
616 : : }
617 : 1245 : }
618 : :
619 : 5400 : SvxNumRule::SvxNumRule(const SvxNumRule& rCopy)
620 : : {
621 : 5400 : ++nRefCount;
622 : 5400 : aLocale = rCopy.aLocale;
623 : 5400 : nLevelCount = rCopy.nLevelCount ;
624 : 5400 : nFeatureFlags = rCopy.nFeatureFlags ;
625 : 5400 : bContinuousNumbering = rCopy.bContinuousNumbering;
626 : 5400 : eNumberingType = rCopy.eNumberingType;
627 : 5400 : memset( aFmts, 0, sizeof( aFmts ));
628 [ + + ]: 59400 : for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
629 : : {
630 [ + + ]: 54000 : if(rCopy.aFmts[i])
631 [ + - ][ + - ]: 43208 : aFmts[i] = new SvxNumberFormat(*rCopy.aFmts[i]);
632 : : else
633 : 10792 : aFmts[i] = 0;
634 : 54000 : aFmtsSet[i] = rCopy.aFmtsSet[i];
635 : : }
636 : 5400 : }
637 : :
638 : 0 : SvStream& SvxNumRule::Store(SvStream &rStream)
639 : : {
640 : 0 : rStream<<(sal_uInt16)NUMITEM_VERSION_03;
641 : 0 : rStream<<nLevelCount;
642 : : //first save of nFeatureFlags for old versions
643 : 0 : rStream<<(sal_uInt16)nFeatureFlags;
644 : 0 : rStream<<(sal_uInt16)bContinuousNumbering;
645 : 0 : rStream<<(sal_uInt16)eNumberingType;
646 : :
647 : 0 : FontToSubsFontConverter pConverter = 0;
648 : 0 : sal_Bool bConvertBulletFont = rStream.GetVersion() <= SOFFICE_FILEFORMAT_50;
649 [ # # ]: 0 : for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
650 : : {
651 [ # # ]: 0 : if(aFmts[i])
652 : : {
653 : 0 : rStream << sal_uInt16(1);
654 [ # # ][ # # ]: 0 : if(bConvertBulletFont && aFmts[i]->GetBulletFont())
[ # # ]
655 : : {
656 [ # # ]: 0 : if(!pConverter)
657 : : pConverter =
658 : 0 : CreateFontToSubsFontConverter(aFmts[i]->GetBulletFont()->GetName(),
659 : 0 : FONTTOSUBSFONT_EXPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS);
660 : : }
661 : 0 : aFmts[i]->Store(rStream, pConverter);
662 : : }
663 : : else
664 : 0 : rStream << sal_uInt16(0);
665 : : }
666 : : //second save of nFeatureFlags for new versions
667 : 0 : rStream<<(sal_uInt16)nFeatureFlags;
668 [ # # ]: 0 : if(pConverter)
669 : 0 : DestroyFontToSubsFontConverter(pConverter);
670 : :
671 : 0 : return rStream;
672 : : }
673 : :
674 : 6621 : SvxNumRule::~SvxNumRule()
675 : : {
676 [ + + ]: 72831 : for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
677 [ + + ][ + - ]: 66210 : delete aFmts[i];
678 [ + + ]: 6621 : if(!--nRefCount)
679 : : {
680 [ + + ][ + - ]: 134 : DELETEZ(pStdNumFmt);
681 [ + + ][ + - ]: 134 : DELETEZ(pStdOutlineNumFmt);
682 : : }
683 [ - + ]: 10965 : }
684 : :
685 : 0 : SvxNumRule& SvxNumRule::operator=( const SvxNumRule& rCopy )
686 : : {
687 : 0 : nLevelCount = rCopy.nLevelCount;
688 : 0 : nFeatureFlags = rCopy.nFeatureFlags;
689 : 0 : bContinuousNumbering = rCopy.bContinuousNumbering;
690 : 0 : eNumberingType = rCopy.eNumberingType;
691 [ # # ]: 0 : for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
692 : : {
693 [ # # ]: 0 : delete aFmts[i];
694 [ # # ]: 0 : if(rCopy.aFmts[i])
695 [ # # ]: 0 : aFmts[i] = new SvxNumberFormat(*rCopy.aFmts[i]);
696 : : else
697 : 0 : aFmts[i] = 0;
698 : 0 : aFmtsSet[i] = rCopy.aFmtsSet[i];
699 : : }
700 : 0 : return *this;
701 : : }
702 : :
703 : 7043 : int SvxNumRule::operator==( const SvxNumRule& rCopy) const
704 : : {
705 [ + + ][ + + ]: 7043 : if(nLevelCount != rCopy.nLevelCount ||
[ + - ][ + + ]
706 : : nFeatureFlags != rCopy.nFeatureFlags ||
707 : : bContinuousNumbering != rCopy.bContinuousNumbering ||
708 : : eNumberingType != rCopy.eNumberingType)
709 : 1162 : return sal_False;
710 [ + + ]: 16934 : for(sal_uInt16 i = 0; i < nLevelCount; i++)
711 : : {
712 [ + - ][ - + ]: 31658 : if (
[ # # ][ + - ]
[ + - ]
[ + - + + ]
[ + + ]
713 : 31658 : (aFmtsSet[i] != rCopy.aFmtsSet[i]) ||
714 : 15829 : (!aFmts[i] && rCopy.aFmts[i]) ||
715 : 31658 : (aFmts[i] && !rCopy.aFmts[i]) ||
716 : 15829 : (aFmts[i] && *aFmts[i] != *rCopy.aFmts[i])
717 : : )
718 : : {
719 : 4776 : return sal_False;
720 : : }
721 : : }
722 : 7043 : return sal_True;
723 : : }
724 : :
725 : 25204 : const SvxNumberFormat* SvxNumRule::Get(sal_uInt16 nLevel)const
726 : : {
727 : : DBG_ASSERT(nLevel < SVX_MAX_NUM, "Wrong Level" );
728 [ + - ]: 25204 : if( nLevel < SVX_MAX_NUM )
729 [ + - ]: 25204 : return aFmtsSet[nLevel] ? aFmts[nLevel] : 0;
730 : : else
731 : 25204 : return 0;
732 : : }
733 : :
734 : 7496 : const SvxNumberFormat& SvxNumRule::GetLevel(sal_uInt16 nLevel)const
735 : : {
736 [ + + ]: 7496 : if(!pStdNumFmt)
737 : : {
738 [ + - ]: 36 : pStdNumFmt = new SvxNumberFormat(SVX_NUM_ARABIC);
739 [ + - ]: 36 : pStdOutlineNumFmt = new SvxNumberFormat(SVX_NUM_NUMBER_NONE);
740 : : }
741 : :
742 : : DBG_ASSERT(nLevel < SVX_MAX_NUM, "Wrong Level" );
743 : :
744 : 7496 : return ( ( nLevel < SVX_MAX_NUM ) && aFmts[nLevel] ) ?
745 : 7496 : *aFmts[nLevel] : eNumberingType == SVX_RULETYPE_NUMBERING ?
746 [ + - ][ + - ]: 7496 : *pStdNumFmt : *pStdOutlineNumFmt;
[ # # ]
747 : : }
748 : :
749 : 13820 : void SvxNumRule::SetLevel( sal_uInt16 i, const SvxNumberFormat& rNumFmt, sal_Bool bIsValid )
750 : : {
751 : : DBG_ASSERT(i < SVX_MAX_NUM, "Wrong Level" );
752 : :
753 [ + - ][ + + ]: 13820 : if( (i < SVX_MAX_NUM) && (!aFmtsSet[i] || !(rNumFmt == *Get( i ))) )
[ + + ][ + + ]
754 : : {
755 [ + - ]: 11508 : delete aFmts[ i ];
756 [ + - ]: 11508 : aFmts[ i ] = new SvxNumberFormat( rNumFmt );
757 : 11508 : aFmtsSet[i] = bIsValid;
758 : : }
759 : 13820 : }
760 : :
761 : 0 : String SvxNumRule::MakeNumString( const SvxNodeNum& rNum, sal_Bool bInclStrings ) const
762 : : {
763 : 0 : String aStr;
764 [ # # ][ # # ]: 0 : if( SVX_NO_NUM > rNum.GetLevel() && !( SVX_NO_NUMLEVEL & rNum.GetLevel() ) )
[ # # ]
765 : : {
766 [ # # ]: 0 : const SvxNumberFormat& rMyNFmt = GetLevel( rNum.GetLevel() );
767 [ # # ]: 0 : if( SVX_NUM_NUMBER_NONE != rMyNFmt.GetNumberingType() )
768 : : {
769 : 0 : sal_uInt8 i = rNum.GetLevel();
770 : :
771 [ # # ]: 0 : if( !IsContinuousNumbering() &&
[ # # # # ]
772 : 0 : 1 < rMyNFmt.GetIncludeUpperLevels() ) // only on own level?
773 : : {
774 : 0 : sal_uInt8 n = rMyNFmt.GetIncludeUpperLevels();
775 [ # # ]: 0 : if( 1 < n )
776 : : {
777 [ # # ]: 0 : if( i+1 >= n )
778 : 0 : i -= n - 1;
779 : : else
780 : 0 : i = 0;
781 : : }
782 : : }
783 : :
784 [ # # ]: 0 : for( ; i <= rNum.GetLevel(); ++i )
785 : : {
786 [ # # ]: 0 : const SvxNumberFormat& rNFmt = GetLevel( i );
787 [ # # ]: 0 : if( SVX_NUM_NUMBER_NONE == rNFmt.GetNumberingType() )
788 : : {
789 : 0 : continue;
790 : : }
791 : :
792 : 0 : sal_Bool bDot = sal_True;
793 [ # # ]: 0 : if( rNum.GetLevelVal()[ i ] )
794 : : {
795 [ # # ]: 0 : if(SVX_NUM_BITMAP != rNFmt.GetNumberingType())
796 [ # # ][ # # ]: 0 : aStr += rNFmt.GetNumStr( rNum.GetLevelVal()[ i ], aLocale );
[ # # ]
797 : : else
798 : 0 : bDot = sal_False;
799 : : }
800 : : else
801 [ # # ]: 0 : aStr += sal_Unicode('0'); // all 0-levels are a 0
802 [ # # ][ # # ]: 0 : if( i != rNum.GetLevel() && bDot)
[ # # ]
803 [ # # ]: 0 : aStr += sal_Unicode('.');
804 : : }
805 : : }
806 : :
807 [ # # ]: 0 : if( bInclStrings )
808 : : {
809 [ # # ][ # # ]: 0 : aStr.Insert( rMyNFmt.GetPrefix(), 0 );
[ # # ]
810 [ # # ]: 0 : aStr += rMyNFmt.GetSuffix();
811 : : }
812 : : }
813 : 0 : return aStr;
814 : : }
815 : :
816 : : // changes linked to embedded bitmaps
817 : 116 : sal_Bool SvxNumRule::UnLinkGraphics()
818 : : {
819 : 116 : sal_Bool bRet = sal_False;
820 [ + + ]: 1276 : for(sal_uInt16 i = 0; i < GetLevelCount(); i++)
821 : : {
822 [ + - ][ + - ]: 1160 : SvxNumberFormat aFmt(GetLevel(i));
823 : 1160 : const SvxBrushItem* pBrush = aFmt.GetBrush();
824 : : const String* pLinkStr;
825 : : const Graphic* pGraphic;
826 [ - + ]: 1160 : if(SVX_NUM_BITMAP == aFmt.GetNumberingType())
827 : : {
828 [ # # ]: 0 : if(pBrush &&
[ # # # # ]
[ # # ][ # # ]
[ # # ]
829 : : 0 != (pLinkStr = pBrush->GetGraphicLink()) &&
830 : 0 : pLinkStr->Len() &&
831 : : 0 !=(pGraphic = pBrush->GetGraphic()))
832 : : {
833 [ # # ]: 0 : SvxBrushItem aTempItem(*pBrush);
834 [ # # ][ # # ]: 0 : aTempItem.SetGraphicLink( String());
[ # # ]
835 [ # # ]: 0 : aTempItem.SetGraphic(*pGraphic);
836 [ # # ]: 0 : sal_Int16 eOrient = aFmt.GetVertOrient();
837 [ # # ]: 0 : aFmt.SetGraphicBrush( &aTempItem, &aFmt.GetGraphicSize(), &eOrient );
838 [ # # ]: 0 : bRet = sal_True;
839 : : }
840 : : }
841 [ - + ]: 1160 : else if((SVX_NUM_BITMAP|LINK_TOKEN) == aFmt.GetNumberingType())
842 : 0 : aFmt.SetNumberingType(SVX_NUM_BITMAP);
843 [ + - ]: 1160 : SetLevel(i, aFmt);
844 [ + - ]: 1160 : }
845 : 116 : return bRet;
846 : : }
847 : :
848 : 116 : SvxNumBulletItem::SvxNumBulletItem(SvxNumRule& rRule) :
849 : : SfxPoolItem(SID_ATTR_NUMBERING_RULE),
850 [ + - ][ + - ]: 116 : pNumRule(new SvxNumRule(rRule))
851 : : {
852 : 116 : }
853 : :
854 : 1107 : SvxNumBulletItem::SvxNumBulletItem(SvxNumRule& rRule, sal_uInt16 _nWhich ) :
855 : : SfxPoolItem(_nWhich),
856 [ + - ][ + - ]: 1107 : pNumRule(new SvxNumRule(rRule))
857 : : {
858 : 1107 : }
859 : :
860 : 0 : SfxPoolItem* SvxNumBulletItem::Create(SvStream &s, sal_uInt16 n) const
861 : : {
862 : 0 : return SfxPoolItem::Create(s, n );
863 : : }
864 : :
865 : 3029 : SvxNumBulletItem::SvxNumBulletItem(const SvxNumBulletItem& rCopy) :
866 : 3029 : SfxPoolItem(rCopy.Which())
867 : : {
868 [ + - ][ + - ]: 3029 : pNumRule = new SvxNumRule(*rCopy.pNumRule);
869 : 3029 : }
870 : :
871 : 4228 : SvxNumBulletItem::~SvxNumBulletItem()
872 : : {
873 [ + - ][ + - ]: 4228 : delete pNumRule;
874 [ - + ]: 7310 : }
875 : :
876 : 7043 : int SvxNumBulletItem::operator==( const SfxPoolItem& rCopy) const
877 : : {
878 : 7043 : return *pNumRule == *((SvxNumBulletItem&)rCopy).pNumRule;
879 : : }
880 : :
881 : 2861 : SfxPoolItem* SvxNumBulletItem::Clone( SfxItemPool * ) const
882 : : {
883 [ + - ]: 2861 : return new SvxNumBulletItem(*this);
884 : : }
885 : :
886 : 7116 : sal_uInt16 SvxNumBulletItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const
887 : : {
888 : 7116 : return NUMITEM_VERSION_03;
889 : : }
890 : :
891 : 0 : SvStream& SvxNumBulletItem::Store(SvStream &rStream, sal_uInt16 /*nItemVersion*/ )const
892 : : {
893 : 0 : pNumRule->Store(rStream);
894 : 0 : return rStream;
895 : : }
896 : :
897 : 0 : bool SvxNumBulletItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
898 : : {
899 [ # # ]: 0 : rVal <<= SvxCreateNumRule( pNumRule );
900 : 0 : return true;
901 : : }
902 : :
903 : 116 : bool SvxNumBulletItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
904 : : {
905 : 116 : uno::Reference< container::XIndexReplace > xRule;
906 [ + - ][ + - ]: 116 : if( rVal >>= xRule )
907 : : {
908 : : try
909 : : {
910 [ + - ][ + - ]: 116 : SvxNumRule* pNewRule = new SvxNumRule( SvxGetNumRule( xRule ) );
[ + - ][ # # ]
911 [ - + ]: 232 : if( pNewRule->GetLevelCount() != pNumRule->GetLevelCount() ||
[ + - - + ]
912 : 116 : pNewRule->GetNumRuleType() != pNumRule->GetNumRuleType() )
913 : : {
914 [ # # ]: 0 : SvxNumRule* pConverted = SvxConvertNumRule( pNewRule, pNumRule->GetLevelCount(), pNumRule->GetNumRuleType() );
915 [ # # ][ # # ]: 0 : delete pNewRule;
916 : 0 : pNewRule = pConverted;
917 : : }
918 [ + - ][ + - ]: 116 : delete pNumRule;
919 : 116 : pNumRule = pNewRule;
920 : 116 : return true;
921 : : }
922 [ # # ]: 0 : catch(const lang::IllegalArgumentException&)
923 : : {
924 : : }
925 : : }
926 : 116 : return false;
927 : : }
928 : :
929 : 0 : SvxNumRule* SvxConvertNumRule( const SvxNumRule* pRule, sal_uInt16 nLevels, SvxNumRuleType eType )
930 : : {
931 : 0 : const sal_uInt16 nSrcLevels = pRule->GetLevelCount();
932 [ # # ]: 0 : SvxNumRule* pNewRule = new SvxNumRule( pRule->GetFeatureFlags(), nLevels, pRule->IsContinuousNumbering(), eType );
933 : :
934 [ # # ][ # # ]: 0 : for( sal_uInt16 nLevel = 0; (nLevel < nLevels) && (nLevel < nSrcLevels); nLevel++ )
[ # # ]
935 : 0 : pNewRule->SetLevel( nLevel, pRule->GetLevel( nLevel ) );
936 : :
937 : 0 : return pNewRule;
938 [ + - ][ + - ]: 477 : }
939 : :
940 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|