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 <svl/smplhint.hxx>
31 : : #include <hintids.hxx>
32 : : #include <svl/itemiter.hxx>
33 : : #include <svl/eitem.hxx>
34 : : #include <unotools/syslocale.hxx>
35 : : #include <editeng/boxitem.hxx>
36 : : #include <editeng/numitem.hxx>
37 : : #include <editeng/lrspitem.hxx>
38 : : #include <fmtcol.hxx>
39 : : #include <uitool.hxx>
40 : : #include <swmodule.hxx>
41 : : #include <wrtsh.hxx>
42 : : #include <docsh.hxx>
43 : : #include <frmfmt.hxx>
44 : : #include <charfmt.hxx>
45 : : #include <poolfmt.hxx>
46 : : #include <pagedesc.hxx>
47 : : #include <docstyle.hxx>
48 : : #include <docary.hxx>
49 : : #include <ccoll.hxx>
50 : : #include <doc.hxx>
51 : : #include <IDocumentUndoRedo.hxx>
52 : : #include <cmdid.h>
53 : : #include <swstyle.h>
54 : : #include <app.hrc>
55 : : #include <paratr.hxx>
56 : : #include <SwStyleNameMapper.hxx>
57 : : #include <svl/cjkoptions.hxx>
58 : : #include <comphelper/processfactory.hxx>
59 : : #include <unotools/localedatawrapper.hxx>
60 : : #include <unotools/intlwrapper.hxx>
61 : : #include <numrule.hxx>
62 : : #include <fmthdft.hxx>
63 : : #include <svx/svxids.hrc>
64 : : #include <SwRewriter.hxx>
65 : :
66 : : // The Format names in the list of all names have the
67 : : // following family as their first character:
68 : :
69 : : #define cCHAR (sal_Unicode)'c'
70 : : #define cPARA (sal_Unicode)'p'
71 : : #define cFRAME (sal_Unicode)'f'
72 : : #define cPAGE (sal_Unicode)'g'
73 : : #define cNUMRULE (sal_Unicode)'n'
74 : :
75 : : // At the names' publication, this character is removed again and the
76 : : // family is newly generated.
77 : :
78 : : // In addition now there is the Bit bPhysical. In case this Bit is
79 : : // TRUE, the Pool-Formatnames are not being submitted.
80 : :
81 : : class SwImplShellAction
82 : : {
83 : : SwWrtShell* pSh;
84 : : CurrShell* pCurrSh;
85 : : public:
86 : : SwImplShellAction( SwDoc& rDoc );
87 : : ~SwImplShellAction();
88 : :
89 : : SwWrtShell* GetSh() { return pSh; }
90 : : };
91 : :
92 : 6988 : SwImplShellAction::SwImplShellAction( SwDoc& rDoc )
93 : 6988 : : pCurrSh( 0 )
94 : : {
95 [ + - ]: 6988 : if( rDoc.GetDocShell() )
96 : 6988 : pSh = rDoc.GetDocShell()->GetWrtShell();
97 : : else
98 : 0 : pSh = 0;
99 : :
100 [ + + ]: 6988 : if( pSh )
101 : : {
102 [ + - ]: 322 : pCurrSh = new CurrShell( pSh );
103 : 322 : pSh->StartAllAction();
104 : : }
105 : 6988 : }
106 : :
107 : 6988 : SwImplShellAction::~SwImplShellAction()
108 : : {
109 [ + + ]: 6988 : if( pCurrSh )
110 : : {
111 : 322 : pSh->EndAllAction();
112 [ + - ]: 322 : delete pCurrSh;
113 : : }
114 : 6988 : }
115 : :
116 : : /*--------------------------------------------------------------------
117 : : Description: find/create SwCharFormate
118 : : possibly fill Style
119 : : --------------------------------------------------------------------*/
120 : :
121 : 8397 : SwCharFmt* lcl_FindCharFmt( SwDoc& rDoc,
122 : : const String& rName,
123 : : SwDocStyleSheet* pStyle = 0,
124 : : sal_Bool bCreate = sal_True )
125 : : {
126 : 8397 : SwCharFmt* pFmt = 0;
127 [ + - ]: 8397 : if( rName.Len() )
128 : : {
129 : 8397 : pFmt = rDoc.FindCharFmtByName( rName );
130 [ + + ][ + + ]: 13289 : if( !pFmt && rName == SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
[ + + ]
131 : 4892 : RES_POOLCOLL_TEXT_BEGIN ] )
132 : : {
133 : : // Standard-Character template
134 : 120 : pFmt = (SwCharFmt*)rDoc.GetDfltCharFmt();
135 : : }
136 : :
137 [ + + ][ + + ]: 8397 : if( !pFmt && bCreate )
138 : : { // explore Pool
139 : 430 : const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
140 [ + + ]: 430 : if(nId != USHRT_MAX)
141 : 66 : pFmt = rDoc.GetCharFmtFromPool(nId);
142 : : }
143 : : }
144 [ + + ]: 8397 : if(pStyle)
145 : : {
146 [ + + ]: 7738 : if(pFmt)
147 : : {
148 : 3396 : pStyle->SetPhysical(sal_True);
149 : 3396 : SwFmt* p = pFmt->DerivedFrom();
150 [ + + ][ + + ]: 3396 : if( p && !p->IsDefault() )
[ + + ]
151 : 1605 : pStyle->PresetParent( p->GetName() );
152 : : else
153 : 1791 : pStyle->PresetParent( aEmptyStr );
154 : : }
155 : : else
156 : 4342 : pStyle->SetPhysical(sal_False);
157 : : }
158 : 8397 : return pFmt;
159 : : }
160 : :
161 : :
162 : : /*--------------------------------------------------------------------
163 : : Description: find/create ParaFormats
164 : : fill Style
165 : : --------------------------------------------------------------------*/
166 : :
167 : 49785 : SwTxtFmtColl* lcl_FindParaFmt( SwDoc& rDoc,
168 : : const String& rName,
169 : : SwDocStyleSheet* pStyle = 0,
170 : : sal_Bool bCreate = sal_True )
171 : : {
172 : 49785 : SwTxtFmtColl* pColl = 0;
173 : :
174 [ + - ]: 49785 : if( rName.Len() )
175 : : {
176 : 49785 : pColl = rDoc.FindTxtFmtCollByName( rName );
177 [ + + ][ + + ]: 49785 : if( !pColl && bCreate )
178 : : { // explore Pool
179 : 662 : const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
180 [ + + ]: 662 : if(nId != USHRT_MAX)
181 : 483 : pColl = rDoc.GetTxtCollFromPool(nId);
182 : : }
183 : : }
184 : :
185 [ + + ]: 49785 : if(pStyle)
186 : : {
187 [ + + ]: 48836 : if(pColl)
188 : : {
189 : 26521 : pStyle->SetPhysical(sal_True);
190 [ + + ][ + + ]: 26521 : if( pColl->DerivedFrom() && !pColl->DerivedFrom()->IsDefault() )
[ + - ]
191 : 13828 : pStyle->PresetParent( pColl->DerivedFrom()->GetName() );
192 : : else
193 : 12693 : pStyle->PresetParent( aEmptyStr );
194 : :
195 : 26521 : SwTxtFmtColl& rNext = pColl->GetNextTxtFmtColl();
196 : 26521 : pStyle->PresetFollow(rNext.GetName());
197 : : }
198 : : else
199 : 22315 : pStyle->SetPhysical(sal_False);
200 : : }
201 : 49785 : return pColl;
202 : : }
203 : :
204 : :
205 : : /*--------------------------------------------------------------------
206 : : Description: Border formats
207 : : --------------------------------------------------------------------*/
208 : :
209 : :
210 : 1434 : SwFrmFmt* lcl_FindFrmFmt( SwDoc& rDoc,
211 : : const String& rName,
212 : : SwDocStyleSheet* pStyle = 0,
213 : : sal_Bool bCreate = sal_True )
214 : : {
215 : 1434 : SwFrmFmt* pFmt = 0;
216 [ + - ]: 1434 : if( rName.Len() )
217 : : {
218 : 1434 : pFmt = rDoc.FindFrmFmtByName( rName );
219 [ + + ][ + + ]: 1434 : if( !pFmt && bCreate )
220 : : { // explore Pool
221 : 26 : const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT);
222 [ + - ]: 26 : if(nId != USHRT_MAX)
223 : 26 : pFmt = rDoc.GetFrmFmtFromPool(nId);
224 : : }
225 : : }
226 : :
227 [ + - ]: 1434 : if(pStyle)
228 : : {
229 [ + + ]: 1434 : if(pFmt)
230 : : {
231 : 216 : pStyle->SetPhysical(sal_True);
232 [ - + ][ - + ]: 216 : if( pFmt->DerivedFrom() && !pFmt->DerivedFrom()->IsDefault() )
[ + - ]
233 : 0 : pStyle->PresetParent( pFmt->DerivedFrom()->GetName() );
234 : : else
235 : 216 : pStyle->PresetParent( aEmptyStr );
236 : : }
237 : : else
238 : 1218 : pStyle->SetPhysical(sal_False);
239 : : }
240 : 1434 : return pFmt;
241 : : }
242 : :
243 : : /*--------------------------------------------------------------------
244 : : Description: Page descriptors
245 : : --------------------------------------------------------------------*/
246 : :
247 : :
248 : 8057 : const SwPageDesc* lcl_FindPageDesc( SwDoc& rDoc,
249 : : const String& rName,
250 : : SwDocStyleSheet* pStyle = 0,
251 : : sal_Bool bCreate = sal_True )
252 : : {
253 : 8057 : const SwPageDesc* pDesc = 0;
254 : :
255 [ + - ]: 8057 : if( rName.Len() )
256 : : {
257 : 8057 : pDesc = rDoc.FindPageDescByName( rName );
258 [ + + ][ + + ]: 8057 : if( !pDesc && bCreate )
259 : : {
260 : 116 : sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC);
261 [ + + ]: 116 : if(nId != USHRT_MAX)
262 : 58 : pDesc = rDoc.GetPageDescFromPool(nId);
263 : : }
264 : : }
265 : :
266 [ + + ]: 8057 : if(pStyle)
267 : : {
268 [ + + ]: 7985 : if(pDesc)
269 : : {
270 : 5806 : pStyle->SetPhysical(sal_True);
271 [ + - ]: 5806 : if(pDesc->GetFollow())
272 : 5806 : pStyle->PresetFollow(pDesc->GetFollow()->GetName());
273 : : else
274 : 0 : pStyle->PresetParent( aEmptyStr );
275 : : }
276 : : else
277 : 2179 : pStyle->SetPhysical(sal_False);
278 : : }
279 : 8057 : return pDesc;
280 : : }
281 : :
282 : 1420 : const SwNumRule* lcl_FindNumRule( SwDoc& rDoc,
283 : : const String& rName,
284 : : SwDocStyleSheet* pStyle = 0,
285 : : sal_Bool bCreate = sal_True )
286 : : {
287 : 1420 : const SwNumRule* pRule = 0;
288 : :
289 [ + - ]: 1420 : if( rName.Len() )
290 : : {
291 : 1420 : pRule = rDoc.FindNumRulePtr( rName );
292 [ + + ][ + + ]: 1420 : if( !pRule && bCreate )
293 : : {
294 : 118 : sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE);
295 [ + + ]: 118 : if(nId != USHRT_MAX)
296 : 10 : pRule = rDoc.GetNumRuleFromPool(nId);
297 : : }
298 : : }
299 : :
300 [ + + ]: 1420 : if(pStyle)
301 : : {
302 [ + + ]: 1312 : if(pRule)
303 : : {
304 : 398 : pStyle->SetPhysical(sal_True);
305 : 398 : pStyle->PresetParent( aEmptyStr );
306 : : }
307 : : else
308 : 914 : pStyle->SetPhysical(sal_False);
309 : : }
310 : 1420 : return pRule;
311 : : }
312 : :
313 : :
314 : 2 : sal_uInt16 lcl_FindName(const SwPoolFmtList& rLst, SfxStyleFamily eFam,
315 : : const rtl::OUString& rName)
316 : : {
317 [ + - ]: 2 : if(!rLst.empty())
318 : : {
319 [ + - ]: 2 : String sSrch = rtl::OUString(' ');
320 [ + - - - : 2 : switch( eFam )
- - ]
321 : : {
322 [ + - ]: 2 : case SFX_STYLE_FAMILY_CHAR: sSrch = cCHAR; break;
323 [ # # ]: 0 : case SFX_STYLE_FAMILY_PARA: sSrch = cPARA; break;
324 [ # # ]: 0 : case SFX_STYLE_FAMILY_FRAME: sSrch = cFRAME; break;
325 [ # # ]: 0 : case SFX_STYLE_FAMILY_PAGE: sSrch = cPAGE; break;
326 [ # # ]: 0 : case SFX_STYLE_FAMILY_PSEUDO: sSrch = cNUMRULE; break;
327 : : default:; //prevent warning
328 : : }
329 [ + - ]: 2 : sSrch += rName;
330 [ + + ]: 4 : for(size_t i = 0; i < rLst.size(); ++i)
331 [ + - ][ + - ]: 2 : if(rLst[i] == sSrch)
[ - + ]
332 [ + - ][ + - ]: 2 : return i;
333 : : }
334 : 2 : return USHRT_MAX;
335 : : }
336 : :
337 : 0 : sal_Bool FindPhyStyle( SwDoc& rDoc, const String& rName, SfxStyleFamily eFam )
338 : : {
339 [ # # # # : 0 : switch( eFam )
# # ]
340 : : {
341 : : case SFX_STYLE_FAMILY_CHAR :
342 : 0 : return 0 != lcl_FindCharFmt( rDoc, rName, 0, sal_False );
343 : : case SFX_STYLE_FAMILY_PARA :
344 : 0 : return 0 != lcl_FindParaFmt( rDoc, rName, 0, sal_False );
345 : : case SFX_STYLE_FAMILY_FRAME:
346 : 0 : return 0 != lcl_FindFrmFmt( rDoc, rName, 0, sal_False );
347 : : case SFX_STYLE_FAMILY_PAGE :
348 : 0 : return 0 != lcl_FindPageDesc( rDoc, rName, 0, sal_False );
349 : : case SFX_STYLE_FAMILY_PSEUDO:
350 : 0 : return 0 != lcl_FindNumRule( rDoc, rName, 0, sal_False );
351 : : default:; //prevent warning
352 : : }
353 : 0 : return sal_False;
354 : : }
355 : :
356 : :
357 : : /*--------------------------------------------------------------------
358 : : Description: Add Strings to the list of templates
359 : : --------------------------------------------------------------------*/
360 : :
361 : :
362 : 140848 : void SwPoolFmtList::Append( char cChar, const String& rStr )
363 : : {
364 [ + - ]: 140848 : String aStr = rtl::OUString(cChar);
365 [ + - ]: 140848 : aStr += rStr;
366 [ + - ][ + - ]: 6231814 : for(std::vector<String>::const_iterator i = begin(); i != end(); ++i)
[ + - ][ + + ]
367 [ + - ][ + - ]: 6098722 : if(*i == aStr)
[ + + ]
368 : 140848 : return;
369 [ + - ][ + - ]: 140848 : push_back(aStr);
[ + + ]
370 : : }
371 : :
372 : : /*--------------------------------------------------------------------
373 : : Description: Erase the list completely
374 : : --------------------------------------------------------------------*/
375 : :
376 : :
377 : 21526 : void SwPoolFmtList::Erase()
378 : : {
379 : 21526 : clear();
380 : 21526 : }
381 : :
382 : : /*--------------------------------------------------------------------
383 : : Description: UI-sided implementation of StyleSheets
384 : : uses the Core-Engine
385 : : --------------------------------------------------------------------*/
386 : :
387 : 6919 : SwDocStyleSheet::SwDocStyleSheet( SwDoc& rDocument,
388 : : const String& rName,
389 : : SwDocStyleSheetPool* _rPool,
390 : : SfxStyleFamily eFam,
391 : : sal_uInt16 _nMask) :
392 : :
393 : : SfxStyleSheetBase( rName, _rPool, eFam, _nMask ),
394 : : pCharFmt(0),
395 : : pColl(0),
396 : : pFrmFmt(0),
397 : : pDesc(0),
398 : : pNumRule(0),
399 : :
400 : : rDoc(rDocument),
401 [ + - ]: 6919 : aCoreSet(GetPool().GetPool(),
402 : : RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
403 : : RES_PARATR_BEGIN, RES_PARATR_END - 1,
404 : : RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1,
405 : : RES_FRMATR_BEGIN, RES_FRMATR_END - 1,
406 : : RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
407 : : SID_ATTR_PAGE, SID_ATTR_PAGE_EXT1,
408 : : SID_ATTR_PAGE_HEADERSET,SID_ATTR_PAGE_FOOTERSET,
409 : : SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
410 : : FN_PARAM_FTN_INFO, FN_PARAM_FTN_INFO,
411 : : SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL,
412 : : SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM,
413 : : SID_SWREGISTER_MODE, SID_SWREGISTER_MODE,
414 : : SID_SWREGISTER_COLLECTION, SID_SWREGISTER_COLLECTION,
415 : : FN_COND_COLL, FN_COND_COLL,
416 : : SID_ATTR_AUTO_STYLE_UPDATE, SID_ATTR_AUTO_STYLE_UPDATE,
417 : : SID_ATTR_NUMBERING_RULE, SID_ATTR_NUMBERING_RULE,
418 : : SID_PARA_BACKGRND_DESTINATION, SID_ATTR_BRUSH_CHAR,
419 : : SID_ATTR_NUMBERING_RULE, SID_ATTR_NUMBERING_RULE,
420 : : 0),
421 [ + - ]: 13838 : bPhysical(sal_False)
422 : : {
423 : 6919 : nHelpId = UCHAR_MAX;
424 : 6919 : }
425 : :
426 : :
427 : 18501 : SwDocStyleSheet::SwDocStyleSheet( const SwDocStyleSheet& rOrg) :
428 : : SfxStyleSheetBase(rOrg),
429 : : pCharFmt(rOrg.pCharFmt),
430 : : pColl(rOrg.pColl),
431 : : pFrmFmt(rOrg.pFrmFmt),
432 : : pDesc(rOrg.pDesc),
433 : : pNumRule(rOrg.pNumRule),
434 : : rDoc(rOrg.rDoc),
435 : : aCoreSet(rOrg.aCoreSet),
436 [ + - ]: 18501 : bPhysical(rOrg.bPhysical)
437 : : {
438 : 18501 : }
439 : :
440 : :
441 [ + - ]: 25305 : SwDocStyleSheet::~SwDocStyleSheet()
442 : : {
443 [ - + ]: 50610 : }
444 : :
445 : : /*--------------------------------------------------------------------
446 : : Description: Reset
447 : : --------------------------------------------------------------------*/
448 : :
449 : :
450 : 21526 : void SwDocStyleSheet::Reset()
451 : : {
452 : 21526 : aName.Erase();
453 : 21526 : aFollow.Erase();
454 : 21526 : aParent.Erase();
455 : 21526 : SetPhysical(sal_False);
456 : 21526 : }
457 : :
458 : : /*--------------------------------------------------------------------
459 : : Description: virtual methods
460 : : --------------------------------------------------------------------*/
461 : :
462 : :
463 : 4581 : const String& SwDocStyleSheet::GetParent() const
464 : : {
465 [ + + ]: 4581 : if( !bPhysical )
466 : : {
467 : : // check if it's already in document
468 : 1140 : SwFmt* pFmt = 0;
469 : : SwGetPoolIdFromName eGetType;
470 [ + + - + ]: 1140 : switch(nFamily)
471 : : {
472 : : case SFX_STYLE_FAMILY_CHAR:
473 [ + - ]: 112 : pFmt = rDoc.FindCharFmtByName( aName );
474 : 112 : eGetType = nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
475 : 112 : break;
476 : :
477 : : case SFX_STYLE_FAMILY_PARA:
478 [ + - ]: 984 : pFmt = rDoc.FindTxtFmtCollByName( aName );
479 : 984 : eGetType = nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL;
480 : 984 : break;
481 : :
482 : : case SFX_STYLE_FAMILY_FRAME:
483 [ # # ]: 0 : pFmt = rDoc.FindFrmFmtByName( aName );
484 : 0 : eGetType = nsSwGetPoolIdFromName::GET_POOLID_FRMFMT;
485 : 0 : break;
486 : :
487 : : case SFX_STYLE_FAMILY_PAGE:
488 : : case SFX_STYLE_FAMILY_PSEUDO:
489 : : default:
490 : 44 : return aEmptyStr; // there's no parent
491 : : }
492 : :
493 [ + - ]: 1096 : String sTmp;
494 [ + + ]: 1096 : if( !pFmt ) // not yet there, so default Parent
495 : : {
496 [ + - ]: 1024 : sal_uInt16 i = SwStyleNameMapper::GetPoolIdFromUIName( aName, eGetType );
497 [ + - ]: 1024 : i = ::GetPoolParent( i );
498 [ + + ][ + + ]: 1024 : if( i && USHRT_MAX != i )
499 [ + - ]: 920 : SwStyleNameMapper::FillUIName( i, sTmp );
500 : : }
501 : : else
502 : : {
503 : 72 : SwFmt* p = pFmt->DerivedFrom();
504 [ + + ][ + + ]: 72 : if( p && !p->IsDefault() )
[ + - ]
505 [ + - ]: 60 : sTmp = p->GetName();
506 : : }
507 : 1096 : SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
508 [ + - ][ + - ]: 1096 : pThis->aParent = sTmp;
509 : : }
510 : 4581 : return aParent;
511 : : }
512 : :
513 : : /*--------------------------------------------------------------------
514 : : Description: Follower
515 : : --------------------------------------------------------------------*/
516 : :
517 : :
518 : 913 : const String& SwDocStyleSheet::GetFollow() const
519 : : {
520 [ - + ]: 913 : if( !bPhysical )
521 : : {
522 : 0 : SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
523 : 0 : pThis->FillStyleSheet( FillAllInfo );
524 : : }
525 : 913 : return aFollow;
526 : : }
527 : :
528 : : /*--------------------------------------------------------------------
529 : : Description: What Linkage is possible
530 : : --------------------------------------------------------------------*/
531 : :
532 : :
533 : 0 : sal_Bool SwDocStyleSheet::HasFollowSupport() const
534 : : {
535 [ # # # ]: 0 : switch(nFamily)
536 : : {
537 : : case SFX_STYLE_FAMILY_PARA :
538 : 0 : case SFX_STYLE_FAMILY_PAGE : return sal_True;
539 : : case SFX_STYLE_FAMILY_FRAME:
540 : : case SFX_STYLE_FAMILY_CHAR :
541 : 0 : case SFX_STYLE_FAMILY_PSEUDO: return sal_False;
542 : : default:
543 : : OSL_ENSURE(!this, "unknown style family");
544 : : }
545 : 0 : return sal_False;
546 : : }
547 : :
548 : : /*--------------------------------------------------------------------
549 : : Description: Parent ?
550 : : --------------------------------------------------------------------*/
551 : :
552 : :
553 : 0 : sal_Bool SwDocStyleSheet::HasParentSupport() const
554 : : {
555 : 0 : sal_Bool bRet = sal_False;
556 [ # # ]: 0 : switch(nFamily)
557 : : {
558 : : case SFX_STYLE_FAMILY_CHAR :
559 : : case SFX_STYLE_FAMILY_PARA :
560 : 0 : case SFX_STYLE_FAMILY_FRAME: bRet = sal_True;
561 : : default:; //prevent warning
562 : : }
563 : 0 : return bRet;
564 : : }
565 : :
566 : :
567 : 0 : sal_Bool SwDocStyleSheet::HasClearParentSupport() const
568 : : {
569 : 0 : sal_Bool bRet = sal_False;
570 [ # # ]: 0 : switch(nFamily)
571 : : {
572 : : case SFX_STYLE_FAMILY_PARA :
573 : : case SFX_STYLE_FAMILY_CHAR :
574 : 0 : case SFX_STYLE_FAMILY_FRAME: bRet = sal_True;
575 : : default:; //prevent warning
576 : : }
577 : 0 : return bRet;
578 : : }
579 : :
580 : : /*--------------------------------------------------------------------
581 : : Description: determine textual description
582 : : --------------------------------------------------------------------*/
583 : 0 : String SwDocStyleSheet::GetDescription(SfxMapUnit eUnit)
584 : : {
585 : : IntlWrapper aIntlWrapper(
586 : : ::comphelper::getProcessServiceFactory(),
587 [ # # ][ # # ]: 0 : SvtSysLocale().GetLocaleData().getLocale());
[ # # ][ # # ]
[ # # ][ # # ]
588 : :
589 : 0 : rtl::OUString sPlus(" + ");
590 [ # # ]: 0 : if ( SFX_STYLE_FAMILY_PAGE == nFamily )
591 : : {
592 [ # # ]: 0 : if( !pSet )
593 [ # # ]: 0 : GetItemSet();
594 : :
595 [ # # ]: 0 : SfxItemIter aIter( *pSet );
596 [ # # ]: 0 : String aDesc;
597 : 0 : const SfxPoolItem* pItem = aIter.FirstItem();
598 : :
599 [ # # ]: 0 : while ( pItem )
600 : : {
601 [ # # ]: 0 : if(!IsInvalidItem(pItem))
602 [ # # ]: 0 : switch ( pItem->Which() )
603 : : {
604 : : case RES_LR_SPACE:
605 : : case SID_ATTR_PAGE_SIZE:
606 : : case SID_ATTR_PAGE_MAXSIZE:
607 : : case SID_ATTR_PAGE_PAPERBIN:
608 : : case SID_ATTR_PAGE_APP:
609 : : case SID_ATTR_BORDER_INNER:
610 : 0 : break;
611 : : default:
612 : : {
613 [ # # ]: 0 : String aItemPresentation;
614 [ # # ][ # # ]: 0 : if ( !IsInvalidItem( pItem ) &&
[ # # ]
615 [ # # ]: 0 : pPool->GetPool().GetPresentation(
616 : : *pItem, SFX_ITEM_PRESENTATION_COMPLETE,
617 [ # # ]: 0 : eUnit, aItemPresentation, &aIntlWrapper ) )
618 : : {
619 [ # # ][ # # ]: 0 : if ( aDesc.Len() && aItemPresentation.Len() )
[ # # ]
620 [ # # ]: 0 : aDesc += sPlus;
621 [ # # ]: 0 : aDesc += aItemPresentation;
622 [ # # ]: 0 : }
623 : : }
624 : : }
625 [ # # ]: 0 : pItem = aIter.NextItem();
626 : : }
627 [ # # ][ # # ]: 0 : return aDesc;
[ # # ]
628 : : }
629 [ # # ][ # # ]: 0 : else if ( SFX_STYLE_FAMILY_FRAME == nFamily ||
630 : : SFX_STYLE_FAMILY_PARA == nFamily)
631 : : {
632 [ # # ]: 0 : if( !pSet )
633 [ # # ]: 0 : GetItemSet();
634 : :
635 [ # # ]: 0 : SfxItemIter aIter( *pSet );
636 [ # # ]: 0 : String aDesc;
637 : 0 : const SfxPoolItem* pItem = aIter.FirstItem();
638 : :
639 : 0 : rtl::OUString sPageNum;
640 [ # # ][ # # ]: 0 : String sModel, sBreak;
641 : 0 : sal_Bool bHasWesternFontPrefix = sal_False;
642 : 0 : sal_Bool bHasCJKFontPrefix = sal_False;
643 [ # # ]: 0 : SvtCJKOptions aCJKOptions;
644 : :
645 [ # # ]: 0 : while ( pItem )
646 : : {
647 [ # # ]: 0 : if(!IsInvalidItem(pItem))
648 [ # # ]: 0 : switch ( pItem->Which() )
649 : : {
650 : : case SID_ATTR_AUTO_STYLE_UPDATE:
651 : : case SID_PARA_BACKGRND_DESTINATION:
652 : : case RES_PAGEDESC:
653 : : //CTL not yet supported
654 : : case RES_CHRATR_CTL_FONT:
655 : : case RES_CHRATR_CTL_FONTSIZE:
656 : : case RES_CHRATR_CTL_LANGUAGE:
657 : : case RES_CHRATR_CTL_POSTURE:
658 : : case RES_CHRATR_CTL_WEIGHT:
659 : 0 : break;
660 : : default:
661 : : {
662 [ # # ]: 0 : String aItemPresentation;
663 [ # # ][ # # ]: 0 : if ( !IsInvalidItem( pItem ) &&
[ # # ]
664 [ # # ]: 0 : pPool->GetPool().GetPresentation(
665 : : *pItem, SFX_ITEM_PRESENTATION_COMPLETE,
666 [ # # ]: 0 : eUnit, aItemPresentation, &aIntlWrapper ) )
667 : : {
668 : 0 : sal_Bool bIsDefault = sal_False;
669 [ # # # # : 0 : switch ( pItem->Which() )
# # ]
670 : : {
671 : : case SID_ATTR_PARA_PAGENUM:
672 [ # # ]: 0 : sPageNum = aItemPresentation;
673 : 0 : break;
674 : : case SID_ATTR_PARA_MODEL:
675 [ # # ]: 0 : sModel = aItemPresentation;
676 : 0 : break;
677 : : case RES_BREAK:
678 [ # # ]: 0 : sBreak = aItemPresentation;
679 : 0 : break;
680 : : case RES_CHRATR_CJK_FONT:
681 : : case RES_CHRATR_CJK_FONTSIZE:
682 : : case RES_CHRATR_CJK_LANGUAGE:
683 : : case RES_CHRATR_CJK_POSTURE:
684 : : case RES_CHRATR_CJK_WEIGHT:
685 [ # # ][ # # ]: 0 : if(aCJKOptions.IsCJKFontEnabled())
686 : 0 : bIsDefault = sal_True;
687 [ # # ]: 0 : if(!bHasCJKFontPrefix)
688 : : {
689 [ # # ][ # # ]: 0 : aItemPresentation.Insert(SW_RESSTR(STR_CJK_FONT), 0);
[ # # ][ # # ]
690 : 0 : bHasCJKFontPrefix = sal_True;
691 : : }
692 : 0 : break;
693 : : case RES_CHRATR_FONT:
694 : : case RES_CHRATR_FONTSIZE:
695 : : case RES_CHRATR_LANGUAGE:
696 : : case RES_CHRATR_POSTURE:
697 : : case RES_CHRATR_WEIGHT:
698 [ # # ]: 0 : if(!bHasWesternFontPrefix)
699 : : {
700 [ # # ][ # # ]: 0 : aItemPresentation.Insert(SW_RESSTR(STR_WESTERN_FONT), 0);
[ # # ][ # # ]
701 : 0 : bHasWesternFontPrefix = sal_True;
702 : 0 : bIsDefault = sal_True;
703 : : }
704 : : // no break;
705 : : default:
706 : 0 : bIsDefault = sal_True;
707 : : }
708 [ # # ]: 0 : if(bIsDefault)
709 : : {
710 [ # # ][ # # ]: 0 : if ( aDesc.Len() && aItemPresentation.Len() )
[ # # ]
711 [ # # ]: 0 : aDesc += sPlus;
712 [ # # ]: 0 : aDesc += aItemPresentation;
713 : : }
714 [ # # ]: 0 : }
715 : : }
716 : : }
717 [ # # ]: 0 : pItem = aIter.NextItem();
718 : : }
719 : : // Special treatment for Break, Page template and Site offset
720 [ # # ][ # # ]: 0 : if(sBreak.Len() && !sModel.Len()) // when Model, break is invalid
[ # # ]
721 : : {
722 [ # # ]: 0 : if(aDesc.Len())
723 [ # # ]: 0 : aDesc += sPlus;
724 [ # # ]: 0 : aDesc += sBreak;
725 : : }
726 [ # # ]: 0 : if(sModel.Len())
727 : : {
728 [ # # ]: 0 : if(aDesc.Len())
729 [ # # ]: 0 : aDesc += sPlus;
730 [ # # ][ # # ]: 0 : aDesc += SW_RESSTR(STR_PAGEBREAK);
731 [ # # ]: 0 : aDesc += sPlus;
732 [ # # ]: 0 : aDesc += sModel;
733 [ # # ]: 0 : if (sPageNum != "0")
734 : : {
735 [ # # ]: 0 : aDesc += sPlus;
736 [ # # ][ # # ]: 0 : aDesc += SW_RESSTR(STR_PAGEOFFSET);
737 [ # # ]: 0 : aDesc += sPageNum;
738 : : }
739 : : }
740 [ # # ][ # # ]: 0 : return aDesc;
[ # # ][ # # ]
[ # # ][ # # ]
741 : : }
742 [ # # ]: 0 : else if( SFX_STYLE_FAMILY_PSEUDO == nFamily )
743 : : {
744 [ # # ]: 0 : return aEmptyStr;
745 : : }
746 : :
747 [ # # ][ # # ]: 0 : return SfxStyleSheetBase::GetDescription(eUnit);
748 : : }
749 : :
750 : :
751 : 0 : String SwDocStyleSheet::GetDescription()
752 : : {
753 : 0 : return GetDescription(SFX_MAPUNIT_CM);
754 : : }
755 : :
756 : : /*--------------------------------------------------------------------
757 : : Description: Set names
758 : : --------------------------------------------------------------------*/
759 : :
760 : :
761 : 16 : sal_Bool SwDocStyleSheet::SetName( const String& rStr)
762 : : {
763 [ - + ]: 16 : if( !rStr.Len() )
764 : 0 : return sal_False;
765 : :
766 [ + - ]: 16 : if( aName != rStr )
767 : : {
768 [ - + ]: 16 : if( !SfxStyleSheetBase::SetName( rStr ))
769 : 0 : return sal_False;
770 : : }
771 [ # # ]: 0 : else if(!bPhysical)
772 : 0 : FillStyleSheet( FillPhysical );
773 : :
774 : 16 : int bChg = sal_False;
775 [ + + - + : 16 : switch(nFamily)
- - ]
776 : : {
777 : : case SFX_STYLE_FAMILY_CHAR :
778 : : {
779 : : OSL_ENSURE(pCharFmt, "SwCharFormat missing!");
780 [ + - ][ + - ]: 4 : if( pCharFmt && pCharFmt->GetName() != rStr )
[ + - ]
781 : : {
782 : 4 : pCharFmt->SetName( rStr );
783 : 4 : bChg = sal_True;
784 : : }
785 : 4 : break;
786 : : }
787 : : case SFX_STYLE_FAMILY_PARA :
788 : : {
789 : : OSL_ENSURE(pColl, "Collection missing!");
790 [ + - ][ + - ]: 8 : if( pColl && pColl->GetName() != rStr )
[ + - ]
791 : : {
792 [ + - ]: 8 : if (pColl->GetName().Len() > 0)
793 : 8 : rDoc.RenameFmt(*pColl, rStr);
794 : : else
795 : 0 : pColl->SetName(rStr);
796 : :
797 : 8 : bChg = sal_True;
798 : : }
799 : 8 : break;
800 : : }
801 : : case SFX_STYLE_FAMILY_FRAME:
802 : : {
803 : : OSL_ENSURE(pFrmFmt, "FrmFmt missing!");
804 [ # # ][ # # ]: 0 : if( pFrmFmt && pFrmFmt->GetName() != rStr )
[ # # ]
805 : : {
806 [ # # ]: 0 : if (pFrmFmt->GetName().Len() > 0)
807 : 0 : rDoc.RenameFmt(*pFrmFmt, rStr);
808 : : else
809 : 0 : pFrmFmt->SetName( rStr );
810 : :
811 : 0 : bChg = sal_True;
812 : : }
813 : 0 : break;
814 : : }
815 : : case SFX_STYLE_FAMILY_PAGE :
816 : : OSL_ENSURE(pDesc, "PageDesc missing!");
817 [ + - ][ + - ]: 4 : if( pDesc && pDesc->GetName() != rStr )
[ + - ]
818 : : {
819 : : // Set PageDesc - copy with earlier one - probably not
820 : : // necessary for setting the name. So here we allow a
821 : : // cast.
822 [ + - ]: 4 : SwPageDesc aPageDesc(*((SwPageDesc*)pDesc));
823 [ + - ]: 4 : String aOldName(aPageDesc.GetName());
824 : :
825 [ + - ]: 4 : aPageDesc.SetName( rStr );
826 [ + - ][ + - ]: 4 : bool const bDoesUndo = rDoc.GetIDocumentUndoRedo().DoesUndo();
827 : :
828 [ + - ][ + - ]: 4 : rDoc.GetIDocumentUndoRedo().DoUndo(aOldName.Len() > 0);
829 [ + - ]: 4 : rDoc.ChgPageDesc(aOldName, aPageDesc);
830 [ + - ][ + - ]: 4 : rDoc.GetIDocumentUndoRedo().DoUndo(bDoesUndo);
831 : :
832 [ + - ]: 4 : rDoc.SetModified();
833 [ + - ][ + - ]: 4 : bChg = sal_True;
834 : : }
835 : 4 : break;
836 : : case SFX_STYLE_FAMILY_PSEUDO:
837 : : OSL_ENSURE(pNumRule, "NumRule missing!");
838 : :
839 [ # # ]: 0 : if (pNumRule)
840 : : {
841 [ # # ]: 0 : String aOldName = pNumRule->GetName();
842 : :
843 [ # # ]: 0 : if (aOldName.Len() > 0)
844 : : {
845 [ # # ][ # # ]: 0 : if ( aOldName != rStr &&
[ # # ][ # # ]
846 [ # # ]: 0 : rDoc.RenameNumRule(aOldName, rStr))
847 : : {
848 [ # # ]: 0 : pNumRule = rDoc.FindNumRulePtr(rStr);
849 [ # # ]: 0 : rDoc.SetModified();
850 : :
851 : 0 : bChg = sal_True;
852 : : }
853 : : }
854 : : else
855 : : {
856 : : // #i91400#
857 [ # # ]: 0 : ((SwNumRule*)pNumRule)->SetName( rStr, rDoc );
858 [ # # ]: 0 : rDoc.SetModified();
859 : :
860 : 0 : bChg = sal_True;
861 [ # # ]: 0 : }
862 : : }
863 : :
864 : 0 : break;
865 : :
866 : : default:
867 : : OSL_ENSURE(!this, "unknown style family");
868 : : }
869 : :
870 [ + - ]: 16 : if( bChg )
871 : : {
872 : 16 : pPool->First(); // internal list has to be updated
873 [ + - ]: 16 : pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) );
874 : 16 : SwEditShell* pSh = rDoc.GetEditShell();
875 [ + - ]: 16 : if( pSh )
876 : 16 : pSh->CallChgLnk();
877 : : }
878 : 16 : return sal_True;
879 : : }
880 : :
881 : : /*--------------------------------------------------------------------
882 : : Description: hierarchy of deduction
883 : : --------------------------------------------------------------------*/
884 : :
885 : :
886 : 1125 : sal_Bool SwDocStyleSheet::SetParent( const String& rStr)
887 : : {
888 : 1125 : SwFmt* pFmt = 0, *pParent = 0;
889 [ + + - - : 1125 : switch(nFamily)
- ]
890 : : {
891 : : case SFX_STYLE_FAMILY_CHAR :
892 : : OSL_ENSURE( pCharFmt, "SwCharFormat missing!" );
893 [ + - ][ + - ]: 59 : if( 0 != ( pFmt = pCharFmt ) && rStr.Len() )
[ + - ]
894 : 59 : pParent = lcl_FindCharFmt(rDoc, rStr);
895 : 59 : break;
896 : :
897 : : case SFX_STYLE_FAMILY_PARA :
898 : : OSL_ENSURE( pColl, "Collektion missing!");
899 [ + - ][ + + ]: 1066 : if( 0 != ( pFmt = pColl ) && rStr.Len() )
[ + + ]
900 : 610 : pParent = lcl_FindParaFmt( rDoc, rStr );
901 : 1066 : break;
902 : :
903 : : case SFX_STYLE_FAMILY_FRAME:
904 : : OSL_ENSURE(pFrmFmt, "FrameFormat missing!");
905 [ # # ][ # # ]: 0 : if( 0 != ( pFmt = pFrmFmt ) && rStr.Len() )
[ # # ]
906 : 0 : pParent = lcl_FindFrmFmt( rDoc, rStr );
907 : 0 : break;
908 : :
909 : : case SFX_STYLE_FAMILY_PAGE:
910 : : case SFX_STYLE_FAMILY_PSEUDO:
911 : 0 : break;
912 : : default:
913 : : OSL_ENSURE(!this, "unknown style family");
914 : : }
915 : :
916 : 1125 : sal_Bool bRet = sal_False;
917 [ + - ]: 2250 : if( pFmt && pFmt->DerivedFrom() &&
[ + - + - ]
[ + - ]
918 : 1125 : pFmt->DerivedFrom()->GetName() != rStr )
919 : : {
920 : : {
921 [ + - ]: 1125 : SwImplShellAction aTmp( rDoc );
922 [ + - ][ + - ]: 1125 : bRet = pFmt->SetDerivedFrom( pParent );
923 : : }
924 : :
925 [ + - ]: 1125 : if( bRet )
926 : : {
927 : 1125 : aParent = rStr;
928 : : pPool->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED,
929 [ + - ]: 1125 : *this ) );
930 : : }
931 : : }
932 : :
933 : 1125 : return bRet;
934 : : }
935 : :
936 : : /*--------------------------------------------------------------------
937 : : Description: Set Follower
938 : : --------------------------------------------------------------------*/
939 : :
940 : :
941 : 42 : sal_Bool SwDocStyleSheet::SetFollow( const String& rStr)
942 : : {
943 [ + - ][ + - ]: 42 : if( rStr.Len() && !SfxStyleSheetBase::SetFollow( rStr ))
[ - + ][ - + ]
944 : 0 : return sal_False;
945 : :
946 [ + - ]: 42 : SwImplShellAction aTmpSh( rDoc );
947 [ + + - - ]: 42 : switch(nFamily)
948 : : {
949 : : case SFX_STYLE_FAMILY_PARA :
950 : : {
951 : : OSL_ENSURE(pColl, "Collection missing!");
952 [ + - ]: 28 : if( pColl )
953 : : {
954 : 28 : SwTxtFmtColl* pFollow = pColl;
955 [ + - ][ + - ]: 28 : if( rStr.Len() && 0 == (pFollow = lcl_FindParaFmt(rDoc, rStr) ))
[ - + ][ - + ]
956 : 0 : pFollow = pColl;
957 : :
958 : 28 : pColl->SetNextTxtFmtColl(*pFollow);
959 : : }
960 : 28 : break;
961 : : }
962 : : case SFX_STYLE_FAMILY_PAGE :
963 : : {
964 : : OSL_ENSURE(pDesc, "PageDesc missing!");
965 [ + - ]: 14 : if( pDesc )
966 : : {
967 : 14 : const SwPageDesc* pFollowDesc = rStr.Len()
968 : 14 : ? lcl_FindPageDesc(rDoc, rStr)
969 [ + - ][ + - ]: 14 : : 0;
970 : : sal_uInt16 nId;
971 [ + - ][ + - ]: 28 : if( pFollowDesc != pDesc->GetFollow() &&
[ + - ]
972 [ + - ]: 14 : rDoc.FindPageDescByName( pDesc->GetName(), &nId ) )
973 : : {
974 [ + - ]: 14 : SwPageDesc aDesc( *pDesc );
975 : 14 : aDesc.SetFollow( pFollowDesc );
976 [ + - ]: 14 : rDoc.ChgPageDesc( nId, aDesc );
977 [ + - ][ + - ]: 14 : pDesc = &rDoc.GetPageDesc( nId );
978 : : }
979 : : }
980 : 14 : break;
981 : : }
982 : : case SFX_STYLE_FAMILY_CHAR:
983 : : case SFX_STYLE_FAMILY_FRAME:
984 : : case SFX_STYLE_FAMILY_PSEUDO:
985 : 0 : break;
986 : : default:
987 : : OSL_ENSURE(!this, "unknwown style family");
988 : : }
989 : :
990 [ + - ]: 42 : return sal_True;
991 : : }
992 : :
993 : : /*--------------------------------------------------------------------
994 : : Description: extract ItemSet to Name and Family, Mask
995 : : --------------------------------------------------------------------*/
996 : :
997 : 11738 : SfxItemSet& SwDocStyleSheet::GetItemSet()
998 : : {
999 [ + + ]: 11738 : if(!bPhysical)
1000 : 111 : FillStyleSheet( FillPhysical );
1001 : :
1002 [ + + + + : 11738 : switch(nFamily)
- ]
1003 : : {
1004 : : case SFX_STYLE_FAMILY_CHAR:
1005 : : {
1006 : : OSL_ENSURE(pCharFmt, "Where's SwCharFmt");
1007 : 2082 : aCoreSet.Put(pCharFmt->GetAttrSet());
1008 : :
1009 [ + - ]: 2082 : if(pCharFmt->DerivedFrom())
1010 : 2082 : aCoreSet.SetParent(&pCharFmt->DerivedFrom()->GetAttrSet());
1011 : : }
1012 : 2082 : break;
1013 : : case SFX_STYLE_FAMILY_PARA :
1014 : : case SFX_STYLE_FAMILY_FRAME:
1015 : : {
1016 [ + - ]: 6718 : SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1017 : 6718 : aBoxInfo.SetTable( sal_False );
1018 : 6718 : aBoxInfo.SetDist( sal_True ); // always show gap field
1019 : 6718 : aBoxInfo.SetMinDist( sal_True );// set minimum size in tables and paragraphs
1020 : 6718 : aBoxInfo.SetDefDist( MIN_BORDER_DIST );// always set Default-Gap
1021 : : // Single lines can only have DontCare-Status in tables
1022 : 6718 : aBoxInfo.SetValid( VALID_DISABLE, sal_True );
1023 [ + + ]: 6718 : if ( nFamily == SFX_STYLE_FAMILY_PARA )
1024 : : {
1025 : : OSL_ENSURE(pColl, "Where's Collection");
1026 [ + - ]: 6650 : aCoreSet.Put(pColl->GetAttrSet());
1027 [ + - ]: 6650 : aCoreSet.Put( aBoxInfo );
1028 [ + - ][ + - ]: 6650 : aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pColl->IsAutoUpdateFmt()));
[ + - ]
1029 : :
1030 [ + - ]: 6650 : if(pColl->DerivedFrom())
1031 : 6650 : aCoreSet.SetParent(&pColl->DerivedFrom()->GetAttrSet());
1032 : : }
1033 : : else
1034 : : {
1035 : : OSL_ENSURE(pFrmFmt, "Where's FrmFmt");
1036 [ + - ]: 68 : aCoreSet.Put(pFrmFmt->GetAttrSet());
1037 [ + - ]: 68 : aCoreSet.Put( aBoxInfo );
1038 [ + - ][ + - ]: 68 : aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pFrmFmt->IsAutoUpdateFmt()));
[ + - ]
1039 : :
1040 [ + - ]: 68 : if(pFrmFmt->DerivedFrom())
1041 : 68 : aCoreSet.SetParent(&pFrmFmt->DerivedFrom()->GetAttrSet());
1042 [ + - ]: 6718 : }
1043 : : }
1044 : 6718 : break;
1045 : :
1046 : : case SFX_STYLE_FAMILY_PAGE :
1047 : : {
1048 : : OSL_ENSURE(pDesc, "No PageDescriptor");
1049 : 2822 : ::PageDescToItemSet(*((SwPageDesc*)pDesc), aCoreSet);
1050 : : }
1051 : 2822 : break;
1052 : :
1053 : : case SFX_STYLE_FAMILY_PSEUDO:
1054 : : {
1055 : : OSL_ENSURE(pNumRule, "No NumRule");
1056 [ + - ]: 116 : SvxNumRule aRule = pNumRule->MakeSvxNumRule();
1057 [ + - ][ + - ]: 116 : aCoreSet.Put(SvxNumBulletItem(aRule));
[ + - ][ + - ]
1058 : : }
1059 : 116 : break;
1060 : :
1061 : : default:
1062 : : OSL_ENSURE(!this, "unknown style family");
1063 : : }
1064 : : // Member of Baseclass
1065 : 11738 : pSet = &aCoreSet;
1066 : :
1067 : 11738 : return aCoreSet;
1068 : : }
1069 : :
1070 : 0 : void SwDocStyleSheet::MergeIndentAttrsOfListStyle( SfxItemSet& rSet )
1071 : : {
1072 [ # # ]: 0 : if ( nFamily != SFX_STYLE_FAMILY_PARA )
1073 : : {
1074 : 0 : return;
1075 : : }
1076 : :
1077 : : OSL_ENSURE( pColl, "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - missing paragraph style");
1078 [ # # ]: 0 : if ( pColl->AreListLevelIndentsApplicable() )
1079 : : {
1080 : : OSL_ENSURE( pColl->GetItemState( RES_PARATR_NUMRULE ) == SFX_ITEM_SET,
1081 : : "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - list level indents are applicable at paragraph style, but no list style found. Serious defect -> please inform OD." );
1082 [ # # ][ # # ]: 0 : const String sNumRule = pColl->GetNumRule().GetValue();
1083 [ # # ]: 0 : if( sNumRule.Len() )
1084 : : {
1085 [ # # ]: 0 : const SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule );
1086 [ # # ]: 0 : if( pRule )
1087 : : {
1088 [ # # ]: 0 : const SwNumFmt& rFmt = pRule->Get( 0 );
1089 [ # # ][ # # ]: 0 : if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1090 : : {
1091 [ # # ]: 0 : SvxLRSpaceItem aLR( RES_LR_SPACE );
1092 [ # # ][ # # ]: 0 : aLR.SetTxtLeft( rFmt.GetIndentAt() );
1093 [ # # ][ # # ]: 0 : aLR.SetTxtFirstLineOfst( static_cast<short>(rFmt.GetFirstLineIndent()) );
1094 [ # # ][ # # ]: 0 : rSet.Put( aLR );
1095 : : }
1096 : : }
1097 [ # # ]: 0 : }
1098 : : }
1099 : : }
1100 : :
1101 : : // handling of parameter <bResetIndentAttrsAtParagraphStyle>
1102 : 5636 : void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
1103 : : const bool bResetIndentAttrsAtParagraphStyle )
1104 : : {
1105 : : // if applicable determine format first
1106 [ - + ]: 5636 : if(!bPhysical)
1107 [ # # ]: 0 : FillStyleSheet( FillPhysical );
1108 : :
1109 [ + - ]: 5636 : SwImplShellAction aTmpSh( rDoc );
1110 : :
1111 : : OSL_ENSURE( &rSet != &aCoreSet, "SetItemSet with own Set is not allowed" );
1112 : :
1113 [ + - ][ + - ]: 5636 : if (rDoc.GetIDocumentUndoRedo().DoesUndo())
[ + + ]
1114 : : {
1115 [ + - ]: 298 : SwRewriter aRewriter;
1116 [ + - ][ + - ]: 298 : aRewriter.AddRule( UndoArg1, GetName() );
1117 [ + - ][ + - ]: 298 : rDoc.GetIDocumentUndoRedo().StartUndo( UNDO_INSFMTATTR, &aRewriter );
[ + - ]
1118 : : }
1119 : :
1120 : 5636 : SwFmt* pFmt = 0;
1121 : 5636 : SwPageDesc* pNewDsc = 0;
1122 : 5636 : sal_uInt16 nPgDscPos = 0;
1123 : :
1124 [ + + + + : 5636 : switch(nFamily)
+ - ]
1125 : : {
1126 : : case SFX_STYLE_FAMILY_CHAR :
1127 : : {
1128 : : OSL_ENSURE(pCharFmt, "Where's CharFormat");
1129 : 1156 : pFmt = pCharFmt;
1130 : : }
1131 : 1156 : break;
1132 : :
1133 : : case SFX_STYLE_FAMILY_PARA :
1134 : : {
1135 : : OSL_ENSURE(pColl, "Where's Collection");
1136 : : const SfxPoolItem* pAutoUpdate;
1137 [ + - ][ + - ]: 3377 : if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,sal_False, &pAutoUpdate ))
1138 : : {
1139 : 3377 : pColl->SetAutoUpdateFmt(((const SfxBoolItem*)pAutoUpdate)->GetValue());
1140 : : }
1141 : :
1142 : : const SwCondCollItem* pCondItem;
1143 [ + - ]: 3377 : if( SFX_ITEM_SET != rSet.GetItemState( FN_COND_COLL, sal_False,
1144 [ + - ]: 3377 : (const SfxPoolItem**)&pCondItem ))
1145 : 3377 : pCondItem = 0;
1146 : :
1147 [ + + ][ - + ]: 3377 : if( RES_CONDTXTFMTCOLL == pColl->Which() && pCondItem )
[ - + ]
1148 : : {
1149 : : SwFmt* pFindFmt;
1150 [ # # ]: 0 : const CommandStruct* pCmds = SwCondCollItem::GetCmds();
1151 [ # # ]: 0 : for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
1152 : : {
1153 [ # # ]: 0 : SwCollCondition aCond( 0, pCmds[ i ].nCnd, pCmds[ i ].nSubCond );
1154 [ # # ]: 0 : ((SwConditionTxtFmtColl*)pColl)->RemoveCondition( aCond );
1155 [ # # ]: 0 : const String& rStyle = pCondItem->GetStyle( i );
1156 [ # # ][ # # ]: 0 : if( rStyle.Len() &&
[ # # ][ # # ]
1157 : 0 : 0 != ( pFindFmt = lcl_FindParaFmt( rDoc, rStyle, 0, sal_True )))
1158 : : {
1159 [ # # ]: 0 : aCond.RegisterToFormat( *pFindFmt );
1160 [ # # ]: 0 : ((SwConditionTxtFmtColl*)pColl)->InsertCondition( aCond );
1161 : : }
1162 [ # # ]: 0 : }
1163 : :
1164 : : // Update document to new conditions
1165 [ # # ]: 0 : SwCondCollCondChg aMsg( pColl );
1166 [ # # ][ # # ]: 0 : pColl->ModifyNotification( &aMsg, &aMsg );
1167 : : }
1168 [ - + ][ # # ]: 3377 : else if( pCondItem && !pColl->GetDepends() )
[ - + ]
1169 : : {
1170 : : // no conditional template, then first create and adopt
1171 : : // all important values
1172 : : SwConditionTxtFmtColl* pCColl = rDoc.MakeCondTxtFmtColl(
1173 [ # # ]: 0 : pColl->GetName(), (SwTxtFmtColl*)pColl->DerivedFrom() );
1174 [ # # ]: 0 : if( pColl != &pColl->GetNextTxtFmtColl() )
1175 : 0 : pCColl->SetNextTxtFmtColl( pColl->GetNextTxtFmtColl() );
1176 : :
1177 [ # # ]: 0 : if( pColl->IsAssignedToListLevelOfOutlineStyle())
1178 [ # # ][ # # ]: 0 : pCColl->AssignToListLevelOfOutlineStyle(pColl->GetAssignedOutlineStyleLevel());
1179 : : else
1180 [ # # ]: 0 : pCColl->DeleteAssignmentToListLevelOfOutlineStyle();
1181 : :
1182 : :
1183 : :
1184 : : SwTxtFmtColl* pFindFmt;
1185 [ # # ]: 0 : const CommandStruct* pCmds = SwCondCollItem::GetCmds();
1186 [ # # ]: 0 : for( sal_uInt16 i = 0; i < COND_COMMAND_COUNT; ++i )
1187 : : {
1188 [ # # ]: 0 : const String& rStyle = pCondItem->GetStyle( i );
1189 [ # # ][ # # ]: 0 : if( rStyle.Len() &&
[ # # ][ # # ]
1190 : 0 : 0 != ( pFindFmt = lcl_FindParaFmt( rDoc, rStyle, 0, sal_True )))
1191 : : {
1192 : : pCColl->InsertCondition( SwCollCondition( pFindFmt,
1193 [ # # ][ # # ]: 0 : pCmds[ i ].nCnd, pCmds[ i ].nSubCond ) );
[ # # ]
1194 : : }
1195 : : }
1196 : :
1197 [ # # ]: 0 : rDoc.DelTxtFmtColl( pColl );
1198 : 0 : pColl = pCColl;
1199 : : }
1200 [ - + ][ # # ]: 3377 : if ( bResetIndentAttrsAtParagraphStyle &&
[ # # ][ # # ]
[ - + ]
1201 [ # # ]: 0 : rSet.GetItemState( RES_PARATR_NUMRULE, sal_False, 0 ) == SFX_ITEM_SET &&
1202 [ # # ]: 0 : rSet.GetItemState( RES_LR_SPACE, sal_False, 0 ) != SFX_ITEM_SET &&
1203 [ # # ]: 0 : pColl->GetItemState( RES_LR_SPACE, sal_False, 0 ) == SFX_ITEM_SET )
1204 : : {
1205 [ # # ]: 0 : rDoc.ResetAttrAtFormat( RES_LR_SPACE, *pColl );
1206 : : }
1207 : :
1208 : : // #i56252: If a standard numbering style is assigned to a standard paragraph style
1209 : : // we have to create a physical instance of the numbering style. If we do not and
1210 : : // neither the paragraph style nor the numbering style is used in the document
1211 : : // the numbering style will not be saved with the document and the assignment got lost.
1212 : 3377 : const SfxPoolItem* pNumRuleItem = 0;
1213 [ + - ][ + + ]: 3377 : if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE, sal_False, &pNumRuleItem ) )
1214 : : { // Setting a numbering rule?
1215 [ + - ]: 45 : String sNumRule = ((SwNumRuleItem*)pNumRuleItem)->GetValue();
1216 [ + + ]: 45 : if( sNumRule.Len() )
1217 : : {
1218 [ + - ]: 27 : SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule );
1219 [ - + ]: 27 : if( !pRule )
1220 : : { // Numbering rule not in use yet.
1221 [ # # ]: 0 : sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sNumRule, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
1222 [ # # ]: 0 : if( USHRT_MAX != nPoolId ) // It's a standard numbering rule
1223 : : {
1224 [ # # ]: 0 : pRule = rDoc.GetNumRuleFromPool( nPoolId ); // Create numbering rule (physical)
1225 : : }
1226 : : }
1227 [ + - ]: 45 : }
1228 : : }
1229 : :
1230 : 3377 : pFmt = pColl;
1231 : :
1232 : 3377 : sal_uInt16 nId = pColl->GetPoolFmtId() &
1233 : 3377 : ~ ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID );
1234 [ + + + + : 3377 : switch( GetMask() & ( 0x0fff & ~SWSTYLEBIT_CONDCOLL ) )
+ - + ]
1235 : : {
1236 : : case SWSTYLEBIT_TEXT:
1237 : 1287 : nId |= COLL_TEXT_BITS;
1238 : 1287 : break;
1239 : : case SWSTYLEBIT_CHAPTER:
1240 : 24 : nId |= COLL_DOC_BITS;
1241 : 24 : break;
1242 : : case SWSTYLEBIT_LIST:
1243 : 342 : nId |= COLL_LISTS_BITS;
1244 : 342 : break;
1245 : : case SWSTYLEBIT_IDX:
1246 : 398 : nId |= COLL_REGISTER_BITS;
1247 : 398 : break;
1248 : : case SWSTYLEBIT_EXTRA:
1249 : 427 : nId |= COLL_EXTRA_BITS;
1250 : 427 : break;
1251 : : case SWSTYLEBIT_HTML:
1252 : 0 : nId |= COLL_HTML_BITS;
1253 : 0 : break;
1254 : : }
1255 : 3377 : pColl->SetPoolFmtId( nId );
1256 : : break;
1257 : : }
1258 : : case SFX_STYLE_FAMILY_FRAME:
1259 : : {
1260 : : OSL_ENSURE(pFrmFmt, "Where's FrmFmt");
1261 : : const SfxPoolItem* pAutoUpdate;
1262 [ + - ][ + - ]: 40 : if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,sal_False, &pAutoUpdate ))
1263 : : {
1264 : 40 : pFrmFmt->SetAutoUpdateFmt(((const SfxBoolItem*)pAutoUpdate)->GetValue());
1265 : : }
1266 : 40 : pFmt = pFrmFmt;
1267 : : }
1268 : 40 : break;
1269 : :
1270 : : case SFX_STYLE_FAMILY_PAGE :
1271 : : {
1272 : : OSL_ENSURE(pDesc, "Where's PageDescriptor");
1273 : :
1274 [ + - ][ + - ]: 947 : if( rDoc.FindPageDescByName( pDesc->GetName(), &nPgDscPos ))
1275 : : {
1276 [ + - ][ + - ]: 947 : pNewDsc = new SwPageDesc( *pDesc );
1277 : : // #i48949# - no undo actions for the
1278 : : // copy of the page style
1279 [ + - ][ + - ]: 947 : ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
1280 [ + - ]: 947 : rDoc.CopyPageDesc(*pDesc, *pNewDsc); // #i7983#
1281 : :
1282 [ + - ]: 947 : pFmt = &pNewDsc->GetMaster();
1283 : : }
1284 : : }
1285 : 947 : break;
1286 : :
1287 : : case SFX_STYLE_FAMILY_PSEUDO:
1288 : : {
1289 : : OSL_ENSURE(pNumRule, "Where's NumRule");
1290 : :
1291 [ + - ]: 116 : if (!pNumRule)
1292 : : break;
1293 : :
1294 : : const SfxPoolItem* pItem;
1295 [ + - ]: 116 : switch( rSet.GetItemState( SID_ATTR_NUMBERING_RULE, sal_False, &pItem ))
[ + - - ]
1296 : : {
1297 : : case SFX_ITEM_SET:
1298 : : {
1299 : 116 : SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule();
1300 [ + - ]: 116 : pSetRule->UnLinkGraphics();
1301 [ + - ]: 116 : SwNumRule aSetRule(*pNumRule);
1302 [ + - ]: 116 : aSetRule.SetSvxRule(*pSetRule, &rDoc);
1303 [ + - ][ + - ]: 116 : rDoc.ChgNumRuleFmts( aSetRule );
1304 : : }
1305 : 116 : break;
1306 : : case SFX_ITEM_DONTCARE:
1307 : : // set NumRule to default values
1308 : : // what are the default values?
1309 : : {
1310 : 0 : SwNumRule aRule( pNumRule->GetName(),
1311 : : // #i89178#
1312 [ # # # # ]: 0 : numfunc::GetDefaultPositionAndSpaceMode() );
1313 [ # # ][ # # ]: 0 : rDoc.ChgNumRuleFmts( aRule );
1314 : : }
1315 : 0 : break;
1316 : : }
1317 : : }
1318 : 116 : break;
1319 : :
1320 : : default:
1321 : : OSL_ENSURE(!this, "unknown style family");
1322 : : }
1323 : :
1324 [ + + ][ + + ]: 5636 : if( pFmt && rSet.Count())
[ + + ]
1325 : : {
1326 [ + - ]: 5449 : SfxItemIter aIter( rSet );
1327 : 5449 : const SfxPoolItem* pItem = aIter.GetCurItem();
1328 : 40930 : while( sal_True )
1329 : : {
1330 [ - + ]: 46379 : if( IsInvalidItem( pItem ) ) // Clear
1331 : : {
1332 : : // use method <SwDoc::ResetAttrAtFormat(..)> in order to
1333 : : // create an Undo object for the attribute reset.
1334 [ # # ]: 0 : rDoc.ResetAttrAtFormat( rSet.GetWhichByPos(aIter.GetCurPos()),
1335 [ # # ]: 0 : *pFmt );
1336 : : }
1337 : :
1338 [ + + ]: 46379 : if( aIter.IsAtEnd() )
1339 : 5449 : break;
1340 [ + - ]: 40930 : pItem = aIter.NextItem();
1341 : : }
1342 [ + - ]: 5449 : SfxItemSet aSet(rSet);
1343 [ + - ]: 5449 : aSet.ClearInvalidItems();
1344 : :
1345 [ + - ]: 5449 : aCoreSet.ClearItem();
1346 : :
1347 [ + + ]: 5449 : if( pNewDsc )
1348 : : {
1349 [ + - ]: 947 : ::ItemSetToPageDesc( aSet, *pNewDsc );
1350 [ + - ]: 947 : rDoc.ChgPageDesc( nPgDscPos, *pNewDsc );
1351 [ + - ]: 947 : pDesc = &rDoc.GetPageDesc( nPgDscPos );
1352 [ + - ]: 947 : rDoc.PreDelPageDesc(pNewDsc); // #i7983#
1353 [ + - ][ + - ]: 947 : delete pNewDsc;
1354 : : }
1355 : : else
1356 [ + - ][ + - ]: 5449 : rDoc.ChgFmt(*pFmt, aSet); // put all that is set
[ + - ]
1357 : : }
1358 : : else
1359 : : {
1360 [ + - ]: 187 : aCoreSet.ClearItem();
1361 [ - + ]: 187 : if( pNewDsc ) // we still need to delete it
1362 : : {
1363 [ # # ]: 0 : rDoc.PreDelPageDesc(pNewDsc); // #i7983#
1364 [ # # ][ # # ]: 0 : delete pNewDsc;
1365 : : }
1366 : : }
1367 : :
1368 [ + - ][ + - ]: 5636 : if (rDoc.GetIDocumentUndoRedo().DoesUndo())
[ + + ]
1369 : : {
1370 [ + - ][ + - ]: 298 : rDoc.GetIDocumentUndoRedo().EndUndo(UNDO_END, 0);
1371 [ + - ]: 5636 : }
1372 : 5636 : }
1373 : :
1374 : 0 : void lcl_SaveStyles( sal_uInt16 nFamily, std::vector<void*>& rArr, SwDoc& rDoc )
1375 : : {
1376 [ # # # # : 0 : switch( nFamily )
# # ]
1377 : : {
1378 : : case SFX_STYLE_FAMILY_CHAR:
1379 : : {
1380 : 0 : const SwCharFmts& rTbl = *rDoc.GetCharFmts();
1381 [ # # ]: 0 : for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
1382 : : {
1383 [ # # ]: 0 : rArr.push_back( rTbl[ n ] );
1384 : : }
1385 : : }
1386 : 0 : break;
1387 : : case SFX_STYLE_FAMILY_PARA:
1388 : : {
1389 : 0 : const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls();
1390 [ # # ]: 0 : for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
1391 : : {
1392 [ # # ]: 0 : rArr.push_back( rTbl[ n ] );
1393 : : }
1394 : : }
1395 : 0 : break;
1396 : : case SFX_STYLE_FAMILY_FRAME:
1397 : : {
1398 : 0 : const SwFrmFmts& rTbl = *rDoc.GetFrmFmts();
1399 [ # # ]: 0 : for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
1400 : : {
1401 [ # # ]: 0 : rArr.push_back( rTbl[ n ] );
1402 : : }
1403 : : }
1404 : 0 : break;
1405 : :
1406 : : case SFX_STYLE_FAMILY_PAGE:
1407 : : {
1408 [ # # ]: 0 : for( sal_uInt16 n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
1409 : : {
1410 [ # # ]: 0 : rArr.push_back( &rDoc.GetPageDesc( n ) );
1411 : : }
1412 : : }
1413 : 0 : break;
1414 : :
1415 : : case SFX_STYLE_FAMILY_PSEUDO:
1416 : : {
1417 : 0 : const SwNumRuleTbl& rTbl = rDoc.GetNumRuleTbl();
1418 [ # # ]: 0 : for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
1419 : : {
1420 [ # # ]: 0 : rArr.push_back( rTbl[ n ] );
1421 : : }
1422 : : }
1423 : 0 : break;
1424 : : }
1425 : 0 : }
1426 : :
1427 : 0 : static bool lcl_Contains(const std::vector<void*>& rArr, const void* p)
1428 : : {
1429 [ # # ][ # # ]: 0 : return std::find( rArr.begin(), rArr.end(), p ) != rArr.end();
1430 : : }
1431 : :
1432 : 0 : void lcl_DeleteInfoStyles( sal_uInt16 nFamily, std::vector<void*>& rArr, SwDoc& rDoc )
1433 : : {
1434 : : sal_uInt16 n, nCnt;
1435 [ # # # # : 0 : switch( nFamily )
# # ]
1436 : : {
1437 : : case SFX_STYLE_FAMILY_CHAR:
1438 : : {
1439 [ # # ]: 0 : std::deque<sal_uInt16> aDelArr;
1440 : 0 : const SwCharFmts& rTbl = *rDoc.GetCharFmts();
1441 [ # # ]: 0 : for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
1442 : : {
1443 [ # # ][ # # ]: 0 : if( !lcl_Contains( rArr, rTbl[ n ] ))
[ # # ]
1444 [ # # ]: 0 : aDelArr.push_front( n );
1445 : : }
1446 [ # # ]: 0 : for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
1447 [ # # ][ # # ]: 0 : rDoc.DelCharFmt( aDelArr[ n ] );
1448 : : }
1449 : 0 : break;
1450 : :
1451 : : case SFX_STYLE_FAMILY_PARA :
1452 : : {
1453 [ # # ]: 0 : std::deque<sal_uInt16> aDelArr;
1454 : 0 : const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls();
1455 [ # # ]: 0 : for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
1456 : : {
1457 [ # # ][ # # ]: 0 : if( !lcl_Contains( rArr, rTbl[ n ] ))
[ # # ]
1458 [ # # ]: 0 : aDelArr.push_front( n );
1459 : : }
1460 [ # # ]: 0 : for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
1461 [ # # ][ # # ]: 0 : rDoc.DelTxtFmtColl( aDelArr[ n ] );
1462 : : }
1463 : 0 : break;
1464 : :
1465 : : case SFX_STYLE_FAMILY_FRAME:
1466 : : {
1467 [ # # ]: 0 : std::deque<SwFrmFmt*> aDelArr;
1468 : 0 : const SwFrmFmts& rTbl = *rDoc.GetFrmFmts();
1469 [ # # ]: 0 : for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
1470 : : {
1471 [ # # ][ # # ]: 0 : if( !lcl_Contains( rArr, rTbl[ n ] ))
[ # # ]
1472 [ # # ][ # # ]: 0 : aDelArr.push_front( rTbl[ n ] );
1473 : : }
1474 [ # # ]: 0 : for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
1475 [ # # ][ # # ]: 0 : rDoc.DelFrmFmt( aDelArr[ n ] );
1476 : : }
1477 : 0 : break;
1478 : :
1479 : : case SFX_STYLE_FAMILY_PAGE:
1480 : : {
1481 [ # # ]: 0 : std::deque<sal_uInt16> aDelArr;
1482 [ # # ]: 0 : for( n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
1483 : : {
1484 [ # # ][ # # ]: 0 : if( !lcl_Contains( rArr, &rDoc.GetPageDesc( n ) ))
[ # # ]
1485 [ # # ]: 0 : aDelArr.push_front( n );
1486 : : }
1487 [ # # ]: 0 : for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
1488 [ # # ][ # # ]: 0 : rDoc.DelPageDesc( aDelArr[ n ] );
1489 : : }
1490 : 0 : break;
1491 : :
1492 : :
1493 : : case SFX_STYLE_FAMILY_PSEUDO:
1494 : : {
1495 [ # # ]: 0 : std::deque<SwNumRule*> aDelArr;
1496 : 0 : const SwNumRuleTbl& rTbl = rDoc.GetNumRuleTbl();
1497 [ # # ]: 0 : for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n )
1498 : : {
1499 [ # # ][ # # ]: 0 : if( !lcl_Contains( rArr, rTbl[ n ] ))
1500 [ # # ]: 0 : aDelArr.push_front( rTbl[ n ] );
1501 : : }
1502 [ # # ]: 0 : for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
1503 [ # # ][ # # ]: 0 : rDoc.DelNumRule( aDelArr[ n ]->GetName() );
1504 : : }
1505 : 0 : break;
1506 : : }
1507 : 0 : }
1508 : :
1509 : : /*--------------------------------------------------------------------
1510 : : Description: determine the format
1511 : : --------------------------------------------------------------------*/
1512 : :
1513 : 67305 : sal_Bool SwDocStyleSheet::FillStyleSheet( FillStyleType eFType )
1514 : : {
1515 : 67305 : sal_Bool bRet = sal_False;
1516 : 67305 : sal_uInt16 nPoolId = USHRT_MAX;
1517 : 67305 : SwFmt* pFmt = 0;
1518 : :
1519 : 67305 : sal_Bool bCreate = FillPhysical == eFType;
1520 : 67305 : sal_Bool bDeleteInfo = sal_False;
1521 : 67305 : sal_Bool bFillOnlyInfo = FillAllInfo == eFType;
1522 [ + - ]: 67305 : std::vector<void*> aDelArr;
1523 : :
1524 [ + + + + : 67305 : switch(nFamily)
+ - ]
1525 : : {
1526 : : case SFX_STYLE_FAMILY_CHAR:
1527 [ + - ]: 7738 : pCharFmt = lcl_FindCharFmt(rDoc, aName, this, bCreate );
1528 : 7738 : bPhysical = 0 != pCharFmt;
1529 [ - + ][ # # ]: 7738 : if( bFillOnlyInfo && !bPhysical )
1530 : : {
1531 : 0 : bDeleteInfo = sal_True;
1532 [ # # ]: 0 : ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
1533 [ # # ]: 0 : pCharFmt = lcl_FindCharFmt(rDoc, aName, this, sal_True );
1534 : : }
1535 : :
1536 : 7738 : pFmt = pCharFmt;
1537 [ + + ][ + + ]: 7738 : if( !bCreate && !pFmt )
1538 : : {
1539 [ + - ][ - + ]: 8684 : if( aName == SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
1540 [ + - ][ + - ]: 4342 : RES_POOLCOLL_TEXT_BEGIN ] )
1541 : 0 : nPoolId = 0;
1542 : : else
1543 [ + - ]: 4342 : nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
1544 : : }
1545 : :
1546 [ + + ][ + + ]: 7738 : bRet = 0 != pCharFmt || USHRT_MAX != nPoolId;
1547 : :
1548 [ - + ]: 7738 : if( bDeleteInfo )
1549 : 0 : pCharFmt = 0;
1550 : 7738 : break;
1551 : :
1552 : : case SFX_STYLE_FAMILY_PARA:
1553 : : {
1554 [ + - ]: 48836 : pColl = lcl_FindParaFmt(rDoc, aName, this, bCreate);
1555 : 48836 : bPhysical = 0 != pColl;
1556 [ - + ][ # # ]: 48836 : if( bFillOnlyInfo && !bPhysical )
1557 : : {
1558 : 0 : bDeleteInfo = sal_True;
1559 [ # # ]: 0 : ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
1560 [ # # ]: 0 : pColl = lcl_FindParaFmt(rDoc, aName, this, sal_True );
1561 : : }
1562 : :
1563 : 48836 : pFmt = pColl;
1564 [ + + ]: 48836 : if( pColl )
1565 [ + - ]: 26521 : PresetFollow( pColl->GetNextTxtFmtColl().GetName() );
1566 [ + - ]: 22315 : else if( !bCreate )
1567 [ + - ]: 22315 : nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
1568 : :
1569 [ + + ][ + + ]: 48836 : bRet = 0 != pColl || USHRT_MAX != nPoolId;
1570 : :
1571 [ - + ]: 48836 : if( bDeleteInfo )
1572 : 0 : pColl = 0;
1573 : : }
1574 : 48836 : break;
1575 : :
1576 : : case SFX_STYLE_FAMILY_FRAME:
1577 [ + - ]: 1434 : pFrmFmt = lcl_FindFrmFmt(rDoc, aName, this, bCreate);
1578 : 1434 : bPhysical = 0 != pFrmFmt;
1579 [ - + ][ # # ]: 1434 : if( bFillOnlyInfo && bPhysical )
1580 : : {
1581 : 0 : bDeleteInfo = sal_True;
1582 [ # # ]: 0 : ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
1583 [ # # ]: 0 : pFrmFmt = lcl_FindFrmFmt(rDoc, aName, this, sal_True );
1584 : : }
1585 : 1434 : pFmt = pFrmFmt;
1586 [ + + ][ + + ]: 1434 : if( !bCreate && !pFmt )
1587 [ + - ]: 1218 : nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT );
1588 : :
1589 [ + + ][ + - ]: 1434 : bRet = 0 != pFrmFmt || USHRT_MAX != nPoolId;
1590 : :
1591 [ - + ]: 1434 : if( bDeleteInfo )
1592 : 0 : pFrmFmt = 0;
1593 : 1434 : break;
1594 : :
1595 : : case SFX_STYLE_FAMILY_PAGE:
1596 [ + - ]: 7985 : pDesc = lcl_FindPageDesc(rDoc, aName, this, bCreate);
1597 : 7985 : bPhysical = 0 != pDesc;
1598 [ - + ][ # # ]: 7985 : if( bFillOnlyInfo && !pDesc )
1599 : : {
1600 : 0 : bDeleteInfo = sal_True;
1601 [ # # ]: 0 : ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
1602 [ # # ]: 0 : pDesc = lcl_FindPageDesc( rDoc, aName, this, sal_True );
1603 : : }
1604 : :
1605 [ + + ]: 7985 : if( pDesc )
1606 : : {
1607 : 5806 : nPoolId = pDesc->GetPoolFmtId();
1608 : 5806 : nHelpId = pDesc->GetPoolHelpId();
1609 [ - + ]: 5806 : if( pDesc->GetPoolHlpFileId() != UCHAR_MAX )
1610 [ # # ][ # # ]: 0 : aHelpFile = *rDoc.GetDocPattern( pDesc->GetPoolHlpFileId() );
1611 : : else
1612 [ + - ]: 5806 : aHelpFile.Erase();
1613 : : }
1614 [ + - ]: 2179 : else if( !bCreate )
1615 [ + - ]: 2179 : nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
1616 : 7985 : SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 );
1617 : :
1618 [ + + ][ + + ]: 7985 : bRet = 0 != pDesc || USHRT_MAX != nPoolId;
1619 [ - + ]: 7985 : if( bDeleteInfo )
1620 : 0 : pDesc = 0;
1621 : 7985 : break;
1622 : :
1623 : : case SFX_STYLE_FAMILY_PSEUDO:
1624 [ + - ]: 1312 : pNumRule = lcl_FindNumRule(rDoc, aName, this, bCreate);
1625 : 1312 : bPhysical = 0 != pNumRule;
1626 [ - + ][ # # ]: 1312 : if( bFillOnlyInfo && !pNumRule )
1627 : : {
1628 : 0 : bDeleteInfo = sal_True;
1629 [ # # ]: 0 : ::lcl_SaveStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
1630 [ # # ]: 0 : pNumRule = lcl_FindNumRule( rDoc, aName, this, sal_True );
1631 : : }
1632 : :
1633 [ + + ]: 1312 : if( pNumRule )
1634 : : {
1635 : 398 : nPoolId = pNumRule->GetPoolFmtId();
1636 : 398 : nHelpId = pNumRule->GetPoolHelpId();
1637 [ - + ]: 398 : if( pNumRule->GetPoolHlpFileId() != UCHAR_MAX )
1638 [ # # ][ # # ]: 0 : aHelpFile = *rDoc.GetDocPattern( pNumRule->GetPoolHlpFileId() );
1639 : : else
1640 [ + - ]: 398 : aHelpFile.Erase();
1641 : : }
1642 [ + - ]: 914 : else if( !bCreate )
1643 [ + - ]: 914 : nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
1644 : 1312 : SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 );
1645 : :
1646 [ + + ][ + + ]: 1312 : bRet = 0 != pNumRule || USHRT_MAX != nPoolId;
1647 : :
1648 [ - + ]: 1312 : if( bDeleteInfo )
1649 : 0 : pNumRule = 0;
1650 : 1312 : break;
1651 : : default:; //prevent warning
1652 : : }
1653 : :
1654 [ + + ][ + + ]: 67305 : if( SFX_STYLE_FAMILY_CHAR == nFamily ||
[ + + ]
1655 : : SFX_STYLE_FAMILY_PARA == nFamily ||
1656 : : SFX_STYLE_FAMILY_FRAME == nFamily )
1657 : : {
1658 [ + + ]: 58008 : if( pFmt )
1659 : 30133 : nPoolId = pFmt->GetPoolFmtId();
1660 : :
1661 : 58008 : sal_uInt16 _nMask = 0;
1662 [ + + ]: 58008 : if( pFmt == rDoc.GetDfltCharFmt() )
1663 : 120 : _nMask |= SFXSTYLEBIT_READONLY;
1664 [ + + ]: 57888 : else if( USER_FMT & nPoolId )
1665 : 7134 : _nMask |= SFXSTYLEBIT_USERDEF;
1666 : :
1667 [ + + + + : 58008 : switch ( COLL_GET_RANGE_BITS & nPoolId )
+ + + ]
1668 : : {
1669 : 28005 : case COLL_TEXT_BITS: _nMask |= SWSTYLEBIT_TEXT; break;
1670 : 415 : case COLL_DOC_BITS : _nMask |= SWSTYLEBIT_CHAPTER; break;
1671 : 6599 : case COLL_LISTS_BITS: _nMask |= SWSTYLEBIT_LIST; break;
1672 : 6677 : case COLL_REGISTER_BITS: _nMask |= SWSTYLEBIT_IDX; break;
1673 : 5418 : case COLL_EXTRA_BITS: _nMask |= SWSTYLEBIT_EXTRA; break;
1674 : 535 : case COLL_HTML_BITS: _nMask |= SWSTYLEBIT_HTML; break;
1675 : : }
1676 : :
1677 [ + + ]: 58008 : if( pFmt )
1678 : : {
1679 : : OSL_ENSURE( bPhysical, "Format not found" );
1680 : :
1681 : 30133 : nHelpId = pFmt->GetPoolHelpId();
1682 [ - + ]: 30133 : if( pFmt->GetPoolHlpFileId() != UCHAR_MAX )
1683 [ # # ][ # # ]: 0 : aHelpFile = *rDoc.GetDocPattern( pFmt->GetPoolHlpFileId() );
1684 : : else
1685 [ + - ]: 30133 : aHelpFile.Erase();
1686 : :
1687 [ + + ]: 30133 : if( RES_CONDTXTFMTCOLL == pFmt->Which() )
1688 : 5153 : _nMask |= SWSTYLEBIT_CONDCOLL;
1689 : : }
1690 : :
1691 : 58008 : SetMask( _nMask );
1692 : : }
1693 [ - + ][ # # ]: 67305 : if( bDeleteInfo && bFillOnlyInfo )
1694 [ # # ]: 0 : ::lcl_DeleteInfoStyles( static_cast< sal_uInt16 >(nFamily), aDelArr, rDoc );
1695 : 67305 : return bRet;
1696 : : }
1697 : :
1698 : : /*--------------------------------------------------------------------
1699 : : Description: Create new format in Core
1700 : : --------------------------------------------------------------------*/
1701 : :
1702 : :
1703 : 709 : void SwDocStyleSheet::Create()
1704 : : {
1705 [ + + - + : 709 : switch(nFamily)
+ - ]
1706 : : {
1707 : : case SFX_STYLE_FAMILY_CHAR :
1708 : 364 : pCharFmt = lcl_FindCharFmt( rDoc, aName );
1709 [ + - ]: 364 : if( !pCharFmt )
1710 : : pCharFmt = rDoc.MakeCharFmt(aName,
1711 : 364 : rDoc.GetDfltCharFmt());
1712 : 364 : pCharFmt->SetAuto( sal_False );
1713 : 364 : break;
1714 : :
1715 : : case SFX_STYLE_FAMILY_PARA :
1716 : 179 : pColl = lcl_FindParaFmt( rDoc, aName );
1717 [ + - ]: 179 : if( !pColl )
1718 : : {
1719 : 179 : SwTxtFmtColl *pPar = (*rDoc.GetTxtFmtColls())[0];
1720 [ + + ]: 179 : if( nMask & SWSTYLEBIT_CONDCOLL )
1721 : 4 : pColl = rDoc.MakeCondTxtFmtColl( aName, pPar );
1722 : : else
1723 : 175 : pColl = rDoc.MakeTxtFmtColl( aName, pPar );
1724 : : }
1725 : 179 : break;
1726 : :
1727 : : case SFX_STYLE_FAMILY_FRAME:
1728 : 0 : pFrmFmt = lcl_FindFrmFmt( rDoc, aName );
1729 [ # # ]: 0 : if( !pFrmFmt )
1730 : 0 : pFrmFmt = rDoc.MakeFrmFmt(aName, rDoc.GetDfltFrmFmt(), sal_False, sal_False);
1731 : :
1732 : 0 : break;
1733 : :
1734 : : case SFX_STYLE_FAMILY_PAGE :
1735 : 58 : pDesc = lcl_FindPageDesc( rDoc, aName );
1736 [ + - ]: 58 : if( !pDesc )
1737 : : {
1738 : 58 : sal_uInt16 nId = rDoc.MakePageDesc(aName);
1739 : 58 : pDesc = &rDoc.GetPageDesc(nId);
1740 : : }
1741 : 58 : break;
1742 : :
1743 : : case SFX_STYLE_FAMILY_PSEUDO:
1744 : 108 : pNumRule = lcl_FindNumRule( rDoc, aName );
1745 [ + - ]: 108 : if( !pNumRule )
1746 : : {
1747 [ + - ]: 108 : String sTmpNm( aName );
1748 [ - + ]: 108 : if( !aName.Len() )
1749 [ # # ][ # # ]: 0 : sTmpNm = rDoc.GetUniqueNumRuleName();
[ # # ]
1750 : :
1751 : 108 : SwNumRule* pRule = rDoc.GetNumRuleTbl()[
1752 : : rDoc.MakeNumRule( sTmpNm, 0, sal_False,
1753 : : // #i89178#
1754 [ + - ][ + - ]: 216 : numfunc::GetDefaultPositionAndSpaceMode() ) ];
1755 : 108 : pRule->SetAutoRule( sal_False );
1756 [ - + ]: 108 : if( !aName.Len() )
1757 : : {
1758 : : // #i91400#
1759 [ # # ]: 0 : pRule->SetName( aName, rDoc );
1760 : : }
1761 [ + - ]: 108 : pNumRule = pRule;
1762 : : }
1763 : 108 : break;
1764 : : default:; //prevent warning
1765 : : }
1766 : 709 : bPhysical = sal_True;
1767 : 709 : aCoreSet.ClearItem();
1768 : 709 : }
1769 : :
1770 : 3334 : SwCharFmt* SwDocStyleSheet::GetCharFmt()
1771 : : {
1772 [ + + ]: 3334 : if(!bPhysical)
1773 : 58 : FillStyleSheet( FillPhysical );
1774 : 3334 : return pCharFmt;
1775 : : }
1776 : :
1777 : 33133 : SwTxtFmtColl* SwDocStyleSheet::GetCollection()
1778 : : {
1779 [ + + ]: 33133 : if(!bPhysical)
1780 : 395 : FillStyleSheet( FillPhysical );
1781 : 33133 : return pColl;
1782 : : }
1783 : :
1784 : 5763 : const SwPageDesc* SwDocStyleSheet::GetPageDesc()
1785 : : {
1786 [ + + ]: 5763 : if(!bPhysical)
1787 : 32 : FillStyleSheet( FillPhysical );
1788 : 5763 : return pDesc;
1789 : : }
1790 : :
1791 : 527 : const SwNumRule * SwDocStyleSheet::GetNumRule()
1792 : : {
1793 [ + + ]: 527 : if(!bPhysical)
1794 : 10 : FillStyleSheet( FillPhysical );
1795 : 527 : return pNumRule;
1796 : : }
1797 : :
1798 : 116 : void SwDocStyleSheet::SetNumRule(const SwNumRule& rRule)
1799 : : {
1800 : : OSL_ENSURE(pNumRule, "Wo ist die NumRule");
1801 : 116 : rDoc.ChgNumRuleFmts( rRule );
1802 : 116 : }
1803 : :
1804 : : // re-generate Name AND Family from String
1805 : : // First() and Next() (see below) insert an identification letter at Pos.1
1806 : :
1807 : 34131 : void SwDocStyleSheet::PresetNameAndFamily(const String& rName)
1808 : : {
1809 [ + + + - : 34131 : switch( rName.GetChar(0) )
+ ]
1810 : : {
1811 : 31190 : case cPARA: nFamily = SFX_STYLE_FAMILY_PARA; break;
1812 : 201 : case cFRAME: nFamily = SFX_STYLE_FAMILY_FRAME; break;
1813 : 905 : case cPAGE: nFamily = SFX_STYLE_FAMILY_PAGE; break;
1814 : 0 : case cNUMRULE: nFamily = SFX_STYLE_FAMILY_PSEUDO; break;
1815 : 1835 : default: nFamily = SFX_STYLE_FAMILY_CHAR; break;
1816 : : }
1817 : 34131 : aName = rName;
1818 : 34131 : aName.Erase( 0, 1 );
1819 : 34131 : }
1820 : :
1821 : : /*--------------------------------------------------------------------
1822 : : Description: Is the format physically present yet
1823 : : --------------------------------------------------------------------*/
1824 : :
1825 : :
1826 : 184952 : void SwDocStyleSheet::SetPhysical(sal_Bool bPhys)
1827 : : {
1828 : 184952 : bPhysical = bPhys;
1829 : :
1830 [ + + ]: 184952 : if(!bPhys)
1831 : : {
1832 : 147906 : pCharFmt = 0;
1833 : 147906 : pColl = 0;
1834 : 147906 : pFrmFmt = 0;
1835 : 147906 : pDesc = 0;
1836 : : }
1837 : 184952 : }
1838 : :
1839 : 244 : SwFrmFmt* SwDocStyleSheet::GetFrmFmt()
1840 : : {
1841 [ + + ]: 244 : if(!bPhysical)
1842 : 26 : FillStyleSheet( FillPhysical );
1843 : 244 : return pFrmFmt;
1844 : : }
1845 : :
1846 : 6 : sal_Bool SwDocStyleSheet::IsUsed() const
1847 : : {
1848 [ - + ]: 6 : if( !bPhysical )
1849 : : {
1850 : 0 : SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
1851 : 0 : pThis->FillStyleSheet( FillOnlyName );
1852 : : }
1853 : :
1854 [ - + ]: 6 : if( !bPhysical )
1855 : 0 : return sal_False;
1856 : :
1857 : : const SwModify* pMod;
1858 [ + + - - : 6 : switch( nFamily )
- - ]
1859 : : {
1860 : 2 : case SFX_STYLE_FAMILY_CHAR : pMod = pCharFmt; break;
1861 : 4 : case SFX_STYLE_FAMILY_PARA : pMod = pColl; break;
1862 : 0 : case SFX_STYLE_FAMILY_FRAME: pMod = pFrmFmt; break;
1863 : 0 : case SFX_STYLE_FAMILY_PAGE : pMod = pDesc; break;
1864 : :
1865 : : case SFX_STYLE_FAMILY_PSEUDO:
1866 [ # # ]: 0 : return pNumRule ? rDoc.IsUsed( *pNumRule ) : sal_False;
1867 : :
1868 : : default:
1869 : : OSL_ENSURE(!this, "unknown style family");
1870 : 0 : return sal_False;
1871 : : }
1872 : 6 : return rDoc.IsUsed( *pMod );
1873 : : }
1874 : :
1875 : :
1876 : 0 : sal_uLong SwDocStyleSheet::GetHelpId( String& rFile )
1877 : : {
1878 : 0 : sal_uInt16 nId = 0;
1879 : 0 : sal_uInt16 nPoolId = 0;
1880 : 0 : unsigned char nFileId = UCHAR_MAX;
1881 : :
1882 [ # # ]: 0 : rFile = rtl::OUString("swrhlppi.hlp");
1883 : :
1884 : 0 : const SwFmt* pTmpFmt = 0;
1885 [ # # # # : 0 : switch( nFamily )
# # ]
1886 : : {
1887 : : case SFX_STYLE_FAMILY_CHAR :
1888 [ # # # # ]: 0 : if( !pCharFmt &&
[ # # ]
1889 : 0 : 0 == (pCharFmt = lcl_FindCharFmt( rDoc, aName, 0, sal_False )) )
1890 : : {
1891 : 0 : nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
1892 [ # # ]: 0 : return USHRT_MAX == nId ? 0 : nId;
1893 : : }
1894 : 0 : pTmpFmt = pCharFmt;
1895 : 0 : break;
1896 : :
1897 : : case SFX_STYLE_FAMILY_PARA:
1898 [ # # # # ]: 0 : if( !pColl &&
[ # # ]
1899 : 0 : 0 == ( pColl = lcl_FindParaFmt( rDoc, aName, 0, sal_False )) )
1900 : : {
1901 : 0 : nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
1902 [ # # ]: 0 : return USHRT_MAX == nId ? 0 : nId;
1903 : : }
1904 : 0 : pTmpFmt = pColl;
1905 : 0 : break;
1906 : :
1907 : : case SFX_STYLE_FAMILY_FRAME:
1908 [ # # # # ]: 0 : if( !pFrmFmt &&
[ # # ]
1909 : 0 : 0 == ( pFrmFmt = lcl_FindFrmFmt( rDoc, aName, 0, sal_False ) ) )
1910 : : {
1911 : 0 : nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT );
1912 [ # # ]: 0 : return USHRT_MAX == nId ? 0 : nId;
1913 : : }
1914 : 0 : pTmpFmt = pFrmFmt;
1915 : 0 : break;
1916 : :
1917 : : case SFX_STYLE_FAMILY_PAGE:
1918 [ # # # # ]: 0 : if( !pDesc &&
[ # # ]
1919 : 0 : 0 == ( pDesc = lcl_FindPageDesc( rDoc, aName, 0, sal_False ) ) )
1920 : : {
1921 : 0 : nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
1922 [ # # ]: 0 : return USHRT_MAX == nId ? 0 : nId;
1923 : : }
1924 : :
1925 : 0 : nId = pDesc->GetPoolHelpId();
1926 : 0 : nFileId = pDesc->GetPoolHlpFileId();
1927 : 0 : nPoolId = pDesc->GetPoolFmtId();
1928 : 0 : break;
1929 : :
1930 : : case SFX_STYLE_FAMILY_PSEUDO:
1931 [ # # # # ]: 0 : if( !pNumRule &&
[ # # ]
1932 : 0 : 0 == ( pNumRule = lcl_FindNumRule( rDoc, aName, 0, sal_False ) ) )
1933 : : {
1934 : 0 : nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
1935 [ # # ]: 0 : return USHRT_MAX == nId ? 0 : nId;
1936 : : }
1937 : :
1938 : 0 : nId = pNumRule->GetPoolHelpId();
1939 : 0 : nFileId = pNumRule->GetPoolHlpFileId();
1940 : 0 : nPoolId = pNumRule->GetPoolFmtId();
1941 : 0 : break;
1942 : :
1943 : : default:
1944 : : OSL_ENSURE(!this, "unknown style family");
1945 : 0 : return 0;
1946 : : }
1947 : :
1948 [ # # ]: 0 : if( pTmpFmt )
1949 : : {
1950 : 0 : nId = pTmpFmt->GetPoolHelpId();
1951 : 0 : nFileId = pTmpFmt->GetPoolHlpFileId();
1952 : 0 : nPoolId = pTmpFmt->GetPoolFmtId();
1953 : : }
1954 : :
1955 [ # # ]: 0 : if( UCHAR_MAX != nFileId )
1956 : : {
1957 : 0 : const String *pTemplate = rDoc.GetDocPattern( nFileId );
1958 [ # # ]: 0 : if( pTemplate )
1959 : : {
1960 : 0 : rFile = *pTemplate;
1961 : : }
1962 : : }
1963 [ # # ]: 0 : else if( !IsPoolUserFmt( nPoolId ) )
1964 : : {
1965 : 0 : nId = nPoolId;
1966 : : }
1967 : :
1968 : : // because SFX acts like that, with HelpId:
1969 [ # # ]: 0 : if( USHRT_MAX == nId )
1970 : 0 : nId = 0; // don't show Help accordingly
1971 : :
1972 : 0 : return nId;
1973 : : }
1974 : :
1975 : :
1976 : 0 : void SwDocStyleSheet::SetHelpId( const String& r, sal_uLong nId )
1977 : : {
1978 : 0 : sal_uInt8 nFileId = static_cast< sal_uInt8 >(rDoc.SetDocPattern( r ));
1979 : 0 : sal_uInt16 nHId = static_cast< sal_uInt16 >(nId); //!! SFX changed over to ULONG arbitrarily!
1980 : :
1981 : 0 : SwFmt* pTmpFmt = 0;
1982 [ # # # # : 0 : switch( nFamily )
# # ]
1983 : : {
1984 : 0 : case SFX_STYLE_FAMILY_CHAR : pTmpFmt = pCharFmt; break;
1985 : 0 : case SFX_STYLE_FAMILY_PARA : pTmpFmt = pColl; break;
1986 : 0 : case SFX_STYLE_FAMILY_FRAME: pTmpFmt = pFrmFmt; break;
1987 : : case SFX_STYLE_FAMILY_PAGE :
1988 : 0 : ((SwPageDesc*)pDesc)->SetPoolHelpId( nHId );
1989 : 0 : ((SwPageDesc*)pDesc)->SetPoolHlpFileId( nFileId );
1990 : 0 : break;
1991 : :
1992 : : case SFX_STYLE_FAMILY_PSEUDO:
1993 : 0 : ((SwNumRule*)pNumRule)->SetPoolHelpId( nHId );
1994 : 0 : ((SwNumRule*)pNumRule)->SetPoolHlpFileId( nFileId );
1995 : 0 : break;
1996 : :
1997 : : default:
1998 : : OSL_ENSURE(!this, "unknown style family");
1999 : 0 : return ;
2000 : : }
2001 [ # # ]: 0 : if( pTmpFmt )
2002 : : {
2003 : 0 : pTmpFmt->SetPoolHelpId( nHId );
2004 : 0 : pTmpFmt->SetPoolHlpFileId( nFileId );
2005 : : }
2006 : : }
2007 : :
2008 : : /*--------------------------------------------------------------------
2009 : : Description: methods for DocStyleSheetPool
2010 : : --------------------------------------------------------------------*/
2011 : :
2012 : 1547 : SwDocStyleSheetPool::SwDocStyleSheetPool( SwDoc& rDocument, sal_Bool bOrg )
2013 : 1547 : : SfxStyleSheetBasePool( rDocument.GetAttrPool() )
2014 [ + - ]: 1547 : , mxStyleSheet( new SwDocStyleSheet( rDocument, aEmptyStr, this, SFX_STYLE_FAMILY_CHAR, 0 ) )
2015 : 3094 : , rDoc( rDocument )
2016 : : {
2017 : 1547 : bOrganizer = bOrg;
2018 : 1547 : }
2019 : :
2020 : 1432 : SwDocStyleSheetPool::~SwDocStyleSheetPool()
2021 : : {
2022 [ - + ]: 2864 : }
2023 : :
2024 : 1547 : void SAL_CALL SwDocStyleSheetPool::acquire( ) throw ()
2025 : : {
2026 : 1547 : comphelper::OWeakTypeObject::acquire();
2027 : 1547 : }
2028 : :
2029 : 1432 : void SAL_CALL SwDocStyleSheetPool::release( ) throw ()
2030 : : {
2031 : 1432 : comphelper::OWeakTypeObject::release();
2032 : 1432 : }
2033 : :
2034 : 709 : SfxStyleSheetBase& SwDocStyleSheetPool::Make(
2035 : : const String& rName,
2036 : : SfxStyleFamily eFam,
2037 : : sal_uInt16 _nMask,
2038 : : sal_uInt16 /*nPos*/ )
2039 : : {
2040 : 709 : mxStyleSheet->PresetName(rName);
2041 : 709 : mxStyleSheet->PresetParent(aEmptyStr);
2042 : 709 : mxStyleSheet->PresetFollow(aEmptyStr);
2043 : 709 : mxStyleSheet->SetMask(_nMask) ;
2044 : 709 : mxStyleSheet->SetFamily(eFam);
2045 : 709 : mxStyleSheet->SetPhysical(sal_True);
2046 : 709 : mxStyleSheet->Create();
2047 : :
2048 : 709 : return *mxStyleSheet.get();
2049 : : }
2050 : :
2051 : :
2052 : 0 : SfxStyleSheetBase* SwDocStyleSheetPool::Create( const SfxStyleSheetBase& /*rOrg*/)
2053 : : {
2054 : : OSL_ENSURE(!this , "Create im SW-Stylesheet-Pool geht nicht" );
2055 : 0 : return NULL;
2056 : : }
2057 : :
2058 : :
2059 : 0 : SfxStyleSheetBase* SwDocStyleSheetPool::Create( const String &,
2060 : : SfxStyleFamily, sal_uInt16 )
2061 : : {
2062 : : OSL_ENSURE( !this, "Create im SW-Stylesheet-Pool geht nicht" );
2063 : 0 : return NULL;
2064 : : }
2065 : :
2066 : 0 : void SwDocStyleSheetPool::Replace( SfxStyleSheetBase& rSource,
2067 : : SfxStyleSheetBase& rTarget )
2068 : : {
2069 : 0 : SfxStyleFamily eFamily( rSource.GetFamily() );
2070 [ # # ][ # # ]: 0 : if( rSource.HasParentSupport())
2071 : : {
2072 [ # # ]: 0 : const String& rParentName = rSource.GetParent();
2073 [ # # ]: 0 : if( 0 != rParentName.Len() )
2074 : : {
2075 [ # # ]: 0 : SfxStyleSheetBase* pParentOfNew = Find( rParentName, eFamily );
2076 [ # # ]: 0 : if( pParentOfNew )
2077 [ # # ]: 0 : rTarget.SetParent( rParentName );
2078 : : }
2079 : : }
2080 [ # # ][ # # ]: 0 : if( rSource.HasFollowSupport())
2081 : : {
2082 [ # # ]: 0 : const String& rFollowName = rSource.GetFollow();
2083 [ # # ]: 0 : if( 0 != rFollowName.Len() )
2084 : : {
2085 [ # # ]: 0 : SfxStyleSheetBase* pFollowOfNew = Find( rFollowName, eFamily );
2086 [ # # ]: 0 : if( pFollowOfNew )
2087 [ # # ]: 0 : rTarget.SetFollow( rFollowName );
2088 : : }
2089 : : }
2090 : :
2091 [ # # ]: 0 : SwImplShellAction aTmpSh( rDoc );
2092 : :
2093 [ # # ]: 0 : sal_Bool bSwSrcPool = GetAppName() == rSource.GetPool().GetAppName();
2094 [ # # ][ # # ]: 0 : if( SFX_STYLE_FAMILY_PAGE == eFamily && bSwSrcPool )
2095 : : {
2096 : : // deal with separately!
2097 : : SwPageDesc* pDestDsc =
2098 [ # # ]: 0 : (SwPageDesc*)((SwDocStyleSheet&)rTarget).GetPageDesc();
2099 : : SwPageDesc* pCpyDsc =
2100 [ # # ]: 0 : (SwPageDesc*)((SwDocStyleSheet&)rSource).GetPageDesc();
2101 [ # # ]: 0 : rDoc.CopyPageDesc( *pCpyDsc, *pDestDsc );
2102 : : }
2103 : : else
2104 : : {
2105 : 0 : const SwFmt *pSourceFmt = 0;
2106 : 0 : SwFmt *pTargetFmt = 0;
2107 : 0 : sal_uInt16 nPgDscPos = USHRT_MAX;
2108 [ # # # # : 0 : switch( eFamily )
# # ]
2109 : : {
2110 : : case SFX_STYLE_FAMILY_CHAR :
2111 [ # # ]: 0 : if( bSwSrcPool )
2112 [ # # ]: 0 : pSourceFmt = ((SwDocStyleSheet&)rSource).GetCharFmt();
2113 [ # # ]: 0 : pTargetFmt = ((SwDocStyleSheet&)rTarget).GetCharFmt();
2114 : 0 : break;
2115 : : case SFX_STYLE_FAMILY_PARA :
2116 [ # # ]: 0 : if( bSwSrcPool )
2117 [ # # ]: 0 : pSourceFmt = ((SwDocStyleSheet&)rSource).GetCollection();
2118 [ # # ]: 0 : pTargetFmt = ((SwDocStyleSheet&)rTarget).GetCollection();
2119 : 0 : break;
2120 : : case SFX_STYLE_FAMILY_FRAME:
2121 [ # # ]: 0 : if( bSwSrcPool )
2122 [ # # ]: 0 : pSourceFmt = ((SwDocStyleSheet&)rSource).GetFrmFmt();
2123 [ # # ]: 0 : pTargetFmt = ((SwDocStyleSheet&)rTarget).GetFrmFmt();
2124 : 0 : break;
2125 : : case SFX_STYLE_FAMILY_PAGE:
2126 [ # # ]: 0 : if( bSwSrcPool )
2127 : : pSourceFmt = &((SwDocStyleSheet&)rSource).GetPageDesc()
2128 [ # # ]: 0 : ->GetMaster();
2129 : : {
2130 : : SwPageDesc *pDesc = rDoc.FindPageDescByName(
2131 [ # # ]: 0 : ((SwDocStyleSheet&)rTarget).GetPageDesc()->GetName(),
2132 [ # # ]: 0 : &nPgDscPos );
2133 : :
2134 [ # # ]: 0 : if( pDesc )
2135 : 0 : pTargetFmt = &pDesc->GetMaster();
2136 : : }
2137 : 0 : break;
2138 : : case SFX_STYLE_FAMILY_PSEUDO:
2139 : : // A NumRule only consists of one Item, so nothing has
2140 : : // to be deleted here.
2141 : 0 : break;
2142 : : default:; //prevent warning
2143 : : }
2144 [ # # ]: 0 : if( pTargetFmt )
2145 : : {
2146 [ # # ]: 0 : if( pSourceFmt )
2147 [ # # ]: 0 : pTargetFmt->DelDiffs( *pSourceFmt );
2148 [ # # ]: 0 : else if( USHRT_MAX != nPgDscPos )
2149 [ # # ]: 0 : pTargetFmt->ResetFmtAttr( RES_PAGEDESC, RES_FRMATR_END-1 );
2150 : : else
2151 : : {
2152 : : // #i73790# - method renamed
2153 [ # # ]: 0 : pTargetFmt->ResetAllFmtAttr();
2154 : : }
2155 : :
2156 [ # # ]: 0 : if( USHRT_MAX != nPgDscPos )
2157 : : rDoc.ChgPageDesc( nPgDscPos,
2158 [ # # ][ # # ]: 0 : rDoc.GetPageDesc(nPgDscPos) );
2159 : : }
2160 [ # # ][ # # ]: 0 : ((SwDocStyleSheet&)rTarget).SetItemSet( rSource.GetItemSet() );
2161 [ # # ]: 0 : }
2162 : 0 : }
2163 : :
2164 : 2686 : SfxStyleSheetIterator* SwDocStyleSheetPool::CreateIterator(
2165 : : SfxStyleFamily eFam, sal_uInt16 _nMask )
2166 : : {
2167 [ + - ]: 2686 : return new SwStyleSheetIterator( this, eFam, _nMask );
2168 : : }
2169 : :
2170 : 1432 : void SwDocStyleSheetPool::dispose()
2171 : : {
2172 : 1432 : mxStyleSheet.clear();
2173 : 1432 : }
2174 : :
2175 : 2 : void SwDocStyleSheetPool::Remove( SfxStyleSheetBase* pStyle)
2176 : : {
2177 [ + - ]: 2 : if( !pStyle )
2178 : 2 : return;
2179 : :
2180 : 2 : sal_Bool bBroadcast = sal_True;
2181 [ + - ]: 2 : SwImplShellAction aTmpSh( rDoc );
2182 [ + - ]: 2 : const String& rName = pStyle->GetName();
2183 [ + - - - : 2 : switch( pStyle->GetFamily() )
- - ]
2184 : : {
2185 : : case SFX_STYLE_FAMILY_CHAR:
2186 : : {
2187 [ + - ]: 2 : SwCharFmt* pFmt = lcl_FindCharFmt(rDoc, rName, 0, sal_False );
2188 [ + - ]: 2 : if(pFmt)
2189 [ + - ]: 2 : rDoc.DelCharFmt(pFmt);
2190 : : }
2191 : 2 : break;
2192 : : case SFX_STYLE_FAMILY_PARA:
2193 : : {
2194 [ # # ]: 0 : SwTxtFmtColl* pColl = lcl_FindParaFmt(rDoc, rName, 0, sal_False );
2195 [ # # ]: 0 : if(pColl)
2196 [ # # ]: 0 : rDoc.DelTxtFmtColl(pColl);
2197 : : }
2198 : 0 : break;
2199 : : case SFX_STYLE_FAMILY_FRAME:
2200 : : {
2201 [ # # ]: 0 : SwFrmFmt* pFmt = lcl_FindFrmFmt(rDoc, rName, 0, sal_False );
2202 [ # # ]: 0 : if(pFmt)
2203 [ # # ]: 0 : rDoc.DelFrmFmt(pFmt);
2204 : : }
2205 : 0 : break;
2206 : : case SFX_STYLE_FAMILY_PAGE :
2207 : : {
2208 : : sal_uInt16 nPos;
2209 [ # # ][ # # ]: 0 : if( rDoc.FindPageDescByName( rName, &nPos ))
2210 [ # # ]: 0 : rDoc.DelPageDesc( nPos );
2211 : : }
2212 : 0 : break;
2213 : :
2214 : : case SFX_STYLE_FAMILY_PSEUDO:
2215 : : {
2216 [ # # ][ # # ]: 0 : if( !rDoc.DelNumRule( rName ) )
2217 : : // Only send Broadcast, when something was deleted
2218 : 0 : bBroadcast = sal_False;
2219 : : }
2220 : 0 : break;
2221 : :
2222 : : default:
2223 : : OSL_ENSURE(!this, "unknown style family");
2224 : 0 : bBroadcast = sal_False;
2225 : : }
2226 : :
2227 [ + - ]: 2 : if( bBroadcast )
2228 [ + - ][ + - ]: 2 : Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *pStyle ) );
[ + - ][ + - ]
2229 : : }
2230 : :
2231 : :
2232 : :
2233 : 183 : sal_Bool SwDocStyleSheetPool::SetParent( SfxStyleFamily eFam,
2234 : : const String &rStyle, const String &rParent )
2235 : : {
2236 : 183 : SwFmt* pFmt = 0, *pParent = 0;
2237 [ + + - - : 183 : switch( eFam )
- ]
2238 : : {
2239 : : case SFX_STYLE_FAMILY_CHAR :
2240 [ + - ][ + - ]: 117 : if( 0 != ( pFmt = lcl_FindCharFmt( rDoc, rStyle ) ) && rParent.Len() )
[ + - ]
2241 : 117 : pParent = lcl_FindCharFmt(rDoc, rParent );
2242 : 117 : break;
2243 : :
2244 : : case SFX_STYLE_FAMILY_PARA :
2245 [ + - ][ + - ]: 66 : if( 0 != ( pFmt = lcl_FindParaFmt( rDoc, rStyle ) ) && rParent.Len() )
[ + - ]
2246 : 66 : pParent = lcl_FindParaFmt( rDoc, rParent );
2247 : 66 : break;
2248 : :
2249 : : case SFX_STYLE_FAMILY_FRAME:
2250 [ # # ][ # # ]: 0 : if( 0 != ( pFmt = lcl_FindFrmFmt( rDoc, rStyle ) ) && rParent.Len() )
[ # # ]
2251 : 0 : pParent = lcl_FindFrmFmt( rDoc, rParent );
2252 : 0 : break;
2253 : :
2254 : : case SFX_STYLE_FAMILY_PAGE:
2255 : : case SFX_STYLE_FAMILY_PSEUDO:
2256 : 0 : break;
2257 : :
2258 : : default:
2259 : : OSL_ENSURE(!this, "unknown style family");
2260 : : }
2261 : :
2262 : 183 : sal_Bool bRet = sal_False;
2263 [ + - ]: 366 : if( pFmt && pFmt->DerivedFrom() &&
[ + - + - ]
[ + - ]
2264 : 183 : pFmt->DerivedFrom()->GetName() != rParent )
2265 : : {
2266 : : {
2267 [ + - ]: 183 : SwImplShellAction aTmpSh( rDoc );
2268 [ + - ][ + - ]: 183 : bRet = pFmt->SetDerivedFrom( pParent );
2269 : : }
2270 : :
2271 [ + - ]: 183 : if( bRet )
2272 : : {
2273 : : // only for Broadcasting
2274 : 183 : mxStyleSheet->PresetName( rStyle );
2275 : 183 : mxStyleSheet->PresetParent( rParent );
2276 [ + + ]: 183 : if( SFX_STYLE_FAMILY_PARA == eFam )
2277 : : mxStyleSheet->PresetFollow( ((SwTxtFmtColl*)pFmt)->
2278 : 66 : GetNextTxtFmtColl().GetName() );
2279 : : else
2280 : 117 : mxStyleSheet->PresetFollow( aEmptyStr );
2281 : :
2282 : : Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED,
2283 [ + - ]: 183 : *(mxStyleSheet.get()) ) );
2284 : : }
2285 : : }
2286 : :
2287 : 183 : return bRet;
2288 : : }
2289 : :
2290 : 61281 : SfxStyleSheetBase* SwDocStyleSheetPool::Find( const String& rName,
2291 : : SfxStyleFamily eFam, sal_uInt16 n )
2292 : : {
2293 : 61281 : sal_uInt16 nSMask = n;
2294 [ + + ][ - + ]: 61281 : if( SFX_STYLE_FAMILY_PARA == eFam && rDoc.get(IDocumentSettingAccess::HTML_MODE) )
[ - + ]
2295 : : {
2296 : : // then only HTML-Templates are of interest
2297 [ # # ]: 0 : if( USHRT_MAX == nSMask )
2298 : 0 : nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED;
2299 : : else
2300 : : nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF |
2301 : 0 : SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML;
2302 [ # # ]: 0 : if( !nSMask )
2303 : 0 : nSMask = SWSTYLEBIT_HTML;
2304 : : }
2305 : :
2306 : : const sal_Bool bSearchUsed = ( n != SFXSTYLEBIT_ALL &&
2307 [ + + ][ + + ]: 61281 : n & SFXSTYLEBIT_USED ) ? sal_True : sal_False;
2308 : 61281 : const SwModify* pMod = 0;
2309 : :
2310 : 61281 : mxStyleSheet->SetPhysical( sal_False );
2311 : 61281 : mxStyleSheet->PresetName( rName );
2312 : 61281 : mxStyleSheet->SetFamily( eFam );
2313 : 61281 : sal_Bool bFnd = mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2314 : :
2315 [ + + ]: 61281 : if( mxStyleSheet->IsPhysical() )
2316 : : {
2317 [ + + + + : 35157 : switch( eFam )
+ - ]
2318 : : {
2319 : : case SFX_STYLE_FAMILY_CHAR:
2320 : 3049 : pMod = mxStyleSheet->GetCharFmt();
2321 : 3049 : break;
2322 : :
2323 : : case SFX_STYLE_FAMILY_PARA:
2324 : 25894 : pMod = mxStyleSheet->GetCollection();
2325 : 25894 : break;
2326 : :
2327 : : case SFX_STYLE_FAMILY_FRAME:
2328 : 190 : pMod = mxStyleSheet->GetFrmFmt();
2329 : 190 : break;
2330 : :
2331 : : case SFX_STYLE_FAMILY_PAGE:
2332 : 5636 : pMod = mxStyleSheet->GetPageDesc();
2333 : 5636 : break;
2334 : :
2335 : : case SFX_STYLE_FAMILY_PSEUDO:
2336 : : {
2337 : 388 : const SwNumRule* pRule = mxStyleSheet->GetNumRule();
2338 [ - + ]: 776 : if( pRule &&
[ - + # # ]
[ - + ][ + - ]
2339 [ # # ][ # # ]: 0 : !(bSearchUsed && (bOrganizer || rDoc.IsUsed(*pRule)) ) &&
2340 : : (( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2341 : 0 : ? !(pRule->GetPoolFmtId() & USER_FMT)
2342 : : // searched for used and found none
2343 [ - + ]: 388 : : bSearchUsed ))
2344 : 0 : bFnd = sal_False;
2345 : : }
2346 : 35157 : break;
2347 : :
2348 : : default:
2349 : : OSL_ENSURE(!this, "unknown style family");
2350 : : }
2351 : : }
2352 : :
2353 : : // then evaluate the mask:
2354 [ + + ][ + + ]: 61281 : if( pMod && !(bSearchUsed && (bOrganizer || rDoc.IsUsed(*pMod)) ) )
[ + - ][ - + ]
[ + + ]
2355 : : {
2356 : : const sal_uInt16 nId = SFX_STYLE_FAMILY_PAGE == eFam
2357 : : ? ((SwPageDesc*)pMod)->GetPoolFmtId()
2358 [ + + ]: 34763 : : ((SwFmt*)pMod)->GetPoolFmtId();
2359 : :
2360 [ - + ]: 34763 : if( ( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2361 : : ? !(nId & USER_FMT)
2362 : : // searched for used and found none
2363 [ - + ]: 34763 : : bSearchUsed )
2364 : 0 : bFnd = sal_False;
2365 : : }
2366 [ + + ]: 61281 : return bFnd ? mxStyleSheet.get() : 0;
2367 : : }
2368 : :
2369 : 2686 : SwStyleSheetIterator::SwStyleSheetIterator( SwDocStyleSheetPool* pBase,
2370 : : SfxStyleFamily eFam, sal_uInt16 n )
2371 : : : SfxStyleSheetIterator( pBase, eFam, n ),
2372 [ + - ]: 2686 : mxIterSheet( new SwDocStyleSheet( pBase->GetDoc(), aEmptyStr, pBase, SFX_STYLE_FAMILY_CHAR, 0 ) ),
2373 [ + - ][ + - ]: 5372 : mxStyleSheet( new SwDocStyleSheet( pBase->GetDoc(), aEmptyStr, pBase, SFX_STYLE_FAMILY_CHAR, 0 ) )
[ + - ]
2374 : : {
2375 : 2686 : bFirstCalled = sal_False;
2376 : 2686 : nLastPos = 0;
2377 [ + - ]: 2686 : StartListening( *pBase );
2378 : 2686 : }
2379 : :
2380 [ + - ]: 2686 : SwStyleSheetIterator::~SwStyleSheetIterator()
2381 : : {
2382 [ + - ]: 2686 : EndListening( mxIterSheet->GetPool() );
2383 [ - + ]: 5372 : }
2384 : :
2385 : 10133 : sal_uInt16 SwStyleSheetIterator::Count()
2386 : : {
2387 : : // let the list fill correctly!!
2388 [ + + ]: 10133 : if( !bFirstCalled )
2389 : 982 : First();
2390 : 10133 : return aLst.size();
2391 : : }
2392 : :
2393 : 5392 : SfxStyleSheetBase* SwStyleSheetIterator::operator[]( sal_uInt16 nIdx )
2394 : : {
2395 : : // found
2396 [ - + ]: 5392 : if( !bFirstCalled )
2397 : 0 : First();
2398 : 5392 : mxStyleSheet->PresetNameAndFamily( aLst[ nIdx ] );
2399 : 5392 : mxStyleSheet->SetPhysical( sal_False );
2400 : 5392 : mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2401 : :
2402 : 5392 : return mxStyleSheet.get();
2403 : : }
2404 : :
2405 : 21526 : SfxStyleSheetBase* SwStyleSheetIterator::First()
2406 : : {
2407 : : // Delete old list
2408 : 21526 : bFirstCalled = sal_True;
2409 : 21526 : nLastPos = 0;
2410 : 21526 : aLst.Erase();
2411 : :
2412 : : // Delete current
2413 : 21526 : mxIterSheet->Reset();
2414 : :
2415 : 21526 : SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc();
2416 : 21526 : const sal_uInt16 nSrchMask = nMask;
2417 : 21526 : const sal_Bool bIsSearchUsed = SearchUsed();
2418 : :
2419 : 21526 : const sal_Bool bOrganizer = ((SwDocStyleSheetPool*)pBasePool)->IsOrganizerMode();
2420 : :
2421 [ - + ][ + + ]: 21526 : if( nSearchFamily == SFX_STYLE_FAMILY_CHAR
2422 : : || nSearchFamily == SFX_STYLE_FAMILY_ALL )
2423 : : {
2424 : 68 : const sal_uInt16 nArrLen = rDoc.GetCharFmts()->size();
2425 [ + + ]: 389 : for( sal_uInt16 i = 0; i < nArrLen; i++ )
2426 : : {
2427 : 321 : SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ];
2428 [ - + ][ - + ]: 321 : if( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() )
[ + + ]
2429 : 0 : continue;
2430 : :
2431 [ - + ][ # # ]: 321 : const sal_Bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(*pFmt));
[ # # ]
2432 [ + - ]: 321 : if( !bUsed )
2433 : : {
2434 : : // Standard is no User template
2435 : 321 : const sal_uInt16 nId = rDoc.GetDfltCharFmt() == pFmt ?
2436 : : sal_uInt16( RES_POOLCHR_INET_NORMAL ):
2437 [ + + ]: 321 : pFmt->GetPoolFmtId();
2438 [ - + ]: 321 : if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2439 : : ? !(nId & USER_FMT)
2440 : : // searched for used and found none
2441 [ - + ]: 321 : : bIsSearchUsed )
2442 : 0 : continue;
2443 : :
2444 [ - + ][ # # ]: 321 : if( rDoc.get(IDocumentSettingAccess::HTML_MODE) && !(nId & USER_FMT) &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ - + ]
2445 : : !( RES_POOLCHR_HTML_BEGIN <= nId &&
2446 [ # # ]: 0 : nId < RES_POOLCHR_HTML_END ) &&
2447 : : RES_POOLCHR_INET_NORMAL != nId &&
2448 : : RES_POOLCHR_INET_VISIT != nId &&
2449 : : RES_POOLCHR_FOOTNOTE != nId &&
2450 : : RES_POOLCHR_ENDNOTE != nId )
2451 : 0 : continue;
2452 : : }
2453 : :
2454 : 321 : aLst.Append( cCHAR, pFmt == rDoc.GetDfltCharFmt()
2455 : 68 : ? SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
2456 : 68 : RES_POOLCOLL_TEXT_BEGIN ]
2457 [ + + ]: 389 : : pFmt->GetName() );
2458 : : }
2459 : :
2460 : : // PoolFormate
2461 : : //
2462 [ + - ]: 68 : if( nSrchMask == SFXSTYLEBIT_ALL )
2463 : : {
2464 [ + - ]: 68 : if( !rDoc.get(IDocumentSettingAccess::HTML_MODE) )
2465 : 68 : AppendStyleList(SwStyleNameMapper::GetChrFmtUINameArray(),
2466 : 68 : bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR);
2467 : : else
2468 : : {
2469 : 0 : aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[
2470 : 0 : RES_POOLCHR_INET_NORMAL - RES_POOLCHR_BEGIN ] );
2471 : 0 : aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[
2472 : 0 : RES_POOLCHR_INET_VISIT - RES_POOLCHR_BEGIN ] );
2473 : 0 : aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[
2474 : 0 : RES_POOLCHR_ENDNOTE - RES_POOLCHR_BEGIN ] );
2475 : 0 : aLst.Append( cCHAR, SwStyleNameMapper::GetChrFmtUINameArray()[
2476 : 0 : RES_POOLCHR_FOOTNOTE - RES_POOLCHR_BEGIN ] );
2477 : : }
2478 : 68 : AppendStyleList(SwStyleNameMapper::GetHTMLChrFmtUINameArray(),
2479 : 68 : bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR);
2480 : : }
2481 : : }
2482 : :
2483 [ + + ][ - + ]: 21526 : if( nSearchFamily == SFX_STYLE_FAMILY_PARA ||
2484 : : nSearchFamily == SFX_STYLE_FAMILY_ALL )
2485 : : {
2486 : 19794 : sal_uInt16 nSMask = nSrchMask;
2487 [ + + ]: 19794 : if( rDoc.get(IDocumentSettingAccess::HTML_MODE) )
2488 : : {
2489 : : // then only HTML-Template are of interest
2490 [ + + ]: 96 : if( USHRT_MAX == nSMask )
2491 : : nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF |
2492 : 4 : SFXSTYLEBIT_USED;
2493 : : else
2494 : : nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF |
2495 : 92 : SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML;
2496 [ + + ]: 96 : if( !nSMask )
2497 : 92 : nSMask = SWSTYLEBIT_HTML;
2498 : : }
2499 : :
2500 : 19794 : const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->size();
2501 [ + + ]: 159742 : for( sal_uInt16 i = 0; i < nArrLen; i++ )
2502 : : {
2503 : 139948 : SwTxtFmtColl* pColl = (*rDoc.GetTxtFmtColls())[ i ];
2504 : :
2505 [ + + ]: 139948 : if(pColl->IsDefault())
2506 : 19794 : continue;
2507 : :
2508 [ + - ][ + + ]: 120154 : const sal_Bool bUsed = bOrganizer || rDoc.IsUsed(*pColl);
2509 [ + + ][ + + ]: 120154 : if( !(bIsSearchUsed && bUsed ))
2510 : : {
2511 : 100290 : const sal_uInt16 nId = pColl->GetPoolFmtId();
2512 [ - + - - : 100290 : switch ( (nSMask & ~SFXSTYLEBIT_USED) )
- - + + -
+ ]
2513 : : {
2514 : : case SFXSTYLEBIT_USERDEF:
2515 [ # # ]: 0 : if(!IsPoolUserFmt(nId)) continue;
2516 : 0 : break;
2517 : : case SWSTYLEBIT_TEXT:
2518 [ + + ]: 3540 : if((nId & COLL_GET_RANGE_BITS) != COLL_TEXT_BITS) continue;
2519 : 1770 : break;
2520 : : case SWSTYLEBIT_CHAPTER:
2521 [ # # ]: 0 : if((nId & COLL_GET_RANGE_BITS) != COLL_DOC_BITS) continue;
2522 : 0 : break;
2523 : : case SWSTYLEBIT_LIST:
2524 [ # # ]: 0 : if((nId & COLL_GET_RANGE_BITS) != COLL_LISTS_BITS) continue;
2525 : 0 : break;
2526 : : case SWSTYLEBIT_IDX:
2527 [ # # ]: 0 : if((nId & COLL_GET_RANGE_BITS) != COLL_REGISTER_BITS) continue;
2528 : 0 : break;
2529 : : case SWSTYLEBIT_EXTRA:
2530 [ # # ]: 0 : if((nId & COLL_GET_RANGE_BITS) != COLL_EXTRA_BITS) continue;
2531 : 0 : break;
2532 : : case SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF:
2533 [ - + ]: 24 : if(IsPoolUserFmt(nId))
2534 : 0 : break;
2535 : : // otherwise move on
2536 : : case SWSTYLEBIT_HTML:
2537 [ + - ]: 392 : if( (nId & COLL_GET_RANGE_BITS) != COLL_HTML_BITS)
2538 : : {
2539 : : // but some we also want to see in this section
2540 : 392 : sal_Bool bWeiter = sal_True;
2541 [ + + ]: 392 : switch( nId )
2542 : : {
2543 : : case RES_POOLCOLL_SENDADRESS: // --> ADDRESS
2544 : : case RES_POOLCOLL_TABLE_HDLN: // --> TH
2545 : : case RES_POOLCOLL_TABLE: // --> TD
2546 : : case RES_POOLCOLL_TEXT: // --> P
2547 : : case RES_POOLCOLL_HEADLINE_BASE:// --> H
2548 : : case RES_POOLCOLL_HEADLINE1: // --> H1
2549 : : case RES_POOLCOLL_HEADLINE2: // --> H2
2550 : : case RES_POOLCOLL_HEADLINE3: // --> H3
2551 : : case RES_POOLCOLL_HEADLINE4: // --> H4
2552 : : case RES_POOLCOLL_HEADLINE5: // --> H5
2553 : : case RES_POOLCOLL_HEADLINE6: // --> H6
2554 : : case RES_POOLCOLL_STANDARD: // --> P
2555 : : case RES_POOLCOLL_FOOTNOTE:
2556 : : case RES_POOLCOLL_ENDNOTE:
2557 : 104 : bWeiter = sal_False;
2558 : 104 : break;
2559 : : }
2560 [ + + ]: 392 : if( bWeiter )
2561 : 288 : continue;
2562 : : }
2563 : 104 : break;
2564 : : case SWSTYLEBIT_CONDCOLL:
2565 [ # # ]: 0 : if( RES_CONDTXTFMTCOLL != pColl->Which() ) continue;
2566 : 0 : break;
2567 : : default:
2568 : : // searched for used and found none
2569 [ + + ]: 96358 : if( bIsSearchUsed )
2570 : 91494 : continue;
2571 : : }
2572 : : }
2573 : 26602 : aLst.Append( cPARA, pColl->GetName() );
2574 : : }
2575 : :
2576 : 19794 : const sal_Bool bAll = nSMask == SFXSTYLEBIT_ALL;
2577 [ + + ][ + + ]: 19794 : if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_TEXT )
2578 : 1392 : AppendStyleList(SwStyleNameMapper::GetTextUINameArray(),
2579 : 1392 : bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA );
2580 [ + + ][ - + ]: 19794 : if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CHAPTER )
2581 : 802 : AppendStyleList(SwStyleNameMapper::GetDocUINameArray(),
2582 : 802 : bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2583 [ + + ][ - + ]: 19794 : if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_LIST )
2584 : 802 : AppendStyleList(SwStyleNameMapper::GetListsUINameArray(),
2585 : 802 : bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2586 [ + + ][ - + ]: 19794 : if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_IDX )
2587 : 802 : AppendStyleList(SwStyleNameMapper::GetRegisterUINameArray(),
2588 : 802 : bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2589 [ + + ][ - + ]: 19794 : if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_EXTRA )
2590 : 802 : AppendStyleList(SwStyleNameMapper::GetExtraUINameArray(),
2591 : 802 : bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2592 [ + + ][ - + ]: 19794 : if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CONDCOLL )
2593 : : {
2594 [ - + # # ]: 802 : if( !bIsSearchUsed ||
[ + - ]
2595 : 0 : rDoc.IsPoolTxtCollUsed( RES_POOLCOLL_TEXT ))
2596 : 802 : aLst.Append( cPARA, SwStyleNameMapper::GetTextUINameArray()[
2597 : 802 : RES_POOLCOLL_TEXT - RES_POOLCOLL_TEXT_BEGIN ] );
2598 : : }
2599 [ + + ][ + + ]: 19794 : if ( bAll ||
[ + + ]
2600 : : (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_HTML ||
2601 : : (nSMask & ~SFXSTYLEBIT_USED) ==
2602 : : (SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF) )
2603 : : {
2604 : 898 : AppendStyleList(SwStyleNameMapper::GetHTMLUINameArray(),
2605 : 898 : bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2606 [ + + ]: 898 : if( !bAll )
2607 : : {
2608 : : // then also the ones, that we are mapping:
2609 : : static sal_uInt16 aPoolIds[] = {
2610 : : RES_POOLCOLL_SENDADRESS, // --> ADDRESS
2611 : : RES_POOLCOLL_TABLE_HDLN, // --> TH
2612 : : RES_POOLCOLL_TABLE, // --> TD
2613 : : RES_POOLCOLL_STANDARD, // --> P
2614 : : RES_POOLCOLL_TEXT, // --> P
2615 : : RES_POOLCOLL_HEADLINE_BASE, // --> H
2616 : : RES_POOLCOLL_HEADLINE1, // --> H1
2617 : : RES_POOLCOLL_HEADLINE2, // --> H2
2618 : : RES_POOLCOLL_HEADLINE3, // --> H3
2619 : : RES_POOLCOLL_HEADLINE4, // --> H4
2620 : : RES_POOLCOLL_HEADLINE5, // --> H5
2621 : : RES_POOLCOLL_HEADLINE6, // --> H6
2622 : : RES_POOLCOLL_FOOTNOTE,
2623 : : RES_POOLCOLL_ENDNOTE,
2624 : : 0
2625 : : };
2626 : :
2627 : 96 : sal_uInt16* pPoolIds = aPoolIds;
2628 [ + - ]: 96 : String s;
2629 [ + + ]: 1440 : while( *pPoolIds )
2630 : : {
2631 [ + + ][ + - ]: 1344 : if( !bIsSearchUsed || rDoc.IsPoolTxtCollUsed( *pPoolIds ) )
[ + + ][ + + ]
2632 : : aLst.Append( cPARA,
2633 [ + - ][ + - ]: 240 : s = SwStyleNameMapper::GetUIName( *pPoolIds, s ));
[ + - ]
2634 : 1344 : ++pPoolIds;
2635 [ + - ]: 96 : }
2636 : : }
2637 : : }
2638 : : }
2639 : :
2640 [ + + ][ - + ]: 21526 : if( nSearchFamily == SFX_STYLE_FAMILY_FRAME ||
2641 : : nSearchFamily == SFX_STYLE_FAMILY_ALL )
2642 : : {
2643 : 1570 : const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->size();
2644 [ + + ]: 4768 : for( sal_uInt16 i = 0; i < nArrLen; i++ )
2645 : : {
2646 : 3198 : SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ];
2647 : :
2648 [ + + ][ + + ]: 3198 : if(pFmt->IsDefault() || pFmt->IsAuto())
[ + + ]
2649 : : {
2650 : 3150 : continue;
2651 : : }
2652 : :
2653 : 48 : const sal_uInt16 nId = pFmt->GetPoolFmtId();
2654 [ + - ][ + + ]: 48 : sal_Bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(*pFmt));
[ + + ]
2655 [ + + ]: 48 : if( !bUsed )
2656 : : {
2657 [ + + ]: 36 : if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2658 : : ? !(nId & USER_FMT)
2659 : : // searched for used and found none
2660 [ - + ]: 36 : : bIsSearchUsed )
2661 : : {
2662 : 12 : continue;
2663 : : }
2664 : : }
2665 : :
2666 : 36 : aLst.Append( cFRAME, pFmt->GetName() );
2667 : : }
2668 : :
2669 : : // PoolFormate
2670 : : //
2671 [ + + ]: 1570 : if ( nSrchMask == SFXSTYLEBIT_ALL )
2672 : 46 : AppendStyleList(SwStyleNameMapper::GetFrmFmtUINameArray(),
2673 : 46 : bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, cFRAME);
2674 : : }
2675 : :
2676 [ + + ][ - + ]: 21526 : if( nSearchFamily == SFX_STYLE_FAMILY_PAGE ||
2677 : : nSearchFamily == SFX_STYLE_FAMILY_ALL )
2678 : : {
2679 : 94 : const sal_uInt16 nCount = rDoc.GetPageDescCnt();
2680 [ + + ]: 247 : for(sal_uInt16 i = 0; i < nCount; ++i)
2681 : : {
2682 : 153 : const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
2683 : 153 : const sal_uInt16 nId = rDesc.GetPoolFmtId();
2684 [ # # ][ # # ]: 153 : sal_Bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rDesc));
[ - + ]
2685 [ + - ]: 153 : if( !bUsed )
2686 : : {
2687 [ - + ]: 153 : if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2688 : : ? !(nId & USER_FMT)
2689 : : // searched for used and found none
2690 [ - + ]: 153 : : bIsSearchUsed )
2691 : 0 : continue;
2692 : : }
2693 : :
2694 : 153 : aLst.Append( cPAGE, rDesc.GetName() );
2695 : : }
2696 [ + - ]: 94 : if ( nSrchMask == SFXSTYLEBIT_ALL )
2697 : 94 : AppendStyleList(SwStyleNameMapper::GetPageDescUINameArray(),
2698 : 94 : bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, cPAGE);
2699 : : }
2700 : :
2701 [ + - ][ - + ]: 21526 : if( nSearchFamily == SFX_STYLE_FAMILY_PSEUDO ||
2702 : : nSearchFamily == SFX_STYLE_FAMILY_ALL )
2703 : : {
2704 : 0 : const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl();
2705 [ # # ]: 0 : for(sal_uInt16 i = 0; i < rNumTbl.size(); ++i)
2706 : : {
2707 : 0 : const SwNumRule& rRule = *rNumTbl[ i ];
2708 [ # # ]: 0 : if( !rRule.IsAutoRule() )
2709 : : {
2710 [ # # ][ # # ]: 0 : sal_Bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rRule) );
[ # # ]
2711 [ # # ]: 0 : if( !bUsed )
2712 : : {
2713 [ # # ]: 0 : if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2714 : 0 : ? !(rRule.GetPoolFmtId() & USER_FMT)
2715 : : // searched for used and found none
2716 [ # # ]: 0 : : bIsSearchUsed )
2717 : 0 : continue;
2718 : : }
2719 : :
2720 : 0 : aLst.Append( cNUMRULE, rRule.GetName() );
2721 : : }
2722 : : }
2723 [ # # ]: 0 : if ( nSrchMask == SFXSTYLEBIT_ALL )
2724 : 0 : AppendStyleList(SwStyleNameMapper::GetNumRuleUINameArray(),
2725 : 0 : bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, cNUMRULE);
2726 : : }
2727 : :
2728 [ + + ]: 21526 : if(!aLst.empty())
2729 : : {
2730 : 20006 : nLastPos = USHRT_MAX;
2731 : 20006 : return Next();
2732 : : }
2733 : 21526 : return 0;
2734 : : }
2735 : :
2736 : 38323 : SfxStyleSheetBase* SwStyleSheetIterator::Next()
2737 : : {
2738 : 38323 : ++nLastPos;
2739 [ + - ][ + + ]: 38323 : if(!aLst.empty() && nLastPos < aLst.size())
[ + + ]
2740 : : {
2741 : 28739 : mxIterSheet->PresetNameAndFamily(aLst[nLastPos]);
2742 : 28739 : mxIterSheet->SetPhysical( sal_False );
2743 : 28739 : mxIterSheet->SetMask( nMask );
2744 [ - + ]: 28739 : if(mxIterSheet->pSet)
2745 : : {
2746 : 0 : mxIterSheet->pSet->ClearItem(0);
2747 : 0 : mxIterSheet->pSet= 0;
2748 : : }
2749 : 28739 : return mxIterSheet.get();
2750 : : }
2751 : 38323 : return 0;
2752 : : }
2753 : :
2754 : 0 : SfxStyleSheetBase* SwStyleSheetIterator::Find(const rtl::OUString& rName)
2755 : : {
2756 : : // searching
2757 [ # # ]: 0 : if( !bFirstCalled )
2758 : 0 : First();
2759 : :
2760 : 0 : nLastPos = lcl_FindName( aLst, nSearchFamily, rName );
2761 [ # # ]: 0 : if( USHRT_MAX != nLastPos )
2762 : : {
2763 : : // found
2764 : 0 : mxStyleSheet->PresetNameAndFamily(aLst[nLastPos]);
2765 : : // new name is set, so determine its Data
2766 : 0 : mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2767 [ # # ]: 0 : if( !mxStyleSheet->IsPhysical() )
2768 : 0 : mxStyleSheet->SetPhysical( sal_False );
2769 : :
2770 : 0 : return mxStyleSheet.get();
2771 : : }
2772 : 0 : return 0;
2773 : : }
2774 : :
2775 : 5774 : void SwStyleSheetIterator::AppendStyleList(const boost::ptr_vector<String>& rList,
2776 : : sal_Bool bTestUsed,
2777 : : sal_uInt16 nSection, char cType )
2778 : : {
2779 [ + + ]: 5774 : if( bTestUsed )
2780 : : {
2781 : 92 : SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc();
2782 [ + + ]: 552 : for ( sal_uInt16 i=0; i < rList.size(); ++i )
2783 : : {
2784 : 460 : sal_Bool bUsed = sal_False;
2785 : 460 : sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rList[i], (SwGetPoolIdFromName)nSection);
2786 [ + - - - : 460 : switch ( nSection )
- ]
2787 : : {
2788 : : case nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL:
2789 : 460 : bUsed = rDoc.IsPoolTxtCollUsed( nId );
2790 : 460 : break;
2791 : : case nsSwGetPoolIdFromName::GET_POOLID_CHRFMT:
2792 : 0 : bUsed = rDoc.IsPoolFmtUsed( nId );
2793 : 0 : break;
2794 : : case nsSwGetPoolIdFromName::GET_POOLID_FRMFMT:
2795 : 0 : bUsed = rDoc.IsPoolFmtUsed( nId );
2796 : : case nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC:
2797 : 0 : bUsed = rDoc.IsPoolPageDescUsed( nId );
2798 : 0 : break;
2799 : : default:
2800 : : OSL_ENSURE( !this, "unknown PoolFmt-Id" );
2801 : : }
2802 [ - + ]: 460 : if ( bUsed )
2803 : 0 : aLst.Append( cType, rList[i] );
2804 : : }
2805 : : }
2806 : : else
2807 [ + + ]: 118376 : for ( sal_uInt16 i=0; i < rList.size(); ++i )
2808 : 112694 : aLst.Append( cType, rList[i] );
2809 : 5774 : }
2810 : :
2811 : 808 : void SwStyleSheetIterator::Notify( SfxBroadcaster&, const SfxHint& rHint )
2812 : : {
2813 : : // search and remove from View-List!!
2814 [ + + + + ]: 854 : if( rHint.ISA( SfxStyleSheetHint ) &&
[ + + ]
2815 : 46 : SFX_STYLESHEET_ERASED == ((SfxStyleSheetHint&) rHint).GetHint() )
2816 : : {
2817 : 2 : SfxStyleSheetBase* pStyle = ((SfxStyleSheetHint&)rHint).GetStyleSheet();
2818 : :
2819 [ + - ]: 2 : if (pStyle)
2820 : : {
2821 : : sal_uInt16 nTmpPos = lcl_FindName( aLst, pStyle->GetFamily(),
2822 [ + - ]: 2 : pStyle->GetName() );
2823 [ - + ]: 2 : if( nTmpPos < aLst.size() )
2824 [ # # ][ # # ]: 0 : aLst.erase(aLst.begin() + nTmpPos);
2825 : : }
2826 : : }
2827 : 808 : }
2828 : :
2829 : :
2830 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|