bump product version to 4.1.6.2
[LibreOffice.git] / oox / source / drawingml / chart / datasourceconverter.cxx
blobea22348c3cc0822a2f4abf13420bc9f92d3c6a03
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 "oox/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 // ============================================================================
33 using namespace ::com::sun::star::chart2::data;
34 using namespace ::com::sun::star::uno;
36 // ============================================================================
38 DataSequenceConverter::DataSequenceConverter( const ConverterRoot& rParent, DataSequenceModel& rModel ) :
39 ConverterBase< DataSequenceModel >( rParent, rModel )
43 DataSequenceConverter::~DataSequenceConverter()
47 Reference< XDataSequence > DataSequenceConverter::createDataSequence( const OUString& rRole )
49 // create data sequence from data source model (virtual call at chart converter)
50 Reference< XDataSequence > xDataSeq;
51 if( getChartConverter() )
53 // the internal data table does not support complex labels
54 // this is only supported in Calc!!!
55 // merge the labels into a single one
56 if(rRole == "label")
58 mrModel.mnPointCount = std::min<sal_Int32>(mrModel.mnPointCount, 1);
59 OUStringBuffer aTitle;
60 bool bFirst = true;
61 for(DataSequenceModel::AnyMap::const_iterator itr = mrModel.maData.begin(),
62 itrEnd = mrModel.maData.end(); itr != itrEnd; ++itr)
64 Any aAny = itr->second;
65 if(aAny.has<OUString>())
67 if(!bFirst)
68 aTitle.append(" ");
70 aTitle.append(aAny.get<OUString>());
71 bFirst = false;
75 if(!bFirst)
77 mrModel.maData.clear();
78 mrModel.maData.insert(std::make_pair<sal_Int32, Any>(1, Any(aTitle.makeStringAndClear())));
81 xDataSeq = getChartConverter()->createDataSequence( getChartDocument()->getDataProvider(), mrModel );
83 // set sequen ce role
84 PropertySet aSeqProp( xDataSeq );
85 aSeqProp.setProperty( PROP_Role, rRole );
87 return xDataSeq;
90 // ============================================================================
92 DataSourceConverter::DataSourceConverter( const ConverterRoot& rParent, DataSourceModel& rModel ) :
93 ConverterBase< DataSourceModel >( rParent, rModel )
97 DataSourceConverter::~DataSourceConverter()
101 Reference< XDataSequence > DataSourceConverter::createDataSequence( const OUString& rRole )
103 Reference< XDataSequence > xDataSeq;
104 if( mrModel.mxDataSeq.is() )
106 DataSequenceConverter aDataSeqConv( *this, *mrModel.mxDataSeq );
107 xDataSeq = aDataSeqConv.createDataSequence( rRole );
109 return xDataSeq;
112 // ============================================================================
114 } // namespace chart
115 } // namespace drawingml
116 } // namespace oox
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */