1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/lang/XComponent.hpp>
22 #include <tools/tenccvt.hxx>
23 #include <comphelper/processfactory.hxx>
24 #include <unotools/intlwrapper.hxx>
25 #include <svl/smplhint.hxx>
26 #include <svl/poolitem.hxx>
27 #include <svl/itemset.hxx>
28 #include <svl/itempool.hxx>
30 #include <svl/itemiter.hxx>
31 #include <svl/style.hxx>
32 #include <unotools/syslocale.hxx>
34 #include <comphelper/servicehelper.hxx>
38 class DbgStyleSheetReferences
41 DbgStyleSheetReferences() : mnStyles(0), mnPools(0) {}
42 ~DbgStyleSheetReferences()
44 OSL_TRACE("DbgStyleSheetReferences\nSfxStyleSheetBase left %ld\nSfxStyleSheetBasePool left %ld", mnStyles
, mnPools
);
50 aDbgStyleSheetReferences
;
54 TYPEINIT0(SfxStyleSheetBase
)
56 TYPEINIT3(SfxStyleSheet
, SfxStyleSheetBase
, SfxListener
, SfxBroadcaster
)
58 TYPEINIT1(SfxStyleSheetHint
, SfxHint
);
59 TYPEINIT1(SfxStyleSheetHintExtended
, SfxStyleSheetHint
);
60 TYPEINIT1(SfxStyleSheetPoolHint
, SfxHint
);
62 SfxStyleSheetHintExtended::SfxStyleSheetHintExtended
64 sal_uInt16 nAction
, // SFX_STYLESHEET_... (s.o.)
65 const OUString
& rOldName
,
66 SfxStyleSheetBase
& rStyleSheet
// geh"ort weiterhin dem Aufrufer
68 : SfxStyleSheetHint( nAction
, rStyleSheet
),
73 SfxStyleSheetHint::SfxStyleSheetHint
75 sal_uInt16 nAction
, // SFX_STYLESHEET_... (s.o.)
76 SfxStyleSheetBase
& rStyleSheet
// geh"ort weiterhin dem Aufrufer
78 : pStyleSh( &rStyleSheet
),
83 class SfxStyleSheetBasePool_Impl
86 SfxStyleSheetIteratorPtr pIter
;
90 SfxStyleSheetBase::SfxStyleSheetBase( const OUString
& rName
, SfxStyleSheetBasePool
* p
, SfxStyleFamily eFam
, sal_uInt16 mask
)
100 , bHidden( sal_False
)
103 aDbgStyleSheetReferences
.mnStyles
++;
107 SfxStyleSheetBase::SfxStyleSheetBase( const SfxStyleSheetBase
& r
)
108 : comphelper::OWeakTypeObject()
110 , nFamily( r
.nFamily
)
112 , aParent( r
.aParent
)
113 , aFollow( r
.aFollow
)
114 , aHelpFile( r
.aHelpFile
)
116 , nHelpId( r
.nHelpId
)
118 , bHidden( r
.bHidden
)
121 aDbgStyleSheetReferences
.mnStyles
++;
124 pSet
= bMySet
? new SfxItemSet( *r
.pSet
) : r
.pSet
;
129 SfxStyleSheetBase::~SfxStyleSheetBase()
132 --aDbgStyleSheetReferences
.mnStyles
;
142 sal_uInt16
SfxStyleSheetBase::GetVersion() const
149 const OUString
& SfxStyleSheetBase::GetName() const
154 bool SfxStyleSheetBase::SetName( const OUString
& rName
)
161 OUString aOldName
= aName
;
162 SfxStyleSheetBase
*pOther
= pPool
->Find( rName
, nFamily
) ;
163 if ( pOther
&& pOther
!= this )
166 SfxStyleFamily eTmpFam
= pPool
->GetSearchFamily();
167 sal_uInt16 nTmpMask
= pPool
->GetSearchMask();
169 pPool
->SetSearchMask(nFamily
);
171 if ( !aName
.isEmpty() )
172 pPool
->ChangeParent( aName
, rName
, sal_False
);
174 if ( aFollow
== aName
)
177 pPool
->SetSearchMask(eTmpFam
, nTmpMask
);
178 pPool
->Broadcast( SfxStyleSheetHintExtended(
179 SFX_STYLESHEET_MODIFIED
, aOldName
, *this ) );
184 OUString
SfxStyleSheetBase::GetDisplayName() const
186 if( maDisplayName
.isEmpty() )
192 return maDisplayName
;
196 void SfxStyleSheetBase::SetDisplayName( const OUString
& rDisplayName
)
198 maDisplayName
= rDisplayName
;
203 const OUString
& SfxStyleSheetBase::GetParent() const
208 bool SfxStyleSheetBase::SetParent( const OUString
& rName
)
210 if ( rName
== aName
)
213 if( aParent
!= rName
)
215 SfxStyleSheetBase
* pIter
= pPool
->Find(rName
, nFamily
);
216 if( !rName
.isEmpty() && !pIter
)
218 OSL_FAIL( "StyleSheet-Parent not found" );
221 // prevent recursive linkages
222 if( !aName
.isEmpty() )
226 if(pIter
->GetName() == aName
)
228 pIter
= pPool
->Find(pIter
->GetParent(), nFamily
);
233 pPool
->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED
, *this ) );
237 void SfxStyleSheetBase::SetHidden( sal_Bool hidden
)
240 pPool
->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED
, *this ) );
245 const OUString
& SfxStyleSheetBase::GetFollow() const
250 bool SfxStyleSheetBase::SetFollow( const OUString
& rName
)
252 if( aFollow
!= rName
)
254 if( !pPool
->Find( rName
, nFamily
) )
256 SAL_WARN( "svl", "StyleSheet-Follow not found" );
261 pPool
->Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_MODIFIED
, *this ) );
265 // Set Itemset. The dflt-implementation creates a new set
267 SfxItemSet
& SfxStyleSheetBase::GetItemSet()
271 pSet
= new SfxItemSet( pPool
->GetPool() );
277 // Hilfe-Datei und -ID setzen und abfragen
279 sal_uLong
SfxStyleSheetBase::GetHelpId( OUString
& rFile
)
285 void SfxStyleSheetBase::SetHelpId( const OUString
& rFile
, sal_uLong nId
)
291 // Next style possible? Default: Yes
293 bool SfxStyleSheetBase::HasFollowSupport() const
298 // Basisvorlage m"oglich? Default: Ja
300 bool SfxStyleSheetBase::HasParentSupport() const
305 // Basisvorlage uf NULL setzen m"oglich? Default: Nein
307 bool SfxStyleSheetBase::HasClearParentSupport() const
312 // Defaultmaessig sind alle StyleSheets Used
314 bool SfxStyleSheetBase::IsUsed() const
319 // eingestellte Attribute ausgeben
321 OUString
SfxStyleSheetBase::GetDescription()
323 return GetDescription( SFX_MAPUNIT_CM
);
326 // eingestellte Attribute ausgeben
328 OUString
SfxStyleSheetBase::GetDescription( SfxMapUnit eMetric
)
330 SfxItemIter
aIter( GetItemSet() );
332 const SfxPoolItem
* pItem
= aIter
.FirstItem();
334 IntlWrapper
aIntlWrapper( SvtSysLocale().GetLanguageTag() );
337 OUString aItemPresentation
;
339 if ( !IsInvalidItem( pItem
) &&
340 pPool
->GetPool().GetPresentation(
341 *pItem
, SFX_ITEM_PRESENTATION_COMPLETE
,
342 eMetric
, aItemPresentation
, &aIntlWrapper
) )
344 if ( !aDesc
.isEmpty() && !aItemPresentation
.isEmpty() )
346 if ( !aItemPresentation
.isEmpty() )
347 aDesc
+= aItemPresentation
;
349 pItem
= aIter
.NextItem();
354 SfxStyleFamily
SfxStyleSheetIterator::GetSearchFamily() const
356 return nSearchFamily
;
359 inline bool SfxStyleSheetIterator::IsTrivialSearch()
361 return (( nMask
& SFXSTYLEBIT_ALL_VISIBLE
) == SFXSTYLEBIT_ALL_VISIBLE
) &&
362 (GetSearchFamily() == SFX_STYLE_FAMILY_ALL
);
365 bool SfxStyleSheetIterator::DoesStyleMatch(SfxStyleSheetBase
*pStyle
)
367 bool bMatchFamily
= ((GetSearchFamily() == SFX_STYLE_FAMILY_ALL
) ||
368 ( pStyle
->GetFamily() == GetSearchFamily() ));
370 bool bUsed
= bSearchUsed
? pStyle
->IsUsed( ) : false;
372 bool bSearchHidden
= ( GetSearchMask() & SFXSTYLEBIT_HIDDEN
);
373 bool bMatchVisibility
= !( !bSearchHidden
&& pStyle
->IsHidden() && !bUsed
);
374 bool bOnlyHidden
= GetSearchMask( ) == SFXSTYLEBIT_HIDDEN
&& pStyle
->IsHidden( );
376 bool bMatches
= bMatchFamily
&& bMatchVisibility
377 && (( pStyle
->GetMask() & ( GetSearchMask() & ~SFXSTYLEBIT_USED
)) ||
378 bUsed
|| bOnlyHidden
||
379 ( GetSearchMask() & SFXSTYLEBIT_ALL_VISIBLE
) == SFXSTYLEBIT_ALL_VISIBLE
);
383 SfxStyleSheetIterator::SfxStyleSheetIterator(SfxStyleSheetBasePool
*pBase
,
384 SfxStyleFamily eFam
, sal_uInt16 n
)
388 bSearchUsed
=sal_False
;
389 if( (( n
& SFXSTYLEBIT_ALL_VISIBLE
) != SFXSTYLEBIT_ALL_VISIBLE
)
390 && ((n
& SFXSTYLEBIT_USED
) == SFXSTYLEBIT_USED
))
392 bSearchUsed
= sal_True
;
393 n
&= ~SFXSTYLEBIT_USED
;
398 SfxStyleSheetIterator::~SfxStyleSheetIterator()
402 sal_uInt16
SfxStyleSheetIterator::Count()
405 if( IsTrivialSearch())
406 n
= (sal_uInt16
) pBasePool
->aStyles
.size();
408 for(sal_uInt16 i
=0; i
<pBasePool
->aStyles
.size(); i
++)
410 SfxStyleSheetBase
* pStyle
= pBasePool
->aStyles
[i
].get();
411 if(DoesStyleMatch(pStyle
))
417 SfxStyleSheetBase
* SfxStyleSheetIterator::operator[](sal_uInt16 nIdx
)
419 if( IsTrivialSearch())
420 return pBasePool
->aStyles
[nIdx
].get();
423 for(sal_uInt16 n
=0; n
<pBasePool
->aStyles
.size(); n
++)
425 SfxStyleSheetBase
* pStyle
= pBasePool
->aStyles
[n
].get();
426 if( DoesStyleMatch(pStyle
))
431 return pAktStyle
=pStyle
;
436 OSL_FAIL("Incorrect index");
440 SfxStyleSheetBase
* SfxStyleSheetIterator::First()
444 if ( IsTrivialSearch() && pBasePool
->aStyles
.size() )
447 for( sal_uInt16 n
= 0; n
< pBasePool
->aStyles
.size(); n
++ )
449 SfxStyleSheetBase
* pStyle
= pBasePool
->aStyles
[n
].get();
451 if ( DoesStyleMatch( pStyle
) )
460 nAktPosition
= (sal_uInt16
)nIdx
;
461 return pAktStyle
= pBasePool
->aStyles
[nIdx
].get();
467 SfxStyleSheetBase
* SfxStyleSheetIterator::Next()
471 if ( IsTrivialSearch() &&
472 (sal_uInt16
)pBasePool
->aStyles
.size() > nAktPosition
+ 1 )
473 nIdx
= nAktPosition
+ 1;
475 for( sal_uInt16 n
= nAktPosition
+ 1; n
< pBasePool
->aStyles
.size(); n
++ )
477 SfxStyleSheetBase
* pStyle
= pBasePool
->aStyles
[n
].get();
479 if ( DoesStyleMatch( pStyle
) )
488 nAktPosition
= (sal_uInt16
)nIdx
;
489 return pAktStyle
= pBasePool
->aStyles
[nIdx
].get();
495 SfxStyleSheetBase
* SfxStyleSheetIterator::Find(const OUString
& rStr
)
497 for ( sal_uInt16 n
= 0; n
< pBasePool
->aStyles
.size(); ++n
)
499 SfxStyleSheetBase
* pStyle
= pBasePool
->aStyles
[n
].get();
501 // #98454# performance: in case of bSearchUsed==sal_True it may be
502 // significant to first compare the name and only if it matches to call
503 // the style sheet IsUsed() method in DoesStyleMatch().
504 if ( pStyle
->GetName() == rStr
&& DoesStyleMatch( pStyle
) )
507 return pAktStyle
= pStyle
;
513 sal_uInt16
SfxStyleSheetIterator::GetSearchMask() const
515 sal_uInt16 mask
= nMask
;
518 mask
|= SFXSTYLEBIT_USED
;
523 void SfxStyleSheetBasePool::Replace( SfxStyleSheetBase
& rSource
, SfxStyleSheetBase
& rTarget
)
525 rTarget
.SetFollow( rSource
.GetFollow() );
526 rTarget
.SetParent( rSource
.GetParent() );
527 SfxItemSet
& rSourceSet
= rSource
.GetItemSet();
528 SfxItemSet
& rTargetSet
= rTarget
.GetItemSet();
529 rTargetSet
.Intersect( rSourceSet
);
530 rTargetSet
.Put( rSourceSet
);
533 SfxStyleSheetIterator
& SfxStyleSheetBasePool::GetIterator_Impl()
535 if( !pImp
->pIter
|| (pImp
->pIter
->GetSearchMask() != nMask
) || (pImp
->pIter
->GetSearchFamily() != nSearchFamily
) )
537 pImp
->pIter
= CreateIterator( nSearchFamily
, nMask
);
543 SfxStyleSheetBasePool::SfxStyleSheetBasePool( SfxItemPool
& r
)
544 : aAppName(r
.GetName())
546 , nSearchFamily(SFX_STYLE_FAMILY_PARA
)
547 , nMask(SFXSTYLEBIT_ALL
)
550 aDbgStyleSheetReferences
.mnPools
++;
553 pImp
= new SfxStyleSheetBasePool_Impl
;
556 SfxStyleSheetBasePool::SfxStyleSheetBasePool( const SfxStyleSheetBasePool
& r
)
557 : SfxBroadcaster( r
)
558 , comphelper::OWeakTypeObject()
559 , aAppName(r
.aAppName
)
561 , nSearchFamily(r
.nSearchFamily
)
565 aDbgStyleSheetReferences
.mnPools
++;
568 pImp
= new SfxStyleSheetBasePool_Impl
;
572 SfxStyleSheetBasePool::~SfxStyleSheetBasePool()
575 aDbgStyleSheetReferences
.mnPools
--;
578 Broadcast( SfxSimpleHint(SFX_HINT_DYING
) );
583 bool SfxStyleSheetBasePool::SetParent(SfxStyleFamily eFam
, const OUString
& rStyle
, const OUString
& rParent
)
585 SfxStyleSheetIterator
aIter(this,eFam
,SFXSTYLEBIT_ALL
);
586 SfxStyleSheetBase
*pStyle
= aIter
.Find(rStyle
);
587 OSL_ENSURE(pStyle
, "Template not found. Writer with solar <2541?");
589 return pStyle
->SetParent(rParent
);
595 void SfxStyleSheetBasePool::SetSearchMask(SfxStyleFamily eFam
, sal_uInt16 n
)
597 nSearchFamily
= eFam
; nMask
= n
;
600 sal_uInt16
SfxStyleSheetBasePool::GetSearchMask() const
605 SfxStyleSheetIteratorPtr
SfxStyleSheetBasePool::CreateIterator
611 return SfxStyleSheetIteratorPtr(new SfxStyleSheetIterator(this,eFam
,mask
));
614 SfxStyleSheetBase
* SfxStyleSheetBasePool::Create
616 const OUString
& rName
,
621 return new SfxStyleSheetBase( rName
, this, eFam
, mask
);
624 SfxStyleSheetBase
* SfxStyleSheetBasePool::Create( const SfxStyleSheetBase
& r
)
626 return new SfxStyleSheetBase( r
);
629 SfxStyleSheetBase
& SfxStyleSheetBasePool::Make( const OUString
& rName
, SfxStyleFamily eFam
, sal_uInt16 mask
)
631 OSL_ENSURE( eFam
!= SFX_STYLE_FAMILY_ALL
, "svl::SfxStyleSheetBasePool::Make(), FamilyAll is not a allowed Familie" );
633 SfxStyleSheetIterator
aIter(this, eFam
, mask
);
634 rtl::Reference
< SfxStyleSheetBase
> xStyle( aIter
.Find( rName
) );
635 OSL_ENSURE( !xStyle
.is(), "svl::SfxStyleSheetBasePool::Make(), StyleSheet already exists" );
639 xStyle
= Create( rName
, eFam
, mask
);
640 aStyles
.push_back(xStyle
);
641 Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED
, *xStyle
.get() ) );
643 return *xStyle
.get();
646 // Hilfsroutine: Falls eine Vorlage dieses Namens existiert, wird
647 // sie neu erzeugt. Alle Vorlagen, die diese Vorlage zum Parent haben,
648 // werden umgehaengt.
650 SfxStyleSheetBase
& SfxStyleSheetBasePool::Add( SfxStyleSheetBase
& rSheet
)
652 SfxStyleSheetIterator
aIter(this, rSheet
.GetFamily(), nMask
);
653 SfxStyleSheetBase
* pOld
= aIter
.Find( rSheet
.GetName() );
655 rtl::Reference
< SfxStyleSheetBase
> xNew( Create( rSheet
) );
656 aStyles
.push_back( xNew
);
657 Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CHANGED
, *xNew
.get() ) );
661 SfxStyleSheetBasePool
& SfxStyleSheetBasePool::operator=( const SfxStyleSheetBasePool
& r
)
671 SfxStyleSheetBasePool
& SfxStyleSheetBasePool::operator+=( const SfxStyleSheetBasePool
& r
)
675 SfxStyles::const_iterator
aIter( r
.aStyles
.begin() );
676 while( aIter
!= r
.aStyles
.end() )
678 Add(*(*aIter
++).get());
684 sal_uInt16
SfxStyleSheetBasePool::Count()
686 return GetIterator_Impl().Count();
689 SfxStyleSheetBase
*SfxStyleSheetBasePool::operator[](sal_uInt16 nIdx
)
691 return GetIterator_Impl()[nIdx
];
694 SfxStyleSheetBase
* SfxStyleSheetBasePool::Find(const OUString
& rName
,
698 SfxStyleSheetIterator
aIter(this,eFam
,mask
);
699 return aIter
.Find(rName
);
702 const SfxStyles
& SfxStyleSheetBasePool::GetStyles()
707 SfxStyleSheetBase
* SfxStyleSheetBasePool::First()
709 return GetIterator_Impl().First();
712 SfxStyleSheetBase
* SfxStyleSheetBasePool::Next()
714 return GetIterator_Impl().Next();
717 void SfxStyleSheetBasePool::Remove( SfxStyleSheetBase
* p
)
721 // Reference to keep p alive until after Broadcast call!
722 rtl::Reference
<SfxStyleSheetBase
> xP(p
);
723 SfxStyles::iterator
const aIter(
724 std::find(aStyles
.begin(), aStyles
.end(), xP
));
725 if( aIter
!= aStyles
.end() )
727 // Alle Styles umsetzen, deren Parent dieser hier ist
728 ChangeParent( p
->GetName(), p
->GetParent() );
730 // #120015# Do not dispose, the removed StyleSheet may still be used in
731 // existing SdrUndoAttrObj incarnations. Rely on refcounting for disposal,
732 // this works well under normal conditions (checked breaking and counting
733 // on SfxStyleSheetBase constructors and destructors)
735 // com::sun::star::uno::Reference< com::sun::star::lang::XComponent > xComp( static_cast< ::cppu::OWeakObject* >((*aIter).get()), com::sun::star::uno::UNO_QUERY );
736 // if( xComp.is() ) try
740 // catch( com::sun::star::uno::Exception& )
744 aStyles
.erase(aIter
);
745 Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED
, *p
) );
750 void SfxStyleSheetBasePool::Insert( SfxStyleSheetBase
* p
)
752 #if OSL_DEBUG_LEVEL > 0
753 OSL_ENSURE( p
, "svl::SfxStyleSheetBasePool::Insert(), no stylesheet?" );
755 SfxStyleSheetIterator
aIter(this, p
->GetFamily(), p
->GetMask());
756 SfxStyleSheetBase
* pOld
= aIter
.Find( p
->GetName() );
757 OSL_ENSURE( !pOld
, "svl::SfxStyleSheetBasePool::Insert(), StyleSheet already inserted" );
758 if( !p
->GetParent().isEmpty() )
760 pOld
= aIter
.Find( p
->GetParent() );
761 OSL_ENSURE( pOld
, "svl::SfxStyleSheetBasePool::Insert(), Parent not found!" );
764 aStyles
.push_back( rtl::Reference
< SfxStyleSheetBase
>( p
) );
765 Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_CREATED
, *p
) );
768 void SfxStyleSheetBasePool::Clear()
770 SfxStyles aClearStyles
;
771 aClearStyles
.swap( aStyles
);
773 SfxStyles::iterator
aIter( aClearStyles
.begin() );
774 while( aIter
!= aClearStyles
.end() )
776 com::sun::star::uno::Reference
< com::sun::star::lang::XComponent
> xComp( static_cast< ::cppu::OWeakObject
* >((*aIter
).get()), com::sun::star::uno::UNO_QUERY
);
781 catch( com::sun::star::uno::Exception
& )
785 Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_ERASED
, *(*aIter
++).get() ) );
789 void SfxStyleSheetBasePool::ChangeParent(const OUString
& rOld
,
790 const OUString
& rNew
,
793 const sal_uInt16 nTmpMask
= GetSearchMask();
794 SetSearchMask(GetSearchFamily(), SFXSTYLEBIT_ALL
);
795 for( SfxStyleSheetBase
* p
= First(); p
; p
= Next() )
797 if( p
->GetParent() == rOld
)
800 p
->SetParent( rNew
);
805 SetSearchMask(GetSearchFamily(), nTmpMask
);
808 void SfxStyleSheetBase::Load( SvStream
&, sal_uInt16
)
812 void SfxStyleSheetBase::Store( SvStream
& )
816 SfxItemPool
& SfxStyleSheetBasePool::GetPool()
821 const SfxItemPool
& SfxStyleSheetBasePool::GetPool() const
827 SfxStyleSheet::SfxStyleSheet(const OUString
&rName
,
828 const SfxStyleSheetBasePool
& r_Pool
,
831 : SfxStyleSheetBase(rName
, const_cast< SfxStyleSheetBasePool
* >( &r_Pool
), eFam
, mask
)
835 SfxStyleSheet::SfxStyleSheet(const SfxStyleSheet
& rStyle
)
836 : SfxStyleSheetBase(rStyle
)
837 , SfxListener( rStyle
)
838 , SfxBroadcaster( rStyle
)
839 , svl::StyleSheetUser()
843 SfxStyleSheet::~SfxStyleSheet()
845 Broadcast( SfxStyleSheetHint( SFX_STYLESHEET_INDESTRUCTION
, *this ) );
849 bool SfxStyleSheet::SetParent( const OUString
& rName
)
853 const OUString
aOldParent(aParent
);
854 if(SfxStyleSheetBase::SetParent(rName
))
856 // aus der Benachrichtigungskette des alten
857 // Parents gfs. austragen
858 if(!aOldParent
.isEmpty())
860 SfxStyleSheet
*pParent
= (SfxStyleSheet
*)pPool
->Find(aOldParent
, nFamily
, SFXSTYLEBIT_ALL
);
862 EndListening(*pParent
);
864 // in die Benachrichtigungskette des neuen
866 if(!aParent
.isEmpty())
868 SfxStyleSheet
*pParent
= (SfxStyleSheet
*)pPool
->Find(aParent
, nFamily
, SFXSTYLEBIT_ALL
);
870 StartListening(*pParent
);
877 // Notify all listeners
878 void SfxStyleSheet::Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
883 bool SfxStyleSheet::isUsedByModel() const
889 SfxStyleSheetPool::SfxStyleSheetPool( SfxItemPool
const& rSet
)
890 : SfxStyleSheetBasePool( const_cast< SfxItemPool
& >( rSet
) )
894 SfxStyleSheetBase
* SfxStyleSheetPool::Create( const OUString
& rName
,
895 SfxStyleFamily eFam
, sal_uInt16 mask
)
897 return new SfxStyleSheet( rName
, *this, eFam
, mask
);
900 SfxStyleSheetBase
* SfxStyleSheetPool::Create( const SfxStyleSheet
& r
)
902 return new SfxStyleSheet( r
);
905 // class SfxUnoStyleSheet
906 SfxUnoStyleSheet::SfxUnoStyleSheet( const OUString
& _rName
, const SfxStyleSheetBasePool
& _rPool
, SfxStyleFamily _eFamily
, sal_uInt16 _nMaske
)
907 : ::cppu::ImplInheritanceHelper2
< SfxStyleSheet
, ::com::sun::star::style::XStyle
, ::com::sun::star::lang::XUnoTunnel
>( _rName
, _rPool
, _eFamily
, _nMaske
)
911 SfxUnoStyleSheet
* SfxUnoStyleSheet::getUnoStyleSheet( const ::com::sun::star::uno::Reference
< ::com::sun::star::style::XStyle
>& xStyle
)
913 SfxUnoStyleSheet
* pRet
= dynamic_cast< SfxUnoStyleSheet
* >( xStyle
.get() );
916 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XUnoTunnel
> xUT( xStyle
, ::com::sun::star::uno::UNO_QUERY
);
918 pRet
= reinterpret_cast<SfxUnoStyleSheet
*>(sal::static_int_cast
<sal_uIntPtr
>(xUT
->getSomething( SfxUnoStyleSheet::getIdentifier())));
924 ::sal_Int64 SAL_CALL
SfxUnoStyleSheet::getSomething( const ::com::sun::star::uno::Sequence
< ::sal_Int8
>& rId
) throw (::com::sun::star::uno::RuntimeException
)
926 if( rId
.getLength() == 16 && 0 == memcmp( getIdentifier().getConstArray(), rId
.getConstArray(), 16 ) )
928 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_uIntPtr
>(this));
939 class theSfxUnoStyleSheetIdentifier
: public rtl::Static
< UnoTunnelIdInit
, theSfxUnoStyleSheetIdentifier
> {};
942 const ::com::sun::star::uno::Sequence
< ::sal_Int8
>& SfxUnoStyleSheet::getIdentifier()
944 return theSfxUnoStyleSheetIdentifier::get().getSeq();
947 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */