LibreOffice Module oox (master) 1
datasourceconverter.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
22#include <com/sun/star/chart2/XChartDocument.hpp>
25#include <oox/token/properties.hxx>
26#include <svl/zforlist.hxx>
27
28namespace oox::drawingml::chart {
29
30using namespace ::com::sun::star::chart2::data;
31using namespace ::com::sun::star::uno;
32
34 ConverterBase< DataSequenceModel >( rParent, rModel )
35{
36}
37
39{
40}
41
43{
44 // create data sequence from data source model (virtual call at chart converter)
46 // the internal data table does not support complex labels
47 // this is only supported in Calc!!!
48 // merge the labels into a single one
49 if(rRole == "label")
50 {
51 mrModel.mnPointCount = std::min<sal_Int32>(mrModel.mnPointCount, 1);
52 OUStringBuffer aTitle;
53 bool bFirst = true;
54 for (auto const& elem : mrModel.maData)
55 {
56 Any aAny = elem.second;
57 if(aAny.has<OUString>())
58 {
59 if(!bFirst)
60 aTitle.append(" ");
61
62 aTitle.append(aAny.get<OUString>());
63 bFirst = false;
64 }
65 }
66
67 if(!bFirst)
68 {
69 mrModel.maData.clear();
70 mrModel.maData.insert(std::make_pair<sal_Int32, Any>(0, Any(aTitle.makeStringAndClear())));
71 }
72 }
73
74 bool bDateCategories = (mrModel.meFormatType == SvNumFormatType::DATE) && (rRole == "categories");
75 xDataSeq = getChartConverter().createDataSequence(getChartDocument()->getDataProvider(), mrModel,
76 rRole, bDateCategories ? OUString("date") : OUString(""));
77
78 // set sequence role
79 PropertySet aSeqProp( xDataSeq );
80 aSeqProp.setProperty( PROP_Role, rRole );
81 return xDataSeq;
82}
83
85 ConverterBase< DataSourceModel >( rParent, rModel )
86{
87}
88
90{
91}
92
94{
96 if( mrModel.mxDataSeq.is() )
97 {
98 DataSequenceConverter aDataSeqConv( *this, *mrModel.mxDataSeq );
99 xDataSeq = aDataSeqConv.createDataSequence( rRole );
100 }
101 return xDataSeq;
102}
103
104} // namespace oox::drawingml::chart
105
106/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
A wrapper for a UNO property set.
Definition: propertyset.hxx:58
bool setProperty(sal_Int32 nPropId, const Type &rValue)
Puts the passed value into the property set.
virtual css::uno::Reference< css::chart2::data::XDataSequence > createDataSequence(const css::uno::Reference< css::chart2::data::XDataProvider > &rxDataProvider, const DataSequenceModel &rDataSeq, const OUString &rRole, const OUString &aRoleQualifier)
Creates a data sequence from a formula.
Base class of all converter classes.
css::uno::Reference< css::chart2::XChartDocument > const & getChartDocument() const
Returns the API chart document model.
ChartConverter & getChartConverter() const
Returns the chart converter.
css::uno::Reference< css::chart2::data::XDataSequence > createDataSequence(const OUString &rRole)
Creates a data sequence object from the contained formula link.
DataSequenceConverter(const ConverterRoot &rParent, DataSequenceModel &rModel)
css::uno::Reference< css::chart2::data::XDataSequence > createDataSequence(const OUString &rRole)
Creates a data sequence object from the contained series data.
DataSourceConverter(const ConverterRoot &rParent, DataSourceModel &rModel)
sal_Int32 mnPointCount
Number format for double values.
SvNumFormatType meFormatType
Number of category levels.