Files
libreoffice/chart2/source/controller/dialogs/tp_Scale.cxx

625 lines
22 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2003-10-06 08:58:36 +00:00
#include "tp_Scale.hxx"
#include "ResId.hxx"
#include "Strings.hrc"
#include "chartview/ChartSfxItemIds.hxx"
2008-12-12 12:17:17 +00:00
#include "AxisHelper.hxx"
#include <svx/svxids.hrc>
2003-10-06 08:58:36 +00:00
#include <rtl/math.hxx>
#include <svx/chrtitem.hxx>
#include <svl/eitem.hxx>
#include <svl/intitem.hxx>
2003-10-06 08:58:36 +00:00
#include <vcl/msgbox.hxx>
#include <svl/zformat.hxx>
#include <svtools/controldims.hrc>
#include <com/sun/star/chart2/AxisType.hpp>
using namespace ::com::sun::star;
2003-10-06 08:58:36 +00:00
namespace chart
{
namespace
{
void lcl_setValue( FormattedField& rFmtField, double fValue )
{
rFmtField.SetValue( fValue );
rFmtField.SetDefaultValue( fValue );
2008-12-12 12:17:17 +00:00
}
}
ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) :
SfxTabPage(pWindow
, "tp_Scale"
, "modules/schart/ui/tp_Scale.ui"
, &rInAttrs),
2003-10-06 08:58:36 +00:00
fMin(0.0),
fMax(0.0),
fStepMain(0.0),
nStepHelp(0),
fOrigin(0.0),
2010-11-30 01:45:03 +01:00
m_nTimeResolution(1),
m_nMainTimeUnit(1),
m_nHelpTimeUnit(1),
m_nAxisType(chart2::AxisType::REALNUMBER),
m_bAllowDateAxis(false),
2008-12-12 12:17:17 +00:00
pNumFormatter(NULL),
m_bShowAxisOrigin(false)
2003-10-06 08:58:36 +00:00
{
get(m_pCbxReverse, "CBX_REVERSE");
get(m_pCbxLogarithm, "CBX_LOGARITHM");
get(m_pLB_AxisType, "LB_AXIS_TYPE");
get(m_pBxType,"boxTYPE");
get(m_pBxMinMax, "gridMINMAX");
get(m_pFmtFldMin, "EDT_MIN");
get(m_pCbxAutoMin, "CBX_AUTO_MIN");
get(m_pFmtFldMax, "EDT_MAX");
get(m_pCbxAutoMax, "CBX_AUTO_MAX");
get(m_pBxResolution, "boxRESOLUTION");
get(m_pLB_TimeResolution, "LB_TIME_RESOLUTION");
get(m_pCbx_AutoTimeResolution, "CBX_AUTO_TIME_RESOLUTION");
get(m_pTxtMain, "TXT_STEP_MAIN");
get(m_pFmtFldStepMain, "EDT_STEP_MAIN");
get(m_pMt_MainDateStep, "MT_MAIN_DATE_STEP");
get(m_pLB_MainTimeUnit, "LB_MAIN_TIME_UNIT");
get(m_pCbxAutoStepMain, "CBX_AUTO_STEP_MAIN");
get(m_pMtStepHelp, "MT_STEPHELP");
get(m_pLB_HelpTimeUnit, "LB_HELP_TIME_UNIT");
get(m_pCbxAutoStepHelp, "CBX_AUTO_STEP_HELP");
get(m_pTxtHelpCount,"TXT_STEP_HELP_COUNT");
get(m_pTxtHelp,"TXT_STEP_HELP");
get(m_pBxOrigin,"boxORIGIN");
get(m_pFmtFldOrigin, "EDT_ORIGIN");
get(m_pCbxAutoOrigin, "CBX_AUTO_ORIGIN");
m_pCbxAutoMin->SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
m_pCbxAutoMax->SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
m_pCbxAutoStepMain->SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
m_pCbxAutoStepHelp->SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
m_pCbxAutoOrigin->SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
m_pCbx_AutoTimeResolution->SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl));
m_pLB_AxisType->SetDropDownLineCount(3);
m_pLB_AxisType->SetSelectHdl(LINK(this, ScaleTabPage, SelectAxisTypeHdl));
m_pLB_TimeResolution->SetDropDownLineCount(3);
m_pLB_MainTimeUnit->SetDropDownLineCount(3);
m_pLB_HelpTimeUnit->SetDropDownLineCount(3);
m_pFmtFldMin->SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl));
m_pFmtFldMax->SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl));
m_pFmtFldStepMain->SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl));
m_pFmtFldOrigin->SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl));
HideAllControls();
}
IMPL_LINK( ScaleTabPage, FmtFieldModifiedHdl, FormattedField*, pFmtFied )
{
if( pFmtFied )
pFmtFied->SetDefaultValue( pFmtFied->GetValue() );
return 0;
}
CWS-TOOLING: integrate CWS chart35 2009-02-20 12:33:54 +0100 nn r268312 : correct line ends 2009-01-19 12:50:45 +0100 iha r266491 : #i91800# style:text-position='0' is wrongly imported 2009-01-19 11:59:09 +0100 iha r266486 : #i91037# Position of Datalabels in 3D Bar-Charts are crossing the edge 2009-01-16 16:45:50 +0100 iha r266435 : #i93802# clockwise does not work on solars sparc 2009-01-16 13:23:37 +0100 iha r266414 : #i91037# Position of Datalabels in 3D Bar-Charts are crossing the edge 2009-01-15 14:09:27 +0100 iha r266370 : #i98102# checkbox show equation should not be checked initially 2009-01-14 17:41:33 +0100 iha r266323 : #i97133# #i97318# chart type is not detected correctly in case of invisible series 2009-01-14 16:23:06 +0100 iha r266316 : #i97133# #i97318# chart type is not detected correctly in case of invisible series 2009-01-14 13:43:38 +0100 iha r266298 : #i84417# Unable to edit existing chart title with clipboard 2009-01-14 13:43:04 +0100 iha r266297 : #i84417# Unable to edit existing chart title with IME 2009-01-14 13:14:15 +0100 dr r266293 : do not set CharEscapement property if not needed 2009-01-14 00:48:46 +0100 er r266262 : #i81383# changed ASC and JIS to use transliteration provided by i18n transliteration; patch from <bluedwarf> 2009-01-14 00:28:06 +0100 er r266261 : #i97536# silence gcc's unbracketed && || warnings 2009-01-13 22:43:45 +0100 er r266259 : #i97905# corrected IndexKey order 2009-01-13 20:36:15 +0100 er r266254 : #i97905# add SKK/EUR conversion (plus MTL/EUR and CYP/EUR) 2009-01-13 20:31:17 +0100 er r266253 : #i97905# updated locale data; contributed by <brko> 2009-01-13 11:57:08 +0100 iha r266204 : #i84103# cannot set data in xy diagram in draw 2009-01-12 20:29:37 +0100 nn r266181 : #i97680# GetStylesContainer: handle non-available style family 2009-01-12 19:53:19 +0100 nn r266180 : #i98000# don't get initial zoom value via SfxViewFrame::Current 2009-01-12 16:11:19 +0100 iha r266166 : #i71686# XY charts without valid x values are not imported correctly from Excel 2009-01-09 17:10:20 +0100 iha r266102 : #i95051# truncated asian strings on scale tabpage 2009-01-09 15:58:46 +0100 iha r266094 : #i89430# truncated asian strings in smooth lines dialog 2009-01-09 13:09:14 +0100 iha r266076 : #i94813# importing pie chart with multiline categories crashes
2009-03-03 11:39:43 +00:00
void ScaleTabPage::StateChanged( StateChangedType nType )
{
TabPage::StateChanged( nType );
}
void ScaleTabPage::EnableControls()
{
bool bValueAxis = chart2::AxisType::REALNUMBER == m_nAxisType
|| chart2::AxisType::PERCENT == m_nAxisType
|| chart2::AxisType::DATE == m_nAxisType;
bool bDateAxis = chart2::AxisType::DATE == m_nAxisType;
2010-11-30 01:45:03 +01:00
m_pBxType->Show(m_bAllowDateAxis);
2010-11-30 01:45:03 +01:00
m_pCbxLogarithm->Show( bValueAxis && !bDateAxis );
2010-11-30 01:45:03 +01:00
m_pBxMinMax->Show(bValueAxis);
m_pTxtMain->Show( bValueAxis );
m_pCbxAutoStepMain->Show( bValueAxis );
2010-11-30 01:45:03 +01:00
m_pTxtHelpCount->Show( bValueAxis && !bDateAxis );
m_pTxtHelp->Show( bDateAxis );
m_pMtStepHelp->Show( bValueAxis );
m_pCbxAutoStepHelp->Show( bValueAxis );
2003-10-06 08:58:36 +00:00
m_pBxOrigin->Show( m_bShowAxisOrigin && bValueAxis );
m_pBxResolution->Show( bDateAxis );
2010-11-30 01:45:03 +01:00
bool bWasDateAxis = m_pMt_MainDateStep->IsVisible();
2010-11-30 01:45:03 +01:00
if( bWasDateAxis != bDateAxis )
{
//transport value from one to other control
if( bWasDateAxis )
lcl_setValue( *m_pFmtFldStepMain, m_pMt_MainDateStep->GetValue() );
2010-11-30 01:45:03 +01:00
else
m_pMt_MainDateStep->SetValue( static_cast<sal_Int32>(m_pFmtFldStepMain->GetValue()) );
2010-11-30 01:45:03 +01:00
}
m_pFmtFldStepMain->Show( bValueAxis && !bDateAxis );
m_pMt_MainDateStep->Show( bDateAxis );
m_pLB_MainTimeUnit->Show( bDateAxis );
m_pLB_HelpTimeUnit->Show( bDateAxis );
EnableValueHdl(m_pCbxAutoMin);
EnableValueHdl(m_pCbxAutoMax);
EnableValueHdl(m_pCbxAutoStepMain);
EnableValueHdl(m_pCbxAutoStepHelp);
EnableValueHdl(m_pCbxAutoOrigin);
EnableValueHdl(m_pCbx_AutoTimeResolution);
2010-11-30 01:45:03 +01:00
}
2008-12-12 12:17:17 +00:00
IMPL_LINK( ScaleTabPage, EnableValueHdl, CheckBox *, pCbx )
2003-10-06 08:58:36 +00:00
{
2010-11-30 01:45:03 +01:00
bool bEnable = pCbx && !pCbx->IsChecked() && pCbx->IsEnabled();
if (pCbx == m_pCbxAutoMin)
2003-10-06 08:58:36 +00:00
{
m_pFmtFldMin->Enable( bEnable );
2003-10-06 08:58:36 +00:00
}
else if (pCbx == m_pCbxAutoMax)
2003-10-06 08:58:36 +00:00
{
m_pFmtFldMax->Enable( bEnable );
2003-10-06 08:58:36 +00:00
}
else if (pCbx == m_pCbxAutoStepMain)
2003-10-06 08:58:36 +00:00
{
m_pFmtFldStepMain->Enable( bEnable );
m_pMt_MainDateStep->Enable( bEnable );
m_pLB_MainTimeUnit->Enable( bEnable );
2003-10-06 08:58:36 +00:00
}
else if (pCbx == m_pCbxAutoStepHelp)
2003-10-06 08:58:36 +00:00
{
m_pMtStepHelp->Enable( bEnable );
m_pLB_HelpTimeUnit->Enable( bEnable );
2010-11-30 01:45:03 +01:00
}
else if (pCbx == m_pCbx_AutoTimeResolution)
2010-11-30 01:45:03 +01:00
{
m_pLB_TimeResolution->Enable( bEnable );
2003-10-06 08:58:36 +00:00
}
else if (pCbx == m_pCbxAutoOrigin)
2003-10-06 08:58:36 +00:00
{
m_pFmtFldOrigin->Enable( bEnable );
2003-10-06 08:58:36 +00:00
}
return 0;
}
2010-11-30 01:45:03 +01:00
enum AxisTypeListBoxEntry
{
TYPE_AUTO=0,
TYPE_TEXT=1,
TYPE_DATE=2
};
IMPL_LINK_NOARG(ScaleTabPage, SelectAxisTypeHdl)
2010-11-30 01:45:03 +01:00
{
sal_uInt16 nPos = m_pLB_AxisType->GetSelectEntryPos();
2010-11-30 01:45:03 +01:00
if( nPos==TYPE_DATE )
m_nAxisType = chart2::AxisType::DATE;
else
m_nAxisType = chart2::AxisType::CATEGORY;
if( chart2::AxisType::DATE == m_nAxisType )
m_pCbxLogarithm->Check(false);
2010-11-30 01:45:03 +01:00
EnableControls();
SetNumFormat();
return 0;
}
SfxTabPage* ScaleTabPage::Create(Window* pWindow,const SfxItemSet* rOutAttrs)
2003-10-06 08:58:36 +00:00
{
return new ScaleTabPage(pWindow, *rOutAttrs);
2003-10-06 08:58:36 +00:00
}
bool ScaleTabPage::FillItemSet(SfxItemSet* rOutAttrs)
2003-10-06 08:58:36 +00:00
{
OSL_PRECOND( pNumFormatter, "No NumberFormatter available" );
2003-10-06 08:58:36 +00:00
rOutAttrs->Put(SfxInt32Item(SCHATTR_AXISTYPE, m_nAxisType));
2010-11-30 01:45:03 +01:00
if(m_bAllowDateAxis)
rOutAttrs->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_DATEAXIS, TYPE_AUTO==m_pLB_AxisType->GetSelectEntryPos()));
2010-11-30 01:45:03 +01:00
bool bAutoScale = false;
if( m_nAxisType==chart2::AxisType::CATEGORY )
bAutoScale = true;//reset scaling for category charts
rOutAttrs->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MIN ,bAutoScale || m_pCbxAutoMin->IsChecked()));
rOutAttrs->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MAX ,bAutoScale || m_pCbxAutoMax->IsChecked()));
rOutAttrs->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP,bAutoScale || m_pCbxAutoStepHelp->IsChecked()));
rOutAttrs->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN ,bAutoScale || m_pCbxAutoOrigin->IsChecked()));
rOutAttrs->Put(SfxBoolItem(SCHATTR_AXIS_LOGARITHM ,m_pCbxLogarithm->IsChecked()));
rOutAttrs->Put(SfxBoolItem(SCHATTR_AXIS_REVERSE ,m_pCbxReverse->IsChecked()));
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));
2003-10-06 08:58:36 +00:00
rOutAttrs->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN,bAutoScale || m_pCbxAutoStepMain->IsChecked()));
rOutAttrs->Put(SvxDoubleItem(fStepMain,SCHATTR_AXIS_STEP_MAIN));
2003-10-06 08:58:36 +00:00
rOutAttrs->Put(SfxBoolItem(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,bAutoScale || m_pCbx_AutoTimeResolution->IsChecked()));
rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS_TIME_RESOLUTION,m_nTimeResolution));
2010-11-30 01:45:03 +01:00
rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS_MAIN_TIME_UNIT,m_nMainTimeUnit));
rOutAttrs->Put(SfxInt32Item(SCHATTR_AXIS_HELP_TIME_UNIT,m_nHelpTimeUnit));
2010-11-30 01:45:03 +01:00
return true;
2003-10-06 08:58:36 +00:00
}
void ScaleTabPage::Reset(const SfxItemSet* rInAttrs)
2003-10-06 08:58:36 +00:00
{
OSL_PRECOND( pNumFormatter, "No NumberFormatter available" );
2003-10-06 08:58:36 +00:00
if(!pNumFormatter)
return;
const SfxPoolItem *pPoolItem = NULL;
if (rInAttrs->GetItemState(SCHATTR_AXIS_ALLOW_DATEAXIS, true, &pPoolItem) == SFX_ITEM_SET)
2010-11-30 01:45:03 +01:00
m_bAllowDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue();
m_nAxisType=chart2::AxisType::REALNUMBER;
if (rInAttrs->GetItemState(SCHATTR_AXISTYPE, true, &pPoolItem) == SFX_ITEM_SET)
2010-11-30 01:45:03 +01:00
m_nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue();
if( m_nAxisType==chart2::AxisType::DATE && !m_bAllowDateAxis )
m_nAxisType=chart2::AxisType::CATEGORY;
2010-11-30 01:45:03 +01:00
if( m_bAllowDateAxis )
{
2010-11-30 01:45:03 +01:00
bool bAutoDateAxis = false;
if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_DATEAXIS, true, &pPoolItem) == SFX_ITEM_SET)
2010-11-30 01:45:03 +01:00
bAutoDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue();
2011-02-07 13:06:08 +01:00
sal_uInt16 nPos = 0;
2010-11-30 01:45:03 +01:00
if( m_nAxisType==chart2::AxisType::DATE )
nPos=TYPE_DATE;
else if( bAutoDateAxis )
nPos=TYPE_AUTO;
else
nPos=TYPE_TEXT;
m_pLB_AxisType->SelectEntryPos( nPos );
}
2003-10-06 08:58:36 +00:00
m_pCbxAutoMin->Check( true );
m_pCbxAutoMax->Check( true );
m_pCbxAutoStepMain->Check( true );
m_pCbxAutoStepHelp->Check( true );
m_pCbxAutoOrigin->Check( true );
m_pCbx_AutoTimeResolution->Check( true );
2003-10-06 08:58:36 +00:00
if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_MIN,true,&pPoolItem) == SFX_ITEM_SET)
m_pCbxAutoMin->Check(((const SfxBoolItem*)pPoolItem)->GetValue());
2003-10-06 08:58:36 +00:00
if (rInAttrs->GetItemState(SCHATTR_AXIS_MIN,true, &pPoolItem) == SFX_ITEM_SET)
2003-10-06 08:58:36 +00:00
{
fMin = ((const SvxDoubleItem*)pPoolItem)->GetValue();
lcl_setValue( *m_pFmtFldMin, fMin );
2003-10-06 08:58:36 +00:00
}
if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_MAX,true, &pPoolItem) == SFX_ITEM_SET)
m_pCbxAutoMax->Check(((const SfxBoolItem*)pPoolItem)->GetValue());
2003-10-06 08:58:36 +00:00
if (rInAttrs->GetItemState(SCHATTR_AXIS_MAX,true, &pPoolItem) == SFX_ITEM_SET)
2003-10-06 08:58:36 +00:00
{
fMax = ((const SvxDoubleItem*)pPoolItem)->GetValue();
lcl_setValue( *m_pFmtFldMax, fMax );
2003-10-06 08:58:36 +00:00
}
if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_STEP_MAIN,true, &pPoolItem) == SFX_ITEM_SET)
m_pCbxAutoStepMain->Check(((const SfxBoolItem*)pPoolItem)->GetValue());
2003-10-06 08:58:36 +00:00
if (rInAttrs->GetItemState(SCHATTR_AXIS_STEP_MAIN,true, &pPoolItem) == SFX_ITEM_SET)
2003-10-06 08:58:36 +00:00
{
fStepMain = ((const SvxDoubleItem*)pPoolItem)->GetValue();
lcl_setValue( *m_pFmtFldStepMain, fStepMain );
m_pMt_MainDateStep->SetValue( static_cast<sal_Int32>(fStepMain) );
2003-10-06 08:58:36 +00:00
}
if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,true, &pPoolItem) == SFX_ITEM_SET)
m_pCbxAutoStepHelp->Check(((const SfxBoolItem*)pPoolItem)->GetValue());
if (rInAttrs->GetItemState(SCHATTR_AXIS_LOGARITHM,true, &pPoolItem) == SFX_ITEM_SET)
m_pCbxLogarithm->Check(((const SfxBoolItem*)pPoolItem)->GetValue());
if (rInAttrs->GetItemState(SCHATTR_AXIS_REVERSE,true, &pPoolItem) == SFX_ITEM_SET)
m_pCbxReverse->Check(((const SfxBoolItem*)pPoolItem)->GetValue());
if (rInAttrs->GetItemState(SCHATTR_AXIS_STEP_HELP,true, &pPoolItem) == SFX_ITEM_SET)
2003-10-06 08:58:36 +00:00
{
nStepHelp = ((const SfxInt32Item*)pPoolItem)->GetValue();
m_pMtStepHelp->SetValue( nStepHelp );
2003-10-06 08:58:36 +00:00
}
if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_ORIGIN,true, &pPoolItem) == SFX_ITEM_SET)
m_pCbxAutoOrigin->Check(((const SfxBoolItem*)pPoolItem)->GetValue());
if (rInAttrs->GetItemState(SCHATTR_AXIS_ORIGIN,true, &pPoolItem) == SFX_ITEM_SET)
2003-10-06 08:58:36 +00:00
{
fOrigin = ((const SvxDoubleItem*)pPoolItem)->GetValue();
lcl_setValue( *m_pFmtFldOrigin, fOrigin );
2003-10-06 08:58:36 +00:00
}
if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,true, &pPoolItem) == SFX_ITEM_SET)
m_pCbx_AutoTimeResolution->Check(((const SfxBoolItem*)pPoolItem)->GetValue());
if (rInAttrs->GetItemState(SCHATTR_AXIS_TIME_RESOLUTION,true, &pPoolItem) == SFX_ITEM_SET)
2010-11-30 01:45:03 +01:00
{
m_nTimeResolution = ((const SfxInt32Item*)pPoolItem)->GetValue();
m_pLB_TimeResolution->SelectEntryPos( m_nTimeResolution );
2010-11-30 01:45:03 +01:00
}
if (rInAttrs->GetItemState(SCHATTR_AXIS_MAIN_TIME_UNIT,true, &pPoolItem) == SFX_ITEM_SET)
2010-11-30 01:45:03 +01:00
{
m_nMainTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue();
m_pLB_MainTimeUnit->SelectEntryPos( m_nMainTimeUnit );
2010-11-30 01:45:03 +01:00
}
if (rInAttrs->GetItemState(SCHATTR_AXIS_HELP_TIME_UNIT,true, &pPoolItem) == SFX_ITEM_SET)
2010-11-30 01:45:03 +01:00
{
m_nHelpTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue();
m_pLB_HelpTimeUnit->SelectEntryPos( m_nHelpTimeUnit );
2010-11-30 01:45:03 +01:00
}
EnableControls();
SetNumFormat();
2003-10-06 08:58:36 +00:00
}
int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet)
2003-10-06 08:58:36 +00:00
{
if( !pNumFormatter )
{
2011-03-01 19:05:02 +01:00
OSL_FAIL( "No NumberFormatter available" );
2003-10-06 08:58:36 +00:00
return LEAVE_PAGE;
}
2010-11-30 01:45:03 +01:00
bool bDateAxis = chart2::AxisType::DATE == m_nAxisType;
sal_uInt32 nMinMaxOriginFmt = m_pFmtFldMax->GetFormatKey();
if ((pNumFormatter->GetType(nMinMaxOriginFmt) &~ NUMBERFORMAT_DEFINED) == NUMBERFORMAT_TEXT)
nMinMaxOriginFmt = 0;
// numberformat_text cause numbers to fail being numbers... Shouldn't happen, but can.
sal_uInt32 nStepFmt = m_pFmtFldStepMain->GetFormatKey();
if ((pNumFormatter->GetType(nStepFmt) &~NUMBERFORMAT_DEFINED) == NUMBERFORMAT_TEXT)
nStepFmt = 0;
2010-11-30 01:45:03 +01:00
Control* pControl = NULL;
sal_uInt16 nErrStrId = 0;
2003-10-06 08:58:36 +00:00
double fDummy;
fMax = m_pFmtFldMax->GetValue();
fMin = m_pFmtFldMin->GetValue();
fOrigin = m_pFmtFldOrigin->GetValue();
fStepMain = bDateAxis ? m_pMt_MainDateStep->GetValue() : m_pFmtFldStepMain->GetValue();
nStepHelp = static_cast< sal_Int32 >( m_pMtStepHelp->GetValue());
m_nTimeResolution = m_pLB_TimeResolution->GetSelectEntryPos();
m_nMainTimeUnit = m_pLB_MainTimeUnit->GetSelectEntryPos();
m_nHelpTimeUnit = m_pLB_HelpTimeUnit->GetSelectEntryPos();
2010-11-30 01:45:03 +01:00
if( chart2::AxisType::REALNUMBER != m_nAxisType )
m_pCbxLogarithm->Show( false );
2010-11-30 01:45:03 +01:00
2013-05-06 20:07:23 +02:00
//check which entries need user action
2003-10-06 08:58:36 +00:00
if ( m_pCbxLogarithm->IsChecked() &&
( ( !m_pCbxAutoMin->IsChecked() && fMin <= 0.0 )
|| ( !m_pCbxAutoMax->IsChecked() && fMax <= 0.0 ) ) )
2003-10-06 08:58:36 +00:00
{
pControl = m_pFmtFldMin;
2003-10-06 08:58:36 +00:00
nErrStrId = STR_BAD_LOGARITHM;
}
// check for entries that cannot be parsed for the current number format
else if ( m_pFmtFldMin->IsModified()
&& !m_pCbxAutoMin->IsChecked()
&& !pNumFormatter->IsNumberFormat( m_pFmtFldMin->GetText(), nMinMaxOriginFmt, fDummy))
2003-10-06 08:58:36 +00:00
{
pControl = m_pFmtFldMin;
2003-10-06 08:58:36 +00:00
nErrStrId = STR_INVALID_NUMBER;
}
else if ( m_pFmtFldMax->IsModified()
&& !m_pCbxAutoMax->IsChecked()
&& !pNumFormatter->IsNumberFormat( m_pFmtFldMax->GetText(), nMinMaxOriginFmt, fDummy))
2003-10-06 08:58:36 +00:00
{
pControl = m_pFmtFldMax;
2003-10-06 08:58:36 +00:00
nErrStrId = STR_INVALID_NUMBER;
}
else if ( !bDateAxis && m_pFmtFldStepMain->IsModified()
&& !m_pCbxAutoStepMain->IsChecked()
&& !pNumFormatter->IsNumberFormat( m_pFmtFldStepMain->GetText(), nStepFmt, fDummy))
2003-10-06 08:58:36 +00:00
{
pControl = m_pFmtFldStepMain;
nErrStrId = STR_INVALID_NUMBER;
2003-10-06 08:58:36 +00:00
}
else if (m_pFmtFldOrigin->IsModified() && !m_pCbxAutoOrigin->IsChecked() &&
!pNumFormatter->IsNumberFormat( m_pFmtFldOrigin->GetText(), nMinMaxOriginFmt, fDummy))
2003-10-06 08:58:36 +00:00
{
pControl = m_pFmtFldOrigin;
2003-10-06 08:58:36 +00:00
nErrStrId = STR_INVALID_NUMBER;
}
else if (!m_pCbxAutoStepMain->IsChecked() && fStepMain <= 0.0)
2003-10-06 08:58:36 +00:00
{
pControl = m_pFmtFldStepMain;
nErrStrId = STR_STEP_GT_ZERO;
2003-10-06 08:58:36 +00:00
}
else if (!m_pCbxAutoMax->IsChecked() && !m_pCbxAutoMin->IsChecked() &&
fMin >= fMax)
{
pControl = m_pFmtFldMin;
nErrStrId = STR_MIN_GREATER_MAX;
}
2010-11-30 01:45:03 +01:00
else if( bDateAxis )
{
if( !m_pCbxAutoStepMain->IsChecked() && !m_pCbxAutoStepHelp->IsChecked() )
2010-11-30 01:45:03 +01:00
{
if( m_nHelpTimeUnit > m_nMainTimeUnit )
{
pControl = m_pLB_MainTimeUnit;
2010-11-30 01:45:03 +01:00
nErrStrId = STR_INVALID_INTERVALS;
}
else if( m_nHelpTimeUnit == m_nMainTimeUnit && nStepHelp > fStepMain )
{
pControl = m_pLB_MainTimeUnit;
2010-11-30 01:45:03 +01:00
nErrStrId = STR_INVALID_INTERVALS;
}
}
if( !nErrStrId && !m_pCbx_AutoTimeResolution->IsChecked() )
2010-11-30 01:45:03 +01:00
{
if( (!m_pCbxAutoStepMain->IsChecked() && m_nTimeResolution > m_nMainTimeUnit )
2010-11-30 01:45:03 +01:00
||
(!m_pCbxAutoStepHelp->IsChecked() && m_nTimeResolution > m_nHelpTimeUnit )
2010-11-30 01:45:03 +01:00
)
{
pControl = m_pLB_TimeResolution;
2010-11-30 01:45:03 +01:00
nErrStrId = STR_INVALID_TIME_UNIT;
}
}
}
2003-10-06 08:58:36 +00:00
2010-11-30 01:45:03 +01:00
if( ShowWarning( nErrStrId, pControl ) )
2003-10-06 08:58:36 +00:00
return KEEP_PAGE;
if( pItemSet )
FillItemSet( pItemSet );
2003-10-06 08:58:36 +00:00
return LEAVE_PAGE;
}
void ScaleTabPage::SetNumFormatter( SvNumberFormatter* pFormatter )
2003-10-06 08:58:36 +00:00
{
pNumFormatter = pFormatter;
m_pFmtFldMax->SetFormatter( pNumFormatter );
m_pFmtFldMin->SetFormatter( pNumFormatter );
m_pFmtFldStepMain->SetFormatter( pNumFormatter );
m_pFmtFldOrigin->SetFormatter( pNumFormatter );
2011-02-07 20:20:44 +01:00
// #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.
m_pFmtFldMax->UseInputStringForFormatting();
m_pFmtFldMin->UseInputStringForFormatting();
m_pFmtFldStepMain->UseInputStringForFormatting();
m_pFmtFldOrigin->UseInputStringForFormatting();
2003-10-06 08:58:36 +00:00
SetNumFormat();
}
void ScaleTabPage::SetNumFormat()
2003-10-06 08:58:36 +00:00
{
const SfxPoolItem *pPoolItem = NULL;
if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, true, &pPoolItem ) == SFX_ITEM_SET )
2003-10-06 08:58:36 +00:00
{
sal_uLong nFmt = (sal_uLong)((const SfxInt32Item*)pPoolItem)->GetValue();
2003-10-06 08:58:36 +00:00
m_pFmtFldMax->SetFormatKey( nFmt );
m_pFmtFldMin->SetFormatKey( nFmt );
m_pFmtFldOrigin->SetFormatKey( nFmt );
2003-10-06 08:58:36 +00:00
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 );
}
2010-11-30 01:45:03 +01:00
if( chart2::AxisType::DATE == m_nAxisType && ( eType != NUMBERFORMAT_DATE && eType != NUMBERFORMAT_DATETIME) )
{
const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt );
if( pFormat )
nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATE, pFormat->GetLanguage() );
else
nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATE );
m_pFmtFldMax->SetFormatKey( nFmt );
m_pFmtFldMin->SetFormatKey( nFmt );
m_pFmtFldOrigin->SetFormatKey( nFmt );
2010-11-30 01:45:03 +01:00
}
2003-10-06 08:58:36 +00:00
}
m_pFmtFldStepMain->SetFormatKey( nFmt );
2003-10-06 08:58:36 +00:00
}
}
2008-12-12 12:17:17 +00:00
void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin )
{
m_bShowAxisOrigin = bShowOrigin;
if( !AxisHelper::isAxisPositioningEnabled() )
m_bShowAxisOrigin = true;
}
2011-02-07 13:06:08 +01:00
bool ScaleTabPage::ShowWarning( sal_uInt16 nResIdMessage, Control* pControl /* = NULL */ )
2003-10-06 08:58:36 +00:00
{
if( nResIdMessage == 0 )
return false;
WarningBox( this, WinBits( WB_OK ), SCH_RESSTR( nResIdMessage ) ).Execute();
2003-10-06 08:58:36 +00:00
if( pControl )
{
pControl->GrabFocus();
2010-11-30 01:45:03 +01:00
Edit* pEdit = dynamic_cast<Edit*>(pControl);
if(pEdit)
pEdit->SetSelection( Selection( 0, SELECTION_MAX ));
2003-10-06 08:58:36 +00:00
}
return true;
}
void ScaleTabPage::HideAllControls()
{
// We need to set these controls invisible when the class is instantiated
// since some code in EnableControls() depends on that logic. The real
// visibility of these controls depend on axis data type, and are
// set in EnableControls().
m_pBxType->Hide();
m_pCbxLogarithm->Hide();
m_pBxMinMax->Hide();
m_pTxtMain->Hide();
m_pFmtFldStepMain->Hide();
m_pMt_MainDateStep->Hide();
m_pLB_MainTimeUnit->Hide();
m_pCbxAutoStepMain->Hide();
m_pTxtHelpCount->Hide();
m_pTxtHelp->Hide();
m_pMtStepHelp->Hide();
m_pCbxAutoStepHelp->Hide();
m_pBxOrigin->Hide();
m_pBxResolution->Hide();
}
2003-10-06 08:58:36 +00:00
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */