LibreOffice Module svl (master) 1
|
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... | |
SfxStyleSheetBase * | GetStyleSheetByPosition (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 () |
SfxStyleSheetBase * | 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. 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 |
This class holds SfxStyleSheets and allows for access via an id and a name.
Definition at line 71 of file IndexedStyleSheets.hxx.
|
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.
|
private |
Definition at line 161 of file IndexedStyleSheets.hxx.
|
strong |
Enumerator | |
---|---|
ReturnAll | |
ReturnFirst |
Definition at line 118 of file IndexedStyleSheets.hxx.
svl::IndexedStyleSheets::IndexedStyleSheets | ( | ) |
Definition at line 47 of file IndexedStyleSheets.cxx.
References i, and mStyleSheetPositionsByFamily.
svl::IndexedStyleSheets::~IndexedStyleSheets | ( | ) |
Destructor.
Definition at line 191 of file IndexedStyleSheets.cxx.
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().
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.
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.
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.
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.
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.
sal_Int32 svl::IndexedStyleSheets::FindStyleSheetPosition | ( | const SfxStyleSheetBase & | style | ) | const |
Find the position of a provided style.
std::runtime_error | if the style has not been found. |
Definition at line 172 of file IndexedStyleSheets.cxx.
References mStyleSheets.
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.
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.
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.
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.
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().
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().
|
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().
void svl::IndexedStyleSheets::Reindex | ( | ) |
Definition at line 64 of file IndexedStyleSheets.cxx.
References i, mPositionsByName, mStyleSheetPositionsByFamily, mStyleSheets, p, and Register().
Referenced by 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().
|
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().
|
private |
Definition at line 175 of file IndexedStyleSheets.hxx.
Referenced by GetStyleSheetPositionsByFamily(), IndexedStyleSheets(), Register(), and Reindex().
|
private |
Vector with the stylesheets to allow for index-based access.
Definition at line 164 of file IndexedStyleSheets.hxx.
Referenced by AddStyleSheet(), ApplyToAllStyleSheets(), Clear(), FindPositionsByNameAndPredicate(), FindPositionsByPredicate(), FindStyleSheetPosition(), GetNthStyleSheetThatMatchesPredicate(), GetNumberOfStyleSheets(), GetNumberOfStyleSheetsWithPredicate(), GetStyleSheetByPosition(), HasStyleSheet(), Reindex(), and RemoveStyleSheet().