LibreOffice Module sc (master) 1
tpdefaults.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#undef SC_DLLIMPLEMENTATION
11
12#include <tpdefaults.hxx>
13#include <sc.hrc>
14#include <defaultsoptions.hxx>
15#include <document.hxx>
16#include <officecfg/Office/Common.hxx>
17#include <config_features.h>
18
20 : SfxTabPage(pPage, pController, "modules/scalc/ui/optdefaultpage.ui", "OptDefaultPage", &rCoreSet)
21 , m_xEdNSheets(m_xBuilder->weld_spin_button("sheetsnumber"))
22 , m_xEdSheetPrefix(m_xBuilder->weld_entry("sheetprefix"))
23 , m_xEdJumboSheets(m_xBuilder->weld_check_button("jumbo_sheets"))
24{
25 m_xEdNSheets->connect_changed( LINK(this, ScTpDefaultsOptions, NumModifiedHdl) );
26 m_xEdSheetPrefix->connect_changed( LINK(this, ScTpDefaultsOptions, PrefixModifiedHdl) );
27 m_xEdSheetPrefix->connect_focus_in( LINK(this, ScTpDefaultsOptions, PrefixEditOnFocusHdl) );
28#if HAVE_FEATURE_JUMBO_SHEETS
29 if (!officecfg::Office::Common::Misc::ExperimentalMode::get())
30#endif
31 m_xEdJumboSheets->hide();
32}
33
35{
36}
37
38std::unique_ptr<SfxTabPage> ScTpDefaultsOptions::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rCoreAttrs)
39{
40 return std::make_unique<ScTpDefaultsOptions>(pPage, pController, *rCoreAttrs);
41}
42
44{
45 bool bRet = false;
47
48 SCTAB nTabCount = static_cast<SCTAB>(m_xEdNSheets->get_value());
49 OUString aSheetPrefix = m_xEdSheetPrefix->get_text();
50 bool bJumboSheets = m_xEdJumboSheets->get_state();
51
52 if ( m_xEdNSheets->get_value_changed_from_saved()
53 || m_xEdSheetPrefix->get_saved_value() != aSheetPrefix
54 || m_xEdJumboSheets->get_saved_state() != (bJumboSheets ? TRISTATE_TRUE : TRISTATE_FALSE) )
55 {
56 aOpt.SetInitTabCount( nTabCount );
57 aOpt.SetInitTabPrefix( aSheetPrefix );
58#if HAVE_FEATURE_JUMBO_SHEETS
59 aOpt.SetInitJumboSheets( bJumboSheets );
60#endif
61 rCoreSet->Put( ScTpDefaultsItem( std::move(aOpt) ) );
62 bRet = true;
63 }
64 return bRet;
65}
66
68{
70
71 if(const ScTpDefaultsItem* pDefaultsItem = rCoreSet->GetItemIfSet(SID_SCDEFAULTSOPTIONS, false))
72 aOpt = pDefaultsItem->GetDefaultsOptions();
73
74 m_xEdNSheets->set_value(aOpt.GetInitTabCount());
75 m_xEdSheetPrefix->set_text( aOpt.GetInitTabPrefix() );
77 m_xEdNSheets->save_value();
78 m_xEdSheetPrefix->save_value();
79 m_xEdJumboSheets->save_state();
80}
81
83{
84 return DeactivateRC::KeepPage;
85}
86
88{
89 auto nVal = m_xEdNSheets->get_value();
90 if (nVal > MAXINITTAB)
91 m_xEdNSheets->set_value(MAXINITTAB);
92 if (nVal < MININITTAB)
93 m_xEdNSheets->set_value(MININITTAB);
94}
95
97{
98 OUString aSheetPrefix = m_xEdSheetPrefix->get_text();
99
100 if (!aSheetPrefix.isEmpty() && !ScDocument::ValidTabName(aSheetPrefix))
101 {
102 // Revert to last good Prefix and also select it to
103 // indicate something illegal was typed
105 m_xEdSheetPrefix->select_region(0, -1);
106 }
107 else
108 {
110 }
111}
112
114{
115 // Store Prefix in case we need to revert
117}
118
120{
121 CheckNumSheets();
122}
123
125{
126 CheckPrefix();
127}
128
130{
131 OnFocusPrefixInput();
132}
133
134/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SCTAB MININITTAB
Definition: address.hxx:82
const SCTAB MAXINITTAB
Definition: address.hxx:81
bool GetInitJumboSheets() const
void SetInitTabCount(SCTAB nTabs)
SCTAB GetInitTabCount() const
void SetInitTabPrefix(const OUString &aPrefix)
const OUString & GetInitTabPrefix() const
static SC_DLLPUBLIC bool ValidTabName(const OUString &rName)
Definition: document.cxx:337
ScTpDefaultsOptions(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rCoreSet)
Definition: tpdefaults.cxx:19
std::unique_ptr< weld::CheckButton > m_xEdJumboSheets
Definition: tpdefaults.hxx:40
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rCoreSet)
Definition: tpdefaults.cxx:38
virtual bool FillItemSet(SfxItemSet *rCoreSet) override
Definition: tpdefaults.cxx:43
std::unique_ptr< weld::Entry > m_xEdSheetPrefix
Definition: tpdefaults.hxx:39
virtual ~ScTpDefaultsOptions() override
Definition: tpdefaults.cxx:34
std::unique_ptr< weld::SpinButton > m_xEdNSheets
Definition: tpdefaults.hxx:38
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: tpdefaults.cxx:82
virtual void Reset(const SfxItemSet *rCoreSet) override
Definition: tpdefaults.cxx:67
OUString maOldPrefixValue
Definition: tpdefaults.hxx:36
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
TRISTATE_FALSE
TRISTATE_TRUE
DeactivateRC
IMPL_LINK_NOARG(ScTpDefaultsOptions, NumModifiedHdl, weld::Entry &, void)
Definition: tpdefaults.cxx:119
sal_Int16 SCTAB
Definition: types.hxx:22