Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / oox / source / drawingml / chart / datasourceconverter.cxx
blobbcfbf1bf84066fc75ac6ab5d49e41bcfc615f0ef
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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 <drawingml/chart/datasourceconverter.hxx>
22 #include <com/sun/star/chart2/XChartDocument.hpp>
23 #include <oox/drawingml/chart/chartconverter.hxx>
24 #include <oox/drawingml/chart/datasourcemodel.hxx>
25 #include <oox/token/properties.hxx>
27 namespace oox {
28 namespace drawingml {
29 namespace chart {
31 using namespace ::com::sun::star::chart2::data;
32 using namespace ::com::sun::star::uno;
34 DataSequenceConverter::DataSequenceConverter( const ConverterRoot& rParent, DataSequenceModel& rModel ) :
35 ConverterBase< DataSequenceModel >( rParent, rModel )
39 DataSequenceConverter::~DataSequenceConverter()
43 Reference< XDataSequence > DataSequenceConverter::createDataSequence( const OUString& rRole )
45 // create data sequence from data source model (virtual call at chart converter)
46 Reference< XDataSequence > xDataSeq;
47 // the internal data table does not support complex labels
48 // this is only supported in Calc!!!
49 // merge the labels into a single one
50 if(rRole == "label")
52 mrModel.mnPointCount = std::min<sal_Int32>(mrModel.mnPointCount, 1);
53 OUStringBuffer aTitle;
54 bool bFirst = true;
55 for (auto const& elem : mrModel.maData)
57 Any aAny = elem.second;
58 if(aAny.has<OUString>())
60 if(!bFirst)
61 aTitle.append(" ");
63 aTitle.append(aAny.get<OUString>());
64 bFirst = false;
68 if(!bFirst)
70 mrModel.maData.clear();
71 mrModel.maData.insert(std::make_pair<sal_Int32, Any>(0, Any(aTitle.makeStringAndClear())));
74 xDataSeq = getChartConverter().createDataSequence(getChartDocument()->getDataProvider(), mrModel, rRole);
76 // set sequence role
77 PropertySet aSeqProp( xDataSeq );
78 aSeqProp.setProperty( PROP_Role, rRole );
79 return xDataSeq;
82 DataSourceConverter::DataSourceConverter( const ConverterRoot& rParent, DataSourceModel& rModel ) :
83 ConverterBase< DataSourceModel >( rParent, rModel )
87 DataSourceConverter::~DataSourceConverter()
91 Reference< XDataSequence > DataSourceConverter::createDataSequence( const OUString& rRole )
93 Reference< XDataSequence > xDataSeq;
94 if( mrModel.mxDataSeq.is() )
96 DataSequenceConverter aDataSeqConv( *this, *mrModel.mxDataSeq );
97 xDataSeq = aDataSeqConv.createDataSequence( rRole );
99 return xDataSeq;
102 } // namespace chart
103 } // namespace drawingml
104 } // namespace oox
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */