1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*cde9e8dcSAndrew Rist * distributed with this work for additional information
6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*cde9e8dcSAndrew Rist *************************************************************/
21*cde9e8dcSAndrew Rist
22*cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir #include "tp_Scale.hxx"
27cdf0e10cSrcweir #include "tp_Scale.hrc"
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include "ResId.hxx"
30cdf0e10cSrcweir #include "Strings.hrc"
31cdf0e10cSrcweir #include "chartview/ChartSfxItemIds.hxx"
32cdf0e10cSrcweir #include "NoWarningThisInCTOR.hxx"
33cdf0e10cSrcweir #include "AxisHelper.hxx"
34cdf0e10cSrcweir
35cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC
36cdf0e10cSrcweir #include <svx/svxids.hrc>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <rtl/math.hxx>
39cdf0e10cSrcweir // header for class SvxDoubleItem
40cdf0e10cSrcweir #include <svx/chrtitem.hxx>
41cdf0e10cSrcweir // header for class SfxBoolItem
42cdf0e10cSrcweir #include <svl/eitem.hxx>
43cdf0e10cSrcweir // header for SfxInt32Item
44cdf0e10cSrcweir #include <svl/intitem.hxx>
45cdf0e10cSrcweir
46cdf0e10cSrcweir // header for class WarningBox
47cdf0e10cSrcweir #include <vcl/msgbox.hxx>
48cdf0e10cSrcweir
49cdf0e10cSrcweir // header for class SvNumberformat
50cdf0e10cSrcweir #ifndef _ZFORMAT_HXX
51cdf0e10cSrcweir #ifndef _ZFORLIST_DECLARE_TABLE
52cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir #include <svl/zformat.hxx>
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir
57cdf0e10cSrcweir #include <svtools/controldims.hrc>
58cdf0e10cSrcweir
59cdf0e10cSrcweir #include <com/sun/star/chart2/AxisType.hpp>
60cdf0e10cSrcweir
61cdf0e10cSrcweir using namespace ::com::sun::star;
62cdf0e10cSrcweir
63cdf0e10cSrcweir //.............................................................................
64cdf0e10cSrcweir namespace chart
65cdf0e10cSrcweir {
66cdf0e10cSrcweir //.............................................................................
67cdf0e10cSrcweir
68cdf0e10cSrcweir namespace
69cdf0e10cSrcweir {
70cdf0e10cSrcweir
lcl_placeControlAtX(Control & rControl,long nNewXPos)71cdf0e10cSrcweir void lcl_placeControlAtX( Control& rControl, long nNewXPos )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir Point aPos( rControl.GetPosPixel() );
74cdf0e10cSrcweir aPos.X() = nNewXPos;
75cdf0e10cSrcweir rControl.SetPosPixel(aPos);
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
lcl_placeControlAtY(Control & rControl,long nNewYPos)78cdf0e10cSrcweir void lcl_placeControlAtY( Control& rControl, long nNewYPos )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir Point aPos( rControl.GetPosPixel() );
81cdf0e10cSrcweir aPos.Y() = nNewYPos;
82cdf0e10cSrcweir rControl.SetPosPixel(aPos);
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
lcl_shiftControls(Control & rEdit,Control & rAuto,long nNewXPos)85cdf0e10cSrcweir void lcl_shiftControls( Control& rEdit, Control& rAuto, long nNewXPos )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir Point aPos( rEdit.GetPosPixel() );
88cdf0e10cSrcweir long nShift = nNewXPos - aPos.X();
89cdf0e10cSrcweir aPos.X() = nNewXPos;
90cdf0e10cSrcweir rEdit.SetPosPixel(aPos);
91cdf0e10cSrcweir
92cdf0e10cSrcweir aPos = rAuto.GetPosPixel();
93cdf0e10cSrcweir aPos.X() += nShift;
94cdf0e10cSrcweir rAuto.SetPosPixel(aPos);
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
lcl_getLabelDistance(Control & rControl)97cdf0e10cSrcweir long lcl_getLabelDistance( Control& rControl )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir return rControl.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, 0), MapMode(MAP_APPFONT) ).Width();
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
lcl_setValue(FormattedField & rFmtField,double fValue)102cdf0e10cSrcweir void lcl_setValue( FormattedField& rFmtField, double fValue )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir rFmtField.SetValue( fValue );
105cdf0e10cSrcweir rFmtField.SetDefaultValue( fValue );
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
108cdf0e10cSrcweir }
109cdf0e10cSrcweir
ScaleTabPage(Window * pWindow,const SfxItemSet & rInAttrs)110cdf0e10cSrcweir ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) :
111cdf0e10cSrcweir SfxTabPage(pWindow, SchResId(TP_SCALE), rInAttrs),
112cdf0e10cSrcweir
113cdf0e10cSrcweir aFlScale(this, SchResId(FL_SCALE)),
114cdf0e10cSrcweir
115cdf0e10cSrcweir aCbxReverse(this, SchResId(CBX_REVERSE)),
116cdf0e10cSrcweir aCbxLogarithm(this, SchResId(CBX_LOGARITHM)),
117cdf0e10cSrcweir
118cdf0e10cSrcweir m_aTxt_AxisType(this, SchResId (TXT_AXIS_TYPE)),
119cdf0e10cSrcweir m_aLB_AxisType(this, SchResId(LB_AXIS_TYPE)),
120cdf0e10cSrcweir
121cdf0e10cSrcweir aTxtMin (this, SchResId (TXT_MIN)),
122cdf0e10cSrcweir aFmtFldMin(this, SchResId(EDT_MIN)),
123cdf0e10cSrcweir aCbxAutoMin(this, SchResId(CBX_AUTO_MIN)),
124cdf0e10cSrcweir
125cdf0e10cSrcweir aTxtMax(this, SchResId (TXT_MAX)),
126cdf0e10cSrcweir aFmtFldMax(this, SchResId(EDT_MAX)),
127cdf0e10cSrcweir aCbxAutoMax(this, SchResId(CBX_AUTO_MAX)),
128cdf0e10cSrcweir
129cdf0e10cSrcweir m_aTxt_TimeResolution(this, SchResId (TXT_TIME_RESOLUTION)),
130cdf0e10cSrcweir m_aLB_TimeResolution(this, SchResId(LB_TIME_RESOLUTION)),
131cdf0e10cSrcweir m_aCbx_AutoTimeResolution(this, SchResId(CBX_AUTO_TIME_RESOLUTION)),
132cdf0e10cSrcweir
133cdf0e10cSrcweir aTxtMain (this, SchResId (TXT_STEP_MAIN)),
134cdf0e10cSrcweir aFmtFldStepMain(this, SchResId(EDT_STEP_MAIN)),
135cdf0e10cSrcweir m_aMt_MainDateStep(this, SchResId(MT_MAIN_DATE_STEP)),
136cdf0e10cSrcweir m_aLB_MainTimeUnit(this, SchResId(LB_MAIN_TIME_UNIT)),
137cdf0e10cSrcweir aCbxAutoStepMain(this, SchResId(CBX_AUTO_STEP_MAIN)),
138cdf0e10cSrcweir
139cdf0e10cSrcweir aTxtHelpCount (this, SchResId (TXT_STEP_HELP_COUNT)),
140cdf0e10cSrcweir aTxtHelp (this, SchResId (TXT_STEP_HELP)),
141cdf0e10cSrcweir aMtStepHelp (this, SchResId (MT_STEPHELP)),
142cdf0e10cSrcweir m_aLB_HelpTimeUnit(this, SchResId(LB_HELP_TIME_UNIT)),
143cdf0e10cSrcweir aCbxAutoStepHelp(this, SchResId(CBX_AUTO_STEP_HELP)),
144cdf0e10cSrcweir
145cdf0e10cSrcweir aTxtOrigin (this, SchResId (TXT_ORIGIN)),
146cdf0e10cSrcweir aFmtFldOrigin(this, SchResId(EDT_ORIGIN)),
147cdf0e10cSrcweir aCbxAutoOrigin(this, SchResId(CBX_AUTO_ORIGIN)),
148cdf0e10cSrcweir
149cdf0e10cSrcweir fMin(0.0),
150cdf0e10cSrcweir fMax(0.0),
151cdf0e10cSrcweir fStepMain(0.0),
152cdf0e10cSrcweir nStepHelp(0),
153cdf0e10cSrcweir fOrigin(0.0),
154cdf0e10cSrcweir m_nTimeResolution(1),
155cdf0e10cSrcweir m_nMainTimeUnit(1),
156cdf0e10cSrcweir m_nHelpTimeUnit(1),
157cdf0e10cSrcweir m_nAxisType(chart2::AxisType::REALNUMBER),
158cdf0e10cSrcweir m_bAllowDateAxis(false),
159cdf0e10cSrcweir pNumFormatter(NULL),
160cdf0e10cSrcweir m_bShowAxisOrigin(false)
161cdf0e10cSrcweir {
162cdf0e10cSrcweir FreeResource();
163cdf0e10cSrcweir SetExchangeSupport();
164cdf0e10cSrcweir
165cdf0e10cSrcweir aCbxAutoMin.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
166cdf0e10cSrcweir aCbxAutoMax.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
167cdf0e10cSrcweir aCbxAutoStepMain.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
168cdf0e10cSrcweir aCbxAutoStepHelp.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
169cdf0e10cSrcweir aCbxAutoOrigin.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
170cdf0e10cSrcweir m_aCbx_AutoTimeResolution.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
171cdf0e10cSrcweir
172cdf0e10cSrcweir m_aLB_AxisType.SetDropDownLineCount(3);
173cdf0e10cSrcweir m_aLB_AxisType.SetSelectHdl(LINK(this, ScaleTabPage, SelectAxisTypeHdl));
174cdf0e10cSrcweir
175cdf0e10cSrcweir m_aLB_TimeResolution.SetDropDownLineCount(3);
176cdf0e10cSrcweir m_aLB_MainTimeUnit.SetDropDownLineCount(3);
177cdf0e10cSrcweir m_aLB_HelpTimeUnit.SetDropDownLineCount(3);
178cdf0e10cSrcweir
179cdf0e10cSrcweir aFmtFldMin.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl));
180cdf0e10cSrcweir aFmtFldMax.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl));
181cdf0e10cSrcweir aFmtFldStepMain.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl));
182cdf0e10cSrcweir aFmtFldOrigin.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl));
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
IMPL_LINK(ScaleTabPage,FmtFieldModifiedHdl,FormattedField *,pFmtFied)185cdf0e10cSrcweir IMPL_LINK( ScaleTabPage, FmtFieldModifiedHdl, FormattedField*, pFmtFied )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir if( pFmtFied )
188cdf0e10cSrcweir pFmtFied->SetDefaultValue( pFmtFied->GetValue() );
189cdf0e10cSrcweir return 0;
190cdf0e10cSrcweir }
191cdf0e10cSrcweir
StateChanged(StateChangedType nType)192cdf0e10cSrcweir void ScaleTabPage::StateChanged( StateChangedType nType )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir TabPage::StateChanged( nType );
195cdf0e10cSrcweir
196cdf0e10cSrcweir if( nType == STATE_CHANGE_INITSHOW )
197cdf0e10cSrcweir AdjustControlPositions();
198cdf0e10cSrcweir }
199cdf0e10cSrcweir
AdjustControlPositions()200cdf0e10cSrcweir void ScaleTabPage::AdjustControlPositions()
201cdf0e10cSrcweir {
202cdf0e10cSrcweir //optimize position of the controls
203cdf0e10cSrcweir long nLabelWidth = ::std::max( aTxtMin.CalcMinimumSize().Width(), aTxtMax.CalcMinimumSize().Width() );
204cdf0e10cSrcweir nLabelWidth = ::std::max( aTxtMain.CalcMinimumSize().Width(), nLabelWidth );
205cdf0e10cSrcweir nLabelWidth = ::std::max( aTxtHelp.CalcMinimumSize().Width(), nLabelWidth );
206cdf0e10cSrcweir nLabelWidth = ::std::max( aTxtHelpCount.CalcMinimumSize().Width(), nLabelWidth );
207cdf0e10cSrcweir nLabelWidth = ::std::max( aTxtOrigin.CalcMinimumSize().Width(), nLabelWidth );
208cdf0e10cSrcweir nLabelWidth = ::std::max( m_aTxt_TimeResolution.CalcMinimumSize().Width(), nLabelWidth );
209cdf0e10cSrcweir nLabelWidth = ::std::max( m_aTxt_AxisType.CalcMinimumSize().Width(), nLabelWidth );
210cdf0e10cSrcweir nLabelWidth+=1;
211cdf0e10cSrcweir
212cdf0e10cSrcweir long nLabelDistance = lcl_getLabelDistance(aTxtMin);
213cdf0e10cSrcweir long nNewXPos = aTxtMin.GetPosPixel().X() + nLabelWidth + nLabelDistance;
214cdf0e10cSrcweir
215cdf0e10cSrcweir //ensure that the auto checkboxes are wide enough and have correct size for calculation
216cdf0e10cSrcweir aCbxAutoMin.SetSizePixel( aCbxAutoMin.CalcMinimumSize() );
217cdf0e10cSrcweir aCbxAutoMax.SetSizePixel( aCbxAutoMax.CalcMinimumSize() );
218cdf0e10cSrcweir aCbxAutoStepMain.SetSizePixel( aCbxAutoStepMain.CalcMinimumSize() );
219cdf0e10cSrcweir aCbxAutoStepHelp.SetSizePixel( aCbxAutoStepHelp.CalcMinimumSize() );
220cdf0e10cSrcweir aCbxAutoOrigin.SetSizePixel( aCbxAutoOrigin.CalcMinimumSize() );
221cdf0e10cSrcweir m_aCbx_AutoTimeResolution.SetSizePixel( m_aCbx_AutoTimeResolution.CalcMinimumSize() );
222cdf0e10cSrcweir
223cdf0e10cSrcweir //ensure new pos is ok
224cdf0e10cSrcweir long nWidthOfOtherControls = m_aLB_MainTimeUnit.GetPosPixel().X() + m_aLB_MainTimeUnit.GetSizePixel().Width() - aFmtFldMin.GetPosPixel().X();
225cdf0e10cSrcweir long nDialogWidth = GetSizePixel().Width();
226cdf0e10cSrcweir
227cdf0e10cSrcweir long nLeftSpace = nDialogWidth - nNewXPos - nWidthOfOtherControls;
228cdf0e10cSrcweir if(nLeftSpace>=0)
229cdf0e10cSrcweir {
230cdf0e10cSrcweir Size aSize( aTxtMin.GetSizePixel() );
231cdf0e10cSrcweir aSize.Width() = nLabelWidth;
232cdf0e10cSrcweir aTxtMin.SetSizePixel(aSize);
233cdf0e10cSrcweir aTxtMax.SetSizePixel(aSize);
234cdf0e10cSrcweir aTxtMain.SetSizePixel(aSize);
235cdf0e10cSrcweir aTxtHelp.SetSizePixel(aSize);
236cdf0e10cSrcweir aTxtHelpCount.SetSizePixel(aSize);
237cdf0e10cSrcweir aTxtOrigin.SetSizePixel(aSize);
238cdf0e10cSrcweir m_aTxt_TimeResolution.SetSizePixel(aSize);
239cdf0e10cSrcweir m_aTxt_AxisType.SetSizePixel(aSize);
240cdf0e10cSrcweir
241cdf0e10cSrcweir long nOrgAutoCheckX = aCbxAutoMin.GetPosPixel().X();
242cdf0e10cSrcweir lcl_placeControlAtX( aCbxAutoStepMain, nOrgAutoCheckX );
243cdf0e10cSrcweir lcl_placeControlAtX( aCbxAutoStepHelp, nOrgAutoCheckX );
244cdf0e10cSrcweir
245cdf0e10cSrcweir lcl_shiftControls( aFmtFldMin, aCbxAutoMin, nNewXPos );
246cdf0e10cSrcweir lcl_shiftControls( aFmtFldMax, aCbxAutoMax, nNewXPos );
247cdf0e10cSrcweir lcl_shiftControls( aFmtFldStepMain, aCbxAutoStepMain, nNewXPos );
248cdf0e10cSrcweir lcl_placeControlAtX( m_aMt_MainDateStep, aFmtFldStepMain.GetPosPixel().X() );
249cdf0e10cSrcweir lcl_shiftControls( aMtStepHelp, aCbxAutoStepHelp, nNewXPos );
250cdf0e10cSrcweir lcl_shiftControls( aFmtFldOrigin, aCbxAutoOrigin, nNewXPos );
251cdf0e10cSrcweir lcl_shiftControls( m_aLB_TimeResolution, m_aCbx_AutoTimeResolution, nNewXPos );
252cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_AxisType, nNewXPos );
253cdf0e10cSrcweir
254cdf0e10cSrcweir nNewXPos = aCbxAutoStepMain.GetPosPixel().X() + aCbxAutoStepMain.GetSizePixel().Width() + nLabelDistance;
255cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_MainTimeUnit, nNewXPos );
256cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_HelpTimeUnit, nNewXPos );
257cdf0e10cSrcweir }
258cdf0e10cSrcweir PlaceIntervalControlsAccordingToAxisType();
259cdf0e10cSrcweir }
260cdf0e10cSrcweir
PlaceIntervalControlsAccordingToAxisType()261cdf0e10cSrcweir void ScaleTabPage::PlaceIntervalControlsAccordingToAxisType()
262cdf0e10cSrcweir {
263cdf0e10cSrcweir long nMinX = std::min( aCbxAutoStepMain.GetPosPixel().X(), m_aLB_MainTimeUnit.GetPosPixel().X() );
264cdf0e10cSrcweir long nLabelDistance = lcl_getLabelDistance(aTxtMin);
265cdf0e10cSrcweir long nListWidth = m_aLB_MainTimeUnit.GetSizePixel().Width();
266cdf0e10cSrcweir
267cdf0e10cSrcweir if( chart2::AxisType::DATE == m_nAxisType )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_MainTimeUnit, nMinX );
270cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_HelpTimeUnit, nMinX );
271cdf0e10cSrcweir long nSecondX = nMinX + nListWidth + nLabelDistance;
272cdf0e10cSrcweir lcl_placeControlAtX( aCbxAutoStepMain, nSecondX );
273cdf0e10cSrcweir lcl_placeControlAtX( aCbxAutoStepHelp, nSecondX );
274cdf0e10cSrcweir
275cdf0e10cSrcweir long nOne = m_aMt_MainDateStep.LogicToPixel( Size(0, 1), MapMode(MAP_APPFONT) ).Height();
276cdf0e10cSrcweir
277cdf0e10cSrcweir long nYMajor = m_aMt_MainDateStep.GetPosPixel().Y();
278cdf0e10cSrcweir lcl_placeControlAtY( aCbxAutoStepMain , nYMajor+(3*nOne));
279cdf0e10cSrcweir lcl_placeControlAtY( aTxtMain , nYMajor+nOne+nOne);
280cdf0e10cSrcweir
281cdf0e10cSrcweir long nYMinor = m_aLB_HelpTimeUnit.GetPosPixel().Y();
282cdf0e10cSrcweir lcl_placeControlAtY( aMtStepHelp , nYMinor );
283cdf0e10cSrcweir lcl_placeControlAtY( aCbxAutoStepHelp , nYMinor+(3*nOne));
284cdf0e10cSrcweir }
285cdf0e10cSrcweir else
286cdf0e10cSrcweir {
287cdf0e10cSrcweir lcl_placeControlAtX( aCbxAutoStepMain, nMinX );
288cdf0e10cSrcweir lcl_placeControlAtX( aCbxAutoStepHelp, nMinX );
289cdf0e10cSrcweir long nSecondX = nMinX + aCbxAutoStepMain.GetSizePixel().Width() + nLabelDistance;
290cdf0e10cSrcweir long nSecondXMax = GetSizePixel().Width() - nListWidth;
291cdf0e10cSrcweir if( nSecondX > nSecondXMax )
292cdf0e10cSrcweir nSecondX = nSecondXMax;
293cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_MainTimeUnit, nSecondX );
294cdf0e10cSrcweir lcl_placeControlAtX( m_aLB_HelpTimeUnit, nSecondX );
295cdf0e10cSrcweir }
296cdf0e10cSrcweir }
297cdf0e10cSrcweir
EnableControls()298cdf0e10cSrcweir void ScaleTabPage::EnableControls()
299cdf0e10cSrcweir {
300cdf0e10cSrcweir bool bValueAxis = chart2::AxisType::REALNUMBER == m_nAxisType || chart2::AxisType::PERCENT == m_nAxisType || chart2::AxisType::DATE == m_nAxisType;
301cdf0e10cSrcweir bool bDateAxis = chart2::AxisType::DATE == m_nAxisType;
302cdf0e10cSrcweir
303cdf0e10cSrcweir m_aTxt_AxisType.Show(m_bAllowDateAxis);
304cdf0e10cSrcweir m_aLB_AxisType.Show(m_bAllowDateAxis);
305cdf0e10cSrcweir
306cdf0e10cSrcweir aCbxLogarithm.Show( bValueAxis && !bDateAxis );
307cdf0e10cSrcweir aTxtMin.Show( bValueAxis );
308cdf0e10cSrcweir aFmtFldMin.Show( bValueAxis );
309cdf0e10cSrcweir aCbxAutoMin.Show( bValueAxis );
310cdf0e10cSrcweir aTxtMax.Show( bValueAxis );
311cdf0e10cSrcweir aFmtFldMax.Show( bValueAxis );
312cdf0e10cSrcweir aCbxAutoMax.Show( bValueAxis );
313cdf0e10cSrcweir aTxtMain.Show( bValueAxis );
314cdf0e10cSrcweir aFmtFldStepMain.Show( bValueAxis );
315cdf0e10cSrcweir aCbxAutoStepMain.Show( bValueAxis );
316cdf0e10cSrcweir aTxtHelp.Show( bValueAxis );
317cdf0e10cSrcweir aTxtHelpCount.Show( bValueAxis );
318cdf0e10cSrcweir aMtStepHelp.Show( bValueAxis );
319cdf0e10cSrcweir aCbxAutoStepHelp.Show( bValueAxis );
320cdf0e10cSrcweir
321cdf0e10cSrcweir aTxtOrigin.Show( m_bShowAxisOrigin && bValueAxis );
322cdf0e10cSrcweir aFmtFldOrigin.Show( m_bShowAxisOrigin && bValueAxis );
323cdf0e10cSrcweir aCbxAutoOrigin.Show( m_bShowAxisOrigin && bValueAxis );
324cdf0e10cSrcweir
325cdf0e10cSrcweir aTxtHelpCount.Show( bValueAxis && !bDateAxis );
326cdf0e10cSrcweir aTxtHelp.Show( bDateAxis );
327cdf0e10cSrcweir
328cdf0e10cSrcweir m_aTxt_TimeResolution.Show( bDateAxis );
329cdf0e10cSrcweir m_aLB_TimeResolution.Show( bDateAxis );
330cdf0e10cSrcweir m_aCbx_AutoTimeResolution.Show( bDateAxis );
331cdf0e10cSrcweir
332cdf0e10cSrcweir bool bWasDateAxis = m_aMt_MainDateStep.IsVisible();
333cdf0e10cSrcweir if( bWasDateAxis != bDateAxis )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir //transport value from one to other control
336cdf0e10cSrcweir if( bWasDateAxis )
337cdf0e10cSrcweir lcl_setValue( aFmtFldStepMain, m_aMt_MainDateStep.GetValue() );
338cdf0e10cSrcweir else
339cdf0e10cSrcweir m_aMt_MainDateStep.SetValue( static_cast<sal_Int32>(aFmtFldStepMain.GetValue()) );
340cdf0e10cSrcweir }
341cdf0e10cSrcweir aFmtFldStepMain.Show( bValueAxis && !bDateAxis );
342cdf0e10cSrcweir m_aMt_MainDateStep.Show( bDateAxis );
343cdf0e10cSrcweir
344cdf0e10cSrcweir m_aLB_MainTimeUnit.Show( bDateAxis );
345cdf0e10cSrcweir m_aLB_HelpTimeUnit.Show( bDateAxis );
346cdf0e10cSrcweir
347cdf0e10cSrcweir EnableValueHdl(&aCbxAutoMin);
348cdf0e10cSrcweir EnableValueHdl(&aCbxAutoMax);
349cdf0e10cSrcweir EnableValueHdl(&aCbxAutoStepMain);
350cdf0e10cSrcweir EnableValueHdl(&aCbxAutoStepHelp);
351cdf0e10cSrcweir EnableValueHdl(&aCbxAutoOrigin);
352cdf0e10cSrcweir EnableValueHdl(&m_aCbx_AutoTimeResolution);
353cdf0e10cSrcweir }
354cdf0e10cSrcweir
IMPL_LINK(ScaleTabPage,EnableValueHdl,CheckBox *,pCbx)355cdf0e10cSrcweir IMPL_LINK( ScaleTabPage, EnableValueHdl, CheckBox *, pCbx )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir bool bEnable = pCbx && !pCbx->IsChecked() && pCbx->IsEnabled();
358cdf0e10cSrcweir if (pCbx == &aCbxAutoMin)
359cdf0e10cSrcweir {
360cdf0e10cSrcweir aFmtFldMin.Enable( bEnable );
361cdf0e10cSrcweir }
362cdf0e10cSrcweir else if (pCbx == &aCbxAutoMax)
363cdf0e10cSrcweir {
364cdf0e10cSrcweir aFmtFldMax.Enable( bEnable );
365cdf0e10cSrcweir }
366cdf0e10cSrcweir else if (pCbx == &aCbxAutoStepMain)
367cdf0e10cSrcweir {
368cdf0e10cSrcweir aFmtFldStepMain.Enable( bEnable );
369cdf0e10cSrcweir m_aMt_MainDateStep.Enable( bEnable );
370cdf0e10cSrcweir m_aLB_MainTimeUnit.Enable( bEnable );
371cdf0e10cSrcweir }
372cdf0e10cSrcweir else if (pCbx == &aCbxAutoStepHelp)
373cdf0e10cSrcweir {
374cdf0e10cSrcweir aMtStepHelp.Enable( bEnable );
375cdf0e10cSrcweir m_aLB_HelpTimeUnit.Enable( bEnable );
376cdf0e10cSrcweir }
377cdf0e10cSrcweir else if (pCbx == &m_aCbx_AutoTimeResolution)
378cdf0e10cSrcweir {
379cdf0e10cSrcweir m_aLB_TimeResolution.Enable( bEnable );
380cdf0e10cSrcweir }
381cdf0e10cSrcweir else if (pCbx == &aCbxAutoOrigin)
382cdf0e10cSrcweir {
383cdf0e10cSrcweir aFmtFldOrigin.Enable( bEnable );
384cdf0e10cSrcweir }
385cdf0e10cSrcweir return 0;
386cdf0e10cSrcweir }
387cdf0e10cSrcweir
388cdf0e10cSrcweir enum AxisTypeListBoxEntry
389cdf0e10cSrcweir {
390cdf0e10cSrcweir TYPE_AUTO=0,
391cdf0e10cSrcweir TYPE_TEXT=1,
392cdf0e10cSrcweir TYPE_DATE=2
393cdf0e10cSrcweir };
394cdf0e10cSrcweir
IMPL_LINK(ScaleTabPage,SelectAxisTypeHdl,void *,EMPTYARG)395cdf0e10cSrcweir IMPL_LINK( ScaleTabPage, SelectAxisTypeHdl, void *, EMPTYARG )
396cdf0e10cSrcweir {
397cdf0e10cSrcweir sal_uInt16 nPos = m_aLB_AxisType.GetSelectEntryPos();
398cdf0e10cSrcweir if( nPos==TYPE_DATE )
399cdf0e10cSrcweir m_nAxisType = chart2::AxisType::DATE;
400cdf0e10cSrcweir else
401cdf0e10cSrcweir m_nAxisType = chart2::AxisType::CATEGORY;
402cdf0e10cSrcweir if( chart2::AxisType::DATE == m_nAxisType )
403cdf0e10cSrcweir aCbxLogarithm.Check(false);
404cdf0e10cSrcweir EnableControls();
405cdf0e10cSrcweir PlaceIntervalControlsAccordingToAxisType();
406cdf0e10cSrcweir SetNumFormat();
407cdf0e10cSrcweir return 0;
408cdf0e10cSrcweir }
409cdf0e10cSrcweir
Create(Window * pWindow,const SfxItemSet & rOutAttrs)410cdf0e10cSrcweir SfxTabPage* ScaleTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs)
411cdf0e10cSrcweir {
412cdf0e10cSrcweir return new ScaleTabPage(pWindow, rOutAttrs);
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
FillItemSet(SfxItemSet & rOutAttrs)415cdf0e10cSrcweir sal_Bool ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs)
416cdf0e10cSrcweir {
417cdf0e10cSrcweir DBG_ASSERT( pNumFormatter, "No NumberFormatter available" );
418cdf0e10cSrcweir
419cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item(SCHATTR_AXISTYPE, m_nAxisType));
420cdf0e10cSrcweir if(m_bAllowDateAxis)
421cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_DATEAXIS, TYPE_AUTO==m_aLB_AxisType.GetSelectEntryPos()));
422cdf0e10cSrcweir
423cdf0e10cSrcweir bool bAutoScale = false;
424cdf0e10cSrcweir if( m_nAxisType==chart2::AxisType::CATEGORY )
425cdf0e10cSrcweir bAutoScale = true;//reset scaling for category charts
426cdf0e10cSrcweir
427cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MIN ,bAutoScale || aCbxAutoMin.IsChecked()));
428cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MAX ,bAutoScale || aCbxAutoMax.IsChecked()));
429cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP,bAutoScale || aCbxAutoStepHelp.IsChecked()));
430cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN ,bAutoScale || aCbxAutoOrigin.IsChecked()));
431cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_LOGARITHM ,aCbxLogarithm.IsChecked()));
432cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_REVERSE ,aCbxReverse.IsChecked()));
433cdf0e10cSrcweir rOutAttrs.Put(SvxDoubleItem(fMax , SCHATTR_AXIS_MAX));
434cdf0e10cSrcweir rOutAttrs.Put(SvxDoubleItem(fMin , SCHATTR_AXIS_MIN));
435cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_STEP_HELP, nStepHelp));
436cdf0e10cSrcweir rOutAttrs.Put(SvxDoubleItem(fOrigin , SCHATTR_AXIS_ORIGIN));
437cdf0e10cSrcweir
438cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN,bAutoScale || aCbxAutoStepMain.IsChecked()));
439cdf0e10cSrcweir rOutAttrs.Put(SvxDoubleItem(fStepMain,SCHATTR_AXIS_STEP_MAIN));
440cdf0e10cSrcweir
441cdf0e10cSrcweir rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,bAutoScale || m_aCbx_AutoTimeResolution.IsChecked()));
442cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_TIME_RESOLUTION,m_nTimeResolution));
443cdf0e10cSrcweir
444cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_MAIN_TIME_UNIT,m_nMainTimeUnit));
445cdf0e10cSrcweir rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_HELP_TIME_UNIT,m_nHelpTimeUnit));
446cdf0e10cSrcweir
447cdf0e10cSrcweir return sal_True;
448cdf0e10cSrcweir }
449cdf0e10cSrcweir
Reset(const SfxItemSet & rInAttrs)450cdf0e10cSrcweir void ScaleTabPage::Reset(const SfxItemSet& rInAttrs)
451cdf0e10cSrcweir {
452cdf0e10cSrcweir DBG_ASSERT( pNumFormatter, "No NumberFormatter available" );
453cdf0e10cSrcweir if(!pNumFormatter)
454cdf0e10cSrcweir return;
455cdf0e10cSrcweir
456cdf0e10cSrcweir const SfxPoolItem *pPoolItem = NULL;
457cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_ALLOW_DATEAXIS, sal_True, &pPoolItem) == SFX_ITEM_SET)
458cdf0e10cSrcweir m_bAllowDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue();
459cdf0e10cSrcweir m_nAxisType=chart2::AxisType::REALNUMBER;
460cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXISTYPE, sal_True, &pPoolItem) == SFX_ITEM_SET)
461cdf0e10cSrcweir m_nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue();
462cdf0e10cSrcweir if( m_nAxisType==chart2::AxisType::DATE && !m_bAllowDateAxis )
463cdf0e10cSrcweir m_nAxisType=chart2::AxisType::CATEGORY;
464cdf0e10cSrcweir if( m_bAllowDateAxis )
465cdf0e10cSrcweir {
466cdf0e10cSrcweir bool bAutoDateAxis = false;
467cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_DATEAXIS, sal_True, &pPoolItem) == SFX_ITEM_SET)
468cdf0e10cSrcweir bAutoDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue();
469cdf0e10cSrcweir
470cdf0e10cSrcweir sal_uInt16 nPos = 0;
471cdf0e10cSrcweir if( m_nAxisType==chart2::AxisType::DATE )
472cdf0e10cSrcweir nPos=TYPE_DATE;
473cdf0e10cSrcweir else if( bAutoDateAxis )
474cdf0e10cSrcweir nPos=TYPE_AUTO;
475cdf0e10cSrcweir else
476cdf0e10cSrcweir nPos=TYPE_TEXT;
477cdf0e10cSrcweir m_aLB_AxisType.SelectEntryPos( nPos );
478cdf0e10cSrcweir }
479cdf0e10cSrcweir
480cdf0e10cSrcweir if( m_bAllowDateAxis )
481cdf0e10cSrcweir aCbxReverse.SetHelpId("chart2:CheckBox:TP_SCALE:CBX_REVERSE:MayBeDateAxis");
482cdf0e10cSrcweir else if( m_nAxisType==chart2::AxisType::CATEGORY || m_nAxisType==chart2::AxisType::SERIES )
483cdf0e10cSrcweir aCbxReverse.SetHelpId("chart2:CheckBox:TP_SCALE:CBX_REVERSE:Category");
484cdf0e10cSrcweir
485cdf0e10cSrcweir PlaceIntervalControlsAccordingToAxisType();
486cdf0e10cSrcweir
487cdf0e10cSrcweir aCbxAutoMin.Check( true );
488cdf0e10cSrcweir aCbxAutoMax.Check( true );
489cdf0e10cSrcweir aCbxAutoStepMain.Check( true );
490cdf0e10cSrcweir aCbxAutoStepHelp.Check( true );
491cdf0e10cSrcweir aCbxAutoOrigin.Check( true );
492cdf0e10cSrcweir m_aCbx_AutoTimeResolution.Check( true );
493cdf0e10cSrcweir
494cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MIN,sal_True,&pPoolItem) == SFX_ITEM_SET)
495cdf0e10cSrcweir aCbxAutoMin.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
496cdf0e10cSrcweir
497cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_MIN,sal_True, &pPoolItem) == SFX_ITEM_SET)
498cdf0e10cSrcweir {
499cdf0e10cSrcweir fMin = ((const SvxDoubleItem*)pPoolItem)->GetValue();
500cdf0e10cSrcweir lcl_setValue( aFmtFldMin, fMin );
501cdf0e10cSrcweir }
502cdf0e10cSrcweir
503cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MAX,sal_True, &pPoolItem) == SFX_ITEM_SET)
504cdf0e10cSrcweir aCbxAutoMax.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
505cdf0e10cSrcweir
506cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_MAX,sal_True, &pPoolItem) == SFX_ITEM_SET)
507cdf0e10cSrcweir {
508cdf0e10cSrcweir fMax = ((const SvxDoubleItem*)pPoolItem)->GetValue();
509cdf0e10cSrcweir lcl_setValue( aFmtFldMax, fMax );
510cdf0e10cSrcweir }
511cdf0e10cSrcweir
512cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_MAIN,sal_True, &pPoolItem) == SFX_ITEM_SET)
513cdf0e10cSrcweir aCbxAutoStepMain.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
514cdf0e10cSrcweir
515cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_MAIN,sal_True, &pPoolItem) == SFX_ITEM_SET)
516cdf0e10cSrcweir {
517cdf0e10cSrcweir fStepMain = ((const SvxDoubleItem*)pPoolItem)->GetValue();
518cdf0e10cSrcweir lcl_setValue( aFmtFldStepMain, fStepMain );
519cdf0e10cSrcweir m_aMt_MainDateStep.SetValue( static_cast<sal_Int32>(fStepMain) );
520cdf0e10cSrcweir }
521cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,sal_True, &pPoolItem) == SFX_ITEM_SET)
522cdf0e10cSrcweir aCbxAutoStepHelp.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
523cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_LOGARITHM,sal_True, &pPoolItem) == SFX_ITEM_SET)
524cdf0e10cSrcweir aCbxLogarithm.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
525cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_REVERSE,sal_True, &pPoolItem) == SFX_ITEM_SET)
526cdf0e10cSrcweir aCbxReverse.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
527cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_HELP,sal_True, &pPoolItem) == SFX_ITEM_SET)
528cdf0e10cSrcweir {
529cdf0e10cSrcweir nStepHelp = ((const SfxInt32Item*)pPoolItem)->GetValue();
530cdf0e10cSrcweir aMtStepHelp.SetValue( nStepHelp );
531cdf0e10cSrcweir }
532cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_ORIGIN,sal_True, &pPoolItem) == SFX_ITEM_SET)
533cdf0e10cSrcweir aCbxAutoOrigin.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
534cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_ORIGIN,sal_True, &pPoolItem) == SFX_ITEM_SET)
535cdf0e10cSrcweir {
536cdf0e10cSrcweir fOrigin = ((const SvxDoubleItem*)pPoolItem)->GetValue();
537cdf0e10cSrcweir lcl_setValue( aFmtFldOrigin, fOrigin );
538cdf0e10cSrcweir }
539cdf0e10cSrcweir
540cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,sal_True, &pPoolItem) == SFX_ITEM_SET)
541cdf0e10cSrcweir m_aCbx_AutoTimeResolution.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
542cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_TIME_RESOLUTION,sal_True, &pPoolItem) == SFX_ITEM_SET)
543cdf0e10cSrcweir {
544cdf0e10cSrcweir m_nTimeResolution = ((const SfxInt32Item*)pPoolItem)->GetValue();
545cdf0e10cSrcweir m_aLB_TimeResolution.SelectEntryPos( m_nTimeResolution );
546cdf0e10cSrcweir }
547cdf0e10cSrcweir
548cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_MAIN_TIME_UNIT,sal_True, &pPoolItem) == SFX_ITEM_SET)
549cdf0e10cSrcweir {
550cdf0e10cSrcweir m_nMainTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue();
551cdf0e10cSrcweir m_aLB_MainTimeUnit.SelectEntryPos( m_nMainTimeUnit );
552cdf0e10cSrcweir }
553cdf0e10cSrcweir if (rInAttrs.GetItemState(SCHATTR_AXIS_HELP_TIME_UNIT,sal_True, &pPoolItem) == SFX_ITEM_SET)
554cdf0e10cSrcweir {
555cdf0e10cSrcweir m_nHelpTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue();
556cdf0e10cSrcweir m_aLB_HelpTimeUnit.SelectEntryPos( m_nHelpTimeUnit );
557cdf0e10cSrcweir }
558cdf0e10cSrcweir
559cdf0e10cSrcweir EnableControls();
560cdf0e10cSrcweir SetNumFormat();
561cdf0e10cSrcweir }
562cdf0e10cSrcweir
DeactivatePage(SfxItemSet * pItemSet)563cdf0e10cSrcweir int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet)
564cdf0e10cSrcweir {
565cdf0e10cSrcweir if( !pNumFormatter )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir DBG_ERROR( "No NumberFormatter available" );
568cdf0e10cSrcweir return LEAVE_PAGE;
569cdf0e10cSrcweir }
570cdf0e10cSrcweir
571cdf0e10cSrcweir bool bDateAxis = chart2::AxisType::DATE == m_nAxisType;
572cdf0e10cSrcweir
573cdf0e10cSrcweir sal_uInt32 nIndex = pNumFormatter->GetStandardIndex(LANGUAGE_SYSTEM);
574cdf0e10cSrcweir const SfxPoolItem *pPoolItem = NULL;
575cdf0e10cSrcweir if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, sal_True, &pPoolItem ) == SFX_ITEM_SET )
576cdf0e10cSrcweir nIndex = static_cast< sal_uInt32 >( static_cast< const SfxInt32Item* >(pPoolItem)->GetValue());
577cdf0e10cSrcweir else
578cdf0e10cSrcweir {
579cdf0e10cSrcweir OSL_ENSURE( false, "Using Standard Language" );
580cdf0e10cSrcweir }
581cdf0e10cSrcweir
582cdf0e10cSrcweir Control* pControl = NULL;
583cdf0e10cSrcweir sal_uInt16 nErrStrId = 0;
584cdf0e10cSrcweir double fDummy;
585cdf0e10cSrcweir
586cdf0e10cSrcweir fMax = aFmtFldMax.GetValue();
587cdf0e10cSrcweir fMin = aFmtFldMin.GetValue();
588cdf0e10cSrcweir fOrigin = aFmtFldOrigin.GetValue();
589cdf0e10cSrcweir fStepMain = bDateAxis ? m_aMt_MainDateStep.GetValue() : aFmtFldStepMain.GetValue();
590cdf0e10cSrcweir nStepHelp = static_cast< sal_Int32 >( aMtStepHelp.GetValue());
591cdf0e10cSrcweir m_nTimeResolution = m_aLB_TimeResolution.GetSelectEntryPos();
592cdf0e10cSrcweir m_nMainTimeUnit = m_aLB_MainTimeUnit.GetSelectEntryPos();
593cdf0e10cSrcweir m_nHelpTimeUnit = m_aLB_HelpTimeUnit.GetSelectEntryPos();
594cdf0e10cSrcweir
595cdf0e10cSrcweir if( chart2::AxisType::REALNUMBER != m_nAxisType )
596cdf0e10cSrcweir aCbxLogarithm.Show( false );
597cdf0e10cSrcweir
598cdf0e10cSrcweir //check wich entries need user action
599cdf0e10cSrcweir
600cdf0e10cSrcweir if ( aCbxLogarithm.IsChecked() &&
601cdf0e10cSrcweir ( ( !aCbxAutoMin.IsChecked() && fMin <= 0.0 )
602cdf0e10cSrcweir || ( !aCbxAutoMax.IsChecked() && fMax <= 0.0 ) ) )
603cdf0e10cSrcweir {
604cdf0e10cSrcweir pControl = &aFmtFldMin;
605cdf0e10cSrcweir nErrStrId = STR_BAD_LOGARITHM;
606cdf0e10cSrcweir }
607cdf0e10cSrcweir else if (!aCbxAutoMax.IsChecked() && !aCbxAutoMin.IsChecked() &&
608cdf0e10cSrcweir fMin >= fMax)
609cdf0e10cSrcweir {
610cdf0e10cSrcweir pControl = &aFmtFldMin;
611cdf0e10cSrcweir nErrStrId = STR_MIN_GREATER_MAX;
612cdf0e10cSrcweir }
613cdf0e10cSrcweir else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0)
614cdf0e10cSrcweir {
615cdf0e10cSrcweir pControl = &aFmtFldStepMain;
616cdf0e10cSrcweir nErrStrId = STR_STEP_GT_ZERO;
617cdf0e10cSrcweir }
618cdf0e10cSrcweir // check for entries that cannot be parsed for the current number format
619cdf0e10cSrcweir else if ( aFmtFldMin.IsModified()
620cdf0e10cSrcweir && !aCbxAutoMin.IsChecked()
621cdf0e10cSrcweir && !pNumFormatter->IsNumberFormat(aFmtFldMin.GetText(), nIndex, fDummy))
622cdf0e10cSrcweir {
623cdf0e10cSrcweir pControl = &aFmtFldMin;
624cdf0e10cSrcweir nErrStrId = STR_INVALID_NUMBER;
625cdf0e10cSrcweir }
626cdf0e10cSrcweir else if (aFmtFldMax.IsModified() && !aCbxAutoMax.IsChecked() &&
627cdf0e10cSrcweir !pNumFormatter->IsNumberFormat(aFmtFldMax.GetText(),
628cdf0e10cSrcweir nIndex, fDummy))
629cdf0e10cSrcweir {
630cdf0e10cSrcweir pControl = &aFmtFldMax;
631cdf0e10cSrcweir nErrStrId = STR_INVALID_NUMBER;
632cdf0e10cSrcweir }
633cdf0e10cSrcweir else if ( !bDateAxis && aFmtFldStepMain.IsModified() && !aCbxAutoStepMain.IsChecked() &&
634cdf0e10cSrcweir !pNumFormatter->IsNumberFormat(aFmtFldStepMain.GetText(),
635cdf0e10cSrcweir nIndex, fDummy))
636cdf0e10cSrcweir {
637cdf0e10cSrcweir pControl = &aFmtFldStepMain;
638cdf0e10cSrcweir nErrStrId = STR_STEP_GT_ZERO;
639cdf0e10cSrcweir }
640cdf0e10cSrcweir else if (aFmtFldOrigin.IsModified() && !aCbxAutoOrigin.IsChecked() &&
641cdf0e10cSrcweir !pNumFormatter->IsNumberFormat(aFmtFldOrigin.GetText(),
642cdf0e10cSrcweir nIndex, fDummy))
643cdf0e10cSrcweir {
644cdf0e10cSrcweir pControl = &aFmtFldOrigin;
645cdf0e10cSrcweir nErrStrId = STR_INVALID_NUMBER;
646cdf0e10cSrcweir }
647cdf0e10cSrcweir else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0.0)
648cdf0e10cSrcweir {
649cdf0e10cSrcweir pControl = &aFmtFldStepMain;
650cdf0e10cSrcweir nErrStrId = STR_STEP_GT_ZERO;
651cdf0e10cSrcweir }
652cdf0e10cSrcweir else if( bDateAxis )
653cdf0e10cSrcweir {
654cdf0e10cSrcweir if( !aCbxAutoStepMain.IsChecked() && !aCbxAutoStepHelp.IsChecked() )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir if( m_nHelpTimeUnit > m_nMainTimeUnit )
657cdf0e10cSrcweir {
658cdf0e10cSrcweir pControl = &m_aLB_MainTimeUnit;
659cdf0e10cSrcweir nErrStrId = STR_INVALID_INTERVALS;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir else if( m_nHelpTimeUnit == m_nMainTimeUnit && nStepHelp > fStepMain )
662cdf0e10cSrcweir {
663cdf0e10cSrcweir pControl = &m_aLB_MainTimeUnit;
664cdf0e10cSrcweir nErrStrId = STR_INVALID_INTERVALS;
665cdf0e10cSrcweir }
666cdf0e10cSrcweir }
667cdf0e10cSrcweir if( !nErrStrId && !m_aCbx_AutoTimeResolution.IsChecked() )
668cdf0e10cSrcweir {
669cdf0e10cSrcweir if( (!aCbxAutoStepMain.IsChecked() && m_nTimeResolution > m_nMainTimeUnit )
670cdf0e10cSrcweir ||
671cdf0e10cSrcweir (!aCbxAutoStepHelp.IsChecked() && m_nTimeResolution > m_nHelpTimeUnit )
672cdf0e10cSrcweir )
673cdf0e10cSrcweir {
674cdf0e10cSrcweir pControl = &m_aLB_TimeResolution;
675cdf0e10cSrcweir nErrStrId = STR_INVALID_TIME_UNIT;
676cdf0e10cSrcweir }
677cdf0e10cSrcweir }
678cdf0e10cSrcweir }
679cdf0e10cSrcweir
680cdf0e10cSrcweir if( ShowWarning( nErrStrId, pControl ) )
681cdf0e10cSrcweir return KEEP_PAGE;
682cdf0e10cSrcweir
683cdf0e10cSrcweir if( pItemSet )
684cdf0e10cSrcweir FillItemSet( *pItemSet );
685cdf0e10cSrcweir
686cdf0e10cSrcweir return LEAVE_PAGE;
687cdf0e10cSrcweir }
688cdf0e10cSrcweir
SetNumFormatter(SvNumberFormatter * pFormatter)689cdf0e10cSrcweir void ScaleTabPage::SetNumFormatter( SvNumberFormatter* pFormatter )
690cdf0e10cSrcweir {
691cdf0e10cSrcweir pNumFormatter = pFormatter;
692cdf0e10cSrcweir aFmtFldMax.SetFormatter( pNumFormatter );
693cdf0e10cSrcweir aFmtFldMin.SetFormatter( pNumFormatter );
694cdf0e10cSrcweir aFmtFldStepMain.SetFormatter( pNumFormatter );
695cdf0e10cSrcweir aFmtFldOrigin.SetFormatter( pNumFormatter );
696cdf0e10cSrcweir
697cdf0e10cSrcweir // #101318#, #i6278# allow more decimal places than the output format. As
698cdf0e10cSrcweir // the numbers shown in the edit fields are used for input, it makes more
699cdf0e10cSrcweir // sense to display the values in the input format rather than the output
700cdf0e10cSrcweir // format.
701cdf0e10cSrcweir aFmtFldMax.UseInputStringForFormatting();
702cdf0e10cSrcweir aFmtFldMin.UseInputStringForFormatting();
703cdf0e10cSrcweir aFmtFldStepMain.UseInputStringForFormatting();
704cdf0e10cSrcweir aFmtFldOrigin.UseInputStringForFormatting();
705cdf0e10cSrcweir
706cdf0e10cSrcweir SetNumFormat();
707cdf0e10cSrcweir }
708cdf0e10cSrcweir
SetNumFormat()709cdf0e10cSrcweir void ScaleTabPage::SetNumFormat()
710cdf0e10cSrcweir {
711cdf0e10cSrcweir const SfxPoolItem *pPoolItem = NULL;
712cdf0e10cSrcweir
713cdf0e10cSrcweir if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, sal_True, &pPoolItem ) == SFX_ITEM_SET )
714cdf0e10cSrcweir {
715cdf0e10cSrcweir sal_uLong nFmt = (sal_uLong)((const SfxInt32Item*)pPoolItem)->GetValue();
716cdf0e10cSrcweir
717cdf0e10cSrcweir aFmtFldMax.SetFormatKey( nFmt );
718cdf0e10cSrcweir aFmtFldMin.SetFormatKey( nFmt );
719cdf0e10cSrcweir aFmtFldOrigin.SetFormatKey( nFmt );
720cdf0e10cSrcweir
721cdf0e10cSrcweir if( pNumFormatter )
722cdf0e10cSrcweir {
723cdf0e10cSrcweir short eType = pNumFormatter->GetType( nFmt );
724cdf0e10cSrcweir if( eType == NUMBERFORMAT_DATE )
725cdf0e10cSrcweir {
726cdf0e10cSrcweir // for intervals use standard format for dates (so you can enter a number of days)
727cdf0e10cSrcweir const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt );
728cdf0e10cSrcweir if( pFormat )
729cdf0e10cSrcweir nFmt = pNumFormatter->GetStandardIndex( pFormat->GetLanguage());
730cdf0e10cSrcweir else
731cdf0e10cSrcweir nFmt = pNumFormatter->GetStandardIndex();
732cdf0e10cSrcweir }
733cdf0e10cSrcweir else if( eType == NUMBERFORMAT_DATETIME )
734cdf0e10cSrcweir {
735cdf0e10cSrcweir // for intervals use time format for date times
736cdf0e10cSrcweir const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt );
737cdf0e10cSrcweir if( pFormat )
738cdf0e10cSrcweir nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_TIME, pFormat->GetLanguage() );
739cdf0e10cSrcweir else
740cdf0e10cSrcweir nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_TIME );
741cdf0e10cSrcweir }
742cdf0e10cSrcweir
743cdf0e10cSrcweir if( chart2::AxisType::DATE == m_nAxisType && ( eType != NUMBERFORMAT_DATE && eType != NUMBERFORMAT_DATETIME) )
744cdf0e10cSrcweir {
745cdf0e10cSrcweir const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt );
746cdf0e10cSrcweir if( pFormat )
747cdf0e10cSrcweir nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATE, pFormat->GetLanguage() );
748cdf0e10cSrcweir else
749cdf0e10cSrcweir nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATE );
750cdf0e10cSrcweir
751cdf0e10cSrcweir aFmtFldMax.SetFormatKey( nFmt );
752cdf0e10cSrcweir aFmtFldMin.SetFormatKey( nFmt );
753cdf0e10cSrcweir aFmtFldOrigin.SetFormatKey( nFmt );
754cdf0e10cSrcweir }
755cdf0e10cSrcweir }
756cdf0e10cSrcweir
757cdf0e10cSrcweir aFmtFldStepMain.SetFormatKey( nFmt );
758cdf0e10cSrcweir }
759cdf0e10cSrcweir }
760cdf0e10cSrcweir
ShowAxisOrigin(bool bShowOrigin)761cdf0e10cSrcweir void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin )
762cdf0e10cSrcweir {
763cdf0e10cSrcweir m_bShowAxisOrigin = bShowOrigin;
764cdf0e10cSrcweir if( !AxisHelper::isAxisPositioningEnabled() )
765cdf0e10cSrcweir m_bShowAxisOrigin = true;
766cdf0e10cSrcweir }
767cdf0e10cSrcweir
ShowWarning(sal_uInt16 nResIdMessage,Control * pControl)768cdf0e10cSrcweir bool ScaleTabPage::ShowWarning( sal_uInt16 nResIdMessage, Control* pControl /* = NULL */ )
769cdf0e10cSrcweir {
770cdf0e10cSrcweir if( nResIdMessage == 0 )
771cdf0e10cSrcweir return false;
772cdf0e10cSrcweir
773cdf0e10cSrcweir WarningBox( this, WinBits( WB_OK ), String( SchResId( nResIdMessage ))).Execute();
774cdf0e10cSrcweir if( pControl )
775cdf0e10cSrcweir {
776cdf0e10cSrcweir pControl->GrabFocus();
777cdf0e10cSrcweir Edit* pEdit = dynamic_cast<Edit*>(pControl);
778cdf0e10cSrcweir if(pEdit)
779cdf0e10cSrcweir pEdit->SetSelection( Selection( 0, SELECTION_MAX ));
780cdf0e10cSrcweir }
781cdf0e10cSrcweir return true;
782cdf0e10cSrcweir }
783cdf0e10cSrcweir
784cdf0e10cSrcweir //.............................................................................
785cdf0e10cSrcweir } //namespace chart
786cdf0e10cSrcweir //.............................................................................
787