Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/lotuswordpro/inc/lwpoverride.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*************************************************************************
3
 *
4
 *  The Contents of this file are made available subject to the terms of
5
 *  either of the following licenses
6
 *
7
 *         - GNU Lesser General Public License Version 2.1
8
 *         - Sun Industry Standards Source License Version 1.1
9
 *
10
 *  Sun Microsystems Inc., October, 2000
11
 *
12
 *  GNU Lesser General Public License Version 2.1
13
 *  =============================================
14
 *  Copyright 2000 by Sun Microsystems, Inc.
15
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
16
 *
17
 *  This library is free software; you can redistribute it and/or
18
 *  modify it under the terms of the GNU Lesser General Public
19
 *  License version 2.1, as published by the Free Software Foundation.
20
 *
21
 *  This library is distributed in the hope that it will be useful,
22
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24
 *  Lesser General Public License for more details.
25
 *
26
 *  You should have received a copy of the GNU Lesser General Public
27
 *  License along with this library; if not, write to the Free Software
28
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29
 *  MA  02111-1307  USA
30
 *
31
 *
32
 *  Sun Industry Standards Source License Version 1.1
33
 *  =================================================
34
 *  The contents of this file are subject to the Sun Industry Standards
35
 *  Source License Version 1.1 (the "License"); You may not use this file
36
 *  except in compliance with the License. You may obtain a copy of the
37
 *  License at http://www.openoffice.org/license.html.
38
 *
39
 *  Software provided under this License is provided on an "AS IS" basis,
40
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43
 *  See the License for the specific provisions governing your rights and
44
 *  obligations concerning the Software.
45
 *
46
 *  The Initial Developer of the Original Code is: IBM Corporation
47
 *
48
 *  Copyright: 2008 by IBM Corporation
49
 *
50
 *  All Rights Reserved.
51
 *
52
 *  Contributor(s): _______________________________________
53
 *
54
 *
55
 ************************************************************************/
56
/*************************************************************************
57
 * @file
58
 *  For LWP filter architecture prototype
59
 ************************************************************************/
60
61
#ifndef INCLUDED_LOTUSWORDPRO_INC_LWPOVERRIDE_HXX
62
#define INCLUDED_LOTUSWORDPRO_INC_LWPOVERRIDE_HXX
63
64
#include "lwpobjid.hxx"
65
#include "lwptools.hxx"
66
#include <o3tl/safeint.hxx>
67
#include <memory>
68
69
class LwpObjectStream;
70
71
enum STATE
72
{
73
    STATE_OFF   = 0,
74
    STATE_ON    = 1,
75
    STATE_STYLE = 2
76
};
77
78
class LwpOverride
79
{
80
public:
81
2.13M
    LwpOverride() : m_nValues(0), m_nOverride(0), m_nApply(0) {}
82
83
2.22M
    virtual ~LwpOverride(){}
84
85
    virtual LwpOverride* clone() const = 0;
86
87
    virtual void Read(LwpObjectStream* pStrm) = 0;
88
89
    void ReadCommon(LwpObjectStream* pStrm);
90
91
    void Clear();
92
93
    void Override(sal_uInt16 nBits, STATE eState);
94
95
protected:
96
    explicit LwpOverride(LwpOverride const& rOther);
97
98
private:
99
    LwpOverride& operator=(LwpOverride const& rOther) = delete;
100
101
protected:
102
    sal_uInt16  m_nValues;
103
    sal_uInt16  m_nOverride;
104
    sal_uInt16  m_nApply;
105
};
106
107
class LwpTextLanguageOverride final : public LwpOverride
108
{
109
public:
110
922k
    LwpTextLanguageOverride() : m_nLanguage(0) {}
111
112
    virtual LwpTextLanguageOverride* clone() const override;
113
114
    void Read(LwpObjectStream* pStrm) override;
115
116
private:
117
    LwpTextLanguageOverride(LwpTextLanguageOverride const& rOther);
118
    LwpTextLanguageOverride& operator=(LwpTextLanguageOverride const& rOther) = delete;
119
120
    sal_uInt16  m_nLanguage;
121
};
122
123
class LwpTextAttributeOverride final : public LwpOverride
124
{
125
public:
126
922k
    LwpTextAttributeOverride() : m_nHideLevels(0), m_nBaseLineOffset(0) {}
127
128
    virtual LwpTextAttributeOverride* clone() const override;
129
130
    void Read(LwpObjectStream* pStrm) override;
131
132
    inline sal_uInt16 GetHideLevels() const;
133
134
    bool IsHighlight() const;
135
136
private:
137
    LwpTextAttributeOverride(LwpTextAttributeOverride const& rOther);
138
    LwpTextAttributeOverride& operator=(LwpTextAttributeOverride const& rOther) = delete;
139
140
    enum{
141
    TAO_HIGHLIGHT = 0x08,
142
    };
143
    sal_uInt16  m_nHideLevels;
144
    sal_uInt32  m_nBaseLineOffset;
145
};
146
147
inline sal_uInt16 LwpTextAttributeOverride::GetHideLevels() const
148
45.3k
{
149
45.3k
    return m_nHideLevels;
150
45.3k
}
151
152
class LwpKinsokuOptsOverride final : public LwpOverride
153
{
154
public:
155
22.9k
    LwpKinsokuOptsOverride() : m_nLevels(0) {}
156
157
    virtual LwpKinsokuOptsOverride* clone() const override;
158
159
    void Read(LwpObjectStream* pStrm) override;
160
161
private:
162
    LwpKinsokuOptsOverride(LwpKinsokuOptsOverride const& rOther);
163
    LwpKinsokuOptsOverride& operator=(LwpKinsokuOptsOverride const& rOther) = delete;
164
165
    sal_uInt16  m_nLevels;
166
};
167
168
class LwpBulletOverride final : public LwpOverride
169
{
170
public:
171
31.3k
    LwpBulletOverride() {m_bIsNull = true;}
172
173
    virtual LwpBulletOverride* clone() const override;
174
175
    void Read(LwpObjectStream* pStrm) override;
176
177
    inline const LwpObjectID& GetSilverBullet() const;
178
179
    void Override(LwpBulletOverride* pOther);
180
181
    inline bool IsSilverBulletOverridden() const;
182
    inline bool IsSkipOverridden() const;
183
    inline bool IsRightAlignedOverridden() const;
184
    inline bool IsSkip() const;
185
    inline bool IsRightAligned() const;
186
    inline bool IsEditable() const;
187
188
    void OverrideSilverBullet(LwpObjectID aID);
189
    void OverrideSkip(bool bOver);
190
    void OverrideRightAligned(bool bOver);
191
192
    inline void RevertSilverBullet();
193
    inline void RevertSkip();
194
    inline void RevertRightAligned();
195
196
8.53k
    bool IsInValid() const {return m_bIsNull;}
197
198
private:
199
    LwpBulletOverride(LwpBulletOverride const& rOther);
200
    LwpBulletOverride& operator=(LwpBulletOverride const& rOther) = delete;
201
202
    enum
203
    {
204
        BO_SILVERBULLET = 0x01,
205
        // 0x02 is free
206
        BO_RIGHTALIGN   = 0x04,
207
        BO_EDITABLE     = 0x08,
208
        BO_SKIP         = 0x10
209
    };
210
211
    LwpObjectID m_SilverBullet;
212
    bool m_bIsNull;
213
};
214
215
inline const LwpObjectID& LwpBulletOverride::GetSilverBullet() const
216
42.3k
{
217
42.3k
    return m_SilverBullet;
218
42.3k
}
219
220
inline bool LwpBulletOverride::IsSilverBulletOverridden() const
221
4.56k
{
222
4.56k
    return ((m_nOverride & BO_SILVERBULLET) != 0);
223
4.56k
}
224
225
inline bool LwpBulletOverride::IsSkipOverridden() const
226
639
{
227
639
    return ((m_nOverride & BO_SKIP) != 0);
228
639
}
229
230
inline bool LwpBulletOverride::IsRightAlignedOverridden() const
231
128
{
232
128
    return ((m_nOverride & BO_RIGHTALIGN) != 0);
233
128
}
234
235
inline bool LwpBulletOverride::IsSkip() const
236
3.30k
{
237
3.30k
    return ((m_nValues & BO_SKIP) != 0);
238
3.30k
}
239
240
inline bool LwpBulletOverride::IsEditable() const
241
1.61k
{
242
1.61k
    return ((m_nValues & BO_EDITABLE) != 0);
243
1.61k
}
244
245
inline bool LwpBulletOverride::IsRightAligned() const
246
1.23k
{
247
1.23k
    return ((m_nValues & BO_RIGHTALIGN) != 0);
248
1.23k
}
249
250
inline void LwpBulletOverride::RevertSilverBullet()
251
59
{
252
59
    LwpOverride::Override(BO_SILVERBULLET, STATE_STYLE);
253
59
}
254
255
inline void LwpBulletOverride::RevertSkip()
256
196
{
257
196
    LwpOverride::Override(BO_SKIP, STATE_STYLE);
258
196
}
259
260
inline void LwpBulletOverride::RevertRightAligned()
261
41
{
262
41
    LwpOverride::Override(BO_RIGHTALIGN, STATE_STYLE);
263
41
}
264
265
class LwpAlignmentOverride final : public LwpOverride
266
{
267
public:
268
4.39k
    LwpAlignmentOverride() : m_nAlignType(ALIGN_LEFT), m_nPosition(0), m_nAlignChar(0){}
269
270
    virtual LwpAlignmentOverride* clone() const override;
271
272
    void Read(LwpObjectStream* pStrm) override;
273
274
    enum AlignType
275
    {
276
        ALIGN_LEFT          = 0,
277
        ALIGN_RIGHT         = 1,
278
        ALIGN_CENTER        = 2,
279
        ALIGN_JUSTIFY       = 3,
280
        ALIGN_JUSTIFYALL    = 4,
281
        ALIGN_NUMERICLEFT   = 5,
282
        ALIGN_NUMERICRIGHT  = 6,
283
        ALIGN_SQUEEZE       = 7
284
    };
285
286
5.43k
    AlignType GetAlignType() const { return m_nAlignType; }
287
    void Override(LwpAlignmentOverride* other);
288
    void OverrideAlignment(AlignType val);
289
290
private:
291
    LwpAlignmentOverride(LwpAlignmentOverride const& rOther);
292
    LwpAlignmentOverride& operator=(LwpAlignmentOverride const& rOther) = delete;
293
294
    enum
295
    {
296
        AO_TYPE     = 0x01,
297
        AO_POSITION = 0x02,
298
        AO_CHAR     = 0x04
299
    };
300
301
    AlignType   m_nAlignType;
302
    sal_uInt32  m_nPosition;
303
    sal_uInt16  m_nAlignChar;
304
};
305
306
class LwpSpacingCommonOverride final : public LwpOverride
307
{
308
public:
309
16.0k
    LwpSpacingCommonOverride() : m_nSpacingType(SPACING_NONE), m_nAmount(0), m_nMultiple(65536){}
310
311
    virtual LwpSpacingCommonOverride* clone() const override;
312
313
    void Read(LwpObjectStream* pStrm) override;
314
315
    enum SpacingType
316
    {
317
        SPACING_DYNAMIC = 0,
318
        SPACING_LEADING = 1,
319
        SPACING_CUSTOM  = 2,
320
        SPACING_NONE    = 3
321
    };
322
323
14.5k
    SpacingType GetType() const {return m_nSpacingType;}
324
14.5k
    sal_Int32 GetAmount() const {return m_nAmount;}
325
14.5k
    sal_Int32 GetMultiple() const {return m_nMultiple;}
326
327
    void Override(LwpSpacingCommonOverride* other);
328
    void OverrideType(SpacingType val);
329
    void OverrideAmount(sal_Int32 val);
330
    void OverrideMultiple(sal_Int32 val);
331
332
private:
333
    LwpSpacingCommonOverride(LwpSpacingCommonOverride const& rOther);
334
    LwpSpacingCommonOverride& operator=(LwpSpacingCommonOverride const& rOther) = delete;
335
336
    enum
337
    {
338
        SPO_TYPE    = 0x01,
339
        SPO_AMOUNT  = 0x02,
340
        SPO_MULTIPLE= 0x04
341
    };
342
    SpacingType m_nSpacingType;//sal_uInt16
343
    sal_Int32   m_nAmount;
344
    sal_Int32   m_nMultiple;
345
};
346
347
class LwpSpacingOverride final : public LwpOverride
348
{
349
public:
350
    LwpSpacingOverride();
351
    virtual ~LwpSpacingOverride() override;
352
353
    virtual LwpSpacingOverride* clone() const override;
354
355
    void Read(LwpObjectStream* pStrm) override;
356
357
    void Override(LwpSpacingOverride* other);
358
359
5.38k
    LwpSpacingCommonOverride* GetSpacing(){return m_pSpacing.get();}
360
551
    LwpSpacingCommonOverride* GetAboveLineSpacing(){return m_pAboveLineSpacing.get();}
361
5.38k
    LwpSpacingCommonOverride* GetAboveSpacing(){return m_pParaSpacingAbove.get();}
362
5.38k
    LwpSpacingCommonOverride* GetBelowSpacing(){return m_pParaSpacingBelow.get();}
363
364
private:
365
    LwpSpacingOverride(LwpSpacingOverride const& rOther);
366
    LwpSpacingOverride& operator=(LwpSpacingOverride const& rOther) = delete;
367
368
    std::unique_ptr<LwpSpacingCommonOverride>   m_pSpacing;
369
    std::unique_ptr<LwpSpacingCommonOverride>   m_pAboveLineSpacing;
370
    std::unique_ptr<LwpSpacingCommonOverride>   m_pParaSpacingAbove;
371
    std::unique_ptr<LwpSpacingCommonOverride>   m_pParaSpacingBelow;
372
};
373
374
class LwpIndentOverride final : public LwpOverride
375
{
376
public:
377
22.4k
    LwpIndentOverride() : m_nAll(0), m_nFirst(0), m_nRest(0), m_nRight(0) {}
378
379
    virtual LwpIndentOverride* clone() const override;
380
381
    void Read(LwpObjectStream* pStrm) override;
382
383
    enum
384
    {
385
        RELATIVE_FIRST, RELATIVE_REST, RELATIVE_ALL
386
    };
387
388
    inline double GetFirst() const;
389
    inline double GetLeft() const;
390
    inline double GetRight() const;
391
392
    sal_uInt16 GetRelative() const;
393
    bool IsUseRelative() const;
394
    void Override(LwpIndentOverride* other);
395
    void OverrideIndentAll(sal_Int32 val);
396
    void OverrideIndentFirst(sal_Int32 val);
397
    void OverrideIndentRight(sal_Int32 val);
398
    void OverrideIndentRest(sal_Int32 val);
399
    void OverrideUseRelative(bool use);
400
    void OverrideRelative(sal_uInt16 relative);
401
7.58k
    sal_Int32 GetMAll() const {return m_nAll;}
402
2.63k
    sal_Int32 GetMFirst() const {return m_nFirst;}
403
4.81k
    sal_Int32 GetMRest() const {return m_nRest;}
404
5.51k
    sal_Int32 GetMRight() const {return m_nRight;}
405
2.75k
    void SetMAll(sal_Int32 val){m_nAll=val;}
406
6.85k
    void SetMFirst(sal_Int32 val){m_nFirst=val;}
407
6.85k
    void SetMRest(sal_Int32 val){m_nRest=val;}
408
2.75k
    void SetMRight(sal_Int32 val){m_nRight=val;}
409
410
private:
411
    LwpIndentOverride(LwpIndentOverride const& rOther);
412
    LwpIndentOverride& operator=(LwpIndentOverride const& rOther) = delete;
413
414
    enum
415
    {
416
        IO_ALL          = 0x0001,
417
        IO_FIRST        = 0x0002,
418
        IO_REST         = 0x0004,
419
        IO_RIGHT        = 0x0008,
420
        IO_HANGING      = 0x0010,
421
        IO_EQUAL        = 0x0020,
422
        IO_BODY         = 0x0040,
423
        IO_REL_ALL      = 0x0080,
424
        IO_REL_FIRST    = 0x0100,
425
        IO_REL_REST     = 0x0200,
426
        IO_REL_FLAGS    = (IO_REL_ALL | IO_REL_FIRST | IO_REL_REST),
427
        IO_USE_RELATIVE = 0x0400
428
    };
429
430
    sal_Int32   m_nAll;
431
    sal_Int32   m_nFirst;
432
    sal_Int32   m_nRest;
433
    sal_Int32   m_nRight;
434
};
435
436
inline double LwpIndentOverride::GetFirst() const
437
14.3k
{
438
14.3k
    sal_Int32 nRes;
439
14.3k
    if (o3tl::checked_sub(m_nFirst, m_nRest, nRes))
440
3
        throw std::range_error("bad len");
441
14.3k
    return LwpTools::ConvertFromUnits(nRes);
442
14.3k
}
443
inline double LwpIndentOverride::GetLeft() const
444
14.3k
{
445
14.3k
    sal_Int32 nRes;
446
14.3k
    if (o3tl::checked_add(m_nAll, m_nRest, nRes))
447
20
        throw std::range_error("bad len");
448
14.3k
    return LwpTools::ConvertFromUnits(nRes);
449
14.3k
}
450
inline double LwpIndentOverride::GetRight() const
451
16.3k
{
452
16.3k
    return LwpTools::ConvertFromUnits(m_nRight);
453
16.3k
}
454
455
class LwpBackgroundStuff;
456
class LwpAmikakeOverride final : public LwpOverride
457
{
458
public:
459
    LwpAmikakeOverride();
460
461
    virtual ~LwpAmikakeOverride() override;
462
463
    virtual LwpAmikakeOverride* clone() const override;
464
465
    void Read(LwpObjectStream* pStrm) override;
466
    enum
467
    {
468
        AMIKAKE_NONE        = 0,
469
        AMIKAKE_BACKGROUND  = 1,
470
        AMIKAKE_CHARACTER   = 2
471
    };
472
473
private:
474
    LwpAmikakeOverride(LwpAmikakeOverride const& rOther);
475
    LwpAmikakeOverride& operator=(LwpAmikakeOverride const& rOther) = delete;
476
477
    std::unique_ptr<LwpBackgroundStuff> m_pBackgroundStuff;
478
    sal_uInt16      m_nType;
479
};
480
481
#endif
482
483
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */