summaryrefslogtreecommitdiffstats
path: root/sc/source/ui/optdlg
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /sc/source/ui/optdlg
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/source/ui/optdlg')
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.cxx135
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.hxx43
-rw-r--r--sc/source/ui/optdlg/opredlin.cxx105
-rw-r--r--sc/source/ui/optdlg/tpcalc.cxx277
-rw-r--r--sc/source/ui/optdlg/tpcompatibility.cxx74
-rw-r--r--sc/source/ui/optdlg/tpdefaults.cxx134
-rw-r--r--sc/source/ui/optdlg/tpformula.cxx411
-rw-r--r--sc/source/ui/optdlg/tpprint.cxx111
-rw-r--r--sc/source/ui/optdlg/tpusrlst.cxx738
-rw-r--r--sc/source/ui/optdlg/tpview.cxx619
10 files changed, 2647 insertions, 0 deletions
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
new file mode 100644
index 000000000..ec65fb9d8
--- /dev/null
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include <officecfg/Office/Calc.hxx>
+
+#include <calcconfig.hxx>
+#include "calcoptionsdlg.hxx"
+
+namespace {
+
+formula::FormulaGrammar::AddressConvention toAddressConvention(sal_Int32 nPos)
+{
+ switch (nPos)
+ {
+ case 1:
+ return formula::FormulaGrammar::CONV_OOO;
+ case 2:
+ return formula::FormulaGrammar::CONV_XL_A1;
+ case 3:
+ return formula::FormulaGrammar::CONV_XL_R1C1;
+ case 4:
+ return formula::FormulaGrammar::CONV_A1_XL_A1;
+ case 0:
+ default:
+ ;
+ }
+
+ return formula::FormulaGrammar::CONV_UNSPECIFIED;
+}
+
+sal_Int32 toSelectedItem( formula::FormulaGrammar::AddressConvention eConv )
+{
+ switch (eConv)
+ {
+ case formula::FormulaGrammar::CONV_OOO:
+ return 1;
+ case formula::FormulaGrammar::CONV_XL_A1:
+ return 2;
+ case formula::FormulaGrammar::CONV_XL_R1C1:
+ return 3;
+ case formula::FormulaGrammar::CONV_A1_XL_A1:
+ return 4;
+ default:
+ ;
+ }
+ return 0;
+}
+
+}
+
+ScCalcOptionsDialog::ScCalcOptionsDialog(weld::Window* pParent, const ScCalcConfig& rConfig, bool bWriteConfig)
+ : GenericDialogController(pParent, "modules/scalc/ui/formulacalculationoptions.ui", "FormulaCalculationOptions")
+ , maConfig(rConfig)
+ , mbSelectedEmptyStringAsZero(rConfig.mbEmptyStringAsZero)
+ , mbWriteConfig(bWriteConfig)
+ , mxEmptyAsZero(m_xBuilder->weld_check_button("checkEmptyAsZero"))
+ , mxConversion(m_xBuilder->weld_combo_box("comboConversion"))
+ , mxCurrentDocOnly(m_xBuilder->weld_check_button("current_doc"))
+ , mxSyntax(m_xBuilder->weld_combo_box("comboSyntaxRef"))
+{
+ mxConversion->set_active(static_cast<int>(rConfig.meStringConversion));
+ mxConversion->connect_changed(LINK(this, ScCalcOptionsDialog, ConversionModifiedHdl));
+ mxConversion->set_sensitive( !officecfg::Office::Calc::Formula::Syntax::StringConversion::isReadOnly() );
+
+ mxEmptyAsZero->set_active(rConfig.mbEmptyStringAsZero);
+ mxEmptyAsZero->connect_toggled(LINK(this, ScCalcOptionsDialog, AsZeroModifiedHdl));
+ CoupleEmptyAsZeroToStringConversion();
+ mxEmptyAsZero->set_sensitive ( !officecfg::Office::Calc::Formula::Syntax::EmptyStringAsZero::isReadOnly() );
+
+ mxSyntax->set_active(toSelectedItem(rConfig.meStringRefAddressSyntax));
+ mxSyntax->connect_changed(LINK(this, ScCalcOptionsDialog, SyntaxModifiedHdl));
+ mxSyntax->set_sensitive ( !officecfg::Office::Calc::Formula::Syntax::StringRefAddressSyntax::isReadOnly() );
+
+ mxCurrentDocOnly->set_active(!mbWriteConfig);
+ mxCurrentDocOnly->connect_toggled(LINK(this, ScCalcOptionsDialog, CurrentDocOnlyHdl));
+}
+
+ScCalcOptionsDialog::~ScCalcOptionsDialog()
+{
+}
+
+void ScCalcOptionsDialog::CoupleEmptyAsZeroToStringConversion()
+{
+ switch (maConfig.meStringConversion)
+ {
+ case ScCalcConfig::StringConversion::ILLEGAL:
+ maConfig.mbEmptyStringAsZero = false;
+ mxEmptyAsZero->set_active(false);
+ mxEmptyAsZero->set_sensitive(false);
+ break;
+ case ScCalcConfig::StringConversion::ZERO:
+ maConfig.mbEmptyStringAsZero = true;
+ mxEmptyAsZero->set_active(true);
+ mxEmptyAsZero->set_sensitive(false);
+ break;
+ case ScCalcConfig::StringConversion::UNAMBIGUOUS:
+ case ScCalcConfig::StringConversion::LOCALE:
+ // Reset to the value the user selected before.
+ maConfig.mbEmptyStringAsZero = mbSelectedEmptyStringAsZero;
+ mxEmptyAsZero->set_sensitive(true);
+ mxEmptyAsZero->set_active(mbSelectedEmptyStringAsZero);
+ break;
+ }
+}
+
+IMPL_LINK(ScCalcOptionsDialog, AsZeroModifiedHdl, weld::Toggleable&, rCheckBox, void )
+{
+ maConfig.mbEmptyStringAsZero = mbSelectedEmptyStringAsZero = rCheckBox.get_active();
+}
+
+IMPL_LINK(ScCalcOptionsDialog, ConversionModifiedHdl, weld::ComboBox&, rConv, void)
+{
+ maConfig.meStringConversion = static_cast<ScCalcConfig::StringConversion>(rConv.get_active());
+ CoupleEmptyAsZeroToStringConversion();
+}
+
+IMPL_LINK(ScCalcOptionsDialog, SyntaxModifiedHdl, weld::ComboBox&, rSyntax, void)
+{
+ maConfig.SetStringRefSyntax(toAddressConvention(rSyntax.get_active()));
+}
+
+IMPL_LINK(ScCalcOptionsDialog, CurrentDocOnlyHdl, weld::Toggleable&, rCheckBox, void)
+{
+ mbWriteConfig = !rCheckBox.get_active();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.hxx b/sc/source/ui/optdlg/calcoptionsdlg.hxx
new file mode 100644
index 000000000..97d7bb21c
--- /dev/null
+++ b/sc/source/ui/optdlg/calcoptionsdlg.hxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <vcl/weld.hxx>
+#include <calcconfig.hxx>
+
+class ScCalcOptionsDialog : public weld::GenericDialogController
+{
+public:
+ ScCalcOptionsDialog(weld::Window* pParent, const ScCalcConfig& rConfig, bool bWriteConfig);
+ virtual ~ScCalcOptionsDialog() override;
+
+ DECL_LINK(AsZeroModifiedHdl, weld::Toggleable&, void);
+ DECL_LINK(ConversionModifiedHdl, weld::ComboBox&, void);
+ DECL_LINK(SyntaxModifiedHdl, weld::ComboBox&, void);
+ DECL_LINK(CurrentDocOnlyHdl, weld::Toggleable&, void);
+
+ const ScCalcConfig& GetConfig() const { return maConfig; }
+ bool GetWriteCalcConfig() const { return mbWriteConfig; }
+
+private:
+ void CoupleEmptyAsZeroToStringConversion();
+
+private:
+ ScCalcConfig maConfig;
+ bool mbSelectedEmptyStringAsZero;
+ bool mbWriteConfig;
+
+ std::unique_ptr<weld::CheckButton> mxEmptyAsZero;
+ std::unique_ptr<weld::ComboBox> mxConversion;
+ std::unique_ptr<weld::CheckButton> mxCurrentDocOnly;
+ std::unique_ptr<weld::ComboBox> mxSyntax;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/opredlin.cxx b/sc/source/ui/optdlg/opredlin.cxx
new file mode 100644
index 000000000..963ea1bb3
--- /dev/null
+++ b/sc/source/ui/optdlg/opredlin.cxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#undef SC_DLLIMPLEMENTATION
+
+#include <svx/colorbox.hxx>
+
+#include <appoptio.hxx>
+#include <scmod.hxx>
+#include <docsh.hxx>
+#include <svx/svxids.hrc>
+
+#include <opredlin.hxx>
+
+ScRedlineOptionsTabPage::ScRedlineOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
+ : SfxTabPage(pPage, pController, "modules/scalc/ui/optchangespage.ui", "OptChangesPage", &rSet)
+ , m_xContentColorLB(new ColorListBox(m_xBuilder->weld_menu_button("changes"),
+ [this]{ return GetDialogController()->getDialog(); }))
+ , m_xRemoveColorLB(new ColorListBox(m_xBuilder->weld_menu_button("deletions"),
+ [this]{ return GetDialogController()->getDialog(); }))
+ , m_xInsertColorLB(new ColorListBox(m_xBuilder->weld_menu_button("entries"),
+ [this]{ return GetDialogController()->getDialog(); }))
+ , m_xMoveColorLB(new ColorListBox(m_xBuilder->weld_menu_button("insertions"),
+ [this]{ return GetDialogController()->getDialog(); }))
+{
+ m_xContentColorLB->SetSlotId(SID_AUTHOR_COLOR);
+ m_xRemoveColorLB->SetSlotId(SID_AUTHOR_COLOR);
+ m_xInsertColorLB->SetSlotId(SID_AUTHOR_COLOR);
+ m_xMoveColorLB->SetSlotId(SID_AUTHOR_COLOR);
+}
+
+ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage()
+{
+ m_xContentColorLB.reset();
+ m_xRemoveColorLB.reset();
+ m_xInsertColorLB.reset();
+ m_xMoveColorLB.reset();
+}
+
+std::unique_ptr<SfxTabPage> ScRedlineOptionsTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
+{
+ return std::make_unique<ScRedlineOptionsTabPage>( pPage, pController, *rSet );
+}
+
+bool ScRedlineOptionsTabPage::FillItemSet( SfxItemSet* /* rSet */ )
+{
+ ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
+
+ Color nNew = m_xContentColorLB->GetSelectEntryColor();
+ aAppOptions.SetTrackContentColor(nNew);
+
+ nNew = m_xMoveColorLB->GetSelectEntryColor();
+ aAppOptions.SetTrackMoveColor(nNew);
+
+ nNew = m_xInsertColorLB->GetSelectEntryColor();
+ aAppOptions.SetTrackInsertColor(nNew);
+
+ nNew = m_xRemoveColorLB->GetSelectEntryColor();
+ aAppOptions.SetTrackDeleteColor(nNew);
+
+ SC_MOD()->SetAppOptions(aAppOptions);
+
+ // repaint (if everything would be done by Items (how it should be),
+ // this wouldn't be necessary)
+ ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() );
+ if (pDocSh)
+ pDocSh->PostPaintGridAll();
+
+ return false;
+}
+
+void ScRedlineOptionsTabPage::Reset( const SfxItemSet* /* rSet */ )
+{
+ ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
+
+ Color nColor = aAppOptions.GetTrackContentColor();
+ m_xContentColorLB->SelectEntry(nColor);
+
+ nColor = aAppOptions.GetTrackMoveColor();
+ m_xMoveColorLB->SelectEntry(nColor);
+
+ nColor = aAppOptions.GetTrackInsertColor();
+ m_xInsertColorLB->SelectEntry(nColor);
+
+ nColor = aAppOptions.GetTrackDeleteColor();
+ m_xRemoveColorLB->SelectEntry(nColor);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpcalc.cxx b/sc/source/ui/optdlg/tpcalc.cxx
new file mode 100644
index 000000000..ae767043f
--- /dev/null
+++ b/sc/source/ui/optdlg/tpcalc.cxx
@@ -0,0 +1,277 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+ #undef SC_DLLIMPLEMENTATION
+
+#include <vcl/svapp.hxx>
+#include <vcl/weld.hxx>
+#include <svl/numformat.hxx>
+
+#include <globstr.hrc>
+#include <scresid.hxx>
+#include <docoptio.hxx>
+#include <sc.hrc>
+#include <officecfg/Office/Calc.hxx>
+#include <svtools/restartdialog.hxx>
+
+#include <tpcalc.hxx>
+
+ScTpCalcOptions::ScTpCalcOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs)
+ : SfxTabPage(pPage, pController, "modules/scalc/ui/optcalculatepage.ui", "OptCalculatePage", &rCoreAttrs)
+ , pOldOptions(new ScDocOptions(
+ rCoreAttrs.Get(SID_SCDOCOPTIONS).GetDocOptions()))
+ , pLocalOptions(new ScDocOptions)
+ , m_xBtnIterate(m_xBuilder->weld_check_button("iterate"))
+ , m_xFtSteps(m_xBuilder->weld_label("stepsft"))
+ , m_xEdSteps(m_xBuilder->weld_spin_button("steps"))
+ , m_xFtEps(m_xBuilder->weld_label("minchangeft"))
+ , m_xEdEps(new ScDoubleField(m_xBuilder->weld_entry("minchange")))
+ , m_xBtnDateStd(m_xBuilder->weld_radio_button("datestd"))
+ , m_xBtnDateSc10(m_xBuilder->weld_radio_button("datesc10"))
+ , m_xBtnDate1904(m_xBuilder->weld_radio_button("date1904"))
+ , m_xBtnCase(m_xBuilder->weld_check_button("case"))
+ , m_xBtnCalc(m_xBuilder->weld_check_button("calc"))
+ , m_xBtnMatch(m_xBuilder->weld_check_button("match"))
+ , m_xBtnWildcards(m_xBuilder->weld_radio_button("formulawildcards"))
+ , m_xBtnRegex(m_xBuilder->weld_radio_button("formularegex"))
+ , m_xBtnLiteral(m_xBuilder->weld_radio_button("formulaliteral"))
+ , m_xBtnLookUp(m_xBuilder->weld_check_button("lookup"))
+ , m_xBtnGeneralPrec(m_xBuilder->weld_check_button("generalprec"))
+ , m_xFtPrec(m_xBuilder->weld_label("precft"))
+ , m_xEdPrec(m_xBuilder->weld_spin_button("prec"))
+ , m_xBtnThread(m_xBuilder->weld_check_button("threadingenabled"))
+{
+ Init();
+ SetExchangeSupport();
+}
+
+ScTpCalcOptions::~ScTpCalcOptions()
+{
+}
+
+void ScTpCalcOptions::Init()
+{
+ m_xBtnIterate->connect_toggled( LINK( this, ScTpCalcOptions, CheckClickHdl ) );
+ m_xBtnGeneralPrec->connect_toggled( LINK(this, ScTpCalcOptions, CheckClickHdl) );
+ m_xBtnDateStd->connect_toggled( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
+ m_xBtnDateSc10->connect_toggled( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
+ m_xBtnDate1904->connect_toggled( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
+ m_xBtnThread->connect_toggled( LINK( this, ScTpCalcOptions, CheckClickHdl ) );
+}
+
+std::unique_ptr<SfxTabPage> ScTpCalcOptions::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
+{
+ return std::make_unique<ScTpCalcOptions>( pPage, pController, *rAttrSet );
+}
+
+void ScTpCalcOptions::Reset(const SfxItemSet* rCoreAttrs)
+{
+ sal_uInt16 d,m;
+ sal_Int16 y;
+
+ pOldOptions.reset(new ScDocOptions(
+ rCoreAttrs->Get(SID_SCDOCOPTIONS).GetDocOptions()));
+
+ *pLocalOptions = *pOldOptions;
+
+ m_xBtnCase->set_active( !pLocalOptions->IsIgnoreCase() );
+ m_xBtnCase->set_sensitive( !officecfg::Office::Calc::Calculate::Other::CaseSensitive::isReadOnly() );
+ m_xBtnCalc->set_active( pLocalOptions->IsCalcAsShown() );
+ m_xBtnCalc->set_sensitive( !officecfg::Office::Calc::Calculate::Other::Precision::isReadOnly() );
+ m_xBtnMatch->set_active( pLocalOptions->IsMatchWholeCell() );
+ m_xBtnMatch->set_sensitive( !officecfg::Office::Calc::Calculate::Other::SearchCriteria::isReadOnly() );
+ bool bWildcards = pLocalOptions->IsFormulaWildcardsEnabled();
+ bool bRegex = pLocalOptions->IsFormulaRegexEnabled();
+ // If both, Wildcards and Regex, are set then Wildcards shall take
+ // precedence. This is also how other code calling Search handles it. Both
+ // simultaneously couldn't be set using UI but editing the configuration.
+ if (bWildcards && bRegex)
+ bRegex = false;
+ m_xBtnWildcards->set_active( bWildcards );
+ m_xBtnRegex->set_active( bRegex );
+ m_xBtnWildcards->set_sensitive( !officecfg::Office::Calc::Calculate::Other::Wildcards::isReadOnly() );
+ m_xBtnRegex->set_sensitive( !officecfg::Office::Calc::Calculate::Other::RegularExpressions::isReadOnly() );
+ m_xBtnLiteral->set_active( !bWildcards && !bRegex );
+ m_xBtnLiteral->set_sensitive( m_xBtnWildcards->get_sensitive() || m_xBtnRegex->get_sensitive() );
+ // if either regex or wildcards radio button is set and read-only, disable all three
+ if ( (!m_xBtnWildcards->get_sensitive() && bWildcards) || (!m_xBtnRegex->get_sensitive() && bRegex) )
+ {
+ m_xBtnWildcards->set_sensitive( false );
+ m_xBtnRegex->set_sensitive( false );
+ m_xBtnLiteral->set_sensitive( false );
+ }
+ m_xBtnLookUp->set_active( pLocalOptions->IsLookUpColRowNames() );
+ m_xBtnLookUp->set_sensitive( !officecfg::Office::Calc::Calculate::Other::FindLabel::isReadOnly() );
+ m_xBtnIterate->set_active( pLocalOptions->IsIter() );
+ m_xEdSteps->set_value( pLocalOptions->GetIterCount() );
+ m_xEdEps->SetValue( pLocalOptions->GetIterEps(), 6 );
+
+ pLocalOptions->GetDate( d, m, y );
+
+ switch ( y )
+ {
+ case 1899:
+ m_xBtnDateStd->set_active(true);
+ break;
+ case 1900:
+ m_xBtnDateSc10->set_active(true);
+ break;
+ case 1904:
+ m_xBtnDate1904->set_active(true);
+ break;
+ }
+
+ sal_uInt16 nPrec = pLocalOptions->GetStdPrecision();
+ if (nPrec == SvNumberFormatter::UNLIMITED_PRECISION)
+ {
+ m_xFtPrec->set_sensitive(false);
+ m_xEdPrec->set_sensitive(false);
+ m_xBtnGeneralPrec->set_active(false);
+ m_xEdPrec->set_value(0);
+ }
+ else
+ {
+ m_xBtnGeneralPrec->set_active(true);
+ m_xFtPrec->set_sensitive(true);
+ m_xEdPrec->set_sensitive(true);
+ m_xEdPrec->set_value(nPrec);
+ }
+
+ m_xBtnThread->set_sensitive( !officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::isReadOnly() );
+ m_xBtnThread->set_active( officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::get() );
+
+ CheckClickHdl(*m_xBtnIterate);
+}
+
+bool ScTpCalcOptions::FillItemSet( SfxItemSet* rCoreAttrs )
+{
+ // every other options are updated in handlers
+ pLocalOptions->SetIterCount( static_cast<sal_uInt16>(m_xEdSteps->get_value()) );
+ pLocalOptions->SetIgnoreCase( !m_xBtnCase->get_active() );
+ pLocalOptions->SetCalcAsShown( m_xBtnCalc->get_active() );
+ pLocalOptions->SetMatchWholeCell( m_xBtnMatch->get_active() );
+ pLocalOptions->SetFormulaWildcardsEnabled( m_xBtnWildcards->get_active() );
+ pLocalOptions->SetFormulaRegexEnabled( m_xBtnRegex->get_active() );
+ pLocalOptions->SetLookUpColRowNames( m_xBtnLookUp->get_active() );
+
+ if (m_xBtnGeneralPrec->get_active())
+ pLocalOptions->SetStdPrecision(
+ static_cast<sal_uInt16>(m_xEdPrec->get_value()) );
+ else
+ pLocalOptions->SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION );
+
+ bool bShouldEnableThreading = m_xBtnThread->get_active();
+ if (bShouldEnableThreading != officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::get())
+ {
+ std::shared_ptr<comphelper::ConfigurationChanges> xBatch(comphelper::ConfigurationChanges::create());
+ officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::set(bShouldEnableThreading, xBatch);
+ xBatch->commit();
+ SolarMutexGuard aGuard;
+ if (svtools::executeRestartDialog(
+ comphelper::getProcessComponentContext(), GetFrameWeld(),
+ svtools::RESTART_REASON_THREADING))
+ GetDialogController()->response(RET_OK);
+ }
+ if ( *pLocalOptions != *pOldOptions )
+ {
+ rCoreAttrs->Put( ScTpCalcItem( SID_SCDOCOPTIONS, *pLocalOptions ) );
+ return true;
+ }
+ else
+ return false;
+}
+
+DeactivateRC ScTpCalcOptions::DeactivatePage( SfxItemSet* pSetP )
+{
+ DeactivateRC nReturn = DeactivateRC::KeepPage;
+
+ double fEps;
+ if( m_xEdEps->GetValue( fEps ) && (fEps > 0.0) )
+ {
+ pLocalOptions->SetIterEps( fEps );
+ nReturn = DeactivateRC::LeavePage;
+ }
+
+ if ( nReturn == DeactivateRC::KeepPage )
+ {
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning,
+ VclButtonsType::Ok, ScResId(STR_INVALID_EPS)));
+ xBox->run();
+
+ m_xEdEps->grab_focus();
+ }
+ else if ( pSetP )
+ FillItemSet( pSetP );
+
+ return nReturn;
+}
+
+// Handler:
+
+IMPL_LINK( ScTpCalcOptions, RadioClickHdl, weld::Toggleable&, rBtn, void )
+{
+ if (!rBtn.get_active())
+ return;
+ if (m_xBtnDateStd->get_active())
+ {
+ pLocalOptions->SetDate( 30, 12, 1899 );
+ }
+ else if (m_xBtnDateSc10->get_active())
+ {
+ pLocalOptions->SetDate( 1, 1, 1900 );
+ }
+ else if (m_xBtnDate1904->get_active())
+ {
+ pLocalOptions->SetDate( 1, 1, 1904 );
+ }
+}
+
+IMPL_LINK(ScTpCalcOptions, CheckClickHdl, weld::Toggleable&, rBtn, void)
+{
+ if (&rBtn == m_xBtnGeneralPrec.get())
+ {
+ if (rBtn.get_active())
+ {
+ m_xEdPrec->set_sensitive(true);
+ m_xFtPrec->set_sensitive(true);
+ }
+ else
+ {
+ m_xEdPrec->set_sensitive(false);
+ m_xFtPrec->set_sensitive(false);
+ }
+ }
+ else if (&rBtn == m_xBtnIterate.get())
+ {
+ if (rBtn.get_active())
+ {
+ pLocalOptions->SetIter( true );
+ m_xFtSteps->set_sensitive(true); m_xEdSteps->set_sensitive(true);
+ m_xFtEps->set_sensitive(true); m_xEdEps->set_sensitive(true);
+ }
+ else
+ {
+ pLocalOptions->SetIter( false );
+ m_xFtSteps->set_sensitive(false); m_xEdSteps->set_sensitive(false);
+ m_xFtEps->set_sensitive(false); m_xEdEps->set_sensitive(false);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpcompatibility.cxx b/sc/source/ui/optdlg/tpcompatibility.cxx
new file mode 100644
index 000000000..f468a68f6
--- /dev/null
+++ b/sc/source/ui/optdlg/tpcompatibility.cxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#undef SC_DLLIMPLEMENTATION
+
+#include <svl/intitem.hxx>
+
+#include <tpcompatibility.hxx>
+#include <sc.hrc>
+#include <optutil.hxx>
+
+ScTpCompatOptions::ScTpCompatOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rCoreAttrs)
+ : SfxTabPage(pPage, pController, "modules/scalc/ui/optcompatibilitypage.ui", "OptCompatibilityPage", &rCoreAttrs)
+ , m_xLbKeyBindings(m_xBuilder->weld_combo_box("keybindings"))
+{
+}
+
+ScTpCompatOptions::~ScTpCompatOptions()
+{
+}
+
+std::unique_ptr<SfxTabPage> ScTpCompatOptions::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rCoreAttrs)
+{
+ return std::make_unique<ScTpCompatOptions>(pPage, pController, *rCoreAttrs);
+}
+
+bool ScTpCompatOptions::FillItemSet(SfxItemSet *rCoreAttrs)
+{
+ bool bRet = false;
+ if (m_xLbKeyBindings->get_value_changed_from_saved())
+ {
+ rCoreAttrs->Put(
+ SfxUInt16Item(
+ SID_SC_OPT_KEY_BINDING_COMPAT, m_xLbKeyBindings->get_active()));
+ bRet = true;
+ }
+ return bRet;
+}
+
+void ScTpCompatOptions::Reset(const SfxItemSet *rCoreAttrs)
+{
+ if (const SfxUInt16Item* p16Item = rCoreAttrs->GetItemIfSet(SID_SC_OPT_KEY_BINDING_COMPAT))
+ {
+ ScOptionsUtil::KeyBindingType eKeyB =
+ static_cast<ScOptionsUtil::KeyBindingType>(p16Item->GetValue());
+
+ switch (eKeyB)
+ {
+ case ScOptionsUtil::KEY_DEFAULT:
+ m_xLbKeyBindings->set_active(0);
+ break;
+ case ScOptionsUtil::KEY_OOO_LEGACY:
+ m_xLbKeyBindings->set_active(1);
+ break;
+ default:
+ ;
+ }
+ }
+
+ m_xLbKeyBindings->save_value();
+}
+
+DeactivateRC ScTpCompatOptions::DeactivatePage(SfxItemSet* /*pSet*/)
+{
+ return DeactivateRC::KeepPage;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpdefaults.cxx b/sc/source/ui/optdlg/tpdefaults.cxx
new file mode 100644
index 000000000..7a47f3dbc
--- /dev/null
+++ b/sc/source/ui/optdlg/tpdefaults.cxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#undef SC_DLLIMPLEMENTATION
+
+#include <tpdefaults.hxx>
+#include <sc.hrc>
+#include <defaultsoptions.hxx>
+#include <document.hxx>
+#include <officecfg/Office/Common.hxx>
+#include <config_features.h>
+
+ScTpDefaultsOptions::ScTpDefaultsOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rCoreSet)
+ : SfxTabPage(pPage, pController, "modules/scalc/ui/optdefaultpage.ui", "OptDefaultPage", &rCoreSet)
+ , m_xEdNSheets(m_xBuilder->weld_spin_button("sheetsnumber"))
+ , m_xEdSheetPrefix(m_xBuilder->weld_entry("sheetprefix"))
+ , m_xEdJumboSheets(m_xBuilder->weld_check_button("jumbo_sheets"))
+{
+ m_xEdNSheets->connect_changed( LINK(this, ScTpDefaultsOptions, NumModifiedHdl) );
+ m_xEdSheetPrefix->connect_changed( LINK(this, ScTpDefaultsOptions, PrefixModifiedHdl) );
+ m_xEdSheetPrefix->connect_focus_in( LINK(this, ScTpDefaultsOptions, PrefixEditOnFocusHdl) );
+#if HAVE_FEATURE_JUMBO_SHEETS
+ if (!officecfg::Office::Common::Misc::ExperimentalMode::get())
+#endif
+ m_xEdJumboSheets->hide();
+}
+
+ScTpDefaultsOptions::~ScTpDefaultsOptions()
+{
+}
+
+std::unique_ptr<SfxTabPage> ScTpDefaultsOptions::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rCoreAttrs)
+{
+ return std::make_unique<ScTpDefaultsOptions>(pPage, pController, *rCoreAttrs);
+}
+
+bool ScTpDefaultsOptions::FillItemSet(SfxItemSet *rCoreSet)
+{
+ bool bRet = false;
+ ScDefaultsOptions aOpt;
+
+ SCTAB nTabCount = static_cast<SCTAB>(m_xEdNSheets->get_value());
+ OUString aSheetPrefix = m_xEdSheetPrefix->get_text();
+ bool bJumboSheets = m_xEdJumboSheets->get_state();
+
+ if ( m_xEdNSheets->get_value_changed_from_saved()
+ || m_xEdSheetPrefix->get_saved_value() != aSheetPrefix
+ || m_xEdJumboSheets->get_saved_state() != (bJumboSheets ? TRISTATE_TRUE : TRISTATE_FALSE) )
+ {
+ aOpt.SetInitTabCount( nTabCount );
+ aOpt.SetInitTabPrefix( aSheetPrefix );
+#if HAVE_FEATURE_JUMBO_SHEETS
+ aOpt.SetInitJumboSheets( bJumboSheets );
+#endif
+ rCoreSet->Put( ScTpDefaultsItem( aOpt ) );
+ bRet = true;
+ }
+ return bRet;
+}
+
+void ScTpDefaultsOptions::Reset(const SfxItemSet* rCoreSet)
+{
+ ScDefaultsOptions aOpt;
+
+ if(const ScTpDefaultsItem* pDefaultsItem = rCoreSet->GetItemIfSet(SID_SCDEFAULTSOPTIONS, false))
+ aOpt = pDefaultsItem->GetDefaultsOptions();
+
+ m_xEdNSheets->set_value(aOpt.GetInitTabCount());
+ m_xEdSheetPrefix->set_text( aOpt.GetInitTabPrefix() );
+ m_xEdJumboSheets->set_state( aOpt.GetInitJumboSheets() ? TRISTATE_TRUE : TRISTATE_FALSE );
+ m_xEdNSheets->save_value();
+ m_xEdSheetPrefix->save_value();
+ m_xEdJumboSheets->save_state();
+}
+
+DeactivateRC ScTpDefaultsOptions::DeactivatePage(SfxItemSet* /*pSet*/)
+{
+ return DeactivateRC::KeepPage;
+}
+
+void ScTpDefaultsOptions::CheckNumSheets()
+{
+ auto nVal = m_xEdNSheets->get_value();
+ if (nVal > MAXINITTAB)
+ m_xEdNSheets->set_value(MAXINITTAB);
+ if (nVal < MININITTAB)
+ m_xEdNSheets->set_value(MININITTAB);
+}
+
+void ScTpDefaultsOptions::CheckPrefix()
+{
+ OUString aSheetPrefix = m_xEdSheetPrefix->get_text();
+
+ if (!aSheetPrefix.isEmpty() && !ScDocument::ValidTabName(aSheetPrefix))
+ {
+ // Revert to last good Prefix and also select it to
+ // indicate something illegal was typed
+ m_xEdSheetPrefix->set_text(maOldPrefixValue);
+ m_xEdSheetPrefix->select_region(0, -1);
+ }
+ else
+ {
+ OnFocusPrefixInput();
+ }
+}
+
+void ScTpDefaultsOptions::OnFocusPrefixInput()
+{
+ // Store Prefix in case we need to revert
+ maOldPrefixValue = m_xEdSheetPrefix->get_text();
+}
+
+IMPL_LINK_NOARG(ScTpDefaultsOptions, NumModifiedHdl, weld::Entry&, void)
+{
+ CheckNumSheets();
+}
+
+IMPL_LINK_NOARG(ScTpDefaultsOptions, PrefixModifiedHdl, weld::Entry&, void)
+{
+ CheckPrefix();
+}
+
+IMPL_LINK_NOARG(ScTpDefaultsOptions, PrefixEditOnFocusHdl, weld::Widget&, void)
+{
+ OnFocusPrefixInput();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx
new file mode 100644
index 000000000..f4815d17c
--- /dev/null
+++ b/sc/source/ui/optdlg/tpformula.cxx
@@ -0,0 +1,411 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#undef SC_DLLIMPLEMENTATION
+
+#include <global.hxx>
+#include <tpformula.hxx>
+#include <formulaopt.hxx>
+#include <sc.hrc>
+#include <strings.hrc>
+#include <scresid.hxx>
+#include <formula/grammar.hxx>
+#include <officecfg/Office/Calc.hxx>
+#include "calcoptionsdlg.hxx"
+
+#include <unotools/localedatawrapper.hxx>
+
+ScTpFormulaOptions::ScTpFormulaOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs)
+ : SfxTabPage(pPage, pController, "modules/scalc/ui/optformula.ui", "OptFormula", &rCoreAttrs)
+ , mnDecSep(0)
+ , mxLbFormulaSyntax(m_xBuilder->weld_combo_box("formulasyntax"))
+ , mxCbEnglishFuncName(m_xBuilder->weld_check_button("englishfuncname"))
+ , mxBtnCustomCalcDefault(m_xBuilder->weld_radio_button("calcdefault"))
+ , mxBtnCustomCalcCustom(m_xBuilder->weld_radio_button("calccustom"))
+ , mxBtnCustomCalcDetails(m_xBuilder->weld_button("details"))
+ , mxEdSepFuncArg(m_xBuilder->weld_entry("function"))
+ , mxEdSepArrayCol(m_xBuilder->weld_entry("arraycolumn"))
+ , mxEdSepArrayRow(m_xBuilder->weld_entry("arrayrow"))
+ , mxBtnSepReset(m_xBuilder->weld_button("reset"))
+ , mxLbOOXMLRecalcOptions(m_xBuilder->weld_combo_box("ooxmlrecalc"))
+ , mxLbODFRecalcOptions(m_xBuilder->weld_combo_box("odfrecalc"))
+{
+ mxLbFormulaSyntax->append_text(ScResId(SCSTR_FORMULA_SYNTAX_CALC_A1));
+ mxLbFormulaSyntax->append_text(ScResId(SCSTR_FORMULA_SYNTAX_XL_A1));
+ mxLbFormulaSyntax->append_text(ScResId(SCSTR_FORMULA_SYNTAX_XL_R1C1));
+
+ Link<weld::Button&,void> aLink2 = LINK( this, ScTpFormulaOptions, ButtonHdl );
+ mxBtnSepReset->connect_clicked(aLink2);
+ mxBtnCustomCalcDetails->connect_clicked(aLink2);
+
+ Link<weld::Toggleable&,void> aToggleLink = LINK( this, ScTpFormulaOptions, ToggleHdl );
+ mxBtnCustomCalcDefault->connect_toggled(aToggleLink);
+ mxBtnCustomCalcCustom->connect_toggled(aToggleLink);
+
+ mxEdSepFuncArg->connect_insert_text(LINK( this, ScTpFormulaOptions, SepInsertTextHdl ));
+ mxEdSepArrayCol->connect_insert_text(LINK( this, ScTpFormulaOptions, ColSepInsertTextHdl ));
+ mxEdSepArrayRow->connect_insert_text(LINK( this, ScTpFormulaOptions, RowSepInsertTextHdl ));
+
+ Link<weld::Entry&,void> aLink = LINK( this, ScTpFormulaOptions, SepModifyHdl );
+ mxEdSepFuncArg->connect_changed(aLink);
+ mxEdSepArrayCol->connect_changed(aLink);
+ mxEdSepArrayRow->connect_changed(aLink);
+
+ Link<weld::Widget&,void> aLink3 = LINK( this, ScTpFormulaOptions, SepEditOnFocusHdl );
+ mxEdSepFuncArg->connect_focus_in(aLink3);
+ mxEdSepArrayCol->connect_focus_in(aLink3);
+ mxEdSepArrayRow->connect_focus_in(aLink3);
+
+ // Get the decimal separator for current locale.
+ OUString aSep = ScGlobal::getLocaleData().getNumDecimalSep();
+ mnDecSep = aSep.isEmpty() ? u'.' : aSep[0];
+
+ maSavedDocOptions = rCoreAttrs.Get(SID_SCDOCOPTIONS).GetDocOptions();
+}
+
+ScTpFormulaOptions::~ScTpFormulaOptions()
+{
+}
+
+void ScTpFormulaOptions::ResetSeparators()
+{
+ OUString aFuncArg, aArrayCol, aArrayRow;
+ ScFormulaOptions::GetDefaultFormulaSeparators(aFuncArg, aArrayCol, aArrayRow);
+ mxEdSepFuncArg->set_text(aFuncArg);
+ mxEdSepArrayCol->set_text(aArrayCol);
+ mxEdSepArrayRow->set_text(aArrayRow);
+}
+
+void ScTpFormulaOptions::OnFocusSeparatorInput(weld::Entry* pEdit)
+{
+ if (!pEdit)
+ return;
+
+ // Make sure the entire text is selected.
+ pEdit->select_region(0, -1);
+ OUString sSepValue = pEdit->get_text();
+ if (!sSepValue.isEmpty())
+ maOldSepValue = sSepValue;
+}
+
+void ScTpFormulaOptions::UpdateCustomCalcRadioButtons(bool bDefault)
+{
+ if (bDefault)
+ {
+ mxBtnCustomCalcDefault->set_active(true);
+ mxBtnCustomCalcCustom->set_active(false);
+ mxBtnCustomCalcDetails->set_sensitive(false);
+ }
+ else
+ {
+ mxBtnCustomCalcDefault->set_active(false);
+ mxBtnCustomCalcCustom->set_active(true);
+ mxBtnCustomCalcDetails->set_sensitive(true);
+ }
+}
+
+void ScTpFormulaOptions::LaunchCustomCalcSettings()
+{
+ ScCalcOptionsDialog aDlg(GetFrameWeld(), maCurrentConfig, maCurrentDocOptions.IsWriteCalcConfig());
+ if (aDlg.run() == RET_OK)
+ {
+ maCurrentConfig = aDlg.GetConfig();
+ maCurrentDocOptions.SetWriteCalcConfig(aDlg.GetWriteCalcConfig());
+ }
+}
+
+bool ScTpFormulaOptions::IsValidSeparator(const OUString& rSep, bool bArray) const
+{
+ if (rSep.getLength() != 1)
+ // Must be one-character long.
+ return false;
+
+ const sal_Unicode c = rSep[0];
+
+ if (c == mnDecSep)
+ // decimal separator is not allowed.
+ return false;
+
+ if (c <= 0x20 || c == 0x7f)
+ // Disallow non-printables including space and DEL.
+ return false;
+
+ if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9'))
+ // Disallow alphanumeric.
+ return false;
+
+ if (bArray)
+ {
+ switch (c)
+ {
+ case '+':
+ case '-':
+ case '{':
+ case '}':
+ case '"':
+ // All following just to prevent confusion, they are not
+ // evaluated in inline arrays and theoretically would be
+ // possible.
+ case '%':
+ case '/':
+ case '*':
+ case '=':
+ case '<':
+ case '>':
+ case '[':
+ case ']':
+ case '(':
+ case ')':
+ case '\'':
+ // Disallowed characters. Anything else we want to disallow ?
+ return false;
+ }
+ }
+ else if (c <= 0x7f)
+ {
+ switch (c)
+ {
+ default:
+ // Anything bad except the knowns.
+ return false;
+ case ';':
+ case ',':
+ ; // nothing
+ }
+ }
+ else
+ {
+ // Any Unicode character, would have to ask the compiler's localized
+ // symbol map whether it's a known symbol but not a separator
+ // (ocSep,ocArrayRowSep,ocArrayColSep), which we're about to set here.
+ // But really..
+ return false;
+ }
+
+ return true;
+}
+
+IMPL_LINK( ScTpFormulaOptions, ButtonHdl, weld::Button&, rBtn, void )
+{
+ if (&rBtn == mxBtnSepReset.get())
+ ResetSeparators();
+ else if (&rBtn == mxBtnCustomCalcDetails.get())
+ LaunchCustomCalcSettings();
+}
+
+IMPL_LINK( ScTpFormulaOptions, ToggleHdl, weld::Toggleable&, rBtn, void )
+{
+ if (!rBtn.get_active())
+ return;
+ if (mxBtnCustomCalcDefault->get_active())
+ UpdateCustomCalcRadioButtons(true);
+ else if (mxBtnCustomCalcCustom->get_active())
+ UpdateCustomCalcRadioButtons(false);
+}
+
+IMPL_LINK(ScTpFormulaOptions, SepInsertTextHdl, OUString&, rTest, bool)
+{
+ if (!IsValidSeparator(rTest, false) && !maOldSepValue.isEmpty())
+ // Invalid separator. Restore the old value.
+ rTest = maOldSepValue;
+ return true;
+}
+
+IMPL_LINK(ScTpFormulaOptions, RowSepInsertTextHdl, OUString&, rTest, bool)
+{
+ // Invalid separator or same as ColStr - Restore the old value.
+ if ((!IsValidSeparator(rTest, true) || rTest == mxEdSepArrayCol->get_text()) && !maOldSepValue.isEmpty())
+ rTest = maOldSepValue;
+ return true;
+}
+
+IMPL_LINK(ScTpFormulaOptions, ColSepInsertTextHdl, OUString&, rTest, bool)
+{
+ // Invalid separator or same as RowStr - Restore the old value.
+ if ((!IsValidSeparator(rTest, true) || rTest == mxEdSepArrayRow->get_text()) && !maOldSepValue.isEmpty())
+ rTest = maOldSepValue;
+ return true;
+}
+
+IMPL_LINK( ScTpFormulaOptions, SepModifyHdl, weld::Entry&, rEdit, void )
+{
+ OnFocusSeparatorInput(&rEdit);
+}
+
+IMPL_LINK( ScTpFormulaOptions, SepEditOnFocusHdl, weld::Widget&, rControl, void )
+{
+ OnFocusSeparatorInput(dynamic_cast<weld::Entry*>(&rControl));
+}
+
+std::unique_ptr<SfxTabPage> ScTpFormulaOptions::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreSet)
+{
+ return std::make_unique<ScTpFormulaOptions>(pPage, pController, *rCoreSet);
+}
+
+bool ScTpFormulaOptions::FillItemSet(SfxItemSet* rCoreSet)
+{
+ bool bRet = false;
+ ScFormulaOptions aOpt;
+ bool bEnglishFuncName = mxCbEnglishFuncName->get_active();
+ sal_Int16 aSyntaxPos = mxLbFormulaSyntax->get_active();
+ OUString aSep = mxEdSepFuncArg->get_text();
+ OUString aSepArrayCol = mxEdSepArrayCol->get_text();
+ OUString aSepArrayRow = mxEdSepArrayRow->get_text();
+ sal_Int16 nOOXMLRecalcMode = mxLbOOXMLRecalcOptions->get_active();
+ sal_Int16 nODFRecalcMode = mxLbODFRecalcOptions->get_active();
+
+ if (mxBtnCustomCalcDefault->get_active())
+ {
+ // When Default is selected, reset all the calc config settings to default.
+ maCurrentConfig.reset();
+ }
+
+ if ( mxLbFormulaSyntax->get_saved_value() != mxLbFormulaSyntax->get_text(aSyntaxPos)
+ || mxCbEnglishFuncName->get_saved_state() != (bEnglishFuncName ? 1 : 0)
+ || mxEdSepFuncArg->get_saved_value() != aSep
+ || mxEdSepArrayCol->get_saved_value() != aSepArrayCol
+ || mxEdSepArrayRow->get_saved_value() != aSepArrayRow
+ || mxLbOOXMLRecalcOptions->get_saved_value() != mxLbOOXMLRecalcOptions->get_text(nOOXMLRecalcMode)
+ || mxLbODFRecalcOptions->get_saved_value() != mxLbODFRecalcOptions->get_text(nODFRecalcMode)
+ || maSavedConfig != maCurrentConfig
+ || maSavedDocOptions != maCurrentDocOptions )
+ {
+ ::formula::FormulaGrammar::Grammar eGram = ::formula::FormulaGrammar::GRAM_DEFAULT;
+
+ switch (aSyntaxPos)
+ {
+ case 0:
+ eGram = ::formula::FormulaGrammar::GRAM_NATIVE;
+ break;
+ case 1:
+ eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1;
+ break;
+ case 2:
+ eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
+ break;
+ }
+
+ ScRecalcOptions eOOXMLRecalc = static_cast<ScRecalcOptions>(nOOXMLRecalcMode);
+ ScRecalcOptions eODFRecalc = static_cast<ScRecalcOptions>(nODFRecalcMode);
+
+ aOpt.SetFormulaSyntax(eGram);
+ aOpt.SetUseEnglishFuncName(bEnglishFuncName);
+ aOpt.SetFormulaSepArg(aSep);
+ aOpt.SetFormulaSepArrayCol(aSepArrayCol);
+ aOpt.SetFormulaSepArrayRow(aSepArrayRow);
+ aOpt.SetCalcConfig(maCurrentConfig);
+ aOpt.SetOOXMLRecalcOptions(eOOXMLRecalc);
+ aOpt.SetODFRecalcOptions(eODFRecalc);
+ aOpt.SetWriteCalcConfig( maCurrentDocOptions.IsWriteCalcConfig());
+
+ rCoreSet->Put( ScTpFormulaItem( aOpt ) );
+ rCoreSet->Put( ScTpCalcItem( SID_SCDOCOPTIONS, maCurrentDocOptions ) );
+
+ bRet = true;
+ }
+ return bRet;
+}
+
+void ScTpFormulaOptions::Reset(const SfxItemSet* rCoreSet)
+{
+ ScFormulaOptions aOpt;
+ if(const ScTpFormulaItem* pItem = rCoreSet->GetItemIfSet(SID_SCFORMULAOPTIONS, false))
+ aOpt = pItem->GetFormulaOptions();
+
+ // formula grammar.
+ ::formula::FormulaGrammar::Grammar eGram = aOpt.GetFormulaSyntax();
+
+ switch (eGram)
+ {
+ case ::formula::FormulaGrammar::GRAM_NATIVE:
+ mxLbFormulaSyntax->set_active(0);
+ break;
+ case ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1:
+ mxLbFormulaSyntax->set_active(1);
+ break;
+ case ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1:
+ mxLbFormulaSyntax->set_active(2);
+ break;
+ default:
+ mxLbFormulaSyntax->set_active(0);
+ }
+
+ mxLbFormulaSyntax->save_value();
+ mxLbFormulaSyntax->set_sensitive( !officecfg::Office::Calc::Formula::Syntax::Grammar::isReadOnly() );
+
+ ScRecalcOptions eOOXMLRecalc = aOpt.GetOOXMLRecalcOptions();
+ mxLbOOXMLRecalcOptions->set_active(static_cast<sal_uInt16>(eOOXMLRecalc));
+ mxLbOOXMLRecalcOptions->save_value();
+ mxLbOOXMLRecalcOptions->set_sensitive( !officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::isReadOnly() );
+
+ ScRecalcOptions eODFRecalc = aOpt.GetODFRecalcOptions();
+ mxLbODFRecalcOptions->set_active(static_cast<sal_uInt16>(eODFRecalc));
+ mxLbODFRecalcOptions->save_value();
+ mxLbODFRecalcOptions->set_sensitive( !officecfg::Office::Calc::Formula::Load::ODFRecalcMode::isReadOnly() );
+
+ // english function name.
+ mxCbEnglishFuncName->set_active( aOpt.GetUseEnglishFuncName() );
+ mxCbEnglishFuncName->save_state();
+ mxCbEnglishFuncName->set_sensitive( !officecfg::Office::Calc::Formula::Syntax::EnglishFunctionName::isReadOnly() );
+
+ // Separators
+ OUString aSep = aOpt.GetFormulaSepArg();
+ OUString aSepArrayRow = aOpt.GetFormulaSepArrayRow();
+ OUString aSepArrayCol = aOpt.GetFormulaSepArrayCol();
+
+ if (IsValidSeparator(aSep, false) && IsValidSeparator(aSepArrayRow, true) && IsValidSeparator(aSepArrayCol, true))
+ {
+ // Each and all separators must be valid.
+ mxEdSepFuncArg->set_text(aSep);
+ mxEdSepArrayCol->set_text(aSepArrayCol);
+ mxEdSepArrayRow->set_text(aSepArrayRow);
+
+ mxEdSepFuncArg->save_value();
+ mxEdSepArrayCol->save_value();
+ mxEdSepArrayRow->save_value();
+ }
+ else
+ ResetSeparators();
+
+ mxEdSepFuncArg->set_sensitive( !officecfg::Office::Calc::Formula::Syntax::SeparatorArg::isReadOnly() );
+ mxEdSepArrayCol->set_sensitive( !officecfg::Office::Calc::Formula::Syntax::SeparatorArrayCol::isReadOnly() );
+ mxEdSepArrayRow->set_sensitive( !officecfg::Office::Calc::Formula::Syntax::SeparatorArrayRow::isReadOnly() );
+ mxBtnSepReset->set_sensitive ( !officecfg::Office::Calc::Formula::Syntax::SeparatorArg::isReadOnly() &&
+ !officecfg::Office::Calc::Formula::Syntax::SeparatorArrayCol::isReadOnly() &&
+ !officecfg::Office::Calc::Formula::Syntax::SeparatorArrayRow::isReadOnly() );
+
+ // detailed calc settings.
+ ScFormulaOptions aDefaults;
+
+ maSavedConfig = aOpt.GetCalcConfig();
+ bool bDefault = aDefaults.GetCalcConfig() == maSavedConfig;
+ UpdateCustomCalcRadioButtons(bDefault);
+
+ maCurrentConfig = maSavedConfig;
+
+ maCurrentDocOptions = maSavedDocOptions;
+}
+
+DeactivateRC ScTpFormulaOptions::DeactivatePage(SfxItemSet* /*pSet*/)
+{
+ // What's this method for ?
+ return DeactivateRC::KeepPage;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpprint.cxx b/sc/source/ui/optdlg/tpprint.cxx
new file mode 100644
index 000000000..c257f6f3d
--- /dev/null
+++ b/sc/source/ui/optdlg/tpprint.cxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#undef SC_DLLIMPLEMENTATION
+
+#include <svl/eitem.hxx>
+
+#include <tpprint.hxx>
+#include <printopt.hxx>
+#include <scmod.hxx>
+#include <sc.hrc>
+
+ScTpPrintOptions::ScTpPrintOptions( weld::Container* pPage, weld::DialogController* pController,
+ const SfxItemSet& rCoreAttrs )
+ : SfxTabPage(pPage, pController, "modules/scalc/ui/optdlg.ui", "optCalcPrintPage", &rCoreAttrs )
+ , m_xSkipEmptyPagesCB(m_xBuilder->weld_check_button("suppressCB"))
+ , m_xSelectedSheetsCB(m_xBuilder->weld_check_button("printCB"))
+ , m_xForceBreaksCB(m_xBuilder->weld_check_button("forceBreaksCB"))
+{
+}
+
+ScTpPrintOptions::~ScTpPrintOptions()
+{
+}
+
+std::unique_ptr<SfxTabPage> ScTpPrintOptions::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet)
+{
+ return std::make_unique<ScTpPrintOptions>(pPage, pController, *rAttrSet);
+}
+
+DeactivateRC ScTpPrintOptions::DeactivatePage( SfxItemSet* pSetP )
+{
+ if ( pSetP )
+ FillItemSet( pSetP );
+
+ return DeactivateRC::LeavePage;
+}
+
+void ScTpPrintOptions::Reset( const SfxItemSet* rCoreSet )
+{
+ ScPrintOptions aOptions;
+
+ if(const ScTpPrintItem* pItem = rCoreSet->GetItemIfSet(SID_SCPRINTOPTIONS, false))
+ aOptions = pItem->GetPrintOptions();
+ else
+ {
+ // when called from print dialog and no options set, use configuration
+ aOptions = SC_MOD()->GetPrintOptions();
+ }
+
+ if ( const SfxBoolItem* pItem = rCoreSet->GetItemIfSet( SID_PRINT_SELECTEDSHEET, false))
+ {
+ bool bChecked = pItem->GetValue();
+ m_xSelectedSheetsCB->set_active( bChecked );
+ }
+ else
+ {
+ m_xSelectedSheetsCB->set_active( !aOptions.GetAllSheets() );
+ }
+
+ m_xSkipEmptyPagesCB->set_active( aOptions.GetSkipEmpty() );
+ m_xSkipEmptyPagesCB->save_state();
+ m_xSelectedSheetsCB->save_state();
+ m_xForceBreaksCB->set_active( aOptions.GetForceBreaks() );
+ m_xForceBreaksCB->save_state();
+}
+
+bool ScTpPrintOptions::FillItemSet( SfxItemSet* rCoreAttrs )
+{
+ rCoreAttrs->ClearItem( SID_PRINT_SELECTEDSHEET );
+
+ bool bSkipEmptyChanged = m_xSkipEmptyPagesCB->get_state_changed_from_saved();
+ bool bSelectedSheetsChanged = m_xSelectedSheetsCB->get_state_changed_from_saved();
+ bool bForceBreaksChanged = m_xForceBreaksCB->get_state_changed_from_saved();
+
+ if ( bSkipEmptyChanged || bSelectedSheetsChanged || bForceBreaksChanged )
+ {
+ ScPrintOptions aOpt;
+ aOpt.SetSkipEmpty( m_xSkipEmptyPagesCB->get_active() );
+ aOpt.SetAllSheets( !m_xSelectedSheetsCB->get_active() );
+ aOpt.SetForceBreaks( m_xForceBreaksCB->get_active() );
+ rCoreAttrs->Put( ScTpPrintItem( aOpt ) );
+ if ( bSelectedSheetsChanged )
+ {
+ rCoreAttrs->Put( SfxBoolItem( SID_PRINT_SELECTEDSHEET, m_xSelectedSheetsCB->get_active() ) );
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpusrlst.cxx b/sc/source/ui/optdlg/tpusrlst.cxx
new file mode 100644
index 000000000..6553d64de
--- /dev/null
+++ b/sc/source/ui/optdlg/tpusrlst.cxx
@@ -0,0 +1,738 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#undef SC_DLLIMPLEMENTATION
+
+#include <comphelper/string.hxx>
+#include <tools/lineend.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/weld.hxx>
+#include <osl/diagnose.h>
+#include <o3tl/string_view.hxx>
+
+#include <document.hxx>
+#include <tabvwsh.hxx>
+#include <viewdata.hxx>
+#include <uiitems.hxx>
+#include <userlist.hxx>
+#include <rangeutl.hxx>
+#include <crdlg.hxx>
+#include <sc.hrc>
+#include <globstr.hrc>
+#include <scresid.hxx>
+#include <tpusrlst.hxx>
+#include <scui_def.hxx>
+
+#define CR u'\x000D'
+#define LF u'\x000A'
+
+const sal_Unicode cDelimiter = ',';
+
+// Benutzerdefinierte Listen:
+
+ScTpUserLists::ScTpUserLists( weld::Container* pPage, weld::DialogController* pController,
+ const SfxItemSet& rCoreAttrs )
+ : SfxTabPage(pPage, pController, "modules/scalc/ui/optsortlists.ui", "OptSortLists",
+ &rCoreAttrs )
+ , mxFtLists(m_xBuilder->weld_label("listslabel"))
+ , mxLbLists(m_xBuilder->weld_tree_view("lists"))
+ , mxFtEntries(m_xBuilder->weld_label("entrieslabel"))
+ , mxEdEntries(m_xBuilder->weld_text_view("entries"))
+ , mxFtCopyFrom(m_xBuilder->weld_label("copyfromlabel"))
+ , mxEdCopyFrom(m_xBuilder->weld_entry("copyfrom"))
+ , mxBtnNew(m_xBuilder->weld_button("new"))
+ , mxBtnDiscard(m_xBuilder->weld_button("discard"))
+ , mxBtnAdd(m_xBuilder->weld_button("add"))
+ , mxBtnModify(m_xBuilder->weld_button("modify"))
+ , mxBtnRemove(m_xBuilder->weld_button("delete"))
+ , mxBtnCopy(m_xBuilder->weld_button("copy"))
+ , aStrQueryRemove ( ScResId( STR_QUERYREMOVE ) )
+ , aStrCopyList ( ScResId( STR_COPYLIST ) )
+ , aStrCopyFrom ( ScResId( STR_COPYFROM ) )
+ , aStrCopyErr ( ScResId( STR_COPYERR ) )
+ , nWhichUserLists ( GetWhich( SID_SCUSERLISTS ) )
+ , pDoc ( nullptr )
+ , pViewData ( nullptr )
+ , bModifyMode ( false )
+ , bCancelMode ( false )
+ , bCopyDone ( false )
+ , nCancelPos ( 0 )
+{
+ SetExchangeSupport();
+ Init();
+ Reset(&rCoreAttrs);
+}
+
+ScTpUserLists::~ScTpUserLists()
+{
+}
+
+void ScTpUserLists::Init()
+{
+ SfxViewShell* pSh = SfxViewShell::Current();
+ ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( pSh );
+
+ mxLbLists->connect_changed ( LINK( this, ScTpUserLists, LbSelectHdl ) );
+ mxBtnNew->connect_clicked ( LINK( this, ScTpUserLists, BtnClickHdl ) );
+ mxBtnDiscard->connect_clicked ( LINK( this, ScTpUserLists, BtnClickHdl ) );
+ mxBtnAdd->connect_clicked ( LINK( this, ScTpUserLists, BtnClickHdl ) );
+ mxBtnModify->connect_clicked ( LINK( this, ScTpUserLists, BtnClickHdl ) );
+ mxBtnRemove->connect_clicked ( LINK( this, ScTpUserLists, BtnClickHdl ) );
+ mxEdEntries->connect_changed ( LINK( this, ScTpUserLists, EdEntriesModHdl ) );
+
+ if ( pViewSh )
+ {
+ SCTAB nStartTab = 0;
+ SCTAB nEndTab = 0;
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+
+ pViewData = &pViewSh->GetViewData();
+ pDoc = &pViewData->GetDocument();
+
+ pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab );
+
+ PutInOrder( nStartCol, nEndCol );
+ PutInOrder( nStartRow, nEndRow );
+ PutInOrder( nStartTab, nEndTab );
+
+ aStrSelectedArea = ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab
+ ).Format(*pDoc, ScRefFlags::RANGE_ABS_3D);
+
+ mxBtnCopy->connect_clicked ( LINK( this, ScTpUserLists, BtnClickHdl ) );
+ mxBtnCopy->set_sensitive(true);
+ }
+ else
+ {
+ mxBtnCopy->set_sensitive(false);
+ mxFtCopyFrom->set_sensitive(false);
+ mxEdCopyFrom->set_sensitive(false);
+ }
+
+}
+
+std::unique_ptr<SfxTabPage> ScTpUserLists::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
+{
+ return std::make_unique<ScTpUserLists>(pPage, pController, *rAttrSet);
+}
+
+void ScTpUserLists::Reset( const SfxItemSet* rCoreAttrs )
+{
+ const ScUserListItem& rUserListItem = static_cast<const ScUserListItem&>(
+ rCoreAttrs->Get( nWhichUserLists ));
+ const ScUserList* pCoreList = rUserListItem.GetUserList();
+
+ OSL_ENSURE( pCoreList, "UserList not found :-/" );
+
+ if ( pCoreList )
+ {
+ if ( !pUserLists )
+ pUserLists.reset( new ScUserList( *pCoreList ) );
+ else
+ *pUserLists = *pCoreList;
+
+ if ( UpdateUserListBox() > 0 )
+ {
+ mxLbLists->select( 0 );
+ UpdateEntries( 0 );
+ }
+ }
+ else if ( !pUserLists )
+ pUserLists.reset( new ScUserList );
+
+ mxEdCopyFrom->set_text( aStrSelectedArea );
+
+ if ( mxLbLists->n_children() == 0 )
+ {
+ mxFtLists->set_sensitive(false);
+ mxLbLists->set_sensitive(false);
+ mxFtEntries->set_sensitive(false);
+ mxEdEntries->set_sensitive(false);
+ mxBtnRemove->set_sensitive(false);
+ }
+
+ mxBtnNew->show();
+ mxBtnDiscard->hide();
+ mxBtnAdd->show();
+ mxBtnModify->hide();
+ mxBtnAdd->set_sensitive(false);
+ mxBtnModify->set_sensitive(false);
+
+ if ( !bCopyDone && pViewData )
+ {
+ mxFtCopyFrom->set_sensitive(true);
+ mxEdCopyFrom->set_sensitive(true);
+ mxBtnCopy->set_sensitive(true);
+ }
+}
+
+bool ScTpUserLists::FillItemSet( SfxItemSet* rCoreAttrs )
+{
+ // Changes aren't saved?
+ // -> simulate click of Add-Button
+
+ if ( bModifyMode || bCancelMode )
+ BtnClickHdl(*mxBtnAdd);
+
+ const ScUserListItem& rUserListItem = static_cast<const ScUserListItem&>(
+ GetItemSet().Get( nWhichUserLists ));
+
+ ScUserList* pCoreList = rUserListItem.GetUserList();
+ bool bDataModified = false;
+
+ if ( (pUserLists == nullptr) && (pCoreList == nullptr) )
+ {
+ bDataModified = false;
+ }
+ else if ( pUserLists != nullptr )
+ {
+ if ( pCoreList != nullptr )
+ bDataModified = (*pUserLists != *pCoreList);
+ else
+ bDataModified = true;
+ }
+
+ if ( bDataModified )
+ {
+ ScUserListItem aULItem( nWhichUserLists );
+
+ if ( pUserLists )
+ aULItem.SetUserList( *pUserLists );
+
+ rCoreAttrs->Put( aULItem );
+ }
+
+ return bDataModified;
+}
+
+DeactivateRC ScTpUserLists::DeactivatePage( SfxItemSet* pSetP )
+{
+ if ( pSetP )
+ FillItemSet( pSetP );
+
+ return DeactivateRC::LeavePage;
+}
+
+size_t ScTpUserLists::UpdateUserListBox()
+{
+ mxLbLists->clear();
+
+ if ( !pUserLists ) return 0;
+
+ size_t nCount = pUserLists->size();
+ OUString aEntry;
+
+ for ( size_t i=0; i<nCount; ++i )
+ {
+ aEntry = (*pUserLists)[i].GetString();
+ OSL_ENSURE( !aEntry.isEmpty(), "Empty UserList-entry :-/" );
+ mxLbLists->append_text( aEntry );
+ }
+
+ return nCount;
+}
+
+void ScTpUserLists::UpdateEntries( size_t nList )
+{
+ if ( !pUserLists ) return;
+
+ if ( nList < pUserLists->size() )
+ {
+ const ScUserListData& rList = (*pUserLists)[nList];
+ std::size_t nSubCount = rList.GetSubCount();
+ OUStringBuffer aEntryListStr;
+
+ for ( size_t i=0; i<nSubCount; i++ )
+ {
+ if ( i!=0 )
+ aEntryListStr.append(CR);
+ aEntryListStr.append(rList.GetSubStr(i));
+ }
+
+ mxEdEntries->set_text(convertLineEnd(aEntryListStr.makeStringAndClear(), GetSystemLineEnd()));
+ }
+ else
+ {
+ OSL_FAIL( "Invalid ListIndex :-/" );
+ }
+}
+
+void ScTpUserLists::MakeListStr( OUString& rListStr )
+{
+ if (rListStr.isEmpty())
+ return;
+
+ OUStringBuffer aStr;
+
+ for(sal_Int32 nIdx=0; nIdx>=0;)
+ {
+ aStr.append(comphelper::string::strip(o3tl::getToken(rListStr, 0, LF, nIdx), ' '));
+ aStr.append(cDelimiter);
+ }
+
+ aStr.strip(cDelimiter);
+ sal_Int32 nLen = aStr.getLength();
+
+ rListStr.clear();
+
+ // delete all duplicates of cDelimiter
+ sal_Int32 c = 0;
+ while ( c < nLen )
+ {
+ rListStr += OUStringChar(aStr[c]);
+ ++c;
+
+ if ((c < nLen) && (aStr[c] == cDelimiter))
+ {
+ rListStr += OUStringChar(aStr[c]);
+
+ while ((c < nLen) && (aStr[c] == cDelimiter))
+ ++c;
+ }
+ }
+
+}
+
+void ScTpUserLists::AddNewList( const OUString& rEntriesStr )
+{
+ OUString theEntriesStr( rEntriesStr );
+
+ if ( !pUserLists )
+ pUserLists.reset( new ScUserList );
+
+ MakeListStr( theEntriesStr );
+
+ pUserLists->push_back(new ScUserListData(theEntriesStr));
+}
+
+void ScTpUserLists::CopyListFromArea( const ScRefAddress& rStartPos,
+ const ScRefAddress& rEndPos )
+{
+ if ( bCopyDone ) return;
+
+ SCTAB nTab = rStartPos.Tab();
+ SCCOL nStartCol = rStartPos.Col();
+ SCROW nStartRow = rStartPos.Row();
+ SCCOL nEndCol = rEndPos.Col();
+ SCROW nEndRow = rEndPos.Row();
+ sal_uInt16 nCellDir = SCRET_COLS;
+
+ if ( (nStartCol != nEndCol) && (nStartRow != nEndRow) )
+ {
+ ScColOrRowDlg aDialog(GetFrameWeld(), aStrCopyList, aStrCopyFrom);
+ nCellDir = aDialog.run();
+ }
+ else if ( nStartCol != nEndCol )
+ nCellDir = SCRET_ROWS;
+ else
+ nCellDir = SCRET_COLS;
+
+ if ( nCellDir != RET_CANCEL )
+ {
+ bool bValueIgnored = false;
+
+ if ( nCellDir == SCRET_COLS )
+ {
+ for ( SCCOL col=nStartCol; col<=nEndCol; col++ )
+ {
+ OUStringBuffer aStrList;
+ for ( SCROW row=nStartRow; row<=nEndRow; row++ )
+ {
+ if ( pDoc->HasStringData( col, row, nTab ) )
+ {
+ OUString aStrField = pDoc->GetString(col, row, nTab);
+
+ if ( !aStrField.isEmpty() )
+ {
+ aStrList.append(aStrField + "\n");
+ }
+ }
+ else
+ bValueIgnored = true;
+ }
+ if ( !aStrList.isEmpty() )
+ AddNewList( aStrList.makeStringAndClear() );
+ }
+ }
+ else
+ {
+ for ( SCROW row=nStartRow; row<=nEndRow; row++ )
+ {
+ OUStringBuffer aStrList;
+ for ( SCCOL col=nStartCol; col<=nEndCol; col++ )
+ {
+ if ( pDoc->HasStringData( col, row, nTab ) )
+ {
+ OUString aStrField = pDoc->GetString(col, row, nTab);
+
+ if ( !aStrField.isEmpty() )
+ {
+ aStrList.append(aStrField + "\n");
+ }
+ }
+ else
+ bValueIgnored = true;
+ }
+ if ( !aStrList.isEmpty() )
+ AddNewList( aStrList.makeStringAndClear() );
+ }
+ }
+
+ if ( bValueIgnored )
+ {
+ std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
+ VclMessageType::Info, VclButtonsType::Ok,
+ aStrCopyErr));
+ xInfoBox->run();
+ }
+ }
+
+ bCopyDone = true;
+
+}
+
+void ScTpUserLists::ModifyList( size_t nSelList,
+ const OUString& rEntriesStr )
+{
+ if ( !pUserLists ) return;
+
+ OUString theEntriesStr( rEntriesStr );
+
+ MakeListStr( theEntriesStr );
+
+ (*pUserLists)[nSelList].SetString( theEntriesStr );
+}
+
+void ScTpUserLists::RemoveList( size_t nList )
+{
+ if (pUserLists && nList < pUserLists->size())
+ {
+ ScUserList::iterator itr = pUserLists->begin();
+ ::std::advance(itr, nList);
+ pUserLists->erase(itr);
+ }
+}
+
+// Handler:
+
+IMPL_LINK( ScTpUserLists, LbSelectHdl, weld::TreeView&, rLb, void )
+{
+ if ( &rLb != mxLbLists.get() )
+ return;
+
+ sal_Int32 nSelPos = mxLbLists->get_selected_index();
+ if ( nSelPos == -1 )
+ return;
+
+ if ( !mxFtEntries->get_sensitive() ) mxFtEntries->set_sensitive(true);
+ if ( !mxEdEntries->get_sensitive() ) mxEdEntries->set_sensitive(true);
+ if ( !mxBtnRemove->get_sensitive() ) mxBtnRemove->set_sensitive(true);
+ if ( mxBtnAdd->get_sensitive() )
+ {
+ mxBtnAdd->set_sensitive(false);
+ mxBtnModify->set_sensitive(false);
+ }
+
+ UpdateEntries( nSelPos );
+}
+
+IMPL_LINK( ScTpUserLists, BtnClickHdl, weld::Button&, rBtn, void )
+{
+ if (&rBtn == mxBtnNew.get() || &rBtn == mxBtnDiscard.get())
+ {
+ if ( !bCancelMode )
+ {
+ nCancelPos = ( mxLbLists->n_children() > 0 )
+ ? mxLbLists->get_selected_index()
+ : 0;
+ mxLbLists->unselect_all();
+ mxFtLists->set_sensitive(false);
+ mxLbLists->set_sensitive(false);
+ mxFtEntries->set_sensitive(true);
+ mxEdEntries->set_sensitive(true);
+ mxEdEntries->set_text( OUString() );
+ mxEdEntries->grab_focus();
+ mxBtnAdd->set_sensitive(false);
+ mxBtnModify->set_sensitive(false);
+ mxBtnRemove->set_sensitive(false);
+
+ if ( mxBtnCopy->get_sensitive() )
+ {
+ mxBtnCopy->set_sensitive(false);
+ mxFtCopyFrom->set_sensitive(false);
+ mxEdCopyFrom->set_sensitive(false);
+ }
+ mxBtnNew->hide();
+ mxBtnDiscard->show();
+ bCancelMode = true;
+ }
+ else // if ( bCancelMode )
+ {
+ if ( mxLbLists->n_children() > 0 )
+ {
+ mxLbLists->select( nCancelPos );
+ LbSelectHdl( *mxLbLists );
+ mxFtLists->set_sensitive(true);
+ mxLbLists->set_sensitive(true);
+ }
+ else
+ {
+ mxFtEntries->set_sensitive(false);
+ mxEdEntries->set_sensitive(false);
+ mxEdEntries->set_text( OUString() );
+ mxBtnRemove->set_sensitive(false);
+ }
+ mxBtnAdd->set_sensitive(false);
+ mxBtnModify->set_sensitive(false);
+
+ if ( pViewData && !bCopyDone )
+ {
+ mxBtnCopy->set_sensitive(true);
+ mxFtCopyFrom->set_sensitive(true);
+ mxEdCopyFrom->set_sensitive(true);
+ }
+ mxBtnNew->show();
+ mxBtnDiscard->hide();
+ bCancelMode = false;
+ bModifyMode = false;
+ }
+ }
+ else if (&rBtn == mxBtnAdd.get() || &rBtn == mxBtnModify.get())
+ {
+ OUString theEntriesStr( mxEdEntries->get_text() );
+
+ if ( !bModifyMode )
+ {
+ if ( !theEntriesStr.isEmpty() )
+ {
+ AddNewList( theEntriesStr );
+ UpdateUserListBox();
+ mxLbLists->select( mxLbLists->n_children()-1 );
+ LbSelectHdl( *mxLbLists );
+ mxFtLists->set_sensitive(true);
+ mxLbLists->set_sensitive(true);
+ }
+ else
+ {
+ if ( mxLbLists->n_children() > 0 )
+ {
+ mxLbLists->select( nCancelPos );
+ LbSelectHdl( *mxLbLists );
+ mxLbLists->set_sensitive(true);
+ mxLbLists->set_sensitive(true);
+ }
+ }
+
+ mxBtnAdd->set_sensitive(false);
+ mxBtnModify->set_sensitive(false);
+ mxBtnRemove->set_sensitive(true);
+ mxBtnNew->show();
+ mxBtnDiscard->hide();
+ bCancelMode = false;
+ }
+ else // if ( bModifyMode )
+ {
+ sal_Int32 nSelList = mxLbLists->get_selected_index();
+
+ OSL_ENSURE( nSelList != -1 , "Modify without List :-/" );
+
+ if ( !theEntriesStr.isEmpty() )
+ {
+ ModifyList( nSelList, theEntriesStr );
+ UpdateUserListBox();
+ mxLbLists->select( nSelList );
+ }
+ else
+ {
+ mxLbLists->select( 0 );
+ LbSelectHdl( *mxLbLists );
+ }
+
+ mxBtnNew->show();
+ mxBtnDiscard->hide();
+ bCancelMode = false;
+ mxBtnAdd->show();
+ mxBtnModify->show();
+ mxBtnAdd->set_sensitive(false);
+ mxBtnModify->set_sensitive(false);
+ bModifyMode = false;
+ mxBtnRemove->set_sensitive(true);
+ mxFtLists->set_sensitive(true);
+ mxLbLists->set_sensitive(true);
+ }
+
+ if ( pViewData && !bCopyDone )
+ {
+ mxBtnCopy->set_sensitive(true);
+ mxFtCopyFrom->set_sensitive(true);
+ mxEdCopyFrom->set_sensitive(true);
+ }
+ }
+ else if ( &rBtn == mxBtnRemove.get() )
+ {
+ if ( mxLbLists->n_children() > 0 )
+ {
+ sal_Int32 nRemovePos = mxLbLists->get_selected_index();
+ OUString aMsg = o3tl::getToken(aStrQueryRemove, 0, '#' )
+ + mxLbLists->get_text( nRemovePos )
+ + o3tl::getToken(aStrQueryRemove, 1, '#' );
+
+ std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
+ VclMessageType::Question, VclButtonsType::YesNo,
+ aMsg));
+ xQueryBox->set_default_response(RET_YES);
+
+ if (RET_YES == xQueryBox->run())
+ {
+ RemoveList( nRemovePos );
+ UpdateUserListBox();
+
+ if ( mxLbLists->n_children() > 0 )
+ {
+ mxLbLists->select(
+ ( nRemovePos >= mxLbLists->n_children() )
+ ? mxLbLists->n_children()-1
+ : nRemovePos );
+ LbSelectHdl( *mxLbLists );
+ }
+ else
+ {
+ mxFtLists->set_sensitive(false);
+ mxLbLists->set_sensitive(false);
+ mxFtEntries->set_sensitive(false);
+ mxEdEntries->set_sensitive(false);
+ mxEdEntries->set_text( OUString() );
+ mxBtnRemove->set_sensitive(false);
+ }
+ }
+
+ if ( pViewData && !bCopyDone && !mxBtnCopy->get_sensitive() )
+ {
+ mxBtnCopy->set_sensitive(true);
+ mxFtCopyFrom->set_sensitive(true);
+ mxEdCopyFrom->set_sensitive(true);
+ }
+ }
+ }
+ else if ( pViewData && (&rBtn == mxBtnCopy.get()) )
+ {
+ if ( bCopyDone )
+ return;
+
+ ScRefAddress theStartPos;
+ ScRefAddress theEndPos;
+ OUString theAreaStr( mxEdCopyFrom->get_text() );
+ bool bAreaOk = false;
+
+ if ( !theAreaStr.isEmpty() )
+ {
+ bAreaOk = ScRangeUtil::IsAbsArea( theAreaStr,
+ *pDoc,
+ pViewData->GetTabNo(),
+ &theAreaStr,
+ &theStartPos,
+ &theEndPos,
+ pDoc->GetAddressConvention() );
+ if ( !bAreaOk )
+ {
+ bAreaOk = ScRangeUtil::IsAbsPos( theAreaStr,
+ *pDoc,
+ pViewData->GetTabNo(),
+ &theAreaStr,
+ &theStartPos,
+ pDoc->GetAddressConvention() );
+ theEndPos = theStartPos;
+ }
+ }
+
+ if ( bAreaOk )
+ {
+ CopyListFromArea( theStartPos, theEndPos );
+ UpdateUserListBox();
+ mxLbLists->select( mxLbLists->n_children()-1 );
+ LbSelectHdl( *mxLbLists );
+ mxEdCopyFrom->set_text( theAreaStr );
+ mxEdCopyFrom->set_sensitive(false);
+ mxBtnCopy->set_sensitive(false);
+ mxFtCopyFrom->set_sensitive(false);
+ }
+ else
+ {
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
+ VclMessageType::Warning, VclButtonsType::Ok,
+ ScResId(STR_INVALID_TABREF)));
+
+ xBox->run();
+ mxEdCopyFrom->grab_focus();
+ mxEdCopyFrom->select_region(0, -1);
+ }
+ }
+}
+
+IMPL_LINK( ScTpUserLists, EdEntriesModHdl, weld::TextView&, rEd, void )
+{
+ if ( &rEd != mxEdEntries.get() )
+ return;
+
+ if ( mxBtnCopy->get_sensitive() )
+ {
+ mxBtnCopy->set_sensitive(false);
+ mxFtCopyFrom->set_sensitive(false);
+ mxEdCopyFrom->set_sensitive(false);
+ }
+
+ if ( !mxEdEntries->get_text().isEmpty() )
+ {
+ if ( !bCancelMode && !bModifyMode )
+ {
+ mxBtnNew->hide();
+ mxBtnDiscard->show();
+ bCancelMode = true;
+ mxBtnAdd->hide();
+ mxBtnAdd->set_sensitive(true);
+ mxBtnModify->show();
+ mxBtnModify->set_sensitive(true);
+ bModifyMode = true;
+ mxBtnRemove->set_sensitive(false);
+ mxFtLists->set_sensitive(false);
+ mxLbLists->set_sensitive(false);
+ }
+ else // if ( bCancelMode || bModifyMode )
+ {
+ if ( !mxBtnAdd->get_sensitive() )
+ {
+ mxBtnAdd->set_sensitive(true);
+ mxBtnModify->set_sensitive(true);
+ }
+ }
+ }
+ else
+ {
+ if ( mxBtnAdd->get_sensitive() )
+ {
+ mxBtnAdd->set_sensitive(false);
+ mxBtnModify->set_sensitive(false);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpview.cxx b/sc/source/ui/optdlg/tpview.cxx
new file mode 100644
index 000000000..d7cd46303
--- /dev/null
+++ b/sc/source/ui/optdlg/tpview.cxx
@@ -0,0 +1,619 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#undef SC_DLLIMPLEMENTATION
+
+#include <tpview.hxx>
+#include <global.hxx>
+#include <viewopti.hxx>
+#include <scresid.hxx>
+#include <docsh.hxx>
+#include <sc.hrc>
+#include <strings.hrc>
+#include <units.hrc>
+#include <appoptio.hxx>
+#include <scmod.hxx>
+#include <svl/eitem.hxx>
+#include <svx/colorbox.hxx>
+#include <svtools/unitconv.hxx>
+
+ScTpContentOptions::ScTpContentOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet)
+ : SfxTabPage(pPage, pController, "modules/scalc/ui/tpviewpage.ui", "TpViewPage", &rArgSet)
+ , m_xGridLB(m_xBuilder->weld_combo_box("grid"))
+ , m_xColorFT(m_xBuilder->weld_label("color_label"))
+ , m_xColorLB(new ColorListBox(m_xBuilder->weld_menu_button("color"),
+ [this]{ return GetDialogController()->getDialog(); }))
+ , m_xBreakCB(m_xBuilder->weld_check_button("break"))
+ , m_xGuideLineCB(m_xBuilder->weld_check_button("guideline"))
+ , m_xFormulaCB(m_xBuilder->weld_check_button("formula"))
+ , m_xNilCB(m_xBuilder->weld_check_button("nil"))
+ , m_xAnnotCB(m_xBuilder->weld_check_button("annot"))
+ , m_xValueCB(m_xBuilder->weld_check_button("value"))
+ , m_xAnchorCB(m_xBuilder->weld_check_button("anchor"))
+ , m_xClipMarkCB(m_xBuilder->weld_check_button("clipmark"))
+ , m_xRangeFindCB(m_xBuilder->weld_check_button("rangefind"))
+ , m_xObjGrfLB(m_xBuilder->weld_combo_box("objgrf"))
+ , m_xDiagramLB(m_xBuilder->weld_combo_box("diagram"))
+ , m_xDrawLB(m_xBuilder->weld_combo_box("draw"))
+ , m_xSyncZoomCB(m_xBuilder->weld_check_button("synczoom"))
+ , m_xRowColHeaderCB(m_xBuilder->weld_check_button("rowcolheader"))
+ , m_xHScrollCB(m_xBuilder->weld_check_button("hscroll"))
+ , m_xVScrollCB(m_xBuilder->weld_check_button("vscroll"))
+ , m_xTblRegCB(m_xBuilder->weld_check_button("tblreg"))
+ , m_xOutlineCB(m_xBuilder->weld_check_button("outline"))
+ , m_xSummaryCB(m_xBuilder->weld_check_button("cbSummary"))
+ , m_xThemedCursorRB(m_xBuilder->weld_radio_button("rbThemedCursor"))
+ , m_xSystemCursorRB(m_xBuilder->weld_radio_button("rbSystemCursor"))
+{
+ SetExchangeSupport();
+ Link<weld::ComboBox&,void> aSelObjHdl(LINK( this, ScTpContentOptions, SelLbObjHdl ) );
+ m_xObjGrfLB->connect_changed(aSelObjHdl);
+ m_xDiagramLB->connect_changed(aSelObjHdl);
+ m_xDrawLB->connect_changed(aSelObjHdl);
+ m_xGridLB->connect_changed( LINK( this, ScTpContentOptions, GridHdl ) );
+
+ Link<weld::Toggleable&, void> aCBHdl(LINK( this, ScTpContentOptions, CBHdl ) );
+ m_xFormulaCB->connect_toggled(aCBHdl);
+ m_xNilCB->connect_toggled(aCBHdl);
+ m_xAnnotCB->connect_toggled(aCBHdl);
+ m_xAnnotCB->set_accessible_description(ScResId(STR_A11Y_DESC_ANNOT));
+ m_xValueCB->connect_toggled(aCBHdl);
+ m_xAnchorCB->connect_toggled(aCBHdl);
+ m_xClipMarkCB->connect_toggled(aCBHdl);
+
+ m_xVScrollCB->connect_toggled(aCBHdl);
+ m_xHScrollCB->connect_toggled(aCBHdl);
+ m_xTblRegCB->connect_toggled(aCBHdl);
+ m_xOutlineCB->connect_toggled(aCBHdl);
+ m_xBreakCB->connect_toggled(aCBHdl);
+ m_xGuideLineCB->connect_toggled(aCBHdl);
+ m_xRowColHeaderCB->connect_toggled(aCBHdl);
+ m_xSummaryCB->connect_toggled(aCBHdl);
+ m_xThemedCursorRB->connect_toggled(aCBHdl);
+
+ m_xColorLB->SetSlotId(SID_ATTR_CHAR_COLOR);
+ m_xColorLB->SetAutoDisplayColor(SC_STD_GRIDCOLOR);
+}
+
+ScTpContentOptions::~ScTpContentOptions()
+{
+ m_xColorLB.reset();
+}
+
+std::unique_ptr<SfxTabPage> ScTpContentOptions::Create( weld::Container* pPage, weld::DialogController* pController,
+ const SfxItemSet* rCoreSet )
+{
+ return std::make_unique<ScTpContentOptions>(pPage, pController, *rCoreSet);
+}
+
+bool ScTpContentOptions::FillItemSet( SfxItemSet* rCoreSet )
+{
+ bool bRet = false;
+ if( m_xFormulaCB->get_state_changed_from_saved() ||
+ m_xNilCB->get_state_changed_from_saved() ||
+ m_xAnnotCB->get_state_changed_from_saved() ||
+ m_xValueCB->get_state_changed_from_saved() ||
+ m_xAnchorCB->get_state_changed_from_saved() ||
+ m_xClipMarkCB->get_state_changed_from_saved() ||
+ m_xObjGrfLB->get_value_changed_from_saved() ||
+ m_xDiagramLB->get_value_changed_from_saved() ||
+ m_xDrawLB->get_value_changed_from_saved() ||
+ m_xGridLB->get_value_changed_from_saved() ||
+ m_xRowColHeaderCB->get_state_changed_from_saved() ||
+ m_xHScrollCB->get_state_changed_from_saved() ||
+ m_xVScrollCB->get_state_changed_from_saved() ||
+ m_xTblRegCB->get_state_changed_from_saved() ||
+ m_xOutlineCB->get_state_changed_from_saved() ||
+ m_xColorLB->IsValueChangedFromSaved() ||
+ m_xBreakCB->get_state_changed_from_saved() ||
+ m_xSummaryCB->get_state_changed_from_saved() ||
+ m_xThemedCursorRB->get_state_changed_from_saved() ||
+ m_xGuideLineCB->get_state_changed_from_saved())
+ {
+ NamedColor aNamedColor = m_xColorLB->GetSelectedEntry();
+ if (aNamedColor.first == COL_AUTO)
+ {
+ aNamedColor.first = SC_STD_GRIDCOLOR;
+ aNamedColor.second.clear();
+ }
+ m_xLocalOptions->SetGridColor(aNamedColor.first, aNamedColor.second);
+ rCoreSet->Put(ScTpViewItem(*m_xLocalOptions));
+ bRet = true;
+ }
+ if(m_xRangeFindCB->get_state_changed_from_saved())
+ {
+ rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_RANGEFINDER, m_xRangeFindCB->get_active()));
+ bRet = true;
+ }
+ if(m_xSyncZoomCB->get_state_changed_from_saved())
+ {
+ rCoreSet->Put(SfxBoolItem(SID_SC_OPT_SYNCZOOM, m_xSyncZoomCB->get_active()));
+ bRet = true;
+ }
+
+ return bRet;
+}
+
+void ScTpContentOptions::Reset( const SfxItemSet* rCoreSet )
+{
+ if(const ScTpViewItem* pViewItem = rCoreSet->GetItemIfSet(SID_SCVIEWOPTIONS, false))
+ m_xLocalOptions.reset( new ScViewOptions( pViewItem->GetViewOptions() ) );
+ else
+ m_xLocalOptions.reset( new ScViewOptions );
+ m_xFormulaCB ->set_active(m_xLocalOptions->GetOption(VOPT_FORMULAS));
+ m_xNilCB ->set_active(m_xLocalOptions->GetOption(VOPT_NULLVALS));
+ m_xAnnotCB ->set_active(m_xLocalOptions->GetOption(VOPT_NOTES));
+ m_xValueCB ->set_active(m_xLocalOptions->GetOption(VOPT_SYNTAX));
+ m_xAnchorCB ->set_active(m_xLocalOptions->GetOption(VOPT_ANCHOR));
+ m_xClipMarkCB->set_active(m_xLocalOptions->GetOption(VOPT_CLIPMARKS));
+
+ m_xObjGrfLB ->set_active( static_cast<sal_uInt16>(m_xLocalOptions->GetObjMode(VOBJ_TYPE_OLE)) );
+ m_xDiagramLB ->set_active( static_cast<sal_uInt16>(m_xLocalOptions->GetObjMode(VOBJ_TYPE_CHART)) );
+ m_xDrawLB ->set_active( static_cast<sal_uInt16>(m_xLocalOptions->GetObjMode(VOBJ_TYPE_DRAW)) );
+
+ m_xRowColHeaderCB->set_active( m_xLocalOptions->GetOption(VOPT_HEADER) );
+ m_xHScrollCB->set_active( m_xLocalOptions->GetOption(VOPT_HSCROLL) );
+ m_xVScrollCB->set_active( m_xLocalOptions->GetOption(VOPT_VSCROLL) );
+ m_xTblRegCB ->set_active( m_xLocalOptions->GetOption(VOPT_TABCONTROLS) );
+ m_xOutlineCB->set_active( m_xLocalOptions->GetOption(VOPT_OUTLINER) );
+ m_xSummaryCB->set_active( m_xLocalOptions->GetOption(VOPT_SUMMARY) );
+ if ( m_xLocalOptions->GetOption(VOPT_THEMEDCURSOR) )
+ m_xThemedCursorRB->set_active( true );
+ else
+ m_xSystemCursorRB->set_active( true );
+
+ InitGridOpt();
+
+ m_xBreakCB->set_active( m_xLocalOptions->GetOption(VOPT_PAGEBREAKS) );
+ m_xGuideLineCB->set_active( m_xLocalOptions->GetOption(VOPT_HELPLINES) );
+
+ if(const SfxBoolItem* pFinderItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_RANGEFINDER, false))
+ m_xRangeFindCB->set_active(pFinderItem->GetValue());
+ if(const SfxBoolItem* pZoomItem = rCoreSet->GetItemIfSet(SID_SC_OPT_SYNCZOOM, false))
+ m_xSyncZoomCB->set_active(pZoomItem->GetValue());
+
+ m_xRangeFindCB->save_state();
+ m_xSyncZoomCB->save_state();
+
+ m_xFormulaCB->save_state();
+ m_xNilCB->save_state();
+ m_xAnnotCB->save_state();
+ m_xValueCB->save_state();
+ m_xAnchorCB->save_state();
+ m_xClipMarkCB->save_state();
+ m_xObjGrfLB->save_value();
+ m_xDiagramLB->save_value();
+ m_xDrawLB->save_value();
+ m_xRowColHeaderCB->save_state();
+ m_xHScrollCB->save_state();
+ m_xVScrollCB->save_state();
+ m_xTblRegCB->save_state();
+ m_xOutlineCB->save_state();
+ m_xGridLB->save_value();
+ m_xColorLB->SaveValue();
+ m_xBreakCB->save_state();
+ m_xGuideLineCB->save_state();
+ m_xSummaryCB->save_state();
+ m_xThemedCursorRB->save_state();
+}
+
+void ScTpContentOptions::ActivatePage( const SfxItemSet& rSet)
+{
+ if(const ScTpViewItem* pViewItem = rSet.GetItemIfSet(SID_SCVIEWOPTIONS, false))
+ *m_xLocalOptions = pViewItem->GetViewOptions();
+}
+
+DeactivateRC ScTpContentOptions::DeactivatePage( SfxItemSet* pSetP )
+{
+ if(pSetP)
+ FillItemSet(pSetP);
+ return DeactivateRC::LeavePage;
+}
+
+IMPL_LINK( ScTpContentOptions, SelLbObjHdl, weld::ComboBox&, rLb, void )
+{
+ const sal_Int32 nSelPos = rLb.get_active();
+ ScVObjMode eMode = ScVObjMode(nSelPos);
+ ScVObjType eType = VOBJ_TYPE_OLE;
+
+ if ( &rLb == m_xDiagramLB.get() )
+ eType = VOBJ_TYPE_CHART;
+ else if ( &rLb == m_xDrawLB.get() )
+ eType = VOBJ_TYPE_DRAW;
+
+ m_xLocalOptions->SetObjMode( eType, eMode );
+}
+
+IMPL_LINK( ScTpContentOptions, CBHdl, weld::Toggleable&, rBtn, void )
+{
+ ScViewOption eOption = VOPT_FORMULAS;
+ bool bChecked = rBtn.get_active();
+
+ if (m_xFormulaCB.get() == &rBtn ) eOption = VOPT_FORMULAS;
+ else if ( m_xNilCB.get() == &rBtn ) eOption = VOPT_NULLVALS;
+ else if ( m_xAnnotCB.get() == &rBtn ) eOption = VOPT_NOTES;
+ else if ( m_xValueCB.get() == &rBtn ) eOption = VOPT_SYNTAX;
+ else if ( m_xAnchorCB.get() == &rBtn ) eOption = VOPT_ANCHOR;
+ else if ( m_xClipMarkCB.get() == &rBtn ) eOption = VOPT_CLIPMARKS;
+ else if ( m_xVScrollCB.get() == &rBtn ) eOption = VOPT_VSCROLL;
+ else if ( m_xHScrollCB.get() == &rBtn ) eOption = VOPT_HSCROLL;
+ else if ( m_xTblRegCB.get() == &rBtn ) eOption = VOPT_TABCONTROLS;
+ else if ( m_xOutlineCB.get() == &rBtn ) eOption = VOPT_OUTLINER;
+ else if ( m_xBreakCB.get() == &rBtn ) eOption = VOPT_PAGEBREAKS;
+ else if ( m_xGuideLineCB.get() == &rBtn ) eOption = VOPT_HELPLINES;
+ else if ( m_xRowColHeaderCB.get() == &rBtn ) eOption = VOPT_HEADER;
+ else if ( m_xSummaryCB.get() == &rBtn ) eOption = VOPT_SUMMARY;
+ else if ( m_xThemedCursorRB.get() == &rBtn ) eOption = VOPT_THEMEDCURSOR;
+
+ m_xLocalOptions->SetOption( eOption, bChecked );
+}
+
+void ScTpContentOptions::InitGridOpt()
+{
+ bool bGrid = m_xLocalOptions->GetOption( VOPT_GRID );
+ bool bGridOnTop = m_xLocalOptions->GetOption( VOPT_GRID_ONTOP );
+ sal_Int32 nSelPos = 0;
+
+ if ( bGrid || bGridOnTop )
+ {
+ m_xColorFT->set_sensitive(true);
+ m_xColorLB->set_sensitive(true);
+ if ( !bGridOnTop )
+ nSelPos = 0;
+ else
+ nSelPos = 1;
+ }
+ else
+ {
+ m_xColorFT->set_sensitive(false);
+ m_xColorLB->set_sensitive(false);
+ nSelPos = 2;
+ }
+
+ m_xGridLB->set_active (nSelPos);
+
+ // select grid color entry
+ OUString aName;
+ Color aCol = m_xLocalOptions->GetGridColor( &aName );
+
+ if (aName.trim().isEmpty() && aCol == SC_STD_GRIDCOLOR)
+ aCol = COL_AUTO;
+
+ m_xColorLB->SelectEntry(std::make_pair(aCol, aName));
+}
+
+IMPL_LINK( ScTpContentOptions, GridHdl, weld::ComboBox&, rLb, void )
+{
+ sal_Int32 nSelPos = rLb.get_active();
+ bool bGrid = ( nSelPos <= 1 );
+ bool bGridOnTop = ( nSelPos == 1 );
+
+ m_xColorFT->set_sensitive(bGrid);
+ m_xColorLB->set_sensitive(bGrid);
+ m_xLocalOptions->SetOption( VOPT_GRID, bGrid );
+ m_xLocalOptions->SetOption( VOPT_GRID_ONTOP, bGridOnTop );
+}
+
+ScTpLayoutOptions::ScTpLayoutOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rArgSet)
+ : SfxTabPage(pPage, pController, "modules/scalc/ui/scgeneralpage.ui", "ScGeneralPage", &rArgSet)
+ , pDoc(nullptr)
+ , m_xUnitLB(m_xBuilder->weld_combo_box("unitlb"))
+ , m_xTabMF(m_xBuilder->weld_metric_spin_button("tabmf", FieldUnit::CM))
+ , m_xAlwaysRB(m_xBuilder->weld_radio_button("alwaysrb"))
+ , m_xRequestRB(m_xBuilder->weld_radio_button("requestrb"))
+ , m_xNeverRB(m_xBuilder->weld_radio_button("neverrb"))
+ , m_xAlignCB(m_xBuilder->weld_check_button("aligncb"))
+ , m_xAlignLB(m_xBuilder->weld_combo_box("alignlb"))
+ , m_xEditModeCB(m_xBuilder->weld_check_button("editmodecb"))
+ , m_xFormatCB(m_xBuilder->weld_check_button("formatcb"))
+ , m_xExpRefCB(m_xBuilder->weld_check_button("exprefcb"))
+ , m_xSortRefUpdateCB(m_xBuilder->weld_check_button("sortrefupdatecb"))
+ , m_xMarkHdrCB(m_xBuilder->weld_check_button("markhdrcb"))
+ , m_xTextFmtCB(m_xBuilder->weld_check_button("textfmtcb"))
+ , m_xReplWarnCB(m_xBuilder->weld_check_button("replwarncb"))
+ , m_xLegacyCellSelectionCB(m_xBuilder->weld_check_button("legacy_cell_selection_cb"))
+ , m_xEnterPasteModeCB(m_xBuilder->weld_check_button("enter_paste_mode_cb"))
+{
+ SetExchangeSupport();
+
+ m_xUnitLB->connect_changed( LINK( this, ScTpLayoutOptions, MetricHdl ) );
+ m_xAlignCB->connect_toggled(LINK(this, ScTpLayoutOptions, AlignHdl));
+
+ for (size_t i = 0; i < SAL_N_ELEMENTS(SCSTR_UNIT); ++i)
+ {
+ OUString sMetric = ScResId(SCSTR_UNIT[i].first);
+ FieldUnit eFUnit = SCSTR_UNIT[i].second;
+
+ switch ( eFUnit )
+ {
+ case FieldUnit::MM:
+ case FieldUnit::CM:
+ case FieldUnit::POINT:
+ case FieldUnit::PICA:
+ case FieldUnit::INCH:
+ {
+ // only use these metrics
+ m_xUnitLB->append(OUString::number(static_cast<sal_uInt32>(eFUnit)), sMetric);
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+}
+
+ScTpLayoutOptions::~ScTpLayoutOptions()
+{
+}
+
+std::unique_ptr<SfxTabPage> ScTpLayoutOptions::Create( weld::Container* pPage, weld::DialogController* pController,
+ const SfxItemSet* rCoreSet )
+{
+ auto xNew = std::make_unique<ScTpLayoutOptions>(pPage, pController, *rCoreSet);
+
+ ScDocShell* pDocSh = dynamic_cast< ScDocShell *>( SfxObjectShell::Current() );
+ if (pDocSh!=nullptr)
+ xNew->pDoc = &pDocSh->GetDocument();
+ return xNew;
+}
+
+bool ScTpLayoutOptions::FillItemSet( SfxItemSet* rCoreSet )
+{
+ bool bRet = true;
+ if (m_xUnitLB->get_value_changed_from_saved())
+ {
+ const sal_Int32 nMPos = m_xUnitLB->get_active();
+ sal_uInt16 nFieldUnit = m_xUnitLB->get_id(nMPos).toUInt32();
+ rCoreSet->Put( SfxUInt16Item( SID_ATTR_METRIC, nFieldUnit ) );
+ bRet = true;
+ }
+
+ if (m_xTabMF->get_value_changed_from_saved())
+ {
+ rCoreSet->Put(SfxUInt16Item(SID_ATTR_DEFTABSTOP,
+ sal::static_int_cast<sal_uInt16>( m_xTabMF->denormalize(m_xTabMF->get_value(FieldUnit::TWIP)) )));
+ bRet = true;
+ }
+
+ ScLkUpdMode nSet=LM_ALWAYS;
+
+ if (m_xRequestRB->get_active())
+ {
+ nSet=LM_ON_DEMAND;
+ }
+ else if (m_xNeverRB->get_active())
+ {
+ nSet=LM_NEVER;
+ }
+
+ if (m_xRequestRB->get_state_changed_from_saved() ||
+ m_xNeverRB->get_state_changed_from_saved() )
+ {
+ if(pDoc)
+ pDoc->SetLinkMode(nSet);
+ ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
+ aAppOptions.SetLinkMode(nSet );
+ SC_MOD()->SetAppOptions(aAppOptions);
+ bRet = true;
+ }
+ if (m_xAlignCB->get_state_changed_from_saved())
+ {
+ rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_SELECTION, m_xAlignCB->get_active()));
+ bRet = true;
+ }
+
+ if (m_xAlignLB->get_value_changed_from_saved())
+ {
+ rCoreSet->Put(SfxUInt16Item(SID_SC_INPUT_SELECTIONPOS, m_xAlignLB->get_active()));
+ bRet = true;
+ }
+
+ if (m_xEditModeCB->get_state_changed_from_saved())
+ {
+ rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_EDITMODE, m_xEditModeCB->get_active()));
+ bRet = true;
+ }
+
+ if (m_xFormatCB->get_state_changed_from_saved())
+ {
+ rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_FMT_EXPAND, m_xFormatCB->get_active()));
+ bRet = true;
+ }
+
+ if (m_xExpRefCB->get_state_changed_from_saved())
+ {
+ rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_REF_EXPAND, m_xExpRefCB->get_active()));
+ bRet = true;
+ }
+
+ if (m_xSortRefUpdateCB->get_state_changed_from_saved())
+ {
+ rCoreSet->Put(SfxBoolItem(SID_SC_OPT_SORT_REF_UPDATE, m_xSortRefUpdateCB->get_active()));
+ bRet = true;
+ }
+
+ if (m_xMarkHdrCB->get_state_changed_from_saved())
+ {
+ rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_MARK_HEADER, m_xMarkHdrCB->get_active()));
+ bRet = true;
+ }
+
+ if (m_xTextFmtCB->get_state_changed_from_saved())
+ {
+ rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_TEXTWYSIWYG, m_xTextFmtCB->get_active()));
+ bRet = true;
+ }
+
+ if (m_xReplWarnCB->get_state_changed_from_saved())
+ {
+ rCoreSet->Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN, m_xReplWarnCB->get_active() ) );
+ bRet = true;
+ }
+
+ if (m_xLegacyCellSelectionCB->get_state_changed_from_saved())
+ {
+ rCoreSet->Put( SfxBoolItem( SID_SC_INPUT_LEGACY_CELL_SELECTION, m_xLegacyCellSelectionCB->get_active() ) );
+ bRet = true;
+ }
+
+ if (m_xEnterPasteModeCB->get_state_changed_from_saved())
+ {
+ rCoreSet->Put( SfxBoolItem( SID_SC_INPUT_ENTER_PASTE_MODE, m_xEnterPasteModeCB->get_active() ) );
+ bRet = true;
+ }
+
+ return bRet;
+}
+
+void ScTpLayoutOptions::Reset( const SfxItemSet* rCoreSet )
+{
+ m_xUnitLB->set_active(-1);
+ if ( rCoreSet->GetItemState( SID_ATTR_METRIC ) >= SfxItemState::DEFAULT )
+ {
+ const SfxUInt16Item& rItem = rCoreSet->Get( SID_ATTR_METRIC );
+ FieldUnit eFieldUnit = static_cast<FieldUnit>(rItem.GetValue());
+
+ for (sal_Int32 i = 0, nEntryCount = m_xUnitLB->get_count(); i < nEntryCount; ++i)
+ {
+ if (m_xUnitLB->get_id(i).toUInt32() == static_cast<sal_uInt32>(eFieldUnit))
+ {
+ m_xUnitLB->set_active(i);
+ break;
+ }
+ }
+ ::SetFieldUnit(*m_xTabMF, eFieldUnit);
+ }
+ m_xUnitLB->save_value();
+
+ if(const SfxUInt16Item* pTabStopItem = rCoreSet->GetItemIfSet(SID_ATTR_DEFTABSTOP, false))
+ m_xTabMF->set_value(m_xTabMF->normalize(pTabStopItem->GetValue()), FieldUnit::TWIP);
+ m_xTabMF->save_value();
+
+ m_xUnitLB->save_value();
+ m_xTabMF->save_value();
+
+ ScLkUpdMode nSet=LM_UNKNOWN;
+
+ if(pDoc!=nullptr)
+ {
+ nSet=pDoc->GetLinkMode();
+ }
+
+ if(nSet==LM_UNKNOWN)
+ {
+ ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
+ nSet=aAppOptions.GetLinkMode();
+ }
+
+ switch(nSet)
+ {
+ case LM_ALWAYS: m_xAlwaysRB->set_active(true); break;
+ case LM_NEVER: m_xNeverRB->set_active(true); break;
+ case LM_ON_DEMAND: m_xRequestRB->set_active(true); break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ if(const SfxBoolItem* pSelectionItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_SELECTION, false))
+ m_xAlignCB->set_active(pSelectionItem->GetValue());
+
+ if(const SfxUInt16Item* pPosItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_SELECTIONPOS, false))
+ m_xAlignLB->set_active(pPosItem->GetValue());
+
+ if(const SfxBoolItem* pEditModeItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_EDITMODE, false))
+ m_xEditModeCB->set_active(pEditModeItem->GetValue());
+
+ if(const SfxBoolItem* pExpandItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_FMT_EXPAND, false))
+ m_xFormatCB->set_active(pExpandItem->GetValue());
+
+ if(const SfxBoolItem* pExpandItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_REF_EXPAND, false))
+ m_xExpRefCB->set_active(pExpandItem->GetValue());
+
+ if (const SfxBoolItem* pUpdateItem = rCoreSet->GetItemIfSet(SID_SC_OPT_SORT_REF_UPDATE))
+ m_xSortRefUpdateCB->set_active(pUpdateItem->GetValue());
+
+ if(const SfxBoolItem* pHeaderItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_MARK_HEADER, false))
+ m_xMarkHdrCB->set_active(pHeaderItem->GetValue());
+
+ if(const SfxBoolItem* pWysiItem = rCoreSet->GetItemIfSet(SID_SC_INPUT_TEXTWYSIWYG, false))
+ m_xTextFmtCB->set_active(pWysiItem->GetValue());
+
+ if( const SfxBoolItem* pWarnItem = rCoreSet->GetItemIfSet( SID_SC_INPUT_REPLCELLSWARN, false ) )
+ m_xReplWarnCB->set_active( pWarnItem->GetValue() );
+
+ if( const SfxBoolItem* pSelectionItem = rCoreSet->GetItemIfSet( SID_SC_INPUT_LEGACY_CELL_SELECTION, false ) )
+ m_xLegacyCellSelectionCB->set_active( pSelectionItem->GetValue() );
+
+ if( const SfxBoolItem* pPasteModeItem = rCoreSet->GetItemIfSet( SID_SC_INPUT_ENTER_PASTE_MODE, false ) )
+ m_xEnterPasteModeCB->set_active( pPasteModeItem->GetValue() );
+
+ m_xAlignCB->save_state();
+ m_xAlignLB->save_value();
+ m_xEditModeCB->save_state();
+ m_xFormatCB->save_state();
+
+ m_xExpRefCB->save_state();
+ m_xSortRefUpdateCB->save_state();
+ m_xMarkHdrCB->save_state();
+ m_xTextFmtCB->save_state();
+ m_xReplWarnCB->save_state();
+
+ m_xLegacyCellSelectionCB->save_state();
+ m_xEnterPasteModeCB->save_state();
+
+ AlignHdl(*m_xAlignCB);
+
+ m_xAlwaysRB->save_state();
+ m_xNeverRB->save_state();
+ m_xRequestRB->save_state();
+}
+
+void ScTpLayoutOptions::ActivatePage( const SfxItemSet& /* rCoreSet */ )
+{
+}
+
+DeactivateRC ScTpLayoutOptions::DeactivatePage( SfxItemSet* pSetP )
+{
+ if(pSetP)
+ FillItemSet(pSetP);
+ return DeactivateRC::LeavePage;
+}
+
+IMPL_LINK_NOARG(ScTpLayoutOptions, MetricHdl, weld::ComboBox&, void)
+{
+ const sal_Int32 nMPos = m_xUnitLB->get_active();
+ if (nMPos != -1)
+ {
+ FieldUnit eFieldUnit = static_cast<FieldUnit>(m_xUnitLB->get_id(nMPos).toUInt32());
+ sal_Int64 nVal =
+ m_xTabMF->denormalize( m_xTabMF->get_value( FieldUnit::TWIP ) );
+ ::SetFieldUnit( *m_xTabMF, eFieldUnit );
+ m_xTabMF->set_value( m_xTabMF->normalize( nVal ), FieldUnit::TWIP );
+ }
+}
+
+IMPL_LINK(ScTpLayoutOptions, AlignHdl, weld::Toggleable&, rBox, void)
+{
+ m_xAlignLB->set_sensitive(rBox.get_active());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */