LibreOffice Module svl (master) 1
IndexedStyleSheets.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 */
9
10#ifndef INCLUDED_SVL_INDEXEDSTYLESHEETS_HXX
11#define INCLUDED_SVL_INDEXEDSTYLESHEETS_HXX
12
13#include <svl/style.hxx>
14#include <rtl/ustring.hxx>
15#include <rtl/ref.hxx>
16
17#include <svl/svldllapi.h>
18
19#include <unordered_map>
20#include <vector>
21
22namespace svl
23{
28{
29 virtual bool Check(const SfxStyleSheetBase& styleSheet) = 0;
31};
32
37{
38 virtual void Dispose(rtl::Reference<SfxStyleSheetBase> styleSheet) = 0;
40};
41
46{
47 virtual void DoIt(const SfxStyleSheetBase& styleSheet) = 0;
49};
50
72{
73public:
75
82
87 void AddStyleSheet(const rtl::Reference<SfxStyleSheetBase>& style);
88
90 bool RemoveStyleSheet(const rtl::Reference<SfxStyleSheetBase>& style);
91
93 bool HasStyleSheet(const rtl::Reference<SfxStyleSheetBase>& style) const;
94
96 sal_Int32 GetNumberOfStyleSheets() const;
97
99 sal_Int32 GetNumberOfStyleSheetsWithPredicate(StyleSheetPredicate& predicate) const;
100
106 SfxStyleSheetBase* GetStyleSheetByPosition(sal_Int32 pos);
107
112 sal_Int32 FindStyleSheetPosition(const SfxStyleSheetBase& style) const;
113
116 std::vector<sal_Int32> FindPositionsByName(const OUString& name) const;
117
118 enum class SearchBehavior
119 {
120 ReturnAll,
121 ReturnFirst
122 };
127 std::vector<sal_Int32>
128 FindPositionsByNameAndPredicate(const OUString& name, StyleSheetPredicate& predicate,
129 SearchBehavior behavior = SearchBehavior::ReturnAll) const;
130
135 std::vector<sal_Int32> FindPositionsByPredicate(StyleSheetPredicate& predicate) const;
136
138 void ApplyToAllStyleSheets(StyleSheetCallback& callback) const;
139
144 void Clear(StyleSheetDisposer& cleanup);
145
146 void Reindex();
147
149 SfxStyleSheetBase* GetNthStyleSheetThatMatchesPredicate(sal_Int32 n,
150 StyleSheetPredicate& predicate,
151 sal_Int32 startAt = 0);
152
155 const std::vector<sal_Int32>& GetStyleSheetPositionsByFamily(SfxStyleFamily) const;
156
157private:
159 void Register(const SfxStyleSheetBase& style, sal_Int32 pos);
160
161 typedef std::vector<rtl::Reference<SfxStyleSheetBase>> VectorType;
165
170 typedef std::unordered_multimap<OUString, unsigned> MapType;
171
174
175 std::vector<std::vector<sal_Int32>> mStyleSheetPositionsByFamily;
176};
177
178} /* namespace svl */
179
180#endif // INCLUDED_SVL_INDEXEDSTYLESHEETS_HXX
181
182/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class holds SfxStyleSheets and allows for access via an id and a name.
std::vector< rtl::Reference< SfxStyleSheetBase > > VectorType
MapType mPositionsByName
A map which stores the positions of style sheets by their name.
VectorType mStyleSheets
Vector with the stylesheets to allow for index-based access.
std::vector< std::vector< sal_Int32 > > mStyleSheetPositionsByFamily
std::unordered_multimap< OUString, unsigned > MapType
The map type that is used to store the mapping from strings to ids in mStyleSheets.
const char * name
void Clear(EHistoryType eHistory)
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
SfxStyleFamily
Definition: style.hxx:42
#define SVL_DLLPUBLIC
Definition: svldllapi.h:28
size_t pos