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