LibreOffice Module sc (master)  1
docoptio.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_SC_INC_DOCOPTIO_HXX
21 #define INCLUDED_SC_INC_DOCOPTIO_HXX
22 
23 #include <unotools/textsearch.hxx>
24 #include <svl/poolitem.hxx>
25 #include "scdllapi.h"
26 #include "optutil.hxx"
27 
29 {
30  double fIterEps; // epsilon value dazu
31  sal_uInt16 nIterCount;
32  sal_uInt16 nPrecStandardFormat;
33  sal_uInt16 nDay;
34  sal_uInt16 nMonth;
35  sal_uInt16 nYear;
36  sal_uInt16 nYear2000;
37  sal_uInt16 nTabDistance;
40  bool bIsIter;
41  bool bCalcAsShown;
43  bool bDoAutoSpell;
45  mutable bool bFormulaRegexEnabled;
48 
49 public:
50  ScDocOptions();
51 
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; }
66 
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;}
73 
74  void ResetDocOptions();
75 
76  inline bool operator==( const ScDocOptions& rOpt ) const;
77  inline bool operator!=( const ScDocOptions& rOpt ) const;
78 
79  sal_uInt16 GetStdPrecision() const { return nPrecStandardFormat; }
80  void SetStdPrecision( sal_uInt16 n ) { nPrecStandardFormat = n; }
81 
82  bool IsCalcAsShown() const { return bCalcAsShown; }
83  void SetCalcAsShown( bool bVal ) { bCalcAsShown = bVal; }
84 
85  void SetYear2000( sal_uInt16 nVal ) { nYear2000 = nVal; }
86  sal_uInt16 GetYear2000() const { return nYear2000; }
87 
89  {
90  if (eFormulaSearchType == utl::SearchParam::SearchType::Unknown || (bFormulaRegexEnabled && bFormulaWildcardsEnabled))
91  eFormulaSearchType = utl::SearchParam::ConvertToSearchType( bFormulaWildcardsEnabled, bFormulaRegexEnabled);
92  return eFormulaSearchType;
93  }
94 
95  void SetFormulaRegexEnabled( bool bVal );
96  bool IsFormulaRegexEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SearchType::Regexp; }
97 
98  void SetFormulaWildcardsEnabled( bool bVal );
99  bool IsFormulaWildcardsEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SearchType::Wildcard; }
100 
101  void SetWriteCalcConfig( bool bVal ) { bWriteCalcConfig = bVal; }
102  bool IsWriteCalcConfig() const { return bWriteCalcConfig; }
103 };
104 
105 inline bool ScDocOptions::operator==( const ScDocOptions& rOpt ) const
106 {
107  return (
109  && rOpt.bIsIter == bIsIter
110  && rOpt.nIterCount == nIterCount
111  && rOpt.fIterEps == fIterEps
113  && rOpt.nDay == nDay
114  && rOpt.nMonth == nMonth
115  && rOpt.nYear == nYear
116  && rOpt.nYear2000 == nYear2000
117  && rOpt.nTabDistance == nTabDistance
118  && rOpt.bCalcAsShown == bCalcAsShown
120  && rOpt.bDoAutoSpell == bDoAutoSpell
126  );
127 }
128 
129 inline bool ScDocOptions::operator!=( const ScDocOptions& rOpt ) const
130 {
131  return !(operator==(rOpt));
132 }
133 
134 // Item for preferences dialog - calculation
135 
137 {
138 public:
139  ScTpCalcItem( sal_uInt16 nWhich,
140  const ScDocOptions& rOpt );
141  virtual ~ScTpCalcItem() override;
142 
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
147 
148  virtual bool operator==( const SfxPoolItem& ) const override;
149  virtual ScTpCalcItem* Clone( SfxItemPool *pPool = nullptr ) const override;
150 
151  const ScDocOptions& GetDocOptions() const { return theOptions; }
152 
153 private:
155 };
156 
157 // Config Item containing document options
158 
159 class ScDocCfg : public ScDocOptions
160 {
163 
164  DECL_LINK( CalcCommitHdl, ScLinkConfigItem&, void );
165  DECL_LINK( LayoutCommitHdl, ScLinkConfigItem&, void );
166 
167  static css::uno::Sequence<OUString> GetCalcPropertyNames();
168  static css::uno::Sequence<OUString> GetLayoutPropertyNames();
169 
170 public:
171  ScDocCfg();
172 
173  void SetOptions( const ScDocOptions& rNew );
174 };
175 
176 #endif
177 
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)
Definition: xlstyle.cxx:517
bool IsWriteCalcConfig() const
Definition: docoptio.hxx:102
bool bCalcAsShown
calculate as shown (wrt precision)
Definition: docoptio.hxx:41
sal_uInt16 nTabDistance
distance of standard tabs
Definition: docoptio.hxx:37
const ScDocOptions & GetDocOptions() const
Definition: docoptio.hxx:151
bool operator!=(const XclExpString &rLeft, const XclExpString &rRight)
Definition: xestring.hxx:246
static SearchType ConvertToSearchType(bool bWildcard, bool &rbRegExp)
virtual bool operator==(const SfxPoolItem &) const =0
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
utl::SearchParam::SearchType eFormulaSearchType
wildcards or regular expressions or normal search
Definition: docoptio.hxx:38
bool bFormulaRegexEnabled
regular expressions in formulas enabled, only when reading settings
Definition: docoptio.hxx:45
void SetOptions(const ScDocOptions &rNew)
Definition: docoptio.cxx:367
SfxPoolItem & operator=(const SfxPoolItem &)=delete
void SetTabDistance(sal_uInt16 nTabDist)
Definition: docoptio.hxx:72
bool IsIter() const
Definition: docoptio.hxx:60
sal_uInt16 nYear2000
earlier 19YY is assumed, 20YY otherwise (if only YY of year is given)
Definition: docoptio.hxx:36
bool IsLookUpColRowNames() const
Definition: docoptio.hxx:52
sal_uInt16 GetIterCount() const
Definition: docoptio.hxx:62
sal_uInt16 nPrecStandardFormat
precision for standard format
Definition: docoptio.hxx:32
double fIterEps
Definition: docoptio.hxx:30
sal_uInt16 nMonth
Definition: docoptio.hxx:34
bool bWriteCalcConfig
(subset of) Calc config will be written to user's profile
Definition: docoptio.hxx:47
static css::uno::Sequence< OUString > GetCalcPropertyNames()
Definition: docoptio.cxx:159
void SetLookUpColRowNames(bool bVal)
Definition: docoptio.hxx:53
void SetIgnoreCase(bool bVal)
Definition: docoptio.hxx:59
bool bMatchWholeCell
search criteria must match the whole cell
Definition: docoptio.hxx:42
bool bDoAutoSpell
auto-spelling
Definition: docoptio.hxx:43
static css::uno::Sequence< OUString > GetLayoutPropertyNames()
Definition: docoptio.cxx:176
sal_uInt16 nDay
Null date:
Definition: docoptio.hxx:33
bool IsMatchWholeCell() const
Definition: docoptio.hxx:56
void SetCalcAsShown(bool bVal)
Definition: docoptio.hxx:83
bool bIsIter
iterations for circular refs
Definition: docoptio.hxx:40
utl::SearchParam::SearchType GetFormulaSearchType() const
Definition: docoptio.hxx:88
sal_uInt16 GetTabDistance() const
Definition: docoptio.hxx:71
ScLinkConfigItem aCalcItem
Definition: docoptio.hxx:161
bool bLookUpColRowNames
determine column-/row titles automagically
Definition: docoptio.hxx:44
bool operator==(const ScDocOptions &rOpt) const
Definition: docoptio.hxx:105
void SetIter(bool bVal)
Definition: docoptio.hxx:61
void SetDate(sal_uInt16 nD, sal_uInt16 nM, sal_Int16 nY)
Definition: docoptio.hxx:69
void SetYear2000(sal_uInt16 nVal)
Definition: docoptio.hxx:85
bool operator!=(const ScDocOptions &rOpt) const
Definition: docoptio.hxx:129
void SetIterCount(sal_uInt16 nCount)
Definition: docoptio.hxx:63
bool bFormulaWildcardsEnabled
wildcards in formulas enabled, only when reading settings
Definition: docoptio.hxx:46
DECL_LINK(CalcCommitHdl, ScLinkConfigItem &, void)
void SetStdPrecision(sal_uInt16 n)
Definition: docoptio.hxx:80
bool IsFormulaWildcardsEnabled() const
Definition: docoptio.hxx:99
bool IsCalcAsShown() const
Definition: docoptio.hxx:82
bool bIsIgnoreCase
ignore case for comparisons?
Definition: docoptio.hxx:39
double GetIterEps() const
Definition: docoptio.hxx:64
bool IsAutoSpell() const
Definition: docoptio.hxx:54
sal_uInt16 GetYear2000() const
Definition: docoptio.hxx:86
sal_uInt16 GetStdPrecision() const
Definition: docoptio.hxx:79
void SetMatchWholeCell(bool bVal)
Definition: docoptio.hxx:57
void SetWriteCalcConfig(bool bVal)
Definition: docoptio.hxx:101
bool IsFormulaRegexEnabled() const
Definition: docoptio.hxx:96
void SetAutoSpell(bool bVal)
Definition: docoptio.hxx:55
bool IsIgnoreCase() const
Definition: docoptio.hxx:58
ScLinkConfigItem aLayoutItem
Definition: docoptio.hxx:162
sal_uInt16 nIterCount
number
Definition: docoptio.hxx:31
ScDocOptions theOptions
Definition: docoptio.hxx:154
sal_uInt16 nYear
Definition: docoptio.hxx:35
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
void GetDate(sal_uInt16 &rD, sal_uInt16 &rM, sal_Int16 &rY) const
Definition: docoptio.hxx:67
void SetIterEps(double fEps)
Definition: docoptio.hxx:65