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 : : #include <hintids.hxx>
30 : :
31 : : #include <string.h>
32 : : #include <vcl/font.hxx>
33 : : #include <editeng/brshitem.hxx>
34 : : #include <editeng/lrspitem.hxx>
35 : : #include <editeng/numitem.hxx>
36 : : #include <fmtornt.hxx>
37 : : #include <doc.hxx>
38 : : #include <pam.hxx>
39 : : #include <charfmt.hxx>
40 : : #include <paratr.hxx>
41 : : #include <frmfmt.hxx>
42 : : #include <ndtxt.hxx>
43 : : #include <docary.hxx>
44 : : #include <docsh.hxx>
45 : : #include <SwStyleNameMapper.hxx>
46 : :
47 : : // Needed to load default bullet list configuration
48 : : #include <unotools/configitem.hxx>
49 : :
50 : : #include <numrule.hxx>
51 : : #include <SwNodeNum.hxx>
52 : :
53 : : #include <boost/unordered_map.hpp>
54 : :
55 : : #include <list.hxx>
56 : : #include <algorithm>
57 : :
58 : : #include <unotools/saveopt.hxx>
59 : :
60 : : #include <IDocumentListsAccess.hxx>
61 : :
62 : : using namespace ::com::sun::star;
63 : :
64 : :
65 : : sal_uInt16 SwNumRule::nRefCount = 0;
66 : : SwNumFmt* SwNumRule::aBaseFmts[ RULE_END ][ MAXLEVEL ] = {
67 : : {0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };
68 : :
69 : : SwNumFmt* SwNumRule::aLabelAlignmentBaseFmts[ RULE_END ][ MAXLEVEL ] = {
70 : : {0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };
71 : :
72 : : char sOutline[] = "Outline";
73 : : char* SwNumRule::pDefOutlineName = sOutline;
74 : :
75 : : sal_uInt16 SwNumRule::aDefNumIndents[ MAXLEVEL ] = {
76 : : //inch: 0,5 1,0 1,5 2,0 2,5 3,0 3,5 4,0 4,5 5,0
77 : : 1440/4, 1440/2, 1440*3/4, 1440, 1440*5/4, 1440*3/2, 1440*7/4, 1440*2,
78 : : 1440*9/4, 1440*5/2
79 : : };
80 : :
81 : 61923 : const SwNumFmt& SwNumRule::Get( sal_uInt16 i ) const
82 : : {
83 : : OSL_ASSERT( i < MAXLEVEL && eRuleType < RULE_END );
84 : 61923 : return aFmts[ i ]
85 : 44523 : ? *aFmts[ i ]
86 : : : ( meDefaultNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION
87 : 0 : ? *aBaseFmts[ eRuleType ][ i ]
88 [ + + ][ - + ]: 61923 : : *aLabelAlignmentBaseFmts[ eRuleType ][ i ] );
89 : : }
90 : :
91 : 39590 : const SwNumFmt* SwNumRule::GetNumFmt( sal_uInt16 i ) const
92 : : {
93 : 39590 : const SwNumFmt * pResult = NULL;
94 : :
95 : : OSL_ASSERT( i < MAXLEVEL && eRuleType < RULE_END );
96 [ + - ][ + - ]: 39590 : if ( i < MAXLEVEL && eRuleType < RULE_END)
97 : : {
98 : 39590 : pResult = aFmts[ i ];
99 : : }
100 : :
101 : 39590 : return pResult;
102 : : }
103 : :
104 : : // #i91400#
105 : 1366 : void SwNumRule::SetName( const String & rName,
106 : : IDocumentListsAccess& rDocListAccess)
107 : : {
108 [ + + ]: 1366 : if ( sName != rName )
109 : : {
110 [ + + ]: 18 : if (pNumRuleMap)
111 : : {
112 : 15 : pNumRuleMap->erase(sName);
113 : 15 : (*pNumRuleMap)[rName] = this;
114 : :
115 [ + - ]: 15 : if ( GetDefaultListId().Len() > 0 )
116 : : {
117 [ + - ][ + - ]: 15 : rDocListAccess.trackChangeOfListStyleName( sName, rName );
[ + - ]
118 : : }
119 : : }
120 : :
121 : 18 : sName = rName;
122 : : }
123 : 1366 : }
124 : :
125 : :
126 : 3808 : void SwNumRule::GetTxtNodeList( SwNumRule::tTxtNodeList& rTxtNodeList ) const
127 : : {
128 : 3808 : rTxtNodeList = maTxtNodeList;
129 : 3808 : }
130 : :
131 : :
132 : 115 : SwNumRule::tTxtNodeList::size_type SwNumRule::GetTxtNodeListSize() const
133 : : {
134 : 115 : return maTxtNodeList.size();
135 : : }
136 : :
137 : :
138 : 4143 : void SwNumRule::AddTxtNode( SwTxtNode& rTxtNode )
139 : : {
140 : : tTxtNodeList::iterator aIter =
141 [ + - ]: 4143 : std::find( maTxtNodeList.begin(), maTxtNodeList.end(), &rTxtNode );
142 : :
143 [ + - ][ + - ]: 4143 : if ( aIter == maTxtNodeList.end() )
144 : : {
145 [ + - ]: 4143 : maTxtNodeList.push_back( &rTxtNode );
146 : : }
147 : 4143 : }
148 : :
149 : :
150 : 4143 : void SwNumRule::RemoveTxtNode( SwTxtNode& rTxtNode )
151 : : {
152 : : tTxtNodeList::iterator aIter =
153 [ + - ]: 4143 : std::find( maTxtNodeList.begin(), maTxtNodeList.end(), &rTxtNode );
154 : :
155 [ + - ][ + - ]: 4143 : if ( aIter != maTxtNodeList.end() )
156 : : {
157 [ + - ]: 4143 : maTxtNodeList.erase( aIter );
158 : : }
159 : 4143 : }
160 : :
161 : :
162 : 2413 : void SwNumRule::SetNumRuleMap(boost::unordered_map<String, SwNumRule *, StringHash> *
163 : : _pNumRuleMap)
164 : : {
165 : 2413 : pNumRuleMap = _pNumRuleMap;
166 : 2413 : }
167 : :
168 : 10734 : sal_uInt16 SwNumRule::GetNumIndent( sal_uInt8 nLvl )
169 : : {
170 : : OSL_ENSURE( MAXLEVEL > nLvl, "NumLevel is out of range" );
171 : 10734 : return aDefNumIndents[ nLvl ];
172 : : }
173 : :
174 : 0 : sal_uInt16 SwNumRule::GetBullIndent( sal_uInt8 nLvl )
175 : : {
176 : : OSL_ENSURE( MAXLEVEL > nLvl, "NumLevel is out of range" );
177 : 0 : return aDefNumIndents[ nLvl ];
178 : : }
179 : :
180 : 1383 : static void lcl_SetRuleChgd( SwTxtNode& rNd, sal_uInt8 nLevel )
181 : : {
182 [ + + ]: 1383 : if( rNd.GetActualListLevel() == nLevel )
183 : 438 : rNd.NumRuleChgd();
184 : 1383 : }
185 : :
186 : 42850 : SwNumFmt::SwNumFmt() :
187 : : SvxNumberFormat(SVX_NUM_ARABIC),
188 : : SwClient( 0 ),
189 [ + - ][ + - ]: 42850 : pVertOrient(new SwFmtVertOrient( 0, text::VertOrientation::NONE))
[ + - ]
190 : : {
191 : 42850 : }
192 : :
193 : 59308 : SwNumFmt::SwNumFmt( const SwNumFmt& rFmt) :
194 : : SvxNumberFormat(rFmt),
195 : : SwClient( rFmt.GetRegisteredInNonConst() ),
196 [ + - ][ + - ]: 59308 : pVertOrient(new SwFmtVertOrient( 0, rFmt.GetVertOrient()))
[ + - ][ + - ]
197 : : {
198 [ + - ]: 59308 : sal_Int16 eMyVertOrient = rFmt.GetVertOrient();
199 : 59308 : SetGraphicBrush( rFmt.GetBrush(), &rFmt.GetGraphicSize(),
200 [ + - ]: 59308 : &eMyVertOrient);
201 : 59308 : }
202 : :
203 : 1160 : SwNumFmt::SwNumFmt(const SvxNumberFormat& rNumFmt, SwDoc* pDoc) :
204 : : SvxNumberFormat(rNumFmt),
205 [ + - ][ + - ]: 1160 : pVertOrient(new SwFmtVertOrient( 0, rNumFmt.GetVertOrient()))
[ + - ]
206 : : {
207 [ + - ]: 1160 : sal_Int16 eMyVertOrient = rNumFmt.GetVertOrient();
208 : 1160 : SetGraphicBrush( rNumFmt.GetBrush(), &rNumFmt.GetGraphicSize(),
209 [ + - ]: 1160 : &eMyVertOrient);
210 [ + - ]: 1160 : const String& rCharStyleName = rNumFmt.SvxNumberFormat::GetCharFmtName();
211 [ + + ]: 1160 : if( rCharStyleName.Len() )
212 : : {
213 [ + - ]: 191 : SwCharFmt* pCFmt = pDoc->FindCharFmtByName( rCharStyleName );
214 [ - + ]: 191 : if( !pCFmt )
215 : : {
216 : : sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCharStyleName,
217 [ # # ]: 0 : nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
218 : : pCFmt = nId != USHRT_MAX
219 : 0 : ? pDoc->GetCharFmtFromPool( nId )
220 [ # # ][ # # ]: 0 : : pDoc->MakeCharFmt( rCharStyleName, 0 );
[ # # ]
221 : : }
222 [ + - ]: 191 : pCFmt->Add( this );
223 : : }
224 [ - + ]: 969 : else if( GetRegisteredIn() )
225 [ # # ]: 0 : GetRegisteredInNonConst()->Remove( this );
226 : :
227 : 1160 : }
228 : :
229 [ + - ]: 102851 : SwNumFmt::~SwNumFmt()
230 : : {
231 [ + - ][ + - ]: 102851 : delete pVertOrient;
232 [ - + ]: 169523 : }
233 : :
234 : 0 : void SwNumFmt::NotifyGraphicArrived()
235 : : {
236 [ # # ]: 0 : if( GetCharFmt() )
237 : 0 : UpdateNumNodes( (SwDoc*)GetCharFmt()->GetDoc() );
238 : 0 : }
239 : :
240 : : // #i22362#
241 : 2396 : sal_Bool SwNumFmt::IsEnumeration() const
242 : : {
243 : : // #i30655# native numbering did not work any longer
244 : : // using this code. Therefore HBRINKM and I agreed upon defining
245 : : // IsEnumeration() as !IsItemize()
246 : 2396 : return !IsItemize();
247 : : }
248 : :
249 : :
250 : 3727 : sal_Bool SwNumFmt::IsItemize() const
251 : : {
252 : : sal_Bool bResult;
253 : :
254 [ + + ]: 3727 : switch(GetNumberingType())
255 : : {
256 : : case SVX_NUM_CHAR_SPECIAL:
257 : : case SVX_NUM_BITMAP:
258 : 130 : bResult = sal_True;
259 : :
260 : 130 : break;
261 : :
262 : : default:
263 : 3597 : bResult = sal_False;
264 : : }
265 : :
266 : 3727 : return bResult;
267 : :
268 : : }
269 : :
270 : 246 : SwNumFmt& SwNumFmt::operator=( const SwNumFmt& rNumFmt)
271 : : {
272 : 246 : SvxNumberFormat::operator=(rNumFmt);
273 [ + + ]: 246 : if( rNumFmt.GetRegisteredIn() )
274 : 244 : rNumFmt.GetRegisteredInNonConst()->Add( this );
275 [ - + ]: 2 : else if( GetRegisteredIn() )
276 : 0 : GetRegisteredInNonConst()->Remove( this );
277 : 246 : return *this;
278 : : }
279 : :
280 : 21909 : sal_Bool SwNumFmt::operator==( const SwNumFmt& rNumFmt) const
281 : : {
282 : 21909 : sal_Bool bRet = SvxNumberFormat::operator==(rNumFmt) &&
283 [ + + ][ + + ]: 21909 : GetRegisteredIn() == rNumFmt.GetRegisteredIn();
284 : 21909 : return bRet;
285 : : }
286 : :
287 : 1707 : void SwNumFmt::SetCharFmt( SwCharFmt* pChFmt)
288 : : {
289 [ + + ]: 1707 : if( pChFmt )
290 : 833 : pChFmt->Add( this );
291 [ - + ]: 874 : else if( GetRegisteredIn() )
292 : 0 : GetRegisteredInNonConst()->Remove( this );
293 : 1707 : }
294 : :
295 : 1892 : void SwNumFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
296 : : {
297 : : // Look for the NumRules object in the Doc where this NumFormat is set.
298 : : // The format does not need to exist!
299 : 1892 : const SwCharFmt* pFmt = 0;
300 [ + - ][ # # ]: 1892 : sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
301 [ + - ]: 1892 : switch( nWhich )
302 : : {
303 : : case RES_ATTRSET_CHG:
304 : : case RES_FMT_CHG:
305 : 1892 : pFmt = GetCharFmt();
306 : 1892 : break;
307 : : }
308 : :
309 [ + - ][ + + ]: 1892 : if( pFmt && !pFmt->GetDoc()->IsInDtor() )
[ + + ]
310 : 1029 : UpdateNumNodes( (SwDoc*)pFmt->GetDoc() );
311 : : else
312 : 863 : CheckRegistration( pOld, pNew );
313 : 1892 : }
314 : :
315 : 191 : void SwNumFmt::SetCharFmtName(const String& rSet)
316 : : {
317 : 191 : SvxNumberFormat::SetCharFmtName(rSet);
318 : 191 : }
319 : :
320 : 0 : const String& SwNumFmt::GetCharFmtName() const
321 : : {
322 [ # # ]: 0 : if((SwCharFmt*)GetRegisteredIn())
323 : 0 : return ((SwCharFmt*)GetRegisteredIn())->GetName();
324 : : else
325 : 0 : return aEmptyStr;
326 : : }
327 : :
328 : 0 : void SwNumFmt::ForgetCharFmt()
329 : : {
330 [ # # ]: 0 : if ( GetRegisteredIn() )
331 : 0 : GetRegisteredInNonConst()->Remove( this );
332 : 0 : }
333 : :
334 : :
335 : 60468 : void SwNumFmt::SetGraphicBrush( const SvxBrushItem* pBrushItem, const Size* pSize,
336 : : const sal_Int16* pOrient)
337 : : {
338 [ + - ]: 60468 : if(pOrient)
339 : 60468 : pVertOrient->SetVertOrient( *pOrient );
340 : 60468 : SvxNumberFormat::SetGraphicBrush( pBrushItem, pSize, pOrient);
341 : 60468 : }
342 : :
343 : 0 : void SwNumFmt::SetVertOrient(sal_Int16 eSet)
344 : : {
345 : 0 : SvxNumberFormat::SetVertOrient(eSet);
346 : 0 : }
347 : :
348 : 118616 : sal_Int16 SwNumFmt::GetVertOrient() const
349 : : {
350 : 118616 : return SvxNumberFormat::GetVertOrient();
351 : : }
352 : :
353 : 1029 : void SwNumFmt::UpdateNumNodes( SwDoc* pDoc )
354 : : {
355 : 1029 : sal_Bool bDocIsModified = pDoc->IsModified();
356 : 1029 : sal_Bool bFnd = sal_False;
357 : : const SwNumRule* pRule;
358 [ + + ][ + + ]: 5143 : for( sal_uInt16 n = pDoc->GetNumRuleTbl().size(); !bFnd && n; )
[ + + ]
359 : : {
360 : 4114 : pRule = pDoc->GetNumRuleTbl()[ --n ];
361 [ + + ]: 39225 : for( sal_uInt8 i = 0; i < MAXLEVEL; ++i )
362 [ + + ]: 36046 : if( pRule->GetNumFmt( i ) == this )
363 : : {
364 [ + - ]: 935 : SwNumRule::tTxtNodeList aTxtNodeList;
365 [ + - ]: 935 : pRule->GetTxtNodeList( aTxtNodeList );
366 [ + - + - ]: 4636 : for ( SwNumRule::tTxtNodeList::iterator aIter = aTxtNodeList.begin();
[ + + ]
367 : 2318 : aIter != aTxtNodeList.end(); ++aIter )
368 : : {
369 [ + - ][ + - ]: 1383 : lcl_SetRuleChgd( *(*aIter), i );
370 : : }
371 : 935 : bFnd = sal_True;
372 : 935 : break;
373 : : }
374 : : }
375 : :
376 [ + + ][ - + ]: 1029 : if( bFnd && !bDocIsModified )
377 : 0 : pDoc->ResetModified();
378 : 1029 : }
379 : :
380 : 0 : const SwFmtVertOrient* SwNumFmt::GetGraphicOrientation() const
381 : : {
382 : 0 : sal_Int16 eOrient = SvxNumberFormat::GetVertOrient();
383 [ # # ]: 0 : if(text::VertOrientation::NONE == eOrient)
384 : 0 : return 0;
385 : : else
386 : : {
387 : 0 : pVertOrient->SetVertOrient(eOrient);
388 : 0 : return pVertOrient;
389 : : }
390 : : }
391 : :
392 : :
393 : : // handle new parameter <eDefaultNumberFormatPositionAndSpaceMode>
394 : 2410 : SwNumRule::SwNumRule( const String& rNm,
395 : : const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode,
396 : : SwNumRuleType eType,
397 : : sal_Bool bAutoFlg )
398 : : : maTxtNodeList(),
399 : : maParagraphStyleList(),
400 : : pNumRuleMap(0),
401 : : sName( rNm ),
402 : : eRuleType( eType ),
403 : : nPoolFmtId( USHRT_MAX ),
404 : : nPoolHelpId( USHRT_MAX ),
405 : : nPoolHlpFileId( UCHAR_MAX ),
406 : : bAutoRuleFlag( bAutoFlg ),
407 : : bInvalidRuleFlag( sal_True ),
408 : : bContinusNum( sal_False ),
409 : : bAbsSpaces( sal_False ),
410 : : mbCountPhantoms( true ),
411 : : meDefaultNumberFormatPositionAndSpaceMode( eDefaultNumberFormatPositionAndSpaceMode ),
412 [ + - ][ + - ]: 2410 : msDefaultListId()
[ + - ]
413 : : {
414 [ + + ]: 2410 : if( !nRefCount++ ) // for the first time, initialize
415 : : {
416 : : SwNumFmt* pFmt;
417 : : sal_uInt8 n;
418 : :
419 : : // numbering:
420 : : // position-and-space mode LABEL_WIDTH_AND_POSITION:
421 [ + + ]: 11781 : for( n = 0; n < MAXLEVEL; ++n )
422 : : {
423 [ + - ][ + - ]: 10710 : pFmt = new SwNumFmt;
424 : 10710 : pFmt->SetIncludeUpperLevels( 1 );
425 : 10710 : pFmt->SetStart( 1 );
426 : 10710 : pFmt->SetLSpace( lNumIndent );
427 [ + - ]: 10710 : pFmt->SetAbsLSpace( lNumIndent + SwNumRule::GetNumIndent( n ) );
428 : 10710 : pFmt->SetFirstLineOffset( lNumFirstLineOffset );
429 : 10710 : pFmt->SetSuffix( aDotStr );
430 [ + - ]: 10710 : pFmt->SetBulletChar( numfunc::GetBulletChar(n));
431 : 10710 : SwNumRule::aBaseFmts[ NUM_RULE ][ n ] = pFmt;
432 : : }
433 : : // position-and-space mode LABEL_ALIGNMENT
434 : : // first line indent of general numbering in inch: -0,25 inch
435 : 1071 : const long cFirstLineIndent = -1440/4;
436 : : // indent values of general numbering in inch:
437 : : // 0,5 0,75 1,0 1,25 1,5
438 : : // 1,75 2,0 2,25 2,5 2,75
439 : : const long cIndentAt[ MAXLEVEL ] = {
440 : : 1440/2, 1440*3/4, 1440, 1440*5/4, 1440*3/2,
441 : 1071 : 1440*7/4, 1440*2, 1440*9/4, 1440*5/2, 1440*11/4 };
442 [ + + ]: 11781 : for( n = 0; n < MAXLEVEL; ++n )
443 : : {
444 [ + - ][ + - ]: 10710 : pFmt = new SwNumFmt;
445 : 10710 : pFmt->SetIncludeUpperLevels( 1 );
446 : 10710 : pFmt->SetStart( 1 );
447 [ + - ]: 10710 : pFmt->SetPositionAndSpaceMode( SvxNumberFormat::LABEL_ALIGNMENT );
448 [ + - ]: 10710 : pFmt->SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
449 [ + - ]: 10710 : pFmt->SetListtabPos( cIndentAt[ n ] );
450 [ + - ]: 10710 : pFmt->SetFirstLineIndent( cFirstLineIndent );
451 [ + - ]: 10710 : pFmt->SetIndentAt( cIndentAt[ n ] );
452 : 10710 : pFmt->SetSuffix( aDotStr );
453 [ + - ]: 10710 : pFmt->SetBulletChar( numfunc::GetBulletChar(n));
454 : 10710 : SwNumRule::aLabelAlignmentBaseFmts[ NUM_RULE ][ n ] = pFmt;
455 : : }
456 : :
457 : : // outline:
458 : : // position-and-space mode LABEL_WIDTH_AND_POSITION:
459 [ + + ]: 11781 : for( n = 0; n < MAXLEVEL; ++n )
460 : : {
461 [ + - ][ + - ]: 10710 : pFmt = new SwNumFmt;
462 : 10710 : pFmt->SetNumberingType(SVX_NUM_NUMBER_NONE);
463 : 10710 : pFmt->SetIncludeUpperLevels( MAXLEVEL );
464 : 10710 : pFmt->SetStart( 1 );
465 : 10710 : pFmt->SetCharTextDistance( lOutlineMinTextDistance );
466 [ + - ]: 10710 : pFmt->SetBulletChar( numfunc::GetBulletChar(n));
467 : 10710 : SwNumRule::aBaseFmts[ OUTLINE_RULE ][ n ] = pFmt;
468 : : }
469 : : // position-and-space mode LABEL_ALIGNMENT:
470 : : // indent values of default outline numbering in inch:
471 : : // 0,3 0,4 0,5 0,6 0,7
472 : : // 0,8 0,9 1,0 1,1 1,2
473 : : const long cOutlineIndentAt[ MAXLEVEL ] = {
474 : : 1440*3/10, 1440*2/5, 1440/2, 1440*3/5, 1440*7/10,
475 : 1071 : 1440*4/5, 1440*9/10, 1440, 1440*11/10, 1440*6/5 };
476 [ + + ]: 11781 : for( n = 0; n < MAXLEVEL; ++n )
477 : : {
478 [ + - ][ + - ]: 10710 : pFmt = new SwNumFmt;
479 : 10710 : pFmt->SetNumberingType(SVX_NUM_NUMBER_NONE);
480 : 10710 : pFmt->SetIncludeUpperLevels( MAXLEVEL );
481 : 10710 : pFmt->SetStart( 1 );
482 [ + - ]: 10710 : pFmt->SetPositionAndSpaceMode( SvxNumberFormat::LABEL_ALIGNMENT );
483 [ + - ]: 10710 : pFmt->SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
484 [ + - ]: 10710 : pFmt->SetListtabPos( cOutlineIndentAt[ n ] );
485 [ + - ]: 10710 : pFmt->SetFirstLineIndent( -cOutlineIndentAt[ n ] );
486 [ + - ]: 10710 : pFmt->SetIndentAt( cOutlineIndentAt[ n ] );
487 [ + - ]: 10710 : pFmt->SetBulletChar( numfunc::GetBulletChar(n));
488 : 10710 : SwNumRule::aLabelAlignmentBaseFmts[ OUTLINE_RULE ][ n ] = pFmt;
489 : : }
490 : : }
491 : 2410 : memset( aFmts, 0, sizeof( aFmts ));
492 : : OSL_ENSURE( sName.Len(), "NumRule without a name!" );
493 : 2410 : }
494 : :
495 : 2001 : SwNumRule::SwNumRule( const SwNumRule& rNumRule )
496 : : : maTxtNodeList(),
497 : : maParagraphStyleList(),
498 : : pNumRuleMap(0),
499 : : sName( rNumRule.sName ),
500 : : eRuleType( rNumRule.eRuleType ),
501 : 2001 : nPoolFmtId( rNumRule.GetPoolFmtId() ),
502 : 2001 : nPoolHelpId( rNumRule.GetPoolHelpId() ),
503 : 2001 : nPoolHlpFileId( rNumRule.GetPoolHlpFileId() ),
504 : : bAutoRuleFlag( rNumRule.bAutoRuleFlag ),
505 : : bInvalidRuleFlag( sal_True ),
506 : : bContinusNum( rNumRule.bContinusNum ),
507 : : bAbsSpaces( rNumRule.bAbsSpaces ),
508 : : mbCountPhantoms( true ),
509 : : meDefaultNumberFormatPositionAndSpaceMode( rNumRule.meDefaultNumberFormatPositionAndSpaceMode ),
510 [ + - ]: 4002 : msDefaultListId( rNumRule.msDefaultListId )
[ + - + - ]
511 : : {
512 : 2001 : ++nRefCount;
513 : 2001 : memset( aFmts, 0, sizeof( aFmts ));
514 [ + + ]: 22011 : for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
515 [ + + ]: 20010 : if( rNumRule.aFmts[ n ] )
516 [ + - ]: 12962 : Set( n, *rNumRule.aFmts[ n ] );
517 : 2001 : }
518 : :
519 [ + - ][ + - ]: 4314 : SwNumRule::~SwNumRule()
520 : : {
521 [ + + ]: 47454 : for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
522 [ + + ][ + - ]: 43140 : delete aFmts[ n ];
523 : :
524 [ + + ]: 4314 : if (pNumRuleMap)
525 : : {
526 [ + - ]: 2316 : pNumRuleMap->erase(GetName());
527 : : }
528 : :
529 [ + + ]: 4314 : if( !--nRefCount ) // the last one closes the door (?)
530 : : {
531 : : // Numbering:
532 : 1063 : SwNumFmt** ppFmts = (SwNumFmt**)SwNumRule::aBaseFmts;
533 : : int n;
534 : :
535 [ + + ]: 11693 : for( n = 0; n < MAXLEVEL; ++n, ++ppFmts )
536 [ + - ][ + - ]: 10630 : delete *ppFmts, *ppFmts = 0;
537 : :
538 : : // Outline:
539 [ + + ]: 11693 : for( n = 0; n < MAXLEVEL; ++n, ++ppFmts )
540 [ + - ][ + - ]: 10630 : delete *ppFmts, *ppFmts = 0;
541 : :
542 : 1063 : ppFmts = (SwNumFmt**)SwNumRule::aLabelAlignmentBaseFmts;
543 [ + + ]: 11693 : for( n = 0; n < MAXLEVEL; ++n, ++ppFmts )
544 [ + - ][ + - ]: 10630 : delete *ppFmts, *ppFmts = 0;
545 [ + + ]: 11693 : for( n = 0; n < MAXLEVEL; ++n, ++ppFmts )
546 [ + - ][ + - ]: 10630 : delete *ppFmts, *ppFmts = 0;
547 : : }
548 : :
549 : 4314 : maTxtNodeList.clear();
550 : 4314 : maParagraphStyleList.clear();
551 : 4314 : }
552 : :
553 : 1601 : void SwNumRule::CheckCharFmts( SwDoc* pDoc )
554 : : {
555 : : SwCharFmt* pFmt;
556 [ + + ]: 17611 : for( sal_uInt8 n = 0; n < MAXLEVEL; ++n )
557 [ + + ]: 16464 : if( aFmts[ n ] && 0 != ( pFmt = aFmts[ n ]->GetCharFmt() ) &&
[ + + - + ]
[ - + ]
558 : 454 : pFmt->GetDoc() != pDoc )
559 : : {
560 : : // copy
561 [ # # ]: 0 : SwNumFmt* pNew = new SwNumFmt( *aFmts[ n ] );
562 : 0 : pNew->SetCharFmt( pDoc->CopyCharFmt( *pFmt ) );
563 [ # # ]: 0 : delete aFmts[ n ];
564 : 0 : aFmts[ n ] = pNew;
565 : : }
566 : 1601 : }
567 : :
568 : 1467 : SwNumRule& SwNumRule::operator=( const SwNumRule& rNumRule )
569 : : {
570 [ + + ]: 1467 : if( this != &rNumRule )
571 : : {
572 [ + + ]: 15180 : for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
573 : 13800 : Set( n, rNumRule.aFmts[ n ] );
574 : :
575 : 1380 : eRuleType = rNumRule.eRuleType;
576 : 1380 : sName = rNumRule.sName;
577 : 1380 : bAutoRuleFlag = rNumRule.bAutoRuleFlag;
578 : 1380 : bInvalidRuleFlag = sal_True;
579 : 1380 : bContinusNum = rNumRule.bContinusNum;
580 : 1380 : bAbsSpaces = rNumRule.bAbsSpaces;
581 : 1380 : nPoolFmtId = rNumRule.GetPoolFmtId();
582 : 1380 : nPoolHelpId = rNumRule.GetPoolHelpId();
583 : 1380 : nPoolHlpFileId = rNumRule.GetPoolHlpFileId();
584 : : }
585 : 1467 : return *this;
586 : : }
587 : :
588 : 129 : sal_Bool SwNumRule::operator==( const SwNumRule& rRule ) const
589 : : {
590 : : sal_Bool bRet = eRuleType == rRule.eRuleType &&
591 : 129 : sName == rRule.sName &&
592 : : bAutoRuleFlag == rRule.bAutoRuleFlag &&
593 : : bContinusNum == rRule.bContinusNum &&
594 : : bAbsSpaces == rRule.bAbsSpaces &&
595 : 129 : nPoolFmtId == rRule.GetPoolFmtId() &&
596 : 129 : nPoolHelpId == rRule.GetPoolHelpId() &&
597 [ + - + - ]: 516 : nPoolHlpFileId == rRule.GetPoolHlpFileId();
[ + - ][ + - ]
[ + - + -
+ - ][ + - ]
598 [ + - ]: 129 : if( bRet )
599 : : {
600 [ + + ]: 1392 : for( sal_uInt8 n = 0; n < MAXLEVEL; ++n )
601 [ + + ]: 1263 : if( !( rRule.Get( n ) == Get( n ) ))
602 : : {
603 : 3 : bRet = sal_False;
604 : 3 : break;
605 : : }
606 : : }
607 : 129 : return bRet;
608 : : }
609 : :
610 : 28188 : void SwNumRule::Set( sal_uInt16 i, const SwNumFmt& rNumFmt )
611 : : {
612 : : OSL_ENSURE( i < MAXLEVEL, "Serious defect, please inform OD" );
613 [ + - ]: 28188 : if( i < MAXLEVEL )
614 : : {
615 [ + + ][ + + ]: 28188 : if( !aFmts[ i ] || !(rNumFmt == Get( i )) )
[ + + ]
616 : : {
617 [ + + ]: 21466 : delete aFmts[ i ];
618 [ + - ]: 21466 : aFmts[ i ] = new SwNumFmt( rNumFmt );
619 : 21466 : bInvalidRuleFlag = sal_True;
620 : : }
621 : : }
622 : 28188 : }
623 : :
624 : 15717 : void SwNumRule::Set( sal_uInt16 i, const SwNumFmt* pNumFmt )
625 : : {
626 : : OSL_ENSURE( i < MAXLEVEL, "Serious defect, please inform OD" );
627 [ - + ]: 15717 : if( i >= MAXLEVEL )
628 : 15717 : return;
629 : 15717 : SwNumFmt* pOld = aFmts[ i ];
630 [ + + ]: 15717 : if( !pOld )
631 : : {
632 [ + + ]: 4774 : if( pNumFmt )
633 : : {
634 [ + - ]: 1673 : aFmts[ i ] = new SwNumFmt( *pNumFmt );
635 : 1673 : bInvalidRuleFlag = sal_True;
636 : : }
637 : : }
638 [ - + ]: 10943 : else if( !pNumFmt )
639 [ # # ]: 0 : delete pOld, aFmts[ i ] = 0, bInvalidRuleFlag = sal_True;
640 [ + + ]: 10943 : else if( *pOld != *pNumFmt )
641 : 246 : *pOld = *pNumFmt, bInvalidRuleFlag = sal_True;
642 : : }
643 : :
644 : 45 : String SwNumRule::MakeNumString( const SwNodeNum& rNum, sal_Bool bInclStrings,
645 : : sal_Bool bOnlyArabic ) const
646 : : {
647 : 45 : String aStr;
648 : :
649 [ + - ][ + - ]: 45 : if (rNum.IsCounted())
650 : : aStr = MakeNumString(rNum.GetNumberVector(),
651 [ + - ][ + - ]: 45 : bInclStrings, bOnlyArabic, MAXLEVEL);
[ + - ][ + - ]
652 : :
653 : 45 : return aStr;
654 : : }
655 : :
656 : 803 : String SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & rNumVector,
657 : : const sal_Bool bInclStrings,
658 : : const sal_Bool bOnlyArabic,
659 : : const unsigned int _nRestrictToThisLevel,
660 : : SwNumRule::Extremities* pExtremities ) const
661 : : {
662 : 803 : String aStr;
663 : :
664 : 803 : unsigned int nLevel = rNumVector.size() - 1;
665 : :
666 [ + + ]: 803 : if ( pExtremities )
667 : 518 : pExtremities->nPrefixChars = pExtremities->nSuffixChars = 0;
668 : :
669 [ - + ]: 803 : if ( nLevel > _nRestrictToThisLevel )
670 : : {
671 : 0 : nLevel = _nRestrictToThisLevel;
672 : : }
673 : :
674 [ + - ]: 803 : if (nLevel < MAXLEVEL)
675 : : {
676 [ + - ]: 803 : const SwNumFmt& rMyNFmt = Get( static_cast<sal_uInt16>(nLevel) );
677 : :
678 : : {
679 : 803 : sal_uInt8 i = static_cast<sal_uInt8>(nLevel);
680 : :
681 [ + - + + : 2358 : if( !IsContinusNum() &&
+ - ][ + + ]
682 : : // - do not include upper levels, if level isn't numbered.
683 : 803 : rMyNFmt.GetNumberingType() != SVX_NUM_NUMBER_NONE &&
684 : 752 : rMyNFmt.GetIncludeUpperLevels() ) // Just the own level?
685 : : {
686 : 752 : sal_uInt8 n = rMyNFmt.GetIncludeUpperLevels();
687 [ + + ]: 752 : if( 1 < n )
688 : : {
689 [ + - ]: 84 : if( i+1 >= n )
690 : 84 : i -= n - 1;
691 : : else
692 : 0 : i = 0;
693 : : }
694 : : }
695 : :
696 [ + + ]: 1720 : for( ; i <= nLevel; ++i )
697 : : {
698 [ + - ]: 917 : const SwNumFmt& rNFmt = Get( i );
699 [ + + ]: 917 : if( SVX_NUM_NUMBER_NONE == rNFmt.GetNumberingType() )
700 : : {
701 : : // Should 1.1.1 --> 2. NoNum --> 1..1 or 1.1 ??
702 : : // if( i != rNum.nMyLevel )
703 : : // aStr += aDotStr;
704 : 51 : continue;
705 : : }
706 : :
707 [ + - ][ + - ]: 866 : if( rNumVector[ i ] )
708 : : {
709 [ - + ]: 866 : if( bOnlyArabic )
710 [ # # ][ # # ]: 0 : aStr += String::CreateFromInt32( rNumVector[ i ] );
[ # # ][ # # ]
711 : : else
712 [ + - ][ + - ]: 866 : aStr += rNFmt.GetNumStr( rNumVector[ i ] );
[ + - ][ + - ]
713 : : }
714 : : else
715 [ # # ]: 0 : aStr += '0'; // all 0 level are a 0
716 [ + + ][ + - ]: 866 : if( i != nLevel && aStr.Len() )
[ + + ]
717 [ + - ]: 114 : aStr += aDotStr;
718 : : }
719 : :
720 : : // The type doesn't have any number, so don't append
721 : : // the post-/prefix string
722 [ + - ][ + - : 2409 : if( bInclStrings && !bOnlyArabic &&
+ - + - ]
[ + - ]
723 : 803 : SVX_NUM_CHAR_SPECIAL != rMyNFmt.GetNumberingType() &&
724 : 803 : SVX_NUM_BITMAP != rMyNFmt.GetNumberingType() )
725 : : {
726 [ + - ]: 803 : String const &rPrefix = rMyNFmt.GetPrefix();
727 [ + - ]: 803 : String const &rSuffix = rMyNFmt.GetSuffix();
728 : :
729 [ + - ]: 803 : aStr.Insert( rPrefix, 0 );
730 [ + - ]: 803 : aStr += rSuffix;
731 [ + + ]: 803 : if ( pExtremities )
732 : : {
733 : 518 : pExtremities->nPrefixChars = rPrefix.Len();
734 : 518 : pExtremities->nSuffixChars = rSuffix.Len();
735 [ + - ][ + - ]: 803 : }
736 : : }
737 : : }
738 : : }
739 : :
740 : 803 : return aStr;
741 : : }
742 : :
743 : :
744 : 240 : String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
745 : : const bool bInclSuperiorNumLabels,
746 : : const sal_uInt8 nRestrictInclToThisLevel ) const
747 : : {
748 : 240 : String aRefNumStr;
749 : :
750 [ + - ][ + - ]: 240 : if ( rNodeNum.GetLevelInListTree() >= 0 )
751 : : {
752 : 240 : sal_Bool bOldHadPrefix = sal_True;
753 : 240 : bool bFirstIteration = true;
754 : 240 : ::rtl::OUString sOldPrefix;
755 : :
756 : 240 : const SwNodeNum* pWorkingNodeNum( &rNodeNum );
757 [ + - ][ + - ]: 1164 : do
[ + + ][ + + ]
758 : : {
759 : 606 : bool bMakeNumStringForPhantom( false );
760 [ + - ][ - + ]: 606 : if ( pWorkingNodeNum->IsPhantom() )
761 : : {
762 [ # # ][ # # ]: 0 : SwNumFmt aFmt( Get( static_cast<sal_uInt16>(pWorkingNodeNum->GetLevelInListTree()) ) );
[ # # ]
763 [ # # ]: 0 : bMakeNumStringForPhantom = aFmt.IsEnumeration() &&
764 [ # # ][ # # ]: 0 : SVX_NUM_NUMBER_NONE != aFmt.GetNumberingType();
[ # # ]
765 : :
766 : : }
767 [ + - ][ + - ]: 2424 : if ( bMakeNumStringForPhantom ||
[ + - ][ + + ]
[ + + ]
768 [ + - ]: 606 : ( !pWorkingNodeNum->IsPhantom() &&
769 [ + - ]: 606 : pWorkingNodeNum->GetTxtNode() &&
770 [ + - ][ + - ]: 606 : pWorkingNodeNum->GetTxtNode()->HasNumber() ) )
771 : : {
772 : : Extremities aExtremities;
773 : : String aPrevStr = MakeNumString( pWorkingNodeNum->GetNumberVector(),
774 : : sal_True, sal_False, MAXLEVEL,
775 [ + - ][ + - ]: 518 : &aExtremities);
776 : 518 : int nLen = aPrevStr.Len();
777 : 518 : int nStrip = 0;
778 : : sal_Unicode c;
779 : :
780 : :
781 [ + + ][ + - ]: 518 : while ( nStrip < aExtremities.nPrefixChars &&
[ - + ][ - + ]
782 : 330 : ( '\t' == ( c = aPrevStr.GetChar( nStrip ) ) ||
783 : : ' ' == c) )
784 : : {
785 : 0 : ++nStrip;
786 : : }
787 : :
788 [ - + ]: 518 : if (nStrip)
789 : : {
790 [ # # ]: 0 : aPrevStr.Erase( 0, nStrip );
791 : 0 : aExtremities.nPrefixChars -= nStrip;
792 : 0 : nLen -= nStrip;
793 : : }
794 : :
795 [ + + ][ + - ]: 518 : if ((bFirstIteration || bOldHadPrefix) &&
[ + - ][ + + ]
796 : : aExtremities.nSuffixChars &&
797 : 518 : !aExtremities.nPrefixChars
798 : : )
799 : : {
800 : 188 : int nStrip2 = aPrevStr.Len();
801 [ + + ]: 308 : while (aPrevStr.Len() - nStrip2 < aExtremities.nSuffixChars)
802 : : {
803 : 188 : char const cur = aPrevStr.GetChar(nStrip2);
804 [ + - ][ + - ]: 188 : if (!bFirstIteration && '\t' != cur && ' ' != cur)
[ + + ]
805 : : {
806 : 68 : break;
807 : : }
808 : 120 : --nStrip2;
809 : : }
810 [ + + ]: 188 : if (nStrip2 < aPrevStr.Len())
811 : : {
812 [ + - ]: 120 : aPrevStr.Erase(nStrip2, aPrevStr.Len() - nStrip2);
813 : 188 : }
814 : : }
815 [ - + ]: 330 : else if (sOldPrefix.getLength())
816 : : {
817 [ # # ][ # # ]: 0 : aRefNumStr.Insert(sOldPrefix, 0);
[ # # ]
818 : : }
819 : 518 : sOldPrefix = ::rtl::OUString();
820 : :
821 : 518 : bOldHadPrefix = ( aExtremities.nPrefixChars > 0);
822 : :
823 [ + - ][ + - ]: 518 : aRefNumStr.Insert( aPrevStr, 0 );
824 : : }
825 [ + - ]: 88 : else if ( aRefNumStr.Len() > 0 )
826 : : {
827 : 88 : sOldPrefix += " ";
828 : 88 : bOldHadPrefix = true;
829 : : }
830 : :
831 [ + + ][ + - ]: 606 : if ( bInclSuperiorNumLabels && pWorkingNodeNum->GetLevelInListTree() > 0 )
[ + + ][ + + ]
832 : : {
833 [ + - ][ + - ]: 388 : sal_uInt8 n = Get( static_cast<sal_uInt16>(pWorkingNodeNum->GetLevelInListTree()) ).GetIncludeUpperLevels();
834 [ + - ]: 388 : pWorkingNodeNum = dynamic_cast<SwNodeNum*>(pWorkingNodeNum->GetParent());
835 : : // skip parents, whose list label is already contained in the actual list label.
836 [ + - ][ - + ]: 388 : while ( pWorkingNodeNum && n > 1 )
[ - + ]
837 : : {
838 [ # # ]: 0 : pWorkingNodeNum = dynamic_cast<SwNodeNum*>(pWorkingNodeNum->GetParent());
839 : 0 : --n;
840 : : }
841 : : }
842 : : else
843 : : {
844 : 218 : break;
845 : : }
846 : 388 : bFirstIteration = false;
847 : : } while ( pWorkingNodeNum &&
848 [ + - ]: 388 : pWorkingNodeNum->GetLevelInListTree() >= 0 &&
849 [ + - ]: 628 : static_cast<sal_uInt8>(pWorkingNodeNum->GetLevelInListTree()) >= nRestrictInclToThisLevel );
850 : : }
851 : :
852 : 240 : return aRefNumStr;
853 : : }
854 : :
855 : : // ----- Copy method of SwNumRule ------
856 : :
857 : : // A kind of copy constructor, so that the num formats are attached
858 : : // to the right CharFormats of a Document.
859 : : // Copies the NumFormats and returns itself.
860 : 0 : SwNumRule& SwNumRule::CopyNumRule( SwDoc* pDoc, const SwNumRule& rNumRule )
861 : : {
862 [ # # ]: 0 : for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
863 : : {
864 : 0 : Set( n, rNumRule.aFmts[ n ] );
865 [ # # # # ]: 0 : if( aFmts[ n ] && aFmts[ n ]->GetCharFmt() &&
[ # # ][ # # ]
866 : 0 : !pDoc->GetCharFmts()->Contains( aFmts[n]->GetCharFmt() ))
867 : : // If we copy across different Documents, then copy the
868 : : // corresponding CharFormat into the new Document.
869 : 0 : aFmts[n]->SetCharFmt( pDoc->CopyCharFmt( *aFmts[n]->
870 : 0 : GetCharFmt() ) );
871 : : }
872 : 0 : eRuleType = rNumRule.eRuleType;
873 : 0 : sName = rNumRule.sName;
874 : 0 : bAutoRuleFlag = rNumRule.bAutoRuleFlag;
875 : 0 : nPoolFmtId = rNumRule.GetPoolFmtId();
876 : 0 : nPoolHelpId = rNumRule.GetPoolHelpId();
877 : 0 : nPoolHlpFileId = rNumRule.GetPoolHlpFileId();
878 : 0 : bInvalidRuleFlag = sal_True;
879 : 0 : return *this;
880 : : }
881 : :
882 : 116 : void SwNumRule::SetSvxRule(const SvxNumRule& rNumRule, SwDoc* pDoc)
883 : : {
884 [ + + ]: 1276 : for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
885 : : {
886 : 1160 : const SvxNumberFormat* pSvxFmt = rNumRule.Get(n);
887 [ + + ]: 1160 : delete aFmts[n];
888 [ + - ][ + - ]: 1160 : aFmts[n] = pSvxFmt ? new SwNumFmt(*pSvxFmt, pDoc) : 0;
889 : : }
890 : :
891 : 116 : bInvalidRuleFlag = sal_True;
892 : 116 : bContinusNum = rNumRule.IsContinuousNumbering();
893 : 116 : }
894 : :
895 : 116 : SvxNumRule SwNumRule::MakeSvxNumRule() const
896 : : {
897 : : SvxNumRule aRule(NUM_CONTINUOUS|NUM_CHAR_TEXT_DISTANCE|NUM_CHAR_STYLE|
898 : : NUM_ENABLE_LINKED_BMP|NUM_ENABLE_EMBEDDED_BMP,
899 : : MAXLEVEL, bContinusNum,
900 : : eRuleType ==
901 : : NUM_RULE ?
902 : : SVX_RULETYPE_NUMBERING :
903 : 116 : SVX_RULETYPE_OUTLINE_NUMBERING );
904 [ + + ]: 1276 : for( sal_uInt16 n = 0; n < MAXLEVEL; ++n )
905 : : {
906 [ + - ][ + - ]: 1160 : SwNumFmt aNumFmt = Get(n);
907 [ + + ]: 1160 : if(aNumFmt.GetCharFmt())
908 [ + - ]: 191 : aNumFmt.SetCharFmtName(aNumFmt.GetCharFmt()->GetName());
909 [ + - ]: 1160 : aRule.SetLevel(n, aNumFmt, aFmts[n] != 0);
910 [ + - ]: 1160 : }
911 : 116 : return aRule;
912 : : }
913 : :
914 : 6221 : void SwNumRule::SetInvalidRule(sal_Bool bFlag)
915 : : {
916 [ + + ]: 6221 : if (bFlag)
917 : : {
918 [ + - ]: 2457 : std::set< SwList* > aLists;
919 : 2457 : tTxtNodeList::iterator aIter;
920 [ + - ][ + - ]: 3930 : for ( aIter = maTxtNodeList.begin(); aIter != maTxtNodeList.end(); ++aIter )
[ + + ]
921 : : {
922 [ + - ]: 1473 : const SwTxtNode* pTxtNode = *aIter;
923 : : // #i111681# - applying patch from cmc
924 [ + - ][ + - ]: 1473 : SwList* pList = pTxtNode->GetDoc()->getListByName( pTxtNode->GetListId() );
[ + - ]
925 : : OSL_ENSURE( pList, "<SwNumRule::SetInvalidRule(..)> - list at which the text node is registered at does not exist. This is a serious issue --> please inform OD.");
926 [ + - ]: 1473 : if ( pList )
927 : : {
928 [ + - ]: 1473 : aLists.insert( pList );
929 : : }
930 : : }
931 : : std::for_each( aLists.begin(), aLists.end(),
932 [ + - ][ + - ]: 2457 : std::mem_fun( &SwList::InvalidateListTree ) );
933 : : }
934 : :
935 : 6221 : bInvalidRuleFlag = bFlag;
936 : 6221 : }
937 : :
938 : :
939 : : // change indent of all list levels by given difference
940 : 0 : void SwNumRule::ChangeIndent( const short nDiff )
941 : : {
942 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
943 : : {
944 [ # # ][ # # ]: 0 : SwNumFmt aTmpNumFmt( Get(i) );
945 : :
946 : : const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
947 [ # # ]: 0 : aTmpNumFmt.GetPositionAndSpaceMode() );
948 [ # # ]: 0 : if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
949 : : {
950 : : short nNewIndent = nDiff +
951 [ # # ]: 0 : aTmpNumFmt.GetAbsLSpace();
952 [ # # ]: 0 : if ( nNewIndent < 0 )
953 : : {
954 : 0 : nNewIndent = 0;
955 : : }
956 : 0 : aTmpNumFmt.SetAbsLSpace( nNewIndent );
957 : : }
958 [ # # ]: 0 : else if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
959 : : {
960 : : // adjust also the list tab position, if a list tab stop is applied
961 [ # # ][ # # ]: 0 : if ( aTmpNumFmt.GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
962 : : {
963 [ # # ]: 0 : const long nNewListTab = aTmpNumFmt.GetListtabPos() + nDiff;
964 [ # # ]: 0 : aTmpNumFmt.SetListtabPos( nNewListTab );
965 : : }
966 : :
967 : : const long nNewIndent = nDiff +
968 [ # # ]: 0 : aTmpNumFmt.GetIndentAt();
969 [ # # ]: 0 : aTmpNumFmt.SetIndentAt( nNewIndent );
970 : : }
971 : :
972 [ # # ]: 0 : Set( i, aTmpNumFmt );
973 [ # # ]: 0 : }
974 : :
975 : 0 : SetInvalidRule( sal_True );
976 : 0 : }
977 : :
978 : : // set indent of certain list level to given value
979 : 0 : void SwNumRule::SetIndent( const short nNewIndent,
980 : : const sal_uInt16 nListLevel )
981 : : {
982 [ # # ][ # # ]: 0 : SwNumFmt aTmpNumFmt( Get(nListLevel) );
983 : :
984 : : const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
985 [ # # ]: 0 : aTmpNumFmt.GetPositionAndSpaceMode() );
986 [ # # ]: 0 : if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
987 : : {
988 : 0 : aTmpNumFmt.SetAbsLSpace( nNewIndent );
989 : : }
990 [ # # ]: 0 : else if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
991 : : {
992 : : // adjust also the list tab position, if a list tab stop is applied
993 [ # # ][ # # ]: 0 : if ( aTmpNumFmt.GetLabelFollowedBy() == SvxNumberFormat::LISTTAB )
994 : : {
995 [ # # ]: 0 : const long nNewListTab = aTmpNumFmt.GetListtabPos() +
996 [ # # ]: 0 : ( nNewIndent - aTmpNumFmt.GetIndentAt() );
997 [ # # ]: 0 : aTmpNumFmt.SetListtabPos( nNewListTab );
998 : : }
999 : :
1000 [ # # ]: 0 : aTmpNumFmt.SetIndentAt( nNewIndent );
1001 : : }
1002 : :
1003 [ # # ][ # # ]: 0 : SetInvalidRule( sal_True );
1004 : 0 : }
1005 : :
1006 : : // set indent of first list level to given value and change other list level's
1007 : : // indents accordingly
1008 : 0 : void SwNumRule::SetIndentOfFirstListLevelAndChangeOthers( const short nNewIndent )
1009 : : {
1010 [ # # ][ # # ]: 0 : SwNumFmt aTmpNumFmt( Get(0) );
1011 : :
1012 : 0 : short nDiff( 0 );
1013 : : const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode(
1014 [ # # ]: 0 : aTmpNumFmt.GetPositionAndSpaceMode() );
1015 [ # # ]: 0 : if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
1016 : : {
1017 : : nDiff = nNewIndent
1018 [ # # ]: 0 : - aTmpNumFmt.GetFirstLineOffset()
1019 [ # # ]: 0 : - aTmpNumFmt.GetAbsLSpace();
1020 : : }
1021 [ # # ]: 0 : else if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT )
1022 : : {
1023 : : nDiff = static_cast<short>(nNewIndent
1024 [ # # ]: 0 : - aTmpNumFmt.GetIndentAt());
1025 : : }
1026 [ # # ]: 0 : if ( nDiff != 0 )
1027 : : {
1028 [ # # ]: 0 : ChangeIndent( nDiff );
1029 [ # # ]: 0 : }
1030 : 0 : }
1031 : :
1032 : :
1033 : 3764 : void SwNumRule::Validate()
1034 : : {
1035 [ + - ]: 3764 : std::set< SwList* > aLists;
1036 : 3764 : tTxtNodeList::iterator aIter;
1037 [ + - ][ + - ]: 5237 : for ( aIter = maTxtNodeList.begin(); aIter != maTxtNodeList.end(); ++aIter )
[ + + ]
1038 : : {
1039 [ + - ]: 1473 : const SwTxtNode* pTxtNode = *aIter;
1040 [ + - ][ + - ]: 1473 : aLists.insert( pTxtNode->GetDoc()->getListByName( pTxtNode->GetListId() ) );
[ + - ][ + - ]
1041 : : }
1042 : : std::for_each( aLists.begin(), aLists.end(),
1043 [ + - ][ + - ]: 3764 : std::mem_fun( &SwList::ValidateListTree ) );
1044 : :
1045 : :
1046 [ + - ]: 3764 : SetInvalidRule(sal_False);
1047 : 3764 : }
1048 : :
1049 : :
1050 : 903 : bool SwNumRule::IsCountPhantoms() const
1051 : : {
1052 : 903 : return mbCountPhantoms;
1053 : : }
1054 : :
1055 : :
1056 : 1597 : void SwNumRule::SetCountPhantoms(bool bCountPhantoms)
1057 : : {
1058 : 1597 : mbCountPhantoms = bCountPhantoms;
1059 : 1597 : }
1060 : :
1061 : :
1062 : 111 : SwNumRule::tParagraphStyleList::size_type SwNumRule::GetParagraphStyleListSize() const
1063 : : {
1064 : 111 : return maParagraphStyleList.size();
1065 : : }
1066 : :
1067 : :
1068 : 472 : void SwNumRule::AddParagraphStyle( SwTxtFmtColl& rTxtFmtColl )
1069 : : {
1070 : : tParagraphStyleList::iterator aIter =
1071 [ + - ]: 472 : std::find( maParagraphStyleList.begin(), maParagraphStyleList.end(), &rTxtFmtColl );
1072 : :
1073 [ + - ][ + + ]: 472 : if ( aIter == maParagraphStyleList.end() )
1074 : : {
1075 [ + - ]: 292 : maParagraphStyleList.push_back( &rTxtFmtColl );
1076 : : }
1077 : 472 : }
1078 : :
1079 : :
1080 : 0 : void SwNumRule::RemoveParagraphStyle( SwTxtFmtColl& rTxtFmtColl )
1081 : : {
1082 : : tParagraphStyleList::iterator aIter =
1083 [ # # ]: 0 : std::find( maParagraphStyleList.begin(), maParagraphStyleList.end(), &rTxtFmtColl );
1084 : :
1085 [ # # ][ # # ]: 0 : if ( aIter != maParagraphStyleList.end() )
1086 : : {
1087 [ # # ]: 0 : maParagraphStyleList.erase( aIter );
1088 : : }
1089 : 0 : }
1090 : :
1091 : :
1092 : : namespace numfunc
1093 : : {
1094 : : /** class containing default bullet list configuration data
1095 : :
1096 : : @author OD
1097 : : */
1098 : : class SwDefBulletConfig : private utl::ConfigItem
1099 : : {
1100 : : public:
1101 : : static SwDefBulletConfig& getInstance();
1102 : :
1103 : 3 : inline const String& GetFontname() const
1104 : : {
1105 : 3 : return msFontname;
1106 : : }
1107 : :
1108 : 0 : inline bool IsFontnameUserDefined() const
1109 : : {
1110 : 0 : return mbUserDefinedFontname;
1111 : : }
1112 : :
1113 : 35 : inline const Font& GetFont() const
1114 : : {
1115 : 35 : return *mpFont;
1116 : : }
1117 : :
1118 : : inline short GetFontWeight() const
1119 : : {
1120 : : return static_cast<short>(meFontWeight);
1121 : : }
1122 : :
1123 : : inline short GetFontItalic() const
1124 : : {
1125 : : return static_cast<short>(meFontItalic);
1126 : : }
1127 : 42840 : inline sal_Unicode GetChar( sal_uInt8 p_nListLevel ) const
1128 : : {
1129 [ - + ]: 42840 : if (p_nListLevel >= MAXLEVEL)
1130 : : {
1131 : 0 : p_nListLevel = MAXLEVEL - 1;
1132 : : }
1133 : :
1134 : 42840 : return mnLevelChars[p_nListLevel];
1135 : : }
1136 : :
1137 : : SwDefBulletConfig();
1138 : : ~SwDefBulletConfig();
1139 : : private:
1140 : :
1141 : : /** sets internal default bullet configuration data to default values
1142 : :
1143 : : @author OD
1144 : : */
1145 : : void SetToDefault();
1146 : :
1147 : : /** returns sequence of default bullet configuration property names
1148 : :
1149 : : @author OD
1150 : : */
1151 : : uno::Sequence<rtl::OUString> GetPropNames() const;
1152 : :
1153 : : /** loads default bullet configuration properties and applies
1154 : : values to internal data
1155 : :
1156 : : @author OD
1157 : : */
1158 : : void LoadConfig();
1159 : :
1160 : : /** initialize font instance for default bullet list
1161 : :
1162 : : @author OD
1163 : : */
1164 : : void InitFont();
1165 : :
1166 : : /** catches notification about changed default bullet configuration data
1167 : :
1168 : : @author OD
1169 : : */
1170 : : virtual void Notify( const uno::Sequence<rtl::OUString>& aPropertyNames );
1171 : : virtual void Commit();
1172 : :
1173 : : // default bullet list configuration data
1174 : : String msFontname;
1175 : : bool mbUserDefinedFontname;
1176 : : FontWeight meFontWeight;
1177 : : FontItalic meFontItalic;
1178 : : sal_Unicode mnLevelChars[MAXLEVEL];
1179 : :
1180 : : // default bullet list font instance
1181 : : Font* mpFont;
1182 : : };
1183 : :
1184 : : namespace
1185 : : {
1186 : : class theSwDefBulletConfig
1187 : : : public rtl::Static<SwDefBulletConfig, theSwDefBulletConfig>{};
1188 : : }
1189 : :
1190 : 42878 : SwDefBulletConfig& SwDefBulletConfig::getInstance()
1191 : : {
1192 : 42878 : return theSwDefBulletConfig::get();
1193 : : }
1194 : :
1195 : 73 : SwDefBulletConfig::SwDefBulletConfig()
1196 : : : ConfigItem( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Writer/Numbering/DefaultBulletList")) ),
1197 : : // default bullet font is now OpenSymbol
1198 : : msFontname( rtl::OUString("OpenSymbol") ),
1199 : : mbUserDefinedFontname( false ),
1200 : : meFontWeight( WEIGHT_DONTKNOW ),
1201 : : meFontItalic( ITALIC_NONE ),
1202 [ + - ][ + - ]: 73 : mpFont( 0 )
1203 : : {
1204 [ + - ]: 73 : SetToDefault();
1205 [ + - ]: 73 : LoadConfig();
1206 [ + - ]: 73 : InitFont();
1207 : :
1208 : : // enable notification for changes on default bullet configuration change
1209 [ + - ][ + - ]: 73 : EnableNotification( GetPropNames() );
[ + - ]
1210 : 73 : }
1211 : :
1212 [ + - ]: 73 : SwDefBulletConfig::~SwDefBulletConfig()
1213 : : {
1214 [ + - ][ + - ]: 73 : delete mpFont;
1215 [ - + ]: 73 : }
1216 : :
1217 : 73 : void SwDefBulletConfig::SetToDefault()
1218 : : {
1219 [ + - ]: 73 : msFontname = rtl::OUString("OpenSymbol");
1220 : 73 : mbUserDefinedFontname = false;
1221 : 73 : meFontWeight = WEIGHT_DONTKNOW;
1222 : 73 : meFontItalic = ITALIC_NONE;
1223 : :
1224 : 73 : mnLevelChars[0] = 0x2022;
1225 : 73 : mnLevelChars[1] = 0x25e6;
1226 : 73 : mnLevelChars[2] = 0x25aa;
1227 : 73 : mnLevelChars[3] = 0x2022;
1228 : 73 : mnLevelChars[4] = 0x25e6;
1229 : 73 : mnLevelChars[5] = 0x25aa;
1230 : 73 : mnLevelChars[6] = 0x2022;
1231 : 73 : mnLevelChars[7] = 0x25e6;
1232 : 73 : mnLevelChars[8] = 0x25aa;
1233 : 73 : mnLevelChars[9] = 0x2022;
1234 : 73 : }
1235 : :
1236 : 146 : uno::Sequence<rtl::OUString> SwDefBulletConfig::GetPropNames() const
1237 : : {
1238 : 146 : uno::Sequence<rtl::OUString> aPropNames(13);
1239 [ + - ]: 146 : rtl::OUString* pNames = aPropNames.getArray();
1240 [ + - ]: 146 : pNames[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletFont/FontFamilyname"));
1241 [ + - ]: 146 : pNames[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletFont/FontWeight"));
1242 [ + - ]: 146 : pNames[2] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletFont/FontItalic"));
1243 [ + - ]: 146 : pNames[3] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletCharLvl1"));
1244 [ + - ]: 146 : pNames[4] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletCharLvl2"));
1245 [ + - ]: 146 : pNames[5] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletCharLvl3"));
1246 [ + - ]: 146 : pNames[6] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletCharLvl4"));
1247 [ + - ]: 146 : pNames[7] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletCharLvl5"));
1248 [ + - ]: 146 : pNames[8] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletCharLvl6"));
1249 [ + - ]: 146 : pNames[9] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletCharLvl7"));
1250 [ + - ]: 146 : pNames[10] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletCharLvl8"));
1251 [ + - ]: 146 : pNames[11] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletCharLvl9"));
1252 [ + - ]: 146 : pNames[12] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BulletCharLvl10"));
1253 : :
1254 : 146 : return aPropNames;
1255 : : }
1256 : :
1257 : 73 : void SwDefBulletConfig::LoadConfig()
1258 : : {
1259 [ + - ]: 73 : uno::Sequence<rtl::OUString> aPropNames = GetPropNames();
1260 : : uno::Sequence<uno::Any> aValues =
1261 [ + - ]: 73 : GetProperties( aPropNames );
1262 : 73 : const uno::Any* pValues = aValues.getConstArray();
1263 : : OSL_ENSURE( aValues.getLength() == aPropNames.getLength(),
1264 : : "<SwDefBulletConfig::SwDefBulletConfig()> - GetProperties failed");
1265 [ + - ]: 73 : if ( aValues.getLength() == aPropNames.getLength() )
1266 : : {
1267 [ + + ]: 1022 : for ( int nProp = 0; nProp < aPropNames.getLength(); ++nProp )
1268 : : {
1269 [ - + ]: 949 : if ( pValues[nProp].hasValue() )
1270 : : {
1271 [ # # # # ]: 0 : switch ( nProp )
1272 : : {
1273 : : case 0:
1274 : : {
1275 : 0 : rtl::OUString aStr;
1276 : 0 : pValues[nProp] >>= aStr;
1277 [ # # ]: 0 : msFontname = aStr;
1278 : 0 : mbUserDefinedFontname = true;
1279 : : }
1280 : 0 : break;
1281 : : case 1:
1282 : : case 2:
1283 : : {
1284 : 0 : sal_uInt8 nTmp = 0;
1285 : 0 : pValues[nProp] >>= nTmp;
1286 [ # # ]: 0 : if ( nProp == 1 )
1287 : 0 : meFontWeight = static_cast<FontWeight>(nTmp);
1288 [ # # ]: 0 : else if ( nProp == 2 )
1289 : 0 : meFontItalic = static_cast<FontItalic>(nTmp);
1290 : : }
1291 : 0 : break;
1292 : : case 3:
1293 : : case 4:
1294 : : case 5:
1295 : : case 6:
1296 : : case 7:
1297 : : case 8:
1298 : : case 9:
1299 : : case 10:
1300 : : case 11:
1301 : : case 12:
1302 : : {
1303 : 0 : sal_Unicode cChar = sal_Unicode();
1304 : 0 : pValues[nProp] >>= cChar;
1305 : 0 : mnLevelChars[nProp-3] = cChar;
1306 : : }
1307 : 0 : break;
1308 : : }
1309 : : }
1310 : : }
1311 [ + - ][ + - ]: 73 : }
1312 : :
1313 : 73 : }
1314 : :
1315 : 73 : void SwDefBulletConfig::InitFont()
1316 : : {
1317 [ - + ]: 73 : delete mpFont;
1318 : :
1319 [ + - ][ + - ]: 73 : mpFont = new Font( msFontname, aEmptyStr, Size( 0, 14 ) );
1320 : 73 : mpFont->SetWeight( meFontWeight );
1321 : 73 : mpFont->SetItalic( meFontItalic );
1322 : 73 : }
1323 : :
1324 : 0 : void SwDefBulletConfig::Notify( const uno::Sequence<rtl::OUString>& )
1325 : : {
1326 : 0 : SetToDefault();
1327 : 0 : LoadConfig();
1328 : 0 : InitFont();
1329 : 0 : }
1330 : :
1331 : 0 : void SwDefBulletConfig::Commit()
1332 : : {
1333 : 0 : }
1334 : :
1335 : 3 : const String& GetDefBulletFontname()
1336 : : {
1337 : 3 : return SwDefBulletConfig::getInstance().GetFontname();
1338 : : }
1339 : :
1340 : 0 : bool IsDefBulletFontUserDefined()
1341 : : {
1342 : 0 : return SwDefBulletConfig::getInstance().IsFontnameUserDefined();
1343 : : }
1344 : :
1345 : 35 : const Font& GetDefBulletFont()
1346 : : {
1347 : 35 : return SwDefBulletConfig::getInstance().GetFont();
1348 : : }
1349 : :
1350 : 42840 : sal_Unicode GetBulletChar( sal_uInt8 nLevel )
1351 : : {
1352 : 42840 : return SwDefBulletConfig::getInstance().GetChar( nLevel );
1353 : : }
1354 : :
1355 : : /** class containing configuration data about user interface behavior
1356 : : regarding lists and list items.
1357 : : configuration item about behavior of <TAB>/<SHIFT-TAB>-key at first
1358 : : position of first list item
1359 : :
1360 : : @author OD
1361 : : */
1362 [ # # ]: 0 : class SwNumberingUIBehaviorConfig : private utl::ConfigItem
1363 : : {
1364 : : public:
1365 : : static SwNumberingUIBehaviorConfig& getInstance();
1366 : :
1367 : 0 : inline sal_Bool ChangeIndentOnTabAtFirstPosOfFirstListItem() const
1368 : : {
1369 : 0 : return mbChangeIndentOnTabAtFirstPosOfFirstListItem;
1370 : : }
1371 : :
1372 : : SwNumberingUIBehaviorConfig();
1373 : :
1374 : : private:
1375 : :
1376 : : /** sets internal configuration data to default values
1377 : :
1378 : : @author OD
1379 : : */
1380 : : void SetToDefault();
1381 : :
1382 : : /** returns sequence of configuration property names
1383 : :
1384 : : @author OD
1385 : : */
1386 : : com::sun::star::uno::Sequence<rtl::OUString> GetPropNames() const;
1387 : :
1388 : : /** loads configuration properties and applies values to internal data
1389 : :
1390 : : @author OD
1391 : : */
1392 : : void LoadConfig();
1393 : :
1394 : : /** catches notification about changed configuration data
1395 : :
1396 : : @author OD
1397 : : */
1398 : : virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames );
1399 : : virtual void Commit();
1400 : :
1401 : : // configuration data
1402 : : sal_Bool mbChangeIndentOnTabAtFirstPosOfFirstListItem;
1403 : : };
1404 : :
1405 : : namespace
1406 : : {
1407 : : class theSwNumberingUIBehaviorConfig : public rtl::Static<SwNumberingUIBehaviorConfig, theSwNumberingUIBehaviorConfig>{};
1408 : : }
1409 : :
1410 : 0 : SwNumberingUIBehaviorConfig& SwNumberingUIBehaviorConfig::getInstance()
1411 : : {
1412 : 0 : return theSwNumberingUIBehaviorConfig::get();
1413 : : }
1414 : :
1415 : 0 : SwNumberingUIBehaviorConfig::SwNumberingUIBehaviorConfig()
1416 : : : ConfigItem( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Writer/Numbering/UserInterfaceBehavior")) ),
1417 [ # # ]: 0 : mbChangeIndentOnTabAtFirstPosOfFirstListItem( sal_True )
1418 : : {
1419 : 0 : SetToDefault();
1420 [ # # ]: 0 : LoadConfig();
1421 : :
1422 : : // enable notification for changes on configuration change
1423 [ # # ][ # # ]: 0 : EnableNotification( GetPropNames() );
[ # # ]
1424 : 0 : }
1425 : :
1426 : 0 : void SwNumberingUIBehaviorConfig::SetToDefault()
1427 : : {
1428 : 0 : mbChangeIndentOnTabAtFirstPosOfFirstListItem = sal_True;
1429 : 0 : }
1430 : :
1431 : 0 : com::sun::star::uno::Sequence<rtl::OUString> SwNumberingUIBehaviorConfig::GetPropNames() const
1432 : : {
1433 : 0 : com::sun::star::uno::Sequence<rtl::OUString> aPropNames(1);
1434 [ # # ]: 0 : rtl::OUString* pNames = aPropNames.getArray();
1435 [ # # ]: 0 : pNames[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ChangeIndentOnTabAtFirstPosOfFirstListItem"));
1436 : :
1437 : 0 : return aPropNames;
1438 : : }
1439 : :
1440 : 0 : void SwNumberingUIBehaviorConfig::Commit() {}
1441 : :
1442 : 0 : void SwNumberingUIBehaviorConfig::LoadConfig()
1443 : : {
1444 [ # # ]: 0 : com::sun::star::uno::Sequence<rtl::OUString> aPropNames = GetPropNames();
1445 : : com::sun::star::uno::Sequence<com::sun::star::uno::Any> aValues =
1446 [ # # ]: 0 : GetProperties( aPropNames );
1447 : 0 : const com::sun::star::uno::Any* pValues = aValues.getConstArray();
1448 : : OSL_ENSURE( aValues.getLength() == aPropNames.getLength(),
1449 : : "<SwNumberingUIBehaviorConfig::LoadConfig()> - GetProperties failed");
1450 [ # # ]: 0 : if ( aValues.getLength() == aPropNames.getLength() )
1451 : : {
1452 [ # # ]: 0 : for ( int nProp = 0; nProp < aPropNames.getLength(); ++nProp )
1453 : : {
1454 [ # # ]: 0 : if ( pValues[nProp].hasValue() )
1455 : : {
1456 [ # # ]: 0 : switch ( nProp )
1457 : : {
1458 : : case 0:
1459 : : {
1460 : 0 : pValues[nProp] >>= mbChangeIndentOnTabAtFirstPosOfFirstListItem;
1461 : : }
1462 : 0 : break;
1463 : : default:
1464 : : {
1465 : : OSL_FAIL( "<SwNumberingUIBehaviorConfig::LoadConfig()> - unknown configuration property");
1466 : : }
1467 : : }
1468 : : }
1469 : : }
1470 [ # # ][ # # ]: 0 : }
1471 : 0 : }
1472 : :
1473 : 0 : void SwNumberingUIBehaviorConfig::Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames )
1474 : : {
1475 : : (void) aPropertyNames;
1476 : 0 : SetToDefault();
1477 : 0 : LoadConfig();
1478 : 0 : }
1479 : :
1480 : 0 : sal_Bool ChangeIndentOnTabAtFirstPosOfFirstListItem()
1481 : : {
1482 : 0 : return SwNumberingUIBehaviorConfig::getInstance().ChangeIndentOnTabAtFirstPosOfFirstListItem();
1483 : : }
1484 : :
1485 : 1717 : SvxNumberFormat::SvxNumPositionAndSpaceMode GetDefaultPositionAndSpaceMode()
1486 : : {
1487 : : SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode;
1488 [ + - ]: 1717 : SvtSaveOptions aSaveOptions;
1489 [ + - ][ - + ]: 1717 : switch ( aSaveOptions.GetODFDefaultVersion() )
1490 : : {
1491 : : case SvtSaveOptions::ODFVER_010:
1492 : : case SvtSaveOptions::ODFVER_011:
1493 : : {
1494 : 0 : ePosAndSpaceMode = SvxNumberFormat::LABEL_WIDTH_AND_POSITION;
1495 : : }
1496 : 0 : break;
1497 : : default: // ODFVER_UNKNOWN or ODFVER_012
1498 : : {
1499 : 1717 : ePosAndSpaceMode = SvxNumberFormat::LABEL_ALIGNMENT;
1500 : : }
1501 : : }
1502 : :
1503 [ + - ]: 1717 : return ePosAndSpaceMode;
1504 : : }
1505 : : }
1506 : :
1507 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|