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/configitem.hxx>
24 #include <unotools/textsearch.hxx>
25 #include <svl/poolitem.hxx>
26 #include <svl/itemprop.hxx>
29 #include "optutil.hxx"
31 #include <formula/grammar.hxx>
33 class SC_DLLPUBLIC ScDocOptions
35 double fIterEps
; // epsilon value dazu
36 sal_uInt16 nIterCount
; ///< number
37 sal_uInt16 nPrecStandardFormat
; ///< precision for standard format
38 sal_uInt16 nDay
; ///< Null date:
41 sal_uInt16 nYear2000
; ///< earlier 19YY is assumed, 20YY otherwise (if only YY of year is given)
42 sal_uInt16 nTabDistance
; ///< distance of standard tabs
43 mutable utl::SearchParam::SearchType eFormulaSearchType
; ///< wildcards or regular expressions or normal search
44 bool bIsIgnoreCase
; ///< ignore case for comparisons?
45 bool bIsIter
; ///< iterations for circular refs
46 bool bCalcAsShown
; ///< calculate as shown (wrt precision)
47 bool bMatchWholeCell
; ///< search criteria must match the whole cell
48 bool bDoAutoSpell
; ///< auto-spelling
49 bool bLookUpColRowNames
; ///< determine column-/row titles automagically
50 mutable bool bFormulaRegexEnabled
; ///< regular expressions in formulas enabled, only when reading settings
51 mutable bool bFormulaWildcardsEnabled
;///< wildcards in formulas enabled, only when reading settings
52 bool bWriteCalcConfig
; ///< (subset of) Calc config will be written to user's profile
54 static const utl::SearchParam::SearchType eSearchTypeUnknown
= static_cast<utl::SearchParam::SearchType
>(-1);
58 ScDocOptions( const ScDocOptions
& rCpy
);
61 bool IsLookUpColRowNames() const { return bLookUpColRowNames
; }
62 void SetLookUpColRowNames( bool bVal
) { bLookUpColRowNames
= bVal
; }
63 bool IsAutoSpell() const { return bDoAutoSpell
; }
64 void SetAutoSpell( bool bVal
) { bDoAutoSpell
= bVal
; }
65 bool IsMatchWholeCell() const { return bMatchWholeCell
; }
66 void SetMatchWholeCell( bool bVal
) { bMatchWholeCell
= bVal
; }
67 bool IsIgnoreCase() const { return bIsIgnoreCase
; }
68 void SetIgnoreCase( bool bVal
) { bIsIgnoreCase
= bVal
; }
69 bool IsIter() const { return bIsIter
; }
70 void SetIter( bool bVal
) { bIsIter
= bVal
; }
71 sal_uInt16
GetIterCount() const { return nIterCount
; }
72 void SetIterCount( sal_uInt16 nCount
) { nIterCount
= nCount
; }
73 double GetIterEps() const { return fIterEps
; }
74 void SetIterEps( double fEps
) { fIterEps
= fEps
; }
76 void GetDate( sal_uInt16
& rD
, sal_uInt16
& rM
, sal_Int16
& rY
) const
77 { rD
= nDay
; rM
= nMonth
; rY
= nYear
;}
78 void SetDate (sal_uInt16 nD
, sal_uInt16 nM
, sal_Int16 nY
)
79 { nDay
= nD
; nMonth
= nM
; nYear
= nY
; }
80 sal_uInt16
GetTabDistance() const { return nTabDistance
;}
81 void SetTabDistance( sal_uInt16 nTabDist
) {nTabDistance
= nTabDist
;}
83 void ResetDocOptions();
85 inline bool operator==( const ScDocOptions
& rOpt
) const;
86 inline bool operator!=( const ScDocOptions
& rOpt
) const;
88 sal_uInt16
GetStdPrecision() const { return nPrecStandardFormat
; }
89 void SetStdPrecision( sal_uInt16 n
) { nPrecStandardFormat
= n
; }
91 bool IsCalcAsShown() const { return bCalcAsShown
; }
92 void SetCalcAsShown( bool bVal
) { bCalcAsShown
= bVal
; }
94 void SetYear2000( sal_uInt16 nVal
) { nYear2000
= nVal
; }
95 sal_uInt16
GetYear2000() const { return nYear2000
; }
97 utl::SearchParam::SearchType
GetFormulaSearchType() const
99 if (eFormulaSearchType
== eSearchTypeUnknown
|| (bFormulaRegexEnabled
&& bFormulaWildcardsEnabled
))
100 eFormulaSearchType
= utl::SearchParam::ConvertToSearchType( bFormulaWildcardsEnabled
, bFormulaRegexEnabled
);
101 return eFormulaSearchType
;
104 void SetFormulaRegexEnabled( bool bVal
);
105 bool IsFormulaRegexEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SRCH_REGEXP
; }
107 void SetFormulaWildcardsEnabled( bool bVal
);
108 bool IsFormulaWildcardsEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SRCH_WILDCARD
; }
110 void SetWriteCalcConfig( bool bVal
) { bWriteCalcConfig
= bVal
; }
111 bool IsWriteCalcConfig() const { return bWriteCalcConfig
; }
114 inline bool ScDocOptions::operator==( const ScDocOptions
& rOpt
) const
117 rOpt
.bIsIgnoreCase
== bIsIgnoreCase
118 && rOpt
.bIsIter
== bIsIter
119 && rOpt
.nIterCount
== nIterCount
120 && rOpt
.fIterEps
== fIterEps
121 && rOpt
.nPrecStandardFormat
== nPrecStandardFormat
123 && rOpt
.nMonth
== nMonth
124 && rOpt
.nYear
== nYear
125 && rOpt
.nYear2000
== nYear2000
126 && rOpt
.nTabDistance
== nTabDistance
127 && rOpt
.bCalcAsShown
== bCalcAsShown
128 && rOpt
.bMatchWholeCell
== bMatchWholeCell
129 && rOpt
.bDoAutoSpell
== bDoAutoSpell
130 && rOpt
.bLookUpColRowNames
== bLookUpColRowNames
131 && rOpt
.bFormulaRegexEnabled
== bFormulaRegexEnabled
132 && rOpt
.bFormulaWildcardsEnabled
== bFormulaWildcardsEnabled
133 && rOpt
.eFormulaSearchType
== eFormulaSearchType
134 && rOpt
.bWriteCalcConfig
== bWriteCalcConfig
138 inline bool ScDocOptions::operator!=( const ScDocOptions
& rOpt
) const
140 return !(operator==(rOpt
));
143 // Item for preferences dialog - calculation
145 class SC_DLLPUBLIC ScTpCalcItem
: public SfxPoolItem
148 static SfxPoolItem
* CreateDefault();
149 ScTpCalcItem( sal_uInt16 nWhich
,
150 const ScDocOptions
& rOpt
);
151 ScTpCalcItem( const ScTpCalcItem
& rItem
);
152 virtual ~ScTpCalcItem() override
;
154 virtual bool operator==( const SfxPoolItem
& ) const override
;
155 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
157 const ScDocOptions
& GetDocOptions() const { return theOptions
; }
160 ScDocOptions theOptions
;
163 // Config Item containing document options
165 class ScDocCfg
: public ScDocOptions
167 ScLinkConfigItem aCalcItem
;
168 ScLinkConfigItem aLayoutItem
;
170 DECL_LINK( CalcCommitHdl
, ScLinkConfigItem
&, void );
171 DECL_LINK( LayoutCommitHdl
, ScLinkConfigItem
&, void );
173 static css::uno::Sequence
<OUString
> GetCalcPropertyNames();
174 static css::uno::Sequence
<OUString
> GetLayoutPropertyNames();
179 void SetOptions( const ScDocOptions
& rNew
);
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */