xref: /AOO41X/main/sc/inc/docoptio.hxx (revision 38d50f7b14e1cf975d8c6468d9633894cd59b523) !
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_DOCOPTIO_HXX
25 #define SC_DOCOPTIO_HXX
26 
27 #include <unotools/configitem.hxx>
28 #include <svl/poolitem.hxx>
29 #include <svl/itemprop.hxx>
30 #include "scdllapi.h"
31 #include "optutil.hxx"
32 
33 class SC_DLLPUBLIC ScDocOptions
34 {
35     double fIterEps;                // Epsilon-Wert dazu
36     sal_uInt16 nIterCount;              // Anzahl
37     sal_uInt16 nPrecStandardFormat; // precision for standard format
38     sal_uInt16 nDay;                    // Nulldatum:
39     sal_uInt16 nMonth;
40     sal_uInt16 nYear;
41     sal_uInt16 nYear2000;               // bis zu welcher zweistelligen Jahreszahl 20xx angenommen wird
42     sal_uInt16 nTabDistance;            // Abstand Standardtabulatoren
43     sal_Bool   bIsIgnoreCase;           // Gross-/Kleinschr. bei Vergleichen
44     sal_Bool   bIsIter;                 // Iteration bei cirk. Ref
45     sal_Bool   bCalcAsShown;            // berechnen wie angezeigt (Precision)
46     sal_Bool   bMatchWholeCell;         // Suchkriterien muessen ganze Zelle matchen
47     sal_Bool   bDoAutoSpell;            // Auto-Spelling
48     sal_Bool   bLookUpColRowNames;      // Spalten-/Zeilenbeschriftungen automagisch suchen
49     sal_Bool   bFormulaRegexEnabled;    // regular expressions in formulas enabled
50 
51 public:
52                 ScDocOptions();
53                 ScDocOptions( const ScDocOptions& rCpy );
54                 ~ScDocOptions();
55 
IsLookUpColRowNames() const56     sal_Bool   IsLookUpColRowNames() const  { return bLookUpColRowNames; }
SetLookUpColRowNames(sal_Bool bVal)57     void   SetLookUpColRowNames( sal_Bool bVal ) { bLookUpColRowNames = bVal; }
IsAutoSpell() const58     sal_Bool   IsAutoSpell() const          { return bDoAutoSpell; }
SetAutoSpell(sal_Bool bVal)59     void   SetAutoSpell( sal_Bool bVal )    { bDoAutoSpell = bVal; }
IsMatchWholeCell() const60     sal_Bool   IsMatchWholeCell() const     { return bMatchWholeCell; }
SetMatchWholeCell(sal_Bool bVal)61     void   SetMatchWholeCell( sal_Bool bVal ){ bMatchWholeCell = bVal; }
IsIgnoreCase() const62     sal_Bool   IsIgnoreCase() const         { return bIsIgnoreCase; }
SetIgnoreCase(sal_Bool bVal)63     void   SetIgnoreCase( sal_Bool bVal )   { bIsIgnoreCase = bVal; }
IsIter() const64     sal_Bool   IsIter() const               { return bIsIter; }
SetIter(sal_Bool bVal)65     void   SetIter( sal_Bool bVal )         { bIsIter = bVal; }
GetIterCount() const66     sal_uInt16 GetIterCount() const         { return nIterCount; }
SetIterCount(sal_uInt16 nCount)67     void   SetIterCount( sal_uInt16 nCount) { nIterCount = nCount; }
GetIterEps() const68     double GetIterEps() const           { return fIterEps; }
SetIterEps(double fEps)69     void   SetIterEps( double fEps )    { fIterEps = fEps; }
70 
GetDate(sal_uInt16 & rD,sal_uInt16 & rM,sal_uInt16 & rY) const71     void   GetDate( sal_uInt16& rD, sal_uInt16& rM, sal_uInt16& rY ) const
72                                         { rD = nDay; rM = nMonth; rY = nYear;}
SetDate(sal_uInt16 nD,sal_uInt16 nM,sal_uInt16 nY)73     void   SetDate (sal_uInt16 nD, sal_uInt16 nM, sal_uInt16 nY)
74                                         { nDay = nD; nMonth = nM; nYear = nY; }
GetTabDistance() const75     sal_uInt16 GetTabDistance() const { return nTabDistance;}
SetTabDistance(sal_uInt16 nTabDist)76     void   SetTabDistance( sal_uInt16 nTabDist ) {nTabDistance = nTabDist;}
77 
78     void        ResetDocOptions();
79     inline void     CopyTo(ScDocOptions& rOpt);
80 
81     inline const ScDocOptions&  operator=( const ScDocOptions& rOpt );
82     inline int                  operator==( const ScDocOptions& rOpt ) const;
83     inline int                  operator!=( const ScDocOptions& rOpt ) const;
84 
GetStdPrecision() const85     sal_uInt16  GetStdPrecision() const { return nPrecStandardFormat; }
SetStdPrecision(sal_uInt16 n)86     void        SetStdPrecision( sal_uInt16 n ) { nPrecStandardFormat = n; }
87 
IsCalcAsShown() const88     sal_Bool    IsCalcAsShown() const       { return bCalcAsShown; }
SetCalcAsShown(sal_Bool bVal)89     void    SetCalcAsShown( sal_Bool bVal ) { bCalcAsShown = bVal; }
90 
SetYear2000(sal_uInt16 nVal)91     void    SetYear2000( sal_uInt16 nVal )  { nYear2000 = nVal; }
GetYear2000() const92     sal_uInt16  GetYear2000() const         { return nYear2000; }
93 
SetFormulaRegexEnabled(sal_Bool bVal)94     void    SetFormulaRegexEnabled( sal_Bool bVal ) { bFormulaRegexEnabled = bVal; }
IsFormulaRegexEnabled() const95     sal_Bool    IsFormulaRegexEnabled() const       { return bFormulaRegexEnabled; }
96 };
97 
98 
CopyTo(ScDocOptions & rOpt)99 inline void ScDocOptions::CopyTo(ScDocOptions& rOpt)
100 {
101     rOpt.bIsIgnoreCase          = bIsIgnoreCase;
102     rOpt.bIsIter                = bIsIter;
103     rOpt.nIterCount             = nIterCount;
104     rOpt.fIterEps               = fIterEps;
105     rOpt.nPrecStandardFormat    = nPrecStandardFormat;
106     rOpt.nDay                   = nDay;
107     rOpt.nMonth                 = nMonth;
108     rOpt.nYear2000              = nYear2000;
109     rOpt.nYear                  = nYear;
110     rOpt.nTabDistance           = nTabDistance;
111     rOpt.bCalcAsShown           = bCalcAsShown;
112     rOpt.bMatchWholeCell        = bMatchWholeCell;
113     rOpt.bDoAutoSpell           = bDoAutoSpell;
114     rOpt.bLookUpColRowNames     = bLookUpColRowNames;
115     rOpt.bFormulaRegexEnabled   = bFormulaRegexEnabled;
116 }
117 
operator =(const ScDocOptions & rCpy)118 inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
119 {
120     bIsIgnoreCase       = rCpy.bIsIgnoreCase;
121     bIsIter             = rCpy.bIsIter;
122     nIterCount          = rCpy.nIterCount;
123     fIterEps            = rCpy.fIterEps;
124     nPrecStandardFormat = rCpy.nPrecStandardFormat;
125     nDay                = rCpy.nDay;
126     nMonth              = rCpy.nMonth;
127     nYear               = rCpy.nYear;
128     nYear2000           = rCpy.nYear2000;
129     nTabDistance        = rCpy.nTabDistance;
130     bCalcAsShown        = rCpy.bCalcAsShown;
131     bMatchWholeCell     = rCpy.bMatchWholeCell;
132     bDoAutoSpell        = rCpy.bDoAutoSpell;
133     bLookUpColRowNames  = rCpy.bLookUpColRowNames;
134     bFormulaRegexEnabled= rCpy.bFormulaRegexEnabled;
135 
136     return *this;
137 }
138 
operator ==(const ScDocOptions & rOpt) const139 inline int ScDocOptions::operator==( const ScDocOptions& rOpt ) const
140 {
141     return (
142                 rOpt.bIsIgnoreCase          == bIsIgnoreCase
143             &&  rOpt.bIsIter                == bIsIter
144             &&  rOpt.nIterCount             == nIterCount
145             &&  rOpt.fIterEps               == fIterEps
146             &&  rOpt.nPrecStandardFormat    == nPrecStandardFormat
147             &&  rOpt.nDay                   == nDay
148             &&  rOpt.nMonth                 == nMonth
149             &&  rOpt.nYear                  == nYear
150             &&  rOpt.nYear2000              == nYear2000
151             &&  rOpt.nTabDistance           == nTabDistance
152             &&  rOpt.bCalcAsShown           == bCalcAsShown
153             &&  rOpt.bMatchWholeCell        == bMatchWholeCell
154             &&  rOpt.bDoAutoSpell           == bDoAutoSpell
155             &&  rOpt.bLookUpColRowNames     == bLookUpColRowNames
156             &&  rOpt.bFormulaRegexEnabled   == bFormulaRegexEnabled
157             );
158 }
159 
operator !=(const ScDocOptions & rOpt) const160 inline int ScDocOptions::operator!=( const ScDocOptions& rOpt ) const
161 {
162     return !(operator==(rOpt));
163 }
164 
165 //==================================================================
166 // Item fuer Einstellungsdialog - Berechnen
167 //==================================================================
168 
169 class SC_DLLPUBLIC ScTpCalcItem : public SfxPoolItem
170 {
171 public:
172                 TYPEINFO();
173 //UNUSED2008-05  ScTpCalcItem( sal_uInt16 nWhich );
174                 ScTpCalcItem( sal_uInt16 nWhich,
175                               const ScDocOptions& rOpt );
176                 ScTpCalcItem( const ScTpCalcItem& rItem );
177                 ~ScTpCalcItem();
178 
179     virtual String          GetValueText() const;
180     virtual int             operator==( const SfxPoolItem& ) const;
181     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
182 
GetDocOptions() const183     const ScDocOptions& GetDocOptions() const { return theOptions; }
184 
185 private:
186     ScDocOptions theOptions;
187 };
188 
189 //==================================================================
190 //  Config Item containing document options
191 //==================================================================
192 
193 class ScDocCfg : public ScDocOptions
194 {
195     ScLinkConfigItem    aCalcItem;
196     ScLinkConfigItem    aLayoutItem;
197 
198     DECL_LINK( CalcCommitHdl, void* );
199     DECL_LINK( LayoutCommitHdl, void* );
200 
201     com::sun::star::uno::Sequence<rtl::OUString> GetCalcPropertyNames();
202     com::sun::star::uno::Sequence<rtl::OUString> GetLayoutPropertyNames();
203 
204 public:
205             ScDocCfg();
206 
207     void    SetOptions( const ScDocOptions& rNew );
208 };
209 
210 
211 #endif
212 
213