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 "ColumnLineDataInterpreter.hxx"
21 #include "DataSeries.hxx"
23 #include "DataSeriesHelper.hxx"
24 #include "CommonConverters.hxx"
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/chart2/data/XDataSink.hpp>
32 using namespace ::com::sun::star
;
33 using namespace ::com::sun::star::chart2
;
34 using namespace ::std
;
36 using ::com::sun::star::uno::Reference
;
37 using ::com::sun::star::uno::Sequence
;
43 ColumnLineDataInterpreter::ColumnLineDataInterpreter(
44 sal_Int32 nNumberOfLines
,
45 const Reference
< uno::XComponentContext
> & xContext
) :
46 DataInterpreter( xContext
),
47 m_nNumberOfLines( nNumberOfLines
)
50 ColumnLineDataInterpreter::~ColumnLineDataInterpreter()
53 // ____ XDataInterpreter ____
54 InterpretedData SAL_CALL
ColumnLineDataInterpreter::interpretDataSource(
55 const Reference
< data::XDataSource
>& xSource
,
56 const Sequence
< beans::PropertyValue
>& aArguments
,
57 const Sequence
< Reference
< XDataSeries
> >& aSeriesToReUse
)
58 throw (uno::RuntimeException
, std::exception
)
60 InterpretedData
aResult( DataInterpreter::interpretDataSource( xSource
, aArguments
, aSeriesToReUse
));
62 // the base class should return one group
63 OSL_ASSERT( aResult
.Series
.getLength() == 1 );
64 if( aResult
.Series
.getLength() == 1 )
66 sal_Int32 nNumberOfSeries
= aResult
.Series
[0].getLength();
68 // if we have more than one series put the last nNumOfLines ones into a new group
69 if( nNumberOfSeries
> 1 && m_nNumberOfLines
> 0 )
71 sal_Int32 nNumOfLines
= ::std::min( m_nNumberOfLines
, nNumberOfSeries
- 1 );
72 aResult
.Series
.realloc(2);
74 Sequence
< Reference
< XDataSeries
> > & rColumnDataSeries
= aResult
.Series
[0];
75 Sequence
< Reference
< XDataSeries
> > & rLineDataSeries
= aResult
.Series
[1];
76 rLineDataSeries
.realloc( nNumOfLines
);
77 ::std::copy( rColumnDataSeries
.getConstArray() + nNumberOfSeries
- nNumOfLines
,
78 rColumnDataSeries
.getConstArray() + nNumberOfSeries
,
79 rLineDataSeries
.getArray() );
80 rColumnDataSeries
.realloc( nNumberOfSeries
- nNumOfLines
);
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */