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
61 // class SvxSearchItem ---------------------------------------------------
63 class SVL_DLLPUBLIC SvxSearchItem
:
65 public utl::ConfigItem
67 css::util::SearchOptions2 m_aSearchOpt
;
69 SfxStyleFamily m_eFamily
; // style family
71 SvxSearchCmd m_nCommand
; // command (Search, Search all, Replace, Replace all)
74 SvxSearchCellType m_nCellType
; // Search in Formulas/Values/Notes
75 SvxSearchApp m_nAppFlag
; // application which the dialog is for
76 bool m_bRowDirection
; // search direction: row-wise/column-wise
77 bool m_bAllTables
; // search in all sheets
78 bool m_bSearchFiltered
; // search filtered cells.
79 bool m_bSearchFormatted
; // search formatted display strings
84 bool m_bBackward
; // search backwards
85 bool m_bPattern
; // search for styles
86 bool m_bContent
; // search in content
87 bool m_bAsianOptions
; // use asian options?
89 // Start search at this point (absolute twips).
90 sal_Int32 m_nStartPointX
;
91 sal_Int32 m_nStartPointY
;
93 virtual void ImplCommit() override
;
96 static SfxPoolItem
* CreateDefault();
98 explicit SvxSearchItem( const sal_uInt16 nId
);
99 SvxSearchItem( const SvxSearchItem
& rItem
);
100 virtual ~SvxSearchItem();
102 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
103 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
104 virtual bool operator == ( const SfxPoolItem
& ) const override
;
105 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
106 virtual bool GetPresentation( SfxItemPresentation ePres
,
107 SfxMapUnit eCoreMetric
,
108 SfxMapUnit ePresMetric
,
109 OUString
&rText
, const IntlWrapper
* = nullptr ) const override
;
112 virtual void Notify( const css::uno::Sequence
< OUString
> &rPropertyNames
) override
;
114 SvxSearchCmd
GetCommand() const { return m_nCommand
; }
115 void SetCommand(SvxSearchCmd nNewCommand
) { m_nCommand
= nNewCommand
; }
117 inline const OUString
& GetSearchString() const;
118 inline void SetSearchString(const OUString
& rNewString
);
120 inline const OUString
& GetReplaceString() const;
121 inline void SetReplaceString(const OUString
& rNewString
);
123 inline bool GetWordOnly() const;
124 void SetWordOnly(bool bNewWordOnly
);
126 inline bool GetExact() const;
127 void SetExact(bool bNewExact
);
129 bool GetBackward() const { return m_bBackward
; }
130 void SetBackward(bool bNewBackward
) { m_bBackward
= bNewBackward
; }
132 inline bool GetSelection() const;
133 void SetSelection(bool bNewSelection
);
135 inline bool GetRegExp() const;
136 void SetRegExp( bool bVal
);
138 inline bool GetWildcard() const;
139 void SetWildcard( bool bVal
);
141 bool GetPattern() const { return m_bPattern
; }
142 void SetPattern(bool bNewPattern
) { m_bPattern
= bNewPattern
; }
144 SfxStyleFamily
GetFamily() const { return m_eFamily
; }
145 void SetFamily( SfxStyleFamily eNewFamily
)
146 { m_eFamily
= eNewFamily
; }
148 bool GetRowDirection() const { return m_bRowDirection
; }
149 void SetRowDirection(bool bNewRowDirection
) { m_bRowDirection
= bNewRowDirection
; }
151 bool IsAllTables() const { return m_bAllTables
; }
152 void SetAllTables(bool bNew
) { m_bAllTables
= bNew
; }
154 bool IsSearchFiltered() const { return m_bSearchFiltered
; }
155 void SetSearchFiltered(bool b
) { m_bSearchFiltered
= b
; }
157 bool IsSearchFormatted() const { return m_bSearchFormatted
; }
158 void SetSearchFormatted(bool b
) { m_bSearchFormatted
= b
; }
160 SvxSearchCellType
GetCellType() const { return m_nCellType
; }
161 void SetCellType(SvxSearchCellType nNewCellType
) { m_nCellType
= nNewCellType
; }
163 bool GetNotes() const { return m_bNotes
; }
164 void SetNotes(bool bNew
) { m_bNotes
= bNew
; }
166 SvxSearchApp
GetAppFlag() const { return m_nAppFlag
; }
167 void SetAppFlag(SvxSearchApp nNewAppFlag
) { m_nAppFlag
= nNewAppFlag
; }
169 inline bool IsLevenshtein() const;
170 void SetLevenshtein( bool bVal
);
172 inline bool IsLEVRelaxed() const;
173 void SetLEVRelaxed(bool bSet
);
175 inline sal_uInt16
GetLEVOther() const;
176 inline void SetLEVOther(sal_uInt16 nSet
);
178 inline sal_uInt16
GetLEVShorter() const;
179 inline void SetLEVShorter(sal_uInt16 nSet
);
181 inline sal_uInt16
GetLEVLonger() const;
182 inline void SetLEVLonger(sal_uInt16 nSet
);
184 inline const css::util::SearchOptions2
&
185 GetSearchOptions() const;
186 inline void SetSearchOptions( const css::util::SearchOptions2
&rOpt
);
188 inline sal_Int32
GetTransliterationFlags() const;
189 void SetTransliterationFlags( sal_Int32 nFlags
);
191 inline bool IsMatchFullHalfWidthForms() const;
192 void SetMatchFullHalfWidthForms( bool bVal
);
194 inline bool IsUseAsianOptions() const { return m_bAsianOptions
; }
195 inline void SetUseAsianOptions( bool bVal
) { m_bAsianOptions
= bVal
; }
197 sal_Int32
GetStartPointX() const;
198 sal_Int32
GetStartPointY() const;
199 /// Either x or y start point is set.
200 bool HasStartPoint() const;
203 const OUString
& SvxSearchItem::GetSearchString() const
205 return m_aSearchOpt
.searchString
;
208 void SvxSearchItem::SetSearchString(const OUString
& rNewString
)
210 m_aSearchOpt
.searchString
= rNewString
;
213 const OUString
& SvxSearchItem::GetReplaceString() const
215 return m_aSearchOpt
.replaceString
;
218 void SvxSearchItem::SetReplaceString(const OUString
& rNewString
)
220 m_aSearchOpt
.replaceString
= rNewString
;
223 bool SvxSearchItem::GetWordOnly() const
225 return 0 != (m_aSearchOpt
.searchFlag
&
226 css::util::SearchFlags::NORM_WORD_ONLY
);
229 bool SvxSearchItem::GetExact() const
231 return 0 == (m_aSearchOpt
.transliterateFlags
& css::i18n::TransliterationModules_IGNORE_CASE
);
234 bool SvxSearchItem::GetSelection() const
236 return 0 != (m_aSearchOpt
.searchFlag
& css::util::SearchFlags::REG_NOT_BEGINOFLINE
);
239 bool SvxSearchItem::GetRegExp() const
241 // Ensure old and new algorithm types are in sync until all places are
242 // adapted to use only new types.
243 assert( (m_aSearchOpt
.algorithmType
== css::util::SearchAlgorithms_REGEXP
) ==
244 (m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::REGEXP
));
245 return m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::REGEXP
;
248 bool SvxSearchItem::GetWildcard() const
250 // Ensure old and new algorithm types are in sync, in this case old is not
251 // REGEXP or APPROXIMATE.
252 assert( m_aSearchOpt
.AlgorithmType2
!= css::util::SearchAlgorithms2::WILDCARD
||
253 (m_aSearchOpt
.algorithmType
!= css::util::SearchAlgorithms_REGEXP
&&
254 m_aSearchOpt
.algorithmType
!= css::util::SearchAlgorithms_APPROXIMATE
) );
255 return m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::WILDCARD
;
258 bool SvxSearchItem::IsLEVRelaxed() const
260 return 0 != (m_aSearchOpt
.searchFlag
& css::util::SearchFlags::LEV_RELAXED
);
263 sal_uInt16
SvxSearchItem::GetLEVOther() const
265 return (sal_Int16
) m_aSearchOpt
.changedChars
;
268 void SvxSearchItem::SetLEVOther( sal_uInt16 nVal
)
270 m_aSearchOpt
.changedChars
= nVal
;
273 sal_uInt16
SvxSearchItem::GetLEVShorter() const
275 return (sal_Int16
) m_aSearchOpt
.insertedChars
;
278 void SvxSearchItem::SetLEVShorter( sal_uInt16 nVal
)
280 m_aSearchOpt
.insertedChars
= nVal
;
283 sal_uInt16
SvxSearchItem::GetLEVLonger() const
285 return (sal_Int16
) m_aSearchOpt
.deletedChars
;
288 void SvxSearchItem::SetLEVLonger( sal_uInt16 nVal
)
290 m_aSearchOpt
.deletedChars
= nVal
;
293 bool SvxSearchItem::IsLevenshtein() const
295 // Ensure old and new algorithm types are in sync until all places are
296 // adapted to use only new types.
297 assert( (m_aSearchOpt
.algorithmType
== css::util::SearchAlgorithms_APPROXIMATE
) ==
298 (m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::APPROXIMATE
));
299 return m_aSearchOpt
.AlgorithmType2
== css::util::SearchAlgorithms2::APPROXIMATE
;
302 const css::util::SearchOptions2
& SvxSearchItem::GetSearchOptions() const
307 void SvxSearchItem::SetSearchOptions( const css::util::SearchOptions2
&rOpt
)
312 sal_Int32
SvxSearchItem::GetTransliterationFlags() const
314 return m_aSearchOpt
.transliterateFlags
;
317 bool SvxSearchItem::IsMatchFullHalfWidthForms() const
319 return 0 != (m_aSearchOpt
.transliterateFlags
& css::i18n::TransliterationModules_IGNORE_WIDTH
);
325 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */