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