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