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 .
21 #include <svl/style.hxx>
23 #include <com/sun/star/lang/XComponent.hpp>
25 #include <sal/log.hxx>
26 #include <osl/diagnose.h>
27 #include <unotools/intlwrapper.hxx>
28 #include <svl/hint.hxx>
29 #include <svl/poolitem.hxx>
30 #include <svl/itemset.hxx>
31 #include <svl/itempool.hxx>
32 #include <svl/IndexedStyleSheets.hxx>
33 #include <svl/itemiter.hxx>
34 #include <unotools/syslocale.hxx>
35 #include <comphelper/servicehelper.hxx>
36 #include <rtl/ustrbuf.hxx>
42 class DbgStyleSheetReferences
45 DbgStyleSheetReferences() : mnStyles(0), mnPools(0) {}
46 ~DbgStyleSheetReferences()
49 mnStyles
!= 0 || mnPools
!= 0, "svl.items",
50 "SfxStyleSheetBase left " << mnStyles
51 << "; SfxStyleSheetBasePool left " << mnPools
);
60 static DbgStyleSheetReferences aDbgStyleSheetReferences
;
64 SfxStyleSheetModifiedHint::SfxStyleSheetModifiedHint
67 SfxStyleSheetBase
& rStyleSheet
// Remains with the caller
69 : SfxStyleSheetHint( SfxHintId::StyleSheetModified
, rStyleSheet
),
70 aName(std::move( aOldName
))
74 SfxStyleSheetHint::SfxStyleSheetHint
77 SfxStyleSheetBase
& rStyleSheet
// Remains with the caller
79 : SfxHint(nAction
), pStyleSh( &rStyleSheet
)
83 class SfxStyleSheetBasePool_Impl
86 SfxStyleSheetBasePool_Impl(const SfxStyleSheetBasePool_Impl
&) = delete;
87 SfxStyleSheetBasePool_Impl
& operator=(const SfxStyleSheetBasePool_Impl
&) = delete;
89 std::shared_ptr
<SfxStyleSheetIterator
> pIter
;
91 /** This member holds the indexed style sheets.
94 * This member is private and not protected in order to have more control which style sheets are added
95 * where. Ideally, all calls which add/remove/change style sheets are done in the base class.
97 std::shared_ptr
<svl::IndexedStyleSheets
> mxIndexedStyleSheets
;
99 SfxStyleSheetBasePool_Impl() :
100 mxIndexedStyleSheets(std::make_shared
<svl::IndexedStyleSheets
>()) {}
104 SfxStyleSheetBase::SfxStyleSheetBase( const OUString
& rName
, SfxStyleSheetBasePool
* p
, SfxStyleFamily eFam
, SfxStyleSearchBits mask
)
116 aDbgStyleSheetReferences
.mnStyles
++;
120 SfxStyleSheetBase::SfxStyleSheetBase( const SfxStyleSheetBase
& r
)
122 , m_pPool( r
.m_pPool
)
123 , nFamily( r
.nFamily
)
125 , aParent( r
.aParent
)
126 , aFollow( r
.aFollow
)
127 , aHelpFile( r
.aHelpFile
)
129 , nHelpId( r
.nHelpId
)
131 , bHidden( r
.bHidden
)
134 aDbgStyleSheetReferences
.mnStyles
++;
137 pSet
= bMySet
? new SfxItemSet( *r
.pSet
) : r
.pSet
;
142 SfxStyleSheetBase::~SfxStyleSheetBase()
145 --aDbgStyleSheetReferences
.mnStyles
;
156 const OUString
& SfxStyleSheetBase::GetName() const
161 bool SfxStyleSheetBase::SetName(const OUString
& rName
, bool bReIndexNow
)
168 OUString aOldName
= aName
;
169 SfxStyleSheetBase
*pOther
= m_pPool
->Find( rName
, nFamily
) ;
170 if ( pOther
&& pOther
!= this )
173 if ( !aName
.isEmpty() )
174 m_pPool
->ChangeParent(aName
, rName
, nFamily
, false);
176 if ( aFollow
== aName
)
182 m_pPool
->Broadcast( SfxStyleSheetModifiedHint( aOldName
, *this ) );
188 const OUString
& SfxStyleSheetBase::GetParent() const
193 bool SfxStyleSheetBase::SetParent( const OUString
& rName
)
195 if ( rName
== aName
)
198 if( aParent
!= rName
)
200 SfxStyleSheetBase
* pIter
= m_pPool
->Find(rName
, nFamily
);
201 if( !rName
.isEmpty() && !pIter
)
203 OSL_FAIL( "StyleSheet-Parent not found" );
206 // prevent recursive linkages
207 if( !aName
.isEmpty() )
211 if(pIter
->GetName() == aName
)
213 pIter
= m_pPool
->Find(pIter
->GetParent(), nFamily
);
218 m_pPool
->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified
, *this ) );
222 void SfxStyleSheetBase::SetHidden( bool hidden
)
225 m_pPool
->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified
, *this ) );
231 const OUString
& SfxStyleSheetBase::GetFollow() const
236 bool SfxStyleSheetBase::SetFollow( const OUString
& rName
)
238 if( aFollow
!= rName
)
240 if( !m_pPool
->Find( rName
, nFamily
) )
242 SAL_WARN( "svl.items", "StyleSheet-Follow not found" );
247 m_pPool
->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified
, *this ) );
253 * The default implementation creates a new set
255 SfxItemSet
& SfxStyleSheetBase::GetItemSet()
259 pSet
= new SfxItemSet( m_pPool
->GetPool() );
265 std::optional
<SfxItemSet
> SfxStyleSheetBase::GetItemSetForPreview()
271 * Set help file and ID and return it
273 sal_uLong
SfxStyleSheetBase::GetHelpId( OUString
& rFile
)
279 void SfxStyleSheetBase::SetHelpId( const OUString
& rFile
, sal_uLong nId
)
286 * Next style possible?
289 bool SfxStyleSheetBase::HasFollowSupport() const
295 * Base template possible?
298 bool SfxStyleSheetBase::HasParentSupport() const
304 * Setting base template to NULL possible?
307 bool SfxStyleSheetBase::HasClearParentSupport() const
313 * By default all stylesheets are set to used
315 bool SfxStyleSheetBase::IsUsed() const
321 * Return set attributes
323 OUString
SfxStyleSheetBase::GetDescription( MapUnit eMetric
)
325 SfxItemIter
aIter( GetItemSet() );
326 OUStringBuffer aDesc
;
328 IntlWrapper
aIntlWrapper(SvtSysLocale().GetUILanguageTag());
329 for (const SfxPoolItem
* pItem
= aIter
.GetCurItem(); pItem
; pItem
= aIter
.NextItem())
331 OUString aItemPresentation
;
333 if ( !IsInvalidItem( pItem
) &&
334 m_pPool
->GetPool().GetPresentation(
335 *pItem
, eMetric
, aItemPresentation
, aIntlWrapper
) )
337 if ( !aDesc
.isEmpty() && !aItemPresentation
.isEmpty() )
339 if ( !aItemPresentation
.isEmpty() )
340 aDesc
.append(aItemPresentation
);
343 return aDesc
.makeStringAndClear();
346 SfxStyleFamily
SfxStyleSheetIterator::GetSearchFamily() const
348 return nSearchFamily
;
351 inline bool SfxStyleSheetIterator::IsTrivialSearch() const
353 return (( nMask
& SfxStyleSearchBits::AllVisible
) == SfxStyleSearchBits::AllVisible
) &&
354 (GetSearchFamily() == SfxStyleFamily::All
);
359 struct DoesStyleMatchStyleSheetPredicate final
: public svl::StyleSheetPredicate
361 explicit DoesStyleMatchStyleSheetPredicate(SfxStyleSheetIterator
*it
)
365 Check(const SfxStyleSheetBase
& styleSheet
) override
367 bool bMatchFamily
= ((mIterator
->GetSearchFamily() == SfxStyleFamily::All
) ||
368 ( styleSheet
.GetFamily() == mIterator
->GetSearchFamily() ));
370 bool bUsed
= mIterator
->SearchUsed() && styleSheet
.IsUsed( );
372 bool bSearchHidden( mIterator
->GetSearchMask() & SfxStyleSearchBits::Hidden
);
373 bool bMatchVisibility
= bSearchHidden
|| !styleSheet
.IsHidden() || bUsed
;
374 bool bOnlyHidden
= mIterator
->GetSearchMask( ) == SfxStyleSearchBits::Hidden
&& styleSheet
.IsHidden( );
376 bool bMatches
= bMatchFamily
&& bMatchVisibility
377 && (( styleSheet
.GetMask() & ( mIterator
->GetSearchMask() & ~SfxStyleSearchBits::Used
)) ||
378 bUsed
|| bOnlyHidden
||
379 ( mIterator
->GetSearchMask() & SfxStyleSearchBits::AllVisible
) == SfxStyleSearchBits::AllVisible
);
383 SfxStyleSheetIterator
*mIterator
;
388 SfxStyleSheetIterator::SfxStyleSheetIterator(const SfxStyleSheetBasePool
*pBase
,
389 SfxStyleFamily eFam
, SfxStyleSearchBits n
)
391 , pCurrentStyle(nullptr)
392 , mnCurrentPosition(0)
396 if( (( n
& SfxStyleSearchBits::AllVisible
) != SfxStyleSearchBits::AllVisible
)
397 && ((n
& SfxStyleSearchBits::Used
) == SfxStyleSearchBits::Used
))
400 n
&= ~SfxStyleSearchBits::Used
;
405 SfxStyleSheetIterator::~SfxStyleSheetIterator()
409 sal_Int32
SfxStyleSheetIterator::Count()
412 if( IsTrivialSearch())
414 n
= static_cast<sal_uInt16
>(pBasePool
->pImpl
->mxIndexedStyleSheets
->GetNumberOfStyleSheets());
416 else if(nMask
== SfxStyleSearchBits::All
)
418 n
= static_cast<sal_uInt16
>(pBasePool
->pImpl
->mxIndexedStyleSheets
->GetStyleSheetPositionsByFamily(nSearchFamily
).size());
422 DoesStyleMatchStyleSheetPredicate
predicate(this);
423 n
= pBasePool
->pImpl
->mxIndexedStyleSheets
->GetNumberOfStyleSheetsWithPredicate(predicate
);
428 SfxStyleSheetBase
* SfxStyleSheetIterator::operator[](sal_Int32 nIdx
)
430 SfxStyleSheetBase
* retval
= nullptr;
431 if( IsTrivialSearch())
433 retval
= pBasePool
->pImpl
->mxIndexedStyleSheets
->GetStyleSheetByPosition(nIdx
);
434 mnCurrentPosition
= nIdx
;
436 else if(nMask
== SfxStyleSearchBits::All
)
438 rtl::Reference
< SfxStyleSheetBase
> ref
=
439 pBasePool
->pImpl
->mxIndexedStyleSheets
->GetStyleSheetByPosition(
440 pBasePool
->pImpl
->mxIndexedStyleSheets
->GetStyleSheetPositionsByFamily(nSearchFamily
).at(nIdx
))
443 mnCurrentPosition
= nIdx
;
447 DoesStyleMatchStyleSheetPredicate
predicate(this);
448 rtl::Reference
< SfxStyleSheetBase
> ref
=
449 pBasePool
->pImpl
->mxIndexedStyleSheets
->GetNthStyleSheetThatMatchesPredicate(nIdx
, predicate
);
452 mnCurrentPosition
= pBasePool
->pImpl
->mxIndexedStyleSheets
->FindStyleSheetPosition(*ref
);
457 if (retval
== nullptr)
459 OSL_FAIL("Incorrect index");
465 SfxStyleSheetBase
* SfxStyleSheetIterator::First()
468 return operator[](0);
475 SfxStyleSheetBase
* SfxStyleSheetIterator::Next()
477 SfxStyleSheetBase
* retval
= nullptr;
479 if ( IsTrivialSearch() )
481 sal_Int32 nStyleSheets
= pBasePool
->pImpl
->mxIndexedStyleSheets
->GetNumberOfStyleSheets();
482 sal_Int32 newPosition
= mnCurrentPosition
+ 1;
483 if (nStyleSheets
> newPosition
)
485 mnCurrentPosition
= newPosition
;
486 retval
= pBasePool
->pImpl
->mxIndexedStyleSheets
->GetStyleSheetByPosition(mnCurrentPosition
);
489 else if(nMask
== SfxStyleSearchBits::All
)
491 sal_Int32 newPosition
= mnCurrentPosition
+ 1;
492 const std::vector
<sal_Int32
>& familyVector
494 pBasePool
->pImpl
->mxIndexedStyleSheets
->GetStyleSheetPositionsByFamily(nSearchFamily
);
495 if (static_cast<sal_Int32
>(familyVector
.size()) > newPosition
)
497 mnCurrentPosition
= newPosition
;
498 sal_Int32 stylePosition
= familyVector
[newPosition
];
499 retval
= pBasePool
->pImpl
->mxIndexedStyleSheets
->GetStyleSheetByPosition(stylePosition
);
504 DoesStyleMatchStyleSheetPredicate
predicate(this);
505 rtl::Reference
< SfxStyleSheetBase
> ref
=
506 pBasePool
->pImpl
->mxIndexedStyleSheets
->GetNthStyleSheetThatMatchesPredicate(
507 0, predicate
, mnCurrentPosition
+1);
509 if (retval
!= nullptr) {
510 mnCurrentPosition
= pBasePool
->pImpl
->mxIndexedStyleSheets
->FindStyleSheetPosition(*ref
);
513 pCurrentStyle
= retval
;
517 SfxStyleSheetBase
* SfxStyleSheetIterator::Find(const OUString
& rStr
)
519 DoesStyleMatchStyleSheetPredicate
predicate(this);
521 std::vector
<sal_Int32
> positions
=
522 pBasePool
->pImpl
->mxIndexedStyleSheets
->FindPositionsByNameAndPredicate(rStr
, predicate
,
523 svl::IndexedStyleSheets::SearchBehavior::ReturnFirst
);
524 if (positions
.empty()) {
528 sal_Int32 pos
= positions
.front();
529 SfxStyleSheetBase
* pStyle
= pBasePool
->pImpl
->mxIndexedStyleSheets
->GetStyleSheetByPosition(pos
);
530 mnCurrentPosition
= pos
;
531 pCurrentStyle
= pStyle
;
532 return pCurrentStyle
;
535 SfxStyleSearchBits
SfxStyleSheetIterator::GetSearchMask() const
537 SfxStyleSearchBits mask
= nMask
;
540 mask
|= SfxStyleSearchBits::Used
;
544 SfxStyleSheetIterator
* SfxStyleSheetBasePool::GetCachedIterator()
546 return pImpl
->pIter
.get();
549 SfxStyleSheetIterator
& SfxStyleSheetBasePool::GetIterator_Impl(SfxStyleFamily eFamily
, SfxStyleSearchBits eMask
)
551 if (!pImpl
->pIter
|| (pImpl
->pIter
->GetSearchMask() != eMask
) || (pImpl
->pIter
->GetSearchFamily() != eFamily
))
552 pImpl
->pIter
= CreateIterator(eFamily
, eMask
);
553 return *pImpl
->pIter
;
556 SfxStyleSheetBasePool::SfxStyleSheetBasePool( SfxItemPool
& r
) :
557 pImpl(new SfxStyleSheetBasePool_Impl
),
561 aDbgStyleSheetReferences
.mnPools
++;
565 SfxStyleSheetBasePool::SfxStyleSheetBasePool( const SfxStyleSheetBasePool
& r
) :
568 pImpl(new SfxStyleSheetBasePool_Impl
),
572 aDbgStyleSheetReferences
.mnPools
++;
578 SfxStyleSheetBasePool::~SfxStyleSheetBasePool()
581 aDbgStyleSheetReferences
.mnPools
--;
584 Broadcast( SfxHint(SfxHintId::Dying
) );
588 std::unique_ptr
<SfxStyleSheetIterator
> SfxStyleSheetBasePool::CreateIterator
591 SfxStyleSearchBits mask
594 return std::make_unique
<SfxStyleSheetIterator
>(this,eFam
,mask
);
597 rtl::Reference
<SfxStyleSheetBase
> SfxStyleSheetBasePool::Create
599 const OUString
& rName
,
601 SfxStyleSearchBits mask
604 return new SfxStyleSheetBase( rName
, this, eFam
, mask
);
607 rtl::Reference
<SfxStyleSheetBase
> SfxStyleSheetBasePool::Create( const SfxStyleSheetBase
& r
)
609 return new SfxStyleSheetBase( r
);
612 SfxStyleSheetBase
& SfxStyleSheetBasePool::Make( const OUString
& rName
, SfxStyleFamily eFam
, SfxStyleSearchBits mask
)
614 OSL_ENSURE( eFam
!= SfxStyleFamily::All
, "svl::SfxStyleSheetBasePool::Make(), FamilyAll is not an allowed Family" );
616 SfxStyleSheetIterator
aIter(this, eFam
, mask
);
617 rtl::Reference
< SfxStyleSheetBase
> xStyle( aIter
.Find( rName
) );
618 OSL_ENSURE( !xStyle
.is(), "svl::SfxStyleSheetBasePool::Make(), StyleSheet already exists" );
622 xStyle
= Create( rName
, eFam
, mask
);
623 StoreStyleSheet(xStyle
);
624 Broadcast(SfxStyleSheetHint(SfxHintId::StyleSheetCreated
, *xStyle
));
630 * Helper function: If a template with this name exists it is created
631 * anew. All templates that have this template as a parent are reconnected.
633 void SfxStyleSheetBasePool::Add( const SfxStyleSheetBase
& rSheet
)
635 SfxStyleSheetIterator
aIter(this, rSheet
.GetFamily(), SfxStyleSearchBits::All
);
636 SfxStyleSheetBase
* pOld
= aIter
.Find( rSheet
.GetName() );
640 rtl::Reference
< SfxStyleSheetBase
> xNew( Create( rSheet
) );
641 pImpl
->mxIndexedStyleSheets
->AddStyleSheet(xNew
);
642 Broadcast(SfxStyleSheetHint(SfxHintId::StyleSheetChanged
, *xNew
));
645 SfxStyleSheetBasePool
& SfxStyleSheetBasePool::operator=( const SfxStyleSheetBasePool
& r
)
656 struct AddStyleSheetCallback
: svl::StyleSheetCallback
658 explicit AddStyleSheetCallback(SfxStyleSheetBasePool
*pool
)
661 void DoIt(const SfxStyleSheetBase
& ssheet
) override
666 SfxStyleSheetBasePool
*mPool
;
670 SfxStyleSheetBasePool
& SfxStyleSheetBasePool::operator+=( const SfxStyleSheetBasePool
& r
)
674 AddStyleSheetCallback
callback(this);
675 pImpl
->mxIndexedStyleSheets
->ApplyToAllStyleSheets(callback
);
680 SfxStyleSheetBase
* SfxStyleSheetBasePool::Find(const OUString
& rName
,
681 SfxStyleFamily eFamily
,
682 SfxStyleSearchBits eMask
)
684 SfxStyleSheetIterator
aIter(this, eFamily
, eMask
);
685 return aIter
.Find(rName
);
688 SfxStyleSheetBase
* SfxStyleSheetBasePool::First(SfxStyleFamily eFamily
, SfxStyleSearchBits eMask
)
690 return GetIterator_Impl(eFamily
, eMask
).First();
693 SfxStyleSheetBase
* SfxStyleSheetBasePool::Next()
695 assert(pImpl
->pIter
&& "Next called without a previous First");
696 return pImpl
->pIter
->Next();
699 void SfxStyleSheetBasePool::Remove( SfxStyleSheetBase
* p
)
704 // Reference to keep p alive until after Broadcast call!
705 rtl::Reference
<SfxStyleSheetBase
> xP(p
);
706 bool bWasRemoved
= pImpl
->mxIndexedStyleSheets
->RemoveStyleSheet(xP
);
710 // Adapt all styles which have this style as parent
711 ChangeParent(p
->GetName(), p
->GetParent(), p
->GetFamily());
713 // #120015# Do not dispose, the removed StyleSheet may still be used in
714 // existing SdrUndoAttrObj incarnations. Rely on refcounting for disposal,
715 // this works well under normal conditions (checked breaking and counting
716 // on SfxStyleSheetBase constructors and destructors)
718 // css::uno::Reference< css::lang::XComponent > xComp( getXWeak((*aIter).get()), css::uno::UNO_QUERY );
719 // if( xComp.is() ) try
723 // catch( css::uno::Exception& )
726 Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetErased
, *p
) );
729 void SfxStyleSheetBasePool::Insert( SfxStyleSheetBase
* p
)
731 #if OSL_DEBUG_LEVEL > 0
732 OSL_ENSURE( p
, "svl::SfxStyleSheetBasePool::Insert(), no stylesheet?" );
734 SfxStyleSheetIterator
aIter(this, p
->GetFamily(), p
->GetMask());
735 SfxStyleSheetBase
* pOld
= aIter
.Find( p
->GetName() );
736 OSL_ENSURE( !pOld
, "svl::SfxStyleSheetBasePool::Insert(), StyleSheet already inserted" );
737 if( !p
->GetParent().isEmpty() )
739 pOld
= aIter
.Find( p
->GetParent() );
740 OSL_ENSURE( pOld
, "svl::SfxStyleSheetBasePool::Insert(), Parent not found!" );
743 StoreStyleSheet(rtl::Reference
< SfxStyleSheetBase
>( p
) );
744 Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetCreated
, *p
) );
750 struct StyleSheetDisposerFunctor final
: public svl::StyleSheetDisposer
752 explicit StyleSheetDisposerFunctor(SfxStyleSheetBasePool
* pool
)
756 Dispose(rtl::Reference
<SfxStyleSheetBase
> styleSheet
) override
758 cppu::OWeakObject
* weakObject
= styleSheet
.get();
759 css::uno::Reference
< css::lang::XComponent
> xComp( weakObject
, css::uno::UNO_QUERY
);
764 catch( css::uno::Exception
& )
767 mPool
->Broadcast(SfxStyleSheetHint(SfxHintId::StyleSheetErased
, *styleSheet
));
770 SfxStyleSheetBasePool
* mPool
;
775 void SfxStyleSheetBasePool::Clear()
777 StyleSheetDisposerFunctor
cleanup(this);
778 pImpl
->mxIndexedStyleSheets
->Clear(cleanup
);
781 void SfxStyleSheetBasePool::ChangeParent(std::u16string_view rOld
,
782 const OUString
& rNew
,
783 SfxStyleFamily eFamily
,
786 for( SfxStyleSheetBase
* p
= First(eFamily
); p
; p
= Next() )
788 if( p
->GetParent() == rOld
)
791 p
->SetParent( rNew
);
798 SfxStyleSheet::SfxStyleSheet(const OUString
&rName
,
799 const SfxStyleSheetBasePool
& r_Pool
,
801 SfxStyleSearchBits mask
)
802 : SfxStyleSheetBase(rName
, const_cast< SfxStyleSheetBasePool
* >( &r_Pool
), eFam
, mask
)
806 SfxStyleSheet::SfxStyleSheet(const SfxStyleSheet
& rStyle
)
807 : SfxStyleSheetBase(rStyle
)
808 , SfxListener( rStyle
)
809 , SfxBroadcaster( rStyle
)
810 , svl::StyleSheetUser()
814 SfxStyleSheet::~SfxStyleSheet()
816 Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetInDestruction
, *this ) );
820 bool SfxStyleSheet::SetParent( const OUString
& rName
)
824 const OUString
aOldParent(aParent
);
825 if(SfxStyleSheetBase::SetParent(rName
))
827 // Remove from notification chain of the old parent if applicable
828 if(!aOldParent
.isEmpty())
830 SfxStyleSheet
*pParent
= static_cast<SfxStyleSheet
*>(m_pPool
->Find(aOldParent
, nFamily
));
832 EndListening(*pParent
);
834 // Add to the notification chain of the new parent
835 if(!aParent
.isEmpty())
837 SfxStyleSheet
*pParent
= static_cast<SfxStyleSheet
*>(m_pPool
->Find(aParent
, nFamily
));
839 StartListening(*pParent
);
847 * Notify all listeners
849 void SfxStyleSheet::Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
854 bool SfxStyleSheet::isUsedByModel() const
860 SfxStyleSheetPool::SfxStyleSheetPool( SfxItemPool
const& rSet
)
861 : SfxStyleSheetBasePool( const_cast< SfxItemPool
& >( rSet
) )
865 rtl::Reference
<SfxStyleSheetBase
> SfxStyleSheetPool::Create( const OUString
& rName
,
866 SfxStyleFamily eFam
, SfxStyleSearchBits mask
)
868 return new SfxStyleSheet( rName
, *this, eFam
, mask
);
871 SfxUnoStyleSheet::SfxUnoStyleSheet( const OUString
& _rName
, const SfxStyleSheetBasePool
& _rPool
, SfxStyleFamily _eFamily
, SfxStyleSearchBits _nMask
)
872 : cppu::ImplInheritanceHelper
<SfxStyleSheet
, css::style::XStyle
>(_rName
, _rPool
, _eFamily
, _nMask
)
876 SfxUnoStyleSheet
* SfxUnoStyleSheet::getUnoStyleSheet( const css::uno::Reference
< css::style::XStyle
>& xStyle
)
878 return dynamic_cast<SfxUnoStyleSheet
*>(xStyle
.get());
882 SfxStyleSheetBasePool::StoreStyleSheet(const rtl::Reference
< SfxStyleSheetBase
>& xStyle
)
884 pImpl
->mxIndexedStyleSheets
->AddStyleSheet(xStyle
);
888 SfxStyleSheetBasePool::Reindex()
890 pImpl
->mxIndexedStyleSheets
->Reindex();
893 const svl::IndexedStyleSheets
&
894 SfxStyleSheetBasePool::GetIndexedStyleSheets() const
896 return *pImpl
->mxIndexedStyleSheets
;
900 SfxStyleSheetBasePool::GetStyleSheetByPositionInIndex(unsigned pos
)
902 return pImpl
->mxIndexedStyleSheets
->GetStyleSheetByPosition(pos
);
905 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */