tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / model / template / HistogramChartTypeTemplate.cxx
blob97dc001d95507ae4e2c357e8b5eec0fcbf6c2397
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
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/.
8 */
10 #include "HistogramChartTypeTemplate.hxx"
11 #include "HistogramChartType.hxx"
12 #include "HistogramDataInterpreter.hxx"
13 #include <Diagram.hxx>
14 #include <DataSeries.hxx>
15 #include <DataSeriesHelper.hxx>
16 #include <PropertyHelper.hxx>
17 #include <com/sun/star/beans/PropertyAttribute.hpp>
18 #include <com/sun/star/drawing/LineStyle.hpp>
19 #include <com/sun/star/chart2/DataPointGeometry3D.hpp>
20 #include <com/sun/star/uno/XComponentContext.hpp>
21 #include <comphelper/diagnose_ex.hxx>
23 #include <algorithm>
25 using namespace ::com::sun::star;
27 using ::com::sun::star::uno::Reference;
28 using ::com::sun::star::uno::Sequence;
29 using ::com::sun::star::beans::Property;
31 namespace
33 enum
35 PROP_HISTOGRAM_TEMPLATE_DIMENSION,
38 void lcl_AddPropertiesToVector(std::vector<Property>& rOutProperties)
40 rOutProperties.emplace_back(
41 "Dimension", PROP_HISTOGRAM_TEMPLATE_DIMENSION, cppu::UnoType<sal_Int32>::get(),
42 beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT);
45 ::cppu::OPropertyArrayHelper& StaticHistogramChartTypeTemplateInfoHelper()
47 static ::cppu::OPropertyArrayHelper aPropHelper = []() {
48 std::vector<css::beans::Property> aProperties;
49 lcl_AddPropertiesToVector(aProperties);
51 std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess());
53 return comphelper::containerToSequence(aProperties);
54 }();
55 return aPropHelper;
58 } // anonymous namespace
60 namespace chart
62 HistogramChartTypeTemplate::HistogramChartTypeTemplate(
63 Reference<uno::XComponentContext> const& xContext, const OUString& rServiceName,
64 StackMode eStackMode)
65 : ChartTypeTemplate(xContext, rServiceName)
66 , m_eStackMode(eStackMode)
67 , m_nDim(2)
71 sal_Int32 HistogramChartTypeTemplate::getDimension() const { return m_nDim; }
73 StackMode HistogramChartTypeTemplate::getStackMode(sal_Int32 /* nChartTypeIndex */) const
75 return m_eStackMode;
78 rtl::Reference<ChartType>
79 HistogramChartTypeTemplate::getChartTypeForIndex(sal_Int32 /*nChartTypeIndex*/)
81 return new HistogramChartType();
84 rtl::Reference<ChartType> HistogramChartTypeTemplate::getChartTypeForNewSeries2(
85 const std::vector<rtl::Reference<ChartType>>& aFormerlyUsedChartTypes)
87 rtl::Reference<ChartType> xResult(getChartTypeForIndex(0));
88 ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(aFormerlyUsedChartTypes, xResult);
89 return xResult;
92 // ____ OPropertySet ____
93 void HistogramChartTypeTemplate::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const
95 static ::chart::tPropertyValueMap aStaticDefaults = []() {
96 ::chart::tPropertyValueMap aTmp;
97 ::chart::PropertyHelper::setPropertyValueDefault<sal_Int32>(
98 aTmp, PROP_HISTOGRAM_TEMPLATE_DIMENSION, 2);
99 return aTmp;
100 }();
101 tPropertyValueMap::const_iterator aFound(aStaticDefaults.find(nHandle));
102 if (aFound == aStaticDefaults.end())
103 rAny.clear();
104 else
105 rAny = (*aFound).second;
108 ::cppu::IPropertyArrayHelper& SAL_CALL HistogramChartTypeTemplate::getInfoHelper()
110 return StaticHistogramChartTypeTemplateInfoHelper();
113 // ____ XPropertySet ____
114 Reference<beans::XPropertySetInfo> SAL_CALL HistogramChartTypeTemplate::getPropertySetInfo()
116 static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo(
117 ::cppu::OPropertySetHelper::createPropertySetInfo(
118 StaticHistogramChartTypeTemplateInfoHelper()));
119 return xPropertySetInfo;
122 void HistogramChartTypeTemplate::applyStyle2(const rtl::Reference<DataSeries>& xSeries,
123 ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex,
124 ::sal_Int32 nSeriesCount)
126 ChartTypeTemplate::applyStyle2(xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount);
127 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, "BorderStyle",
128 uno::Any(drawing::LineStyle_NONE));
131 void HistogramChartTypeTemplate::resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram)
133 ChartTypeTemplate::resetStyles2(xDiagram);
134 std::vector<rtl::Reference<DataSeries>> aSeriesVec(xDiagram->getDataSeries());
135 uno::Any aLineStyleAny(drawing::LineStyle_NONE);
136 for (auto const& series : aSeriesVec)
138 if (series->getPropertyValue("BorderStyle") == aLineStyleAny)
140 series->setPropertyToDefault("BorderStyle");
144 xDiagram->setVertical(false);
147 rtl::Reference<DataInterpreter> HistogramChartTypeTemplate::getDataInterpreter2()
149 if (!m_xDataInterpreter.is())
150 m_xDataInterpreter.set(new HistogramDataInterpreter);
152 return m_xDataInterpreter;
155 IMPLEMENT_FORWARD_XINTERFACE2(HistogramChartTypeTemplate, ChartTypeTemplate, OPropertySet)
156 IMPLEMENT_FORWARD_XTYPEPROVIDER2(HistogramChartTypeTemplate, ChartTypeTemplate, OPropertySet)
158 } // namespace chart
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */