1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #undef SC_DLLIMPLEMENTATION
22 #include "scitems.hxx"
23 #include <vcl/msgbox.hxx>
26 #include "globstr.hrc"
27 #include "uiitems.hxx"
29 #include "document.hxx"
30 #include "docoptio.hxx"
31 #include "scresid.hxx"
38 ScTpCalcOptions::ScTpCalcOptions(vcl::Window
* pParent
, const SfxItemSet
& rCoreAttrs
)
39 : SfxTabPage(pParent
, "OptCalculatePage",
40 "modules/scalc/ui/optcalculatepage.ui", &rCoreAttrs
)
41 , pOldOptions(new ScDocOptions(
42 static_cast<const ScTpCalcItem
&>(rCoreAttrs
.Get(
43 GetWhich(SID_SCDOCOPTIONS
))).GetDocOptions()))
44 , pLocalOptions(new ScDocOptions
)
45 , nWhichCalc(GetWhich(SID_SCDOCOPTIONS
))
47 get(m_pBtnIterate
, "iterate");
48 get(m_pFtSteps
, "stepsft");
49 get(m_pEdSteps
, "steps");
50 get(m_pFtEps
, "minchangeft");
51 get(m_pEdEps
, "minchange");
52 get(m_pBtnDateStd
, "datestd");
53 get(m_pBtnDateSc10
, "datesc10");
54 get(m_pBtnDate1904
, "date1904");
55 get(m_pBtnCase
, "case");
56 get(m_pBtnCalc
, "calc");
57 get(m_pBtnMatch
, "match");
58 get(m_pBtnRegex
, "regex");
59 get(m_pBtnLookUp
, "lookup");
60 get(m_pBtnGeneralPrec
, "generalprec");
61 get(m_pFtPrec
, "precft");
62 get(m_pEdPrec
, "prec");
67 ScTpCalcOptions::~ScTpCalcOptions()
72 void ScTpCalcOptions::dispose()
76 m_pBtnIterate
.clear();
81 m_pBtnDateStd
.clear();
82 m_pBtnDateSc10
.clear();
83 m_pBtnDate1904
.clear();
89 m_pBtnGeneralPrec
.clear();
92 SfxTabPage::dispose();
95 void ScTpCalcOptions::Init()
97 m_pBtnIterate
->SetClickHdl( LINK( this, ScTpCalcOptions
, CheckClickHdl
) );
98 m_pBtnGeneralPrec
->SetClickHdl( LINK(this, ScTpCalcOptions
, CheckClickHdl
) );
99 m_pBtnDateStd
->SetClickHdl( LINK( this, ScTpCalcOptions
, RadioClickHdl
) );
100 m_pBtnDateSc10
->SetClickHdl( LINK( this, ScTpCalcOptions
, RadioClickHdl
) );
101 m_pBtnDate1904
->SetClickHdl( LINK( this, ScTpCalcOptions
, RadioClickHdl
) );
104 VclPtr
<SfxTabPage
> ScTpCalcOptions::Create( vcl::Window
* pParent
, const SfxItemSet
* rAttrSet
)
106 return VclPtr
<ScTpCalcOptions
>::Create( pParent
, *rAttrSet
);
109 void ScTpCalcOptions::Reset( const SfxItemSet
* /* rCoreAttrs */ )
113 *pLocalOptions
= *pOldOptions
;
115 m_pBtnCase
->Check( !pLocalOptions
->IsIgnoreCase() );
116 m_pBtnCalc
->Check( pLocalOptions
->IsCalcAsShown() );
117 m_pBtnMatch
->Check( pLocalOptions
->IsMatchWholeCell() );
118 m_pBtnRegex
->Check( pLocalOptions
->IsFormulaRegexEnabled() );
119 m_pBtnLookUp
->Check( pLocalOptions
->IsLookUpColRowNames() );
120 m_pBtnIterate
->Check( pLocalOptions
->IsIter() );
121 m_pEdSteps
->SetValue( pLocalOptions
->GetIterCount() );
122 m_pEdEps
->SetValue( pLocalOptions
->GetIterEps(), 6 );
124 pLocalOptions
->GetDate( d
, m
, y
);
129 m_pBtnDateStd
->Check();
132 m_pBtnDateSc10
->Check();
135 m_pBtnDate1904
->Check();
139 sal_uInt16 nPrec
= pLocalOptions
->GetStdPrecision();
140 if (nPrec
== SvNumberFormatter::UNLIMITED_PRECISION
)
142 m_pFtPrec
->Disable();
143 m_pEdPrec
->Disable();
144 m_pBtnGeneralPrec
->Check(false);
148 m_pBtnGeneralPrec
->Check();
151 m_pEdPrec
->SetValue(nPrec
);
154 CheckClickHdl(m_pBtnIterate
);
157 bool ScTpCalcOptions::FillItemSet( SfxItemSet
* rCoreAttrs
)
159 // alle weiteren Optionen werden in den Handlern aktualisiert
160 pLocalOptions
->SetIterCount( (sal_uInt16
)m_pEdSteps
->GetValue() );
161 pLocalOptions
->SetIgnoreCase( !m_pBtnCase
->IsChecked() );
162 pLocalOptions
->SetCalcAsShown( m_pBtnCalc
->IsChecked() );
163 pLocalOptions
->SetMatchWholeCell( m_pBtnMatch
->IsChecked() );
164 pLocalOptions
->SetFormulaRegexEnabled( m_pBtnRegex
->IsChecked() );
165 pLocalOptions
->SetLookUpColRowNames( m_pBtnLookUp
->IsChecked() );
167 if (m_pBtnGeneralPrec
->IsChecked())
168 pLocalOptions
->SetStdPrecision(
169 static_cast<sal_uInt16
>(m_pEdPrec
->GetValue()) );
171 pLocalOptions
->SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION
);
173 if ( *pLocalOptions
!= *pOldOptions
)
175 rCoreAttrs
->Put( ScTpCalcItem( nWhichCalc
, *pLocalOptions
) );
182 SfxTabPage::sfxpg
ScTpCalcOptions::DeactivatePage( SfxItemSet
* pSetP
)
184 sfxpg nReturn
= KEEP_PAGE
;
187 if( m_pEdEps
->GetValue( fEps
) && (fEps
> 0.0) )
189 pLocalOptions
->SetIterEps( fEps
);
190 nReturn
= LEAVE_PAGE
;
193 if ( nReturn
== KEEP_PAGE
)
195 ScopedVclPtr
<MessageDialog
>::Create( this,
196 ScGlobal::GetRscString( STR_INVALID_EPS
)
199 m_pEdEps
->GrabFocus();
202 FillItemSet( pSetP
);
209 IMPL_LINK( ScTpCalcOptions
, RadioClickHdl
, RadioButton
*, pBtn
)
211 if (pBtn
== m_pBtnDateStd
)
213 pLocalOptions
->SetDate( 30, 12, 1899 );
215 else if (pBtn
== m_pBtnDateSc10
)
217 pLocalOptions
->SetDate( 1, 1, 1900 );
219 else if (pBtn
== m_pBtnDate1904
)
221 pLocalOptions
->SetDate( 1, 1, 1904 );
227 IMPL_LINK( ScTpCalcOptions
, CheckClickHdl
, CheckBox
*, pBtn
)
229 if (pBtn
== m_pBtnGeneralPrec
)
231 if (pBtn
->IsChecked())
238 m_pEdPrec
->Disable();
239 m_pFtPrec
->Disable();
242 else if (pBtn
== m_pBtnIterate
)
244 if ( pBtn
->IsChecked() )
246 pLocalOptions
->SetIter( true );
247 m_pFtSteps
->Enable(); m_pEdSteps
->Enable();
248 m_pFtEps
->Enable(); m_pEdEps
->Enable();
252 pLocalOptions
->SetIter( false );
253 m_pFtSteps
->Disable(); m_pEdSteps
->Disable();
254 m_pFtEps
->Disable(); m_pEdEps
->Disable();
261 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */