Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/chart2/source/inc/ReferenceSizeProvider.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 <com/sun/star/awt/Size.hpp>
22
#include <rtl/ref.hxx>
23
#include <ChartModel.hxx>
24
25
namespace com::sun::star {
26
    namespace chart2 {
27
        class XTitle;
28
        class XTitled;
29
    }
30
    namespace beans {
31
        class XPropertySet;
32
    }
33
}
34
35
namespace chart
36
{
37
38
class ReferenceSizeProvider
39
{
40
public:
41
42
    enum AutoResizeState
43
    {
44
        AUTO_RESIZE_YES,
45
        AUTO_RESIZE_NO,
46
        AUTO_RESIZE_AMBIGUOUS,
47
        AUTO_RESIZE_UNKNOWN
48
    };
49
50
    ReferenceSizeProvider(
51
        css::awt::Size aPageSize,
52
        const rtl::Reference<::chart::ChartModel> & xChartDoc );
53
54
0
    const css::awt::Size& getPageSize() const { return m_aPageSize;}
55
56
    /** Retrieves the state auto-resize from all objects that support this
57
        feature.  If all objects return the same state, AUTO_RESIZE_YES or
58
        AUTO_RESIZE_NO is returned.
59
60
        If no object supporting the feature is found, AUTO_RESIZE_UNKNOWN is
61
        returned.  If there are multiple objects, some with state YES and some
62
        with state NO, AUTO_RESIZE_AMBIGUOUS is returned.
63
    */
64
    static AutoResizeState getAutoResizeState(
65
        const rtl::Reference<::chart::ChartModel> & xChartDoc );
66
67
    /** sets or resets the auto-resize at all objects that support this feature
68
        for text to the opposite of the current setting.  If the current state
69
        is ambiguous, it is turned on.  If the current state is unknown it stays
70
        unknown.
71
    */
72
    void toggleAutoResizeState();
73
74
    /** Sets the ReferencePageSize according to the internal settings of this
75
        class at the XPropertySet, and the adapted font sizes if bAdaptFontSizes
76
        is </sal_True>.
77
     */
78
    void setValuesAtPropertySet(
79
        const css::uno::Reference< css::beans::XPropertySet > & xProp,
80
        bool bAdaptFontSizes = true );
81
82
    /** Sets the ReferencePageSize according to the internal settings of this
83
        class at the XTitle, and the adapted font sizes at the contained
84
        XFormattedStrings
85
     */
86
    void setValuesAtTitle(
87
        const css::uno::Reference< css::chart2::XTitle > & xTitle );
88
89
    /** Sets the internal value at all data series in the currently set model.
90
        This is useful, if you have changed a chart-type and thus probably added
91
        some new data series via model functionality.
92
     */
93
    void setValuesAtAllDataSeries();
94
95
private:
96
0
    bool useAutoScale() const { return m_bUseAutoScale;}
97
98
    /** sets the auto-resize at all objects that support this feature for text.
99
        eNewState must be either AUTO_RESIZE_YES or AUTO_RESIZE_NO
100
    */
101
    void setAutoResizeState( AutoResizeState eNewState );
102
103
    /** Retrieves the auto-resize state from the given propertyset.  The result
104
        will be put into eInOutState.  If you initialize eInOutState with
105
        AUTO_RESIZE_UNKNOWN, you will get the actual state.  If you pass any
106
        other state, the result will be the accumulated state,
107
        esp. AUTO_RESIZE_AMBIGUOUS, if the value was NO before, and is YES for
108
        the current property set, or the other way round.
109
     */
110
    static void getAutoResizeFromPropSet(
111
        const css::uno::Reference< css::beans::XPropertySet > & xProp,
112
        AutoResizeState & rInOutState );
113
114
    void impl_setValuesAtTitled(
115
        const css::uno::Reference< css::chart2::XTitled > & xTitled );
116
    static void impl_getAutoResizeFromTitled(
117
        const css::uno::Reference< css::chart2::XTitled > & xTitled,
118
        AutoResizeState & rInOutState );
119
120
    css::awt::Size m_aPageSize;
121
    rtl::Reference<::chart::ChartModel> m_xChartDoc;
122
    bool      m_bUseAutoScale;
123
};
124
125
} //  namespace chart
126
127
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */