Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx
Line
Count
Source
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
#pragma once
20
21
#include <WrappedProperty.hxx>
22
#include "Chart2ModelContact.hxx"
23
#include <DataSeries.hxx>
24
25
#include <memory>
26
#include <utility>
27
#include <vector>
28
29
namespace chart::wrapper
30
{
31
32
enum tSeriesOrDiagramPropertyType
33
{
34
    DATA_SERIES,
35
    DIAGRAM
36
};
37
38
//PROPERTYTYPE is the type of the outer property
39
40
template< typename PROPERTYTYPE >
41
class WrappedSeriesOrDiagramProperty : public WrappedProperty
42
{
43
public:
44
    virtual PROPERTYTYPE getValueFromSeries( const css::uno::Reference< css::beans::XPropertySet >& xSeriesPropertySet ) const =0;
45
    virtual void setValueToSeries( const css::uno::Reference< css::beans::XPropertySet >& xSeriesPropertySet, const PROPERTYTYPE & aNewValue ) const =0;
46
47
    explicit WrappedSeriesOrDiagramProperty( const OUString& rName, const css::uno::Any& rDefaulValue
48
        , std::shared_ptr<Chart2ModelContact> spChart2ModelContact
49
        , tSeriesOrDiagramPropertyType ePropertyType )
50
0
            : WrappedProperty(rName,OUString())
51
0
            , m_spChart2ModelContact(std::move(spChart2ModelContact))
52
0
            , m_aOuterValue(rDefaulValue)
53
0
            , m_aDefaultValue(rDefaulValue)
54
0
            , m_ePropertyType( ePropertyType )
55
0
    {
56
0
    }
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<int>::WrappedSeriesOrDiagramProperty(rtl::OUString const&, com::sun::star::uno::Any const&, std::__1::shared_ptr<chart::wrapper::Chart2ModelContact>, chart::wrapper::tSeriesOrDiagramPropertyType)
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<double>::WrappedSeriesOrDiagramProperty(rtl::OUString const&, com::sun::star::uno::Any const&, std::__1::shared_ptr<chart::wrapper::Chart2ModelContact>, chart::wrapper::tSeriesOrDiagramPropertyType)
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<bool>::WrappedSeriesOrDiagramProperty(rtl::OUString const&, com::sun::star::uno::Any const&, std::__1::shared_ptr<chart::wrapper::Chart2ModelContact>, chart::wrapper::tSeriesOrDiagramPropertyType)
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartErrorCategory>::WrappedSeriesOrDiagramProperty(rtl::OUString const&, com::sun::star::uno::Any const&, std::__1::shared_ptr<chart::wrapper::Chart2ModelContact>, chart::wrapper::tSeriesOrDiagramPropertyType)
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartErrorIndicatorType>::WrappedSeriesOrDiagramProperty(rtl::OUString const&, com::sun::star::uno::Any const&, std::__1::shared_ptr<chart::wrapper::Chart2ModelContact>, chart::wrapper::tSeriesOrDiagramPropertyType)
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<rtl::OUString>::WrappedSeriesOrDiagramProperty(rtl::OUString const&, com::sun::star::uno::Any const&, std::__1::shared_ptr<chart::wrapper::Chart2ModelContact>, chart::wrapper::tSeriesOrDiagramPropertyType)
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartRegressionCurveType>::WrappedSeriesOrDiagramProperty(rtl::OUString const&, com::sun::star::uno::Any const&, std::__1::shared_ptr<chart::wrapper::Chart2ModelContact>, chart::wrapper::tSeriesOrDiagramPropertyType)
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> >::WrappedSeriesOrDiagramProperty(rtl::OUString const&, com::sun::star::uno::Any const&, std::__1::shared_ptr<chart::wrapper::Chart2ModelContact>, chart::wrapper::tSeriesOrDiagramPropertyType)
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::uno::Reference<com::sun::star::graphic::XGraphic> >::WrappedSeriesOrDiagramProperty(rtl::OUString const&, com::sun::star::uno::Any const&, std::__1::shared_ptr<chart::wrapper::Chart2ModelContact>, chart::wrapper::tSeriesOrDiagramPropertyType)
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::awt::Size>::WrappedSeriesOrDiagramProperty(rtl::OUString const&, com::sun::star::uno::Any const&, std::__1::shared_ptr<chart::wrapper::Chart2ModelContact>, chart::wrapper::tSeriesOrDiagramPropertyType)
57
58
    bool detectInnerValue( PROPERTYTYPE& rValue, bool& rHasAmbiguousValue ) const
59
0
    {
60
0
        rHasAmbiguousValue = false;
61
0
        if( m_ePropertyType != DIAGRAM || !m_spChart2ModelContact )
62
0
            return false;
63
0
        bool bHasDetectableInnerValue = false;
64
0
        rtl::Reference<Diagram> xDiagram = m_spChart2ModelContact->getDiagram();
65
0
        if (!xDiagram)
66
0
            return false;
67
0
        std::vector< rtl::Reference< DataSeries > > aSeriesVector =
68
0
            xDiagram->getDataSeries();
69
0
        for (auto const& series : aSeriesVector)
70
0
        {
71
0
            PROPERTYTYPE aCurValue = getValueFromSeries( series );
72
0
            if( !bHasDetectableInnerValue )
73
0
                rValue = aCurValue;
74
0
            else
75
0
            {
76
0
                if( rValue != aCurValue )
77
0
                {
78
0
                    rHasAmbiguousValue = true;
79
0
                    break;
80
0
                }
81
0
                else
82
0
                    rValue = aCurValue;
83
0
            }
84
0
            bHasDetectableInnerValue = true;
85
0
        }
86
0
        return bHasDetectableInnerValue;
87
0
    }
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<int>::detectInnerValue(int&, bool&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<double>::detectInnerValue(double&, bool&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<bool>::detectInnerValue(bool&, bool&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartErrorCategory>::detectInnerValue(com::sun::star::chart::ChartErrorCategory&, bool&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartErrorIndicatorType>::detectInnerValue(com::sun::star::chart::ChartErrorIndicatorType&, bool&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<rtl::OUString>::detectInnerValue(rtl::OUString&, bool&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartRegressionCurveType>::detectInnerValue(com::sun::star::chart::ChartRegressionCurveType&, bool&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> >::detectInnerValue(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>&, bool&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::uno::Reference<com::sun::star::graphic::XGraphic> >::detectInnerValue(com::sun::star::uno::Reference<com::sun::star::graphic::XGraphic>&, bool&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::awt::Size>::detectInnerValue(com::sun::star::awt::Size&, bool&) const
88
    void setInnerValue( PROPERTYTYPE aNewValue ) const
89
0
    {
90
0
        if( m_ePropertyType == DIAGRAM &&
91
0
            m_spChart2ModelContact )
92
0
        {
93
0
            std::vector< rtl::Reference< DataSeries > > aSeriesVector =
94
0
                m_spChart2ModelContact->getDiagram()->getDataSeries();
95
0
            for (auto const& series : aSeriesVector)
96
0
            {
97
0
                setValueToSeries( series, aNewValue );
98
0
            }
99
0
        }
100
0
    }
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<int>::setInnerValue(int) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<double>::setInnerValue(double) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<bool>::setInnerValue(bool) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartErrorCategory>::setInnerValue(com::sun::star::chart::ChartErrorCategory) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartErrorIndicatorType>::setInnerValue(com::sun::star::chart::ChartErrorIndicatorType) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<rtl::OUString>::setInnerValue(rtl::OUString) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartRegressionCurveType>::setInnerValue(com::sun::star::chart::ChartRegressionCurveType) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> >::setInnerValue(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::uno::Reference<com::sun::star::graphic::XGraphic> >::setInnerValue(com::sun::star::uno::Reference<com::sun::star::graphic::XGraphic>) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::awt::Size>::setInnerValue(com::sun::star::awt::Size) const
101
    virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override
102
0
    {
103
0
        PROPERTYTYPE aNewValue = PROPERTYTYPE();
104
0
        if( ! (rOuterValue >>= aNewValue) )
105
0
            throw css::lang::IllegalArgumentException( u"statistic property requires different type"_ustr, nullptr, 0 );
106
107
0
        if( m_ePropertyType == DIAGRAM )
108
0
        {
109
0
            m_aOuterValue = rOuterValue;
110
111
0
            bool bHasAmbiguousValue = false;
112
0
            PROPERTYTYPE aOldValue = PROPERTYTYPE();
113
0
            if( detectInnerValue( aOldValue, bHasAmbiguousValue ) )
114
0
            {
115
0
                if( bHasAmbiguousValue || aNewValue != aOldValue )
116
0
                    setInnerValue( aNewValue );
117
0
            }
118
0
        }
119
0
        else
120
0
        {
121
0
            setValueToSeries( xInnerPropertySet, aNewValue );
122
0
        }
123
0
    }
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<int>::setPropertyValue(com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<double>::setPropertyValue(com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<bool>::setPropertyValue(com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartErrorCategory>::setPropertyValue(com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartErrorIndicatorType>::setPropertyValue(com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<rtl::OUString>::setPropertyValue(com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartRegressionCurveType>::setPropertyValue(com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> >::setPropertyValue(com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::uno::Reference<com::sun::star::graphic::XGraphic> >::setPropertyValue(com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::awt::Size>::setPropertyValue(com::sun::star::uno::Any const&, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
124
125
    virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override
126
0
    {
127
0
        if( m_ePropertyType == DIAGRAM )
128
0
        {
129
0
            bool bHasAmbiguousValue = false;
130
0
            PROPERTYTYPE aValue = PROPERTYTYPE();
131
0
            if( detectInnerValue( aValue, bHasAmbiguousValue ) )
132
0
            {
133
0
                if(bHasAmbiguousValue)
134
0
                    m_aOuterValue = m_aDefaultValue;
135
0
                else
136
0
                    m_aOuterValue <<= aValue;
137
0
            }
138
0
            return m_aOuterValue;
139
0
        }
140
0
        else
141
0
        {
142
0
            css::uno::Any aRet( m_aDefaultValue );
143
0
            aRet <<= getValueFromSeries( xInnerPropertySet );
144
0
            return aRet;
145
0
        }
146
0
    }
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<int>::getPropertyValue(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<double>::getPropertyValue(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<bool>::getPropertyValue(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartErrorCategory>::getPropertyValue(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartErrorIndicatorType>::getPropertyValue(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<rtl::OUString>::getPropertyValue(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartRegressionCurveType>::getPropertyValue(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> >::getPropertyValue(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::uno::Reference<com::sun::star::graphic::XGraphic> >::getPropertyValue(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::awt::Size>::getPropertyValue(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&) const
147
148
    virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& /* xInnerPropertyState */ ) const override
149
0
    {
150
0
        return m_aDefaultValue;
151
0
    }
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<int>::getPropertyDefault(com::sun::star::uno::Reference<com::sun::star::beans::XPropertyState> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<double>::getPropertyDefault(com::sun::star::uno::Reference<com::sun::star::beans::XPropertyState> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<bool>::getPropertyDefault(com::sun::star::uno::Reference<com::sun::star::beans::XPropertyState> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartErrorCategory>::getPropertyDefault(com::sun::star::uno::Reference<com::sun::star::beans::XPropertyState> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartErrorIndicatorType>::getPropertyDefault(com::sun::star::uno::Reference<com::sun::star::beans::XPropertyState> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<rtl::OUString>::getPropertyDefault(com::sun::star::uno::Reference<com::sun::star::beans::XPropertyState> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::chart::ChartRegressionCurveType>::getPropertyDefault(com::sun::star::uno::Reference<com::sun::star::beans::XPropertyState> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> >::getPropertyDefault(com::sun::star::uno::Reference<com::sun::star::beans::XPropertyState> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::uno::Reference<com::sun::star::graphic::XGraphic> >::getPropertyDefault(com::sun::star::uno::Reference<com::sun::star::beans::XPropertyState> const&) const
Unexecuted instantiation: chart::wrapper::WrappedSeriesOrDiagramProperty<com::sun::star::awt::Size>::getPropertyDefault(com::sun::star::uno::Reference<com::sun::star::beans::XPropertyState> const&) const
152
153
protected:
154
    std::shared_ptr< Chart2ModelContact >  m_spChart2ModelContact;
155
    mutable css::uno::Any         m_aOuterValue;
156
    css::uno::Any                 m_aDefaultValue;
157
    tSeriesOrDiagramPropertyType               m_ePropertyType;
158
};
159
160
} //namespace chart::wrapper
161
162
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */