Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "dlg_InsertErrorBars.hxx"
21 : #include "res_ErrorBar.hxx"
22 : #include "ResId.hxx"
23 : #include "chartview/ExplicitValueProvider.hxx"
24 : #include "ChartModelHelper.hxx"
25 : #include "ObjectIdentifier.hxx"
26 : #include "DiagramHelper.hxx"
27 : #include "AxisHelper.hxx"
28 : #include "ObjectNameProvider.hxx"
29 :
30 : #include <com/sun/star/chart2/XAxis.hpp>
31 : #include <com/sun/star/chart2/XDiagram.hpp>
32 : #include <vcl/settings.hxx>
33 :
34 : using ::com::sun::star::uno::Reference;
35 : using namespace ::com::sun::star;
36 : using namespace ::com::sun::star::chart2;
37 :
38 : namespace chart
39 : {
40 :
41 0 : InsertErrorBarsDialog::InsertErrorBarsDialog(
42 : vcl::Window* pParent, const SfxItemSet& rMyAttrs,
43 : const uno::Reference< chart2::XChartDocument > & xChartDocument,
44 : ErrorBarResources::tErrorBarType eType /* = ErrorBarResources::ERROR_BAR_Y */ ) :
45 : ModalDialog( pParent
46 : ,"dlg_InsertErrorBars"
47 : ,"modules/schart/ui/dlg_InsertErrorBars.ui"),
48 : rInAttrs( rMyAttrs ),
49 : m_apErrorBarResources( new ErrorBarResources(
50 : this, this, rInAttrs,
51 0 : /* bNoneAvailable = */ true, eType ))
52 : {
53 0 : ObjectType objType = eType == ErrorBarResources::ERROR_BAR_Y ? OBJECTTYPE_DATA_ERRORS_Y : OBJECTTYPE_DATA_ERRORS_X;
54 :
55 0 : this->SetText( ObjectNameProvider::getName_ObjectForAllSeries(objType) );
56 :
57 0 : m_apErrorBarResources->SetChartDocumentForRangeChoosing( xChartDocument );
58 0 : }
59 :
60 0 : void InsertErrorBarsDialog::FillItemSet(SfxItemSet& rOutAttrs)
61 : {
62 0 : m_apErrorBarResources->FillItemSet(rOutAttrs);
63 0 : }
64 :
65 0 : void InsertErrorBarsDialog::DataChanged( const DataChangedEvent& rDCEvt )
66 : {
67 0 : ModalDialog::DataChanged( rDCEvt );
68 :
69 0 : if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
70 0 : m_apErrorBarResources->FillValueSets();
71 0 : }
72 :
73 0 : void InsertErrorBarsDialog::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth )
74 : {
75 0 : m_apErrorBarResources->SetAxisMinorStepWidthForErrorBarDecimals( fMinorStepWidth );
76 0 : }
77 :
78 0 : double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals(
79 : const Reference< frame::XModel >& xChartModel,
80 : const Reference< uno::XInterface >& xChartView,
81 : const OUString& rSelectedObjectCID )
82 : {
83 0 : double fStepWidth = 0.001;
84 :
85 0 : ExplicitValueProvider* pExplicitValueProvider( ExplicitValueProvider::getExplicitValueProvider(xChartView) );
86 0 : if( pExplicitValueProvider )
87 : {
88 0 : Reference< XAxis > xAxis;
89 0 : Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
90 0 : Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID, xChartModel );
91 0 : xAxis = DiagramHelper::getAttachedAxis( xSeries, xDiagram );
92 0 : if(!xAxis.is())
93 0 : xAxis = AxisHelper::getAxis( 1/*nDimensionIndex*/, true/*bMainAxis*/, xDiagram );
94 0 : if(xAxis.is())
95 : {
96 0 : ExplicitScaleData aExplicitScale;
97 0 : ExplicitIncrementData aExplicitIncrement;
98 0 : pExplicitValueProvider->getExplicitValuesForAxis( xAxis,aExplicitScale, aExplicitIncrement );
99 :
100 0 : fStepWidth = aExplicitIncrement.Distance;
101 0 : if( !aExplicitIncrement.SubIncrements.empty() && aExplicitIncrement.SubIncrements[0].IntervalCount>0 )
102 0 : fStepWidth=fStepWidth/double(aExplicitIncrement.SubIncrements[0].IntervalCount);
103 : else
104 0 : fStepWidth/=10;
105 0 : }
106 : }
107 :
108 0 : return fStepWidth;
109 : }
110 :
111 57 : } //namespace chart
112 :
113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|