Line data Source code
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 :
20 : #include "drawingml/chart/datasourceconverter.hxx"
21 :
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"
26 :
27 : namespace oox {
28 : namespace drawingml {
29 : namespace chart {
30 :
31 : using namespace ::com::sun::star::chart2::data;
32 : using namespace ::com::sun::star::uno;
33 :
34 1218 : DataSequenceConverter::DataSequenceConverter( const ConverterRoot& rParent, DataSequenceModel& rModel ) :
35 1218 : ConverterBase< DataSequenceModel >( rParent, rModel )
36 : {
37 1218 : }
38 :
39 1218 : DataSequenceConverter::~DataSequenceConverter()
40 : {
41 1218 : }
42 :
43 1218 : Reference< XDataSequence > DataSequenceConverter::createDataSequence( const OUString& rRole )
44 : {
45 : // create data sequence from data source model (virtual call at chart converter)
46 1218 : Reference< XDataSequence > xDataSeq;
47 1218 : if( getChartConverter() )
48 : {
49 : // the internal data table does not support complex labels
50 : // this is only supported in Calc!!!
51 : // merge the labels into a single one
52 1218 : if(rRole == "label")
53 : {
54 478 : mrModel.mnPointCount = std::min<sal_Int32>(mrModel.mnPointCount, 1);
55 478 : OUStringBuffer aTitle;
56 478 : bool bFirst = true;
57 1432 : for(DataSequenceModel::AnyMap::const_iterator itr = mrModel.maData.begin(),
58 478 : itrEnd = mrModel.maData.end(); itr != itrEnd; ++itr)
59 : {
60 476 : Any aAny = itr->second;
61 476 : if(aAny.has<OUString>())
62 : {
63 476 : if(!bFirst)
64 0 : aTitle.append(" ");
65 :
66 476 : aTitle.append(aAny.get<OUString>());
67 476 : bFirst = false;
68 : }
69 476 : }
70 :
71 478 : if(!bFirst)
72 : {
73 476 : mrModel.maData.clear();
74 476 : mrModel.maData.insert(std::make_pair<sal_Int32, Any>(1, Any(aTitle.makeStringAndClear())));
75 478 : }
76 : }
77 1218 : xDataSeq = getChartConverter()->createDataSequence(getChartDocument()->getDataProvider(), mrModel, rRole);
78 :
79 : // set sequence role
80 1218 : PropertySet aSeqProp( xDataSeq );
81 1218 : aSeqProp.setProperty( PROP_Role, rRole );
82 : }
83 1218 : return xDataSeq;
84 : }
85 :
86 740 : DataSourceConverter::DataSourceConverter( const ConverterRoot& rParent, DataSourceModel& rModel ) :
87 740 : ConverterBase< DataSourceModel >( rParent, rModel )
88 : {
89 740 : }
90 :
91 740 : DataSourceConverter::~DataSourceConverter()
92 : {
93 740 : }
94 :
95 740 : Reference< XDataSequence > DataSourceConverter::createDataSequence( const OUString& rRole )
96 : {
97 740 : Reference< XDataSequence > xDataSeq;
98 740 : if( mrModel.mxDataSeq.is() )
99 : {
100 740 : DataSequenceConverter aDataSeqConv( *this, *mrModel.mxDataSeq );
101 740 : xDataSeq = aDataSeqConv.createDataSequence( rRole );
102 : }
103 740 : return xDataSeq;
104 : }
105 :
106 : } // namespace chart
107 : } // namespace drawingml
108 408 : } // namespace oox
109 :
110 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|