LibreOffice Module svl (master) 1
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
svl::IndexedStyleSheets Class Referencefinal

This class holds SfxStyleSheets and allows for access via an id and a name. More...

#include <IndexedStyleSheets.hxx>

Public Types

enum class  SearchBehavior {
  ReturnAll ,
  ReturnFirst
}
 

Public Member Functions

 IndexedStyleSheets ()
 
 ~IndexedStyleSheets ()
 Destructor. More...
 
void AddStyleSheet (const rtl::Reference< SfxStyleSheetBase > &style)
 Adds a style sheet. More...
 
bool RemoveStyleSheet (const rtl::Reference< SfxStyleSheetBase > &style)
 Removes a style sheet. More...
 
bool HasStyleSheet (const rtl::Reference< SfxStyleSheetBase > &style) const
 Check whether a specified style sheet is stored. More...
 
sal_Int32 GetNumberOfStyleSheets () const
 Obtain the number of style sheets which are held. More...
 
sal_Int32 GetNumberOfStyleSheetsWithPredicate (StyleSheetPredicate &predicate) const
 Obtain the number of style sheets for which a certain condition holds. More...
 
SfxStyleSheetBaseGetStyleSheetByPosition (sal_Int32 pos)
 Return the stylesheet by its position. More...
 
sal_Int32 FindStyleSheetPosition (const SfxStyleSheetBase &style) const
 Find the position of a provided style. More...
 
std::vector< sal_Int32 > FindPositionsByName (const OUString &name) const
 Obtain the positions of all styles which have a given name. More...
 
std::vector< sal_Int32 > FindPositionsByNameAndPredicate (const OUString &name, StyleSheetPredicate &predicate, SearchBehavior behavior=SearchBehavior::ReturnAll) const
 Obtain the positions of all styles which have a certain name and fulfill a certain condition. More...
 
std::vector< sal_Int32 > FindPositionsByPredicate (StyleSheetPredicate &predicate) const
 Obtain the positions of all styles which fulfill a certain condition. More...
 
void ApplyToAllStyleSheets (StyleSheetCallback &callback) const
 Execute a callback on all style sheets. More...
 
void Clear (StyleSheetDisposer &cleanup)
 Clear the contents of the index. More...
 
void Reindex ()
 
SfxStyleSheetBaseGetNthStyleSheetThatMatchesPredicate (sal_Int32 n, StyleSheetPredicate &predicate, sal_Int32 startAt=0)
 Warning: counting for n starts at 0, i.e., the 0th style sheet is the first that is found. More...
 
const std::vector< sal_Int32 > & GetStyleSheetPositionsByFamily (SfxStyleFamily) const
 Get the positions of the style sheets which belong to a certain family. More...
 

Private Types

typedef std::vector< rtl::Reference< SfxStyleSheetBase > > VectorType
 
typedef std::unordered_multimap< OUString, unsigned > MapType
 The map type that is used to store the mapping from strings to ids in mStyleSheets. More...
 

Private Member Functions

void Register (const SfxStyleSheetBase &style, sal_Int32 pos)
 Register the position of a styleName in the index. More...
 

Private Attributes

VectorType mStyleSheets
 Vector with the stylesheets to allow for index-based access. More...
 
MapType mPositionsByName
 A map which stores the positions of style sheets by their name. More...
 
std::vector< std::vector< sal_Int32 > > mStyleSheetPositionsByFamily
 

Detailed Description

This class holds SfxStyleSheets and allows for access via an id and a name.

Warning
The identification of style sheets happens by their name. If the name of a sheet changes, it will not be found again! Please call Reindex() after changing a style sheet's name.

Definition at line 71 of file IndexedStyleSheets.hxx.

Member Typedef Documentation

◆ MapType

typedef std::unordered_multimap<OUString, unsigned> svl::IndexedStyleSheets::MapType
private

The map type that is used to store the mapping from strings to ids in mStyleSheets.

Definition at line 170 of file IndexedStyleSheets.hxx.

◆ VectorType

Definition at line 161 of file IndexedStyleSheets.hxx.

Member Enumeration Documentation

◆ SearchBehavior

Enumerator
ReturnAll 
ReturnFirst 

Definition at line 118 of file IndexedStyleSheets.hxx.

Constructor & Destructor Documentation

◆ IndexedStyleSheets()

svl::IndexedStyleSheets::IndexedStyleSheets ( )

Definition at line 47 of file IndexedStyleSheets.cxx.

References i, and mStyleSheetPositionsByFamily.

◆ ~IndexedStyleSheets()

svl::IndexedStyleSheets::~IndexedStyleSheets ( )

Destructor.

Definition at line 191 of file IndexedStyleSheets.cxx.

Member Function Documentation

◆ AddStyleSheet()

void svl::IndexedStyleSheets::AddStyleSheet ( const rtl::Reference< SfxStyleSheetBase > &  style)

Adds a style sheet.

If the style sheet is already contained, this call has no effect.

Definition at line 86 of file IndexedStyleSheets.cxx.

References HasStyleSheet(), mStyleSheets, and Register().

◆ ApplyToAllStyleSheets()

void svl::IndexedStyleSheets::ApplyToAllStyleSheets ( StyleSheetCallback callback) const

Execute a callback on all style sheets.

Definition at line 216 of file IndexedStyleSheets.cxx.

References svl::StyleSheetCallback::DoIt(), and mStyleSheets.

◆ Clear()

void svl::IndexedStyleSheets::Clear ( StyleSheetDisposer cleanup)

Clear the contents of the index.

The StyleSheetDisposer::Dispose() method is called on each style sheet, e.g., if you want to broadcast changes.

Definition at line 182 of file IndexedStyleSheets.cxx.

References svl::StyleSheetDisposer::Dispose(), mPositionsByName, and mStyleSheets.

◆ FindPositionsByName()

std::vector< sal_Int32 > svl::IndexedStyleSheets::FindPositionsByName ( const OUString &  name) const

Obtain the positions of all styles which have a given name.

Definition at line 112 of file IndexedStyleSheets.cxx.

References mPositionsByName, and name.

◆ FindPositionsByNameAndPredicate()

std::vector< sal_Int32 > svl::IndexedStyleSheets::FindPositionsByNameAndPredicate ( const OUString &  name,
StyleSheetPredicate predicate,
SearchBehavior  behavior = SearchBehavior::ReturnAll 
) const

Obtain the positions of all styles which have a certain name and fulfill a certain condition.

This method is fast because it can use the name-based index

Definition at line 122 of file IndexedStyleSheets.cxx.

References svl::StyleSheetPredicate::Check(), mPositionsByName, mStyleSheets, name, pos, and ReturnFirst.

◆ FindPositionsByPredicate()

std::vector< sal_Int32 > svl::IndexedStyleSheets::FindPositionsByPredicate ( StyleSheetPredicate predicate) const

Obtain the positions of all styles which fulfill a certain condition.

This method is slow because it cannot use the name-based index

Definition at line 224 of file IndexedStyleSheets.cxx.

References svl::StyleSheetPredicate::Check(), and mStyleSheets.

◆ FindStyleSheetPosition()

sal_Int32 svl::IndexedStyleSheets::FindStyleSheetPosition ( const SfxStyleSheetBase style) const

Find the position of a provided style.

Exceptions
std::runtime_errorif the style has not been found.

Definition at line 172 of file IndexedStyleSheets.cxx.

References mStyleSheets.

◆ GetNthStyleSheetThatMatchesPredicate()

SfxStyleSheetBase * svl::IndexedStyleSheets::GetNthStyleSheetThatMatchesPredicate ( sal_Int32  n,
StyleSheetPredicate predicate,
sal_Int32  startAt = 0 
)

Warning: counting for n starts at 0, i.e., the 0th style sheet is the first that is found.

Definition at line 152 of file IndexedStyleSheets.cxx.

References svl::StyleSheetPredicate::Check(), mStyleSheets, and n.

◆ GetNumberOfStyleSheets()

sal_Int32 svl::IndexedStyleSheets::GetNumberOfStyleSheets ( ) const

Obtain the number of style sheets which are held.

Definition at line 80 of file IndexedStyleSheets.cxx.

References mStyleSheets.

◆ GetNumberOfStyleSheetsWithPredicate()

sal_Int32 svl::IndexedStyleSheets::GetNumberOfStyleSheetsWithPredicate ( StyleSheetPredicate predicate) const

Obtain the number of style sheets for which a certain condition holds.

Definition at line 142 of file IndexedStyleSheets.cxx.

References mStyleSheets.

◆ GetStyleSheetByPosition()

SfxStyleSheetBase * svl::IndexedStyleSheets::GetStyleSheetByPosition ( sal_Int32  pos)

Return the stylesheet by its position.

You can obtain the position by, e.g., FindStyleSheetPosition()

Definition at line 208 of file IndexedStyleSheets.cxx.

References mStyleSheets, and pos.

◆ GetStyleSheetPositionsByFamily()

const std::vector< sal_Int32 > & svl::IndexedStyleSheets::GetStyleSheetPositionsByFamily ( SfxStyleFamily  e) const

Get the positions of the style sheets which belong to a certain family.

Definition at line 236 of file IndexedStyleSheets.cxx.

References mStyleSheetPositionsByFamily, and position().

◆ HasStyleSheet()

bool svl::IndexedStyleSheets::HasStyleSheet ( const rtl::Reference< SfxStyleSheetBase > &  style) const

Check whether a specified style sheet is stored.

Definition at line 196 of file IndexedStyleSheets.cxx.

References mPositionsByName, and mStyleSheets.

Referenced by AddStyleSheet().

◆ Register()

void svl::IndexedStyleSheets::Register ( const SfxStyleSheetBase style,
sal_Int32  pos 
)
private

Register the position of a styleName in the index.

Definition at line 54 of file IndexedStyleSheets.cxx.

References All, SfxStyleSheetBase::GetFamily(), SfxStyleSheetBase::GetName(), mPositionsByName, mStyleSheetPositionsByFamily, pos, and position().

Referenced by AddStyleSheet(), and Reindex().

◆ Reindex()

void svl::IndexedStyleSheets::Reindex ( )

Definition at line 64 of file IndexedStyleSheets.cxx.

References i, mPositionsByName, mStyleSheetPositionsByFamily, mStyleSheets, p, and Register().

Referenced by RemoveStyleSheet().

◆ RemoveStyleSheet()

bool svl::IndexedStyleSheets::RemoveStyleSheet ( const rtl::Reference< SfxStyleSheetBase > &  style)

Removes a style sheet.

Definition at line 96 of file IndexedStyleSheets.cxx.

References mPositionsByName, mStyleSheets, pos, and Reindex().

Member Data Documentation

◆ mPositionsByName

MapType svl::IndexedStyleSheets::mPositionsByName
private

A map which stores the positions of style sheets by their name.

Definition at line 173 of file IndexedStyleSheets.hxx.

Referenced by Clear(), FindPositionsByName(), FindPositionsByNameAndPredicate(), HasStyleSheet(), Register(), Reindex(), and RemoveStyleSheet().

◆ mStyleSheetPositionsByFamily

std::vector<std::vector<sal_Int32> > svl::IndexedStyleSheets::mStyleSheetPositionsByFamily
private

◆ mStyleSheets

VectorType svl::IndexedStyleSheets::mStyleSheets
private

The documentation for this class was generated from the following files: