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 .
22 #include <unotools/textsearch.hxx>
23 #include <svl/poolitem.hxx>
25 #include "optutil.hxx"
27 class SC_DLLPUBLIC ScDocOptions
29 double fIterEps
; // epsilon value dazu
30 sal_uInt16 nIterCount
; ///< number
31 sal_uInt16 nPrecStandardFormat
; ///< precision for standard format
32 sal_uInt16 nDay
; ///< Null date:
35 sal_uInt16 nYear2000
; ///< earlier 19YY is assumed, 20YY otherwise (if only YY of year is given)
36 sal_uInt16 nTabDistance
; ///< distance of standard tabs
37 mutable utl::SearchParam::SearchType eFormulaSearchType
; ///< wildcards or regular expressions or normal search
38 bool bIsIgnoreCase
; ///< ignore case for comparisons?
39 bool bIsIter
; ///< iterations for circular refs
40 bool bCalcAsShown
; ///< calculate as shown (wrt precision)
41 bool bMatchWholeCell
; ///< search criteria must match the whole cell
42 bool bLookUpColRowNames
; ///< determine column-/row titles automagically
43 mutable bool bFormulaRegexEnabled
; ///< regular expressions in formulas enabled, only when reading settings
44 mutable bool bFormulaWildcardsEnabled
;///< wildcards in formulas enabled, only when reading settings
45 bool bWriteCalcConfig
; ///< (subset of) Calc config will be written to user's profile
50 bool IsLookUpColRowNames() const { return bLookUpColRowNames
; }
51 void SetLookUpColRowNames( bool bVal
) { bLookUpColRowNames
= bVal
; }
52 bool IsMatchWholeCell() const { return bMatchWholeCell
; }
53 void SetMatchWholeCell( bool bVal
) { bMatchWholeCell
= bVal
; }
54 bool IsIgnoreCase() const { return bIsIgnoreCase
; }
55 void SetIgnoreCase( bool bVal
) { bIsIgnoreCase
= bVal
; }
56 bool IsIter() const { return bIsIter
; }
57 void SetIter( bool bVal
) { bIsIter
= bVal
; }
58 sal_uInt16
GetIterCount() const { return nIterCount
; }
59 void SetIterCount( sal_uInt16 nCount
) { nIterCount
= nCount
; }
60 double GetIterEps() const { return fIterEps
; }
61 void SetIterEps( double fEps
) { fIterEps
= fEps
; }
63 void GetDate( sal_uInt16
& rD
, sal_uInt16
& rM
, sal_Int16
& rY
) const
64 { rD
= nDay
; rM
= nMonth
; rY
= nYear
;}
65 void SetDate (sal_uInt16 nD
, sal_uInt16 nM
, sal_Int16 nY
)
66 { nDay
= nD
; nMonth
= nM
; nYear
= nY
; }
67 sal_uInt16
GetTabDistance() const { return nTabDistance
;}
68 void SetTabDistance( sal_uInt16 nTabDist
) {nTabDistance
= nTabDist
;}
70 void ResetDocOptions();
72 inline bool operator==( const ScDocOptions
& rOpt
) const;
73 inline bool operator!=( const ScDocOptions
& rOpt
) const;
75 sal_uInt16
GetStdPrecision() const { return nPrecStandardFormat
; }
76 void SetStdPrecision( sal_uInt16 n
) { nPrecStandardFormat
= n
; }
78 bool IsCalcAsShown() const { return bCalcAsShown
; }
79 void SetCalcAsShown( bool bVal
) { bCalcAsShown
= bVal
; }
81 void SetYear2000( sal_uInt16 nVal
) { nYear2000
= nVal
; }
82 sal_uInt16
GetYear2000() const { return nYear2000
; }
84 utl::SearchParam::SearchType
GetFormulaSearchType() const
86 if (eFormulaSearchType
== utl::SearchParam::SearchType::Unknown
|| (bFormulaRegexEnabled
&& bFormulaWildcardsEnabled
))
87 eFormulaSearchType
= utl::SearchParam::ConvertToSearchType( bFormulaWildcardsEnabled
, bFormulaRegexEnabled
);
88 return eFormulaSearchType
;
91 void SetFormulaRegexEnabled( bool bVal
);
92 bool IsFormulaRegexEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SearchType::Regexp
; }
94 void SetFormulaWildcardsEnabled( bool bVal
);
95 bool IsFormulaWildcardsEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SearchType::Wildcard
; }
97 void SetWriteCalcConfig( bool bVal
) { bWriteCalcConfig
= bVal
; }
98 bool IsWriteCalcConfig() const { return bWriteCalcConfig
; }
101 inline bool ScDocOptions::operator==( const ScDocOptions
& rOpt
) const
104 rOpt
.bIsIgnoreCase
== bIsIgnoreCase
105 && rOpt
.bIsIter
== bIsIter
106 && rOpt
.nIterCount
== nIterCount
107 && rOpt
.fIterEps
== fIterEps
108 && rOpt
.nPrecStandardFormat
== nPrecStandardFormat
110 && rOpt
.nMonth
== nMonth
111 && rOpt
.nYear
== nYear
112 && rOpt
.nYear2000
== nYear2000
113 && rOpt
.nTabDistance
== nTabDistance
114 && rOpt
.bCalcAsShown
== bCalcAsShown
115 && rOpt
.bMatchWholeCell
== bMatchWholeCell
116 && rOpt
.bLookUpColRowNames
== bLookUpColRowNames
117 && rOpt
.bFormulaRegexEnabled
== bFormulaRegexEnabled
118 && rOpt
.bFormulaWildcardsEnabled
== bFormulaWildcardsEnabled
119 && rOpt
.eFormulaSearchType
== eFormulaSearchType
120 && rOpt
.bWriteCalcConfig
== bWriteCalcConfig
124 inline bool ScDocOptions::operator!=( const ScDocOptions
& rOpt
) const
126 return !(operator==(rOpt
));
129 // Item for preferences dialog - calculation
131 class SC_DLLPUBLIC ScTpCalcItem final
: public SfxPoolItem
134 ScTpCalcItem( sal_uInt16 nWhich
,
135 const ScDocOptions
& rOpt
);
136 virtual ~ScTpCalcItem() override
;
138 ScTpCalcItem(ScTpCalcItem
const &) = default;
139 ScTpCalcItem(ScTpCalcItem
&&) = default;
140 ScTpCalcItem
& operator =(ScTpCalcItem
const &) = delete; // due to SfxPoolItem
141 ScTpCalcItem
& operator =(ScTpCalcItem
&&) = delete; // due to SfxPoolItem
143 virtual bool operator==( const SfxPoolItem
& ) const override
;
144 virtual ScTpCalcItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
146 const ScDocOptions
& GetDocOptions() const { return theOptions
; }
149 ScDocOptions theOptions
;
152 // Config Item containing document options
154 class ScDocCfg
: public ScDocOptions
156 ScLinkConfigItem aCalcItem
;
157 ScLinkConfigItem aLayoutItem
;
159 DECL_LINK( CalcCommitHdl
, ScLinkConfigItem
&, void );
160 DECL_LINK( LayoutCommitHdl
, ScLinkConfigItem
&, void );
162 static css::uno::Sequence
<OUString
> GetCalcPropertyNames();
163 static css::uno::Sequence
<OUString
> GetLayoutPropertyNames();
168 void SetOptions( const ScDocOptions
& rNew
);
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */