tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / model / template / ColumnLineDataInterpreter.cxx
blob5cce30cd97a072645f20893183d6182a57bf36dd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
22 #include <osl/diagnose.h>
24 #include <algorithm>
26 using namespace ::com::sun::star;
27 using namespace ::com::sun::star::chart2;
29 using ::com::sun::star::uno::Reference;
30 using ::com::sun::star::uno::Sequence;
32 namespace chart
35 // explicit
36 ColumnLineDataInterpreter::ColumnLineDataInterpreter(
37 sal_Int32 nNumberOfLines ) :
38 m_nNumberOfLines( nNumberOfLines )
41 ColumnLineDataInterpreter::~ColumnLineDataInterpreter()
44 // ____ DataInterpreter ____
45 InterpretedData ColumnLineDataInterpreter::interpretDataSource(
46 const Reference< data::XDataSource >& xSource,
47 const Sequence< beans::PropertyValue >& aArguments,
48 const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
50 InterpretedData aResult( DataInterpreter::interpretDataSource( xSource, aArguments, aSeriesToReUse ));
52 // the base class should return one group
53 OSL_ASSERT( aResult.Series.size() == 1 );
54 if( aResult.Series.size() == 1 )
56 sal_Int32 nNumberOfSeries = aResult.Series[0].size();
58 // if we have more than one series put the last nNumOfLines ones into a new group
59 if( nNumberOfSeries > 1 && m_nNumberOfLines > 0 )
61 sal_Int32 nNumOfLines = std::min( m_nNumberOfLines, nNumberOfSeries - 1 );
62 aResult.Series.resize(2);
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 );
74 return aResult;
77 } // namespace chart
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */