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