1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tpcalc.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #undef SC_DLLIMPLEMENTATION
38 //------------------------------------------------------------------
40 #include "scitems.hxx"
41 #include <vcl/msgbox.hxx>
44 #include "globstr.hrc"
45 #include "uiitems.hxx"
47 #include "document.hxx"
48 #include "docoptio.hxx"
49 #include "scresid.hxx"
50 #include "sc.hrc" // -> Slot-IDs
59 // STATIC DATA -----------------------------------------------------------
61 static USHORT pCalcOptRanges
[] =
68 //========================================================================
70 ScTpCalcOptions::ScTpCalcOptions( Window
* pParent
,
71 const SfxItemSet
& rCoreAttrs
)
73 : SfxTabPage ( pParent
,
74 ScResId( RID_SCPAGE_CALC
),
77 aGbZRefs ( this, ScResId( GB_ZREFS
) ),
78 aBtnIterate ( this, ScResId( BTN_ITERATE
) ),
79 aFtSteps ( this, ScResId( FT_STEPS
) ),
80 aEdSteps ( this, ScResId( ED_STEPS
) ),
81 aFtEps ( this, ScResId( FT_EPS
) ),
82 aEdEps ( this, ScResId( ED_EPS
) ),
83 aSeparatorFL ( this, ScResId( FL_SEPARATOR
) ),
84 aGbDate ( this, ScResId( GB_DATE
) ),
85 aBtnDateStd ( this, ScResId( BTN_DATESTD
) ),
86 aBtnDateSc10 ( this, ScResId( BTN_DATESC10
) ),
87 aBtnDate1904 ( this, ScResId( BTN_DATE1904
) ),
88 aHSeparatorFL ( this, ScResId( FL_H_SEPARATOR
) ),
89 aBtnCase ( this, ScResId( BTN_CASE
) ),
90 aBtnCalc ( this, ScResId( BTN_CALC
) ),
91 aBtnMatch ( this, ScResId( BTN_MATCH
) ),
92 aBtnRegex ( this, ScResId( BTN_REGEX
) ),
93 aBtnLookUp ( this, ScResId( BTN_LOOKUP
) ),
94 aFtPrec ( this, ScResId( FT_PREC
) ),
95 aEdPrec ( this, ScResId( ED_PREC
) ),
96 pOldOptions ( new ScDocOptions(
97 ((const ScTpCalcItem
&)rCoreAttrs
.Get(
98 GetWhich( SID_SCDOCOPTIONS
))).
100 pLocalOptions ( new ScDocOptions
),
101 nWhichCalc ( GetWhich( SID_SCDOCOPTIONS
) )
103 aSeparatorFL
.SetStyle( aSeparatorFL
.GetStyle() | WB_VERT
);
106 SetExchangeSupport();
109 //-----------------------------------------------------------------------
111 __EXPORT
ScTpCalcOptions::~ScTpCalcOptions()
114 delete pLocalOptions
;
117 //-----------------------------------------------------------------------
119 void ScTpCalcOptions::Init()
121 aBtnIterate
.SetClickHdl( LINK( this, ScTpCalcOptions
, CheckClickHdl
) );
122 aBtnDateStd
.SetClickHdl( LINK( this, ScTpCalcOptions
, RadioClickHdl
) );
123 aBtnDateSc10
.SetClickHdl( LINK( this, ScTpCalcOptions
, RadioClickHdl
) );
124 aBtnDate1904
.SetClickHdl( LINK( this, ScTpCalcOptions
, RadioClickHdl
) );
127 //-----------------------------------------------------------------------
129 USHORT
* __EXPORT
ScTpCalcOptions::GetRanges()
131 return pCalcOptRanges
;
134 //-----------------------------------------------------------------------
136 SfxTabPage
* __EXPORT
ScTpCalcOptions::Create( Window
* pParent
, const SfxItemSet
& rAttrSet
)
138 return ( new ScTpCalcOptions( pParent
, rAttrSet
) );
141 //-----------------------------------------------------------------------
143 void __EXPORT
ScTpCalcOptions::Reset( const SfxItemSet
& /* rCoreAttrs */ )
147 *pLocalOptions
= *pOldOptions
;
149 aBtnCase
.Check( !pLocalOptions
->IsIgnoreCase() );
150 aBtnCalc
.Check( pLocalOptions
->IsCalcAsShown() );
151 aBtnMatch
.Check( pLocalOptions
->IsMatchWholeCell() );
152 aBtnRegex
.Check( pLocalOptions
->IsFormulaRegexEnabled() );
153 aBtnLookUp
.Check( pLocalOptions
->IsLookUpColRowNames() );
154 aBtnIterate
.Check( pLocalOptions
->IsIter() );
155 aEdSteps
.SetValue( pLocalOptions
->GetIterCount() );
156 aEdPrec
.SetValue( pLocalOptions
->GetStdPrecision() );
157 aEdEps
.SetValue( pLocalOptions
->GetIterEps(), 6 );
159 pLocalOptions
->GetDate( d
, m
, y
);
167 aBtnDateSc10
.Check();
170 aBtnDate1904
.Check();
174 CheckClickHdl( &aBtnIterate
);
178 //-----------------------------------------------------------------------
180 BOOL __EXPORT
ScTpCalcOptions::FillItemSet( SfxItemSet
& rCoreAttrs
)
182 // alle weiteren Optionen werden in den Handlern aktualisiert
183 pLocalOptions
->SetIterCount( (USHORT
)aEdSteps
.GetValue() );
184 pLocalOptions
->SetStdPrecision( (USHORT
)aEdPrec
.GetValue() );
185 pLocalOptions
->SetIgnoreCase( !aBtnCase
.IsChecked() );
186 pLocalOptions
->SetCalcAsShown( aBtnCalc
.IsChecked() );
187 pLocalOptions
->SetMatchWholeCell( aBtnMatch
.IsChecked() );
188 pLocalOptions
->SetFormulaRegexEnabled( aBtnRegex
.IsChecked() );
189 pLocalOptions
->SetLookUpColRowNames( aBtnLookUp
.IsChecked() );
191 if ( *pLocalOptions
!= *pOldOptions
)
193 rCoreAttrs
.Put( ScTpCalcItem( nWhichCalc
, *pLocalOptions
) );
200 //------------------------------------------------------------------------
202 int __EXPORT
ScTpCalcOptions::DeactivatePage( SfxItemSet
* pSetP
)
204 int nReturn
= KEEP_PAGE
;
207 if( aEdEps
.GetValue( fEps
) && (fEps
> 0.0) )
209 pLocalOptions
->SetIterEps( fEps
);
210 nReturn
= LEAVE_PAGE
;
213 if ( nReturn
== KEEP_PAGE
)
216 WinBits( WB_OK
| WB_DEF_OK
),
217 ScGlobal::GetRscString( STR_INVALID_EPS
)
223 FillItemSet( *pSetP
);
228 //-----------------------------------------------------------------------
231 IMPL_LINK( ScTpCalcOptions
, RadioClickHdl
, RadioButton
*, pBtn
)
233 if ( pBtn
== &aBtnDateStd
)
235 pLocalOptions
->SetDate( 30, 12, 1899 );
237 else if ( pBtn
== &aBtnDateSc10
)
239 pLocalOptions
->SetDate( 1, 1, 1900 );
241 else if ( pBtn
== &aBtnDate1904
)
243 pLocalOptions
->SetDate( 1, 1, 1904 );
249 //-----------------------------------------------------------------------
251 IMPL_LINK( ScTpCalcOptions
, CheckClickHdl
, CheckBox
*, pBtn
)
253 if ( pBtn
->IsChecked() )
255 pLocalOptions
->SetIter( TRUE
);
256 aFtSteps
.Enable(); aEdSteps
.Enable();
257 aFtEps
.Enable(); aEdEps
.Enable();
261 pLocalOptions
->SetIter( FALSE
);
262 aFtSteps
.Disable(); aEdSteps
.Disable();
263 aFtEps
.Disable(); aEdEps
.Disable();