LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / inc / docoptio.hxx
blob6e4d4f124cda96406cf1de8e1b416b1698a51258
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <unotools/textsearch.hxx>
23 #include <svl/poolitem.hxx>
24 #include "scdllapi.h"
25 #include "optutil.hxx"
27 class SC_DLLPUBLIC ScDocOptions
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 bMatchWholeCell; ///< search criteria must match the whole cell
42 bool bDoAutoSpell; ///< auto-spelling
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
48 public:
49 ScDocOptions();
51 bool IsLookUpColRowNames() const { return bLookUpColRowNames; }
52 void SetLookUpColRowNames( bool bVal ) { bLookUpColRowNames = bVal; }
53 bool IsAutoSpell() const { return bDoAutoSpell; }
54 void SetAutoSpell( bool bVal ) { bDoAutoSpell = bVal; }
55 bool IsMatchWholeCell() const { return bMatchWholeCell; }
56 void SetMatchWholeCell( bool bVal ) { bMatchWholeCell = bVal; }
57 bool IsIgnoreCase() const { return bIsIgnoreCase; }
58 void SetIgnoreCase( bool bVal ) { bIsIgnoreCase = bVal; }
59 bool IsIter() const { return bIsIter; }
60 void SetIter( bool bVal ) { bIsIter = bVal; }
61 sal_uInt16 GetIterCount() const { return nIterCount; }
62 void SetIterCount( sal_uInt16 nCount) { nIterCount = nCount; }
63 double GetIterEps() const { return fIterEps; }
64 void SetIterEps( double fEps ) { fIterEps = fEps; }
66 void GetDate( sal_uInt16& rD, sal_uInt16& rM, sal_Int16& rY ) const
67 { rD = nDay; rM = nMonth; rY = nYear;}
68 void SetDate (sal_uInt16 nD, sal_uInt16 nM, sal_Int16 nY)
69 { nDay = nD; nMonth = nM; nYear = nY; }
70 sal_uInt16 GetTabDistance() const { return nTabDistance;}
71 void SetTabDistance( sal_uInt16 nTabDist ) {nTabDistance = nTabDist;}
73 void ResetDocOptions();
75 inline bool operator==( const ScDocOptions& rOpt ) const;
76 inline bool operator!=( const ScDocOptions& rOpt ) const;
78 sal_uInt16 GetStdPrecision() const { return nPrecStandardFormat; }
79 void SetStdPrecision( sal_uInt16 n ) { nPrecStandardFormat = n; }
81 bool IsCalcAsShown() const { return bCalcAsShown; }
82 void SetCalcAsShown( bool bVal ) { bCalcAsShown = bVal; }
84 void SetYear2000( sal_uInt16 nVal ) { nYear2000 = nVal; }
85 sal_uInt16 GetYear2000() const { return nYear2000; }
87 utl::SearchParam::SearchType GetFormulaSearchType() const
89 if (eFormulaSearchType == utl::SearchParam::SearchType::Unknown || (bFormulaRegexEnabled && bFormulaWildcardsEnabled))
90 eFormulaSearchType = utl::SearchParam::ConvertToSearchType( bFormulaWildcardsEnabled, bFormulaRegexEnabled);
91 return eFormulaSearchType;
94 void SetFormulaRegexEnabled( bool bVal );
95 bool IsFormulaRegexEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SearchType::Regexp; }
97 void SetFormulaWildcardsEnabled( bool bVal );
98 bool IsFormulaWildcardsEnabled() const { return GetFormulaSearchType() == utl::SearchParam::SearchType::Wildcard; }
100 void SetWriteCalcConfig( bool bVal ) { bWriteCalcConfig = bVal; }
101 bool IsWriteCalcConfig() const { return bWriteCalcConfig; }
104 inline bool ScDocOptions::operator==( const ScDocOptions& rOpt ) const
106 return (
107 rOpt.bIsIgnoreCase == bIsIgnoreCase
108 && rOpt.bIsIter == bIsIter
109 && rOpt.nIterCount == nIterCount
110 && rOpt.fIterEps == fIterEps
111 && rOpt.nPrecStandardFormat == nPrecStandardFormat
112 && rOpt.nDay == nDay
113 && rOpt.nMonth == nMonth
114 && rOpt.nYear == nYear
115 && rOpt.nYear2000 == nYear2000
116 && rOpt.nTabDistance == nTabDistance
117 && rOpt.bCalcAsShown == bCalcAsShown
118 && rOpt.bMatchWholeCell == bMatchWholeCell
119 && rOpt.bDoAutoSpell == bDoAutoSpell
120 && rOpt.bLookUpColRowNames == bLookUpColRowNames
121 && rOpt.bFormulaRegexEnabled == bFormulaRegexEnabled
122 && rOpt.bFormulaWildcardsEnabled == bFormulaWildcardsEnabled
123 && rOpt.eFormulaSearchType == eFormulaSearchType
124 && rOpt.bWriteCalcConfig == bWriteCalcConfig
128 inline bool ScDocOptions::operator!=( const ScDocOptions& rOpt ) const
130 return !(operator==(rOpt));
133 // Item for preferences dialog - calculation
135 class SC_DLLPUBLIC ScTpCalcItem final : public SfxPoolItem
137 public:
138 ScTpCalcItem( sal_uInt16 nWhich,
139 const ScDocOptions& rOpt );
140 virtual ~ScTpCalcItem() override;
142 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
147 virtual bool operator==( const SfxPoolItem& ) const override;
148 virtual ScTpCalcItem* Clone( SfxItemPool *pPool = nullptr ) const override;
150 const ScDocOptions& GetDocOptions() const { return theOptions; }
152 private:
153 ScDocOptions theOptions;
156 // Config Item containing document options
158 class ScDocCfg : public ScDocOptions
160 ScLinkConfigItem aCalcItem;
161 ScLinkConfigItem aLayoutItem;
163 DECL_LINK( CalcCommitHdl, ScLinkConfigItem&, void );
164 DECL_LINK( LayoutCommitHdl, ScLinkConfigItem&, void );
166 static css::uno::Sequence<OUString> GetCalcPropertyNames();
167 static css::uno::Sequence<OUString> GetLayoutPropertyNames();
169 public:
170 ScDocCfg();
172 void SetOptions( const ScDocOptions& rNew );
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */