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