Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/oox/inc/drawingml/chart/converterbase.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
20
#ifndef INCLUDED_OOX_DRAWINGML_CHART_CONVERTERBASE_HXX
21
#define INCLUDED_OOX_DRAWINGML_CHART_CONVERTERBASE_HXX
22
23
#include <drawingml/chart/objectformatter.hxx>
24
25
namespace com::sun::star {
26
    namespace awt { struct Rectangle; }
27
    namespace chart2 { class XChartDocument; }
28
    namespace chart2 { class XTitle; }
29
    namespace drawing { class XShape; }
30
    namespace uno { class XComponentContext; }
31
}
32
namespace oox::core { class XmlFilterBase; }
33
34
namespace oox::drawingml::chart {
35
36
class ChartConverter;
37
struct ChartSpaceModel;
38
struct ConverterData;
39
40
41
const sal_Int32 API_PRIM_AXESSET = 0;
42
const sal_Int32 API_SECN_AXESSET = 1;
43
44
const sal_Int32 API_X_AXIS = 0;
45
const sal_Int32 API_Y_AXIS = 1;
46
const sal_Int32 API_Z_AXIS = 2;
47
48
49
class ConverterRoot
50
{
51
public:
52
    explicit            ConverterRoot(
53
                            ::oox::core::XmlFilterBase& rFilter,
54
                            const ChartConverter& rChartConverter,
55
                            const ChartSpaceModel& rChartModel,
56
                            const css::uno::Reference< css::chart2::XChartDocument >& rxChartDoc,
57
                            const css::awt::Size& rChartSize );
58
    virtual             ~ConverterRoot();
59
60
0
    ConverterRoot(ConverterRoot const &) = default;
61
    ConverterRoot(ConverterRoot &&) = default;
62
    ConverterRoot & operator =(ConverterRoot const &) = default;
63
    ConverterRoot & operator =(ConverterRoot &&) = default;
64
65
    /** Creates an instance for the passed service name, using the process service factory. */
66
    css::uno::Reference< css::uno::XInterface >
67
                        createInstance( const OUString& rServiceName ) const;
68
    css::uno::Reference< css::uno::XComponentContext > const &
69
                        getComponentContext() const;
70
71
protected:
72
    /** Returns the filter object of the imported/exported document. */
73
    ::oox::core::XmlFilterBase& getFilter() const;
74
    /** Returns the chart converter. */
75
    const ChartConverter&     getChartConverter() const;
76
    /** Returns the API chart document model. */
77
    css::uno::Reference< css::chart2::XChartDocument > const &
78
                        getChartDocument() const;
79
    /** Returns the position and size of the chart shape in 1/100 mm. */
80
    const css::awt::Size& getChartSize() const;
81
    /** Returns the default position and size of the chart shape in 1/100 mm. */
82
0
    static css::awt::Size getDefaultPageSize() { return css::awt::Size(16000, 9000); }
83
    /** Returns the object formatter. */
84
    ObjectFormatter&    getFormatter() const;
85
86
    /** Registers a title object and its layout data, needed for conversion of
87
        the title position using the old Chart1 API. */
88
    void                registerTitleLayout(
89
                            const css::uno::Reference< css::chart2::XTitle >& rxTitle,
90
                            const ModelRef< LayoutModel >& rxLayout, ObjectType eObjType,
91
                            sal_Int32 nMainIdx, sal_Int32 nSubIdx );
92
    /** Converts the positions of the main title and all axis titles. */
93
    void                convertTitlePositions();
94
95
private:
96
    std::shared_ptr< ConverterData > mxData;
97
};
98
99
100
/** Base class of all converter classes. Holds a reference to a model structure
101
    of the specified type.
102
 */
103
template< typename ModelType >
104
class ConverterBase : public ConverterRoot
105
{
106
public:
107
0
    const ModelType& getModel() const { return mrModel; }
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::SeriesModel>::getModel() const
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::TypeGroupModel>::getModel() const
108
109
protected:
110
    explicit            ConverterBase( const ConverterRoot& rParent, ModelType& rModel ) :
111
0
                            ConverterRoot( rParent ), mrModel( rModel ) {}
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::ChartSpaceModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::ChartSpaceModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::LayoutModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::LayoutModel&)
Unexecuted instantiation: plotareaconverter.cxx:oox::drawingml::chart::ConverterBase<oox::drawingml::chart::(anonymous namespace)::AxesSetModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::(anonymous namespace)::AxesSetModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::View3DModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::View3DModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::WallFloorModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::WallFloorModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::PlotAreaModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::PlotAreaModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::TextModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::TextModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::TitleModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::TitleModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::LegendModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::LegendModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::UpDownBarsModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::UpDownBarsModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::TypeGroupModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::TypeGroupModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::AxisModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::AxisModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::AxisDispUnitsModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::AxisDispUnitsModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::DataSequenceModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::DataSequenceModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::DataSourceModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::DataSourceModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::DataTableModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::DataTableModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::DataLabelModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::DataLabelModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::DataLabelsModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::DataLabelsModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::ErrorBarModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::ErrorBarModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::TrendlineLabelModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::TrendlineLabelModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::TrendlineModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::TrendlineModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::DataPointModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::DataPointModel&)
Unexecuted instantiation: oox::drawingml::chart::ConverterBase<oox::drawingml::chart::SeriesModel>::ConverterBase(oox::drawingml::chart::ConverterRoot const&, oox::drawingml::chart::SeriesModel&)
112
    virtual             ~ConverterBase() override {}
113
114
protected:
115
    ModelType&          mrModel;
116
};
117
118
119
/** A layout converter calculates positions and sizes for various chart objects.
120
 */
121
class LayoutConverter final : public ConverterBase< LayoutModel >
122
{
123
public:
124
    explicit            LayoutConverter( const ConverterRoot& rParent, LayoutModel& rModel );
125
    virtual             ~LayoutConverter() override;
126
127
    /** Tries to calculate the absolute position and size from the contained
128
        OOXML layout model. Returns true, if returned rectangle is valid. */
129
    bool                calcAbsRectangle( css::awt::Rectangle& orRect ) const;
130
131
    /** Tries to set the position and size from the contained OOXML layout model.
132
        Returns true, if a manual position and size could be calculated. */
133
    bool                convertFromModel( PropertySet& rPropSet );
134
135
    /** Tries to set the position from the contained OOXML layout model. */
136
    void                convertFromModel(
137
                            const css::uno::Reference< css::drawing::XShape >& rxShape,
138
                            double fRotationAngle );
139
0
    bool getAutoLayout() const {return mrModel.mbAutoLayout;}
140
};
141
142
143
} // namespace oox::drawingml::chart
144
145
#endif
146
147
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */