update dev300-m58
[ooovba.git] / chart2 / source / controller / dialogs / dlg_InsertErrorBars.cxx
blobd7dff1ff8271504008710110bcfa5ff03e22263e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dlg_InsertErrorBars.cxx,v $
10 * $Revision: 1.4.44.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "dlg_InsertErrorBars.hxx"
35 #include "dlg_InsertErrorBars.hrc"
36 #include "res_ErrorBar.hxx"
37 #include "ResourceIds.hrc"
38 #include "ResId.hxx"
39 #include "Strings.hrc"
40 #include "chartview/ExplicitValueProvider.hxx"
41 #include "ChartModelHelper.hxx"
42 #include "ObjectIdentifier.hxx"
43 #include "DiagramHelper.hxx"
44 #include "AxisHelper.hxx"
46 #include <com/sun/star/chart2/XAxis.hpp>
47 #include <com/sun/star/chart2/XDiagram.hpp>
49 using ::rtl::OUString;
50 using ::com::sun::star::uno::Reference;
51 using namespace ::com::sun::star;
52 using namespace ::com::sun::star::chart2;
54 //.............................................................................
55 namespace chart
57 //.............................................................................
59 InsertErrorBarsDialog::InsertErrorBarsDialog(
60 Window* pParent, const SfxItemSet& rMyAttrs,
61 const uno::Reference< chart2::XChartDocument > & xChartDocument,
62 ErrorBarResources::tErrorBarType eType /* = ErrorBarResources::ERROR_BAR_Y */ ) :
63 ModalDialog( pParent, SchResId( DLG_DATA_YERRORBAR )),
64 rInAttrs( rMyAttrs ),
65 aBtnOK( this, SchResId( BTN_OK )),
66 aBtnCancel( this, SchResId( BTN_CANCEL )),
67 aBtnHelp( this, SchResId( BTN_HELP )),
68 m_apErrorBarResources( new ErrorBarResources(
69 this, this, rInAttrs,
70 /* bNoneAvailable = */ true, eType ))
72 FreeResource();
73 this->SetText( String( SchResId( STR_PAGE_YERROR_BARS )));
74 m_apErrorBarResources->SetChartDocumentForRangeChoosing( xChartDocument );
77 InsertErrorBarsDialog::~InsertErrorBarsDialog()
81 void InsertErrorBarsDialog::FillItemSet(SfxItemSet& rOutAttrs)
83 m_apErrorBarResources->FillItemSet(rOutAttrs);
86 void InsertErrorBarsDialog::DataChanged( const DataChangedEvent& rDCEvt )
88 ModalDialog::DataChanged( rDCEvt );
90 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
91 m_apErrorBarResources->FillValueSets();
94 void InsertErrorBarsDialog::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth )
96 m_apErrorBarResources->SetAxisMinorStepWidthForErrorBarDecimals( fMinorStepWidth );
99 //static
100 double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals(
101 const Reference< frame::XModel >& xChartModel,
102 const Reference< uno::XInterface >& xChartView,
103 const OUString& rSelectedObjectCID )
105 double fStepWidth = 0.001;
107 ExplicitValueProvider* pExplicitValueProvider( ExplicitValueProvider::getExplicitValueProvider(xChartView) );
108 if( pExplicitValueProvider )
110 Reference< XAxis > xAxis;
111 Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
112 Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID, xChartModel );
113 xAxis = DiagramHelper::getAttachedAxis( xSeries, xDiagram );
114 if(!xAxis.is())
115 xAxis = AxisHelper::getAxis( 1/*nDimensionIndex*/, true/*bMainAxis*/, xDiagram );
116 if(xAxis.is())
118 ExplicitScaleData aExplicitScale;
119 ExplicitIncrementData aExplicitIncrement;
120 pExplicitValueProvider->getExplicitValuesForAxis( xAxis,aExplicitScale, aExplicitIncrement );
122 fStepWidth = aExplicitIncrement.Distance;
123 if( aExplicitIncrement.SubIncrements.getLength() && aExplicitIncrement.SubIncrements[0].IntervalCount>0 )
124 fStepWidth=fStepWidth/double(aExplicitIncrement.SubIncrements[0].IntervalCount);
125 else
126 fStepWidth/=10;
130 return fStepWidth;
133 //.............................................................................
134 } //namespace chart
135 //.............................................................................