1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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"
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"
45 #include "ObjectNameProvider.hxx"
47 #include <com/sun/star/chart2/XAxis.hpp>
48 #include <com/sun/star/chart2/XDiagram.hpp>
50 using ::rtl::OUString
;
51 using ::com::sun::star::uno::Reference
;
52 using namespace ::com::sun::star
;
53 using namespace ::com::sun::star::chart2
;
55 //.............................................................................
58 //.............................................................................
60 InsertErrorBarsDialog::InsertErrorBarsDialog(
61 Window
* pParent
, const SfxItemSet
& rMyAttrs
,
62 const uno::Reference
< chart2::XChartDocument
> & xChartDocument
,
63 ErrorBarResources::tErrorBarType eType
/* = ErrorBarResources::ERROR_BAR_Y */ ) :
64 ModalDialog( pParent
, SchResId( DLG_DATA_YERRORBAR
)),
66 aBtnOK( this, SchResId( BTN_OK
)),
67 aBtnCancel( this, SchResId( BTN_CANCEL
)),
68 aBtnHelp( this, SchResId( BTN_HELP
)),
69 m_apErrorBarResources( new ErrorBarResources(
71 /* bNoneAvailable = */ true, eType
))
74 this->SetText( ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS
) );
76 m_apErrorBarResources
->SetChartDocumentForRangeChoosing( xChartDocument
);
79 InsertErrorBarsDialog::~InsertErrorBarsDialog()
83 void InsertErrorBarsDialog::FillItemSet(SfxItemSet
& rOutAttrs
)
85 m_apErrorBarResources
->FillItemSet(rOutAttrs
);
88 void InsertErrorBarsDialog::DataChanged( const DataChangedEvent
& rDCEvt
)
90 ModalDialog::DataChanged( rDCEvt
);
92 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
93 m_apErrorBarResources
->FillValueSets();
96 void InsertErrorBarsDialog::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth
)
98 m_apErrorBarResources
->SetAxisMinorStepWidthForErrorBarDecimals( fMinorStepWidth
);
102 double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals(
103 const Reference
< frame::XModel
>& xChartModel
,
104 const Reference
< uno::XInterface
>& xChartView
,
105 const OUString
& rSelectedObjectCID
)
107 double fStepWidth
= 0.001;
109 ExplicitValueProvider
* pExplicitValueProvider( ExplicitValueProvider::getExplicitValueProvider(xChartView
) );
110 if( pExplicitValueProvider
)
112 Reference
< XAxis
> xAxis
;
113 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
114 Reference
< XDataSeries
> xSeries
= ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID
, xChartModel
);
115 xAxis
= DiagramHelper::getAttachedAxis( xSeries
, xDiagram
);
117 xAxis
= AxisHelper::getAxis( 1/*nDimensionIndex*/, true/*bMainAxis*/, xDiagram
);
120 ExplicitScaleData aExplicitScale
;
121 ExplicitIncrementData aExplicitIncrement
;
122 pExplicitValueProvider
->getExplicitValuesForAxis( xAxis
,aExplicitScale
, aExplicitIncrement
);
124 fStepWidth
= aExplicitIncrement
.Distance
;
125 if( aExplicitIncrement
.SubIncrements
.getLength() && aExplicitIncrement
.SubIncrements
[0].IntervalCount
>0 )
126 fStepWidth
=fStepWidth
/double(aExplicitIncrement
.SubIncrements
[0].IntervalCount
);
135 //.............................................................................
137 //.............................................................................