23#include <com/sun/star/lang/XComponent.hpp>
26#include <osl/diagnose.h>
36#include <rtl/ustrbuf.hxx>
42class DbgStyleSheetReferences
45 DbgStyleSheetReferences() : mnStyles(0), mnPools(0) {}
46 ~DbgStyleSheetReferences()
49 mnStyles != 0 || mnPools != 0,
"svl.items",
50 "SfxStyleSheetBase left " << mnStyles
51 <<
"; SfxStyleSheetBasePool left " << mnPools);
64SfxStyleSheetModifiedHint::SfxStyleSheetModifiedHint
79:
SfxHint(nAction), pStyleSh( &rStyleSheet )
89 std::shared_ptr<SfxStyleSheetIterator>
pIter;
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 )
168 OUString aOldName =
aName;
170 if ( pOther && pOther !=
this )
173 if ( !
aName.isEmpty() )
195 if ( rName ==
aName )
201 if( !rName.isEmpty() && !pIter )
203 OSL_FAIL(
"StyleSheet-Parent not found" );
207 if( !
aName.isEmpty() )
242 SAL_WARN(
"svl.items",
"StyleSheet-Follow not found" );
326 OUStringBuffer aDesc;
331 OUString aItemPresentation;
335 *pItem, eMetric, aItemPresentation, aIntlWrapper ) )
337 if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
339 if ( !aItemPresentation.isEmpty() )
340 aDesc.append(aItemPresentation);
343 return aDesc.makeStringAndClear();
368 ( styleSheet.
GetFamily() == mIterator->GetSearchFamily() ));
370 bool bUsed = mIterator->SearchUsed() && styleSheet.
IsUsed( );
373 bool bMatchVisibility = bSearchHidden || !styleSheet.
IsHidden() || bUsed;
376 bool bMatches = bMatchFamily && bMatchVisibility
378 bUsed || bOnlyHidden ||
391 , pCurrentStyle(nullptr)
392 , mnCurrentPosition(0)
414 n =
static_cast<sal_uInt16
>(
pBasePool->
pImpl->mxIndexedStyleSheets->GetNumberOfStyleSheets());
422 DoesStyleMatchStyleSheetPredicate predicate(
this);
423 n =
pBasePool->
pImpl->mxIndexedStyleSheets->GetNumberOfStyleSheetsWithPredicate(predicate);
433 retval =
pBasePool->
pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(nIdx);
447 DoesStyleMatchStyleSheetPredicate predicate(
this);
449 pBasePool->
pImpl->mxIndexedStyleSheets->GetNthStyleSheetThatMatchesPredicate(nIdx, predicate);
457 if (retval ==
nullptr)
459 OSL_FAIL(
"Incorrect index");
481 sal_Int32 nStyleSheets =
pBasePool->
pImpl->mxIndexedStyleSheets->GetNumberOfStyleSheets();
483 if (nStyleSheets > newPosition)
492 const std::vector<sal_Int32>& familyVector
495 if (
static_cast<sal_Int32
>(familyVector.size()) > newPosition)
498 sal_Int32 stylePosition = familyVector[newPosition];
499 retval =
pBasePool->
pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(stylePosition);
504 DoesStyleMatchStyleSheetPredicate predicate(
this);
506 pBasePool->
pImpl->mxIndexedStyleSheets->GetNthStyleSheetThatMatchesPredicate(
509 if (retval !=
nullptr) {
519 DoesStyleMatchStyleSheetPredicate predicate(
this);
521 std::vector<sal_Int32> positions =
522 pBasePool->
pImpl->mxIndexedStyleSheets->FindPositionsByNameAndPredicate(rStr, predicate,
524 if (positions.empty()) {
528 sal_Int32
pos = positions.front();
546 return pImpl->pIter.get();
551 if (!
pImpl->pIter || (
pImpl->pIter->GetSearchMask() != eMask) || (
pImpl->pIter->GetSearchFamily() != eFamily))
553 return *
pImpl->pIter;
594 return std::make_unique<SfxStyleSheetIterator>(
this,eFam,mask);
599 const OUString& rName,
614 OSL_ENSURE( eFam !=
SfxStyleFamily::All,
"svl::SfxStyleSheetBasePool::Make(), FamilyAll is not an allowed Family" );
618 OSL_ENSURE( !xStyle.is(),
"svl::SfxStyleSheetBasePool::Make(), StyleSheet already exists" );
622 xStyle =
Create( rName, eFam, mask );
641 pImpl->mxIndexedStyleSheets->AddStyleSheet(xNew);
674 AddStyleSheetCallback callback(
this);
675 pImpl->mxIndexedStyleSheets->ApplyToAllStyleSheets(callback);
685 return aIter.
Find(rName);
695 assert(
pImpl->pIter &&
"Next called without a previous First");
696 return pImpl->pIter->Next();
706 bool bWasRemoved =
pImpl->mxIndexedStyleSheets->RemoveStyleSheet(xP);
731#if OSL_DEBUG_LEVEL > 0
732 OSL_ENSURE(
p,
"svl::SfxStyleSheetBasePool::Insert(), no stylesheet?" );
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!" );
759 css::uno::Reference< css::lang::XComponent > xComp( weakObject, css::uno::UNO_QUERY );
764 catch( css::uno::Exception& )
777 StyleSheetDisposerFunctor
cleanup(
this);
782 const OUString& rNew,
788 if(
p->GetParent() == rOld )
791 p->SetParent( rNew );
810 ,
svl::StyleSheetUser()
824 const OUString aOldParent(
aParent);
828 if(!aOldParent.isEmpty())
872:
cppu::ImplInheritanceHelper<
SfxStyleSheet, css::style::XStyle>(_rName, _rPool, _eFamily, _nMask)
884 pImpl->mxIndexedStyleSheets->AddStyleSheet(xStyle);
890 pImpl->mxIndexedStyleSheets->Reindex();
896 return *
pImpl->mxIndexedStyleSheets;
902 return pImpl->mxIndexedStyleSheets->GetStyleSheetByPosition(
pos);
void Broadcast(const SfxHint &rHint)
void Forward(SfxBroadcaster &rBC, const SfxHint &rHint)
const SfxPoolItem * GetCurItem() const
get item, or null if no items
const SfxPoolItem * NextItem()
Base class for providers of defaults of SfxPoolItems.
virtual bool GetPresentation(const SfxPoolItem &rItem, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntlWrapper) const
Request string representation of pool items.
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
Registers a specific SfxBroadcaster.
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
std::shared_ptr< SfxStyleSheetIterator > pIter
SfxStyleSheetBasePool_Impl & operator=(const SfxStyleSheetBasePool_Impl &)=delete
SfxStyleSheetBasePool_Impl()
std::shared_ptr< svl::IndexedStyleSheets > mxIndexedStyleSheets
This member holds the indexed style sheets.
SfxStyleSheetBasePool_Impl(const SfxStyleSheetBasePool_Impl &)=delete
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
friend class SfxStyleSheetBase
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
std::unique_ptr< SfxStyleSheetBasePool_Impl > pImpl
SfxStyleSheetIterator * GetCachedIterator()
SfxStyleSheetBase * GetStyleSheetByPositionInIndex(unsigned pos)
void Insert(SfxStyleSheetBase *)
SfxStyleSheetIterator & GetIterator_Impl(SfxStyleFamily eFamily, SfxStyleSearchBits eMask)
virtual void Remove(SfxStyleSheetBase *)
SfxStyleSheetBasePool(SfxItemPool &)
virtual ~SfxStyleSheetBasePool() override
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
void Add(const SfxStyleSheetBase &)
Add a style sheet.
void ChangeParent(std::u16string_view rOld, const OUString &rNew, SfxStyleFamily eFamily, bool bVirtual=true)
SfxStyleSheetBase * Next()
SfxStyleSheetBasePool & operator+=(const SfxStyleSheetBasePool &)
virtual rtl::Reference< SfxStyleSheetBase > Create(const OUString &, SfxStyleFamily, SfxStyleSearchBits)
void StoreStyleSheet(const rtl::Reference< SfxStyleSheetBase > &)
const svl::IndexedStyleSheets & GetIndexedStyleSheets() const
Obtain the indexed style sheets.
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
SfxStyleSheetBasePool & operator=(const SfxStyleSheetBasePool &)
SfxStyleSearchBits GetMask() const
virtual bool HasClearParentSupport() const
Setting base template to NULL possible? Default: No.
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true)
virtual const OUString & GetParent() const
const OUString & GetName() const
virtual bool HasFollowSupport() const
Next style possible? Default: Yes.
SfxStyleSheetBase(const OUString &, SfxStyleSheetBasePool *, SfxStyleFamily eFam, SfxStyleSearchBits mask)
SfxStyleFamily GetFamily() const
virtual void SetHidden(bool bValue)
virtual sal_uLong GetHelpId(OUString &rFile)
Set help file and ID and return it.
virtual void SetHelpId(const OUString &r, sal_uLong nId)
virtual bool HasParentSupport() const
Base template possible? Default: Yes.
virtual const OUString & GetFollow() const
Change follow.
virtual bool IsHidden() const
virtual bool SetParent(const OUString &)
virtual SfxItemSet & GetItemSet()
Set Itemset The default implementation creates a new set.
virtual bool IsUsed() const
By default all stylesheets are set to used.
virtual bool SetFollow(const OUString &)
SfxStyleSheetBasePool * m_pPool
virtual ~SfxStyleSheetBase() override
virtual OUString GetDescription(MapUnit eMetric)
Return set attributes.
virtual std::optional< SfxItemSet > GetItemSetForPreview()
Due to writer's usual lack of sanity this is a separate function for preview only; it shall not creat...
SfxStyleSheetHint(SfxHintId, SfxStyleSheetBase &)
virtual SfxStyleSheetBase * Find(const OUString &rStr)
SfxStyleFamily nSearchFamily
SVL_DLLPRIVATE bool IsTrivialSearch() const
virtual sal_Int32 Count()
virtual SfxStyleSheetBase * operator[](sal_Int32 nIdx)
SfxStyleFamily GetSearchFamily() const
virtual SfxStyleSheetBase * Next()
SfxStyleSearchBits GetSearchMask() const
const SfxStyleSheetBasePool * pBasePool
SfxStyleSheetIterator(const SfxStyleSheetBasePool *pBase, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
Constructor.
sal_Int32 mnCurrentPosition
virtual ~SfxStyleSheetIterator()
SfxStyleSheetBase * pCurrentStyle
virtual SfxStyleSheetBase * First()
SfxStyleSheetPool(SfxItemPool const &)
virtual rtl::Reference< SfxStyleSheetBase > Create(const OUString &, SfxStyleFamily, SfxStyleSearchBits mask) override
virtual ~SfxStyleSheet() override
SfxStyleSheet(const OUString &, const SfxStyleSheetBasePool &, SfxStyleFamily, SfxStyleSearchBits)
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Notify all listeners.
virtual bool SetParent(const OUString &) override
virtual bool isUsedByModel() const override
static SfxUnoStyleSheet * getUnoStyleSheet(const css::uno::Reference< css::style::XStyle > &xStyle)
SfxUnoStyleSheet(const OUString &_rName, const SfxStyleSheetBasePool &_rPool, SfxStyleFamily _eFamily, SfxStyleSearchBits _nMask)
This class holds SfxStyleSheets and allows for access via an id and a name.
SfxHintId
hint ids, mostly used to avoid dynamic_cast of SfxHint
@ StyleSheetInDestruction
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
tDoubleVectorPair cleanup(const css::uno::Sequence< double > &rXValues, const css::uno::Sequence< double > &rYValues, Pred aPred)
std::shared_ptr< T > make_shared(Args &&... args)
bool IsInvalidItem(const SfxPoolItem *pItem)
Function object to apply a method on all style sheets.
virtual void DoIt(const SfxStyleSheetBase &styleSheet)=0
Function object for cleanup-Strategy for IndexedSfxStyleSheets::Clear().
virtual void Dispose(rtl::Reference< SfxStyleSheetBase > styleSheet)=0
Function object to check whether a style sheet a fulfills specific criteria.
virtual bool Check(const SfxStyleSheetBase &styleSheet)=0
static DbgStyleSheetReferences aDbgStyleSheetReferences
@ Used
used styles (search mask)
@ AllVisible
all visible styles
@ Hidden
hidden styles (search mask)