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>
22 #include <chartview/ExplicitScaleValues.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 <comphelper/servicehelper.hxx>
32 using ::com::sun::star::uno::Reference
;
33 using namespace ::com::sun::star
;
34 using namespace ::com::sun::star::chart2
;
39 InsertErrorBarsDialog::InsertErrorBarsDialog(
40 weld::Window
* pParent
, const SfxItemSet
& rMyAttrs
,
41 const uno::Reference
< chart2::XChartDocument
> & xChartDocument
,
42 ErrorBarResources::tErrorBarType eType
/* = ErrorBarResources::ERROR_BAR_Y */ )
43 : GenericDialogController(pParent
, "modules/schart/ui/dlg_InsertErrorBars.ui", "dlg_InsertErrorBars")
44 , m_apErrorBarResources( new ErrorBarResources(
45 m_xBuilder
.get(), this, rMyAttrs
,
46 /* bNoneAvailable = */ true, eType
))
48 ObjectType objType
= eType
== ErrorBarResources::ERROR_BAR_Y
? OBJECTTYPE_DATA_ERRORS_Y
: OBJECTTYPE_DATA_ERRORS_X
;
50 m_xDialog
->set_title(ObjectNameProvider::getName_ObjectForAllSeries(objType
));
52 m_apErrorBarResources
->SetChartDocumentForRangeChoosing( xChartDocument
);
55 void InsertErrorBarsDialog::FillItemSet(SfxItemSet
& rOutAttrs
)
57 m_apErrorBarResources
->FillItemSet(rOutAttrs
);
60 void InsertErrorBarsDialog::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth
)
62 m_apErrorBarResources
->SetAxisMinorStepWidthForErrorBarDecimals( fMinorStepWidth
);
65 double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals(
66 const Reference
< frame::XModel
>& xChartModel
,
67 const Reference
< uno::XInterface
>& xChartView
,
68 const OUString
& rSelectedObjectCID
)
70 double fStepWidth
= 0.001;
72 ExplicitValueProvider
* pExplicitValueProvider( comphelper::getUnoTunnelImplementation
<ExplicitValueProvider
>(xChartView
) );
73 if( pExplicitValueProvider
)
75 Reference
< XAxis
> xAxis
;
76 Reference
< XDiagram
> xDiagram( ChartModelHelper::findDiagram( xChartModel
) );
77 Reference
< XDataSeries
> xSeries
= ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID
, xChartModel
);
78 xAxis
= DiagramHelper::getAttachedAxis( xSeries
, xDiagram
);
80 xAxis
= AxisHelper::getAxis( 1/*nDimensionIndex*/, true/*bMainAxis*/, xDiagram
);
83 ExplicitScaleData aExplicitScale
;
84 ExplicitIncrementData aExplicitIncrement
;
85 pExplicitValueProvider
->getExplicitValuesForAxis( xAxis
,aExplicitScale
, aExplicitIncrement
);
87 fStepWidth
= aExplicitIncrement
.Distance
;
88 if( !aExplicitIncrement
.SubIncrements
.empty() && aExplicitIncrement
.SubIncrements
[0].IntervalCount
>0 )
89 fStepWidth
=fStepWidth
/double(aExplicitIncrement
.SubIncrements
[0].IntervalCount
);
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */