Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/editeng/adjustitem.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_ADJUSTITEM_HXX
20
#define INCLUDED_EDITENG_ADJUSTITEM_HXX
21
22
#include <svl/poolitem.hxx>
23
#include <editeng/svxenum.hxx>
24
#include <editeng/editengdllapi.h>
25
26
// class SvxAdjustItem ---------------------------------------------------
27
28
/*
29
[Description]
30
This item describes the row orientation.
31
*/
32
constexpr sal_uInt16 ADJUST_LASTBLOCK_VERSION = 0x0001;
33
34
class EDITENG_DLLPUBLIC SvxAdjustItem final : public SfxPoolItem
35
{
36
    bool    bLeft      : 1;
37
    bool    bRight     : 1;
38
    bool    bCenter    : 1;
39
    bool    bBlock     : 1;
40
    bool    bStart     : 1;
41
    bool    bEnd       : 1;
42
43
    // only active when bBlock
44
    bool    bOneBlock : 1;
45
    bool    bLastCenter : 1;
46
    bool    bLastBlock : 1;
47
48
    // desired, minimum and maximum word spacing values in percent of
49
    // the width of space character in justified text
50
    sal_uInt16 nPropWordSpacing;
51
    sal_uInt16 nPropWordSpacingMinimum;
52
    sal_uInt16 nPropWordSpacingMaximum;
53
54
    // minimum and maximum letter spacing values in percent of
55
    // the width of space character in justified text
56
    sal_Int16 nPropLetterSpacingMinimum;
57
    sal_Int16 nPropLetterSpacingMaximum;
58
59
    // minimum and maximum glyph scaling values in percent
60
    sal_Int16 nPropScaleWidthMinimum;
61
    sal_Int16 nPropScaleWidthMaximum;
62
63
protected:
64
    virtual ItemInstanceManager* getItemInstanceManager() const override;
65
66
public:
67
    static SfxPoolItem* CreateDefault();
68
69
    DECLARE_ITEM_TYPE_FUNCTION(SvxAdjustItem)
70
    SvxAdjustItem( const SvxAdjust eAdjst /*= SvxAdjust::Left*/,
71
                   const sal_uInt16 nId );
72
73
    // "pure virtual Methods" from SfxPoolItem
74
    virtual bool            operator==( const SfxPoolItem& ) const override;
75
0
    virtual bool            supportsHashCode() const override { return true; }
76
    virtual size_t          hashCode() const override;
77
78
    virtual bool            QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
79
    virtual bool            PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
80
81
    virtual bool GetPresentation( SfxItemPresentation ePres,
82
                                  MapUnit eCoreMetric,
83
                                  MapUnit ePresMetric,
84
                                  OUString &rText, const IntlWrapper& ) const override;
85
    static OUString          GetValueTextByPos( sal_uInt16 nPos );
86
    virtual SvxAdjustItem*   Clone( SfxItemPool *pPool = nullptr ) const override;
87
88
    void SetOneWord( const SvxAdjust eType )
89
0
    {
90
0
        ASSERT_CHANGE_REFCOUNTED_ITEM;
91
0
        bOneBlock  = eType == SvxAdjust::Block;
92
0
    }
Unexecuted instantiation: SvxAdjustItem::SetOneWord(SvxAdjust)
Unexecuted instantiation: SvxAdjustItem::SetOneWord(SvxAdjust)
93
94
    void SetLastBlock( const SvxAdjust eType )
95
39.1k
    {
96
39.1k
        ASSERT_CHANGE_REFCOUNTED_ITEM;
97
39.1k
        bLastBlock = eType == SvxAdjust::Block;
98
39.1k
        bLastCenter = eType == SvxAdjust::Center;
99
39.1k
    }
100
101
    void SetAdjust( const SvxAdjust eType )
102
1.27M
    {
103
1.27M
        ASSERT_CHANGE_REFCOUNTED_ITEM;
104
1.27M
        bLeft = eType == SvxAdjust::Left;
105
1.27M
        bRight = eType == SvxAdjust::Right;
106
1.27M
        bCenter = eType == SvxAdjust::Center;
107
1.27M
        bBlock = eType == SvxAdjust::Block;
108
1.27M
        bStart = eType == SvxAdjust::ParaStart;
109
1.27M
        bEnd = eType == SvxAdjust::ParaEnd;
110
1.27M
    }
111
112
    SvxAdjust GetLastBlock() const
113
853k
    {
114
853k
        SvxAdjust eRet = SvxAdjust::Left;
115
116
853k
        if ( bLastBlock )
117
0
            eRet = SvxAdjust::Block;
118
853k
        else if( bLastCenter )
119
0
            eRet = SvxAdjust::Center;
120
853k
        return eRet;
121
853k
    }
122
123
    SvxAdjust GetOneWord() const
124
422k
    {
125
422k
        SvxAdjust eRet = SvxAdjust::Left;
126
127
422k
        if ( bBlock && bOneBlock )
128
0
            eRet = SvxAdjust::Block;
129
422k
        return eRet;
130
422k
    }
131
132
    SvxAdjust GetAdjust() const
133
13.6M
    {
134
13.6M
        SvxAdjust eRet = SvxAdjust::Left;
135
136
13.6M
        if ( bRight )
137
355k
            eRet = SvxAdjust::Right;
138
13.3M
        else if ( bCenter )
139
2.35M
            eRet = SvxAdjust::Center;
140
10.9M
        else if ( bBlock )
141
406k
            eRet = SvxAdjust::Block;
142
10.5M
        else if ( bStart )
143
6.98M
            eRet = SvxAdjust::ParaStart;
144
3.57M
        else if ( bEnd )
145
570k
            eRet = SvxAdjust::ParaEnd;
146
13.6M
        return eRet;
147
13.6M
    }
148
149
    sal_Int8 GetAsFlags() const
150
0
    {
151
0
        sal_Int8 nFlags = 0;
152
0
        if ( bOneBlock )
153
0
            nFlags |= 0x0001;
154
0
        if ( bLastCenter )
155
0
            nFlags |= 0x0002;
156
0
        if ( bLastBlock )
157
0
            nFlags |= 0x0004;
158
0
        return nFlags;
159
0
    }
160
161
    void SetAsFlags(sal_Int8 nFlags)
162
0
    {
163
0
        ASSERT_CHANGE_REFCOUNTED_ITEM;
164
0
        bOneBlock = 0 != (nFlags & 0x0001);
165
0
        bLastCenter = 0 != (nFlags & 0x0002);
166
0
        bLastBlock = 0 != (nFlags & 0x0004);
167
0
    }
168
169
    sal_uInt16 GetPropWordSpacing() const
170
548k
    {
171
548k
        return nPropWordSpacing;
172
548k
    }
173
174
    void SetPropWordSpacing( sal_uInt16 nVal )
175
6.76k
    {
176
6.76k
        nPropWordSpacing = nVal;
177
6.76k
    }
178
179
180
    sal_uInt16 GetPropWordSpacingMinimum() const
181
548k
    {
182
548k
        return nPropWordSpacingMinimum;
183
548k
    }
184
185
    void SetPropWordSpacingMinimum( sal_uInt16 nVal )
186
6.77k
    {
187
6.77k
        nPropWordSpacingMinimum = nVal;
188
6.77k
    }
189
190
191
    sal_uInt16 GetPropWordSpacingMaximum() const
192
548k
    {
193
548k
        return nPropWordSpacingMaximum;
194
548k
    }
195
196
    void SetPropWordSpacingMaximum( sal_uInt16 nVal )
197
6.77k
    {
198
6.77k
        nPropWordSpacingMaximum = nVal;
199
6.77k
    }
200
201
    sal_Int16 GetPropLetterSpacingMinimum() const
202
1.05M
    {
203
1.05M
        return nPropLetterSpacingMinimum;
204
1.05M
    }
205
206
    void SetPropLetterSpacingMinimum( sal_Int16 nVal )
207
6.76k
    {
208
6.76k
        nPropLetterSpacingMinimum = nVal;
209
6.76k
    }
210
211
212
    sal_Int16 GetPropLetterSpacingMaximum() const
213
548k
    {
214
548k
        return nPropLetterSpacingMaximum;
215
548k
    }
216
217
    void SetPropLetterSpacingMaximum( sal_Int16 nVal )
218
6.76k
    {
219
6.76k
        nPropLetterSpacingMaximum = nVal;
220
6.76k
    }
221
222
223
    sal_Int16 GetPropScaleWidthMaximum() const
224
548k
    {
225
548k
        return nPropScaleWidthMaximum;
226
548k
    }
227
228
    void SetPropScaleWidthMaximum( sal_Int16 nVal )
229
6.76k
    {
230
6.76k
        nPropScaleWidthMaximum = nVal;
231
6.76k
    }
232
233
    sal_Int16 GetPropScaleWidthMinimum() const
234
1.05M
    {
235
1.05M
        return nPropScaleWidthMinimum;
236
1.05M
    }
237
238
    void SetPropScaleWidthMinimum( sal_Int16 nVal )
239
6.76k
    {
240
6.76k
        nPropScaleWidthMinimum = nVal;
241
6.76k
    }
242
};
243
244
#endif
245
246
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */