LibreOffice Module chart2 (master) 1
dlg_InsertErrorBars.cxx
Go to the documentation of this file.
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
21#include <res_ErrorBar.hxx>
24#include <ChartModelHelper.hxx>
25#include <ChartModel.hxx>
26#include <ChartView.hxx>
27#include <ObjectIdentifier.hxx>
28#include <DiagramHelper.hxx>
29#include <Diagram.hxx>
30#include <Axis.hxx>
31#include <AxisHelper.hxx>
33#include <DataSeries.hxx>
34
36
37using namespace ::com::sun::star;
38using namespace ::com::sun::star::chart2;
39
40namespace chart
41{
42
44 weld::Window* pParent, const SfxItemSet& rMyAttrs,
45 const rtl::Reference<::chart::ChartModel> & xChartDocument,
46 ErrorBarResources::tErrorBarType eType /* = ErrorBarResources::ERROR_BAR_Y */ )
47 : GenericDialogController(pParent, "modules/schart/ui/dlg_InsertErrorBars.ui", "dlg_InsertErrorBars")
48 , m_apErrorBarResources( new ErrorBarResources(
49 m_xBuilder.get(), this, rMyAttrs,
50 /* bNoneAvailable = */ true, eType ))
51{
53
55
56 m_apErrorBarResources->SetChartDocumentForRangeChoosing( xChartDocument );
57}
58
60{
61 m_apErrorBarResources->FillItemSet(rOutAttrs);
62}
63
65{
66 m_apErrorBarResources->SetAxisMinorStepWidthForErrorBarDecimals( fMinorStepWidth );
67}
68
70 const rtl::Reference<::chart::ChartModel>& xChartModel,
71 const rtl::Reference<::chart::ChartView>& xChartView,
72 std::u16string_view rSelectedObjectCID )
73{
74 double fStepWidth = 0.001;
75
76 ExplicitValueProvider* pExplicitValueProvider( xChartView.get() );
77 if( pExplicitValueProvider )
78 {
79 rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() );
80 rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID, xChartModel );
81 rtl::Reference< Axis > xAxis = xDiagram->getAttachedAxis( xSeries );
82 if(!xAxis.is())
83 xAxis = AxisHelper::getAxis( 1/*nDimensionIndex*/, true/*bMainAxis*/, xDiagram );
84 if(xAxis.is())
85 {
86 ExplicitScaleData aExplicitScale;
87 ExplicitIncrementData aExplicitIncrement;
88 pExplicitValueProvider->getExplicitValuesForAxis( xAxis,aExplicitScale, aExplicitIncrement );
89
90 fStepWidth = aExplicitIncrement.Distance;
91 if( !aExplicitIncrement.SubIncrements.empty() && aExplicitIncrement.SubIncrements[0].IntervalCount>0 )
92 fStepWidth=fStepWidth/double(aExplicitIncrement.SubIncrements[0].IntervalCount);
93 else
94 fStepWidth/=10;
95 }
96 }
97
98 return fStepWidth;
99}
100
101} //namespace chart
102
103/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static rtl::Reference< ::chart::Axis > getAxis(sal_Int32 nDimensionIndex, bool bMainAxis, const rtl::Reference< ::chart::Diagram > &xDiagram)
void SetAxisMinorStepWidthForErrorBarDecimals(double fMinorStepWidth)
void FillItemSet(SfxItemSet &rOutAttrs)
static double getAxisMinorStepWidthForErrorBarDecimals(const rtl::Reference<::chart::ChartModel > &xChartModel, const rtl::Reference<::chart::ChartView > &xChartView, std::u16string_view rSelectedObjectCID)
std::unique_ptr< ErrorBarResources > m_apErrorBarResources
InsertErrorBarsDialog(weld::Window *pParent, const SfxItemSet &rMyAttrs, const rtl::Reference<::chart::ChartModel > &xChartDocument, ErrorBarResources::tErrorBarType eType)
static rtl::Reference< ::chart::DataSeries > getDataSeriesForCID(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartModel)
static OUString getName_ObjectForAllSeries(ObjectType eObjectType)
std::shared_ptr< weld::Dialog > m_xDialog
DocumentType eType
@ OBJECTTYPE_DATA_ERRORS_X
@ OBJECTTYPE_DATA_ERRORS_Y
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
describes how tickmarks are positioned on the scale of an axis.
std::vector< ExplicitSubIncrement > SubIncrements
<member>SubIncrements</member> describes the positioning of further sub tickmarks on the scale of an ...
double Distance
the other members are for not date-time axis
This structure contains the explicit values for a scale like Minimum and Maximum.