Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/chart2/source/model/template/ColumnLineDataInterpreter.cxx
Line
Count
Source (jump to first uncovered line)
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 "ColumnLineDataInterpreter.hxx"
21
#include <DataSeries.hxx>
22
#include <osl/diagnose.h>
23
24
#include <algorithm>
25
26
using namespace ::com::sun::star;
27
using namespace ::com::sun::star::chart2;
28
29
using ::com::sun::star::uno::Reference;
30
using ::com::sun::star::uno::Sequence;
31
32
namespace chart
33
{
34
35
// explicit
36
ColumnLineDataInterpreter::ColumnLineDataInterpreter(
37
    sal_Int32 nNumberOfLines ) :
38
0
        m_nNumberOfLines( nNumberOfLines )
39
0
{}
40
41
ColumnLineDataInterpreter::~ColumnLineDataInterpreter()
42
0
{}
43
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 )
49
0
{
50
0
    InterpretedData aResult(  DataInterpreter::interpretDataSource( xSource, aArguments, aSeriesToReUse ));
51
52
    // the base class should return one group
53
0
    OSL_ASSERT( aResult.Series.size() == 1 );
54
0
    if( aResult.Series.size() == 1 )
55
0
    {
56
0
        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
0
        if( nNumberOfSeries > 1 && m_nNumberOfLines > 0 )
60
0
        {
61
0
            sal_Int32 nNumOfLines = std::min( m_nNumberOfLines, nNumberOfSeries - 1 );
62
0
            aResult.Series.resize(2);
63
64
0
            std::vector< rtl::Reference< DataSeries > > & rColumnDataSeries = aResult.Series[0];
65
0
            std::vector< rtl::Reference< DataSeries > > & rLineDataSeries   = aResult.Series[1];
66
0
            rLineDataSeries.resize( nNumOfLines );
67
0
            std::copy( std::cbegin(rColumnDataSeries) + nNumberOfSeries - nNumOfLines,
68
0
                         std::cbegin(rColumnDataSeries) + nNumberOfSeries,
69
0
                         rLineDataSeries.begin() );
70
0
            rColumnDataSeries.resize( nNumberOfSeries - nNumOfLines );
71
0
        }
72
0
    }
73
74
0
    return aResult;
75
0
}
76
77
} // namespace chart
78
79
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */