LibreOffice Module sc (master)  1
calcoptionsdlg.cxx
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 
10 #include <sal/config.h>
11 
12 #include <officecfg/Office/Calc.hxx>
13 
14 #include <calcconfig.hxx>
15 #include "calcoptionsdlg.hxx"
16 
17 namespace {
18 
19 formula::FormulaGrammar::AddressConvention toAddressConvention(sal_Int32 nPos)
20 {
21  switch (nPos)
22  {
23  case 1:
25  case 2:
27  case 3:
29  case 4:
31  case 0:
32  default:
33  ;
34  }
35 
37 }
38 
39 sal_Int32 toSelectedItem( formula::FormulaGrammar::AddressConvention eConv )
40 {
41  switch (eConv)
42  {
44  return 1;
46  return 2;
48  return 3;
50  return 4;
51  default:
52  ;
53  }
54  return 0;
55 }
56 
57 }
58 
59 ScCalcOptionsDialog::ScCalcOptionsDialog(weld::Window* pParent, const ScCalcConfig& rConfig, bool bWriteConfig)
60  : GenericDialogController(pParent, "modules/scalc/ui/formulacalculationoptions.ui", "FormulaCalculationOptions")
61  , maConfig(rConfig)
62  , mbSelectedEmptyStringAsZero(rConfig.mbEmptyStringAsZero)
63  , mbWriteConfig(bWriteConfig)
64  , mxEmptyAsZero(m_xBuilder->weld_check_button("checkEmptyAsZero"))
65  , mxConversion(m_xBuilder->weld_combo_box("comboConversion"))
66  , mxCurrentDocOnly(m_xBuilder->weld_check_button("current_doc"))
67  , mxSyntax(m_xBuilder->weld_combo_box("comboSyntaxRef"))
68 {
69  mxConversion->set_active(static_cast<int>(rConfig.meStringConversion));
70  mxConversion->connect_changed(LINK(this, ScCalcOptionsDialog, ConversionModifiedHdl));
71  mxConversion->set_sensitive( !officecfg::Office::Calc::Formula::Syntax::StringConversion::isReadOnly() );
72 
73  mxEmptyAsZero->set_active(rConfig.mbEmptyStringAsZero);
74  mxEmptyAsZero->connect_toggled(LINK(this, ScCalcOptionsDialog, AsZeroModifiedHdl));
76  mxEmptyAsZero->set_sensitive ( !officecfg::Office::Calc::Formula::Syntax::EmptyStringAsZero::isReadOnly() );
77 
78  mxSyntax->set_active(toSelectedItem(rConfig.meStringRefAddressSyntax));
79  mxSyntax->connect_changed(LINK(this, ScCalcOptionsDialog, SyntaxModifiedHdl));
80  mxSyntax->set_sensitive ( !officecfg::Office::Calc::Formula::Syntax::StringRefAddressSyntax::isReadOnly() );
81 
82  mxCurrentDocOnly->set_active(!mbWriteConfig);
83  mxCurrentDocOnly->connect_toggled(LINK(this, ScCalcOptionsDialog, CurrentDocOnlyHdl));
84 }
85 
87 {
88 }
89 
91 {
93  {
96  mxEmptyAsZero->set_active(false);
97  mxEmptyAsZero->set_sensitive(false);
98  break;
101  mxEmptyAsZero->set_active(true);
102  mxEmptyAsZero->set_sensitive(false);
103  break;
106  // Reset to the value the user selected before.
108  mxEmptyAsZero->set_sensitive(true);
110  break;
111  }
112 }
113 
114 IMPL_LINK(ScCalcOptionsDialog, AsZeroModifiedHdl, weld::ToggleButton&, rCheckBox, void )
115 {
116  maConfig.mbEmptyStringAsZero = mbSelectedEmptyStringAsZero = rCheckBox.get_active();
117 }
118 
119 IMPL_LINK(ScCalcOptionsDialog, ConversionModifiedHdl, weld::ComboBox&, rConv, void)
120 {
121  maConfig.meStringConversion = static_cast<ScCalcConfig::StringConversion>(rConv.get_active());
122  CoupleEmptyAsZeroToStringConversion();
123 }
124 
125 IMPL_LINK(ScCalcOptionsDialog, SyntaxModifiedHdl, weld::ComboBox&, rSyntax, void)
126 {
127  maConfig.SetStringRefSyntax(toAddressConvention(rSyntax.get_active()));
128 }
129 
130 IMPL_LINK(ScCalcOptionsDialog, CurrentDocOnlyHdl, weld::ToggleButton&, rCheckBox, void)
131 {
132  mbWriteConfig = !rCheckBox.get_active();
133 }
134 
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::ComboBox > mxConversion
IMPL_LINK(ScCalcOptionsDialog, AsZeroModifiedHdl, weld::ToggleButton &, rCheckBox, void)
=1+"1" gives 2, but =1+"1.000" or =1+"x" give VALUE!
virtual ~ScCalcOptionsDialog() override
=1+"1" or =1+"x" give 1
StringConversion meStringConversion
Definition: calcconfig.hxx:54
std::unique_ptr< weld::CheckButton > mxCurrentDocOnly
=1+"1.000" may be 2 or 1001 ... =1+"x" gives VALUE!
formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax
Definition: calcconfig.hxx:53
Configuration options for formula interpreter.
Definition: calcconfig.hxx:43
std::unique_ptr< weld::ComboBox > mxSyntax
=1+"1" or =1+"x" give VALUE!
std::unique_ptr< weld::CheckButton > mxEmptyAsZero
bool mbEmptyStringAsZero
Definition: calcconfig.hxx:55
ScCalcOptionsDialog(weld::Window *pParent, const ScCalcConfig &rConfig, bool bWriteConfig)
void CoupleEmptyAsZeroToStringConversion()