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