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 $
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>
48 #include <swmodule.hxx>
55 #include <charfmt.hxx>
56 #include <poolfmt.hxx>
57 #include <pagedesc.hxx>
58 #include <docstyle.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>
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
102 SwImplShellAction( SwDoc
& rDoc
);
103 ~SwImplShellAction();
105 SwWrtShell
* GetSh() { return pSh
; }
108 SwImplShellAction::SwImplShellAction( SwDoc
& rDoc
)
111 if( rDoc
.GetDocShell() )
112 pSh
= rDoc
.GetDocShell()->GetWrtShell();
118 pCurrSh
= new CurrShell( pSh
);
119 pSh
->StartAllAction();
123 SwImplShellAction::~SwImplShellAction()
132 /*--------------------------------------------------------------------
133 Beschreibung: SwCharFormate finden/anlegen
135 --------------------------------------------------------------------*/
137 SwCharFmt
* lcl_FindCharFmt( SwDoc
& rDoc
,
139 SwDocStyleSheet
* pStyle
= 0,
140 BOOL bCreate
= TRUE
)
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
)
155 const USHORT nId
= SwStyleNameMapper::GetPoolIdFromUIName(rName
, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
);
157 pFmt
= rDoc
.GetCharFmtFromPool(nId
);
164 pStyle
->SetPhysical(TRUE
);
165 SwFmt
* p
= pFmt
->DerivedFrom();
166 if( p
&& !p
->IsDefault() )
167 pStyle
->PresetParent( p
->GetName() );
169 pStyle
->PresetParent( aEmptyStr
);
172 pStyle
->SetPhysical(FALSE
);
178 /*--------------------------------------------------------------------
179 Beschreibung: ParaFormate finden/erzeugen
181 --------------------------------------------------------------------*/
183 SwTxtFmtColl
* lcl_FindParaFmt( SwDoc
& rDoc
,
185 SwDocStyleSheet
* pStyle
= 0,
186 BOOL bCreate
= TRUE
)
188 SwTxtFmtColl
* pColl
= 0;
192 pColl
= rDoc
.FindTxtFmtCollByName( rName
);
193 if( !pColl
&& bCreate
)
195 const USHORT nId
= SwStyleNameMapper::GetPoolIdFromUIName(rName
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
);
197 pColl
= rDoc
.GetTxtCollFromPool(nId
);
205 pStyle
->SetPhysical(TRUE
);
206 if( pColl
->DerivedFrom() && !pColl
->DerivedFrom()->IsDefault() )
207 pStyle
->PresetParent( pColl
->DerivedFrom()->GetName() );
209 pStyle
->PresetParent( aEmptyStr
);
211 SwTxtFmtColl
& rNext
= pColl
->GetNextTxtFmtColl();
212 pStyle
->PresetFollow(rNext
.GetName());
215 pStyle
->SetPhysical(FALSE
);
221 /*--------------------------------------------------------------------
222 Beschreibung: Rahmenformate
223 --------------------------------------------------------------------*/
226 SwFrmFmt
* lcl_FindFrmFmt( SwDoc
& rDoc
,
228 SwDocStyleSheet
* pStyle
= 0,
229 BOOL bCreate
= TRUE
)
234 pFmt
= rDoc
.FindFrmFmtByName( rName
);
235 if( !pFmt
&& bCreate
)
237 const USHORT nId
= SwStyleNameMapper::GetPoolIdFromUIName(rName
, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT
);
239 pFmt
= rDoc
.GetFrmFmtFromPool(nId
);
247 pStyle
->SetPhysical(TRUE
);
248 if( pFmt
->DerivedFrom() && !pFmt
->DerivedFrom()->IsDefault() )
249 pStyle
->PresetParent( pFmt
->DerivedFrom()->GetName() );
251 pStyle
->PresetParent( aEmptyStr
);
254 pStyle
->SetPhysical(FALSE
);
259 /*--------------------------------------------------------------------
260 Beschreibung: Seitendescriptoren
261 --------------------------------------------------------------------*/
264 const SwPageDesc
* lcl_FindPageDesc( SwDoc
& rDoc
,
266 SwDocStyleSheet
* pStyle
= 0,
267 BOOL bCreate
= TRUE
)
269 const SwPageDesc
* pDesc
= 0;
273 pDesc
= rDoc
.FindPageDescByName( rName
);
274 if( !pDesc
&& bCreate
)
276 USHORT nId
= SwStyleNameMapper::GetPoolIdFromUIName(rName
, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC
);
278 pDesc
= rDoc
.GetPageDescFromPool(nId
);
286 pStyle
->SetPhysical(TRUE
);
287 if(pDesc
->GetFollow())
288 pStyle
->PresetFollow(pDesc
->GetFollow()->GetName());
290 pStyle
->PresetParent( aEmptyStr
);
293 pStyle
->SetPhysical(FALSE
);
298 const SwNumRule
* lcl_FindNumRule( SwDoc
& rDoc
,
300 SwDocStyleSheet
* pStyle
= 0,
301 BOOL bCreate
= TRUE
)
303 const SwNumRule
* pRule
= 0;
307 pRule
= rDoc
.FindNumRulePtr( rName
);
308 if( !pRule
&& bCreate
)
310 USHORT nId
= SwStyleNameMapper::GetPoolIdFromUIName(rName
, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE
);
312 pRule
= rDoc
.GetNumRuleFromPool(nId
);
320 pStyle
->SetPhysical(TRUE
);
321 pStyle
->PresetParent( aEmptyStr
);
324 pStyle
->SetPhysical(FALSE
);
330 USHORT
lcl_FindName( const SwPoolFmtList
& rLst
, SfxStyleFamily eFam
,
331 const String
& rName
)
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
347 for( USHORT i
=0; i
< rLst
.Count(); ++i
)
348 if( *rLst
[i
] == sSrch
)
354 BOOL
FindPhyStyle( SwDoc
& rDoc
, const String
& rName
, SfxStyleFamily 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
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
);
383 for ( USHORT i
=0; i
< Count(); ++i
)
385 if( *operator[](i
) == *pStr
)
391 Insert( pStr
, Count() );
394 /*--------------------------------------------------------------------
395 Beschreibung: Liste kompletti loeschen
396 --------------------------------------------------------------------*/
399 void SwPoolFmtList::Erase()
401 DeleteAndDestroy( 0, Count() );
406 /*--------------------------------------------------------------------
407 Beschreibung: UI-seitige implementierung von StyleSheets
408 greift auf die Core-Engine zu
409 --------------------------------------------------------------------*/
411 SwDocStyleSheet::SwDocStyleSheet( SwDoc
& rDocument
,
413 SwDocStyleSheetPool
& _rPool
,
417 SfxStyleSheetBase( rName
, _rPool
, eFam
, _nMask
),
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,
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
,
453 SwDocStyleSheet::SwDocStyleSheet( const SwDocStyleSheet
& rOrg
) :
454 SfxStyleSheetBase(rOrg
),
455 pCharFmt(rOrg
.pCharFmt
),
457 pFrmFmt(rOrg
.pFrmFmt
),
459 pNumRule(rOrg
.pNumRule
),
461 aCoreSet(rOrg
.aCoreSet
),
462 bPhysical(rOrg
.bPhysical
)
467 SwDocStyleSheet::~SwDocStyleSheet()
471 /*--------------------------------------------------------------------
472 Beschreibung: Zuruecksetzen
473 --------------------------------------------------------------------*/
476 void SwDocStyleSheet::Reset()
484 /*--------------------------------------------------------------------
485 Beschreibung: virtuelle Methoden
486 --------------------------------------------------------------------*/
489 const String
& SwDocStyleSheet::GetParent() const
493 // dann pruefe, ob schon im Doc vorhanden
495 SwGetPoolIdFromName eGetType
;
498 case SFX_STYLE_FAMILY_CHAR
:
499 pFmt
= rDoc
.FindCharFmtByName( aName
);
500 eGetType
= nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
;
503 case SFX_STYLE_FAMILY_PARA
:
504 pFmt
= rDoc
.FindTxtFmtCollByName( aName
);
505 eGetType
= nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
;
508 case SFX_STYLE_FAMILY_FRAME
:
509 pFmt
= rDoc
.FindFrmFmtByName( aName
);
510 eGetType
= nsSwGetPoolIdFromName::GET_POOLID_FRMFMT
;
513 case SFX_STYLE_FAMILY_PAGE
:
514 case SFX_STYLE_FAMILY_PSEUDO
:
516 return aEmptyStr
; // es gibt keinen Parent
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
);
529 SwFmt
* p
= pFmt
->DerivedFrom();
530 if( p
&& !p
->IsDefault() )
533 SwDocStyleSheet
* pThis
= (SwDocStyleSheet
*)this;
534 pThis
->aParent
= sTmp
;
539 /*--------------------------------------------------------------------
540 Beschreibung: Nachfolger
541 --------------------------------------------------------------------*/
544 const String
& SwDocStyleSheet::GetFollow() const
548 SwDocStyleSheet
* pThis
= (SwDocStyleSheet
*)this;
549 pThis
->FillStyleSheet( FillAllInfo
);
554 /*--------------------------------------------------------------------
555 Beschreibung: Welche Verkettung ist moeglich
556 --------------------------------------------------------------------*/
559 BOOL
SwDocStyleSheet::HasFollowSupport() const
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
;
569 ASSERT(!this, "unbekannte Style-Familie");
574 /*--------------------------------------------------------------------
575 Beschreibung: Parent ?
576 --------------------------------------------------------------------*/
579 BOOL
SwDocStyleSheet::HasParentSupport() const
584 case SFX_STYLE_FAMILY_CHAR
:
585 case SFX_STYLE_FAMILY_PARA
:
586 case SFX_STYLE_FAMILY_FRAME
: bRet
= TRUE
;
587 default:; //prevent warning
593 BOOL
SwDocStyleSheet::HasClearParentSupport() const
598 case SFX_STYLE_FAMILY_PARA
:
599 case SFX_STYLE_FAMILY_CHAR
:
600 case SFX_STYLE_FAMILY_FRAME
: bRet
= TRUE
;
601 default:; //prevent warning
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
)
621 SfxItemIter
aIter( *pSet
);
623 const SfxPoolItem
* pItem
= aIter
.FirstItem();
627 if(!IsInvalidItem(pItem
))
628 switch ( pItem
->Which() )
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
:
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() )
647 aDesc
+= aItemPresentation
;
651 pItem
= aIter
.NextItem();
655 else if ( SFX_STYLE_FAMILY_FRAME
== nFamily
||
656 SFX_STYLE_FAMILY_PARA
== nFamily
)
661 SfxItemIter
aIter( *pSet
);
663 const SfxPoolItem
* pItem
= aIter
.FirstItem();
665 String sPageNum
, sModel
, sBreak
;
666 BOOL bHasWesternFontPrefix
= FALSE
;
667 BOOL bHasCJKFontPrefix
= FALSE
;
668 SvtCJKOptions aCJKOptions
;
672 if(!IsInvalidItem(pItem
))
673 switch ( pItem
->Which() )
675 case SID_ATTR_AUTO_STYLE_UPDATE
:
676 case SID_PARA_BACKGRND_DESTINATION
:
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
:
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
;
699 case SID_ATTR_PARA_MODEL
:
700 sModel
= aItemPresentation
;
703 sBreak
= aItemPresentation
;
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())
712 if(!bHasCJKFontPrefix
)
714 aItemPresentation
.Insert(SW_RESSTR(STR_CJK_FONT
), 0);
715 bHasCJKFontPrefix
= TRUE
;
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
;
735 if ( aDesc
.Len() && aItemPresentation
.Len() )
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
755 aDesc
+= SW_RESSTR(STR_PAGEBREAK
);
758 if(sPageNum
!= String(UniString::CreateFromInt32(0)))
761 aDesc
+= SW_RESSTR(STR_PAGEOFFSET
);
767 else if( SFX_STYLE_FAMILY_PSEUDO
== nFamily
)
770 // return pNumRule->GetName();
771 //os: was sollte man bei Numerierungen schon anzeigen?
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
)
796 if( !SfxStyleSheetBase::SetName( rStr
))
800 FillStyleSheet( FillPhysical
);
805 case SFX_STYLE_FAMILY_CHAR
:
807 ASSERT(pCharFmt
, "SwCharFormat fehlt!");
808 if( pCharFmt
&& pCharFmt
->GetName() != rStr
)
810 pCharFmt
->SetName( rStr
);
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
);
823 pColl
->SetName(rStr
);
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
);
837 pFrmFmt
->SetName( rStr
);
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.
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
);
866 case SFX_STYLE_FAMILY_PSEUDO
:
867 ASSERT(pNumRule
, "NumRule fehlt!");
872 String aOldName
= pNumRule
->GetName();
874 if (aOldName
.Len() > 0)
876 if ( aOldName
!= rStr
&&
877 rDoc
.RenameNumRule(aOldName
, rStr
))
879 pNumRule
= rDoc
.FindNumRulePtr(rStr
);
887 // --> OD 2008-07-08 #i91400#
888 ((SwNumRule
*)pNumRule
)->SetName( rStr
, rDoc
);
900 ASSERT(!this, "unbekannte Style-Familie");
905 rPool
.First(); // interne Liste muss geupdatet werden
906 rPool
.Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED
, *this ) );
907 SwEditShell
* pSh
= rDoc
.GetEditShell();
914 /*--------------------------------------------------------------------
915 Beschreibung: Ableitungshirachie
916 --------------------------------------------------------------------*/
919 BOOL
SwDocStyleSheet::SetParent( const String
& rStr
)
921 SwFmt
* pFmt
= 0, *pParent
= 0;
924 case SFX_STYLE_FAMILY_CHAR
:
925 ASSERT( pCharFmt
, "SwCharFormat fehlt!" )
926 if( 0 != ( pFmt
= pCharFmt
) && rStr
.Len() )
927 pParent
= lcl_FindCharFmt(rDoc
, rStr
);
930 case SFX_STYLE_FAMILY_PARA
:
931 ASSERT( pColl
, "Collektion fehlt!")
932 if( 0 != ( pFmt
= pColl
) && rStr
.Len() )
933 pParent
= lcl_FindParaFmt( rDoc
, rStr
);
936 case SFX_STYLE_FAMILY_FRAME
:
937 ASSERT(pFrmFmt
, "FrameFormat fehlt!");
938 if( 0 != ( pFmt
= pFrmFmt
) && rStr
.Len() )
939 pParent
= lcl_FindFrmFmt( rDoc
, rStr
);
942 case SFX_STYLE_FAMILY_PAGE
:
943 case SFX_STYLE_FAMILY_PSEUDO
:
946 ASSERT(!this, "unbekannte Style-Familie");
950 if( pFmt
&& pFmt
->DerivedFrom() &&
951 pFmt
->DerivedFrom()->GetName() != rStr
)
954 SwImplShellAction
aTmp( rDoc
);
955 bRet
= pFmt
->SetDerivedFrom( pParent
);
961 rPool
.Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED
,
969 /*--------------------------------------------------------------------
970 Beschreibung: Nachfolger detzen
971 --------------------------------------------------------------------*/
974 BOOL
SwDocStyleSheet::SetFollow( const String
& rStr
)
976 if( rStr
.Len() && !SfxStyleSheetBase::SetFollow( rStr
))
979 SwImplShellAction
aTmpSh( rDoc
);
982 case SFX_STYLE_FAMILY_PARA
:
984 ASSERT(pColl
, "Collection fehlt!");
987 SwTxtFmtColl
* pFollow
= pColl
;
988 if( rStr
.Len() && 0 == (pFollow
= lcl_FindParaFmt(rDoc
, rStr
) ))
991 pColl
->SetNextTxtFmtColl(*pFollow
);
995 case SFX_STYLE_FAMILY_PAGE
:
997 ASSERT(pDesc
, "PageDesc fehlt!");
1000 const SwPageDesc
* pFollowDesc
= rStr
.Len()
1001 ? lcl_FindPageDesc(rDoc
, rStr
)
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
);
1015 case SFX_STYLE_FAMILY_CHAR
:
1016 case SFX_STYLE_FAMILY_FRAME
:
1017 case SFX_STYLE_FAMILY_PSEUDO
:
1020 ASSERT(!this, "unbekannte Style-Familie");
1026 /*--------------------------------------------------------------------
1027 Beschreibung: ueber Name und Family, Mask den ItemSet rausholen
1028 --------------------------------------------------------------------*/
1030 SfxItemSet
& SwDocStyleSheet::GetItemSet()
1033 FillStyleSheet( FillPhysical
);
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());
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());
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());
1076 case SFX_STYLE_FAMILY_PAGE
:
1078 ASSERT(pDesc
, "Kein PageDescriptor");
1079 ::PageDescToItemSet(*((SwPageDesc
*)pDesc
), aCoreSet
);
1083 case SFX_STYLE_FAMILY_PSEUDO
:
1085 ASSERT(pNumRule
, "Keine NumRule");
1086 SvxNumRule aRule
= pNumRule
->MakeSvxNumRule();
1087 aCoreSet
.Put(SvxNumBulletItem(aRule
));
1092 ASSERT(!this, "unbekannte Style-Familie");
1094 // Member der Basisklasse
1100 // --> OD 2008-02-13 #newlistlevelattrs#
1101 void SwDocStyleSheet::MergeIndentAttrsOfListStyle( SfxItemSet
& rSet
)
1103 if ( nFamily
!= SFX_STYLE_FAMILY_PARA
)
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
);
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()) );
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
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
);
1160 SwPageDesc
* pNewDsc
= 0;
1161 USHORT nPgDscPos
= 0;
1165 case SFX_STYLE_FAMILY_CHAR
:
1167 ASSERT(pCharFmt
, "Wo ist das CharFormat");
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
))
1186 if( RES_CONDTXTFMTCOLL
== pColl
->Which() && pCondItem
)
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
);
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());
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
);
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
);
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
);
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
);
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)
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
;
1281 case SWSTYLEBIT_CHAPTER
:
1282 nId
|= COLL_DOC_BITS
;
1284 case SWSTYLEBIT_LIST
:
1285 nId
|= COLL_LISTS_BITS
;
1287 case SWSTYLEBIT_IDX
:
1288 nId
|= COLL_REGISTER_BITS
;
1290 case SWSTYLEBIT_EXTRA
:
1291 nId
|= COLL_EXTRA_BITS
;
1293 case SWSTYLEBIT_HTML
:
1294 nId
|= COLL_HTML_BITS
;
1297 pColl
->SetPoolFmtId( nId
);
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());
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
);
1327 pFmt
= &pNewDsc
->GetMaster();
1332 case SFX_STYLE_FAMILY_PSEUDO
:
1334 ASSERT(pNumRule
, "Wo ist die NumRule");
1339 const SfxPoolItem
* pItem
;
1340 switch( rSet
.GetItemState( SID_ATTR_NUMBERING_RULE
, FALSE
, &pItem
))
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
);
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() );
1362 rDoc
.ChgNumRuleFmts( aRule
);
1370 ASSERT(!this, "unbekannte Style-Familie");
1373 if( pFmt
&& rSet
.Count())
1375 SfxItemIter
aIter( rSet
);
1376 const SfxPoolItem
* pItem
= aIter
.GetCurItem();
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()),
1389 if( aIter
.IsAtEnd() )
1391 pItem
= aIter
.NextItem();
1393 SfxItemSet
aSet(rSet
);
1394 aSet
.ClearInvalidItems();
1396 aCoreSet
.ClearItem();
1400 ::ItemSetToPageDesc( aSet
, *pNewDsc
);
1401 rDoc
.ChgPageDesc( nPgDscPos
, *pNewDsc
);
1402 pDesc
= &const_cast<const SwDoc
&>(rDoc
).GetPageDesc( nPgDscPos
);
1403 rDoc
.PreDelPageDesc(pNewDsc
); // #i7983#
1407 rDoc
.ChgFmt(*pFmt
, aSet
); // alles gesetzten Putten
1411 aCoreSet
.ClearItem();
1412 if( pNewDsc
) // den muessen wir noch vernichten!!
1414 rDoc
.PreDelPageDesc(pNewDsc
); // #i7983#
1419 // --> OD 2008-02-12 #newlistlevelattrs#
1420 if ( rDoc
.DoesUndo() )
1422 rDoc
.EndUndo( UNDO_INSFMTATTR
, NULL
);
1427 void lcl_SaveStyles( USHORT nFamily
, SvPtrarr
& rArr
, SwDoc
& rDoc
)
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
);
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
);
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
);
1462 case SFX_STYLE_FAMILY_PAGE
:
1464 for( sal_uInt16 n
= 0, nCnt
= rDoc
.GetPageDescCnt(); n
< nCnt
; ++n
)
1467 (void*)&const_cast<const SwDoc
&>(rDoc
).GetPageDesc( n
);
1468 rArr
.Insert( p
, n
);
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
);
1486 void lcl_DeleteInfoStyles( USHORT nFamily
, SvPtrarr
& rArr
, SwDoc
& rDoc
)
1491 case SFX_STYLE_FAMILY_CHAR
:
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
] );
1506 case SFX_STYLE_FAMILY_PARA
:
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
] );
1521 case SFX_STYLE_FAMILY_FRAME
:
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
] );
1536 case SFX_STYLE_FAMILY_PAGE
:
1539 for( n
= 0, nCnt
= rDoc
.GetPageDescCnt(); n
< nCnt
; ++n
)
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
] );
1552 case SFX_STYLE_FAMILY_PSEUDO
:
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() );
1569 /*--------------------------------------------------------------------
1570 Beschreibung: Das Format ermitteln
1571 --------------------------------------------------------------------*/
1573 BOOL
SwDocStyleSheet::FillStyleSheet( FillStyleType eFType
)
1576 USHORT nPoolId
= USHRT_MAX
;
1579 BOOL bCreate
= FillPhysical
== eFType
;
1580 BOOL bDeleteInfo
= FALSE
;
1581 BOOL bFillOnlyInfo
= FillAllInfo
== eFType
;
1586 case SFX_STYLE_FAMILY_CHAR
:
1587 pCharFmt
= lcl_FindCharFmt(rDoc
, aName
, this, bCreate
);
1588 bPhysical
= 0 != pCharFmt
;
1589 if( bFillOnlyInfo
&& !bPhysical
)
1592 ::lcl_SaveStyles( static_cast< USHORT
>(nFamily
), aDelArr
, rDoc
);
1593 pCharFmt
= lcl_FindCharFmt(rDoc
, aName
, this, TRUE
);
1597 if( !bCreate
&& !pFmt
)
1599 if( aName
== *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD
-
1600 RES_POOLCOLL_TEXT_BEGIN
] )
1603 nPoolId
= SwStyleNameMapper::GetPoolIdFromUIName( aName
, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
);
1606 bRet
= 0 != pCharFmt
|| USHRT_MAX
!= nPoolId
;
1612 case SFX_STYLE_FAMILY_PARA
:
1614 pColl
= lcl_FindParaFmt(rDoc
, aName
, this, bCreate
);
1615 bPhysical
= 0 != pColl
;
1616 if( bFillOnlyInfo
&& !bPhysical
)
1619 ::lcl_SaveStyles( static_cast< USHORT
>(nFamily
), aDelArr
, rDoc
);
1620 pColl
= lcl_FindParaFmt(rDoc
, aName
, this, TRUE
);
1625 PresetFollow( pColl
->GetNextTxtFmtColl().GetName() );
1627 nPoolId
= SwStyleNameMapper::GetPoolIdFromUIName( aName
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
);
1629 bRet
= 0 != pColl
|| USHRT_MAX
!= nPoolId
;
1636 case SFX_STYLE_FAMILY_FRAME
:
1637 pFrmFmt
= lcl_FindFrmFmt(rDoc
, aName
, this, bCreate
);
1638 bPhysical
= 0 != pFrmFmt
;
1639 if( bFillOnlyInfo
&& bPhysical
)
1642 ::lcl_SaveStyles( static_cast< USHORT
>(nFamily
), aDelArr
, rDoc
);
1643 pFrmFmt
= lcl_FindFrmFmt(rDoc
, aName
, this, TRUE
);
1646 if( !bCreate
&& !pFmt
)
1647 nPoolId
= SwStyleNameMapper::GetPoolIdFromUIName( aName
, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT
);
1649 bRet
= 0 != pFrmFmt
|| USHRT_MAX
!= nPoolId
;
1655 case SFX_STYLE_FAMILY_PAGE
:
1656 pDesc
= lcl_FindPageDesc(rDoc
, aName
, this, bCreate
);
1657 bPhysical
= 0 != pDesc
;
1658 if( bFillOnlyInfo
&& !pDesc
)
1661 ::lcl_SaveStyles( static_cast< USHORT
>(nFamily
), aDelArr
, rDoc
);
1662 pDesc
= lcl_FindPageDesc( rDoc
, aName
, this, TRUE
);
1667 nPoolId
= pDesc
->GetPoolFmtId();
1668 nHelpId
= pDesc
->GetPoolHelpId();
1669 if( pDesc
->GetPoolHlpFileId() != UCHAR_MAX
)
1670 aHelpFile
= *rDoc
.GetDocPattern( pDesc
->GetPoolHlpFileId() );
1675 nPoolId
= SwStyleNameMapper::GetPoolIdFromUIName( aName
, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC
);
1676 SetMask( USER_FMT
& nPoolId
? SFXSTYLEBIT_USERDEF
: 0 );
1678 bRet
= 0 != pDesc
|| USHRT_MAX
!= nPoolId
;
1683 case SFX_STYLE_FAMILY_PSEUDO
:
1684 pNumRule
= lcl_FindNumRule(rDoc
, aName
, this, bCreate
);
1685 bPhysical
= 0 != pNumRule
;
1686 if( bFillOnlyInfo
&& !pNumRule
)
1689 ::lcl_SaveStyles( static_cast< USHORT
>(nFamily
), aDelArr
, rDoc
);
1690 pNumRule
= lcl_FindNumRule( rDoc
, aName
, this, TRUE
);
1695 nPoolId
= pNumRule
->GetPoolFmtId();
1696 nHelpId
= pNumRule
->GetPoolHelpId();
1697 if( pNumRule
->GetPoolHlpFileId() != UCHAR_MAX
)
1698 aHelpFile
= *rDoc
.GetDocPattern( pNumRule
->GetPoolHlpFileId() );
1703 nPoolId
= SwStyleNameMapper::GetPoolIdFromUIName( aName
, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE
);
1704 SetMask( USER_FMT
& nPoolId
? SFXSTYLEBIT_USERDEF
: 0 );
1706 bRet
= 0 != pNumRule
|| USHRT_MAX
!= nPoolId
;
1711 default:; //prevent warning
1714 if( SFX_STYLE_FAMILY_CHAR
== nFamily
||
1715 SFX_STYLE_FAMILY_PARA
== nFamily
||
1716 SFX_STYLE_FAMILY_FRAME
== nFamily
)
1719 nPoolId
= pFmt
->GetPoolFmtId();
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;
1739 ASSERT( bPhysical
, "Format nicht gefunden" );
1741 nHelpId
= pFmt
->GetPoolHelpId();
1742 if( pFmt
->GetPoolHlpFileId() != UCHAR_MAX
)
1743 aHelpFile
= *rDoc
.GetDocPattern( pFmt
->GetPoolHlpFileId() );
1747 if( RES_CONDTXTFMTCOLL
== pFmt
->Which() )
1748 _nMask
|= SWSTYLEBIT_CONDCOLL
;
1753 if( bDeleteInfo
&& bFillOnlyInfo
)
1754 ::lcl_DeleteInfoStyles( static_cast< USHORT
>(nFamily
), aDelArr
, rDoc
);
1758 /*--------------------------------------------------------------------
1759 Beschreibung: Neues Format in der Core anlegen
1760 --------------------------------------------------------------------*/
1763 void SwDocStyleSheet::Create()
1767 case SFX_STYLE_FAMILY_CHAR
:
1768 pCharFmt
= lcl_FindCharFmt( rDoc
, aName
);
1770 pCharFmt
= rDoc
.MakeCharFmt(aName
,
1771 rDoc
.GetDfltCharFmt());
1772 pCharFmt
->SetAuto( FALSE
);
1775 case SFX_STYLE_FAMILY_PARA
:
1776 pColl
= lcl_FindParaFmt( rDoc
, aName
);
1779 SwTxtFmtColl
*pPar
= (*rDoc
.GetTxtFmtColls())[0];
1780 if( nMask
& SWSTYLEBIT_CONDCOLL
)
1781 pColl
= rDoc
.MakeCondTxtFmtColl( aName
, pPar
);
1783 pColl
= rDoc
.MakeTxtFmtColl( aName
, pPar
);
1787 case SFX_STYLE_FAMILY_FRAME
:
1788 pFrmFmt
= lcl_FindFrmFmt( rDoc
, aName
);
1790 pFrmFmt
= rDoc
.MakeFrmFmt(aName
, rDoc
.GetDfltFrmFmt(), FALSE
, FALSE
);
1794 case SFX_STYLE_FAMILY_PAGE
:
1795 pDesc
= lcl_FindPageDesc( rDoc
, aName
);
1798 USHORT nId
= rDoc
.MakePageDesc(aName
);
1799 pDesc
= &const_cast<const SwDoc
&>(rDoc
).GetPageDesc(nId
);
1803 case SFX_STYLE_FAMILY_PSEUDO
:
1804 pNumRule
= lcl_FindNumRule( rDoc
, aName
);
1807 //JP 05.02.99: temp Namen erzeugen, damit kein ASSERT kommt
1808 String
sTmpNm( aName
);
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() ) ];
1819 pRule
->SetAutoRule( FALSE
);
1822 // --> OD 2008-07-08 #i91400#
1823 pRule
->SetName( aName
, rDoc
);
1829 default:; //prevent warning
1832 aCoreSet
.ClearItem();
1835 /*--------------------------------------------------------------------
1836 Beschreibung: Konkrete Formate rausholen
1837 --------------------------------------------------------------------*/
1841 SwCharFmt
* SwDocStyleSheet::GetCharFmt()
1844 FillStyleSheet( FillPhysical
);
1849 SwTxtFmtColl
* SwDocStyleSheet::GetCollection()
1852 FillStyleSheet( FillPhysical
);
1857 const SwPageDesc
* SwDocStyleSheet::GetPageDesc()
1860 FillStyleSheet( FillPhysical
);
1864 const SwNumRule
* SwDocStyleSheet::GetNumRule()
1867 FillStyleSheet( FillPhysical
);
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;
1891 aName
.Erase( 0, 1 );
1894 /*--------------------------------------------------------------------
1895 Beschreibung: Ist das Format physikalisch schon vorhanden
1896 --------------------------------------------------------------------*/
1899 void SwDocStyleSheet::SetPhysical(BOOL bPhys
)
1912 SwFrmFmt
* SwDocStyleSheet::GetFrmFmt()
1915 FillStyleSheet( FillPhysical
);
1920 BOOL
SwDocStyleSheet::IsUsed() const
1924 SwDocStyleSheet
* pThis
= (SwDocStyleSheet
*)this;
1925 pThis
->FillStyleSheet( FillOnlyName
);
1928 // immer noch nicht ?
1932 const SwModify
* pMod
;
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
;
1944 ASSERT(!this, "unbekannte Style-Familie");
1947 return rDoc
.IsUsed( *pMod
);
1951 ULONG
SwDocStyleSheet::GetHelpId( String
& rFile
)
1953 static String sTemplateHelpFile
= String::CreateFromAscii("swrhlppi.hlp");
1957 unsigned char nFileId
= UCHAR_MAX
;
1959 rFile
= sTemplateHelpFile
;
1961 const SwFmt
* pTmpFmt
= 0;
1964 case SFX_STYLE_FAMILY_CHAR
:
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
;
1974 case SFX_STYLE_FAMILY_PARA
:
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
;
1984 case SFX_STYLE_FAMILY_FRAME
:
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
;
1994 case SFX_STYLE_FAMILY_PAGE
:
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();
2007 case SFX_STYLE_FAMILY_PSEUDO
:
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();
2021 ASSERT(!this, "unbekannte Style-Familie");
2027 nId
= pTmpFmt
->GetPoolHelpId();
2028 nFileId
= pTmpFmt
->GetPoolHlpFileId();
2029 nPoolId
= pTmpFmt
->GetPoolFmtId();
2032 if( UCHAR_MAX
!= nFileId
)
2034 const String
*pTemplate
= rDoc
.GetDocPattern( nFileId
);
2037 // const String aHelpPath(MakeHelpPath(*pTemplate));
2041 else if( !IsPoolUserFmt( nPoolId
) )
2046 // weil sich der SFX so anstellt mit der HilfeId:
2047 if( USHRT_MAX
== nId
)
2048 nId
= 0; // entsp. keine Hilfe anzeigen
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!
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
);
2070 case SFX_STYLE_FAMILY_PSEUDO
:
2071 ((SwNumRule
*)pNumRule
)->SetPoolHelpId( nHId
);
2072 ((SwNumRule
*)pNumRule
)->SetPoolHlpFileId( nFileId
);
2076 ASSERT(!this, "unbekannte Style-Familie");
2081 pTmpFmt
->SetPoolHelpId( nHId
);
2082 pTmpFmt
->SetPoolHlpFileId( nFileId
);
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 ) )
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
,
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" );
2140 SfxStyleSheetBase
* SwDocStyleSheetPool::Create( const String
&,
2141 SfxStyleFamily
, USHORT
)
2143 ASSERT( !this, "Create im SW-Stylesheet-Pool geht nicht" );
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
);
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
);
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
);
2186 const SwFmt
*pSourceFmt
= 0;
2187 SwFmt
*pTargetFmt
= 0;
2188 USHORT nPgDscPos
= USHRT_MAX
;
2191 case SFX_STYLE_FAMILY_CHAR
:
2193 pSourceFmt
= ((SwDocStyleSheet
&)rSource
).GetCharFmt();
2194 pTargetFmt
= ((SwDocStyleSheet
&)rTarget
).GetCharFmt();
2196 case SFX_STYLE_FAMILY_PARA
:
2198 pSourceFmt
= ((SwDocStyleSheet
&)rSource
).GetCollection();
2199 pTargetFmt
= ((SwDocStyleSheet
&)rTarget
).GetCollection();
2201 case SFX_STYLE_FAMILY_FRAME
:
2203 pSourceFmt
= ((SwDocStyleSheet
&)rSource
).GetFrmFmt();
2204 pTargetFmt
= ((SwDocStyleSheet
&)rTarget
).GetFrmFmt();
2206 case SFX_STYLE_FAMILY_PAGE
:
2208 pSourceFmt
= &((SwDocStyleSheet
&)rSource
).GetPageDesc()
2211 SwPageDesc
*pDesc
= rDoc
.FindPageDescByName(
2212 ((SwDocStyleSheet
&)rTarget
).GetPageDesc()->GetName(),
2216 pTargetFmt
= &pDesc
->GetMaster();
2219 case SFX_STYLE_FAMILY_PSEUDO
:
2220 // Eine NumRule besteht nur aus einem Item, also muss man
2221 // hier nichts loeschen.
2223 default:; //prevent warning
2228 pTargetFmt
->DelDiffs( *pSourceFmt
);
2229 else if( USHRT_MAX
!= nPgDscPos
)
2230 pTargetFmt
->ResetFmtAttr( RES_PAGEDESC
, RES_FRMATR_END
-1 );
2233 // --> OD 2007-01-25 #i73790# - method renamed
2234 pTargetFmt
->ResetAllFmtAttr();
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
)
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
);
2272 rDoc
.DelCharFmt(pFmt
);
2275 case SFX_STYLE_FAMILY_PARA
:
2277 SwTxtFmtColl
* pColl
= lcl_FindParaFmt(rDoc
, rName
, 0, FALSE
);
2279 rDoc
.DelTxtFmtColl(pColl
);
2282 case SFX_STYLE_FAMILY_FRAME
:
2284 SwFrmFmt
* pFmt
= lcl_FindFrmFmt(rDoc
, rName
, 0, FALSE
);
2286 rDoc
.DelFrmFmt(pFmt
);
2289 case SFX_STYLE_FAMILY_PAGE
:
2292 if( rDoc
.FindPageDescByName( rName
, &nPos
))
2293 rDoc
.DelPageDesc( nPos
);
2297 case SFX_STYLE_FAMILY_PSEUDO
:
2299 if( !rDoc
.DelNumRule( rName
) )
2300 // Broadcast nur versenden, wenn etwas geloescht wurde
2306 ASSERT(!this, "unbekannte Style-Familie");
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;
2322 case SFX_STYLE_FAMILY_CHAR
:
2323 if( 0 != ( pFmt
= lcl_FindCharFmt( rDoc
, rStyle
) ) && rParent
.Len() )
2324 pParent
= lcl_FindCharFmt(rDoc
, rParent
);
2327 case SFX_STYLE_FAMILY_PARA
:
2328 if( 0 != ( pFmt
= lcl_FindParaFmt( rDoc
, rStyle
) ) && rParent
.Len() )
2329 pParent
= lcl_FindParaFmt( rDoc
, rParent
);
2332 case SFX_STYLE_FAMILY_FRAME
:
2333 if( 0 != ( pFmt
= lcl_FindFrmFmt( rDoc
, rStyle
) ) && rParent
.Len() )
2334 pParent
= lcl_FindFrmFmt( rDoc
, rParent
);
2337 case SFX_STYLE_FAMILY_PAGE
:
2338 case SFX_STYLE_FAMILY_PSEUDO
:
2342 ASSERT(!this, "unbekannte Style-Familie");
2346 if( pFmt
&& pFmt
->DerivedFrom() &&
2347 pFmt
->DerivedFrom()->GetName() != rParent
)
2350 SwImplShellAction
aTmpSh( rDoc
);
2351 bRet
= pFmt
->SetDerivedFrom( pParent
);
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() );
2363 mxStyleSheet
->PresetFollow( aEmptyStr
);
2365 Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED
,
2366 *(mxStyleSheet
.get()) ) );
2373 SfxStyleSheetBase
* SwDocStyleSheetPool::Find( const String
& rName
,
2374 SfxStyleFamily eFam
, USHORT 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
;
2383 nSMask
&= SFXSTYLEBIT_USED
| SFXSTYLEBIT_USERDEF
|
2384 SWSTYLEBIT_CONDCOLL
| SWSTYLEBIT_HTML
;
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() )
2402 case SFX_STYLE_FAMILY_CHAR
:
2403 pMod
= mxStyleSheet
->GetCharFmt();
2406 case SFX_STYLE_FAMILY_PARA
:
2407 pMod
= mxStyleSheet
->GetCollection();
2410 case SFX_STYLE_FAMILY_FRAME
:
2411 pMod
= mxStyleSheet
->GetFrmFmt();
2414 case SFX_STYLE_FAMILY_PAGE
:
2415 pMod
= mxStyleSheet
->GetPageDesc();
2418 case SFX_STYLE_FAMILY_PSEUDO
:
2420 const SwNumRule
* pRule
= mxStyleSheet
->GetNumRule();
2422 !(bSearchUsed
&& (bOrganizer
|| rDoc
.IsUsed(*pRule
)) ) &&
2423 (( nSMask
& ~SFXSTYLEBIT_USED
) == SFXSTYLEBIT_USERDEF
2424 ? !(pRule
->GetPoolFmtId() & USER_FMT
)
2425 // benutzte gesucht und keine gefunden
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
2445 // benutzte gesucht und keine gefunden
2449 return bFnd
? mxStyleSheet
.get() : 0;
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
;
2462 StartListening( *pBase
);
2465 SwStyleSheetIterator::~SwStyleSheetIterator()
2467 EndListening( mxIterSheet
->GetPool() );
2470 USHORT
SwStyleSheetIterator::Count()
2472 // Liste richtig fuellen lassen !!
2475 return aLst
.Count();
2478 SfxStyleSheetBase
* SwStyleSheetIterator::operator[]( USHORT nIdx
)
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
;
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() )
2516 const BOOL bUsed
= bIsSearchUsed
&& (bOrganizer
|| rDoc
.IsUsed(*pFmt
));
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
2525 // benutzte gesucht und keine gefunden
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
)
2539 aLst
.Append( cCHAR
, pFmt
== rDoc
.GetDfltCharFmt()
2540 ? (const String
&) *SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD
-
2541 RES_POOLCOLL_TEXT_BEGIN
]
2542 : pFmt
->GetName() );
2547 if( nSrchMask
== SFXSTYLEBIT_ALL
)
2549 if( !rDoc
.get(IDocumentSettingAccess::HTML_MODE
) )
2550 AppendStyleList(SwStyleNameMapper::GetChrFmtUINameArray(),
2551 bIsSearchUsed
, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
, cCHAR
);
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
|
2579 nSMask
&= SFXSTYLEBIT_USED
| SFXSTYLEBIT_USERDEF
|
2580 SWSTYLEBIT_CONDCOLL
| SWSTYLEBIT_HTML
;
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())
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;
2602 case SWSTYLEBIT_TEXT
:
2603 if((nId
& COLL_GET_RANGE_BITS
) != COLL_TEXT_BITS
) continue;
2605 case SWSTYLEBIT_CHAPTER
:
2606 if((nId
& COLL_GET_RANGE_BITS
) != COLL_DOC_BITS
) continue;
2608 case SWSTYLEBIT_LIST
:
2609 if((nId
& COLL_GET_RANGE_BITS
) != COLL_LISTS_BITS
) continue;
2611 case SWSTYLEBIT_IDX
:
2612 if((nId
& COLL_GET_RANGE_BITS
) != COLL_REGISTER_BITS
) continue;
2614 case SWSTYLEBIT_EXTRA
:
2615 if((nId
& COLL_GET_RANGE_BITS
) != COLL_EXTRA_BITS
) continue;
2618 case SWSTYLEBIT_HTML
| SFXSTYLEBIT_USERDEF
:
2619 if(IsPoolUserFmt(nId
))
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
;
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
:
2650 case SWSTYLEBIT_CONDCOLL
:
2651 if( RES_CONDTXTFMTCOLL
!= pColl
->Which() ) continue;
2654 // benutzte gesucht und keine gefunden
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
] );
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
) ;
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
;
2717 if( !bIsSearchUsed
|| rDoc
.IsPoolTxtCollUsed( *pPoolIds
) )
2719 s
= SwStyleNameMapper::GetUIName( *pPoolIds
, s
));
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())
2739 const USHORT nId
= pFmt
->GetPoolFmtId();
2740 BOOL bUsed
= bIsSearchUsed
&& ( bOrganizer
|| rDoc
.IsUsed(*pFmt
));
2743 if( (nSrchMask
& ~SFXSTYLEBIT_USED
) == SFXSTYLEBIT_USERDEF
2745 // benutzte gesucht und keine gefunden
2752 aLst
.Append( cFRAME
, pFmt
->GetName() );
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
));
2774 if( (nSrchMask
& ~SFXSTYLEBIT_USED
) == SFXSTYLEBIT_USERDEF
2776 // benutzte gesucht und keine gefunden
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
) );
2800 if( (nSrchMask
& ~SFXSTYLEBIT_USED
) == SFXSTYLEBIT_USERDEF
2801 ? !(rRule
.GetPoolFmtId() & USER_FMT
)
2802 // benutzte gesucht und keine gefunden
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
;
2823 SfxStyleSheetBase
* SwStyleSheetIterator::Next()
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();
2841 SfxStyleSheetBase
* SwStyleSheetIterator::Find( const UniString
& rName
)
2847 nLastPos
= lcl_FindName( aLst
, nSearchFamily
, rName
);
2848 if( USHRT_MAX
!= nLastPos
)
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();
2862 void SwStyleSheetIterator::AppendStyleList(const SvStringsDtor
& rList
,
2864 USHORT nSection
, char cType
)
2868 SwDoc
& rDoc
= ((SwDocStyleSheetPool
*)pBasePool
)->GetDoc();
2869 for ( USHORT i
=0; i
< rList
.Count(); ++i
)
2872 USHORT nId
= SwStyleNameMapper::GetPoolIdFromUIName(*rList
[i
], (SwGetPoolIdFromName
)nSection
);
2875 case nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
:
2876 bUsed
= rDoc
.IsPoolTxtCollUsed( nId
);
2878 case nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
:
2879 bUsed
= rDoc
.IsPoolFmtUsed( nId
);
2881 case nsSwGetPoolIdFromName::GET_POOLID_FRMFMT
:
2882 bUsed
= rDoc
.IsPoolFmtUsed( nId
);
2883 case nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC
:
2884 bUsed
= rDoc
.IsPoolPageDescUsed( nId
);
2887 ASSERT( !this, "unknown PoolFmt-Id" );
2890 aLst
.Append( cType
, *rList
[i
] );
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();
2908 USHORT nTmpPos
= lcl_FindName( aLst
, pStyle
->GetFamily(),
2909 pStyle
->GetName() );
2910 if( nTmpPos
< aLst
.Count() )
2911 aLst
.DeleteAndDestroy( nTmpPos
);