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 #include "tp_Scale.hxx"
23 #include "Strings.hrc"
24 #include "chartview/ChartSfxItemIds.hxx"
25 #include "AxisHelper.hxx"
27 #include <svx/svxids.hrc>
28 #include <rtl/math.hxx>
29 #include <svx/chrtitem.hxx>
30 #include <svl/eitem.hxx>
31 #include <svl/intitem.hxx>
32 #include <vcl/msgbox.hxx>
33 #include <svl/zformat.hxx>
34 #include <svtools/controldims.hrc>
36 #include <com/sun/star/chart2/AxisType.hpp>
38 using namespace ::com::sun::star
;
46 void lcl_setValue( FormattedField
& rFmtField
, double fValue
)
48 rFmtField
.SetValue( fValue
);
49 rFmtField
.SetDefaultValue( fValue
);
54 ScaleTabPage::ScaleTabPage(vcl::Window
* pWindow
,const SfxItemSet
& rInAttrs
) :
57 , "modules/schart/ui/tp_Scale.ui"
67 m_nAxisType(chart2::AxisType::REALNUMBER
),
68 m_bAllowDateAxis(false),
70 m_bShowAxisOrigin(false)
72 get(m_pCbxReverse
, "CBX_REVERSE");
73 get(m_pCbxLogarithm
, "CBX_LOGARITHM");
74 get(m_pLB_AxisType
, "LB_AXIS_TYPE");
75 get(m_pBxType
,"boxTYPE");
77 get(m_pBxMinMax
, "gridMINMAX");
78 get(m_pFmtFldMin
, "EDT_MIN");
79 get(m_pCbxAutoMin
, "CBX_AUTO_MIN");
80 get(m_pFmtFldMax
, "EDT_MAX");
81 get(m_pCbxAutoMax
, "CBX_AUTO_MAX");
83 get(m_pBxResolution
, "boxRESOLUTION");
84 get(m_pLB_TimeResolution
, "LB_TIME_RESOLUTION");
85 get(m_pCbx_AutoTimeResolution
, "CBX_AUTO_TIME_RESOLUTION");
87 get(m_pTxtMain
, "TXT_STEP_MAIN");
88 get(m_pFmtFldStepMain
, "EDT_STEP_MAIN");
89 get(m_pMt_MainDateStep
, "MT_MAIN_DATE_STEP");
90 get(m_pLB_MainTimeUnit
, "LB_MAIN_TIME_UNIT");
91 get(m_pCbxAutoStepMain
, "CBX_AUTO_STEP_MAIN");
93 get(m_pMtStepHelp
, "MT_STEPHELP");
94 get(m_pLB_HelpTimeUnit
, "LB_HELP_TIME_UNIT");
95 get(m_pCbxAutoStepHelp
, "CBX_AUTO_STEP_HELP");
96 get(m_pTxtHelpCount
,"TXT_STEP_HELP_COUNT");
97 get(m_pTxtHelp
,"TXT_STEP_HELP");
99 get(m_pBxOrigin
,"boxORIGIN");
100 get(m_pFmtFldOrigin
, "EDT_ORIGIN");
101 get(m_pCbxAutoOrigin
, "CBX_AUTO_ORIGIN");
103 m_pCbxAutoMin
->SetClickHdl(LINK(this, ScaleTabPage
, EnableValueHdl
));
104 m_pCbxAutoMax
->SetClickHdl(LINK(this, ScaleTabPage
, EnableValueHdl
));
105 m_pCbxAutoStepMain
->SetClickHdl(LINK(this, ScaleTabPage
, EnableValueHdl
));
106 m_pCbxAutoStepHelp
->SetClickHdl(LINK(this, ScaleTabPage
, EnableValueHdl
));
107 m_pCbxAutoOrigin
->SetClickHdl(LINK(this, ScaleTabPage
, EnableValueHdl
));
108 m_pCbx_AutoTimeResolution
->SetClickHdl(LINK(this, ScaleTabPage
, EnableValueHdl
));
110 m_pLB_AxisType
->SetDropDownLineCount(3);
111 m_pLB_AxisType
->SetSelectHdl(LINK(this, ScaleTabPage
, SelectAxisTypeHdl
));
113 m_pLB_TimeResolution
->SetDropDownLineCount(3);
114 m_pLB_MainTimeUnit
->SetDropDownLineCount(3);
115 m_pLB_HelpTimeUnit
->SetDropDownLineCount(3);
117 m_pFmtFldMin
->SetModifyHdl(LINK(this, ScaleTabPage
, FmtFieldModifiedHdl
));
118 m_pFmtFldMax
->SetModifyHdl(LINK(this, ScaleTabPage
, FmtFieldModifiedHdl
));
119 m_pFmtFldStepMain
->SetModifyHdl(LINK(this, ScaleTabPage
, FmtFieldModifiedHdl
));
120 m_pFmtFldOrigin
->SetModifyHdl(LINK(this, ScaleTabPage
, FmtFieldModifiedHdl
));
125 ScaleTabPage::~ScaleTabPage()
130 void ScaleTabPage::dispose()
132 m_pCbxReverse
.clear();
133 m_pCbxLogarithm
.clear();
135 m_pLB_AxisType
.clear();
137 m_pFmtFldMin
.clear();
138 m_pCbxAutoMin
.clear();
139 m_pFmtFldMax
.clear();
140 m_pCbxAutoMax
.clear();
141 m_pBxResolution
.clear();
142 m_pLB_TimeResolution
.clear();
143 m_pCbx_AutoTimeResolution
.clear();
145 m_pFmtFldStepMain
.clear();
146 m_pMt_MainDateStep
.clear();
147 m_pLB_MainTimeUnit
.clear();
148 m_pCbxAutoStepMain
.clear();
149 m_pTxtHelpCount
.clear();
151 m_pMtStepHelp
.clear();
152 m_pLB_HelpTimeUnit
.clear();
153 m_pCbxAutoStepHelp
.clear();
154 m_pFmtFldOrigin
.clear();
155 m_pCbxAutoOrigin
.clear();
157 SfxTabPage::dispose();
161 ScaleTabPage
, FmtFieldModifiedHdl
, FormattedField
*, pFmtFied
)
164 pFmtFied
->SetDefaultValue( pFmtFied
->GetValue() );
168 void ScaleTabPage::StateChanged( StateChangedType nType
)
170 TabPage::StateChanged( nType
);
173 void ScaleTabPage::EnableControls()
175 bool bValueAxis
= chart2::AxisType::REALNUMBER
== m_nAxisType
176 || chart2::AxisType::PERCENT
== m_nAxisType
177 || chart2::AxisType::DATE
== m_nAxisType
;
178 bool bDateAxis
= chart2::AxisType::DATE
== m_nAxisType
;
180 m_pBxType
->Show(m_bAllowDateAxis
);
182 m_pCbxLogarithm
->Show( bValueAxis
&& !bDateAxis
);
184 m_pBxMinMax
->Show(bValueAxis
);
186 m_pTxtMain
->Show( bValueAxis
);
187 m_pCbxAutoStepMain
->Show( bValueAxis
);
189 m_pTxtHelpCount
->Show( bValueAxis
&& !bDateAxis
);
190 m_pTxtHelp
->Show( bDateAxis
);
191 m_pMtStepHelp
->Show( bValueAxis
);
192 m_pCbxAutoStepHelp
->Show( bValueAxis
);
194 m_pBxOrigin
->Show( m_bShowAxisOrigin
&& bValueAxis
);
195 m_pBxResolution
->Show( bDateAxis
);
197 bool bWasDateAxis
= m_pMt_MainDateStep
->IsVisible();
198 if( bWasDateAxis
!= bDateAxis
)
200 //transport value from one to other control
202 lcl_setValue( *m_pFmtFldStepMain
, m_pMt_MainDateStep
->GetValue() );
204 m_pMt_MainDateStep
->SetValue( static_cast<sal_Int32
>(m_pFmtFldStepMain
->GetValue()) );
207 m_pFmtFldStepMain
->Show( bValueAxis
&& !bDateAxis
);
208 m_pMt_MainDateStep
->Show( bDateAxis
);
210 m_pLB_MainTimeUnit
->Show( bDateAxis
);
211 m_pLB_HelpTimeUnit
->Show( bDateAxis
);
213 EnableValueHdl(m_pCbxAutoMin
);
214 EnableValueHdl(m_pCbxAutoMax
);
215 EnableValueHdl(m_pCbxAutoStepMain
);
216 EnableValueHdl(m_pCbxAutoStepHelp
);
217 EnableValueHdl(m_pCbxAutoOrigin
);
218 EnableValueHdl(m_pCbx_AutoTimeResolution
);
221 IMPL_LINK( ScaleTabPage
, EnableValueHdl
, CheckBox
*, pCbx
)
223 bool bEnable
= pCbx
&& !pCbx
->IsChecked() && pCbx
->IsEnabled();
224 if (pCbx
== m_pCbxAutoMin
)
226 m_pFmtFldMin
->Enable( bEnable
);
228 else if (pCbx
== m_pCbxAutoMax
)
230 m_pFmtFldMax
->Enable( bEnable
);
232 else if (pCbx
== m_pCbxAutoStepMain
)
234 m_pFmtFldStepMain
->Enable( bEnable
);
235 m_pMt_MainDateStep
->Enable( bEnable
);
236 m_pLB_MainTimeUnit
->Enable( bEnable
);
238 else if (pCbx
== m_pCbxAutoStepHelp
)
240 m_pMtStepHelp
->Enable( bEnable
);
241 m_pLB_HelpTimeUnit
->Enable( bEnable
);
243 else if (pCbx
== m_pCbx_AutoTimeResolution
)
245 m_pLB_TimeResolution
->Enable( bEnable
);
247 else if (pCbx
== m_pCbxAutoOrigin
)
249 m_pFmtFldOrigin
->Enable( bEnable
);
254 enum AxisTypeListBoxEntry
261 IMPL_LINK_NOARG(ScaleTabPage
, SelectAxisTypeHdl
)
263 sal_uInt16 nPos
= m_pLB_AxisType
->GetSelectEntryPos();
264 if( nPos
==TYPE_DATE
)
265 m_nAxisType
= chart2::AxisType::DATE
;
267 m_nAxisType
= chart2::AxisType::CATEGORY
;
268 if( chart2::AxisType::DATE
== m_nAxisType
)
269 m_pCbxLogarithm
->Check(false);
275 VclPtr
<SfxTabPage
> ScaleTabPage::Create(vcl::Window
* pWindow
,const SfxItemSet
* rOutAttrs
)
277 return VclPtr
<ScaleTabPage
>::Create(pWindow
, *rOutAttrs
);
280 bool ScaleTabPage::FillItemSet(SfxItemSet
* rOutAttrs
)
282 OSL_PRECOND( pNumFormatter
, "No NumberFormatter available" );
284 rOutAttrs
->Put(SfxInt32Item(SCHATTR_AXISTYPE
, m_nAxisType
));
286 rOutAttrs
->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_DATEAXIS
, TYPE_AUTO
==m_pLB_AxisType
->GetSelectEntryPos()));
288 bool bAutoScale
= false;
289 if( m_nAxisType
==chart2::AxisType::CATEGORY
)
290 bAutoScale
= true;//reset scaling for category charts
292 rOutAttrs
->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MIN
,bAutoScale
|| m_pCbxAutoMin
->IsChecked()));
293 rOutAttrs
->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MAX
,bAutoScale
|| m_pCbxAutoMax
->IsChecked()));
294 rOutAttrs
->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP
,bAutoScale
|| m_pCbxAutoStepHelp
->IsChecked()));
295 rOutAttrs
->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN
,bAutoScale
|| m_pCbxAutoOrigin
->IsChecked()));
296 rOutAttrs
->Put(SfxBoolItem(SCHATTR_AXIS_LOGARITHM
,m_pCbxLogarithm
->IsChecked()));
297 rOutAttrs
->Put(SfxBoolItem(SCHATTR_AXIS_REVERSE
,m_pCbxReverse
->IsChecked()));
298 rOutAttrs
->Put(SvxDoubleItem(fMax
, SCHATTR_AXIS_MAX
));
299 rOutAttrs
->Put(SvxDoubleItem(fMin
, SCHATTR_AXIS_MIN
));
300 rOutAttrs
->Put(SfxInt32Item(SCHATTR_AXIS_STEP_HELP
, nStepHelp
));
301 rOutAttrs
->Put(SvxDoubleItem(fOrigin
, SCHATTR_AXIS_ORIGIN
));
303 rOutAttrs
->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN
,bAutoScale
|| m_pCbxAutoStepMain
->IsChecked()));
304 rOutAttrs
->Put(SvxDoubleItem(fStepMain
,SCHATTR_AXIS_STEP_MAIN
));
306 rOutAttrs
->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_TIME_RESOLUTION
,bAutoScale
|| m_pCbx_AutoTimeResolution
->IsChecked()));
307 rOutAttrs
->Put(SfxInt32Item(SCHATTR_AXIS_TIME_RESOLUTION
,m_nTimeResolution
));
309 rOutAttrs
->Put(SfxInt32Item(SCHATTR_AXIS_MAIN_TIME_UNIT
,m_nMainTimeUnit
));
310 rOutAttrs
->Put(SfxInt32Item(SCHATTR_AXIS_HELP_TIME_UNIT
,m_nHelpTimeUnit
));
315 void ScaleTabPage::Reset(const SfxItemSet
* rInAttrs
)
317 OSL_PRECOND( pNumFormatter
, "No NumberFormatter available" );
321 const SfxPoolItem
*pPoolItem
= NULL
;
322 if (rInAttrs
->GetItemState(SCHATTR_AXIS_ALLOW_DATEAXIS
, true, &pPoolItem
) == SfxItemState::SET
)
323 m_bAllowDateAxis
= (bool) static_cast<const SfxBoolItem
*>(pPoolItem
)->GetValue();
324 m_nAxisType
=chart2::AxisType::REALNUMBER
;
325 if (rInAttrs
->GetItemState(SCHATTR_AXISTYPE
, true, &pPoolItem
) == SfxItemState::SET
)
326 m_nAxisType
= (int) static_cast<const SfxInt32Item
*>(pPoolItem
)->GetValue();
327 if( m_nAxisType
==chart2::AxisType::DATE
&& !m_bAllowDateAxis
)
328 m_nAxisType
=chart2::AxisType::CATEGORY
;
329 if( m_bAllowDateAxis
)
331 bool bAutoDateAxis
= false;
332 if (rInAttrs
->GetItemState(SCHATTR_AXIS_AUTO_DATEAXIS
, true, &pPoolItem
) == SfxItemState::SET
)
333 bAutoDateAxis
= (bool) static_cast<const SfxBoolItem
*>(pPoolItem
)->GetValue();
336 if( m_nAxisType
==chart2::AxisType::DATE
)
338 else if( bAutoDateAxis
)
342 m_pLB_AxisType
->SelectEntryPos( nPos
);
345 m_pCbxAutoMin
->Check( true );
346 m_pCbxAutoMax
->Check( true );
347 m_pCbxAutoStepMain
->Check( true );
348 m_pCbxAutoStepHelp
->Check( true );
349 m_pCbxAutoOrigin
->Check( true );
350 m_pCbx_AutoTimeResolution
->Check( true );
352 if (rInAttrs
->GetItemState(SCHATTR_AXIS_AUTO_MIN
,true,&pPoolItem
) == SfxItemState::SET
)
353 m_pCbxAutoMin
->Check(static_cast<const SfxBoolItem
*>(pPoolItem
)->GetValue());
355 if (rInAttrs
->GetItemState(SCHATTR_AXIS_MIN
,true, &pPoolItem
) == SfxItemState::SET
)
357 fMin
= static_cast<const SvxDoubleItem
*>(pPoolItem
)->GetValue();
358 lcl_setValue( *m_pFmtFldMin
, fMin
);
361 if (rInAttrs
->GetItemState(SCHATTR_AXIS_AUTO_MAX
,true, &pPoolItem
) == SfxItemState::SET
)
362 m_pCbxAutoMax
->Check(static_cast<const SfxBoolItem
*>(pPoolItem
)->GetValue());
364 if (rInAttrs
->GetItemState(SCHATTR_AXIS_MAX
,true, &pPoolItem
) == SfxItemState::SET
)
366 fMax
= static_cast<const SvxDoubleItem
*>(pPoolItem
)->GetValue();
367 lcl_setValue( *m_pFmtFldMax
, fMax
);
370 if (rInAttrs
->GetItemState(SCHATTR_AXIS_AUTO_STEP_MAIN
,true, &pPoolItem
) == SfxItemState::SET
)
371 m_pCbxAutoStepMain
->Check(static_cast<const SfxBoolItem
*>(pPoolItem
)->GetValue());
373 if (rInAttrs
->GetItemState(SCHATTR_AXIS_STEP_MAIN
,true, &pPoolItem
) == SfxItemState::SET
)
375 fStepMain
= static_cast<const SvxDoubleItem
*>(pPoolItem
)->GetValue();
376 lcl_setValue( *m_pFmtFldStepMain
, fStepMain
);
377 m_pMt_MainDateStep
->SetValue( static_cast<sal_Int32
>(fStepMain
) );
379 if (rInAttrs
->GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP
,true, &pPoolItem
) == SfxItemState::SET
)
380 m_pCbxAutoStepHelp
->Check(static_cast<const SfxBoolItem
*>(pPoolItem
)->GetValue());
381 if (rInAttrs
->GetItemState(SCHATTR_AXIS_LOGARITHM
,true, &pPoolItem
) == SfxItemState::SET
)
382 m_pCbxLogarithm
->Check(static_cast<const SfxBoolItem
*>(pPoolItem
)->GetValue());
383 if (rInAttrs
->GetItemState(SCHATTR_AXIS_REVERSE
,true, &pPoolItem
) == SfxItemState::SET
)
384 m_pCbxReverse
->Check(static_cast<const SfxBoolItem
*>(pPoolItem
)->GetValue());
385 if (rInAttrs
->GetItemState(SCHATTR_AXIS_STEP_HELP
,true, &pPoolItem
) == SfxItemState::SET
)
387 nStepHelp
= static_cast<const SfxInt32Item
*>(pPoolItem
)->GetValue();
388 m_pMtStepHelp
->SetValue( nStepHelp
);
390 if (rInAttrs
->GetItemState(SCHATTR_AXIS_AUTO_ORIGIN
,true, &pPoolItem
) == SfxItemState::SET
)
391 m_pCbxAutoOrigin
->Check(static_cast<const SfxBoolItem
*>(pPoolItem
)->GetValue());
392 if (rInAttrs
->GetItemState(SCHATTR_AXIS_ORIGIN
,true, &pPoolItem
) == SfxItemState::SET
)
394 fOrigin
= static_cast<const SvxDoubleItem
*>(pPoolItem
)->GetValue();
395 lcl_setValue( *m_pFmtFldOrigin
, fOrigin
);
398 if (rInAttrs
->GetItemState(SCHATTR_AXIS_AUTO_TIME_RESOLUTION
,true, &pPoolItem
) == SfxItemState::SET
)
399 m_pCbx_AutoTimeResolution
->Check(static_cast<const SfxBoolItem
*>(pPoolItem
)->GetValue());
400 if (rInAttrs
->GetItemState(SCHATTR_AXIS_TIME_RESOLUTION
,true, &pPoolItem
) == SfxItemState::SET
)
402 m_nTimeResolution
= static_cast<const SfxInt32Item
*>(pPoolItem
)->GetValue();
403 m_pLB_TimeResolution
->SelectEntryPos( m_nTimeResolution
);
406 if (rInAttrs
->GetItemState(SCHATTR_AXIS_MAIN_TIME_UNIT
,true, &pPoolItem
) == SfxItemState::SET
)
408 m_nMainTimeUnit
= static_cast<const SfxInt32Item
*>(pPoolItem
)->GetValue();
409 m_pLB_MainTimeUnit
->SelectEntryPos( m_nMainTimeUnit
);
411 if (rInAttrs
->GetItemState(SCHATTR_AXIS_HELP_TIME_UNIT
,true, &pPoolItem
) == SfxItemState::SET
)
413 m_nHelpTimeUnit
= static_cast<const SfxInt32Item
*>(pPoolItem
)->GetValue();
414 m_pLB_HelpTimeUnit
->SelectEntryPos( m_nHelpTimeUnit
);
421 SfxTabPage::sfxpg
ScaleTabPage::DeactivatePage(SfxItemSet
* pItemSet
)
425 OSL_FAIL( "No NumberFormatter available" );
429 bool bDateAxis
= chart2::AxisType::DATE
== m_nAxisType
;
431 sal_uInt32 nMinMaxOriginFmt
= m_pFmtFldMax
->GetFormatKey();
432 if ((pNumFormatter
->GetType(nMinMaxOriginFmt
) & ~css::util::NumberFormat::DEFINED
) == css::util::NumberFormat::TEXT
)
433 nMinMaxOriginFmt
= 0;
434 // numberformat_text cause numbers to fail being numbers... Shouldn't happen, but can.
435 sal_uInt32 nStepFmt
= m_pFmtFldStepMain
->GetFormatKey();
436 if ((pNumFormatter
->GetType(nStepFmt
) & ~css::util::NumberFormat::DEFINED
) == css::util::NumberFormat::TEXT
)
439 Control
* pControl
= NULL
;
440 sal_uInt16 nErrStrId
= 0;
443 fMax
= m_pFmtFldMax
->GetValue();
444 fMin
= m_pFmtFldMin
->GetValue();
445 fOrigin
= m_pFmtFldOrigin
->GetValue();
446 fStepMain
= bDateAxis
? m_pMt_MainDateStep
->GetValue() : m_pFmtFldStepMain
->GetValue();
447 nStepHelp
= static_cast< sal_Int32
>( m_pMtStepHelp
->GetValue());
448 m_nTimeResolution
= m_pLB_TimeResolution
->GetSelectEntryPos();
449 m_nMainTimeUnit
= m_pLB_MainTimeUnit
->GetSelectEntryPos();
450 m_nHelpTimeUnit
= m_pLB_HelpTimeUnit
->GetSelectEntryPos();
452 if( chart2::AxisType::REALNUMBER
!= m_nAxisType
)
453 m_pCbxLogarithm
->Show( false );
455 //check which entries need user action
457 if ( m_pCbxLogarithm
->IsChecked() &&
458 ( ( !m_pCbxAutoMin
->IsChecked() && fMin
<= 0.0 )
459 || ( !m_pCbxAutoMax
->IsChecked() && fMax
<= 0.0 ) ) )
461 pControl
= m_pFmtFldMin
;
462 nErrStrId
= STR_BAD_LOGARITHM
;
464 // check for entries that cannot be parsed for the current number format
465 else if ( m_pFmtFldMin
->IsModified()
466 && !m_pCbxAutoMin
->IsChecked()
467 && !pNumFormatter
->IsNumberFormat( m_pFmtFldMin
->GetText(), nMinMaxOriginFmt
, fDummy
))
469 pControl
= m_pFmtFldMin
;
470 nErrStrId
= STR_INVALID_NUMBER
;
472 else if ( m_pFmtFldMax
->IsModified()
473 && !m_pCbxAutoMax
->IsChecked()
474 && !pNumFormatter
->IsNumberFormat( m_pFmtFldMax
->GetText(), nMinMaxOriginFmt
, fDummy
))
476 pControl
= m_pFmtFldMax
;
477 nErrStrId
= STR_INVALID_NUMBER
;
479 else if ( !bDateAxis
&& m_pFmtFldStepMain
->IsModified()
480 && !m_pCbxAutoStepMain
->IsChecked()
481 && !pNumFormatter
->IsNumberFormat( m_pFmtFldStepMain
->GetText(), nStepFmt
, fDummy
))
483 pControl
= m_pFmtFldStepMain
;
484 nErrStrId
= STR_INVALID_NUMBER
;
486 else if (m_pFmtFldOrigin
->IsModified() && !m_pCbxAutoOrigin
->IsChecked() &&
487 !pNumFormatter
->IsNumberFormat( m_pFmtFldOrigin
->GetText(), nMinMaxOriginFmt
, fDummy
))
489 pControl
= m_pFmtFldOrigin
;
490 nErrStrId
= STR_INVALID_NUMBER
;
492 else if (!m_pCbxAutoStepMain
->IsChecked() && fStepMain
<= 0.0)
494 pControl
= m_pFmtFldStepMain
;
495 nErrStrId
= STR_STEP_GT_ZERO
;
497 else if (!m_pCbxAutoMax
->IsChecked() && !m_pCbxAutoMin
->IsChecked() &&
500 pControl
= m_pFmtFldMin
;
501 nErrStrId
= STR_MIN_GREATER_MAX
;
505 if( !m_pCbxAutoStepMain
->IsChecked() && !m_pCbxAutoStepHelp
->IsChecked() )
507 if( m_nHelpTimeUnit
> m_nMainTimeUnit
)
509 pControl
= m_pLB_MainTimeUnit
;
510 nErrStrId
= STR_INVALID_INTERVALS
;
512 else if( m_nHelpTimeUnit
== m_nMainTimeUnit
&& nStepHelp
> fStepMain
)
514 pControl
= m_pLB_MainTimeUnit
;
515 nErrStrId
= STR_INVALID_INTERVALS
;
518 if( !nErrStrId
&& !m_pCbx_AutoTimeResolution
->IsChecked() )
520 if( (!m_pCbxAutoStepMain
->IsChecked() && m_nTimeResolution
> m_nMainTimeUnit
)
522 (!m_pCbxAutoStepHelp
->IsChecked() && m_nTimeResolution
> m_nHelpTimeUnit
)
525 pControl
= m_pLB_TimeResolution
;
526 nErrStrId
= STR_INVALID_TIME_UNIT
;
531 if( ShowWarning( nErrStrId
, pControl
) )
535 FillItemSet( pItemSet
);
540 void ScaleTabPage::SetNumFormatter( SvNumberFormatter
* pFormatter
)
542 pNumFormatter
= pFormatter
;
543 m_pFmtFldMax
->SetFormatter( pNumFormatter
);
544 m_pFmtFldMin
->SetFormatter( pNumFormatter
);
545 m_pFmtFldStepMain
->SetFormatter( pNumFormatter
);
546 m_pFmtFldOrigin
->SetFormatter( pNumFormatter
);
548 // #i6278# allow more decimal places than the output format. As
549 // the numbers shown in the edit fields are used for input, it makes more
550 // sense to display the values in the input format rather than the output
552 m_pFmtFldMax
->UseInputStringForFormatting();
553 m_pFmtFldMin
->UseInputStringForFormatting();
554 m_pFmtFldStepMain
->UseInputStringForFormatting();
555 m_pFmtFldOrigin
->UseInputStringForFormatting();
560 void ScaleTabPage::SetNumFormat()
562 const SfxPoolItem
*pPoolItem
= NULL
;
564 if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE
, true, &pPoolItem
) == SfxItemState::SET
)
566 sal_uLong nFmt
= (sal_uLong
)static_cast<const SfxInt32Item
*>(pPoolItem
)->GetValue();
568 m_pFmtFldMax
->SetFormatKey( nFmt
);
569 m_pFmtFldMin
->SetFormatKey( nFmt
);
570 m_pFmtFldOrigin
->SetFormatKey( nFmt
);
574 short eType
= pNumFormatter
->GetType( nFmt
);
575 if( eType
== css::util::NumberFormat::DATE
)
577 // for intervals use standard format for dates (so you can enter a number of days)
578 const SvNumberformat
* pFormat
= pNumFormatter
->GetEntry( nFmt
);
580 nFmt
= pNumFormatter
->GetStandardIndex( pFormat
->GetLanguage());
582 nFmt
= pNumFormatter
->GetStandardIndex();
584 else if( eType
== css::util::NumberFormat::DATETIME
)
586 // for intervals use time format for date times
587 const SvNumberformat
* pFormat
= pNumFormatter
->GetEntry( nFmt
);
589 nFmt
= pNumFormatter
->GetStandardFormat( css::util::NumberFormat::TIME
, pFormat
->GetLanguage() );
591 nFmt
= pNumFormatter
->GetStandardFormat( css::util::NumberFormat::TIME
);
594 if( chart2::AxisType::DATE
== m_nAxisType
&& ( eType
!= css::util::NumberFormat::DATE
&& eType
!= css::util::NumberFormat::DATETIME
) )
596 const SvNumberformat
* pFormat
= pNumFormatter
->GetEntry( nFmt
);
598 nFmt
= pNumFormatter
->GetStandardFormat( css::util::NumberFormat::DATE
, pFormat
->GetLanguage() );
600 nFmt
= pNumFormatter
->GetStandardFormat( css::util::NumberFormat::DATE
);
602 m_pFmtFldMax
->SetFormatKey( nFmt
);
603 m_pFmtFldMin
->SetFormatKey( nFmt
);
604 m_pFmtFldOrigin
->SetFormatKey( nFmt
);
608 m_pFmtFldStepMain
->SetFormatKey( nFmt
);
612 void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin
)
614 m_bShowAxisOrigin
= bShowOrigin
;
615 if( !AxisHelper::isAxisPositioningEnabled() )
616 m_bShowAxisOrigin
= true;
619 bool ScaleTabPage::ShowWarning( sal_uInt16 nResIdMessage
, Control
* pControl
/* = NULL */ )
621 if( nResIdMessage
== 0 )
624 ScopedVclPtr
<WarningBox
>::Create( this, WinBits( WB_OK
), SCH_RESSTR( nResIdMessage
) )->Execute();
627 pControl
->GrabFocus();
628 Edit
* pEdit
= dynamic_cast<Edit
*>(pControl
);
630 pEdit
->SetSelection( Selection( 0, SELECTION_MAX
));
635 void ScaleTabPage::HideAllControls()
637 // We need to set these controls invisible when the class is instantiated
638 // since some code in EnableControls() depends on that logic. The real
639 // visibility of these controls depend on axis data type, and are
640 // set in EnableControls().
643 m_pCbxLogarithm
->Hide();
646 m_pFmtFldStepMain
->Hide();
647 m_pMt_MainDateStep
->Hide();
648 m_pLB_MainTimeUnit
->Hide();
649 m_pCbxAutoStepMain
->Hide();
650 m_pTxtHelpCount
->Hide();
652 m_pMtStepHelp
->Hide();
653 m_pCbxAutoStepHelp
->Hide();
655 m_pBxResolution
->Hide();
660 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */