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