fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / optdlg / tpcalc.cxx
bloba3fad625889e6797213109c7aade7396ff996395
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/.
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>
25 #include "global.hxx"
26 #include "globstr.hrc"
27 #include "uiitems.hxx"
28 #include "docsh.hxx"
29 #include "document.hxx"
30 #include "docoptio.hxx"
31 #include "scresid.hxx"
32 #include "sc.hrc"
34 #include "tpcalc.hxx"
36 #include <math.h>
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");
63 Init();
64 SetExchangeSupport();
67 ScTpCalcOptions::~ScTpCalcOptions()
69 disposeOnce();
72 void ScTpCalcOptions::dispose()
74 delete pOldOptions;
75 delete pLocalOptions;
76 m_pBtnIterate.clear();
77 m_pFtSteps.clear();
78 m_pEdSteps.clear();
79 m_pFtEps.clear();
80 m_pEdEps.clear();
81 m_pBtnDateStd.clear();
82 m_pBtnDateSc10.clear();
83 m_pBtnDate1904.clear();
84 m_pBtnCase.clear();
85 m_pBtnCalc.clear();
86 m_pBtnMatch.clear();
87 m_pBtnRegex.clear();
88 m_pBtnLookUp.clear();
89 m_pBtnGeneralPrec.clear();
90 m_pFtPrec.clear();
91 m_pEdPrec.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 */ )
111 sal_uInt16 d,m,y;
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 );
126 switch ( y )
128 case 1899:
129 m_pBtnDateStd->Check();
130 break;
131 case 1900:
132 m_pBtnDateSc10->Check();
133 break;
134 case 1904:
135 m_pBtnDate1904->Check();
136 break;
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);
146 else
148 m_pBtnGeneralPrec->Check();
149 m_pFtPrec->Enable();
150 m_pEdPrec->Enable();
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()) );
170 else
171 pLocalOptions->SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION );
173 if ( *pLocalOptions != *pOldOptions )
175 rCoreAttrs->Put( ScTpCalcItem( nWhichCalc, *pLocalOptions ) );
176 return true;
178 else
179 return false;
182 SfxTabPage::sfxpg ScTpCalcOptions::DeactivatePage( SfxItemSet* pSetP )
184 sfxpg nReturn = KEEP_PAGE;
186 double fEps;
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 )
197 )->Execute();
199 m_pEdEps->GrabFocus();
201 else if ( pSetP )
202 FillItemSet( pSetP );
204 return nReturn;
207 // Handler:
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 );
224 return 0;
227 IMPL_LINK( ScTpCalcOptions, CheckClickHdl, CheckBox*, pBtn )
229 if (pBtn == m_pBtnGeneralPrec)
231 if (pBtn->IsChecked())
233 m_pEdPrec->Enable();
234 m_pFtPrec->Enable();
236 else
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();
250 else
252 pLocalOptions->SetIter( false );
253 m_pFtSteps->Disable(); m_pEdSteps->Disable();
254 m_pFtEps->Disable(); m_pEdEps->Disable();
258 return 0;
261 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */