Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/relfld.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
#ifndef INCLUDED_SVX_RELFLD_HXX
20
#define INCLUDED_SVX_RELFLD_HXX
21
22
#include <tools/fldunit.hxx>
23
#include <svtools/unitconv.hxx>
24
#include <vcl/weld/MetricSpinButton.hxx>
25
#include <vcl/weld/SpinButton.hxx>
26
#include <svx/svxdllapi.h>
27
28
class SVX_DLLPUBLIC SvxRelativeField
29
{
30
private:
31
    std::unique_ptr<weld::MetricSpinButton> m_xSpinButton;
32
33
    FieldUnit m_eAbsoluteFieldUnit = FieldUnit::NONE;
34
    FieldUnit m_eFontRelativeFieldUnit = FieldUnit::NONE;
35
    sal_uInt16          m_nRelMin;
36
    sal_uInt16          m_nRelMax;
37
    bool                m_bRelativeMode;
38
    bool                m_bRelative;
39
    bool                m_bNegativeEnabled;
40
    bool m_bFontRelativeMode;
41
42
    DECL_DLLPRIVATE_LINK(ModifyHdl, weld::TextWidget&, void);
43
44
public:
45
    SvxRelativeField(std::unique_ptr<weld::MetricSpinButton> pControl);
46
47
    void            EnableRelativeMode( sal_uInt16 nMin, sal_uInt16 nMax );
48
    void EnableFontRelativeMode();
49
    void            SetRelative( bool bRelative );
50
    void SetFontRelative(FieldUnit eNewRelativeUnit);
51
0
    bool            IsRelative() const { return m_bRelative; }
52
0
    void            EnableNegativeMode() {m_bNegativeEnabled = true;}
53
0
    FieldUnit GetCurrentUnit() const { return m_eFontRelativeFieldUnit; }
54
55
0
    void set_sensitive(bool sensitive) { m_xSpinButton->set_sensitive(sensitive); }
56
0
    bool get_sensitive() const { return m_xSpinButton->get_sensitive(); }
57
0
    void set_value(sal_Int64 nValue, FieldUnit eValueUnit) { m_xSpinButton->set_value(nValue, eValueUnit); }
58
0
    sal_Int64 get_value(FieldUnit eDestUnit) const { return m_xSpinButton->get_value(eDestUnit); }
59
0
    sal_Int64 get_min(FieldUnit eValueUnit) const { return m_xSpinButton->get_min(eValueUnit); }
60
0
    void set_min(sal_Int64 min, FieldUnit eValueUnit) { m_xSpinButton->set_min(min, eValueUnit); }
61
0
    void set_max(sal_Int64 max, FieldUnit eValueUnit) { m_xSpinButton->set_max(max, eValueUnit); }
62
0
    sal_Int64 normalize(sal_Int64 nValue) const { return m_xSpinButton->normalize(nValue); }
63
0
    sal_Int64 denormalize(sal_Int64 nValue) const { return m_xSpinButton->denormalize(nValue); }
64
0
    void connect_value_changed(const Link<weld::MetricSpinButton&, void>& rLink) { m_xSpinButton->connect_value_changed(rLink); }
65
0
    OUString get_text() const { return m_xSpinButton->get_text(); }
66
0
    void set_text(const OUString& rText) { m_xSpinButton->set_text(rText); }
67
0
    void save_value() { m_xSpinButton->save_value(); }
68
0
    bool get_value_changed_from_saved() const { return m_xSpinButton->get_value_changed_from_saved(); }
69
0
    weld::SpinButton& get_widget() { return m_xSpinButton->get_widget(); }
70
71
0
    sal_Int64 GetCoreValue(MapUnit eUnit) const { return ::GetCoreValue(*m_xSpinButton, eUnit); }
72
    void SetFieldUnit(FieldUnit eUnit, bool bAll = false)
73
0
    {
74
0
        ::SetFieldUnit(*m_xSpinButton, eUnit, bAll);
75
0
        m_eAbsoluteFieldUnit = m_xSpinButton->get_unit();
76
0
    }
77
0
    void SetMetricValue(sal_Int64 lCoreValue, MapUnit eUnit) { ::SetMetricValue(*m_xSpinButton, lCoreValue, eUnit); }
78
};
79
80
#endif
81
82
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */