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 : InsertErrorBarsDialog::~InsertErrorBarsDialog()
61 : {
62 0 : }
63 :
64 0 : void InsertErrorBarsDialog::FillItemSet(SfxItemSet& rOutAttrs)
65 : {
66 0 : m_apErrorBarResources->FillItemSet(rOutAttrs);
67 0 : }
68 :
69 0 : void InsertErrorBarsDialog::DataChanged( const DataChangedEvent& rDCEvt )
70 : {
71 0 : ModalDialog::DataChanged( rDCEvt );
72 :
73 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
74 0 : m_apErrorBarResources->FillValueSets();
75 0 : }
76 :
77 0 : void InsertErrorBarsDialog::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth )
78 : {
79 0 : m_apErrorBarResources->SetAxisMinorStepWidthForErrorBarDecimals( fMinorStepWidth );
80 0 : }
81 :
82 0 : double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals(
83 : const Reference< frame::XModel >& xChartModel,
84 : const Reference< uno::XInterface >& xChartView,
85 : const OUString& rSelectedObjectCID )
86 : {
87 0 : double fStepWidth = 0.001;
88 :
89 0 : ExplicitValueProvider* pExplicitValueProvider( ExplicitValueProvider::getExplicitValueProvider(xChartView) );
90 0 : if( pExplicitValueProvider )
91 : {
92 0 : Reference< XAxis > xAxis;
93 0 : Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
94 0 : Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID, xChartModel );
95 0 : xAxis = DiagramHelper::getAttachedAxis( xSeries, xDiagram );
96 0 : if(!xAxis.is())
97 0 : xAxis = AxisHelper::getAxis( 1/*nDimensionIndex*/, true/*bMainAxis*/, xDiagram );
98 0 : if(xAxis.is())
99 : {
100 0 : ExplicitScaleData aExplicitScale;
101 0 : ExplicitIncrementData aExplicitIncrement;
102 0 : pExplicitValueProvider->getExplicitValuesForAxis( xAxis,aExplicitScale, aExplicitIncrement );
103 :
104 0 : fStepWidth = aExplicitIncrement.Distance;
105 0 : if( !aExplicitIncrement.SubIncrements.empty() && aExplicitIncrement.SubIncrements[0].IntervalCount>0 )
106 0 : fStepWidth=fStepWidth/double(aExplicitIncrement.SubIncrements[0].IntervalCount);
107 : else
108 0 : fStepWidth/=10;
109 0 : }
110 : }
111 :
112 0 : return fStepWidth;
113 : }
114 :
115 102 : } //namespace chart
116 :
117 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|