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