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 "oox/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 :
32 :
33 : using namespace ::com::sun::star::chart2::data;
34 : using namespace ::com::sun::star::uno;
35 :
36 :
37 :
38 0 : DataSequenceConverter::DataSequenceConverter( const ConverterRoot& rParent, DataSequenceModel& rModel ) :
39 0 : ConverterBase< DataSequenceModel >( rParent, rModel )
40 : {
41 0 : }
42 :
43 0 : DataSequenceConverter::~DataSequenceConverter()
44 : {
45 0 : }
46 :
47 0 : Reference< XDataSequence > DataSequenceConverter::createDataSequence( const OUString& rRole )
48 : {
49 : // create data sequence from data source model (virtual call at chart converter)
50 0 : Reference< XDataSequence > xDataSeq;
51 0 : if( getChartConverter() )
52 : {
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 0 : if(rRole == "label")
57 : {
58 0 : mrModel.mnPointCount = std::min<sal_Int32>(mrModel.mnPointCount, 1);
59 0 : OUStringBuffer aTitle;
60 0 : bool bFirst = true;
61 0 : for(DataSequenceModel::AnyMap::const_iterator itr = mrModel.maData.begin(),
62 0 : itrEnd = mrModel.maData.end(); itr != itrEnd; ++itr)
63 : {
64 0 : Any aAny = itr->second;
65 0 : if(aAny.has<OUString>())
66 : {
67 0 : if(!bFirst)
68 0 : aTitle.append(" ");
69 :
70 0 : aTitle.append(aAny.get<OUString>());
71 0 : bFirst = false;
72 : }
73 0 : }
74 :
75 0 : if(!bFirst)
76 : {
77 0 : mrModel.maData.clear();
78 0 : mrModel.maData.insert(std::make_pair<sal_Int32, Any>(1, Any(aTitle.makeStringAndClear())));
79 0 : }
80 : }
81 0 : xDataSeq = getChartConverter()->createDataSequence( getChartDocument()->getDataProvider(), mrModel );
82 :
83 : // set sequen ce role
84 0 : PropertySet aSeqProp( xDataSeq );
85 0 : aSeqProp.setProperty( PROP_Role, rRole );
86 : }
87 0 : return xDataSeq;
88 : }
89 :
90 :
91 :
92 0 : DataSourceConverter::DataSourceConverter( const ConverterRoot& rParent, DataSourceModel& rModel ) :
93 0 : ConverterBase< DataSourceModel >( rParent, rModel )
94 : {
95 0 : }
96 :
97 0 : DataSourceConverter::~DataSourceConverter()
98 : {
99 0 : }
100 :
101 0 : Reference< XDataSequence > DataSourceConverter::createDataSequence( const OUString& rRole )
102 : {
103 0 : Reference< XDataSequence > xDataSeq;
104 0 : if( mrModel.mxDataSeq.is() )
105 : {
106 0 : DataSequenceConverter aDataSeqConv( *this, *mrModel.mxDataSeq );
107 0 : xDataSeq = aDataSeqConv.createDataSequence( rRole );
108 : }
109 0 : return xDataSeq;
110 : }
111 :
112 :
113 :
114 : } // namespace chart
115 : } // namespace drawingml
116 0 : } // namespace oox
117 :
118 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|