LibreOffice Module svl (master) 1
srchitem.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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_SVL_SRCHITEM_HXX
20#define INCLUDED_SVL_SRCHITEM_HXX
21
22#include <sal/config.h>
23#include <svl/svldllapi.h>
24#include <com/sun/star/util/SearchAlgorithms2.hpp>
25#include <com/sun/star/util/SearchFlags.hpp>
29#include <svl/style.hxx>
30#include <svl/poolitem.hxx>
31
32// defines ---------------------------------------------------------------
33
34// commands
35enum class SvxSearchCmd
36{
37 FIND = 0,
38 FIND_ALL = 1,
39 REPLACE = 2,
40 REPLACE_ALL = 3,
41};
42
43// search flags
45{
46 FORMULA = 0,
47 VALUE = 1,
48 NOTE = 2,
49};
50
51enum class SvxSearchApp
52{
53 WRITER = 0,
54 CALC = 1,
55 DRAW = 2,
56};
57
58// class SvxSearchItem ---------------------------------------------------
59
61 public SfxPoolItem,
62 public utl::ConfigItem
63{
65
66 SfxStyleFamily m_eFamily; // style family
67
68 SvxSearchCmd m_nCommand; // command (Search, Search all, Replace, Replace all)
69
70 // Calc-specific
71 SvxSearchCellType m_nCellType; // Search in Formulas/Values/Notes
72 SvxSearchApp m_nAppFlag; // application which the dialog is for
73 bool m_bRowDirection; // search direction: row-wise/column-wise
74 bool m_bAllTables; // search in all sheets
75 bool m_bSearchFiltered; // search filtered cells.
76 bool m_bSearchFormatted; // search formatted display strings
77
78 // Writer-specific
80
81 bool m_bBackward; // search backwards
82 bool m_bPattern; // search for styles
83 bool m_bContent; // search in content
84 bool m_bAsianOptions; // use asian options?
85
86 // Start search at this point (absolute twips).
87 sal_Int32 m_nStartPointX;
88 sal_Int32 m_nStartPointY;
89
90 virtual void ImplCommit() override;
91
92public:
93 static SfxPoolItem* CreateDefault();
94
95 explicit SvxSearchItem( const sal_uInt16 nId );
96 SvxSearchItem( const SvxSearchItem& rItem );
97 virtual ~SvxSearchItem() override;
98
99 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
100 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
101 virtual bool operator == ( const SfxPoolItem& ) const override;
102 virtual SvxSearchItem* Clone( SfxItemPool *pPool = nullptr ) const override;
103 virtual bool GetPresentation( SfxItemPresentation ePres,
104 MapUnit eCoreMetric,
105 MapUnit ePresMetric,
106 OUString &rText, const IntlWrapper& ) const override;
107
108 // ConfigItem
109 virtual void Notify( const css::uno::Sequence< OUString > &rPropertyNames ) override;
110
111 bool equalsIgnoring(const SvxSearchItem& rSItem, bool bIgnoreReplace,
112 bool bIgnoreCommand) const;
113
114 SvxSearchCmd GetCommand() const { return m_nCommand; }
115 void SetCommand(SvxSearchCmd nNewCommand) { m_nCommand = nNewCommand; }
116
117 inline const OUString& GetSearchString() const;
118 inline void SetSearchString(const OUString& rNewString);
119
120 inline const OUString& GetReplaceString() const;
121 inline void SetReplaceString(const OUString& rNewString);
122
123 inline bool GetWordOnly() const;
124 void SetWordOnly(bool bNewWordOnly);
125
126 inline bool GetExact() const;
127 void SetExact(bool bNewExact);
128
129 bool GetBackward() const { return m_bBackward; }
130 void SetBackward(bool bNewBackward) { m_bBackward = bNewBackward; }
131
132 inline bool GetSelection() const;
133 void SetSelection(bool bNewSelection);
134
135 inline bool GetRegExp() const;
136 void SetRegExp( bool bVal );
137
138 inline bool GetWildcard() const;
139 void SetWildcard( bool bVal );
140
141 bool GetPattern() const { return m_bPattern; }
142 void SetPattern(bool bNewPattern) { m_bPattern = bNewPattern; }
143
144 SfxStyleFamily GetFamily() const { return m_eFamily; }
145 void SetFamily( SfxStyleFamily eNewFamily )
146 { m_eFamily = eNewFamily; }
147
148 bool GetRowDirection() const { return m_bRowDirection; }
149 void SetRowDirection(bool bNewRowDirection) { m_bRowDirection = bNewRowDirection; }
150
151 bool IsAllTables() const { return m_bAllTables; }
152 void SetAllTables(bool bNew) { m_bAllTables = bNew; }
153
154 bool IsSearchFiltered() const { return m_bSearchFiltered; }
155 void SetSearchFiltered(bool b) { m_bSearchFiltered = b; }
156
157 bool IsSearchFormatted() const { return m_bSearchFormatted; }
158 void SetSearchFormatted(bool b) { m_bSearchFormatted = b; }
159
160 SvxSearchCellType GetCellType() const { return m_nCellType; }
161 void SetCellType(SvxSearchCellType nNewCellType) { m_nCellType = nNewCellType; }
162
163 bool GetNotes() const { return m_bNotes; }
164 void SetNotes(bool bNew) { m_bNotes = bNew; }
165
166 SvxSearchApp GetAppFlag() const { return m_nAppFlag; }
167 void SetAppFlag(SvxSearchApp nNewAppFlag) { m_nAppFlag = nNewAppFlag; }
168
169 inline bool IsLevenshtein() const;
170 void SetLevenshtein( bool bVal );
171
172 inline bool IsLEVRelaxed() const;
173 void SetLEVRelaxed(bool bSet);
174
175 inline sal_uInt16 GetLEVOther() const;
176 inline void SetLEVOther(sal_uInt16 nSet);
177
178 inline sal_uInt16 GetLEVShorter() const;
179 inline void SetLEVShorter(sal_uInt16 nSet);
180
181 inline sal_uInt16 GetLEVLonger() const;
182 inline void SetLEVLonger(sal_uInt16 nSet);
183
184 inline const i18nutil::SearchOptions2 &
185 GetSearchOptions() const;
186 inline void SetSearchOptions( const i18nutil::SearchOptions2 &rOpt );
187
190 void SetTransliterationFlags( TransliterationFlags nFlags );
191
192 inline bool IsMatchFullHalfWidthForms() const;
193 void SetMatchFullHalfWidthForms( bool bVal );
194
195 bool IsUseAsianOptions() const { return m_bAsianOptions; }
196 void SetUseAsianOptions( bool bVal ) { m_bAsianOptions = bVal; }
197
198 sal_Int32 GetStartPointX() const;
199 sal_Int32 GetStartPointY() const;
201 bool HasStartPoint() const;
202};
203
204const OUString& SvxSearchItem::GetSearchString() const
205{
207}
208
209void SvxSearchItem::SetSearchString(const OUString& rNewString)
210{
211 m_aSearchOpt.searchString = rNewString;
212}
213
214const OUString& SvxSearchItem::GetReplaceString() const
215{
217}
218
219void SvxSearchItem::SetReplaceString(const OUString& rNewString)
220{
221 m_aSearchOpt.replaceString = rNewString;
222}
223
225{
226 return 0 != (m_aSearchOpt.searchFlag &
227 css::util::SearchFlags::NORM_WORD_ONLY);
228}
229
231{
232 return !(m_aSearchOpt.transliterateFlags & TransliterationFlags::IGNORE_CASE);
233}
234
236{
237 return 0 != (m_aSearchOpt.searchFlag & css::util::SearchFlags::REG_NOT_BEGINOFLINE);
238}
239
241{
242 return m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::REGEXP ;
243}
244
246{
247 return m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::WILDCARD ;
248}
249
251{
252 return 0 != (m_aSearchOpt.searchFlag & css::util::SearchFlags::LEV_RELAXED);
253}
254
256{
257 return static_cast<sal_Int16>(m_aSearchOpt.changedChars);
258}
259
260void SvxSearchItem::SetLEVOther( sal_uInt16 nVal )
261{
263}
264
266{
267 return static_cast<sal_Int16>(m_aSearchOpt.insertedChars);
268}
269
270void SvxSearchItem::SetLEVShorter( sal_uInt16 nVal )
271{
273}
274
276{
277 return static_cast<sal_Int16>(m_aSearchOpt.deletedChars);
278}
279
280void SvxSearchItem::SetLEVLonger( sal_uInt16 nVal )
281{
283}
284
286{
287 return m_aSearchOpt.AlgorithmType2 == css::util::SearchAlgorithms2::APPROXIMATE;
288}
289
291{
292 return m_aSearchOpt;
293}
294
296{
297 m_aSearchOpt = rOpt;
298}
299
301{
303}
304
306{
307 return bool(m_aSearchOpt.transliterateFlags & TransliterationFlags::IGNORE_WIDTH);
308}
309
310#endif
311
312
313/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const short FIND
Base class for providers of defaults of SfxPoolItems.
Definition: itempool.hxx:51
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
Definition: poolitem.cxx:604
virtual bool GetPresentation(SfxItemPresentation ePresentation, MapUnit eCoreMetric, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntlWrapper) const
This virtual method allows to get a textual representation of the value for the SfxPoolItem subclasse...
Definition: poolitem.cxx:524
virtual bool operator==(const SfxPoolItem &) const =0
Definition: poolitem.cxx:478
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId)
Definition: poolitem.cxx:610
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
void SetReplaceString(const OUString &rNewString)
Definition: srchitem.hxx:219
SvxSearchCmd m_nCommand
Definition: srchitem.hxx:68
SvxSearchApp GetAppFlag() const
Definition: srchitem.hxx:166
void SetBackward(bool bNewBackward)
Definition: srchitem.hxx:130
const OUString & GetSearchString() const
Definition: srchitem.hxx:204
void SetCellType(SvxSearchCellType nNewCellType)
Definition: srchitem.hxx:161
SvxSearchCmd GetCommand() const
Definition: srchitem.hxx:114
const OUString & GetReplaceString() const
Definition: srchitem.hxx:214
bool GetExact() const
Definition: srchitem.hxx:230
i18nutil::SearchOptions2 m_aSearchOpt
Definition: srchitem.hxx:64
bool GetWildcard() const
Definition: srchitem.hxx:245
void SetSearchFormatted(bool b)
Definition: srchitem.hxx:158
bool IsAllTables() const
Definition: srchitem.hxx:151
bool IsSearchFiltered() const
Definition: srchitem.hxx:154
sal_Int32 m_nStartPointX
Definition: srchitem.hxx:87
void SetLEVLonger(sal_uInt16 nSet)
Definition: srchitem.hxx:280
bool GetNotes() const
Definition: srchitem.hxx:163
void SetAppFlag(SvxSearchApp nNewAppFlag)
Definition: srchitem.hxx:167
const i18nutil::SearchOptions2 & GetSearchOptions() const
Definition: srchitem.hxx:290
sal_Int32 m_nStartPointY
Definition: srchitem.hxx:88
bool GetSelection() const
Definition: srchitem.hxx:235
bool GetWordOnly() const
Definition: srchitem.hxx:224
void SetRowDirection(bool bNewRowDirection)
Definition: srchitem.hxx:149
void SetCommand(SvxSearchCmd nNewCommand)
Definition: srchitem.hxx:115
sal_uInt16 GetLEVShorter() const
Definition: srchitem.hxx:265
bool m_bPattern
Definition: srchitem.hxx:82
bool m_bContent
Definition: srchitem.hxx:83
void SetSearchString(const OUString &rNewString)
Definition: srchitem.hxx:209
bool IsSearchFormatted() const
Definition: srchitem.hxx:157
bool m_bSearchFiltered
Definition: srchitem.hxx:75
bool m_bSearchFormatted
Definition: srchitem.hxx:76
bool m_bBackward
Definition: srchitem.hxx:81
void SetSearchOptions(const i18nutil::SearchOptions2 &rOpt)
Definition: srchitem.hxx:295
bool m_bRowDirection
Definition: srchitem.hxx:73
bool m_bAsianOptions
Definition: srchitem.hxx:84
SvxSearchApp m_nAppFlag
Definition: srchitem.hxx:72
bool IsLEVRelaxed() const
Definition: srchitem.hxx:250
bool GetRowDirection() const
Definition: srchitem.hxx:148
void SetNotes(bool bNew)
Definition: srchitem.hxx:164
void SetAllTables(bool bNew)
Definition: srchitem.hxx:152
void SetLEVShorter(sal_uInt16 nSet)
Definition: srchitem.hxx:270
void SetLEVOther(sal_uInt16 nSet)
Definition: srchitem.hxx:260
void SetUseAsianOptions(bool bVal)
Definition: srchitem.hxx:196
bool m_bAllTables
Definition: srchitem.hxx:74
SvxSearchCellType GetCellType() const
Definition: srchitem.hxx:160
SfxStyleFamily m_eFamily
Definition: srchitem.hxx:66
void SetSearchFiltered(bool b)
Definition: srchitem.hxx:155
bool GetBackward() const
Definition: srchitem.hxx:129
sal_uInt16 GetLEVOther() const
Definition: srchitem.hxx:255
TransliterationFlags GetTransliterationFlags() const
Definition: srchitem.hxx:300
bool IsMatchFullHalfWidthForms() const
Definition: srchitem.hxx:305
void SetFamily(SfxStyleFamily eNewFamily)
Definition: srchitem.hxx:145
bool IsUseAsianOptions() const
Definition: srchitem.hxx:195
SvxSearchCellType m_nCellType
Definition: srchitem.hxx:71
bool GetRegExp() const
Definition: srchitem.hxx:240
bool GetPattern() const
Definition: srchitem.hxx:141
bool IsLevenshtein() const
Definition: srchitem.hxx:285
SfxStyleFamily GetFamily() const
Definition: srchitem.hxx:144
void SetPattern(bool bNewPattern)
Definition: srchitem.hxx:142
sal_uInt16 GetLEVLonger() const
Definition: srchitem.hxx:275
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames)=0
virtual void ImplCommit()=0
virtual TransliterationFlags GetTransliterationFlags() const override
WRITER
DRAW
CALC
MapUnit
FORMULA
SfxItemPresentation
Definition: poolitem.hxx:72
SvxSearchCellType
Definition: srchitem.hxx:45
SvxSearchApp
Definition: srchitem.hxx:52
SvxSearchCmd
Definition: srchitem.hxx:36
TransliterationFlags transliterateFlags
SfxStyleFamily
Definition: style.hxx:42
#define SVL_DLLPUBLIC
Definition: svldllapi.h:28
TransliterationFlags
unsigned char sal_uInt8
void GetSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder) noexcept