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