1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SVL_SRCHITEM_HXX
20 #define INCLUDED_SVL_SRCHITEM_HXX
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>
26 #include <i18nutil/transliteration.hxx>
27 #include <i18nutil/searchopt.hxx>
28 #include <unotools/configitem.hxx>
29 #include <svl/style.hxx>
30 #include <svl/poolitem.hxx>
32 // defines ---------------------------------------------------------------
35 enum class SvxSearchCmd
44 enum class SvxSearchCellType
51 enum class SvxSearchApp
58 // class SvxSearchItem ---------------------------------------------------
60 class SVL_DLLPUBLIC SvxSearchItem
:
62 public utl::ConfigItem
64 i18nutil::SearchOptions2 m_aSearchOpt
;
66 SfxStyleFamily m_eFamily
; // style family
68 SvxSearchCmd m_nCommand
; // command (Search, Search all, Replace, Replace all)
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
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?
86 // Start search at this point (absolute twips).
87 sal_Int32 m_nStartPointX
;
88 sal_Int32 m_nStartPointY
;
90 virtual void ImplCommit() override
;
93 static SfxPoolItem
* CreateDefault();
95 explicit SvxSearchItem( const sal_uInt16 nId
);
96 SvxSearchItem( const SvxSearchItem
& rItem
);
97 virtual ~SvxSearchItem() override
;
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 SfxPoolItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
103 virtual bool GetPresentation( SfxItemPresentation ePres
,
106 OUString
&rText
, const IntlWrapper
& ) const override
;
109 virtual void Notify( const css::uno::Sequence
< OUString
> &rPropertyNames
) override
;
111 SvxSearchCmd
GetCommand() const { return m_nCommand
; }
112 void SetCommand(SvxSearchCmd nNewCommand
) { m_nCommand
= nNewCommand
; }
114 inline const OUString
& GetSearchString() const;
115 inline void SetSearchString(const OUString
& rNewString
);
117 inline const OUString
& GetReplaceString() const;
118 inline void SetReplaceString(const OUString
& rNewString
);
120 inline bool GetWordOnly() const;
121 void SetWordOnly(bool bNewWordOnly
);
123 inline bool GetExact() const;
124 void SetExact(bool bNewExact
);
126 bool GetBackward() const { return m_bBackward
; }
127 void SetBackward(bool bNewBackward
) { m_bBackward
= bNewBackward
; }
129 inline bool GetSelection() const;
130 void SetSelection(bool bNewSelection
);
132 inline bool GetRegExp() const;
133 void SetRegExp( bool bVal
);
135 inline bool GetWildcard() const;
136 void SetWildcard( bool bVal
);
138 bool GetPattern() const { return m_bPattern
; }
139 void SetPattern(bool bNewPattern
) { m_bPattern
= bNewPattern
; }
141 SfxStyleFamily
GetFamily() const { return m_eFamily
; }
142 void SetFamily( SfxStyleFamily eNewFamily
)
143 { m_eFamily
= eNewFamily
; }
145 bool GetRowDirection() const { return m_bRowDirection
; }
146 void SetRowDirection(bool bNewRowDirection
) { m_bRowDirection
= bNewRowDirection
; }
148 bool IsAllTables() const { return m_bAllTables
; }
149 void SetAllTables(bool bNew
) { m_bAllTables
= bNew
; }
151 bool IsSearchFiltered() const { return m_bSearchFiltered
; }
152 void SetSearchFiltered(bool b
) { m_bSearchFiltered
= b
; }
154 bool IsSearchFormatted() const { return m_bSearchFormatted
; }
155 void SetSearchFormatted(bool b
) { m_bSearchFormatted
= b
; }
157 SvxSearchCellType
GetCellType() const { return m_nCellType
; }
158 void SetCellType(SvxSearchCellType nNewCellType
) { m_nCellType
= nNewCellType
; }
160 bool GetNotes() const { return m_bNotes
; }
161 void SetNotes(bool bNew
) { m_bNotes
= bNew
; }
163 SvxSearchApp
GetAppFlag() const { return m_nAppFlag
; }
164 void SetAppFlag(SvxSearchApp nNewAppFlag
) { m_nAppFlag
= nNewAppFlag
; }
166 inline bool IsLevenshtein() const;
167 void SetLevenshtein( bool bVal
);
169 inline bool IsLEVRelaxed() const;
170 void SetLEVRelaxed(bool bSet
);
172 inline sal_uInt16
GetLEVOther() const;
173 inline void SetLEVOther(sal_uInt16 nSet
);
175 inline sal_uInt16
GetLEVShorter() const;
176 inline void SetLEVShorter(sal_uInt16 nSet
);
178 inline sal_uInt16
GetLEVLonger() const;
179 inline void SetLEVLonger(sal_uInt16 nSet
);
181 inline const i18nutil::SearchOptions2
&
182 GetSearchOptions() const;
183 inline void SetSearchOptions( const i18nutil::SearchOptions2
&rOpt
);
185 inline TransliterationFlags
186 GetTransliterationFlags() const;
187 void SetTransliterationFlags( TransliterationFlags nFlags
);
189 inline bool IsMatchFullHalfWidthForms() const;
190 void SetMatchFullHalfWidthForms( bool bVal
);
192 bool IsUseAsianOptions() const { return m_bAsianOptions
; }
193 void SetUseAsianOptions( bool bVal
) { m_bAsianOptions
= bVal
; }
195 sal_Int32
GetStartPointX() const;
196 sal_Int32
GetStartPointY() const;
197 /// Either x or y start point is set.
198 bool HasStartPoint() const;
201 const OUString
& SvxSearchItem::GetSearchString() const
203 return m_aSearchOpt
.searchString
;
206 void SvxSearchItem::SetSearchString(const OUString
& rNewString
)
208 m_aSearchOpt
.searchString
= rNewString
;
211 const OUString
& SvxSearchItem::GetReplaceString() const
213 return m_aSearchOpt
.replaceString
;
216 void SvxSearchItem::SetReplaceString(const OUString
& rNewString
)
218 m_aSearchOpt
.replaceString
= rNewString
;
221 bool SvxSearchItem::GetWordOnly() const
223 return 0 != (m_aSearchOpt
.searchFlag
&
224 css::util::SearchFlags::NORM_WORD_ONLY
);
227 bool SvxSearchItem::GetExact() const
229 return !(m_aSearchOpt
.transliterateFlags
& TransliterationFlags::IGNORE_CASE
);
232 bool SvxSearchItem::GetSelection() const
234 return 0 != (m_aSearchOpt
.searchFlag
& css::util::SearchFlags::REG_NOT_BEGINOFLINE
);
237 bool SvxSearchItem::GetRegExp() const
239 // Ensure old and new algorithm types are in sync until all places are
240 // adapted to use only new types.
241 assert( (m_aSearchOpt
.algorithmType
== css::util::SearchAlgorithms_REGEXP
) ==
242 (m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::REGEXP
));
243 return m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::REGEXP
;
246 bool SvxSearchItem::GetWildcard() const
248 // Ensure old and new algorithm types are in sync, in this case old is not
249 // REGEXP or APPROXIMATE.
250 assert( m_aSearchOpt
.AlgorithmType2
!= css::util::SearchAlgorithms2::WILDCARD
||
251 (m_aSearchOpt
.algorithmType
!= css::util::SearchAlgorithms_REGEXP
&&
252 m_aSearchOpt
.algorithmType
!= css::util::SearchAlgorithms_APPROXIMATE
) );
253 return m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::WILDCARD
;
256 bool SvxSearchItem::IsLEVRelaxed() const
258 return 0 != (m_aSearchOpt
.searchFlag
& css::util::SearchFlags::LEV_RELAXED
);
261 sal_uInt16
SvxSearchItem::GetLEVOther() const
263 return static_cast<sal_Int16
>(m_aSearchOpt
.changedChars
);
266 void SvxSearchItem::SetLEVOther( sal_uInt16 nVal
)
268 m_aSearchOpt
.changedChars
= nVal
;
271 sal_uInt16
SvxSearchItem::GetLEVShorter() const
273 return static_cast<sal_Int16
>(m_aSearchOpt
.insertedChars
);
276 void SvxSearchItem::SetLEVShorter( sal_uInt16 nVal
)
278 m_aSearchOpt
.insertedChars
= nVal
;
281 sal_uInt16
SvxSearchItem::GetLEVLonger() const
283 return static_cast<sal_Int16
>(m_aSearchOpt
.deletedChars
);
286 void SvxSearchItem::SetLEVLonger( sal_uInt16 nVal
)
288 m_aSearchOpt
.deletedChars
= nVal
;
291 bool SvxSearchItem::IsLevenshtein() const
293 // Ensure old and new algorithm types are in sync until all places are
294 // adapted to use only new types.
295 assert( (m_aSearchOpt
.algorithmType
== css::util::SearchAlgorithms_APPROXIMATE
) ==
296 (m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::APPROXIMATE
));
297 return m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::APPROXIMATE
;
300 const i18nutil::SearchOptions2
& SvxSearchItem::GetSearchOptions() const
305 void SvxSearchItem::SetSearchOptions( const i18nutil::SearchOptions2
&rOpt
)
310 TransliterationFlags
SvxSearchItem::GetTransliterationFlags() const
312 return m_aSearchOpt
.transliterateFlags
;
315 bool SvxSearchItem::IsMatchFullHalfWidthForms() const
317 return bool(m_aSearchOpt
.transliterateFlags
& TransliterationFlags::IGNORE_WIDTH
);
323 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */