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