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
10*cde9e8dcSAndrew Rist *
11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist *
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.
19*cde9e8dcSAndrew Rist *
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
27cdf0e10cSrcweir #include "dlg_InsertErrorBars.hxx"
28cdf0e10cSrcweir #include "dlg_InsertErrorBars.hrc"
29cdf0e10cSrcweir #include "res_ErrorBar.hxx"
30cdf0e10cSrcweir #include "ResourceIds.hrc"
31cdf0e10cSrcweir #include "ResId.hxx"
32cdf0e10cSrcweir #include "Strings.hrc"
33cdf0e10cSrcweir #include "chartview/ExplicitValueProvider.hxx"
34cdf0e10cSrcweir #include "ChartModelHelper.hxx"
35cdf0e10cSrcweir #include "ObjectIdentifier.hxx"
36cdf0e10cSrcweir #include "DiagramHelper.hxx"
37cdf0e10cSrcweir #include "AxisHelper.hxx"
38cdf0e10cSrcweir #include "ObjectNameProvider.hxx"
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include <com/sun/star/chart2/XAxis.hpp>
41cdf0e10cSrcweir #include <com/sun/star/chart2/XDiagram.hpp>
42cdf0e10cSrcweir
43cdf0e10cSrcweir using ::rtl::OUString;
44cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
45cdf0e10cSrcweir using namespace ::com::sun::star;
46cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
47cdf0e10cSrcweir
48cdf0e10cSrcweir //.............................................................................
49cdf0e10cSrcweir namespace chart
50cdf0e10cSrcweir {
51cdf0e10cSrcweir //.............................................................................
52cdf0e10cSrcweir
InsertErrorBarsDialog(Window * pParent,const SfxItemSet & rMyAttrs,const uno::Reference<chart2::XChartDocument> & xChartDocument,ErrorBarResources::tErrorBarType eType)53cdf0e10cSrcweir InsertErrorBarsDialog::InsertErrorBarsDialog(
54cdf0e10cSrcweir Window* pParent, const SfxItemSet& rMyAttrs,
55cdf0e10cSrcweir const uno::Reference< chart2::XChartDocument > & xChartDocument,
56cdf0e10cSrcweir ErrorBarResources::tErrorBarType eType /* = ErrorBarResources::ERROR_BAR_Y */ ) :
57cdf0e10cSrcweir ModalDialog( pParent, SchResId( DLG_DATA_YERRORBAR )),
58cdf0e10cSrcweir rInAttrs( rMyAttrs ),
59cdf0e10cSrcweir aBtnOK( this, SchResId( BTN_OK )),
60cdf0e10cSrcweir aBtnCancel( this, SchResId( BTN_CANCEL )),
61cdf0e10cSrcweir aBtnHelp( this, SchResId( BTN_HELP )),
62cdf0e10cSrcweir m_apErrorBarResources( new ErrorBarResources(
63cdf0e10cSrcweir this, this, rInAttrs,
64cdf0e10cSrcweir /* bNoneAvailable = */ true, eType ))
65cdf0e10cSrcweir {
66cdf0e10cSrcweir FreeResource();
67cdf0e10cSrcweir this->SetText( ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS ) );
68cdf0e10cSrcweir
69cdf0e10cSrcweir m_apErrorBarResources->SetChartDocumentForRangeChoosing( xChartDocument );
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
~InsertErrorBarsDialog()72cdf0e10cSrcweir InsertErrorBarsDialog::~InsertErrorBarsDialog()
73cdf0e10cSrcweir {
74cdf0e10cSrcweir }
75cdf0e10cSrcweir
FillItemSet(SfxItemSet & rOutAttrs)76cdf0e10cSrcweir void InsertErrorBarsDialog::FillItemSet(SfxItemSet& rOutAttrs)
77cdf0e10cSrcweir {
78cdf0e10cSrcweir m_apErrorBarResources->FillItemSet(rOutAttrs);
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
DataChanged(const DataChangedEvent & rDCEvt)81cdf0e10cSrcweir void InsertErrorBarsDialog::DataChanged( const DataChangedEvent& rDCEvt )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir ModalDialog::DataChanged( rDCEvt );
84cdf0e10cSrcweir
85cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
86cdf0e10cSrcweir m_apErrorBarResources->FillValueSets();
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
SetAxisMinorStepWidthForErrorBarDecimals(double fMinorStepWidth)89cdf0e10cSrcweir void InsertErrorBarsDialog::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir m_apErrorBarResources->SetAxisMinorStepWidthForErrorBarDecimals( fMinorStepWidth );
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
getAxisMinorStepWidthForErrorBarDecimals(const Reference<frame::XModel> & xChartModel,const Reference<uno::XInterface> & xChartView,const OUString & rSelectedObjectCID)94cdf0e10cSrcweir double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals(
95cdf0e10cSrcweir const Reference< frame::XModel >& xChartModel,
96cdf0e10cSrcweir const Reference< uno::XInterface >& xChartView,
97cdf0e10cSrcweir const OUString& rSelectedObjectCID )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir double fStepWidth = 0.001;
100cdf0e10cSrcweir
101cdf0e10cSrcweir ExplicitValueProvider* pExplicitValueProvider( ExplicitValueProvider::getExplicitValueProvider(xChartView) );
102cdf0e10cSrcweir if( pExplicitValueProvider )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir Reference< XAxis > xAxis;
105cdf0e10cSrcweir Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
106cdf0e10cSrcweir Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID, xChartModel );
107cdf0e10cSrcweir xAxis = DiagramHelper::getAttachedAxis( xSeries, xDiagram );
108cdf0e10cSrcweir if(!xAxis.is())
109cdf0e10cSrcweir xAxis = AxisHelper::getAxis( 1/*nDimensionIndex*/, true/*bMainAxis*/, xDiagram );
110cdf0e10cSrcweir if(xAxis.is())
111cdf0e10cSrcweir {
112cdf0e10cSrcweir ExplicitScaleData aExplicitScale;
113cdf0e10cSrcweir ExplicitIncrementData aExplicitIncrement;
114cdf0e10cSrcweir pExplicitValueProvider->getExplicitValuesForAxis( xAxis,aExplicitScale, aExplicitIncrement );
115cdf0e10cSrcweir
116cdf0e10cSrcweir fStepWidth = aExplicitIncrement.Distance;
117cdf0e10cSrcweir if( !aExplicitIncrement.SubIncrements.empty() && aExplicitIncrement.SubIncrements[0].IntervalCount>0 )
118cdf0e10cSrcweir fStepWidth=fStepWidth/double(aExplicitIncrement.SubIncrements[0].IntervalCount);
119cdf0e10cSrcweir else
120cdf0e10cSrcweir fStepWidth/=10;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
124cdf0e10cSrcweir return fStepWidth;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir //.............................................................................
128cdf0e10cSrcweir } //namespace chart
129cdf0e10cSrcweir //.............................................................................
130