Update ooo320-m1
[ooovba.git] / sw / source / ui / app / docstyle.cxx
blobdb72c86319c0d49246e120c9ec03f87cb0355699
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docstyle.cxx,v $
10 * $Revision: 1.35 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #define _SVSTDARR_USHORTS
36 #include <svtools/smplhint.hxx>
37 #include <hintids.hxx>
38 #include <svtools/itemiter.hxx>
39 #include <svtools/eitem.hxx>
40 #include <svtools/syslocale.hxx>
41 #include <svx/boxitem.hxx>
42 #include <svx/numitem.hxx>
43 // --> OD 2008-02-13 #newlistlevelattrs#
44 #include <svx/lrspitem.hxx>
45 // <--
46 #include <fmtcol.hxx>
47 #include <uitool.hxx>
48 #include <swmodule.hxx>
49 #include <wrtsh.hxx>
50 #ifndef _DOCSH_HXX
51 #include <docsh.hxx>
52 #endif
53 #include <errhdl.hxx>
54 #include <frmfmt.hxx>
55 #include <charfmt.hxx>
56 #include <poolfmt.hxx>
57 #include <pagedesc.hxx>
58 #include <docstyle.hxx>
59 #include <docary.hxx>
60 #include <ccoll.hxx>
61 #include <doc.hxx>
62 #ifndef _CMDID_H
63 #include <cmdid.h>
64 #endif
65 #include <swstyle.h>
66 #ifndef _APP_HRC
67 #include <app.hrc>
68 #endif
69 #include <paratr.hxx>
70 #include <SwStyleNameMapper.hxx>
71 #include <svtools/cjkoptions.hxx>
72 #include <comphelper/processfactory.hxx>
73 #include <unotools/localedatawrapper.hxx>
74 #include <unotools/intlwrapper.hxx>
75 #include <numrule.hxx>
76 #include <fmthdft.hxx>
77 // --> OD 2008-02-12 #newlistlevelattrs#
78 #include <SwRewriter.hxx>
79 #include <undobj.hxx>
80 // <--
82 // MD 06.02.95: Die Formatnamen in der Liste aller Namen haben als
83 // erstes Zeichen die Familie:
85 #define cCHAR (sal_Unicode)'c'
86 #define cPARA (sal_Unicode)'p'
87 #define cFRAME (sal_Unicode)'f'
88 #define cPAGE (sal_Unicode)'g'
89 #define cNUMRULE (sal_Unicode)'n'
91 // Dieses Zeichen wird bei der Herausgabe der Namen wieder entfernt und
92 // die Familie wird neu generiert.
94 // Ausserdem gibt es jetzt zusaetzlich das Bit bPhysical. Ist dieses Bit
95 // TRUE, werden die Pool-Formatnamen NICHT mit eingetragen.
97 class SwImplShellAction
99 SwWrtShell* pSh;
100 CurrShell* pCurrSh;
101 public:
102 SwImplShellAction( SwDoc& rDoc );
103 ~SwImplShellAction();
105 SwWrtShell* GetSh() { return pSh; }
108 SwImplShellAction::SwImplShellAction( SwDoc& rDoc )
109 : pCurrSh( 0 )
111 if( rDoc.GetDocShell() )
112 pSh = rDoc.GetDocShell()->GetWrtShell();
113 else
114 pSh = 0;
116 if( pSh )
118 pCurrSh = new CurrShell( pSh );
119 pSh->StartAllAction();
123 SwImplShellAction::~SwImplShellAction()
125 if( pCurrSh )
127 pSh->EndAllAction();
128 delete pCurrSh;
132 /*--------------------------------------------------------------------
133 Beschreibung: SwCharFormate finden/anlegen
134 evtl. Style fuellen
135 --------------------------------------------------------------------*/
137 SwCharFmt* lcl_FindCharFmt( SwDoc& rDoc,
138 const String& rName,
139 SwDocStyleSheet* pStyle = 0,
140 BOOL bCreate = TRUE )
142 SwCharFmt* pFmt = 0;
143 if( rName.Len() )
145 pFmt = rDoc.FindCharFmtByName( rName );
146 if( !pFmt && rName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
147 RES_POOLCOLL_TEXT_BEGIN ] )
149 // Standard-Zeichenvorlage
150 pFmt = (SwCharFmt*)rDoc.GetDfltCharFmt();
153 if( !pFmt && bCreate )
154 { // Pool abklappern
155 const USHORT nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
156 if(nId != USHRT_MAX)
157 pFmt = rDoc.GetCharFmtFromPool(nId);
160 if(pStyle)
162 if(pFmt)
164 pStyle->SetPhysical(TRUE);
165 SwFmt* p = pFmt->DerivedFrom();
166 if( p && !p->IsDefault() )
167 pStyle->PresetParent( p->GetName() );
168 else
169 pStyle->PresetParent( aEmptyStr );
171 else
172 pStyle->SetPhysical(FALSE);
174 return pFmt;
178 /*--------------------------------------------------------------------
179 Beschreibung: ParaFormate finden/erzeugen
180 Style fuellen
181 --------------------------------------------------------------------*/
183 SwTxtFmtColl* lcl_FindParaFmt( SwDoc& rDoc,
184 const String& rName,
185 SwDocStyleSheet* pStyle = 0,
186 BOOL bCreate = TRUE )
188 SwTxtFmtColl* pColl = 0;
190 if( rName.Len() )
192 pColl = rDoc.FindTxtFmtCollByName( rName );
193 if( !pColl && bCreate )
194 { // Pool abklappern
195 const USHORT nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
196 if(nId != USHRT_MAX)
197 pColl = rDoc.GetTxtCollFromPool(nId);
201 if(pStyle)
203 if(pColl)
205 pStyle->SetPhysical(TRUE);
206 if( pColl->DerivedFrom() && !pColl->DerivedFrom()->IsDefault() )
207 pStyle->PresetParent( pColl->DerivedFrom()->GetName() );
208 else
209 pStyle->PresetParent( aEmptyStr );
211 SwTxtFmtColl& rNext = pColl->GetNextTxtFmtColl();
212 pStyle->PresetFollow(rNext.GetName());
214 else
215 pStyle->SetPhysical(FALSE);
217 return pColl;
221 /*--------------------------------------------------------------------
222 Beschreibung: Rahmenformate
223 --------------------------------------------------------------------*/
226 SwFrmFmt* lcl_FindFrmFmt( SwDoc& rDoc,
227 const String& rName,
228 SwDocStyleSheet* pStyle = 0,
229 BOOL bCreate = TRUE )
231 SwFrmFmt* pFmt = 0;
232 if( rName.Len() )
234 pFmt = rDoc.FindFrmFmtByName( rName );
235 if( !pFmt && bCreate )
236 { // Pool abklappern
237 const USHORT nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT);
238 if(nId != USHRT_MAX)
239 pFmt = rDoc.GetFrmFmtFromPool(nId);
243 if(pStyle)
245 if(pFmt)
247 pStyle->SetPhysical(TRUE);
248 if( pFmt->DerivedFrom() && !pFmt->DerivedFrom()->IsDefault() )
249 pStyle->PresetParent( pFmt->DerivedFrom()->GetName() );
250 else
251 pStyle->PresetParent( aEmptyStr );
253 else
254 pStyle->SetPhysical(FALSE);
256 return pFmt;
259 /*--------------------------------------------------------------------
260 Beschreibung: Seitendescriptoren
261 --------------------------------------------------------------------*/
264 const SwPageDesc* lcl_FindPageDesc( SwDoc& rDoc,
265 const String& rName,
266 SwDocStyleSheet* pStyle = 0,
267 BOOL bCreate = TRUE )
269 const SwPageDesc* pDesc = 0;
271 if( rName.Len() )
273 pDesc = rDoc.FindPageDescByName( rName );
274 if( !pDesc && bCreate )
276 USHORT nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC);
277 if(nId != USHRT_MAX)
278 pDesc = rDoc.GetPageDescFromPool(nId);
282 if(pStyle)
284 if(pDesc)
286 pStyle->SetPhysical(TRUE);
287 if(pDesc->GetFollow())
288 pStyle->PresetFollow(pDesc->GetFollow()->GetName());
289 else
290 pStyle->PresetParent( aEmptyStr );
292 else
293 pStyle->SetPhysical(FALSE);
295 return pDesc;
298 const SwNumRule* lcl_FindNumRule( SwDoc& rDoc,
299 const String& rName,
300 SwDocStyleSheet* pStyle = 0,
301 BOOL bCreate = TRUE )
303 const SwNumRule* pRule = 0;
305 if( rName.Len() )
307 pRule = rDoc.FindNumRulePtr( rName );
308 if( !pRule && bCreate )
310 USHORT nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE);
311 if(nId != USHRT_MAX)
312 pRule = rDoc.GetNumRuleFromPool(nId);
316 if(pStyle)
318 if(pRule)
320 pStyle->SetPhysical(TRUE);
321 pStyle->PresetParent( aEmptyStr );
323 else
324 pStyle->SetPhysical(FALSE);
326 return pRule;
330 USHORT lcl_FindName( const SwPoolFmtList& rLst, SfxStyleFamily eFam,
331 const String& rName )
333 if( rLst.Count() )
335 // suchen
336 String sSrch( ' ' );
337 switch( eFam )
339 case SFX_STYLE_FAMILY_CHAR: sSrch = cCHAR; break;
340 case SFX_STYLE_FAMILY_PARA: sSrch = cPARA; break;
341 case SFX_STYLE_FAMILY_FRAME: sSrch = cFRAME; break;
342 case SFX_STYLE_FAMILY_PAGE: sSrch = cPAGE; break;
343 case SFX_STYLE_FAMILY_PSEUDO: sSrch = cNUMRULE; break;
344 default:; //prevent warning
346 sSrch += rName;
347 for( USHORT i=0; i < rLst.Count(); ++i )
348 if( *rLst[i] == sSrch )
349 return i;
351 return USHRT_MAX;
354 BOOL FindPhyStyle( SwDoc& rDoc, const String& rName, SfxStyleFamily eFam )
356 switch( eFam )
358 case SFX_STYLE_FAMILY_CHAR :
359 return 0 != lcl_FindCharFmt( rDoc, rName, 0, FALSE );
360 case SFX_STYLE_FAMILY_PARA :
361 return 0 != lcl_FindParaFmt( rDoc, rName, 0, FALSE );
362 case SFX_STYLE_FAMILY_FRAME:
363 return 0 != lcl_FindFrmFmt( rDoc, rName, 0, FALSE );
364 case SFX_STYLE_FAMILY_PAGE :
365 return 0 != lcl_FindPageDesc( rDoc, rName, 0, FALSE );
366 case SFX_STYLE_FAMILY_PSEUDO:
367 return 0 != lcl_FindNumRule( rDoc, rName, 0, FALSE );
368 default:; //prevent warning
370 return FALSE;
374 /*--------------------------------------------------------------------
375 Beschreibung: Einfuegen von Strings in die Liste der Vorlagen
376 --------------------------------------------------------------------*/
379 void SwPoolFmtList::Append( char cChar, const String& rStr )
381 String* pStr = new String( cChar );
382 *pStr += rStr;
383 for ( USHORT i=0; i < Count(); ++i )
385 if( *operator[](i) == *pStr )
387 delete pStr;
388 return;
391 Insert( pStr, Count() );
394 /*--------------------------------------------------------------------
395 Beschreibung: Liste kompletti loeschen
396 --------------------------------------------------------------------*/
399 void SwPoolFmtList::Erase()
401 DeleteAndDestroy( 0, Count() );
404 /* \f */
406 /*--------------------------------------------------------------------
407 Beschreibung: UI-seitige implementierung von StyleSheets
408 greift auf die Core-Engine zu
409 --------------------------------------------------------------------*/
411 SwDocStyleSheet::SwDocStyleSheet( SwDoc& rDocument,
412 const String& rName,
413 SwDocStyleSheetPool& _rPool,
414 SfxStyleFamily eFam,
415 USHORT _nMask) :
417 SfxStyleSheetBase( rName, _rPool, eFam, _nMask ),
418 pCharFmt(0),
419 pColl(0),
420 pFrmFmt(0),
421 pDesc(0),
422 pNumRule(0),
424 rDoc(rDocument),
425 aCoreSet(GetPool().GetPool(),
426 RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
427 RES_PARATR_BEGIN, RES_PARATR_END - 1,
428 // --> OD 2008-02-25 #refactorlists#
429 RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1,
430 // <--
431 RES_FRMATR_BEGIN, RES_FRMATR_END - 1,
432 RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
433 SID_ATTR_PAGE, SID_ATTR_PAGE_EXT1,
434 SID_ATTR_PAGE_HEADERSET,SID_ATTR_PAGE_FOOTERSET,
435 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
436 FN_PARAM_FTN_INFO, FN_PARAM_FTN_INFO,
437 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL,
438 SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM,
439 SID_SWREGISTER_MODE, SID_SWREGISTER_MODE,
440 SID_SWREGISTER_COLLECTION, SID_SWREGISTER_COLLECTION,
441 FN_COND_COLL, FN_COND_COLL,
442 SID_ATTR_AUTO_STYLE_UPDATE, SID_ATTR_AUTO_STYLE_UPDATE,
443 SID_ATTR_NUMBERING_RULE, SID_ATTR_NUMBERING_RULE,
444 SID_PARA_BACKGRND_DESTINATION, SID_ATTR_BRUSH_CHAR,
445 SID_ATTR_NUMBERING_RULE, SID_ATTR_NUMBERING_RULE,
447 bPhysical(FALSE)
449 nHelpId = UCHAR_MAX;
453 SwDocStyleSheet::SwDocStyleSheet( const SwDocStyleSheet& rOrg) :
454 SfxStyleSheetBase(rOrg),
455 pCharFmt(rOrg.pCharFmt),
456 pColl(rOrg.pColl),
457 pFrmFmt(rOrg.pFrmFmt),
458 pDesc(rOrg.pDesc),
459 pNumRule(rOrg.pNumRule),
460 rDoc(rOrg.rDoc),
461 aCoreSet(rOrg.aCoreSet),
462 bPhysical(rOrg.bPhysical)
467 SwDocStyleSheet::~SwDocStyleSheet()
471 /*--------------------------------------------------------------------
472 Beschreibung: Zuruecksetzen
473 --------------------------------------------------------------------*/
476 void SwDocStyleSheet::Reset()
478 aName.Erase();
479 aFollow.Erase();
480 aParent.Erase();
481 SetPhysical(FALSE);
484 /*--------------------------------------------------------------------
485 Beschreibung: virtuelle Methoden
486 --------------------------------------------------------------------*/
489 const String& SwDocStyleSheet::GetParent() const
491 if( !bPhysical )
493 // dann pruefe, ob schon im Doc vorhanden
494 SwFmt* pFmt = 0;
495 SwGetPoolIdFromName eGetType;
496 switch(nFamily)
498 case SFX_STYLE_FAMILY_CHAR:
499 pFmt = rDoc.FindCharFmtByName( aName );
500 eGetType = nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
501 break;
503 case SFX_STYLE_FAMILY_PARA:
504 pFmt = rDoc.FindTxtFmtCollByName( aName );
505 eGetType = nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL;
506 break;
508 case SFX_STYLE_FAMILY_FRAME:
509 pFmt = rDoc.FindFrmFmtByName( aName );
510 eGetType = nsSwGetPoolIdFromName::GET_POOLID_FRMFMT;
511 break;
513 case SFX_STYLE_FAMILY_PAGE:
514 case SFX_STYLE_FAMILY_PSEUDO:
515 default:
516 return aEmptyStr; // es gibt keinen Parent
519 String sTmp;
520 if( !pFmt ) // noch nicht vorhanden, also dflt. Parent
522 USHORT i = SwStyleNameMapper::GetPoolIdFromUIName( aName, eGetType );
523 i = ::GetPoolParent( i );
524 if( i && USHRT_MAX != i )
525 SwStyleNameMapper::FillUIName( i, sTmp );
527 else
529 SwFmt* p = pFmt->DerivedFrom();
530 if( p && !p->IsDefault() )
531 sTmp = p->GetName();
533 SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
534 pThis->aParent = sTmp;
536 return aParent;
539 /*--------------------------------------------------------------------
540 Beschreibung: Nachfolger
541 --------------------------------------------------------------------*/
544 const String& SwDocStyleSheet::GetFollow() const
546 if( !bPhysical )
548 SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
549 pThis->FillStyleSheet( FillAllInfo );
551 return aFollow;
554 /*--------------------------------------------------------------------
555 Beschreibung: Welche Verkettung ist moeglich
556 --------------------------------------------------------------------*/
559 BOOL SwDocStyleSheet::HasFollowSupport() const
561 switch(nFamily)
563 case SFX_STYLE_FAMILY_PARA :
564 case SFX_STYLE_FAMILY_PAGE : return TRUE;
565 case SFX_STYLE_FAMILY_FRAME:
566 case SFX_STYLE_FAMILY_CHAR :
567 case SFX_STYLE_FAMILY_PSEUDO: return FALSE;
568 default:
569 ASSERT(!this, "unbekannte Style-Familie");
571 return FALSE;
574 /*--------------------------------------------------------------------
575 Beschreibung: Parent ?
576 --------------------------------------------------------------------*/
579 BOOL SwDocStyleSheet::HasParentSupport() const
581 BOOL bRet = FALSE;
582 switch(nFamily)
584 case SFX_STYLE_FAMILY_CHAR :
585 case SFX_STYLE_FAMILY_PARA :
586 case SFX_STYLE_FAMILY_FRAME: bRet = TRUE;
587 default:; //prevent warning
589 return bRet;
593 BOOL SwDocStyleSheet::HasClearParentSupport() const
595 BOOL bRet = FALSE;
596 switch(nFamily)
598 case SFX_STYLE_FAMILY_PARA :
599 case SFX_STYLE_FAMILY_CHAR :
600 case SFX_STYLE_FAMILY_FRAME: bRet = TRUE;
601 default:; //prevent warning
603 return bRet;
606 /*--------------------------------------------------------------------
607 Beschreibung: textuelle Beschreibung ermitteln
608 --------------------------------------------------------------------*/
609 String SwDocStyleSheet::GetDescription(SfxMapUnit eUnit)
611 IntlWrapper aIntlWrapper(
612 ::comphelper::getProcessServiceFactory(),
613 SvtSysLocale().GetLocaleData().getLocale());
615 String sPlus(String::CreateFromAscii(" + "));
616 if ( SFX_STYLE_FAMILY_PAGE == nFamily )
618 if( !pSet )
619 GetItemSet();
621 SfxItemIter aIter( *pSet );
622 String aDesc;
623 const SfxPoolItem* pItem = aIter.FirstItem();
625 while ( pItem )
627 if(!IsInvalidItem(pItem))
628 switch ( pItem->Which() )
630 case RES_LR_SPACE:
631 case SID_ATTR_PAGE_SIZE:
632 case SID_ATTR_PAGE_MAXSIZE:
633 case SID_ATTR_PAGE_PAPERBIN:
634 case SID_ATTR_PAGE_APP:
635 case SID_ATTR_BORDER_INNER:
636 break;
637 default:
639 String aItemPresentation;
640 if ( !IsInvalidItem( pItem ) &&
641 rPool.GetPool().GetPresentation(
642 *pItem, SFX_ITEM_PRESENTATION_COMPLETE,
643 eUnit, aItemPresentation, &aIntlWrapper ) )
645 if ( aDesc.Len() && aItemPresentation.Len() )
646 aDesc += sPlus;
647 aDesc += aItemPresentation;
651 pItem = aIter.NextItem();
653 return aDesc;
655 else if ( SFX_STYLE_FAMILY_FRAME == nFamily ||
656 SFX_STYLE_FAMILY_PARA == nFamily)
658 if( !pSet )
659 GetItemSet();
661 SfxItemIter aIter( *pSet );
662 String aDesc;
663 const SfxPoolItem* pItem = aIter.FirstItem();
665 String sPageNum, sModel, sBreak;
666 BOOL bHasWesternFontPrefix = FALSE;
667 BOOL bHasCJKFontPrefix = FALSE;
668 SvtCJKOptions aCJKOptions;
670 while ( pItem )
672 if(!IsInvalidItem(pItem))
673 switch ( pItem->Which() )
675 case SID_ATTR_AUTO_STYLE_UPDATE:
676 case SID_PARA_BACKGRND_DESTINATION:
677 case RES_PAGEDESC:
678 //CTL no yet supported
679 case RES_CHRATR_CTL_FONT:
680 case RES_CHRATR_CTL_FONTSIZE:
681 case RES_CHRATR_CTL_LANGUAGE:
682 case RES_CHRATR_CTL_POSTURE:
683 case RES_CHRATR_CTL_WEIGHT:
684 break;
685 default:
687 String aItemPresentation;
688 if ( !IsInvalidItem( pItem ) &&
689 rPool.GetPool().GetPresentation(
690 *pItem, SFX_ITEM_PRESENTATION_COMPLETE,
691 eUnit, aItemPresentation, &aIntlWrapper ) )
693 BOOL bIsDefault = FALSE;
694 switch ( pItem->Which() )
696 case SID_ATTR_PARA_PAGENUM:
697 sPageNum = aItemPresentation;
698 break;
699 case SID_ATTR_PARA_MODEL:
700 sModel = aItemPresentation;
701 break;
702 case RES_BREAK:
703 sBreak = aItemPresentation;
704 break;
705 case RES_CHRATR_CJK_FONT:
706 case RES_CHRATR_CJK_FONTSIZE:
707 case RES_CHRATR_CJK_LANGUAGE:
708 case RES_CHRATR_CJK_POSTURE:
709 case RES_CHRATR_CJK_WEIGHT:
710 if(aCJKOptions.IsCJKFontEnabled())
711 bIsDefault = TRUE;
712 if(!bHasCJKFontPrefix)
714 aItemPresentation.Insert(SW_RESSTR(STR_CJK_FONT), 0);
715 bHasCJKFontPrefix = TRUE;
717 break;
718 case RES_CHRATR_FONT:
719 case RES_CHRATR_FONTSIZE:
720 case RES_CHRATR_LANGUAGE:
721 case RES_CHRATR_POSTURE:
722 case RES_CHRATR_WEIGHT:
723 if(!bHasWesternFontPrefix)
725 aItemPresentation.Insert(SW_RESSTR(STR_WESTERN_FONT), 0);
726 bHasWesternFontPrefix = TRUE;
727 bIsDefault = TRUE;
729 // no break;
730 default:
731 bIsDefault = TRUE;
733 if(bIsDefault)
735 if ( aDesc.Len() && aItemPresentation.Len() )
736 aDesc += sPlus;
737 aDesc += aItemPresentation;
742 pItem = aIter.NextItem();
744 //Sonderbehandlung fuer Umburch, Seitenvorlage und Seitenoffset
745 if(sBreak.Len() && !sModel.Len()) // wemm Model. dann ist Break ungueltig
747 if(aDesc.Len())
748 aDesc += sPlus;
749 aDesc += sBreak;
751 if(sModel.Len())
753 if(aDesc.Len())
754 aDesc += sPlus;
755 aDesc += SW_RESSTR(STR_PAGEBREAK);
756 aDesc += sPlus;
757 aDesc += sModel;
758 if(sPageNum != String(UniString::CreateFromInt32(0)))
760 aDesc += sPlus;
761 aDesc += SW_RESSTR(STR_PAGEOFFSET);
762 aDesc += sPageNum;
765 return aDesc;
767 else if( SFX_STYLE_FAMILY_PSEUDO == nFamily )
769 // if( pNumRule )
770 // return pNumRule->GetName();
771 //os: was sollte man bei Numerierungen schon anzeigen?
772 return aEmptyStr;
775 return SfxStyleSheetBase::GetDescription(eUnit);
779 String SwDocStyleSheet::GetDescription()
781 return GetDescription(SFX_MAPUNIT_CM);
784 /*--------------------------------------------------------------------
785 Beschreibung: Namen setzen
786 --------------------------------------------------------------------*/
789 BOOL SwDocStyleSheet::SetName( const String& rStr)
791 if( !rStr.Len() )
792 return FALSE;
794 if( aName != rStr )
796 if( !SfxStyleSheetBase::SetName( rStr ))
797 return FALSE;
799 else if(!bPhysical)
800 FillStyleSheet( FillPhysical );
802 int bChg = FALSE;
803 switch(nFamily)
805 case SFX_STYLE_FAMILY_CHAR :
807 ASSERT(pCharFmt, "SwCharFormat fehlt!");
808 if( pCharFmt && pCharFmt->GetName() != rStr )
810 pCharFmt->SetName( rStr );
811 bChg = TRUE;
813 break;
815 case SFX_STYLE_FAMILY_PARA :
817 ASSERT(pColl, "Collektion fehlt!");
818 if( pColl && pColl->GetName() != rStr )
820 if (pColl->GetName().Len() > 0)
821 rDoc.RenameFmt(*pColl, rStr);
822 else
823 pColl->SetName(rStr);
825 bChg = TRUE;
827 break;
829 case SFX_STYLE_FAMILY_FRAME:
831 ASSERT(pFrmFmt, "FrmFmt fehlt!");
832 if( pFrmFmt && pFrmFmt->GetName() != rStr )
834 if (pFrmFmt->GetName().Len() > 0)
835 rDoc.RenameFmt(*pFrmFmt, rStr);
836 else
837 pFrmFmt->SetName( rStr );
839 bChg = TRUE;
841 break;
843 case SFX_STYLE_FAMILY_PAGE :
844 ASSERT(pDesc, "PageDesc fehlt!");
845 if( pDesc && pDesc->GetName() != rStr )
847 //PageDesc setzen - mit vorherigem kopieren - ist fuer das
848 //setzen des Namens wohl nicht notwendig. Deshalb erlauben
849 //wir hier mal einen cast.
850 // -> #116530#
851 SwPageDesc aPageDesc(*((SwPageDesc*)pDesc));
852 String aOldName(aPageDesc.GetName());
854 aPageDesc.SetName( rStr );
855 BOOL bDoesUndo = rDoc.DoesUndo();
857 rDoc.DoUndo(aOldName.Len() > 0);
858 rDoc.ChgPageDesc(aOldName, aPageDesc);
859 rDoc.DoUndo(bDoesUndo);
860 // <- #116530#
862 rDoc.SetModified();
863 bChg = TRUE;
865 break;
866 case SFX_STYLE_FAMILY_PSEUDO:
867 ASSERT(pNumRule, "NumRule fehlt!");
869 // -> #106897#
870 if (pNumRule)
872 String aOldName = pNumRule->GetName();
874 if (aOldName.Len() > 0)
876 if ( aOldName != rStr &&
877 rDoc.RenameNumRule(aOldName, rStr))
879 pNumRule = rDoc.FindNumRulePtr(rStr);
880 rDoc.SetModified();
882 bChg = TRUE;
885 else
887 // --> OD 2008-07-08 #i91400#
888 ((SwNumRule*)pNumRule)->SetName( rStr, rDoc );
889 // <--
890 rDoc.SetModified();
892 bChg = TRUE;
895 // <- #106897#
897 break;
899 default:
900 ASSERT(!this, "unbekannte Style-Familie");
903 if( bChg )
905 rPool.First(); // interne Liste muss geupdatet werden
906 rPool.Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED, *this ) );
907 SwEditShell* pSh = rDoc.GetEditShell();
908 if( pSh )
909 pSh->CallChgLnk();
911 return TRUE;
914 /*--------------------------------------------------------------------
915 Beschreibung: Ableitungshirachie
916 --------------------------------------------------------------------*/
919 BOOL SwDocStyleSheet::SetParent( const String& rStr)
921 SwFmt* pFmt = 0, *pParent = 0;
922 switch(nFamily)
924 case SFX_STYLE_FAMILY_CHAR :
925 ASSERT( pCharFmt, "SwCharFormat fehlt!" )
926 if( 0 != ( pFmt = pCharFmt ) && rStr.Len() )
927 pParent = lcl_FindCharFmt(rDoc, rStr);
928 break;
930 case SFX_STYLE_FAMILY_PARA :
931 ASSERT( pColl, "Collektion fehlt!")
932 if( 0 != ( pFmt = pColl ) && rStr.Len() )
933 pParent = lcl_FindParaFmt( rDoc, rStr );
934 break;
936 case SFX_STYLE_FAMILY_FRAME:
937 ASSERT(pFrmFmt, "FrameFormat fehlt!");
938 if( 0 != ( pFmt = pFrmFmt ) && rStr.Len() )
939 pParent = lcl_FindFrmFmt( rDoc, rStr );
940 break;
942 case SFX_STYLE_FAMILY_PAGE:
943 case SFX_STYLE_FAMILY_PSEUDO:
944 break;
945 default:
946 ASSERT(!this, "unbekannte Style-Familie");
949 BOOL bRet = FALSE;
950 if( pFmt && pFmt->DerivedFrom() &&
951 pFmt->DerivedFrom()->GetName() != rStr )
954 SwImplShellAction aTmp( rDoc );
955 bRet = pFmt->SetDerivedFrom( pParent );
958 if( bRet )
960 aParent = rStr;
961 rPool.Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED,
962 *this ) );
966 return bRet;
969 /*--------------------------------------------------------------------
970 Beschreibung: Nachfolger detzen
971 --------------------------------------------------------------------*/
974 BOOL SwDocStyleSheet::SetFollow( const String& rStr)
976 if( rStr.Len() && !SfxStyleSheetBase::SetFollow( rStr ))
977 return FALSE;
979 SwImplShellAction aTmpSh( rDoc );
980 switch(nFamily)
982 case SFX_STYLE_FAMILY_PARA :
984 ASSERT(pColl, "Collection fehlt!");
985 if( pColl )
987 SwTxtFmtColl* pFollow = pColl;
988 if( rStr.Len() && 0 == (pFollow = lcl_FindParaFmt(rDoc, rStr) ))
989 pFollow = pColl;
991 pColl->SetNextTxtFmtColl(*pFollow);
993 break;
995 case SFX_STYLE_FAMILY_PAGE :
997 ASSERT(pDesc, "PageDesc fehlt!");
998 if( pDesc )
1000 const SwPageDesc* pFollowDesc = rStr.Len()
1001 ? lcl_FindPageDesc(rDoc, rStr)
1002 : 0;
1003 USHORT nId;
1004 if( pFollowDesc != pDesc->GetFollow() &&
1005 rDoc.FindPageDescByName( pDesc->GetName(), &nId ) )
1007 SwPageDesc aDesc( *pDesc );
1008 aDesc.SetFollow( pFollowDesc );
1009 rDoc.ChgPageDesc( nId, aDesc );
1010 pDesc = &const_cast<const SwDoc &>(rDoc).GetPageDesc( nId );
1013 break;
1015 case SFX_STYLE_FAMILY_CHAR:
1016 case SFX_STYLE_FAMILY_FRAME:
1017 case SFX_STYLE_FAMILY_PSEUDO:
1018 break;
1019 default:
1020 ASSERT(!this, "unbekannte Style-Familie");
1023 return TRUE;
1026 /*--------------------------------------------------------------------
1027 Beschreibung: ueber Name und Family, Mask den ItemSet rausholen
1028 --------------------------------------------------------------------*/
1030 SfxItemSet& SwDocStyleSheet::GetItemSet()
1032 if(!bPhysical)
1033 FillStyleSheet( FillPhysical );
1035 switch(nFamily)
1037 case SFX_STYLE_FAMILY_CHAR:
1039 ASSERT(pCharFmt, "Wo ist das SwCharFmt");
1040 aCoreSet.Put(pCharFmt->GetAttrSet());
1041 if(pCharFmt->DerivedFrom())
1042 aCoreSet.SetParent(&pCharFmt->DerivedFrom()->GetAttrSet());
1044 break;
1045 case SFX_STYLE_FAMILY_PARA :
1046 case SFX_STYLE_FAMILY_FRAME:
1048 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1049 aBoxInfo.SetTable( FALSE );
1050 aBoxInfo.SetDist( TRUE); // Abstandsfeld immer anzeigen
1051 aBoxInfo.SetMinDist( TRUE );// Minimalgroesse in Tabellen und Absaetzen setzen
1052 aBoxInfo.SetDefDist( MIN_BORDER_DIST );// Default-Abstand immer setzen
1053 // Einzelne Linien koennen nur in Tabellen DontCare-Status haben
1054 aBoxInfo.SetValid( VALID_DISABLE, TRUE );
1055 if ( nFamily == SFX_STYLE_FAMILY_PARA )
1057 ASSERT(pColl, "Wo ist die Collektion");
1058 aCoreSet.Put(pColl->GetAttrSet());
1059 aCoreSet.Put( aBoxInfo );
1060 aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pColl->IsAutoUpdateFmt()));
1061 if(pColl->DerivedFrom())
1062 aCoreSet.SetParent(&pColl->DerivedFrom()->GetAttrSet());
1064 else
1066 ASSERT(pFrmFmt, "Wo ist das FrmFmt");
1067 aCoreSet.Put(pFrmFmt->GetAttrSet());
1068 aCoreSet.Put( aBoxInfo );
1069 aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pFrmFmt->IsAutoUpdateFmt()));
1070 if(pFrmFmt->DerivedFrom())
1071 aCoreSet.SetParent(&pFrmFmt->DerivedFrom()->GetAttrSet());
1074 break;
1076 case SFX_STYLE_FAMILY_PAGE :
1078 ASSERT(pDesc, "Kein PageDescriptor");
1079 ::PageDescToItemSet(*((SwPageDesc*)pDesc), aCoreSet);
1081 break;
1083 case SFX_STYLE_FAMILY_PSEUDO:
1085 ASSERT(pNumRule, "Keine NumRule");
1086 SvxNumRule aRule = pNumRule->MakeSvxNumRule();
1087 aCoreSet.Put(SvxNumBulletItem(aRule));
1089 break;
1091 default:
1092 ASSERT(!this, "unbekannte Style-Familie");
1094 // Member der Basisklasse
1095 pSet = &aCoreSet;
1097 return aCoreSet;
1100 // --> OD 2008-02-13 #newlistlevelattrs#
1101 void SwDocStyleSheet::MergeIndentAttrsOfListStyle( SfxItemSet& rSet )
1103 if ( nFamily != SFX_STYLE_FAMILY_PARA )
1105 return;
1108 ASSERT( pColl, "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - missing paragraph style");
1109 if ( pColl->AreListLevelIndentsApplicable() )
1111 ASSERT( pColl->GetItemState( RES_PARATR_NUMRULE ) == SFX_ITEM_SET,
1112 "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - list level indents are applicable at paragraph style, but no list style found. Serious defect -> please inform OD." );
1113 const String sNumRule = pColl->GetNumRule().GetValue();
1114 if( sNumRule.Len() )
1116 const SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule );
1117 if( pRule )
1119 const SwNumFmt& rFmt = pRule->Get( 0 );
1120 if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
1122 SvxLRSpaceItem aLR( RES_LR_SPACE );
1123 aLR.SetTxtLeft( rFmt.GetIndentAt() );
1124 aLR.SetTxtFirstLineOfst( static_cast<short>(rFmt.GetFirstLineIndent()) );
1125 rSet.Put( aLR );
1131 // <--
1133 /*--------------------------------------------------------------------
1134 Beschreibung: ItemSet setzen
1135 --------------------------------------------------------------------*/
1137 // --> OD 2008-02-12 #newlistlevelattrs#
1138 // handling of parameter <bResetIndentAttrsAtParagraphStyle>
1139 void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
1140 const bool bResetIndentAttrsAtParagraphStyle )
1142 // gegebenenfalls Format erst ermitteln
1143 if(!bPhysical)
1144 FillStyleSheet( FillPhysical );
1146 SwImplShellAction aTmpSh( rDoc );
1148 ASSERT( &rSet != &aCoreSet, "SetItemSet mit eigenem Set ist nicht erlaubt" );
1150 // --> OD 2008-02-12 #newlistlevelattrs#
1151 if ( rDoc.DoesUndo() )
1153 SwRewriter aRewriter;
1154 aRewriter.AddRule( UNDO_ARG1, GetName() );
1155 rDoc.StartUndo( UNDO_INSFMTATTR, &aRewriter );
1157 // <--
1159 SwFmt* pFmt = 0;
1160 SwPageDesc* pNewDsc = 0;
1161 USHORT nPgDscPos = 0;
1163 switch(nFamily)
1165 case SFX_STYLE_FAMILY_CHAR :
1167 ASSERT(pCharFmt, "Wo ist das CharFormat");
1168 pFmt = pCharFmt;
1170 break;
1172 case SFX_STYLE_FAMILY_PARA :
1174 ASSERT(pColl, "Wo ist die Collection");
1175 const SfxPoolItem* pAutoUpdate;
1176 if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,FALSE, &pAutoUpdate ))
1178 pColl->SetAutoUpdateFmt(((const SfxBoolItem*)pAutoUpdate)->GetValue());
1181 const SwCondCollItem* pCondItem;
1182 if( SFX_ITEM_SET != rSet.GetItemState( FN_COND_COLL, FALSE,
1183 (const SfxPoolItem**)&pCondItem ))
1184 pCondItem = 0;
1186 if( RES_CONDTXTFMTCOLL == pColl->Which() && pCondItem )
1188 SwFmt* pFindFmt;
1189 const CommandStruct* pCmds = SwCondCollItem::GetCmds();
1190 for(USHORT i = 0; i < COND_COMMAND_COUNT; i++)
1192 SwCollCondition aCond( 0, pCmds[ i ].nCnd, pCmds[ i ].nSubCond );
1193 ((SwConditionTxtFmtColl*)pColl)->RemoveCondition( aCond );
1194 const String& rStyle = pCondItem->GetStyle( i );
1195 if( rStyle.Len() &&
1196 0 != ( pFindFmt = lcl_FindParaFmt( rDoc, rStyle, 0, TRUE )))
1198 pFindFmt->Add( &aCond );
1199 ((SwConditionTxtFmtColl*)pColl)->InsertCondition( aCond );
1203 // Document auf die neue Bedingungen updaten
1204 SwCondCollCondChg aMsg( pColl );
1205 pColl->Modify( &aMsg, &aMsg );
1207 else if( pCondItem && !pColl->GetDepends() )
1209 // keine bedingte Vorlage, dann erstmal erzeugen und
1210 // alle wichtigen Werte uebernehmen
1211 SwConditionTxtFmtColl* pCColl = rDoc.MakeCondTxtFmtColl(
1212 pColl->GetName(), (SwTxtFmtColl*)pColl->DerivedFrom() );
1213 if( pColl != &pColl->GetNextTxtFmtColl() )
1214 pCColl->SetNextTxtFmtColl( pColl->GetNextTxtFmtColl() );
1216 //pCColl->SetOutlineLevel( pColl->GetOutlineLevel() );//#outline level,zhaojianwei
1217 if( pColl->IsAssignedToListLevelOfOutlineStyle())
1218 pCColl->AssignToListLevelOfOutlineStyle(pColl->GetAssignedOutlineStyleLevel());
1219 else
1220 pCColl->DeleteAssignmentToListLevelOfOutlineStyle();//<--end,zhaojianwei
1224 SwTxtFmtColl* pFindFmt;
1225 const CommandStruct* pCmds = SwCondCollItem::GetCmds();
1226 for( USHORT i = 0; i < COND_COMMAND_COUNT; ++i )
1228 const String& rStyle = pCondItem->GetStyle( i );
1229 if( rStyle.Len() &&
1230 0 != ( pFindFmt = lcl_FindParaFmt( rDoc, rStyle, 0, TRUE )))
1232 pCColl->InsertCondition( SwCollCondition( pFindFmt,
1233 pCmds[ i ].nCnd, pCmds[ i ].nSubCond ) );
1237 rDoc.DelTxtFmtColl( pColl );
1238 pColl = pCColl;
1240 // --> OD 2008-02-12 #newlistlevelattrs#
1241 if ( bResetIndentAttrsAtParagraphStyle &&
1242 rSet.GetItemState( RES_PARATR_NUMRULE, FALSE, 0 ) == SFX_ITEM_SET &&
1243 rSet.GetItemState( RES_LR_SPACE, FALSE, 0 ) != SFX_ITEM_SET &&
1244 pColl->GetItemState( RES_LR_SPACE, FALSE, 0 ) == SFX_ITEM_SET )
1246 rDoc.ResetAttrAtFormat( RES_LR_SPACE, *pColl );
1248 // <--
1250 // #i56252: If a standard numbering style is assigned to a standard paragraph style
1251 // we have to create a physical instance of the numbering style. If we do not and
1252 // neither the paragraph style nor the numbering style is used in the document
1253 // the numbering style will not be saved with the document and the assignment got lost.
1254 const SfxPoolItem* pNumRuleItem = 0;
1255 if( SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE, FALSE, &pNumRuleItem ) )
1256 { // Setting a numbering rule?
1257 String sNumRule = ((SwNumRuleItem*)pNumRuleItem)->GetValue();
1258 if( sNumRule.Len() )
1260 SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule );
1261 if( !pRule )
1262 { // Numbering rule not in use yet.
1263 USHORT nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sNumRule, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
1264 if( USHRT_MAX != nPoolId ) // It's a standard numbering rule
1266 pRule = rDoc.GetNumRuleFromPool( nPoolId ); // Create numbering rule (physical)
1272 pFmt = pColl;
1274 USHORT nId = pColl->GetPoolFmtId() &
1275 ~ ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID );
1276 switch( GetMask() & ( 0x0fff & ~SWSTYLEBIT_CONDCOLL ) )
1278 case SWSTYLEBIT_TEXT:
1279 nId |= COLL_TEXT_BITS;
1280 break;
1281 case SWSTYLEBIT_CHAPTER:
1282 nId |= COLL_DOC_BITS;
1283 break;
1284 case SWSTYLEBIT_LIST:
1285 nId |= COLL_LISTS_BITS;
1286 break;
1287 case SWSTYLEBIT_IDX:
1288 nId |= COLL_REGISTER_BITS;
1289 break;
1290 case SWSTYLEBIT_EXTRA:
1291 nId |= COLL_EXTRA_BITS;
1292 break;
1293 case SWSTYLEBIT_HTML:
1294 nId |= COLL_HTML_BITS;
1295 break;
1297 pColl->SetPoolFmtId( nId );
1298 break;
1300 case SFX_STYLE_FAMILY_FRAME:
1302 ASSERT(pFrmFmt, "Wo ist das FrmFmt");
1303 const SfxPoolItem* pAutoUpdate;
1304 if(SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,FALSE, &pAutoUpdate ))
1306 pFrmFmt->SetAutoUpdateFmt(((const SfxBoolItem*)pAutoUpdate)->GetValue());
1308 pFmt = pFrmFmt;
1310 break;
1312 case SFX_STYLE_FAMILY_PAGE :
1314 ASSERT(pDesc, "Wo ist der PageDescriptor");
1316 if( rDoc.FindPageDescByName( pDesc->GetName(), &nPgDscPos ))
1318 pNewDsc = new SwPageDesc( *pDesc );
1319 // --> OD 2005-05-09 #i48949# - no undo actions for the
1320 // copy of the page style
1321 const sal_Bool bDoesUndo( rDoc.DoesUndo() );
1322 rDoc.DoUndo( sal_False );
1323 rDoc.CopyPageDesc(*pDesc, *pNewDsc); // #i7983#
1324 rDoc.DoUndo( bDoesUndo );
1325 // <--
1327 pFmt = &pNewDsc->GetMaster();
1330 break;
1332 case SFX_STYLE_FAMILY_PSEUDO:
1334 ASSERT(pNumRule, "Wo ist die NumRule");
1336 if (!pNumRule)
1337 break;
1339 const SfxPoolItem* pItem;
1340 switch( rSet.GetItemState( SID_ATTR_NUMBERING_RULE, FALSE, &pItem ))
1342 case SFX_ITEM_SET:
1344 SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule();
1345 pSetRule->UnLinkGraphics();
1346 //SwNumRule aSetRule(rDoc.GetUniqueNumRuleName());
1347 SwNumRule aSetRule(*pNumRule);
1348 aSetRule.SetSvxRule(*pSetRule, &rDoc);
1349 rDoc.ChgNumRuleFmts( aSetRule );
1351 break;
1352 case SFX_ITEM_DONTCARE:
1353 // NumRule auf default Werte
1354 // was sind die default Werte?
1356 // --> OD 2008-02-11 #newlistlevelattrs#
1357 SwNumRule aRule( pNumRule->GetName(),
1358 // --> OD 2008-06-06 #i89178#
1359 numfunc::GetDefaultPositionAndSpaceMode() );
1360 // <--
1361 // <--
1362 rDoc.ChgNumRuleFmts( aRule );
1364 break;
1367 break;
1369 default:
1370 ASSERT(!this, "unbekannte Style-Familie");
1373 if( pFmt && rSet.Count())
1375 SfxItemIter aIter( rSet );
1376 const SfxPoolItem* pItem = aIter.GetCurItem();
1377 while( TRUE )
1379 if( IsInvalidItem( pItem ) ) // Clearen
1381 // --> OD 2008-02-12 #newlistlevelattrs#
1382 // use method <SwDoc::ResetAttrAtFormat(..)> in order to
1383 // create an Undo object for the attribute reset.
1384 // pFmt->ResetAttr( rSet.GetWhichByPos(aIter.GetCurPos()));
1385 rDoc.ResetAttrAtFormat( rSet.GetWhichByPos(aIter.GetCurPos()),
1386 *pFmt );
1389 if( aIter.IsAtEnd() )
1390 break;
1391 pItem = aIter.NextItem();
1393 SfxItemSet aSet(rSet);
1394 aSet.ClearInvalidItems();
1396 aCoreSet.ClearItem();
1398 if( pNewDsc )
1400 ::ItemSetToPageDesc( aSet, *pNewDsc );
1401 rDoc.ChgPageDesc( nPgDscPos, *pNewDsc );
1402 pDesc = &const_cast<const SwDoc &>(rDoc).GetPageDesc( nPgDscPos );
1403 rDoc.PreDelPageDesc(pNewDsc); // #i7983#
1404 delete pNewDsc;
1406 else
1407 rDoc.ChgFmt(*pFmt, aSet); // alles gesetzten Putten
1409 else
1411 aCoreSet.ClearItem();
1412 if( pNewDsc ) // den muessen wir noch vernichten!!
1414 rDoc.PreDelPageDesc(pNewDsc); // #i7983#
1415 delete pNewDsc;
1419 // --> OD 2008-02-12 #newlistlevelattrs#
1420 if ( rDoc.DoesUndo() )
1422 rDoc.EndUndo( UNDO_INSFMTATTR, NULL );
1424 // <--
1427 void lcl_SaveStyles( USHORT nFamily, SvPtrarr& rArr, SwDoc& rDoc )
1429 switch( nFamily )
1431 case SFX_STYLE_FAMILY_CHAR:
1433 const SwCharFmts& rTbl = *rDoc.GetCharFmts();
1434 for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1436 void* p = (void*)rTbl[ n ];
1437 rArr.Insert( p, n );
1440 break;
1441 case SFX_STYLE_FAMILY_PARA:
1443 const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls();
1444 for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1446 void* p = (void*)rTbl[ n ];
1447 rArr.Insert( p, n );
1450 break;
1451 case SFX_STYLE_FAMILY_FRAME:
1453 const SwFrmFmts& rTbl = *rDoc.GetFrmFmts();
1454 for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1456 void* p = (void*)rTbl[ n ];
1457 rArr.Insert( p, n );
1460 break;
1462 case SFX_STYLE_FAMILY_PAGE:
1464 for( sal_uInt16 n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
1466 void* p =
1467 (void*)&const_cast<const SwDoc &>(rDoc).GetPageDesc( n );
1468 rArr.Insert( p, n );
1471 break;
1473 case SFX_STYLE_FAMILY_PSEUDO:
1475 const SwNumRuleTbl& rTbl = rDoc.GetNumRuleTbl();
1476 for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1478 void* p = (void*)rTbl[ n ];
1479 rArr.Insert( p, n );
1482 break;
1486 void lcl_DeleteInfoStyles( USHORT nFamily, SvPtrarr& rArr, SwDoc& rDoc )
1488 sal_uInt16 n, nCnt;
1489 switch( nFamily )
1491 case SFX_STYLE_FAMILY_CHAR:
1493 SvUShorts aDelArr;
1494 const SwCharFmts& rTbl = *rDoc.GetCharFmts();
1495 for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1497 void* p = (void*)rTbl[ n ];
1498 if( USHRT_MAX == rArr.GetPos( p ))
1499 aDelArr.Insert( n, 0 );
1501 for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
1502 rDoc.DelCharFmt( aDelArr[ n ] );
1504 break;
1506 case SFX_STYLE_FAMILY_PARA :
1508 SvUShorts aDelArr;
1509 const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls();
1510 for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1512 void* p = (void*)rTbl[ n ];
1513 if( USHRT_MAX == rArr.GetPos( p ))
1514 aDelArr.Insert( n, 0 );
1516 for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
1517 rDoc.DelTxtFmtColl( aDelArr[ n ] );
1519 break;
1521 case SFX_STYLE_FAMILY_FRAME:
1523 SvPtrarr aDelArr;
1524 const SwFrmFmts& rTbl = *rDoc.GetFrmFmts();
1525 for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1527 void* p = (void*)rTbl[ n ];
1528 if( USHRT_MAX == rArr.GetPos( p ))
1529 aDelArr.Insert( p, 0 );
1531 for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
1532 rDoc.DelFrmFmt( (SwFrmFmt*)aDelArr[ n ] );
1534 break;
1536 case SFX_STYLE_FAMILY_PAGE:
1538 SvUShorts aDelArr;
1539 for( n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
1541 void* p =
1542 (void*)&const_cast<const SwDoc &>(rDoc).GetPageDesc( n );
1543 if( USHRT_MAX == rArr.GetPos( p ))
1544 aDelArr.Insert( n, 0 );
1546 for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
1547 rDoc.DelPageDesc( aDelArr[ n ] );
1549 break;
1552 case SFX_STYLE_FAMILY_PSEUDO:
1554 SvPtrarr aDelArr;
1555 const SwNumRuleTbl& rTbl = rDoc.GetNumRuleTbl();
1556 for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n )
1558 void* p = (void*)rTbl[ n ];
1559 if( USHRT_MAX == rArr.GetPos( p ))
1560 aDelArr.Insert( p, 0 );
1562 for( n = 0, nCnt = aDelArr.Count(); n < nCnt; ++n )
1563 rDoc.DelNumRule( ((SwNumRule*)aDelArr[ n ])->GetName() );
1565 break;
1569 /*--------------------------------------------------------------------
1570 Beschreibung: Das Format ermitteln
1571 --------------------------------------------------------------------*/
1573 BOOL SwDocStyleSheet::FillStyleSheet( FillStyleType eFType )
1575 BOOL bRet = FALSE;
1576 USHORT nPoolId = USHRT_MAX;
1577 SwFmt* pFmt = 0;
1579 BOOL bCreate = FillPhysical == eFType;
1580 BOOL bDeleteInfo = FALSE;
1581 BOOL bFillOnlyInfo = FillAllInfo == eFType;
1582 SvPtrarr aDelArr;
1584 switch(nFamily)
1586 case SFX_STYLE_FAMILY_CHAR:
1587 pCharFmt = lcl_FindCharFmt(rDoc, aName, this, bCreate );
1588 bPhysical = 0 != pCharFmt;
1589 if( bFillOnlyInfo && !bPhysical )
1591 bDeleteInfo = TRUE;
1592 ::lcl_SaveStyles( static_cast< USHORT >(nFamily), aDelArr, rDoc );
1593 pCharFmt = lcl_FindCharFmt(rDoc, aName, this, TRUE );
1596 pFmt = pCharFmt;
1597 if( !bCreate && !pFmt )
1599 if( aName == *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
1600 RES_POOLCOLL_TEXT_BEGIN ] )
1601 nPoolId = 0;
1602 else
1603 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
1606 bRet = 0 != pCharFmt || USHRT_MAX != nPoolId;
1608 if( bDeleteInfo )
1609 pCharFmt = 0;
1610 break;
1612 case SFX_STYLE_FAMILY_PARA:
1614 pColl = lcl_FindParaFmt(rDoc, aName, this, bCreate);
1615 bPhysical = 0 != pColl;
1616 if( bFillOnlyInfo && !bPhysical )
1618 bDeleteInfo = TRUE;
1619 ::lcl_SaveStyles( static_cast< USHORT >(nFamily), aDelArr, rDoc );
1620 pColl = lcl_FindParaFmt(rDoc, aName, this, TRUE );
1623 pFmt = pColl;
1624 if( pColl )
1625 PresetFollow( pColl->GetNextTxtFmtColl().GetName() );
1626 else if( !bCreate )
1627 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
1629 bRet = 0 != pColl || USHRT_MAX != nPoolId;
1631 if( bDeleteInfo )
1632 pColl = 0;
1634 break;
1636 case SFX_STYLE_FAMILY_FRAME:
1637 pFrmFmt = lcl_FindFrmFmt(rDoc, aName, this, bCreate);
1638 bPhysical = 0 != pFrmFmt;
1639 if( bFillOnlyInfo && bPhysical )
1641 bDeleteInfo = TRUE;
1642 ::lcl_SaveStyles( static_cast< USHORT >(nFamily), aDelArr, rDoc );
1643 pFrmFmt = lcl_FindFrmFmt(rDoc, aName, this, TRUE );
1645 pFmt = pFrmFmt;
1646 if( !bCreate && !pFmt )
1647 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT );
1649 bRet = 0 != pFrmFmt || USHRT_MAX != nPoolId;
1651 if( bDeleteInfo )
1652 pFrmFmt = 0;
1653 break;
1655 case SFX_STYLE_FAMILY_PAGE:
1656 pDesc = lcl_FindPageDesc(rDoc, aName, this, bCreate);
1657 bPhysical = 0 != pDesc;
1658 if( bFillOnlyInfo && !pDesc )
1660 bDeleteInfo = TRUE;
1661 ::lcl_SaveStyles( static_cast< USHORT >(nFamily), aDelArr, rDoc );
1662 pDesc = lcl_FindPageDesc( rDoc, aName, this, TRUE );
1665 if( pDesc )
1667 nPoolId = pDesc->GetPoolFmtId();
1668 nHelpId = pDesc->GetPoolHelpId();
1669 if( pDesc->GetPoolHlpFileId() != UCHAR_MAX )
1670 aHelpFile = *rDoc.GetDocPattern( pDesc->GetPoolHlpFileId() );
1671 else
1672 aHelpFile.Erase();
1674 else if( !bCreate )
1675 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
1676 SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 );
1678 bRet = 0 != pDesc || USHRT_MAX != nPoolId;
1679 if( bDeleteInfo )
1680 pDesc = 0;
1681 break;
1683 case SFX_STYLE_FAMILY_PSEUDO:
1684 pNumRule = lcl_FindNumRule(rDoc, aName, this, bCreate);
1685 bPhysical = 0 != pNumRule;
1686 if( bFillOnlyInfo && !pNumRule )
1688 bDeleteInfo = TRUE;
1689 ::lcl_SaveStyles( static_cast< USHORT >(nFamily), aDelArr, rDoc );
1690 pNumRule = lcl_FindNumRule( rDoc, aName, this, TRUE );
1693 if( pNumRule )
1695 nPoolId = pNumRule->GetPoolFmtId();
1696 nHelpId = pNumRule->GetPoolHelpId();
1697 if( pNumRule->GetPoolHlpFileId() != UCHAR_MAX )
1698 aHelpFile = *rDoc.GetDocPattern( pNumRule->GetPoolHlpFileId() );
1699 else
1700 aHelpFile.Erase();
1702 else if( !bCreate )
1703 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
1704 SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 );
1706 bRet = 0 != pNumRule || USHRT_MAX != nPoolId;
1708 if( bDeleteInfo )
1709 pNumRule = 0;
1710 break;
1711 default:; //prevent warning
1714 if( SFX_STYLE_FAMILY_CHAR == nFamily ||
1715 SFX_STYLE_FAMILY_PARA == nFamily ||
1716 SFX_STYLE_FAMILY_FRAME == nFamily )
1718 if( pFmt )
1719 nPoolId = pFmt->GetPoolFmtId();
1721 USHORT _nMask = 0;
1722 if( pFmt == rDoc.GetDfltCharFmt() )
1723 _nMask |= SFXSTYLEBIT_READONLY;
1724 else if( USER_FMT & nPoolId )
1725 _nMask |= SFXSTYLEBIT_USERDEF;
1727 switch ( COLL_GET_RANGE_BITS & nPoolId )
1729 case COLL_TEXT_BITS: _nMask |= SWSTYLEBIT_TEXT; break;
1730 case COLL_DOC_BITS : _nMask |= SWSTYLEBIT_CHAPTER; break;
1731 case COLL_LISTS_BITS: _nMask |= SWSTYLEBIT_LIST; break;
1732 case COLL_REGISTER_BITS: _nMask |= SWSTYLEBIT_IDX; break;
1733 case COLL_EXTRA_BITS: _nMask |= SWSTYLEBIT_EXTRA; break;
1734 case COLL_HTML_BITS: _nMask |= SWSTYLEBIT_HTML; break;
1737 if( pFmt )
1739 ASSERT( bPhysical, "Format nicht gefunden" );
1741 nHelpId = pFmt->GetPoolHelpId();
1742 if( pFmt->GetPoolHlpFileId() != UCHAR_MAX )
1743 aHelpFile = *rDoc.GetDocPattern( pFmt->GetPoolHlpFileId() );
1744 else
1745 aHelpFile.Erase();
1747 if( RES_CONDTXTFMTCOLL == pFmt->Which() )
1748 _nMask |= SWSTYLEBIT_CONDCOLL;
1751 SetMask( _nMask );
1753 if( bDeleteInfo && bFillOnlyInfo )
1754 ::lcl_DeleteInfoStyles( static_cast< USHORT >(nFamily), aDelArr, rDoc );
1755 return bRet;
1758 /*--------------------------------------------------------------------
1759 Beschreibung: Neues Format in der Core anlegen
1760 --------------------------------------------------------------------*/
1763 void SwDocStyleSheet::Create()
1765 switch(nFamily)
1767 case SFX_STYLE_FAMILY_CHAR :
1768 pCharFmt = lcl_FindCharFmt( rDoc, aName );
1769 if( !pCharFmt )
1770 pCharFmt = rDoc.MakeCharFmt(aName,
1771 rDoc.GetDfltCharFmt());
1772 pCharFmt->SetAuto( FALSE );
1773 break;
1775 case SFX_STYLE_FAMILY_PARA :
1776 pColl = lcl_FindParaFmt( rDoc, aName );
1777 if( !pColl )
1779 SwTxtFmtColl *pPar = (*rDoc.GetTxtFmtColls())[0];
1780 if( nMask & SWSTYLEBIT_CONDCOLL )
1781 pColl = rDoc.MakeCondTxtFmtColl( aName, pPar );
1782 else
1783 pColl = rDoc.MakeTxtFmtColl( aName, pPar );
1785 break;
1787 case SFX_STYLE_FAMILY_FRAME:
1788 pFrmFmt = lcl_FindFrmFmt( rDoc, aName );
1789 if( !pFrmFmt )
1790 pFrmFmt = rDoc.MakeFrmFmt(aName, rDoc.GetDfltFrmFmt(), FALSE, FALSE);
1792 break;
1794 case SFX_STYLE_FAMILY_PAGE :
1795 pDesc = lcl_FindPageDesc( rDoc, aName );
1796 if( !pDesc )
1798 USHORT nId = rDoc.MakePageDesc(aName);
1799 pDesc = &const_cast<const SwDoc &>(rDoc).GetPageDesc(nId);
1801 break;
1803 case SFX_STYLE_FAMILY_PSEUDO:
1804 pNumRule = lcl_FindNumRule( rDoc, aName );
1805 if( !pNumRule )
1807 //JP 05.02.99: temp Namen erzeugen, damit kein ASSERT kommt
1808 String sTmpNm( aName );
1809 if( !aName.Len() )
1810 sTmpNm = rDoc.GetUniqueNumRuleName();
1812 // --> OD 2008-02-11 #newlistlevelattrs#
1813 SwNumRule* pRule = rDoc.GetNumRuleTbl()[
1814 rDoc.MakeNumRule( sTmpNm, 0, FALSE,
1815 // --> OD 2008-06-06 #i89178#
1816 numfunc::GetDefaultPositionAndSpaceMode() ) ];
1817 // <--
1818 // <--
1819 pRule->SetAutoRule( FALSE );
1820 if( !aName.Len() )
1822 // --> OD 2008-07-08 #i91400#
1823 pRule->SetName( aName, rDoc );
1824 // <--
1826 pNumRule = pRule;
1828 break;
1829 default:; //prevent warning
1831 bPhysical = TRUE;
1832 aCoreSet.ClearItem();
1835 /*--------------------------------------------------------------------
1836 Beschreibung: Konkrete Formate rausholen
1837 --------------------------------------------------------------------*/
1841 SwCharFmt* SwDocStyleSheet::GetCharFmt()
1843 if(!bPhysical)
1844 FillStyleSheet( FillPhysical );
1845 return pCharFmt;
1849 SwTxtFmtColl* SwDocStyleSheet::GetCollection()
1851 if(!bPhysical)
1852 FillStyleSheet( FillPhysical );
1853 return pColl;
1857 const SwPageDesc* SwDocStyleSheet::GetPageDesc()
1859 if(!bPhysical)
1860 FillStyleSheet( FillPhysical );
1861 return pDesc;
1864 const SwNumRule * SwDocStyleSheet::GetNumRule()
1866 if(!bPhysical)
1867 FillStyleSheet( FillPhysical );
1868 return pNumRule;
1871 void SwDocStyleSheet::SetNumRule(const SwNumRule& rRule)
1873 DBG_ASSERT(pNumRule, "Wo ist die NumRule");
1874 rDoc.ChgNumRuleFmts( rRule );
1877 // Namen UND Familie aus String re-generieren
1878 // First() und Next() (s.u.) fuegen einen Kennbuchstaben an Pos.1 ein
1880 void SwDocStyleSheet::PresetNameAndFamily(const String& rName)
1882 switch( rName.GetChar(0) )
1884 case cPARA: nFamily = SFX_STYLE_FAMILY_PARA; break;
1885 case cFRAME: nFamily = SFX_STYLE_FAMILY_FRAME; break;
1886 case cPAGE: nFamily = SFX_STYLE_FAMILY_PAGE; break;
1887 case cNUMRULE: nFamily = SFX_STYLE_FAMILY_PSEUDO; break;
1888 default: nFamily = SFX_STYLE_FAMILY_CHAR; break;
1890 aName = rName;
1891 aName.Erase( 0, 1 );
1894 /*--------------------------------------------------------------------
1895 Beschreibung: Ist das Format physikalisch schon vorhanden
1896 --------------------------------------------------------------------*/
1899 void SwDocStyleSheet::SetPhysical(BOOL bPhys)
1901 bPhysical = bPhys;
1903 if(!bPhys)
1905 pCharFmt = 0;
1906 pColl = 0;
1907 pFrmFmt = 0;
1908 pDesc = 0;
1912 SwFrmFmt* SwDocStyleSheet::GetFrmFmt()
1914 if(!bPhysical)
1915 FillStyleSheet( FillPhysical );
1916 return pFrmFmt;
1920 BOOL SwDocStyleSheet::IsUsed() const
1922 if( !bPhysical )
1924 SwDocStyleSheet* pThis = (SwDocStyleSheet*)this;
1925 pThis->FillStyleSheet( FillOnlyName );
1928 // immer noch nicht ?
1929 if( !bPhysical )
1930 return FALSE;
1932 const SwModify* pMod;
1933 switch( nFamily )
1935 case SFX_STYLE_FAMILY_CHAR : pMod = pCharFmt; break;
1936 case SFX_STYLE_FAMILY_PARA : pMod = pColl; break;
1937 case SFX_STYLE_FAMILY_FRAME: pMod = pFrmFmt; break;
1938 case SFX_STYLE_FAMILY_PAGE : pMod = pDesc; break;
1940 case SFX_STYLE_FAMILY_PSEUDO:
1941 return pNumRule ? rDoc.IsUsed( *pNumRule ) : FALSE;
1943 default:
1944 ASSERT(!this, "unbekannte Style-Familie");
1945 return FALSE;
1947 return rDoc.IsUsed( *pMod );
1951 ULONG SwDocStyleSheet::GetHelpId( String& rFile )
1953 static String sTemplateHelpFile = String::CreateFromAscii("swrhlppi.hlp");
1955 USHORT nId = 0;
1956 USHORT nPoolId = 0;
1957 unsigned char nFileId = UCHAR_MAX;
1959 rFile = sTemplateHelpFile;
1961 const SwFmt* pTmpFmt = 0;
1962 switch( nFamily )
1964 case SFX_STYLE_FAMILY_CHAR :
1965 if( !pCharFmt &&
1966 0 == (pCharFmt = lcl_FindCharFmt( rDoc, aName, 0, FALSE )) )
1968 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
1969 return USHRT_MAX == nId ? 0 : nId;
1971 pTmpFmt = pCharFmt;
1972 break;
1974 case SFX_STYLE_FAMILY_PARA:
1975 if( !pColl &&
1976 0 == ( pColl = lcl_FindParaFmt( rDoc, aName, 0, FALSE )) )
1978 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
1979 return USHRT_MAX == nId ? 0 : nId;
1981 pTmpFmt = pColl;
1982 break;
1984 case SFX_STYLE_FAMILY_FRAME:
1985 if( !pFrmFmt &&
1986 0 == ( pFrmFmt = lcl_FindFrmFmt( rDoc, aName, 0, FALSE ) ) )
1988 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT );
1989 return USHRT_MAX == nId ? 0 : nId;
1991 pTmpFmt = pFrmFmt;
1992 break;
1994 case SFX_STYLE_FAMILY_PAGE:
1995 if( !pDesc &&
1996 0 == ( pDesc = lcl_FindPageDesc( rDoc, aName, 0, FALSE ) ) )
1998 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
1999 return USHRT_MAX == nId ? 0 : nId;
2002 nId = pDesc->GetPoolHelpId();
2003 nFileId = pDesc->GetPoolHlpFileId();
2004 nPoolId = pDesc->GetPoolFmtId();
2005 break;
2007 case SFX_STYLE_FAMILY_PSEUDO:
2008 if( !pNumRule &&
2009 0 == ( pNumRule = lcl_FindNumRule( rDoc, aName, 0, FALSE ) ) )
2011 nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
2012 return USHRT_MAX == nId ? 0 : nId;
2015 nId = pNumRule->GetPoolHelpId();
2016 nFileId = pNumRule->GetPoolHlpFileId();
2017 nPoolId = pNumRule->GetPoolFmtId();
2018 break;
2020 default:
2021 ASSERT(!this, "unbekannte Style-Familie");
2022 return 0;
2025 if( pTmpFmt )
2027 nId = pTmpFmt->GetPoolHelpId();
2028 nFileId = pTmpFmt->GetPoolHlpFileId();
2029 nPoolId = pTmpFmt->GetPoolFmtId();
2032 if( UCHAR_MAX != nFileId )
2034 const String *pTemplate = rDoc.GetDocPattern( nFileId );
2035 if( pTemplate )
2037 // const String aHelpPath(MakeHelpPath(*pTemplate));
2038 rFile = *pTemplate;
2041 else if( !IsPoolUserFmt( nPoolId ) )
2043 nId = nPoolId;
2046 // weil sich der SFX so anstellt mit der HilfeId:
2047 if( USHRT_MAX == nId )
2048 nId = 0; // entsp. keine Hilfe anzeigen
2050 return nId;
2054 void SwDocStyleSheet::SetHelpId( const String& r, ULONG nId )
2056 BYTE nFileId = static_cast< BYTE >(rDoc.SetDocPattern( r ));
2057 USHORT nHId = static_cast< USHORT >(nId); //!! SFX hat eigenmaechtig auf ULONG umgestellt!
2059 SwFmt* pTmpFmt = 0;
2060 switch( nFamily )
2062 case SFX_STYLE_FAMILY_CHAR : pTmpFmt = pCharFmt; break;
2063 case SFX_STYLE_FAMILY_PARA : pTmpFmt = pColl; break;
2064 case SFX_STYLE_FAMILY_FRAME: pTmpFmt = pFrmFmt; break;
2065 case SFX_STYLE_FAMILY_PAGE :
2066 ((SwPageDesc*)pDesc)->SetPoolHelpId( nHId );
2067 ((SwPageDesc*)pDesc)->SetPoolHlpFileId( nFileId );
2068 break;
2070 case SFX_STYLE_FAMILY_PSEUDO:
2071 ((SwNumRule*)pNumRule)->SetPoolHelpId( nHId );
2072 ((SwNumRule*)pNumRule)->SetPoolHlpFileId( nFileId );
2073 break;
2075 default:
2076 ASSERT(!this, "unbekannte Style-Familie");
2077 return ;
2079 if( pTmpFmt )
2081 pTmpFmt->SetPoolHelpId( nHId );
2082 pTmpFmt->SetPoolHlpFileId( nFileId );
2087 /* \f */
2089 /*--------------------------------------------------------------------
2090 Beschreibung: Methoden fuer den DocStyleSheetPool
2091 --------------------------------------------------------------------*/
2093 SwDocStyleSheetPool::SwDocStyleSheetPool( SwDoc& rDocument, BOOL bOrg )
2094 : SfxStyleSheetBasePool( rDocument.GetAttrPool() )
2095 , mxStyleSheet( new SwDocStyleSheet( rDocument, aEmptyStr, *this, SFX_STYLE_FAMILY_CHAR, 0 ) )
2096 , rDoc( rDocument )
2098 bOrganizer = bOrg;
2101 SwDocStyleSheetPool::~SwDocStyleSheetPool()
2105 void SAL_CALL SwDocStyleSheetPool::acquire( ) throw ()
2107 comphelper::OWeakTypeObject::acquire();
2110 void SAL_CALL SwDocStyleSheetPool::release( ) throw ()
2112 comphelper::OWeakTypeObject::release();
2115 SfxStyleSheetBase& SwDocStyleSheetPool::Make(
2116 const String& rName,
2117 SfxStyleFamily eFam,
2118 USHORT _nMask,
2119 USHORT /*nPos*/ )
2121 mxStyleSheet->PresetName(rName);
2122 mxStyleSheet->PresetParent(aEmptyStr);
2123 mxStyleSheet->PresetFollow(aEmptyStr);
2124 mxStyleSheet->SetMask(_nMask) ;
2125 mxStyleSheet->SetFamily(eFam);
2126 mxStyleSheet->SetPhysical(TRUE);
2127 mxStyleSheet->Create();
2129 return *mxStyleSheet.get();
2133 SfxStyleSheetBase* SwDocStyleSheetPool::Create( const SfxStyleSheetBase& /*rOrg*/)
2135 ASSERT(!this , "Create im SW-Stylesheet-Pool geht nicht" );
2136 return NULL;
2140 SfxStyleSheetBase* SwDocStyleSheetPool::Create( const String &,
2141 SfxStyleFamily, USHORT )
2143 ASSERT( !this, "Create im SW-Stylesheet-Pool geht nicht" );
2144 return NULL;
2147 void SwDocStyleSheetPool::Replace( SfxStyleSheetBase& rSource,
2148 SfxStyleSheetBase& rTarget )
2150 SfxStyleFamily eFamily( rSource.GetFamily() );
2151 if( rSource.HasParentSupport())
2153 const String& rParentName = rSource.GetParent();
2154 if( 0 != rParentName.Len() )
2156 SfxStyleSheetBase* pParentOfNew = Find( rParentName, eFamily );
2157 if( pParentOfNew )
2158 rTarget.SetParent( rParentName );
2161 if( rSource.HasFollowSupport())
2163 const String& rFollowName = rSource.GetFollow();
2164 if( 0 != rFollowName.Len() )
2166 SfxStyleSheetBase* pFollowOfNew = Find( rFollowName, eFamily );
2167 if( pFollowOfNew )
2168 rTarget.SetFollow( rFollowName );
2172 SwImplShellAction aTmpSh( rDoc );
2174 BOOL bSwSrcPool = GetAppName() == rSource.GetPool().GetAppName();
2175 if( SFX_STYLE_FAMILY_PAGE == eFamily && bSwSrcPool )
2177 // gesondert behandeln!!
2178 SwPageDesc* pDestDsc =
2179 (SwPageDesc*)((SwDocStyleSheet&)rTarget).GetPageDesc();
2180 SwPageDesc* pCpyDsc =
2181 (SwPageDesc*)((SwDocStyleSheet&)rSource).GetPageDesc();
2182 rDoc.CopyPageDesc( *pCpyDsc, *pDestDsc );
2184 else
2186 const SwFmt *pSourceFmt = 0;
2187 SwFmt *pTargetFmt = 0;
2188 USHORT nPgDscPos = USHRT_MAX;
2189 switch( eFamily )
2191 case SFX_STYLE_FAMILY_CHAR :
2192 if( bSwSrcPool )
2193 pSourceFmt = ((SwDocStyleSheet&)rSource).GetCharFmt();
2194 pTargetFmt = ((SwDocStyleSheet&)rTarget).GetCharFmt();
2195 break;
2196 case SFX_STYLE_FAMILY_PARA :
2197 if( bSwSrcPool )
2198 pSourceFmt = ((SwDocStyleSheet&)rSource).GetCollection();
2199 pTargetFmt = ((SwDocStyleSheet&)rTarget).GetCollection();
2200 break;
2201 case SFX_STYLE_FAMILY_FRAME:
2202 if( bSwSrcPool )
2203 pSourceFmt = ((SwDocStyleSheet&)rSource).GetFrmFmt();
2204 pTargetFmt = ((SwDocStyleSheet&)rTarget).GetFrmFmt();
2205 break;
2206 case SFX_STYLE_FAMILY_PAGE:
2207 if( bSwSrcPool )
2208 pSourceFmt = &((SwDocStyleSheet&)rSource).GetPageDesc()
2209 ->GetMaster();
2211 SwPageDesc *pDesc = rDoc.FindPageDescByName(
2212 ((SwDocStyleSheet&)rTarget).GetPageDesc()->GetName(),
2213 &nPgDscPos );
2215 if( pDesc )
2216 pTargetFmt = &pDesc->GetMaster();
2218 break;
2219 case SFX_STYLE_FAMILY_PSEUDO:
2220 // Eine NumRule besteht nur aus einem Item, also muss man
2221 // hier nichts loeschen.
2222 break;
2223 default:; //prevent warning
2225 if( pTargetFmt )
2227 if( pSourceFmt )
2228 pTargetFmt->DelDiffs( *pSourceFmt );
2229 else if( USHRT_MAX != nPgDscPos )
2230 pTargetFmt->ResetFmtAttr( RES_PAGEDESC, RES_FRMATR_END-1 );
2231 else
2233 // --> OD 2007-01-25 #i73790# - method renamed
2234 pTargetFmt->ResetAllFmtAttr();
2235 // <--
2238 if( USHRT_MAX != nPgDscPos )
2239 rDoc.ChgPageDesc( nPgDscPos,
2240 const_cast<const SwDoc &>(rDoc).
2241 GetPageDesc(nPgDscPos) );
2243 ((SwDocStyleSheet&)rTarget).SetItemSet( rSource.GetItemSet() );
2247 SfxStyleSheetIterator* SwDocStyleSheetPool::CreateIterator(
2248 SfxStyleFamily eFam, USHORT _nMask )
2250 return new SwStyleSheetIterator( this, eFam, _nMask );
2253 void SwDocStyleSheetPool::dispose()
2255 mxStyleSheet.clear();
2258 void SwDocStyleSheetPool::Remove( SfxStyleSheetBase* pStyle)
2260 if( !pStyle )
2261 return;
2263 BOOL bBroadcast = TRUE;
2264 SwImplShellAction aTmpSh( rDoc );
2265 const String& rName = pStyle->GetName();
2266 switch( pStyle->GetFamily() )
2268 case SFX_STYLE_FAMILY_CHAR:
2270 SwCharFmt* pFmt = lcl_FindCharFmt(rDoc, rName, 0, FALSE );
2271 if(pFmt)
2272 rDoc.DelCharFmt(pFmt);
2274 break;
2275 case SFX_STYLE_FAMILY_PARA:
2277 SwTxtFmtColl* pColl = lcl_FindParaFmt(rDoc, rName, 0, FALSE );
2278 if(pColl)
2279 rDoc.DelTxtFmtColl(pColl);
2281 break;
2282 case SFX_STYLE_FAMILY_FRAME:
2284 SwFrmFmt* pFmt = lcl_FindFrmFmt(rDoc, rName, 0, FALSE );
2285 if(pFmt)
2286 rDoc.DelFrmFmt(pFmt);
2288 break;
2289 case SFX_STYLE_FAMILY_PAGE :
2291 USHORT nPos;
2292 if( rDoc.FindPageDescByName( rName, &nPos ))
2293 rDoc.DelPageDesc( nPos );
2295 break;
2297 case SFX_STYLE_FAMILY_PSEUDO:
2299 if( !rDoc.DelNumRule( rName ) )
2300 // Broadcast nur versenden, wenn etwas geloescht wurde
2301 bBroadcast = FALSE;
2303 break;
2305 default:
2306 ASSERT(!this, "unbekannte Style-Familie");
2307 bBroadcast = FALSE;
2310 if( bBroadcast )
2311 Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *pStyle ) );
2316 BOOL SwDocStyleSheetPool::SetParent( SfxStyleFamily eFam,
2317 const String &rStyle, const String &rParent )
2319 SwFmt* pFmt = 0, *pParent = 0;
2320 switch( eFam )
2322 case SFX_STYLE_FAMILY_CHAR :
2323 if( 0 != ( pFmt = lcl_FindCharFmt( rDoc, rStyle ) ) && rParent.Len() )
2324 pParent = lcl_FindCharFmt(rDoc, rParent );
2325 break;
2327 case SFX_STYLE_FAMILY_PARA :
2328 if( 0 != ( pFmt = lcl_FindParaFmt( rDoc, rStyle ) ) && rParent.Len() )
2329 pParent = lcl_FindParaFmt( rDoc, rParent );
2330 break;
2332 case SFX_STYLE_FAMILY_FRAME:
2333 if( 0 != ( pFmt = lcl_FindFrmFmt( rDoc, rStyle ) ) && rParent.Len() )
2334 pParent = lcl_FindFrmFmt( rDoc, rParent );
2335 break;
2337 case SFX_STYLE_FAMILY_PAGE:
2338 case SFX_STYLE_FAMILY_PSEUDO:
2339 break;
2341 default:
2342 ASSERT(!this, "unbekannte Style-Familie");
2345 BOOL bRet = FALSE;
2346 if( pFmt && pFmt->DerivedFrom() &&
2347 pFmt->DerivedFrom()->GetName() != rParent )
2350 SwImplShellAction aTmpSh( rDoc );
2351 bRet = pFmt->SetDerivedFrom( pParent );
2354 if( bRet )
2356 // nur fuer das Broadcasting
2357 mxStyleSheet->PresetName( rStyle );
2358 mxStyleSheet->PresetParent( rParent );
2359 if( SFX_STYLE_FAMILY_PARA == eFam )
2360 mxStyleSheet->PresetFollow( ((SwTxtFmtColl*)pFmt)->
2361 GetNextTxtFmtColl().GetName() );
2362 else
2363 mxStyleSheet->PresetFollow( aEmptyStr );
2365 Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED,
2366 *(mxStyleSheet.get()) ) );
2370 return bRet;
2373 SfxStyleSheetBase* SwDocStyleSheetPool::Find( const String& rName,
2374 SfxStyleFamily eFam, USHORT n )
2376 USHORT nSMask = n;
2377 if( SFX_STYLE_FAMILY_PARA == eFam && rDoc.get(IDocumentSettingAccess::HTML_MODE) )
2379 // dann sind nur HTML-Vorlagen von Interesse
2380 if( USHRT_MAX == nSMask )
2381 nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED;
2382 else
2383 nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF |
2384 SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML;
2385 if( !nSMask )
2386 nSMask = SWSTYLEBIT_HTML;
2389 const BOOL bSearchUsed = ( n != SFXSTYLEBIT_ALL &&
2390 n & SFXSTYLEBIT_USED ) ? TRUE : FALSE;
2391 const SwModify* pMod = 0;
2393 mxStyleSheet->SetPhysical( FALSE );
2394 mxStyleSheet->PresetName( rName );
2395 mxStyleSheet->SetFamily( eFam );
2396 BOOL bFnd = mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2398 if( mxStyleSheet->IsPhysical() )
2400 switch( eFam )
2402 case SFX_STYLE_FAMILY_CHAR:
2403 pMod = mxStyleSheet->GetCharFmt();
2404 break;
2406 case SFX_STYLE_FAMILY_PARA:
2407 pMod = mxStyleSheet->GetCollection();
2408 break;
2410 case SFX_STYLE_FAMILY_FRAME:
2411 pMod = mxStyleSheet->GetFrmFmt();
2412 break;
2414 case SFX_STYLE_FAMILY_PAGE:
2415 pMod = mxStyleSheet->GetPageDesc();
2416 break;
2418 case SFX_STYLE_FAMILY_PSEUDO:
2420 const SwNumRule* pRule = mxStyleSheet->GetNumRule();
2421 if( pRule &&
2422 !(bSearchUsed && (bOrganizer || rDoc.IsUsed(*pRule)) ) &&
2423 (( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2424 ? !(pRule->GetPoolFmtId() & USER_FMT)
2425 // benutzte gesucht und keine gefunden
2426 : bSearchUsed ))
2427 bFnd = FALSE;
2429 break;
2431 default:
2432 ASSERT(!this, "unbekannte Style-Familie");
2436 // dann noch die Maske auswerten:
2437 if( pMod && !(bSearchUsed && (bOrganizer || rDoc.IsUsed(*pMod)) ) )
2439 const USHORT nId = SFX_STYLE_FAMILY_PAGE == eFam
2440 ? ((SwPageDesc*)pMod)->GetPoolFmtId()
2441 : ((SwFmt*)pMod)->GetPoolFmtId();
2443 if( ( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2444 ? !(nId & USER_FMT)
2445 // benutzte gesucht und keine gefunden
2446 : bSearchUsed )
2447 bFnd = FALSE;
2449 return bFnd ? mxStyleSheet.get() : 0;
2452 /* \f */
2454 SwStyleSheetIterator::SwStyleSheetIterator( SwDocStyleSheetPool* pBase,
2455 SfxStyleFamily eFam, USHORT n )
2456 : SfxStyleSheetIterator( pBase, eFam, n ),
2457 mxIterSheet( new SwDocStyleSheet( pBase->GetDoc(), aEmptyStr, *pBase, SFX_STYLE_FAMILY_CHAR, 0 ) ),
2458 mxStyleSheet( new SwDocStyleSheet( pBase->GetDoc(), aEmptyStr, *pBase, SFX_STYLE_FAMILY_CHAR, 0 ) )
2460 bFirstCalled = FALSE;
2461 nLastPos = 0;
2462 StartListening( *pBase );
2465 SwStyleSheetIterator::~SwStyleSheetIterator()
2467 EndListening( mxIterSheet->GetPool() );
2470 USHORT SwStyleSheetIterator::Count()
2472 // Liste richtig fuellen lassen !!
2473 if( !bFirstCalled )
2474 First();
2475 return aLst.Count();
2478 SfxStyleSheetBase* SwStyleSheetIterator::operator[]( USHORT nIdx )
2480 // gefunden
2481 if( !bFirstCalled )
2482 First();
2483 mxStyleSheet->PresetNameAndFamily( *aLst[ nIdx ] );
2484 mxStyleSheet->SetPhysical( FALSE );
2485 mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2487 return mxStyleSheet.get();
2490 SfxStyleSheetBase* SwStyleSheetIterator::First()
2492 // Alte Liste loeschen
2493 bFirstCalled = TRUE;
2494 nLastPos = 0;
2495 aLst.Erase();
2497 // aktuellen loeschen
2498 mxIterSheet->Reset();
2500 SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc();
2501 const USHORT nSrchMask = nMask;
2502 const BOOL bIsSearchUsed = SearchUsed();
2504 const BOOL bOrganizer = ((SwDocStyleSheetPool*)pBasePool)->IsOrganizerMode();
2506 if( nSearchFamily == SFX_STYLE_FAMILY_CHAR
2507 || nSearchFamily == SFX_STYLE_FAMILY_ALL )
2509 const USHORT nArrLen = rDoc.GetCharFmts()->Count();
2510 for( USHORT i = 0; i < nArrLen; i++ )
2512 SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ];
2513 if( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() )
2514 continue;
2516 const BOOL bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(*pFmt));
2517 if( !bUsed )
2519 // Standard ist keine Benutzervorlage #46181#
2520 const USHORT nId = rDoc.GetDfltCharFmt() == pFmt ?
2521 USHORT( RES_POOLCHR_INET_NORMAL ):
2522 pFmt->GetPoolFmtId();
2523 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2524 ? !(nId & USER_FMT)
2525 // benutzte gesucht und keine gefunden
2526 : bIsSearchUsed )
2527 continue;
2529 if( rDoc.get(IDocumentSettingAccess::HTML_MODE) && !(nId & USER_FMT) &&
2530 !( RES_POOLCHR_HTML_BEGIN <= nId &&
2531 nId < RES_POOLCHR_HTML_END ) &&
2532 RES_POOLCHR_INET_NORMAL != nId &&
2533 RES_POOLCHR_INET_VISIT != nId &&
2534 RES_POOLCHR_FOOTNOTE != nId &&
2535 RES_POOLCHR_ENDNOTE != nId )
2536 continue;
2539 aLst.Append( cCHAR, pFmt == rDoc.GetDfltCharFmt()
2540 ? (const String&) *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
2541 RES_POOLCOLL_TEXT_BEGIN ]
2542 : pFmt->GetName() );
2545 // PoolFormate
2547 if( nSrchMask == SFXSTYLEBIT_ALL )
2549 if( !rDoc.get(IDocumentSettingAccess::HTML_MODE) )
2550 AppendStyleList(SwStyleNameMapper::GetChrFmtUINameArray(),
2551 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR);
2552 else
2554 aLst.Append( cCHAR, *SwStyleNameMapper::GetChrFmtUINameArray()[
2555 RES_POOLCHR_INET_NORMAL - RES_POOLCHR_BEGIN ] );
2556 aLst.Append( cCHAR, *SwStyleNameMapper::GetChrFmtUINameArray()[
2557 RES_POOLCHR_INET_VISIT - RES_POOLCHR_BEGIN ] );
2558 aLst.Append( cCHAR, *SwStyleNameMapper::GetChrFmtUINameArray()[
2559 RES_POOLCHR_ENDNOTE - RES_POOLCHR_BEGIN ] );
2560 aLst.Append( cCHAR, *SwStyleNameMapper::GetChrFmtUINameArray()[
2561 RES_POOLCHR_FOOTNOTE - RES_POOLCHR_BEGIN ] );
2563 AppendStyleList(SwStyleNameMapper::GetHTMLChrFmtUINameArray(),
2564 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, cCHAR);
2568 if( nSearchFamily == SFX_STYLE_FAMILY_PARA ||
2569 nSearchFamily == SFX_STYLE_FAMILY_ALL )
2571 USHORT nSMask = nSrchMask;
2572 if( rDoc.get(IDocumentSettingAccess::HTML_MODE) )
2574 // dann sind nur HTML-Vorlagen von Interesse
2575 if( USHRT_MAX == nSMask )
2576 nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF |
2577 SFXSTYLEBIT_USED;
2578 else
2579 nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF |
2580 SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML;
2581 if( !nSMask )
2582 nSMask = SWSTYLEBIT_HTML;
2585 const USHORT nArrLen = rDoc.GetTxtFmtColls()->Count();
2586 for( USHORT i = 0; i < nArrLen; i++ )
2588 SwTxtFmtColl* pColl = (*rDoc.GetTxtFmtColls())[ i ];
2590 if(pColl->IsDefault())
2591 continue;
2593 const BOOL bUsed = bOrganizer || rDoc.IsUsed(*pColl);
2594 if( !(bIsSearchUsed && bUsed ))
2596 const USHORT nId = pColl->GetPoolFmtId();
2597 switch ( (nSMask & ~SFXSTYLEBIT_USED) )
2599 case SFXSTYLEBIT_USERDEF:
2600 if(!IsPoolUserFmt(nId)) continue;
2601 break;
2602 case SWSTYLEBIT_TEXT:
2603 if((nId & COLL_GET_RANGE_BITS) != COLL_TEXT_BITS) continue;
2604 break;
2605 case SWSTYLEBIT_CHAPTER:
2606 if((nId & COLL_GET_RANGE_BITS) != COLL_DOC_BITS) continue;
2607 break;
2608 case SWSTYLEBIT_LIST:
2609 if((nId & COLL_GET_RANGE_BITS) != COLL_LISTS_BITS) continue;
2610 break;
2611 case SWSTYLEBIT_IDX:
2612 if((nId & COLL_GET_RANGE_BITS) != COLL_REGISTER_BITS) continue;
2613 break;
2614 case SWSTYLEBIT_EXTRA:
2615 if((nId & COLL_GET_RANGE_BITS) != COLL_EXTRA_BITS) continue;
2616 break;
2618 case SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF:
2619 if(IsPoolUserFmt(nId))
2620 break;
2621 // ansonten weiter
2622 case SWSTYLEBIT_HTML:
2623 if( (nId & COLL_GET_RANGE_BITS) != COLL_HTML_BITS)
2625 // einige wollen wir aber auch in dieser Section sehen
2626 BOOL bWeiter = TRUE;
2627 switch( nId )
2629 case RES_POOLCOLL_SENDADRESS: // --> ADDRESS
2630 case RES_POOLCOLL_TABLE_HDLN: // --> TH
2631 case RES_POOLCOLL_TABLE: // --> TD
2632 case RES_POOLCOLL_TEXT: // --> P
2633 case RES_POOLCOLL_HEADLINE_BASE:// --> H
2634 case RES_POOLCOLL_HEADLINE1: // --> H1
2635 case RES_POOLCOLL_HEADLINE2: // --> H2
2636 case RES_POOLCOLL_HEADLINE3: // --> H3
2637 case RES_POOLCOLL_HEADLINE4: // --> H4
2638 case RES_POOLCOLL_HEADLINE5: // --> H5
2639 case RES_POOLCOLL_HEADLINE6: // --> H6
2640 case RES_POOLCOLL_STANDARD: // --> P
2641 case RES_POOLCOLL_FOOTNOTE:
2642 case RES_POOLCOLL_ENDNOTE:
2643 bWeiter = FALSE;
2644 break;
2646 if( bWeiter )
2647 continue;
2649 break;
2650 case SWSTYLEBIT_CONDCOLL:
2651 if( RES_CONDTXTFMTCOLL != pColl->Which() ) continue;
2652 break;
2653 default:
2654 // benutzte gesucht und keine gefunden
2655 if( bIsSearchUsed )
2656 continue;
2659 aLst.Append( cPARA, pColl->GetName() );
2662 const BOOL bAll = nSMask == SFXSTYLEBIT_ALL;
2663 if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_TEXT )
2664 AppendStyleList(SwStyleNameMapper::GetTextUINameArray(),
2665 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA );
2666 if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CHAPTER )
2667 AppendStyleList(SwStyleNameMapper::GetDocUINameArray(),
2668 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2669 if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_LIST )
2670 AppendStyleList(SwStyleNameMapper::GetListsUINameArray(),
2671 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2672 if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_IDX )
2673 AppendStyleList(SwStyleNameMapper::GetRegisterUINameArray(),
2674 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2675 if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_EXTRA )
2676 AppendStyleList(SwStyleNameMapper::GetExtraUINameArray(),
2677 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2678 if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CONDCOLL )
2680 if( !bIsSearchUsed ||
2681 rDoc.IsPoolTxtCollUsed( RES_POOLCOLL_TEXT ))
2682 aLst.Append( cPARA, *SwStyleNameMapper::GetTextUINameArray()[
2683 RES_POOLCOLL_TEXT - RES_POOLCOLL_TEXT_BEGIN ] );
2685 if ( bAll ||
2686 (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_HTML ||
2687 (nSMask & ~SFXSTYLEBIT_USED) ==
2688 (SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF) )
2690 AppendStyleList(SwStyleNameMapper::GetHTMLUINameArray(),
2691 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, cPARA ) ;
2692 if( !bAll )
2694 // dann auch die, die wir mappen:
2695 static USHORT aPoolIds[] = {
2696 RES_POOLCOLL_SENDADRESS, // --> ADDRESS
2697 RES_POOLCOLL_TABLE_HDLN, // --> TH
2698 RES_POOLCOLL_TABLE, // --> TD
2699 RES_POOLCOLL_STANDARD, // --> P
2700 RES_POOLCOLL_TEXT, // --> P
2701 RES_POOLCOLL_HEADLINE_BASE, // --> H
2702 RES_POOLCOLL_HEADLINE1, // --> H1
2703 RES_POOLCOLL_HEADLINE2, // --> H2
2704 RES_POOLCOLL_HEADLINE3, // --> H3
2705 RES_POOLCOLL_HEADLINE4, // --> H4
2706 RES_POOLCOLL_HEADLINE5, // --> H5
2707 RES_POOLCOLL_HEADLINE6, // --> H6
2708 RES_POOLCOLL_FOOTNOTE,
2709 RES_POOLCOLL_ENDNOTE,
2713 USHORT* pPoolIds = aPoolIds;
2714 String s;
2715 while( *pPoolIds )
2717 if( !bIsSearchUsed || rDoc.IsPoolTxtCollUsed( *pPoolIds ) )
2718 aLst.Append( cPARA,
2719 s = SwStyleNameMapper::GetUIName( *pPoolIds, s ));
2720 ++pPoolIds;
2726 if( nSearchFamily == SFX_STYLE_FAMILY_FRAME ||
2727 nSearchFamily == SFX_STYLE_FAMILY_ALL )
2729 const USHORT nArrLen = rDoc.GetFrmFmts()->Count();
2730 for( USHORT i = 0; i < nArrLen; i++ )
2732 SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ];
2734 if(pFmt->IsDefault() || pFmt->IsAuto())
2736 continue;
2739 const USHORT nId = pFmt->GetPoolFmtId();
2740 BOOL bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(*pFmt));
2741 if( !bUsed )
2743 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2744 ? !(nId & USER_FMT)
2745 // benutzte gesucht und keine gefunden
2746 : bIsSearchUsed )
2748 continue;
2752 aLst.Append( cFRAME, pFmt->GetName() );
2755 // PoolFormate
2757 if ( nSrchMask == SFXSTYLEBIT_ALL )
2758 AppendStyleList(SwStyleNameMapper::GetFrmFmtUINameArray(),
2759 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, cFRAME);
2762 if( nSearchFamily == SFX_STYLE_FAMILY_PAGE ||
2763 nSearchFamily == SFX_STYLE_FAMILY_ALL )
2765 const USHORT nCount = rDoc.GetPageDescCnt();
2766 for(USHORT i = 0; i < nCount; ++i)
2768 const SwPageDesc& rDesc =
2769 const_cast<const SwDoc &>(rDoc).GetPageDesc(i);
2770 const USHORT nId = rDesc.GetPoolFmtId();
2771 BOOL bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rDesc));
2772 if( !bUsed )
2774 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2775 ? !(nId & USER_FMT)
2776 // benutzte gesucht und keine gefunden
2777 : bIsSearchUsed )
2778 continue;
2781 aLst.Append( cPAGE, rDesc.GetName() );
2783 if ( nSrchMask == SFXSTYLEBIT_ALL )
2784 AppendStyleList(SwStyleNameMapper::GetPageDescUINameArray(),
2785 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, cPAGE);
2788 if( nSearchFamily == SFX_STYLE_FAMILY_PSEUDO ||
2789 nSearchFamily == SFX_STYLE_FAMILY_ALL )
2791 const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl();
2792 for(USHORT i = 0; i < rNumTbl.Count(); ++i)
2794 const SwNumRule& rRule = *rNumTbl[ i ];
2795 if( !rRule.IsAutoRule() )
2797 BOOL bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rRule) );
2798 if( !bUsed )
2800 if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
2801 ? !(rRule.GetPoolFmtId() & USER_FMT)
2802 // benutzte gesucht und keine gefunden
2803 : bIsSearchUsed )
2804 continue;
2807 aLst.Append( cNUMRULE, rRule.GetName() );
2810 if ( nSrchMask == SFXSTYLEBIT_ALL )
2811 AppendStyleList(SwStyleNameMapper::GetNumRuleUINameArray(),
2812 bIsSearchUsed, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, cNUMRULE);
2815 if(aLst.Count() > 0)
2817 nLastPos = USHRT_MAX;
2818 return Next();
2820 return 0;
2823 SfxStyleSheetBase* SwStyleSheetIterator::Next()
2825 nLastPos++;
2826 if(aLst.Count() > 0 && nLastPos < aLst.Count())
2828 mxIterSheet->PresetNameAndFamily(*aLst[nLastPos]);
2829 mxIterSheet->SetPhysical( FALSE );
2830 mxIterSheet->SetMask( nMask );
2831 if(mxIterSheet->pSet)
2833 mxIterSheet->pSet->ClearItem(0);
2834 mxIterSheet->pSet= 0;
2836 return mxIterSheet.get();
2838 return 0;
2841 SfxStyleSheetBase* SwStyleSheetIterator::Find( const UniString& rName )
2843 // suchen
2844 if( !bFirstCalled )
2845 First();
2847 nLastPos = lcl_FindName( aLst, nSearchFamily, rName );
2848 if( USHRT_MAX != nLastPos )
2850 // gefunden
2851 mxStyleSheet->PresetNameAndFamily(*aLst[nLastPos]);
2852 // neuer Name gesetzt, also bestimme seine Daten
2853 mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
2854 if( !mxStyleSheet->IsPhysical() )
2855 mxStyleSheet->SetPhysical( FALSE );
2857 return mxStyleSheet.get();
2859 return 0;
2862 void SwStyleSheetIterator::AppendStyleList(const SvStringsDtor& rList,
2863 BOOL bTestUsed,
2864 USHORT nSection, char cType )
2866 if( bTestUsed )
2868 SwDoc& rDoc = ((SwDocStyleSheetPool*)pBasePool)->GetDoc();
2869 for ( USHORT i=0; i < rList.Count(); ++i )
2871 BOOL bUsed = FALSE;
2872 USHORT nId = SwStyleNameMapper::GetPoolIdFromUIName(*rList[i], (SwGetPoolIdFromName)nSection);
2873 switch ( nSection )
2875 case nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL:
2876 bUsed = rDoc.IsPoolTxtCollUsed( nId );
2877 break;
2878 case nsSwGetPoolIdFromName::GET_POOLID_CHRFMT:
2879 bUsed = rDoc.IsPoolFmtUsed( nId );
2880 break;
2881 case nsSwGetPoolIdFromName::GET_POOLID_FRMFMT:
2882 bUsed = rDoc.IsPoolFmtUsed( nId );
2883 case nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC:
2884 bUsed = rDoc.IsPoolPageDescUsed( nId );
2885 break;
2886 default:
2887 ASSERT( !this, "unknown PoolFmt-Id" );
2889 if ( bUsed )
2890 aLst.Append( cType, *rList[i] );
2893 else
2894 for ( USHORT i=0; i < rList.Count(); ++i )
2895 aLst.Append( cType, *rList[i] );
2898 void SwStyleSheetIterator::Notify( SfxBroadcaster&, const SfxHint& rHint )
2900 // suchen und aus der Anzeige-Liste entfernen !!
2901 if( rHint.ISA( SfxStyleSheetHint ) &&
2902 SFX_STYLESHEET_ERASED == ((SfxStyleSheetHint&) rHint).GetHint() )
2904 SfxStyleSheetBase* pStyle = ((SfxStyleSheetHint&)rHint).GetStyleSheet();
2906 if (pStyle)
2908 USHORT nTmpPos = lcl_FindName( aLst, pStyle->GetFamily(),
2909 pStyle->GetName() );
2910 if( nTmpPos < aLst.Count() )
2911 aLst.DeleteAndDestroy( nTmpPos );