2003-10-06 08:58:36 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 19:24:18 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2008-04-10 19:24:18 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2008-04-10 19:24:18 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2008-04-10 19:24:18 +00:00
|
|
|
* $RCSfile: tp_Scale.cxx,v $
|
|
|
|
* $Revision: 1.13 $
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2008-04-10 19:24:18 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2008-04-10 19:24:18 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2008-04-10 19:24:18 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2008-04-10 19:24:18 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 11:59:34 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_chart2.hxx"
|
2003-10-06 08:58:36 +00:00
|
|
|
#include "tp_Scale.hxx"
|
|
|
|
|
|
|
|
#include "ResId.hxx"
|
|
|
|
#include "TabPages.hrc"
|
|
|
|
#include "Strings.hrc"
|
2007-05-22 16:48:21 +00:00
|
|
|
#include "chartview/ChartSfxItemIds.hxx"
|
|
|
|
#include "NoWarningThisInCTOR.hxx"
|
2008-12-12 12:17:17 +00:00
|
|
|
#include "AxisHelper.hxx"
|
2007-05-22 16:48:21 +00:00
|
|
|
|
|
|
|
#ifndef _SVX_SVXIDS_HRC
|
|
|
|
#include <svx/svxids.hrc>
|
|
|
|
#endif
|
2003-10-06 08:58:36 +00:00
|
|
|
#include <rtl/math.hxx>
|
|
|
|
// header for class SvxDoubleItem
|
|
|
|
#include <svx/chrtitem.hxx>
|
|
|
|
// header for class SfxBoolItem
|
|
|
|
#include <svtools/eitem.hxx>
|
|
|
|
// header for SfxInt32Item
|
|
|
|
#include <svtools/intitem.hxx>
|
|
|
|
|
|
|
|
// header for class WarningBox
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
|
|
|
|
// header for class SvNumberformat
|
|
|
|
#ifndef _ZFORMAT_HXX
|
|
|
|
#ifndef _ZFORLIST_DECLARE_TABLE
|
|
|
|
#define _ZFORLIST_DECLARE_TABLE
|
|
|
|
#endif
|
|
|
|
#include <svtools/zformat.hxx>
|
|
|
|
#endif
|
|
|
|
|
2008-01-14 12:56:51 +00:00
|
|
|
#include <svtools/controldims.hrc>
|
|
|
|
|
2007-10-22 15:48:11 +00:00
|
|
|
#include <com/sun/star/chart2/AxisType.hpp>
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2003-10-06 08:58:36 +00:00
|
|
|
//.............................................................................
|
|
|
|
namespace chart
|
|
|
|
{
|
|
|
|
//.............................................................................
|
|
|
|
|
2008-01-14 12:56:51 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2008-12-12 12:17:17 +00:00
|
|
|
void lcl_shiftControls( Control& rEdit, Control& rAuto, long nNewXPos )
|
2008-01-14 12:56:51 +00:00
|
|
|
{
|
|
|
|
Point aPos( rEdit.GetPosPixel() );
|
|
|
|
long nShift = nNewXPos - aPos.X();
|
|
|
|
aPos.X() = nNewXPos;
|
|
|
|
rEdit.SetPosPixel(aPos);
|
|
|
|
|
|
|
|
aPos = rAuto.GetPosPixel();
|
|
|
|
aPos.X() += nShift;
|
|
|
|
rAuto.SetPosPixel(aPos);
|
|
|
|
}
|
|
|
|
|
2008-12-12 12:17:17 +00:00
|
|
|
void lcl_placeControlsAtY( Control& rTop, Control& rBottom, long nNewYPos )
|
|
|
|
{
|
|
|
|
Point aPos( rTop.GetPosPixel() );
|
|
|
|
long nShift = nNewYPos - aPos.Y();
|
|
|
|
aPos.Y() = nNewYPos;
|
|
|
|
rTop.SetPosPixel(aPos);
|
|
|
|
|
|
|
|
aPos = rBottom.GetPosPixel();
|
|
|
|
aPos.Y() += nShift;
|
|
|
|
rBottom.SetPosPixel(aPos);
|
|
|
|
}
|
|
|
|
|
2008-01-14 12:56:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-22 15:48:11 +00:00
|
|
|
ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) :
|
2008-12-12 12:17:17 +00:00
|
|
|
SfxTabPage(pWindow, SchResId(TP_SCALE), rInAttrs),
|
2003-10-06 08:58:36 +00:00
|
|
|
|
2008-12-12 12:17:17 +00:00
|
|
|
aFlScale(this, SchResId(FL_SCALE)),
|
2007-04-26 08:37:14 +00:00
|
|
|
aTxtMin (this, SchResId (TXT_MIN)),
|
|
|
|
aFmtFldMin(this, SchResId(EDT_MIN)),
|
|
|
|
aCbxAutoMin(this, SchResId(CBX_AUTO_MIN)),
|
|
|
|
aTxtMax(this, SchResId (TXT_MAX)),
|
|
|
|
aFmtFldMax(this, SchResId(EDT_MAX)),
|
|
|
|
aCbxAutoMax(this, SchResId(CBX_AUTO_MAX)),
|
|
|
|
aTxtMain (this, SchResId (TXT_STEP_MAIN)),
|
|
|
|
aFmtFldStepMain(this, SchResId(EDT_STEP_MAIN)),
|
|
|
|
aCbxAutoStepMain(this, SchResId(CBX_AUTO_STEP_MAIN)),
|
|
|
|
aTxtHelp (this, SchResId (TXT_STEP_HELP)),
|
|
|
|
aMtStepHelp (this, SchResId (MT_STEPHELP)),
|
|
|
|
aCbxAutoStepHelp(this, SchResId(CBX_AUTO_STEP_HELP)),
|
2008-12-12 12:17:17 +00:00
|
|
|
|
2007-04-26 08:37:14 +00:00
|
|
|
aTxtOrigin (this, SchResId (TXT_ORIGIN)),
|
|
|
|
aFmtFldOrigin(this, SchResId(EDT_ORIGIN)),
|
|
|
|
aCbxAutoOrigin(this, SchResId(CBX_AUTO_ORIGIN)),
|
2008-12-12 12:17:17 +00:00
|
|
|
|
2007-04-26 08:37:14 +00:00
|
|
|
aCbxLogarithm(this, SchResId(CBX_LOGARITHM)),
|
2007-10-22 15:48:11 +00:00
|
|
|
aCbxReverse(this, SchResId(CBX_REVERSE)),
|
2003-10-06 08:58:36 +00:00
|
|
|
|
|
|
|
fMin(0.0),
|
|
|
|
fMax(0.0),
|
|
|
|
fStepMain(0.0),
|
|
|
|
nStepHelp(0),
|
|
|
|
fOrigin(0.0),
|
2007-10-22 15:48:11 +00:00
|
|
|
nAxisType(chart2::AxisType::REALNUMBER),
|
2008-12-12 12:17:17 +00:00
|
|
|
pNumFormatter(NULL),
|
|
|
|
m_bShowAxisOrigin(false)
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
SetExchangeSupport();
|
|
|
|
|
2008-01-14 12:56:51 +00:00
|
|
|
//optimize position of the controls
|
|
|
|
{
|
|
|
|
long nLabelWidth = ::std::max( aTxtMin.CalcMinimumSize().Width(), aTxtMax.CalcMinimumSize().Width() );
|
|
|
|
nLabelWidth = ::std::max( aTxtMain.CalcMinimumSize().Width(), nLabelWidth );
|
|
|
|
nLabelWidth = ::std::max( aTxtHelp.CalcMinimumSize().Width(), nLabelWidth );
|
|
|
|
nLabelWidth = ::std::max( aTxtOrigin.CalcMinimumSize().Width(), nLabelWidth );
|
|
|
|
nLabelWidth+=1;
|
|
|
|
|
|
|
|
long nLabelDistance = aTxtMin.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, 0), MapMode(MAP_APPFONT) ).Width();
|
|
|
|
long nNewXPos = aTxtMin.GetPosPixel().X() + nLabelWidth + nLabelDistance;
|
|
|
|
|
|
|
|
//ensure that the auto checkboxes are wide enough and have correct size for calculation
|
|
|
|
aCbxAutoMin.SetSizePixel( aCbxAutoMin.CalcMinimumSize() );
|
|
|
|
aCbxAutoMax.SetSizePixel( aCbxAutoMax.CalcMinimumSize() );
|
|
|
|
aCbxAutoStepMain.SetSizePixel( aCbxAutoStepMain.CalcMinimumSize() );
|
|
|
|
aCbxAutoStepHelp.SetSizePixel( aCbxAutoStepHelp.CalcMinimumSize() );
|
|
|
|
aCbxAutoOrigin.SetSizePixel( aCbxAutoOrigin.CalcMinimumSize() );
|
|
|
|
|
|
|
|
//ensure new pos is ok
|
|
|
|
long nWidthOfOtherControls = aCbxAutoMin.GetPosPixel().X() + aCbxAutoMin.GetSizePixel().Width() - aFmtFldMin.GetPosPixel().X();
|
|
|
|
long nDialogWidth = GetSizePixel().Width();
|
|
|
|
|
|
|
|
long nLeftSpace = nDialogWidth - nNewXPos - nWidthOfOtherControls;
|
|
|
|
if(nLeftSpace>=0)
|
|
|
|
{
|
|
|
|
Size aSize( aTxtMin.GetSizePixel() );
|
|
|
|
aSize.Width() = nLabelWidth;
|
|
|
|
aTxtMin.SetSizePixel(aSize);
|
|
|
|
aTxtMax.SetSizePixel(aSize);
|
|
|
|
aTxtMain.SetSizePixel(aSize);
|
|
|
|
aTxtHelp.SetSizePixel(aSize);
|
|
|
|
aTxtOrigin.SetSizePixel(aSize);
|
|
|
|
|
|
|
|
lcl_shiftControls( aFmtFldMin, aCbxAutoMin, nNewXPos );
|
|
|
|
lcl_shiftControls( aFmtFldMax, aCbxAutoMax, nNewXPos );
|
|
|
|
lcl_shiftControls( aFmtFldStepMain, aCbxAutoStepMain, nNewXPos );
|
|
|
|
lcl_shiftControls( aMtStepHelp, aCbxAutoStepHelp, nNewXPos );
|
|
|
|
lcl_shiftControls( aFmtFldOrigin, aCbxAutoOrigin, nNewXPos );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-22 15:48:11 +00:00
|
|
|
aCbxAutoMin.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
|
|
|
|
aCbxAutoMax.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
|
|
|
|
aCbxAutoStepMain.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
|
|
|
|
aCbxAutoStepHelp.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
|
|
|
|
aCbxAutoOrigin.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScaleTabPage::EnableControls()
|
|
|
|
{
|
|
|
|
bool bEnableForValueOrPercentAxis = chart2::AxisType::REALNUMBER == nAxisType || chart2::AxisType::PERCENT == nAxisType;
|
|
|
|
aFlScale.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aTxtMin.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aFmtFldMin.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aCbxAutoMin.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aTxtMax.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aFmtFldMax.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aCbxAutoMax.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aTxtMain.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aFmtFldStepMain.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aCbxAutoStepMain.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aTxtHelp.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aMtStepHelp.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aCbxAutoStepHelp.Enable( bEnableForValueOrPercentAxis );
|
|
|
|
aCbxLogarithm.Enable( bEnableForValueOrPercentAxis );
|
2008-12-12 12:17:17 +00:00
|
|
|
|
|
|
|
aTxtOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis );
|
|
|
|
aFmtFldOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis );
|
|
|
|
aCbxAutoOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis );
|
|
|
|
|
|
|
|
long nNewYPos = aTxtOrigin.GetPosPixel().Y();
|
|
|
|
if( m_bShowAxisOrigin )
|
|
|
|
nNewYPos += ( aTxtOrigin.GetPosPixel().Y() - aTxtHelp.GetPosPixel().Y() );
|
|
|
|
lcl_placeControlsAtY( aCbxLogarithm, aCbxReverse, nNewYPos );
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
|
|
|
|
2008-12-12 12:17:17 +00:00
|
|
|
|
|
|
|
|
2007-10-22 15:48:11 +00:00
|
|
|
IMPL_LINK( ScaleTabPage, EnableValueHdl, CheckBox *, pCbx )
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
if (pCbx == &aCbxAutoMin)
|
|
|
|
{
|
|
|
|
aFmtFldMin.Enable(!aCbxAutoMin.IsChecked());
|
|
|
|
}
|
|
|
|
else if (pCbx == &aCbxAutoMax)
|
|
|
|
{
|
|
|
|
aFmtFldMax.Enable(!aCbxAutoMax.IsChecked());
|
|
|
|
}
|
|
|
|
else if (pCbx == &aCbxAutoStepMain)
|
|
|
|
{
|
|
|
|
aFmtFldStepMain.Enable(!aCbxAutoStepMain.IsChecked());
|
|
|
|
}
|
|
|
|
else if (pCbx == &aCbxAutoStepHelp)
|
|
|
|
{
|
|
|
|
aMtStepHelp.Show ();
|
|
|
|
aMtStepHelp.Enable( ! aCbxAutoStepHelp.IsChecked() );
|
|
|
|
}
|
|
|
|
else if (pCbx == &aCbxAutoOrigin)
|
|
|
|
{
|
|
|
|
aFmtFldOrigin.Enable(!aCbxAutoOrigin.IsChecked());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-10-22 15:48:11 +00:00
|
|
|
SfxTabPage* ScaleTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs)
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
2007-10-22 15:48:11 +00:00
|
|
|
return new ScaleTabPage(pWindow, rOutAttrs);
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
|
|
|
|
2007-10-22 15:48:11 +00:00
|
|
|
BOOL ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs)
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( pNumFormatter, "No NumberFormatter available" );
|
|
|
|
|
|
|
|
rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MIN ,aCbxAutoMin.IsChecked()));
|
|
|
|
rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MAX ,aCbxAutoMax.IsChecked()));
|
|
|
|
rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP,aCbxAutoStepHelp.IsChecked()));
|
|
|
|
rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN ,aCbxAutoOrigin.IsChecked()));
|
|
|
|
rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_LOGARITHM ,aCbxLogarithm.IsChecked()));
|
2007-10-22 15:48:11 +00:00
|
|
|
rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_REVERSE ,aCbxReverse.IsChecked()));
|
2003-10-06 08:58:36 +00:00
|
|
|
rOutAttrs.Put(SvxDoubleItem(fMax , SCHATTR_AXIS_MAX));
|
|
|
|
rOutAttrs.Put(SvxDoubleItem(fMin , SCHATTR_AXIS_MIN));
|
|
|
|
rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_STEP_HELP, nStepHelp));
|
|
|
|
rOutAttrs.Put(SvxDoubleItem(fOrigin , SCHATTR_AXIS_ORIGIN));
|
|
|
|
|
|
|
|
rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN,aCbxAutoStepMain.IsChecked()));
|
|
|
|
rOutAttrs.Put(SvxDoubleItem(fStepMain,SCHATTR_AXIS_STEP_MAIN));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-10-22 15:48:11 +00:00
|
|
|
void ScaleTabPage::Reset(const SfxItemSet& rInAttrs)
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( pNumFormatter, "No NumberFormatter available" );
|
|
|
|
if(!pNumFormatter)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const SfxPoolItem *pPoolItem = NULL;
|
2007-10-22 15:48:11 +00:00
|
|
|
nAxisType=chart2::AxisType::REALNUMBER;
|
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXISTYPE, TRUE, &pPoolItem) == SFX_ITEM_SET)
|
|
|
|
{
|
|
|
|
nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue();
|
|
|
|
EnableControls();
|
|
|
|
}
|
2003-10-06 08:58:36 +00:00
|
|
|
|
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MIN,TRUE,&pPoolItem) == SFX_ITEM_SET)
|
|
|
|
aCbxAutoMin.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
|
|
|
|
|
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXIS_MIN,TRUE, &pPoolItem) == SFX_ITEM_SET)
|
|
|
|
{
|
|
|
|
fMin = ((const SvxDoubleItem*)pPoolItem)->GetValue();
|
|
|
|
aFmtFldMin.SetValue( fMin );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MAX,TRUE, &pPoolItem) == SFX_ITEM_SET)
|
|
|
|
aCbxAutoMax.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
|
|
|
|
|
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXIS_MAX,TRUE, &pPoolItem) == SFX_ITEM_SET)
|
|
|
|
{
|
|
|
|
fMax = ((const SvxDoubleItem*)pPoolItem)->GetValue();
|
|
|
|
aFmtFldMax.SetValue( fMax );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_MAIN,TRUE, &pPoolItem) == SFX_ITEM_SET)
|
|
|
|
aCbxAutoStepMain.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
|
|
|
|
|
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_MAIN,TRUE, &pPoolItem) == SFX_ITEM_SET)
|
|
|
|
{
|
|
|
|
fStepMain = ((const SvxDoubleItem*)pPoolItem)->GetValue();
|
|
|
|
aFmtFldStepMain.SetValue( fStepMain );
|
|
|
|
}
|
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,TRUE, &pPoolItem) == SFX_ITEM_SET)
|
|
|
|
aCbxAutoStepHelp.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
|
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXIS_LOGARITHM,TRUE, &pPoolItem) == SFX_ITEM_SET)
|
|
|
|
aCbxLogarithm.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
|
2007-10-22 15:48:11 +00:00
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXIS_REVERSE,TRUE, &pPoolItem) == SFX_ITEM_SET)
|
|
|
|
aCbxReverse.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
|
2003-10-06 08:58:36 +00:00
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_HELP,TRUE, &pPoolItem) == SFX_ITEM_SET)
|
|
|
|
{
|
|
|
|
nStepHelp = ((const SfxInt32Item*)pPoolItem)->GetValue();
|
|
|
|
aMtStepHelp.SetValue( nStepHelp );
|
|
|
|
}
|
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_ORIGIN,TRUE, &pPoolItem) == SFX_ITEM_SET)
|
|
|
|
aCbxAutoOrigin.Check(((const SfxBoolItem*)pPoolItem)->GetValue());
|
|
|
|
if (rInAttrs.GetItemState(SCHATTR_AXIS_ORIGIN,TRUE, &pPoolItem) == SFX_ITEM_SET)
|
|
|
|
{
|
|
|
|
fOrigin = ((const SvxDoubleItem*)pPoolItem)->GetValue();
|
|
|
|
aFmtFldOrigin.SetValue( fOrigin );
|
|
|
|
}
|
|
|
|
|
|
|
|
EnableValueHdl(&aCbxAutoMin);
|
|
|
|
EnableValueHdl(&aCbxAutoMax);
|
|
|
|
EnableValueHdl(&aCbxAutoStepMain);
|
|
|
|
EnableValueHdl(&aCbxAutoStepHelp);
|
|
|
|
EnableValueHdl(&aCbxAutoOrigin);
|
|
|
|
}
|
|
|
|
|
2007-10-22 15:48:11 +00:00
|
|
|
int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet)
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
if( !pNumFormatter )
|
|
|
|
{
|
|
|
|
DBG_ERROR( "No NumberFormatter available" );
|
|
|
|
return LEAVE_PAGE;
|
|
|
|
}
|
|
|
|
|
2005-12-14 13:58:50 +00:00
|
|
|
sal_uInt32 nIndex = pNumFormatter->GetStandardIndex(LANGUAGE_SYSTEM);
|
2007-09-18 13:55:12 +00:00
|
|
|
const SfxPoolItem *pPoolItem = NULL;
|
|
|
|
if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, TRUE, &pPoolItem ) == SFX_ITEM_SET )
|
|
|
|
nIndex = static_cast< sal_uInt32 >( static_cast< const SfxInt32Item* >(pPoolItem)->GetValue());
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSL_ENSURE( false, "Using Standard Language" );
|
|
|
|
}
|
|
|
|
|
2003-10-06 08:58:36 +00:00
|
|
|
Edit* pEdit = NULL;
|
|
|
|
USHORT nErrStrId = 0;
|
|
|
|
double fDummy;
|
|
|
|
|
|
|
|
fMax = aFmtFldMax.GetValue();
|
|
|
|
fMin = aFmtFldMin.GetValue();
|
|
|
|
fOrigin = aFmtFldOrigin.GetValue();
|
|
|
|
fStepMain = aFmtFldStepMain.GetValue();
|
2007-07-25 07:37:32 +00:00
|
|
|
nStepHelp = static_cast< sal_Int32 >( aMtStepHelp.GetValue());
|
2003-10-06 08:58:36 +00:00
|
|
|
|
|
|
|
//do some reasonable automatic correction of user input if necessary
|
|
|
|
if (!aCbxAutoMax.IsChecked() && !aCbxAutoMin.IsChecked() &&
|
|
|
|
fMin >= fMax)
|
|
|
|
{
|
|
|
|
pEdit = &aFmtFldMin;
|
2007-05-22 16:48:21 +00:00
|
|
|
nErrStrId = STR_MIN_GREATER_MAX;
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
|
|
|
// check for entries in invalid ranges
|
|
|
|
if ( aCbxLogarithm.IsChecked() &&
|
|
|
|
( ( !aCbxAutoMin.IsChecked() && fMin <= 0.0 )
|
|
|
|
|| ( !aCbxAutoMax.IsChecked() && fMax <= 0.0 ) ) )
|
|
|
|
{
|
|
|
|
pEdit = &aFmtFldMin;
|
|
|
|
nErrStrId = STR_BAD_LOGARITHM;
|
|
|
|
}
|
2007-05-22 16:48:21 +00:00
|
|
|
if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0)
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
pEdit = &aFmtFldStepMain;
|
|
|
|
nErrStrId = STR_STEP_GT_ZERO;
|
|
|
|
}
|
|
|
|
|
|
|
|
//check wich entries need user action
|
|
|
|
|
|
|
|
// check for entries that cannot be parsed for the current number format
|
|
|
|
if ( aFmtFldMin.IsModified()
|
|
|
|
&& !aCbxAutoMin.IsChecked()
|
|
|
|
&& !pNumFormatter->IsNumberFormat(aFmtFldMin.GetText(), nIndex, fDummy))
|
|
|
|
{
|
|
|
|
pEdit = &aFmtFldMin;
|
|
|
|
nErrStrId = STR_INVALID_NUMBER;
|
|
|
|
}
|
|
|
|
else if (aFmtFldMax.IsModified() && !aCbxAutoMax.IsChecked() &&
|
|
|
|
!pNumFormatter->IsNumberFormat(aFmtFldMax.GetText(),
|
|
|
|
nIndex, fDummy))
|
|
|
|
{
|
|
|
|
pEdit = &aFmtFldMax;
|
|
|
|
nErrStrId = STR_INVALID_NUMBER;
|
|
|
|
}
|
|
|
|
else if (aFmtFldStepMain.IsModified() && !aCbxAutoStepMain.IsChecked() &&
|
|
|
|
!pNumFormatter->IsNumberFormat(aFmtFldStepMain.GetText(),
|
|
|
|
nIndex, fDummy))
|
|
|
|
{
|
|
|
|
pEdit = &aFmtFldStepMain;
|
2007-05-22 16:48:21 +00:00
|
|
|
nErrStrId = STR_STEP_GT_ZERO;
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
|
|
|
else if (aFmtFldOrigin.IsModified() && !aCbxAutoOrigin.IsChecked() &&
|
|
|
|
!pNumFormatter->IsNumberFormat(aFmtFldOrigin.GetText(),
|
|
|
|
nIndex, fDummy))
|
|
|
|
{
|
|
|
|
pEdit = &aFmtFldOrigin;
|
|
|
|
nErrStrId = STR_INVALID_NUMBER;
|
|
|
|
}
|
|
|
|
else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0.0)
|
|
|
|
{
|
|
|
|
pEdit = &aFmtFldStepMain;
|
2007-05-22 16:48:21 +00:00
|
|
|
nErrStrId = STR_STEP_GT_ZERO;
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( ShowWarning( nErrStrId, pEdit ) )
|
|
|
|
return KEEP_PAGE;
|
|
|
|
|
|
|
|
if( pItemSet )
|
|
|
|
FillItemSet( *pItemSet );
|
|
|
|
|
|
|
|
return LEAVE_PAGE;
|
|
|
|
}
|
|
|
|
|
2007-10-22 15:48:11 +00:00
|
|
|
void ScaleTabPage::SetNumFormatter( SvNumberFormatter* pFormatter )
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
pNumFormatter = pFormatter;
|
|
|
|
aFmtFldMax.SetFormatter( pNumFormatter );
|
|
|
|
aFmtFldMin.SetFormatter( pNumFormatter );
|
|
|
|
aFmtFldStepMain.SetFormatter( pNumFormatter );
|
|
|
|
aFmtFldOrigin.SetFormatter( pNumFormatter );
|
2007-09-18 13:55:12 +00:00
|
|
|
|
|
|
|
// #101318#, #i6278# allow more decimal places than the output format. As
|
|
|
|
// the numbers shown in the edit fields are used for input, it makes more
|
|
|
|
// sense to display the values in the input format rather than the output
|
|
|
|
// format.
|
|
|
|
aFmtFldMax.UseInputStringForFormatting();
|
|
|
|
aFmtFldMin.UseInputStringForFormatting();
|
|
|
|
aFmtFldStepMain.UseInputStringForFormatting();
|
|
|
|
aFmtFldOrigin.UseInputStringForFormatting();
|
|
|
|
|
2003-10-06 08:58:36 +00:00
|
|
|
SetNumFormat();
|
|
|
|
}
|
|
|
|
|
2007-10-22 15:48:11 +00:00
|
|
|
void ScaleTabPage::SetNumFormat()
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
const SfxPoolItem *pPoolItem = NULL;
|
|
|
|
|
2007-05-22 16:48:21 +00:00
|
|
|
if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, TRUE, &pPoolItem ) == SFX_ITEM_SET )
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
ULONG nFmt = (ULONG)((const SfxInt32Item*)pPoolItem)->GetValue();
|
|
|
|
|
|
|
|
aFmtFldMax.SetFormatKey( nFmt );
|
|
|
|
aFmtFldMin.SetFormatKey( nFmt );
|
|
|
|
aFmtFldOrigin.SetFormatKey( nFmt );
|
|
|
|
|
2008-12-12 12:17:17 +00:00
|
|
|
if( pNumFormatter )
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
2008-12-12 12:17:17 +00:00
|
|
|
short eType = pNumFormatter->GetType( nFmt );
|
|
|
|
if( eType == NUMBERFORMAT_DATE )
|
|
|
|
{
|
|
|
|
// for intervals use standard format for dates (so you can enter a number of days)
|
|
|
|
const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt );
|
|
|
|
if( pFormat )
|
|
|
|
nFmt = pNumFormatter->GetStandardIndex( pFormat->GetLanguage());
|
|
|
|
else
|
|
|
|
nFmt = pNumFormatter->GetStandardIndex();
|
|
|
|
}
|
|
|
|
else if( eType == NUMBERFORMAT_DATETIME )
|
|
|
|
{
|
|
|
|
// for intervals use time format for date times
|
|
|
|
const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt );
|
|
|
|
if( pFormat )
|
|
|
|
nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_TIME, pFormat->GetLanguage() );
|
|
|
|
else
|
|
|
|
nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_TIME );
|
|
|
|
}
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aFmtFldStepMain.SetFormatKey( nFmt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-12 12:17:17 +00:00
|
|
|
void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin )
|
|
|
|
{
|
|
|
|
m_bShowAxisOrigin = bShowOrigin;
|
|
|
|
if( !AxisHelper::isAxisPositioningEnabled() )
|
|
|
|
m_bShowAxisOrigin = true;
|
|
|
|
}
|
|
|
|
|
2007-10-22 15:48:11 +00:00
|
|
|
bool ScaleTabPage::ShowWarning( USHORT nResIdMessage, Edit * pControl /* = NULL */ )
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
if( nResIdMessage == 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
WarningBox( this, WinBits( WB_OK ), String( SchResId( nResIdMessage ))).Execute();
|
|
|
|
if( pControl )
|
|
|
|
{
|
|
|
|
pControl->GrabFocus();
|
|
|
|
pControl->SetSelection( Selection( 0, SELECTION_MAX ));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//.............................................................................
|
|
|
|
} //namespace chart
|
|
|
|
//.............................................................................
|