Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/editeng/tstpitem.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_TSTPITEM_HXX
20
#define INCLUDED_EDITENG_TSTPITEM_HXX
21
22
#include <svl/poolitem.hxx>
23
#include <editeng/svxenum.hxx>
24
#include <editeng/editengdllapi.h>
25
#include <o3tl/sorted_vector.hxx>
26
27
// class SvxTabStop ------------------------------------------------------
28
29
6
#define SVX_TAB_DEFCOUNT    10
30
6
#define SVX_TAB_DEFDIST     1134            // 2cm in twips
31
5.19M
#define SVX_TAB_NOTFOUND    USHRT_MAX
32
5.80M
#define cDfltDecimalChar    u'\0' // Get from IntlWrapper
33
1.60M
#define cDfltFillChar       u' '
34
35
class EDITENG_DLLPUBLIC SvxTabStop
36
{
37
private:
38
    sal_Int32       nTabPos;
39
    SvxTabAdjust    eAdjustment;
40
    sal_Unicode     m_cDecimal;
41
    sal_Unicode     cFill;
42
43
    void fillDecimal();
44
45
public:
46
    SvxTabStop();
47
    explicit SvxTabStop( const sal_Int32 nPos,
48
                const SvxTabAdjust eAdjst = SvxTabAdjust::Left,
49
                const sal_Unicode cDec = cDfltDecimalChar,
50
                const sal_Unicode cFil = cDfltFillChar );
51
52
100k
    sal_Int32&    GetTabPos() { return nTabPos; }
53
5.22M
    sal_Int32     GetTabPos() const { return nTabPos; }
54
55
96.9k
    SvxTabAdjust& GetAdjustment() { return eAdjustment; }
56
2.81M
    SvxTabAdjust  GetAdjustment() const { return eAdjustment; }
57
58
2.80k
    sal_Unicode&  GetDecimal() { return m_cDecimal; }
59
90.2k
    sal_Unicode   GetDecimal() const { return m_cDecimal; }
60
61
82.5k
    sal_Unicode&  GetFill() { return cFill; }
62
90.2k
    sal_Unicode   GetFill() const { return cFill; }
63
64
    bool          operator==( const SvxTabStop& rTS ) const
65
3.13M
                        {
66
3.13M
                            return ( nTabPos     == rTS.nTabPos     &&
67
3.07M
                                     eAdjustment == rTS.eAdjustment &&
68
3.07M
                                     m_cDecimal    == rTS.m_cDecimal    &&
69
3.07M
                                     cFill       == rTS.cFill );
70
3.13M
                        }
71
    bool          operator!=( const SvxTabStop& rTS ) const
72
3.13M
                        {
73
3.13M
                            return !operator==(rTS);
74
3.13M
                        }
75
    // For the SortedArray:
76
    bool            operator <( const SvxTabStop& rTS ) const
77
10.9M
                        { return nTabPos < rTS.nTabPos; }
78
79
    void dumpAsXml(xmlTextWriterPtr pWriter) const;
80
};
81
82
// class SvxTabStopItem --------------------------------------------------
83
84
typedef o3tl::sorted_vector<SvxTabStop> SvxTabStopArr;
85
86
/*  [Description]
87
88
    This item describes a list of TabStops.
89
*/
90
91
class EDITENG_DLLPUBLIC SvxTabStopItem final : public SfxPoolItem
92
{
93
    SvxTabStopArr maTabStops;
94
    /// Defines default tab width for tabs without dedicated tab stop in the paragraph.
95
    sal_Int32 mnDefaultDistance = 0;
96
97
public:
98
    static SfxPoolItem* CreateDefault();
99
100
    DECLARE_ITEM_TYPE_FUNCTION(SvxTabStopItem)
101
    explicit SvxTabStopItem( sal_uInt16 nWhich  );
102
    SvxTabStopItem( const sal_uInt16 nTabs,
103
                    const sal_uInt16 nDist,
104
                    const SvxTabAdjust eAdjst /*= SvxTabAdjust::Default*/,
105
                    sal_uInt16 nWhich  );
106
107
    // Returns index of the tab or TAB_NOTFOUND
108
    sal_uInt16          GetPos( const SvxTabStop& rTab ) const;
109
110
    // Returns index of the tab at nPos, or TAB_NOTFOUND
111
    sal_uInt16          GetPos( const sal_Int32 nPos ) const;
112
    void SetDefaultDistance(sal_Int32 nDefaultDistancenDefTabSize);
113
    sal_Int32 GetDefaultDistance() const;
114
115
    // unprivatized:
116
9.87M
    sal_uInt16          Count() const { return maTabStops.size(); }
117
    bool                Insert( const SvxTabStop& rTab );
118
    void                Insert( const SvxTabStopItem* pTabs );
119
    void                Remove( const sal_uInt16 nPos, const sal_uInt16 nLen = 1 )
120
47.5k
                        { ASSERT_CHANGE_REFCOUNTED_ITEM; maTabStops.erase( maTabStops.begin() + nPos, maTabStops.begin() + nPos + nLen ); }
121
122
    // Assignment operator, equality operator (caution: expensive!)
123
124
    // this is already included in SfxPoolItem declaration
125
    //int             operator!=( const SvxTabStopItem& rTSI ) const
126
    //                  { return !( operator==( rTSI ) ); }
127
128
    const SvxTabStop& operator[]( const sal_uInt16 nPos ) const
129
8.57M
                        { return maTabStops[nPos]; }
130
131
    const SvxTabStop& At( const sal_uInt16 nPos ) const
132
0
    {
133
0
        return maTabStops[nPos];
134
0
    }
135
136
    // "pure virtual Methods" from SfxPoolItem
137
    virtual bool             operator==( const SfxPoolItem& ) const override;
138
5
    virtual bool             supportsHashCode() const override { return true; }
139
    virtual size_t           hashCode() const override final;
140
    virtual bool             QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
141
    virtual bool             PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
142
143
    virtual bool GetPresentation( SfxItemPresentation ePres,
144
                                  MapUnit eCoreMetric,
145
                                  MapUnit ePresMetric,
146
                                  OUString &rText, const IntlWrapper& ) const override;
147
148
    virtual SvxTabStopItem* Clone( SfxItemPool *pPool = nullptr ) const override;
149
150
    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
151
};
152
153
#endif
154
155
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */