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/XSearchDescriptor.hpp>
25 #include <com/sun/star/util/SearchOptions2.hpp>
26 #include <com/sun/star/util/SearchAlgorithms2.hpp>
27 #include <com/sun/star/util/SearchFlags.hpp>
28 #include <com/sun/star/i18n/TransliterationModules.hpp>
29 #include <unotools/configitem.hxx>
30 #include <rsc/rscsfx.hxx>
31 #include <svl/poolitem.hxx>
32 #include <svl/srchdefs.hxx>
34 // defines ---------------------------------------------------------------
37 enum class SvxSearchCmd
46 enum class SvxSearchCellType
53 enum class SvxSearchApp
60 // class SvxSearchItem ---------------------------------------------------
62 class SVL_DLLPUBLIC SvxSearchItem
:
64 public utl::ConfigItem
66 css::util::SearchOptions2 m_aSearchOpt
;
68 SfxStyleFamily m_eFamily
; // style family
70 SvxSearchCmd m_nCommand
; // command (Search, Search all, Replace, Replace all)
73 SvxSearchCellType m_nCellType
; // Search in Formulas/Values/Notes
74 SvxSearchApp m_nAppFlag
; // application which the dialog is for
75 bool m_bRowDirection
; // search direction: row-wise/column-wise
76 bool m_bAllTables
; // search in all sheets
77 bool m_bSearchFiltered
; // search filtered cells.
78 bool m_bSearchFormatted
; // search formatted display strings
83 bool m_bBackward
; // search backwards
84 bool m_bPattern
; // search for styles
85 bool m_bContent
; // search in content
86 bool m_bAsianOptions
; // use asian options?
88 // Start search at this point (absolute twips).
89 sal_Int32 m_nStartPointX
;
90 sal_Int32 m_nStartPointY
;
92 virtual void ImplCommit() override
;
95 static SfxPoolItem
* CreateDefault();
97 explicit SvxSearchItem( const sal_uInt16 nId
);
98 SvxSearchItem( const SvxSearchItem
& rItem
);
99 virtual ~SvxSearchItem() override
;
101 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
102 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
103 virtual bool operator == ( const SfxPoolItem
& ) const override
;
104 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
105 virtual bool GetPresentation( SfxItemPresentation ePres
,
108 OUString
&rText
, const IntlWrapper
* = nullptr ) const override
;
111 virtual void Notify( const css::uno::Sequence
< OUString
> &rPropertyNames
) override
;
113 SvxSearchCmd
GetCommand() const { return m_nCommand
; }
114 void SetCommand(SvxSearchCmd nNewCommand
) { m_nCommand
= nNewCommand
; }
116 inline const OUString
& GetSearchString() const;
117 inline void SetSearchString(const OUString
& rNewString
);
119 inline const OUString
& GetReplaceString() const;
120 inline void SetReplaceString(const OUString
& rNewString
);
122 inline bool GetWordOnly() const;
123 void SetWordOnly(bool bNewWordOnly
);
125 inline bool GetExact() const;
126 void SetExact(bool bNewExact
);
128 bool GetBackward() const { return m_bBackward
; }
129 void SetBackward(bool bNewBackward
) { m_bBackward
= bNewBackward
; }
131 inline bool GetSelection() const;
132 void SetSelection(bool bNewSelection
);
134 inline bool GetRegExp() const;
135 void SetRegExp( bool bVal
);
137 inline bool GetWildcard() const;
138 void SetWildcard( bool bVal
);
140 bool GetPattern() const { return m_bPattern
; }
141 void SetPattern(bool bNewPattern
) { m_bPattern
= bNewPattern
; }
143 SfxStyleFamily
GetFamily() const { return m_eFamily
; }
144 void SetFamily( SfxStyleFamily eNewFamily
)
145 { m_eFamily
= eNewFamily
; }
147 bool GetRowDirection() const { return m_bRowDirection
; }
148 void SetRowDirection(bool bNewRowDirection
) { m_bRowDirection
= bNewRowDirection
; }
150 bool IsAllTables() const { return m_bAllTables
; }
151 void SetAllTables(bool bNew
) { m_bAllTables
= bNew
; }
153 bool IsSearchFiltered() const { return m_bSearchFiltered
; }
154 void SetSearchFiltered(bool b
) { m_bSearchFiltered
= b
; }
156 bool IsSearchFormatted() const { return m_bSearchFormatted
; }
157 void SetSearchFormatted(bool b
) { m_bSearchFormatted
= b
; }
159 SvxSearchCellType
GetCellType() const { return m_nCellType
; }
160 void SetCellType(SvxSearchCellType nNewCellType
) { m_nCellType
= nNewCellType
; }
162 bool GetNotes() const { return m_bNotes
; }
163 void SetNotes(bool bNew
) { m_bNotes
= bNew
; }
165 SvxSearchApp
GetAppFlag() const { return m_nAppFlag
; }
166 void SetAppFlag(SvxSearchApp nNewAppFlag
) { m_nAppFlag
= nNewAppFlag
; }
168 inline bool IsLevenshtein() const;
169 void SetLevenshtein( bool bVal
);
171 inline bool IsLEVRelaxed() const;
172 void SetLEVRelaxed(bool bSet
);
174 inline sal_uInt16
GetLEVOther() const;
175 inline void SetLEVOther(sal_uInt16 nSet
);
177 inline sal_uInt16
GetLEVShorter() const;
178 inline void SetLEVShorter(sal_uInt16 nSet
);
180 inline sal_uInt16
GetLEVLonger() const;
181 inline void SetLEVLonger(sal_uInt16 nSet
);
183 inline const css::util::SearchOptions2
&
184 GetSearchOptions() const;
185 inline void SetSearchOptions( const css::util::SearchOptions2
&rOpt
);
187 inline sal_Int32
GetTransliterationFlags() const;
188 void SetTransliterationFlags( sal_Int32 nFlags
);
190 inline bool IsMatchFullHalfWidthForms() const;
191 void SetMatchFullHalfWidthForms( bool bVal
);
193 inline bool IsUseAsianOptions() const { return m_bAsianOptions
; }
194 inline void SetUseAsianOptions( bool bVal
) { m_bAsianOptions
= bVal
; }
196 sal_Int32
GetStartPointX() const;
197 sal_Int32
GetStartPointY() const;
198 /// Either x or y start point is set.
199 bool HasStartPoint() const;
202 const OUString
& SvxSearchItem::GetSearchString() const
204 return m_aSearchOpt
.searchString
;
207 void SvxSearchItem::SetSearchString(const OUString
& rNewString
)
209 m_aSearchOpt
.searchString
= rNewString
;
212 const OUString
& SvxSearchItem::GetReplaceString() const
214 return m_aSearchOpt
.replaceString
;
217 void SvxSearchItem::SetReplaceString(const OUString
& rNewString
)
219 m_aSearchOpt
.replaceString
= rNewString
;
222 bool SvxSearchItem::GetWordOnly() const
224 return 0 != (m_aSearchOpt
.searchFlag
&
225 css::util::SearchFlags::NORM_WORD_ONLY
);
228 bool SvxSearchItem::GetExact() const
230 return 0 == (m_aSearchOpt
.transliterateFlags
& css::i18n::TransliterationModules_IGNORE_CASE
);
233 bool SvxSearchItem::GetSelection() const
235 return 0 != (m_aSearchOpt
.searchFlag
& css::util::SearchFlags::REG_NOT_BEGINOFLINE
);
238 bool SvxSearchItem::GetRegExp() const
240 // Ensure old and new algorithm types are in sync until all places are
241 // adapted to use only new types.
242 assert( (m_aSearchOpt
.algorithmType
== css::util::SearchAlgorithms_REGEXP
) ==
243 (m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::REGEXP
));
244 return m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::REGEXP
;
247 bool SvxSearchItem::GetWildcard() const
249 // Ensure old and new algorithm types are in sync, in this case old is not
250 // REGEXP or APPROXIMATE.
251 assert( m_aSearchOpt
.AlgorithmType2
!= css::util::SearchAlgorithms2::WILDCARD
||
252 (m_aSearchOpt
.algorithmType
!= css::util::SearchAlgorithms_REGEXP
&&
253 m_aSearchOpt
.algorithmType
!= css::util::SearchAlgorithms_APPROXIMATE
) );
254 return m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::WILDCARD
;
257 bool SvxSearchItem::IsLEVRelaxed() const
259 return 0 != (m_aSearchOpt
.searchFlag
& css::util::SearchFlags::LEV_RELAXED
);
262 sal_uInt16
SvxSearchItem::GetLEVOther() const
264 return (sal_Int16
) m_aSearchOpt
.changedChars
;
267 void SvxSearchItem::SetLEVOther( sal_uInt16 nVal
)
269 m_aSearchOpt
.changedChars
= nVal
;
272 sal_uInt16
SvxSearchItem::GetLEVShorter() const
274 return (sal_Int16
) m_aSearchOpt
.insertedChars
;
277 void SvxSearchItem::SetLEVShorter( sal_uInt16 nVal
)
279 m_aSearchOpt
.insertedChars
= nVal
;
282 sal_uInt16
SvxSearchItem::GetLEVLonger() const
284 return (sal_Int16
) m_aSearchOpt
.deletedChars
;
287 void SvxSearchItem::SetLEVLonger( sal_uInt16 nVal
)
289 m_aSearchOpt
.deletedChars
= nVal
;
292 bool SvxSearchItem::IsLevenshtein() const
294 // Ensure old and new algorithm types are in sync until all places are
295 // adapted to use only new types.
296 assert( (m_aSearchOpt
.algorithmType
== css::util::SearchAlgorithms_APPROXIMATE
) ==
297 (m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::APPROXIMATE
));
298 return m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::APPROXIMATE
;
301 const css::util::SearchOptions2
& SvxSearchItem::GetSearchOptions() const
306 void SvxSearchItem::SetSearchOptions( const css::util::SearchOptions2
&rOpt
)
311 sal_Int32
SvxSearchItem::GetTransliterationFlags() const
313 return m_aSearchOpt
.transliterateFlags
;
316 bool SvxSearchItem::IsMatchFullHalfWidthForms() const
318 return 0 != (m_aSearchOpt
.transliterateFlags
& css::i18n::TransliterationModules_IGNORE_WIDTH
);
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */