/src/libreoffice/sc/inc/docoptio.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
22 | | #include <unotools/textsearch.hxx> |
23 | | #include <svl/poolitem.hxx> |
24 | | #include "scdllapi.h" |
25 | | #include "optutil.hxx" |
26 | | |
27 | | class SC_DLLPUBLIC ScDocOptions |
28 | | { |
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: |
33 | | sal_uInt16 nMonth; |
34 | | sal_uInt16 nYear; |
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 bIgnoreLineBreaks; ///< ignore line breaks when referencing cells, default is false. |
42 | | bool bMatchWholeCell; ///< search criteria must match the whole cell |
43 | | bool bLookUpColRowNames; ///< determine column-/row titles automagically |
44 | | mutable bool bFormulaRegexEnabled; ///< regular expressions in formulas enabled, only when reading settings |
45 | | mutable bool bFormulaWildcardsEnabled;///< wildcards in formulas enabled, only when reading settings |
46 | | bool bWriteCalcConfig; ///< (subset of) Calc config will be written to user's profile |
47 | | |
48 | | public: |
49 | | ScDocOptions(); |
50 | | |
51 | 2.46M | bool IsLookUpColRowNames() const { return bLookUpColRowNames; } |
52 | 159k | void SetLookUpColRowNames( bool bVal ) { bLookUpColRowNames = bVal; } |
53 | 17.7k | bool IsMatchWholeCell() const { return bMatchWholeCell; } |
54 | 19.6k | void SetMatchWholeCell( bool bVal ) { bMatchWholeCell = bVal; } |
55 | 291k | bool IsIgnoreCase() const { return bIsIgnoreCase; } |
56 | 37.7k | void SetIgnoreCase( bool bVal ) { bIsIgnoreCase = bVal; } |
57 | 21.5k | bool IsIgnoreLineBreaks() const { return bIgnoreLineBreaks; } |
58 | 18.2k | void SetIgnoreLineBreaks( bool bVal ) { bIgnoreLineBreaks = bVal; } |
59 | 39.2k | bool IsIter() const { return bIsIter; } |
60 | 27.0k | void SetIter( bool bVal ) { bIsIter = bVal; } |
61 | 0 | sal_uInt16 GetIterCount() const { return nIterCount; } |
62 | 26.3k | void SetIterCount( sal_uInt16 nCount) { nIterCount = nCount; } |
63 | 0 | double GetIterEps() const { return fIterEps; } |
64 | 29.5k | void SetIterEps( double fEps ) { fIterEps = fEps; } |
65 | | |
66 | | void GetDate( sal_uInt16& rD, sal_uInt16& rM, sal_Int16& rY ) const |
67 | 189k | { rD = nDay; rM = nMonth; rY = nYear;} |
68 | | void SetDate (sal_uInt16 nD, sal_uInt16 nM, sal_Int16 nY) |
69 | 37.8k | { nDay = nD; nMonth = nM; nYear = nY; } |
70 | 19.6k | sal_uInt16 GetTabDistance() const { return nTabDistance;} |
71 | 624 | void SetTabDistance( sal_uInt16 nTabDist ) {nTabDistance = nTabDist;} |
72 | | |
73 | | void ResetDocOptions(); |
74 | | |
75 | | inline bool operator==( const ScDocOptions& rOpt ) const; |
76 | | inline bool operator!=( const ScDocOptions& rOpt ) const; |
77 | | |
78 | 189k | sal_uInt16 GetStdPrecision() const { return nPrecStandardFormat; } |
79 | 0 | void SetStdPrecision( sal_uInt16 n ) { nPrecStandardFormat = n; } |
80 | | |
81 | 1.22M | bool IsCalcAsShown() const { return bCalcAsShown; } |
82 | 25.0k | void SetCalcAsShown( bool bVal ) { bCalcAsShown = bVal; } |
83 | | |
84 | 19.6k | void SetYear2000( sal_uInt16 nVal ) { nYear2000 = nVal; } |
85 | 189k | sal_uInt16 GetYear2000() const { return nYear2000; } |
86 | | |
87 | | utl::SearchParam::SearchType GetFormulaSearchType() const |
88 | 3.78k | { |
89 | 3.78k | if (eFormulaSearchType == utl::SearchParam::SearchType::Unknown || (bFormulaRegexEnabled && bFormulaWildcardsEnabled)) |
90 | 0 | eFormulaSearchType = utl::SearchParam::ConvertToSearchType( bFormulaWildcardsEnabled, bFormulaRegexEnabled); |
91 | 3.78k | return eFormulaSearchType; |
92 | 3.78k | } |
93 | | |
94 | | void SetFormulaRegexEnabled( bool bVal ); |
95 | 0 | bool IsFormulaRegexEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SearchType::Regexp; } |
96 | | |
97 | | void SetFormulaWildcardsEnabled( bool bVal ); |
98 | 0 | bool IsFormulaWildcardsEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SearchType::Wildcard; } |
99 | | |
100 | 0 | void SetWriteCalcConfig( bool bVal ) { bWriteCalcConfig = bVal; } |
101 | 0 | bool IsWriteCalcConfig() const { return bWriteCalcConfig; } |
102 | | }; |
103 | | |
104 | | inline bool ScDocOptions::operator==( const ScDocOptions& rOpt ) const |
105 | 259k | { |
106 | 259k | return ( |
107 | 259k | rOpt.bIsIgnoreCase == bIsIgnoreCase |
108 | 255k | && rOpt.bIsIter == bIsIter |
109 | 255k | && rOpt.nIterCount == nIterCount |
110 | 254k | && rOpt.fIterEps == fIterEps |
111 | 251k | && rOpt.nPrecStandardFormat == nPrecStandardFormat |
112 | 251k | && rOpt.nDay == nDay |
113 | 251k | && rOpt.nMonth == nMonth |
114 | 251k | && rOpt.nYear == nYear |
115 | 251k | && rOpt.nYear2000 == nYear2000 |
116 | 251k | && rOpt.nTabDistance == nTabDistance |
117 | 251k | && rOpt.bCalcAsShown == bCalcAsShown |
118 | 251k | && rOpt.bMatchWholeCell == bMatchWholeCell |
119 | 251k | && rOpt.bLookUpColRowNames == bLookUpColRowNames |
120 | 247k | && rOpt.bFormulaRegexEnabled == bFormulaRegexEnabled |
121 | 236k | && rOpt.bFormulaWildcardsEnabled == bFormulaWildcardsEnabled |
122 | 235k | && rOpt.eFormulaSearchType == eFormulaSearchType |
123 | 235k | && rOpt.bWriteCalcConfig == bWriteCalcConfig |
124 | 259k | ); |
125 | 259k | } |
126 | | |
127 | | inline bool ScDocOptions::operator!=( const ScDocOptions& rOpt ) const |
128 | 259k | { |
129 | 259k | return !(operator==(rOpt)); |
130 | 259k | } |
131 | | |
132 | | // Item for preferences dialog - calculation |
133 | | |
134 | | class SC_DLLPUBLIC ScTpCalcItem final : public SfxPoolItem |
135 | | { |
136 | | public: |
137 | | ScTpCalcItem( sal_uInt16 nWhich, |
138 | | const ScDocOptions& rOpt ); |
139 | | virtual ~ScTpCalcItem() override; |
140 | | |
141 | | DECLARE_ITEM_TYPE_FUNCTION(ScTpCalcItem) |
142 | 0 | ScTpCalcItem(ScTpCalcItem const &) = default; |
143 | | ScTpCalcItem(ScTpCalcItem &&) = default; |
144 | | ScTpCalcItem & operator =(ScTpCalcItem const &) = delete; // due to SfxPoolItem |
145 | | ScTpCalcItem & operator =(ScTpCalcItem &&) = delete; // due to SfxPoolItem |
146 | | |
147 | | virtual bool operator==( const SfxPoolItem& ) const override; |
148 | | virtual ScTpCalcItem* Clone( SfxItemPool *pPool = nullptr ) const override; |
149 | | |
150 | 0 | const ScDocOptions& GetDocOptions() const { return theOptions; } |
151 | | |
152 | | private: |
153 | | ScDocOptions theOptions; |
154 | | }; |
155 | | |
156 | | // Config Item containing document options |
157 | | |
158 | | class ScDocCfg : public ScDocOptions |
159 | | { |
160 | | ScLinkConfigItem aCalcItem; |
161 | | ScLinkConfigItem aLayoutItem; |
162 | | |
163 | | DECL_LINK( CalcCommitHdl, ScLinkConfigItem&, void ); |
164 | | DECL_LINK( LayoutCommitHdl, ScLinkConfigItem&, void ); |
165 | | |
166 | | static css::uno::Sequence<OUString> GetCalcPropertyNames(); |
167 | | static css::uno::Sequence<OUString> GetLayoutPropertyNames(); |
168 | | |
169 | | public: |
170 | | ScDocCfg(); |
171 | | |
172 | | void SetOptions( const ScDocOptions& rNew ); |
173 | | }; |
174 | | |
175 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |