Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sw/inc/paratr.hxx
Line
Count
Source (jump to first uncovered line)
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_SW_INC_PARATR_HXX
20
#define INCLUDED_SW_INC_PARATR_HXX
21
#include <svl/eitem.hxx>
22
#include <svl/stritem.hxx>
23
#include "swdllapi.h"
24
#include "hintids.hxx"
25
#include "calbck.hxx"
26
#include "swatrset.hxx"
27
#include "format.hxx"
28
#include "charfmt.hxx"
29
#include <editeng/adjustitem.hxx>
30
#include <editeng/lspcitem.hxx>
31
#include <editeng/spltitem.hxx>
32
#include <editeng/widwitem.hxx>
33
#include <editeng/orphitem.hxx>
34
#include <editeng/tstpitem.hxx>
35
#include <editeng/hyphenzoneitem.hxx>
36
#include <editeng/scriptspaceitem.hxx>
37
#include <editeng/hngpnctitem.hxx>
38
#include <editeng/forbiddenruleitem.hxx>
39
#include <editeng/paravertalignitem.hxx>
40
#include <editeng/pgrditem.hxx>
41
#include <o3tl/typed_flags_set.hxx>
42
43
class SwFormatDrop;
44
45
namespace sw {
46
47
    enum class ListLevelIndents { No, FirstLine, LeftMargin };
48
49
    class SW_DLLPUBLIC FormatDropDefiner {
50
        protected:
51
7.15M
            virtual ~FormatDropDefiner() {};
52
        public:
53
            virtual void FormatDropNotify(const SwFormatDrop&) =0;
54
    };
55
}
56
57
namespace o3tl
58
{
59
    template<> struct typed_flags<sw::ListLevelIndents> : is_typed_flags<sw::ListLevelIndents, 0x03> {};
60
}
61
62
/** If SwFormatDrop is a Client, it is the CharFormat that describes the font for the
63
   DropCaps. If it is not a Client, formatting uses the CharFormat of the paragraph.
64
   If the CharFormat is modified, this change is propagated to the paragraphs
65
   via the Modify of SwFormatDrop. */
66
class SW_DLLPUBLIC SwFormatDrop final : public SfxPoolItem, public SwClient
67
{
68
    sw::FormatDropDefiner* m_pDefinedIn;  ///< TextNode or FormatColl that contains the CapDrops.
69
    sal_uInt16 m_nDistance;       ///< Distance to beginning of text.
70
    sal_uInt8  m_nLines;          ///< Line count.
71
    sal_uInt8  m_nChars;          ///< Character count.
72
    bool   m_bWholeWord;      ///< First word with initials.
73
public:
74
    static SfxPoolItem* CreateDefault();
75
76
    DECLARE_ITEM_TYPE_FUNCTION(SwFormatDrop)
77
    SwFormatDrop();
78
    virtual ~SwFormatDrop() override;
79
80
    // @@@ public copy ctor, but no copy assignment?
81
    SwFormatDrop( const SwFormatDrop & );
82
private:
83
    // @@@ public copy ctor, but no copy assignment?
84
    SwFormatDrop & operator= (const SwFormatDrop &) = delete;
85
86
    virtual void SwClientNotify(const SwModify&, const SfxHint&) override
87
32
    {
88
32
        if (!m_pDefinedIn)
89
15
            return;
90
17
        m_pDefinedIn->FormatDropNotify(*this);
91
17
    }
92
93
public:
94
95
    /// "pure virtual methods" of SfxPoolItem
96
    virtual bool            operator==( const SfxPoolItem& ) const override;
97
0
    virtual bool            supportsHashCode() const override { return true; }
98
    virtual size_t          hashCode() const override;
99
    virtual SwFormatDrop*   Clone( SfxItemPool* pPool = nullptr ) const override;
100
    virtual bool GetPresentation( SfxItemPresentation ePres,
101
                                  MapUnit eCoreMetric,
102
                                  MapUnit ePresMetric,
103
                                  OUString &rText,
104
                                  const IntlWrapper& rIntl ) const override;
105
    virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
106
    virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
107
108
282k
    sal_uInt8 GetLines() const { return m_nLines; }
109
1.14k
    void SetLines(sal_uInt8 n) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nLines = n; }
110
111
138k
    sal_uInt8 GetChars() const { return m_nChars; }
112
3.59k
    void SetChars(sal_uInt8 n) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nChars = n; }
113
114
135k
    bool GetWholeWord() const { return m_bWholeWord; }
115
936
    void SetWholeWord(bool b) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_bWholeWord = b; }
116
117
135k
    sal_uInt16 GetDistance() const { return m_nDistance; }
118
936
    void SetDistance(sal_uInt16 n) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nDistance = n; }
119
120
141k
    const SwCharFormat *GetCharFormat() const { return static_cast<const SwCharFormat*>(GetRegisteredIn()); }
121
43.1k
    SwCharFormat *GetCharFormat()       { return static_cast<SwCharFormat*>(GetRegisteredIn()); }
122
    void SetCharFormat( SwCharFormat *pNew );
123
    /// Get information from Client.
124
    virtual bool GetInfo( SwFindNearestNode& ) const override;
125
126
    /// Get and set Modify pointer.
127
    void ChgDefinedIn( const sw::FormatDropDefiner* pDefiner )
128
43.1k
            { m_pDefinedIn = const_cast<sw::FormatDropDefiner*>(pDefiner); };
129
};
130
131
class SwRegisterItem final : public SfxBoolItem
132
{
133
public:
134
    static SfxPoolItem* CreateDefault();
135
    DECLARE_ITEM_TYPE_FUNCTION(SwRegisterItem)
136
    inline SwRegisterItem( const bool bRegister = false );
137
138
    /// "pure virtual methods" of SfxPoolItem
139
    virtual SwRegisterItem* Clone( SfxItemPool *pPool = nullptr ) const override;
140
    virtual bool GetPresentation( SfxItemPresentation ePres,
141
                                  MapUnit eCoreMetric,
142
                                  MapUnit ePresMetric,
143
                                  OUString &rText,
144
                                  const IntlWrapper& rIntl ) const override;
145
};
146
147
inline SwRegisterItem::SwRegisterItem( const bool bRegister ) :
148
275k
    SfxBoolItem( RES_PARATR_REGISTER, bRegister )
149
275k
{}
150
151
class SW_DLLPUBLIC SwNumRuleItem final : public SfxStringItem
152
{
153
public:
154
    static SfxPoolItem* CreateDefault();
155
    DECLARE_ITEM_TYPE_FUNCTION(SwNumRuleItem)
156
    SwNumRuleItem()
157
13.7k
        : SfxStringItem( RES_PARATR_NUMRULE, OUString() ) {}
158
159
    SwNumRuleItem( const UIName& rRuleName )
160
344k
        : SfxStringItem( RES_PARATR_NUMRULE, rRuleName.toString() ) {}
161
162
632k
    SwNumRuleItem(SwNumRuleItem const &) = default; // SfxPoolItem copy function dichotomy
163
164
    /// "pure virtual methods" of SfxPoolItem
165
    virtual bool            operator==( const SfxPoolItem& ) const override;
166
    virtual SwNumRuleItem*  Clone( SfxItemPool *pPool = nullptr ) const override;
167
    // Marked as false since the SfxStringItem superclass supports hashing, but
168
    // this class has not been checked for safety under hashing yet.
169
3
    virtual bool            supportsHashCode() const override { return false; }
170
    virtual bool GetPresentation( SfxItemPresentation ePres,
171
                                  MapUnit eCoreMetric,
172
                                  MapUnit ePresMetric,
173
                                  OUString &rText,
174
                                  const IntlWrapper& rIntl ) const override;
175
176
    virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
177
    virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
178
95.6M
    UIName GetValue() const { return UIName(SfxStringItem::GetValue()); }
179
180
    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
181
};
182
183
class SwParaConnectBorderItem final : public SfxBoolItem
184
{
185
public:
186
    DECLARE_ITEM_TYPE_FUNCTION(SwParaConnectBorderItem)
187
    inline SwParaConnectBorderItem( const bool bConnect = true );
188
189
    /// "pure virtual methods" of SfxPoolItem
190
    virtual SwParaConnectBorderItem* Clone( SfxItemPool *pPool = nullptr ) const override;
191
    virtual bool GetPresentation( SfxItemPresentation ePres,
192
                                  MapUnit eCoreMetric,
193
                                  MapUnit ePresMetric,
194
                                  OUString &rText,
195
                                  const IntlWrapper& rIntl ) const override;
196
};
197
198
inline SwParaConnectBorderItem::SwParaConnectBorderItem( const bool bConnect ) :
199
3.25k
    SfxBoolItem( RES_PARATR_CONNECT_BORDER, bConnect )
200
3.25k
{}
201
202
//  Implementation of paragraph-attributes methods of SwAttrSet
203
inline const SvxLineSpacingItem &SwAttrSet::GetLineSpacing(bool bInP) const
204
713k
    {   return Get( RES_PARATR_LINESPACING,bInP); }
205
inline const SvxAdjustItem &SwAttrSet::GetAdjust(bool bInP) const
206
2.32M
    {   return Get( RES_PARATR_ADJUST,bInP); }
207
inline const SvxFormatSplitItem &SwAttrSet::GetSplit(bool bInP) const
208
103k
    {   return Get( RES_PARATR_SPLIT,bInP); }
209
inline const SwRegisterItem &SwAttrSet::GetRegister(bool bInP) const
210
530k
    {   return Get( RES_PARATR_REGISTER,bInP); }
211
inline const SvxWidowsItem &SwAttrSet::GetWidows(bool bInP) const
212
78.9k
    {   return Get( RES_PARATR_WIDOWS,bInP); }
213
inline const SvxOrphansItem &SwAttrSet::GetOrphans(bool bInP) const
214
102k
    {   return Get( RES_PARATR_ORPHANS,bInP); }
215
inline const SvxTabStopItem &SwAttrSet::GetTabStops(bool bInP) const
216
491k
    {   return Get( RES_PARATR_TABSTOP,bInP); }
217
inline const SvxHyphenZoneItem &SwAttrSet::GetHyphenZone(bool bInP) const
218
346k
    {   return Get(RES_PARATR_HYPHENZONE,bInP); }
219
inline const SwFormatDrop &SwAttrSet::GetDrop(bool bInP) const
220
138k
    {   return Get(RES_PARATR_DROP,bInP); }
221
inline const SwNumRuleItem &SwAttrSet::GetNumRule(bool bInP) const
222
2.95M
    {   return Get(RES_PARATR_NUMRULE,bInP); }
223
inline const SvxScriptSpaceItem& SwAttrSet::GetScriptSpace(bool bInP) const
224
139k
    {   return Get(RES_PARATR_SCRIPTSPACE,bInP); }
225
inline const SvxHangingPunctuationItem &SwAttrSet::GetHangingPunctuation(bool bInP) const
226
139k
    {   return Get(RES_PARATR_HANGINGPUNCTUATION,bInP); }
227
inline const SvxForbiddenRuleItem &SwAttrSet::GetForbiddenRule(bool bInP) const
228
139k
    {   return Get(RES_PARATR_FORBIDDEN_RULES, bInP); }
229
inline const SvxParaVertAlignItem &SwAttrSet::GetParaVertAlign(bool bInP) const
230
491k
    {   return Get( RES_PARATR_VERTALIGN, bInP ); }
231
inline const SvxParaGridItem &SwAttrSet::GetParaGrid(bool bInP) const
232
502k
    {   return Get( RES_PARATR_SNAPTOGRID, bInP ); }
233
inline const SwParaConnectBorderItem &SwAttrSet::GetParaConnectBorder(bool bInP) const
234
92.2k
    {   return Get( RES_PARATR_CONNECT_BORDER, bInP ); }
235
236
// Implementation of paragraph-attributes methods of SwFormat
237
inline const SvxLineSpacingItem &SwFormat::GetLineSpacing(bool bInP) const
238
0
    {   return m_aSet.GetLineSpacing(bInP); }
239
inline const SvxTabStopItem &SwFormat::GetTabStops(bool bInP) const
240
72
    {   return m_aSet.GetTabStops(bInP); }
241
inline const SwFormatDrop &SwFormat::GetDrop(bool bInP) const
242
135
    {   return m_aSet.GetDrop(bInP); }
243
inline const SwNumRuleItem &SwFormat::GetNumRule(bool bInP) const
244
2.95M
    {   return m_aSet.GetNumRule(bInP); }
245
246
#endif
247
248
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */