1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
26 #include <svl/zforlist.hxx>
28 namespace oox::drawingml::chart
{
30 using namespace ::com::sun::star::chart2::data
;
31 using namespace ::com::sun::star::uno
;
33 DataSequenceConverter::DataSequenceConverter( const ConverterRoot
& rParent
, DataSequenceModel
& rModel
) :
34 ConverterBase
< DataSequenceModel
>( rParent
, rModel
)
38 DataSequenceConverter::~DataSequenceConverter()
42 Reference
< XDataSequence
> DataSequenceConverter::createDataSequence( const OUString
& rRole
)
44 // create data sequence from data source model (virtual call at chart converter)
45 Reference
< XDataSequence
> xDataSeq
;
46 // the internal data table does not support complex labels
47 // this is only supported in Calc!!!
48 // merge the labels into a single one
51 mrModel
.mnPointCount
= std::min
<sal_Int32
>(mrModel
.mnPointCount
, 1);
52 OUStringBuffer aTitle
;
54 for (auto const& elem
: mrModel
.maData
)
56 Any aAny
= elem
.second
;
57 if(aAny
.has
<OUString
>())
62 aTitle
.append(aAny
.get
<OUString
>());
69 mrModel
.maData
.clear();
70 mrModel
.maData
.insert(std::make_pair
<sal_Int32
, Any
>(0, Any(aTitle
.makeStringAndClear())));
74 bool bDateCategories
= (mrModel
.meFormatType
== SvNumFormatType::DATE
) && (rRole
== "categories");
75 xDataSeq
= getChartConverter().createDataSequence(getChartDocument()->getDataProvider(), mrModel
,
76 rRole
, bDateCategories
? u
"date"_ustr
: u
""_ustr
);
79 PropertySet
aSeqProp( xDataSeq
);
80 aSeqProp
.setProperty( PROP_Role
, rRole
);
82 const sal_Int32 nKey
= getFormatter().getNumberFormatKey(mrModel
.maFormatCode
);
84 aSeqProp
.setProperty(PROP_NumberFormatKey
, nKey
);
89 DataSourceConverter::DataSourceConverter( const ConverterRoot
& rParent
, DataSourceModel
& rModel
) :
90 ConverterBase
< DataSourceModel
>( rParent
, rModel
)
94 DataSourceConverter::~DataSourceConverter()
98 Reference
< XDataSequence
> DataSourceConverter::createDataSequence( const OUString
& rRole
)
100 Reference
< XDataSequence
> xDataSeq
;
101 if( mrModel
.mxDataSeq
.is() )
103 DataSequenceConverter
aDataSeqConv( *this, *mrModel
.mxDataSeq
);
104 xDataSeq
= aDataSeqConv
.createDataSequence( rRole
);
109 } // namespace oox::drawingml::chart
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */