LibreOffice Module chart2 (master) 1
ColumnLineDataInterpreter.cxx
Go to the documentation of this file.
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
21#include <DataSeries.hxx>
22#include <osl/diagnose.h>
23
24#include <algorithm>
25
26using namespace ::com::sun::star;
27using namespace ::com::sun::star::chart2;
28
29using ::com::sun::star::uno::Reference;
30using ::com::sun::star::uno::Sequence;
31
32namespace chart
33{
34
35// explicit
37 sal_Int32 nNumberOfLines ) :
38 m_nNumberOfLines( nNumberOfLines )
39{}
40
42{}
43
44// ____ DataInterpreter ____
46 const Reference< data::XDataSource >& xSource,
47 const Sequence< beans::PropertyValue >& aArguments,
48 const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
49{
50 InterpretedData aResult( DataInterpreter::interpretDataSource( xSource, aArguments, aSeriesToReUse ));
51
52 // the base class should return one group
53 OSL_ASSERT( aResult.Series.size() == 1 );
54 if( aResult.Series.size() == 1 )
55 {
56 sal_Int32 nNumberOfSeries = aResult.Series[0].size();
57
58 // if we have more than one series put the last nNumOfLines ones into a new group
59 if( nNumberOfSeries > 1 && m_nNumberOfLines > 0 )
60 {
61 sal_Int32 nNumOfLines = std::min( m_nNumberOfLines, nNumberOfSeries - 1 );
62 aResult.Series.resize(2);
63
64 std::vector< rtl::Reference< DataSeries > > & rColumnDataSeries = aResult.Series[0];
65 std::vector< rtl::Reference< DataSeries > > & rLineDataSeries = aResult.Series[1];
66 rLineDataSeries.resize( nNumOfLines );
67 std::copy( std::cbegin(rColumnDataSeries) + nNumberOfSeries - nNumOfLines,
68 std::cbegin(rColumnDataSeries) + nNumberOfSeries,
69 rLineDataSeries.begin() );
70 rColumnDataSeries.resize( nNumberOfSeries - nNumOfLines );
71 }
72 }
73
74 return aResult;
75}
76
77} // namespace chart
78
79/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ColumnLineDataInterpreter(sal_Int32 nNumberOfLines)
virtual InterpretedData interpretDataSource(const css::uno::Reference< css::chart2::data::XDataSource > &xSource, const css::uno::Sequence< css::beans::PropertyValue > &aArguments, const std::vector< rtl::Reference<::chart::DataSeries > > &aSeriesToReUse) override
virtual InterpretedData interpretDataSource(const css::uno::Reference< css::chart2::data::XDataSource > &xSource, const css::uno::Sequence< css::beans::PropertyValue > &aArguments, const std::vector< rtl::Reference< ::chart::DataSeries > > &aSeriesToReUse)
Interprets the given data.
Sequence< PropertyValue > aArguments
offers tooling to interpret different data sources in a structural and chart-type-dependent way.
std::vector< std::vector< rtl::Reference<::chart::DataSeries > > > Series