1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "dlg_InsertErrorBars.hxx"
21 #include "res_ErrorBar.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"
30 #include <com/sun/star/chart2/XAxis.hpp>
31 #include <com/sun/star/chart2/XDiagram.hpp>
32 #include <vcl/settings.hxx>
34 using ::com::sun::star::uno::Reference
;
35 using namespace ::com::sun::star
;
36 using namespace ::com::sun::star::chart2
;
41 InsertErrorBarsDialog::InsertErrorBarsDialog(
42 vcl::Window
* pParent
, const SfxItemSet
& rMyAttrs
,
43 const uno::Reference
< chart2::XChartDocument
> & xChartDocument
,
44 ErrorBarResources::tErrorBarType eType
/* = ErrorBarResources::ERROR_BAR_Y */ ) :
46 ,"dlg_InsertErrorBars"
47 ,"modules/schart/ui/dlg_InsertErrorBars.ui"),
49 m_apErrorBarResources( new ErrorBarResources(
51 /* bNoneAvailable = */ true, eType
))
53 ObjectType objType
= eType
== ErrorBarResources::ERROR_BAR_Y
? OBJECTTYPE_DATA_ERRORS_Y
: OBJECTTYPE_DATA_ERRORS_X
;
55 this->SetText( ObjectNameProvider::getName_ObjectForAllSeries(objType
) );
57 m_apErrorBarResources
->SetChartDocumentForRangeChoosing( xChartDocument
);
60 void InsertErrorBarsDialog::FillItemSet(SfxItemSet
& rOutAttrs
)
62 m_apErrorBarResources
->FillItemSet(rOutAttrs
);
65 void InsertErrorBarsDialog::DataChanged( const DataChangedEvent
& rDCEvt
)
67 ModalDialog::DataChanged( rDCEvt
);
69 if ( (rDCEvt
.GetType() == DataChangedEventType::SETTINGS
) && (rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
) )
70 m_apErrorBarResources
->FillValueSets();
73 void InsertErrorBarsDialog::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth
)
75 m_apErrorBarResources
->SetAxisMinorStepWidthForErrorBarDecimals( fMinorStepWidth
);
78 double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals(
79 const Reference
< frame::XModel
>& xChartModel
,
80 const Reference
< uno::XInterface
>& xChartView
,
81 const OUString
& rSelectedObjectCID
)
83 double fStepWidth
= 0.001;
85 ExplicitValueProvider
* pExplicitValueProvider( ExplicitValueProvider::getExplicitValueProvider(xChartView
) );
86 if( pExplicitValueProvider
)
88 Reference
< XAxis
> xAxis
;
89 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
90 Reference
< XDataSeries
> xSeries
= ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID
, xChartModel
);
91 xAxis
= DiagramHelper::getAttachedAxis( xSeries
, xDiagram
);
93 xAxis
= AxisHelper::getAxis( 1/*nDimensionIndex*/, true/*bMainAxis*/, xDiagram
);
96 ExplicitScaleData aExplicitScale
;
97 ExplicitIncrementData aExplicitIncrement
;
98 pExplicitValueProvider
->getExplicitValuesForAxis( xAxis
,aExplicitScale
, aExplicitIncrement
);
100 fStepWidth
= aExplicitIncrement
.Distance
;
101 if( !aExplicitIncrement
.SubIncrements
.empty() && aExplicitIncrement
.SubIncrements
[0].IntervalCount
>0 )
102 fStepWidth
=fStepWidth
/double(aExplicitIncrement
.SubIncrements
[0].IntervalCount
);
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */