Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/autoformathelper.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
20
#ifndef INCLUDED_SVX_AUTOFORMATHELPER_HXX
21
#define INCLUDED_SVX_AUTOFORMATHELPER_HXX
22
23
#include <svx/svxdllapi.h>
24
#include <memory>
25
26
class SvStream;
27
class SvxFontItem;
28
class SvxFontHeightItem;
29
class SvxWeightItem;
30
class SvxPostureItem;
31
class SvxUnderlineItem;
32
class SvxOverlineItem;
33
class SvxCrossedOutItem;
34
class SvxContourItem;
35
class SvxShadowedItem;
36
class SvxColorItem;
37
class SvxBoxItem;
38
class SvxLineItem;
39
class SvxBrushItem;
40
class SvxAdjustItem;
41
class SvxHorJustifyItem;
42
class SvxVerJustifyItem;
43
class SfxBoolItem;
44
class SvxMarginItem;
45
class SfxInt32Item;
46
class SvxRotateModeItem;
47
48
//////////////////////////////////////////////////////////////////////////////
49
/// Struct with version numbers of the Items
50
51
struct SVX_DLLPUBLIC AutoFormatVersions
52
{
53
public:
54
    // BlockA
55
    sal_uInt16 nFontVersion;
56
    sal_uInt16 nFontHeightVersion;
57
    sal_uInt16 nWeightVersion;
58
    sal_uInt16 nPostureVersion;
59
    sal_uInt16 nUnderlineVersion;
60
    sal_uInt16 nOverlineVersion;
61
    sal_uInt16 nCrossedOutVersion;
62
    sal_uInt16 nContourVersion;
63
    sal_uInt16 nShadowedVersion;
64
    sal_uInt16 nColorVersion;
65
    sal_uInt16 nBoxVersion;
66
    sal_uInt16 nLineVersion;
67
    sal_uInt16 nBrushVersion;
68
    sal_uInt16 nAdjustVersion;
69
70
    // BlockB
71
    sal_uInt16 nHorJustifyVersion;
72
    sal_uInt16 nVerJustifyVersion;
73
    sal_uInt16 nOrientationVersion;
74
    sal_uInt16 nMarginVersion;
75
    sal_uInt16 nBoolVersion;
76
    sal_uInt16 nInt32Version;
77
    sal_uInt16 nRotateModeVersion;
78
    sal_uInt16 nNumFormatVersion;
79
80
    AutoFormatVersions();
81
82
    void LoadBlockA( SvStream& rStream, sal_uInt16 nVer );
83
    void LoadBlockB( SvStream& rStream, sal_uInt16 nVer );
84
85
    static void WriteBlockA(SvStream& rStream, sal_uInt16 fileVersion);
86
    static void WriteBlockB(SvStream& rStream, sal_uInt16 fileVersion);
87
};
88
89
//////////////////////////////////////////////////////////////////////////////
90
91
class SVX_DLLPUBLIC AutoFormatBase
92
{
93
protected:
94
    // common attributes of Calc and Writer
95
    // --- from 641 on: CJK and CTL font settings
96
    std::unique_ptr<SvxFontItem>            m_aFont;
97
    std::unique_ptr<SvxFontHeightItem>      m_aHeight;
98
    std::unique_ptr<SvxWeightItem>          m_aWeight;
99
    std::unique_ptr<SvxPostureItem>         m_aPosture;
100
101
    std::unique_ptr<SvxFontItem>            m_aCJKFont;
102
    std::unique_ptr<SvxFontHeightItem>      m_aCJKHeight;
103
    std::unique_ptr<SvxWeightItem>          m_aCJKWeight;
104
    std::unique_ptr<SvxPostureItem>         m_aCJKPosture;
105
106
    std::unique_ptr<SvxFontItem>            m_aCTLFont;
107
    std::unique_ptr<SvxFontHeightItem>      m_aCTLHeight;
108
    std::unique_ptr<SvxWeightItem>          m_aCTLWeight;
109
    std::unique_ptr<SvxPostureItem>         m_aCTLPosture;
110
111
    std::unique_ptr<SvxUnderlineItem>       m_aUnderline;
112
    std::unique_ptr<SvxOverlineItem>        m_aOverline;
113
    std::unique_ptr<SvxCrossedOutItem>      m_aCrossedOut;
114
    std::unique_ptr<SvxContourItem>         m_aContour;
115
    std::unique_ptr<SvxShadowedItem>        m_aShadowed;
116
    std::unique_ptr<SvxColorItem>           m_aColor;
117
    std::unique_ptr<SvxBoxItem>             m_aBox;
118
    std::unique_ptr<SvxLineItem>            m_aTLBR;
119
    std::unique_ptr<SvxLineItem>            m_aBLTR;
120
    std::unique_ptr<SvxBrushItem>           m_aBackground;
121
122
    // Writer specific
123
    std::unique_ptr<SvxAdjustItem>          m_aAdjust;
124
125
    // Calc specific
126
    std::unique_ptr<SvxHorJustifyItem>      m_aHorJustify;
127
    std::unique_ptr<SvxVerJustifyItem>      m_aVerJustify;
128
    std::unique_ptr<SfxBoolItem>            m_aStacked;
129
    std::unique_ptr<SvxMarginItem>          m_aMargin;
130
    std::unique_ptr<SfxBoolItem>            m_aLinebreak;
131
132
    // from SO5, 504k on, rotated text
133
    std::unique_ptr<SfxInt32Item>           m_aRotateAngle;
134
    std::unique_ptr<SvxRotateModeItem>      m_aRotateMode;
135
136
    // assignment-op is protected due to this being a tooling
137
    // class, so callers need to be aware of what they do
138
    AutoFormatBase& operator=(const AutoFormatBase&);
139
140
    AutoFormatBase();
141
    AutoFormatBase( const AutoFormatBase& rNew );
142
    ~AutoFormatBase();
143
144
    /// Comparing based of boxes backgrounds.
145
    bool operator==(const AutoFormatBase& rRight) const;
146
147
public:
148
    // The get-methods.
149
52.8k
    const SvxFontItem       &GetFont() const        { return *m_aFont; }
150
14.5k
    const SvxFontHeightItem &GetHeight() const      { return *m_aHeight; }
151
12.2k
    const SvxWeightItem     &GetWeight() const      { return *m_aWeight; }
152
12.3k
    const SvxPostureItem    &GetPosture() const     { return *m_aPosture; }
153
52.7k
    const SvxFontItem       &GetCJKFont() const     { return *m_aCJKFont; }
154
10.4k
    const SvxFontHeightItem &GetCJKHeight() const   { return *m_aCJKHeight; }
155
10.4k
    const SvxWeightItem     &GetCJKWeight() const   { return *m_aCJKWeight; }
156
10.4k
    const SvxPostureItem    &GetCJKPosture() const  { return *m_aCJKPosture; }
157
52.4k
    const SvxFontItem       &GetCTLFont() const     { return *m_aCTLFont; }
158
10.4k
    const SvxFontHeightItem &GetCTLHeight() const   { return *m_aCTLHeight; }
159
10.4k
    const SvxWeightItem     &GetCTLWeight() const   { return *m_aCTLWeight; }
160
10.4k
    const SvxPostureItem    &GetCTLPosture() const  { return *m_aCTLPosture; }
161
31.6k
    const SvxUnderlineItem  &GetUnderline() const   { return *m_aUnderline; }
162
0
    const SvxOverlineItem   &GetOverline() const    { return *m_aOverline; }
163
10.4k
    const SvxCrossedOutItem &GetCrossedOut() const  { return *m_aCrossedOut; }
164
13.7k
    const SvxContourItem    &GetContour() const     { return *m_aContour; }
165
13.6k
    const SvxShadowedItem   &GetShadowed() const    { return *m_aShadowed; }
166
31.4k
    const SvxColorItem      &GetColor() const       { return *m_aColor; }
167
97.5k
    const SvxBoxItem        &GetBox() const         { return *m_aBox; }
168
0
    const SvxLineItem&      GetTLBR() const         { return *m_aTLBR; }
169
0
    const SvxLineItem&      GetBLTR() const         { return *m_aBLTR; }
170
10.4k
    const SvxBrushItem      &GetBackground() const  { return *m_aBackground; }
171
10.8k
    const SvxAdjustItem     &GetAdjust() const      { return *m_aAdjust; }
172
0
    const SvxHorJustifyItem& GetHorJustify() const { return *m_aHorJustify; }
173
0
    const SvxVerJustifyItem& GetVerJustify() const { return *m_aVerJustify; }
174
0
    const SfxBoolItem& GetStacked() const { return *m_aStacked; }
175
0
    const SvxMarginItem& GetMargin() const { return *m_aMargin; }
176
0
    const SfxBoolItem& GetLinebreak() const { return *m_aLinebreak; }
177
0
    const SfxInt32Item& GetRotateAngle() const { return *m_aRotateAngle; }
178
0
    const SvxRotateModeItem& GetRotateMode() const { return *m_aRotateMode; }
179
180
    // The set-methods.
181
    void SetFont( const SvxFontItem& rNew );
182
    void SetHeight( const SvxFontHeightItem& rNew );
183
    void SetWeight( const SvxWeightItem& rNew );
184
    void SetPosture( const SvxPostureItem& rNew );
185
    void SetCJKFont( const SvxFontItem& rNew );
186
    void SetCJKHeight( const SvxFontHeightItem& rNew );
187
    void SetCJKWeight( const SvxWeightItem& rNew );
188
    void SetCJKPosture( const SvxPostureItem& rNew );
189
    void SetCTLFont( const SvxFontItem& rNew );
190
    void SetCTLHeight( const SvxFontHeightItem& rNew );
191
    void SetCTLWeight( const SvxWeightItem& rNew );
192
    void SetCTLPosture( const SvxPostureItem& rNew );
193
    void SetUnderline( const SvxUnderlineItem& rNew );
194
    void SetOverline( const SvxOverlineItem& rNew );
195
    void SetCrossedOut( const SvxCrossedOutItem& rNew );
196
    void SetContour( const SvxContourItem& rNew );
197
    void SetShadowed( const SvxShadowedItem& rNew );
198
    void SetColor( const SvxColorItem& rNew );
199
    void SetBox( const SvxBoxItem& rNew );
200
    void SetTLBR( const SvxLineItem& rNew );
201
    void SetBLTR( const SvxLineItem& rNew );
202
    void SetBackground( const SvxBrushItem& rNew );
203
    void SetAdjust( const SvxAdjustItem& rNew );
204
    void SetHorJustify( const SvxHorJustifyItem& rNew );
205
    void SetVerJustify( const SvxVerJustifyItem& rNew );
206
    void SetStacked( const SfxBoolItem& rNew );
207
    void SetMargin( const SvxMarginItem& rNew );
208
    void SetLinebreak( const SfxBoolItem& rNew );
209
    void SetRotateAngle( const SfxInt32Item& rNew );
210
    void SetRotateMode( const SvxRotateModeItem& rNew );
211
212
    bool LoadBlockA( SvStream& rStream, const AutoFormatVersions& rVersions, sal_uInt16 nVer );
213
    bool LoadBlockB( SvStream& rStream, const AutoFormatVersions& rVersions, sal_uInt16 nVer );
214
215
    bool SaveBlockA( SvStream& rStream, sal_uInt16 fileVersion ) const;
216
    bool SaveBlockB( SvStream& rStream, sal_uInt16 fileVersion ) const;
217
};
218
219
#endif // INCLUDED_SVX_AUTOFORMATHELPER_HXX
220
221
//////////////////////////////////////////////////////////////////////////////
222
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */