fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / optdlg / tpdefaults.cxx
bloba2929f77eb3a14448797499a958110dd2d0992f9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #undef SC_DLLIMPLEMENTATION
12 #include "tpdefaults.hxx"
13 #include "sc.hrc"
14 #include "scresid.hxx"
15 #include "scmod.hxx"
16 #include "defaultsoptions.hxx"
17 #include "document.hxx"
19 ScTpDefaultsOptions::ScTpDefaultsOptions(vcl::Window *pParent, const SfxItemSet &rCoreSet) :
20 SfxTabPage(pParent, "OptDefaultPage", "modules/scalc/ui/optdefaultpage.ui", &rCoreSet)
23 get( m_pEdNSheets, "sheetsnumber");
24 get( m_pEdSheetPrefix, "sheetprefix");
26 m_pEdNSheets->SetModifyHdl( LINK(this, ScTpDefaultsOptions, NumModifiedHdl) );
27 m_pEdSheetPrefix->SetModifyHdl( LINK(this, ScTpDefaultsOptions, PrefixModifiedHdl) );
28 m_pEdSheetPrefix->SetGetFocusHdl( LINK(this, ScTpDefaultsOptions, PrefixEditOnFocusHdl) );
31 ScTpDefaultsOptions::~ScTpDefaultsOptions()
33 disposeOnce();
36 void ScTpDefaultsOptions::dispose()
38 m_pEdNSheets.clear();
39 m_pEdSheetPrefix.clear();
40 SfxTabPage::dispose();
43 VclPtr<SfxTabPage> ScTpDefaultsOptions::Create(vcl::Window *pParent, const SfxItemSet *rCoreAttrs)
45 return VclPtr<ScTpDefaultsOptions>::Create(pParent, *rCoreAttrs);
48 bool ScTpDefaultsOptions::FillItemSet(SfxItemSet *rCoreSet)
50 bool bRet = false;
51 ScDefaultsOptions aOpt;
53 SCTAB nTabCount = static_cast<SCTAB>(m_pEdNSheets->GetValue());
54 OUString aSheetPrefix = m_pEdSheetPrefix->GetText();
56 if ( m_pEdNSheets->IsValueChangedFromSaved()
57 || m_pEdSheetPrefix->GetSavedValue() != aSheetPrefix )
59 aOpt.SetInitTabCount( nTabCount );
60 aOpt.SetInitTabPrefix( aSheetPrefix );
62 rCoreSet->Put( ScTpDefaultsItem( SID_SCDEFAULTSOPTIONS, aOpt ) );
63 bRet = true;
65 return bRet;
68 void ScTpDefaultsOptions::Reset(const SfxItemSet* rCoreSet)
70 ScDefaultsOptions aOpt;
71 const SfxPoolItem* pItem = NULL;
73 if(SfxItemState::SET == rCoreSet->GetItemState(SID_SCDEFAULTSOPTIONS, false , &pItem))
74 aOpt = static_cast<const ScTpDefaultsItem*>(pItem)->GetDefaultsOptions();
76 m_pEdNSheets->SetValue( static_cast<sal_uInt16>( aOpt.GetInitTabCount()) );
77 m_pEdSheetPrefix->SetText( aOpt.GetInitTabPrefix() );
78 m_pEdNSheets->SaveValue();
79 m_pEdSheetPrefix->SaveValue();
82 SfxTabPage::sfxpg ScTpDefaultsOptions::DeactivatePage(SfxItemSet* /*pSet*/)
84 return KEEP_PAGE;
87 void ScTpDefaultsOptions::CheckNumSheets()
89 sal_Int64 nVal = m_pEdNSheets->GetValue();
90 if (nVal > MAXINITTAB)
91 m_pEdNSheets->SetValue(MAXINITTAB);
92 if (nVal < MININITTAB)
93 m_pEdNSheets->SetValue(MININITTAB);
96 void ScTpDefaultsOptions::CheckPrefix(Edit* pEdit)
98 if (!pEdit)
99 return;
101 OUString aSheetPrefix = pEdit->GetText();
103 if ( !aSheetPrefix.isEmpty() && !ScDocument::ValidTabName( aSheetPrefix ) )
105 // Revert to last good Prefix and also select it to
106 // indicate something illegal was typed
107 Selection aSel( 0, maOldPrefixValue.getLength() );
108 pEdit->SetText( maOldPrefixValue, aSel );
110 else
112 OnFocusPrefixInput(pEdit);
116 void ScTpDefaultsOptions::OnFocusPrefixInput(Edit* pEdit)
118 if (!pEdit)
119 return;
121 // Store Prefix in case we need to revert
122 maOldPrefixValue = pEdit->GetText();
125 IMPL_LINK_NOARG(ScTpDefaultsOptions, NumModifiedHdl)
127 CheckNumSheets();
128 return 0;
131 IMPL_LINK( ScTpDefaultsOptions, PrefixModifiedHdl, Edit*, pEdit )
133 CheckPrefix(pEdit);
134 return 0;
137 IMPL_LINK( ScTpDefaultsOptions, PrefixEditOnFocusHdl, Edit*, pEdit )
139 OnFocusPrefixInput(pEdit);
140 return 0;
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */