Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/editeng/ulspitem.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_EDITENG_ULSPITEM_HXX
20
#define INCLUDED_EDITENG_ULSPITEM_HXX
21
22
#include <svl/poolitem.hxx>
23
#include <editeng/editengdllapi.h>
24
25
26
// class SvxULSpaceItem --------------------------------------------------
27
28
/*  [Description]
29
30
    This item describes the Upper- and Lower space of a page or paragraph.
31
*/
32
33
class EDITENG_DLLPUBLIC SvxULSpaceItem final : public SfxPoolItem
34
{
35
    sal_uInt16 nUpper;  // Upper space
36
    sal_uInt16 nLower;  // Lower space
37
    bool       bContext; // Contextual spacing?
38
    sal_uInt16 nPropUpper, nPropLower;      // relative or absolute (=100%)
39
public:
40
    static SfxPoolItem* CreateDefault();
41
42
    DECLARE_ITEM_TYPE_FUNCTION(SvxULSpaceItem)
43
    explicit SvxULSpaceItem( const sal_uInt16 nId  );
44
    SvxULSpaceItem( const sal_uInt16 nUp, const sal_uInt16 nLow,
45
                    const sal_uInt16 nId  );
46
47
    // "pure virtual Methods" from SfxPoolItem
48
    virtual bool            operator==( const SfxPoolItem& ) const override;
49
11
    virtual bool            supportsHashCode() const override { return true; }
50
    virtual size_t          hashCode() const override;
51
52
    virtual bool            QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
53
    virtual bool            PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
54
55
    virtual bool GetPresentation( SfxItemPresentation ePres,
56
                                  MapUnit eCoreMetric,
57
                                  MapUnit ePresMetric,
58
                                  OUString &rText, const IntlWrapper& ) const override;
59
60
    virtual SvxULSpaceItem*      Clone( SfxItemPool *pPool = nullptr ) const override;
61
    virtual void                 ScaleMetrics( tools::Long nMult, tools::Long nDiv ) override;
62
    virtual bool                 HasMetrics() const override;
63
64
    inline void SetUpper( const sal_uInt16 nU, const sal_uInt16 nProp = 100 );
65
    inline void SetLower( const sal_uInt16 nL, const sal_uInt16 nProp = 100 );
66
67
73.3k
    void SetUpperValue( const sal_uInt16 nU ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nUpper = nU; }
68
33.3k
    void SetLowerValue( const sal_uInt16 nL ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nLower = nL; }
69
11.5k
    void SetContextValue( const bool bC )     { ASSERT_CHANGE_REFCOUNTED_ITEM; bContext = bC; }
70
43.0k
    void SetPropUpper( const sal_uInt16 nU )  { ASSERT_CHANGE_REFCOUNTED_ITEM; nPropUpper = nU; }
71
2.97k
    void SetPropLower( const sal_uInt16 nL )  { ASSERT_CHANGE_REFCOUNTED_ITEM; nPropLower = nL; }
72
73
3.42M
    sal_uInt16 GetUpper() const { return nUpper; }
74
31.5M
    sal_uInt16 GetLower() const { return nLower; }
75
35.7k
    bool GetContext() const { return bContext; }
76
26.0k
    sal_uInt16 GetPropUpper() const { return nPropUpper; }
77
26.0k
    sal_uInt16 GetPropLower() const { return nPropLower; }
78
79
    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
80
    virtual boost::property_tree::ptree dumpAsJSON() const override;
81
};
82
83
inline void SvxULSpaceItem::SetUpper( const sal_uInt16 nU, const sal_uInt16 nProp )
84
1.34M
{
85
1.34M
    ASSERT_CHANGE_REFCOUNTED_ITEM;
86
1.34M
    nUpper = sal_uInt16((sal_uInt32(nU) * nProp ) / 100); nPropUpper = nProp;
87
1.34M
}
88
inline void SvxULSpaceItem::SetLower( const sal_uInt16 nL, const sal_uInt16 nProp )
89
938k
{
90
    ASSERT_CHANGE_REFCOUNTED_ITEM;
91
938k
    nLower = sal_uInt16((sal_uInt32(nL) * nProp ) / 100); nPropLower = nProp;
92
938k
}
93
94
#endif
95
96
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */