LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / inc / formulaopt.hxx
blob7b7d173f47164b34f840f223f801ce4beba95276
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/.
8 */
10 #pragma once
12 #include <map>
13 #include <svl/poolitem.hxx>
14 #include <unotools/configitem.hxx>
15 #include <formula/grammar.hxx>
16 #include "scdllapi.h"
17 #include "calcconfig.hxx"
19 class SC_DLLPUBLIC ScFormulaOptions
21 private:
22 bool bUseEnglishFuncName; // use English function name even if the locale is not English.
23 formula::FormulaGrammar::Grammar eFormulaGrammar; // formula grammar used to switch different formula syntax
24 ScCalcConfig aCalcConfig;
25 bool mbWriteCalcConfig;
27 OUString aFormulaSepArg;
28 OUString aFormulaSepArrayRow;
29 OUString aFormulaSepArrayCol;
31 ScRecalcOptions meOOXMLRecalc;
32 ScRecalcOptions meODFRecalc;
34 public:
35 ScFormulaOptions();
37 void SetDefaults();
39 void SetFormulaSyntax( ::formula::FormulaGrammar::Grammar eGram ) { eFormulaGrammar = eGram; }
40 ::formula::FormulaGrammar::Grammar GetFormulaSyntax() const { return eFormulaGrammar; }
42 ScCalcConfig& GetCalcConfig() { return aCalcConfig; }
43 const ScCalcConfig& GetCalcConfig() const { return aCalcConfig; }
44 void SetCalcConfig(const ScCalcConfig& rConfig) { aCalcConfig = rConfig; }
46 void SetUseEnglishFuncName( bool bVal ) { bUseEnglishFuncName = bVal; }
47 bool GetUseEnglishFuncName() const { return bUseEnglishFuncName; }
49 void SetWriteCalcConfig( bool bVal ) { mbWriteCalcConfig = bVal; }
50 bool GetWriteCalcConfig() const { return mbWriteCalcConfig; }
52 void SetFormulaSepArg(const OUString& rSep) { aFormulaSepArg = rSep; }
53 const OUString& GetFormulaSepArg() const { return aFormulaSepArg; }
55 void SetFormulaSepArrayRow(const OUString& rSep) { aFormulaSepArrayRow = rSep; }
56 const OUString& GetFormulaSepArrayRow() const { return aFormulaSepArrayRow; }
58 void SetFormulaSepArrayCol(const OUString& rSep) { aFormulaSepArrayCol = rSep; }
59 const OUString& GetFormulaSepArrayCol() const { return aFormulaSepArrayCol; }
61 void SetOOXMLRecalcOptions( ScRecalcOptions eOpt ) { meOOXMLRecalc = eOpt; }
62 ScRecalcOptions GetOOXMLRecalcOptions() const { return meOOXMLRecalc; }
64 void SetODFRecalcOptions( ScRecalcOptions eOpt ) { meODFRecalc = eOpt; }
65 ScRecalcOptions GetODFRecalcOptions() const { return meODFRecalc; }
67 void ResetFormulaSeparators();
69 static void GetDefaultFormulaSeparators(OUString& rSepArg, OUString& rSepArrayCol, OUString& rSepArrayRow);
71 bool operator== ( const ScFormulaOptions& rOpt ) const;
72 bool operator!= ( const ScFormulaOptions& rOpt ) const;
75 // item for the dialog / options page
77 class SC_DLLPUBLIC ScTpFormulaItem final : public SfxPoolItem
79 public:
80 ScTpFormulaItem( const ScFormulaOptions& rOpt );
81 virtual ~ScTpFormulaItem() override;
83 ScTpFormulaItem(ScTpFormulaItem const &) = default;
84 ScTpFormulaItem(ScTpFormulaItem &&) = default;
85 ScTpFormulaItem & operator =(ScTpFormulaItem const &) = delete; // due to SfxPoolItem
86 ScTpFormulaItem & operator =(ScTpFormulaItem &&) = delete; // due to SfxPoolItem
88 virtual bool operator==( const SfxPoolItem& ) const override;
89 virtual ScTpFormulaItem* Clone( SfxItemPool *pPool = nullptr ) const override;
91 const ScFormulaOptions& GetFormulaOptions() const { return theOptions; }
93 private:
94 ScFormulaOptions theOptions;
97 // config item
99 class ScFormulaCfg final : public ScFormulaOptions, public utl::ConfigItem
101 typedef std::map<OUString,sal_uInt16> PropsToIds;
102 static css::uno::Sequence<OUString> GetPropertyNames();
103 static ScFormulaCfg::PropsToIds GetPropNamesToId();
104 void UpdateFromProperties( const css::uno::Sequence<OUString>& rNames );
106 virtual void ImplCommit() override;
108 public:
109 ScFormulaCfg();
111 void SetOptions( const ScFormulaOptions& rNew );
113 virtual void Notify( const css::uno::Sequence< OUString >& aPropertyNames ) override;
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */