LibreOffice Module svl (master)
1
include
svl
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
22
namespace
svl
23
{
27
struct
StyleSheetPredicate
28
{
29
virtual
bool
Check
(
const
SfxStyleSheetBase
& styleSheet) = 0;
30
virtual
~StyleSheetPredicate
() {}
31
};
32
36
struct
StyleSheetDisposer
37
{
38
virtual
void
Dispose
(
rtl::Reference<SfxStyleSheetBase>
styleSheet) = 0;
39
virtual
~StyleSheetDisposer
() {}
40
};
41
45
struct
StyleSheetCallback
46
{
47
virtual
void
DoIt
(
const
SfxStyleSheetBase
& styleSheet) = 0;
48
virtual
~StyleSheetCallback
() {}
49
};
50
71
class
SVL_DLLPUBLIC
IndexedStyleSheets
final
72
{
73
public
:
74
IndexedStyleSheets
();
75
81
~IndexedStyleSheets
();
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
157
private
:
159
void
Register
(
const
SfxStyleSheetBase
& style, sal_Int32 pos);
160
161
typedef
std::vector<rtl::Reference<SfxStyleSheetBase>>
VectorType
;
164
VectorType
mStyleSheets
;
165
170
typedef
std::unordered_multimap<OUString, unsigned>
MapType
;
171
173
MapType
mPositionsByName
;
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: */
SfxStyleSheetBase
Definition:
style.hxx:115
rtl::Reference< SfxStyleSheetBase >
svl::IndexedStyleSheets
This class holds SfxStyleSheets and allows for access via an id and a name.
Definition:
IndexedStyleSheets.hxx:72
svl::IndexedStyleSheets::VectorType
std::vector< rtl::Reference< SfxStyleSheetBase > > VectorType
Definition:
IndexedStyleSheets.hxx:161
svl::IndexedStyleSheets::mPositionsByName
MapType mPositionsByName
A map which stores the positions of style sheets by their name.
Definition:
IndexedStyleSheets.hxx:173
svl::IndexedStyleSheets::mStyleSheets
VectorType mStyleSheets
Vector with the stylesheets to allow for index-based access.
Definition:
IndexedStyleSheets.hxx:164
svl::IndexedStyleSheets::mStyleSheetPositionsByFamily
std::vector< std::vector< sal_Int32 > > mStyleSheetPositionsByFamily
Definition:
IndexedStyleSheets.hxx:175
svl::IndexedStyleSheets::MapType
std::unordered_multimap< OUString, unsigned > MapType
The map type that is used to store the mapping from strings to ids in mStyleSheets.
Definition:
IndexedStyleSheets.hxx:170
svl::IndexedStyleSheets::SearchBehavior
SearchBehavior
Definition:
IndexedStyleSheets.hxx:119
name
const char * name
Clear
void Clear(EHistoryType eHistory)
svl
svl::StyleSheetCallback
Function object to apply a method on all style sheets.
Definition:
IndexedStyleSheets.hxx:46
svl::StyleSheetCallback::~StyleSheetCallback
virtual ~StyleSheetCallback()
Definition:
IndexedStyleSheets.hxx:48
svl::StyleSheetCallback::DoIt
virtual void DoIt(const SfxStyleSheetBase &styleSheet)=0
svl::StyleSheetDisposer
Function object for cleanup-Strategy for IndexedSfxStyleSheets::Clear().
Definition:
IndexedStyleSheets.hxx:37
svl::StyleSheetDisposer::Dispose
virtual void Dispose(rtl::Reference< SfxStyleSheetBase > styleSheet)=0
svl::StyleSheetDisposer::~StyleSheetDisposer
virtual ~StyleSheetDisposer()
Definition:
IndexedStyleSheets.hxx:39
svl::StyleSheetPredicate
Function object to check whether a style sheet a fulfills specific criteria.
Definition:
IndexedStyleSheets.hxx:28
svl::StyleSheetPredicate::~StyleSheetPredicate
virtual ~StyleSheetPredicate()
Definition:
IndexedStyleSheets.hxx:30
svl::StyleSheetPredicate::Check
virtual bool Check(const SfxStyleSheetBase &styleSheet)=0
style.hxx
SfxStyleFamily
SfxStyleFamily
Definition:
style.hxx:42
svldllapi.h
SVL_DLLPUBLIC
#define SVL_DLLPUBLIC
Definition:
svldllapi.h:28
PrepareHint::Register
@ Register
pos
size_t pos
Generated on Sun Jul 30 2023 04:26:35 for LibreOffice Module svl (master) by
1.9.3