Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/poolfmt.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_SW_INC_POOLFMT_HXX
20
#define INCLUDED_SW_INC_POOLFMT_HXX
21
22
#include <limits.h>
23
#include <editeng/frmdir.hxx>
24
#include <i18nlangtag/lang.h>
25
26
/** POOLCOLL-IDs:
27
// +----+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
28
// !User!    Range      ! 0 !               Offset                  !
29
// +----+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
30
//
31
//  Range:                          1 - text
32
//                                  2 - lists
33
//                                  3 - special ranges
34
//                                  4 - indices
35
//                                  5 - chapter / document
36
//                                  6 - HTML-styles.
37
38
// Other IDs:
39
// +----+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
40
// !User!    Range      ! 1 !           Offset                      !
41
// +----+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
42
// Range:                           0 - character styles
43
//                                  1 - frame styles
44
//                                  2 - page styles
45
//                                  3 - paragraph styles (?)
46
//                                  4 - graphics styles (?)
47
48
// For all IDs we have:
49
// Origin:                          0 -pool
50
//                                  1 -user
51
// Offset:                          within the group */
52
53
/** Attention: New IDs can only be added to the ends of the groups.
54
   These IDs are read and written by the Reader/Writer.
55
   They are only aware of the Offset to Start. */
56
57
/// Mask for recognition of COLLPOOL-IDs:
58
59
const sal_uInt16 POOLGRP_NOCOLLID       =  (1 << 10);
60
61
/// POLLCOLL-groups:
62
63
const sal_uInt16 USER_FMT               =  (1 << 15);
64
65
const sal_uInt16 COLL_TEXT_BITS         =  (1 << 11);
66
const sal_uInt16 COLL_LISTS_BITS        =  (2 << 11);
67
const sal_uInt16 COLL_EXTRA_BITS        =  (3 << 11);
68
const sal_uInt16 COLL_REGISTER_BITS     =  (4 << 11);
69
const sal_uInt16 COLL_DOC_BITS          =  (5 << 11);
70
const sal_uInt16 COLL_HTML_BITS         =  (6 << 11);
71
const sal_uInt16 COLL_GET_RANGE_BITS    = (15 << 11);
72
73
/// Other groups:
74
75
const sal_uInt16 POOLGRP_CHARFMT        = (0 << 11) + POOLGRP_NOCOLLID;
76
const sal_uInt16 POOLGRP_FRAMEFMT       = (1 << 11) + POOLGRP_NOCOLLID;
77
const sal_uInt16 POOLGRP_PAGEDESC       = (2 << 11) + POOLGRP_NOCOLLID;
78
const sal_uInt16 POOLGRP_NUMRULE        = (3 << 11) + POOLGRP_NOCOLLID;
79
const sal_uInt16 POOLGRP_TABSTYLE       = (4 << 11) + POOLGRP_NOCOLLID;
80
const sal_uInt16 POOLGRP_CELLSTYLE      = (5 << 11) + POOLGRP_NOCOLLID;
81
82
/// IDs for the ranges.
83
enum class SwPoolFormatId : sal_uInt16
84
{
85
ZERO = 0,
86
RES_POOLFMT_BEGIN = 1,
87
RES_POOL_CHRFMT = RES_POOLFMT_BEGIN,
88
RES_POOL_FRMFMT,
89
RES_POOL_TXTCOLL,
90
RES_POOL_PAGEFMT,
91
92
RES_POOL_PARFMT,
93
RES_POOL_GRFFMT,
94
RES_POOLFMT_END,
95
96
/// Ranges for the IDs of the formats.
97
98
/// IDs for character styles.
99
CHR_BEGIN = POOLGRP_CHARFMT,
100
CHR_NORMAL_BEGIN = POOLGRP_CHARFMT,
101
102
CHR_FOOTNOTE = CHR_NORMAL_BEGIN,    ///< Footnote.
103
CHR_PAGENO,                                 ///< Pages/field.
104
CHR_LABEL,                                  ///< Label.
105
CHR_DROPCAPS,                               ///< Dropcaps.
106
CHR_NUM_LEVEL,                              ///< Numbering symbols
107
CHR_BULLET_LEVEL,                           ///< Bullets.
108
109
CHR_INET_NORMAL,                            ///< Internet normal.
110
CHR_INET_VISIT,                             ///< Internet visited.
111
CHR_JUMPEDIT,                               ///< Placeholder.
112
CHR_TOXJUMP,                                ///< Jump from index.
113
CHR_ENDNOTE,                                ///< Endnote.
114
CHR_LINENUM,                                ///< Line numbering.
115
CHR_IDX_MAIN_ENTRY,                         ///< Main entry in indices.
116
CHR_FOOTNOTE_ANCHOR,                        ///< Footnote anchor.
117
CHR_ENDNOTE_ANCHOR,                         ///< Endnote anchor.
118
CHR_RUBYTEXT,                               ///< Rubytext.
119
CHR_VERT_NUM,                               ///< Vertical numbering symbols.
120
121
CHR_NORMAL_END,
122
123
CHR_HTML_BEGIN = CHR_BEGIN + 50,    ///< HTML-styles.
124
CHR_HTML_EMPHASIS = CHR_HTML_BEGIN,
125
CHR_HTML_CITATION,
126
CHR_HTML_STRONG,
127
CHR_HTML_CODE,
128
CHR_HTML_SAMPLE,
129
CHR_HTML_KEYBOARD,
130
CHR_HTML_VARIABLE,
131
CHR_HTML_DEFINSTANCE,
132
CHR_HTML_TELETYPE,
133
CHR_HTML_END,
134
135
CHR_END = CHR_HTML_END,
136
137
/// IDs for frame styles.
138
FRM_BEGIN = POOLGRP_FRAMEFMT,
139
140
FRM_FRAME = FRM_BEGIN,              ///< Frame.
141
FRM_GRAPHIC,                                ///< Graphics.
142
FRM_OLE,                                    ///< OLE.
143
FRM_FORMEL,                                 ///< Formula.
144
FRM_MARGINAL,                               ///< Marginalia.
145
FRM_WATERSIGN,                              ///< Watermark.
146
FRM_LABEL,                                  ///< Labels.
147
FRM_INLINE_HEADING,                         ///< Inline Heading.
148
149
FRM_END,
150
151
/// IDs for page styles.
152
PAGE_BEGIN = POOLGRP_PAGEDESC,
153
154
PAGE_STANDARD = PAGE_BEGIN,         ///< Standard page.
155
PAGE_FIRST,                                 ///< First page.
156
PAGE_LEFT,                                  ///< Left page.
157
PAGE_RIGHT,                                 ///< Right page.
158
PAGE_ENVELOPE,                              ///< Envelope.
159
PAGE_REGISTER,                              ///< Index.
160
PAGE_HTML,                                  ///< HTML.
161
PAGE_FOOTNOTE,                              ///< Footnote at end of document.
162
PAGE_ENDNOTE,                               ///< Endnote page.
163
PAGE_LANDSCAPE,                             ///< Landscape page style.
164
165
PAGE_END,
166
167
// IDs for list styles.
168
NUMRULE_BEGIN = POOLGRP_NUMRULE,
169
NUMRULE_NOLIST = NUMRULE_BEGIN,
170
NUMRULE_NUM1,                               ///< NumRule Numbering 123.
171
NUMRULE_NUM2,                               ///< NumRule Numbering ABC.
172
NUMRULE_NUM3,                               ///< NumRule Numbering abc.
173
NUMRULE_NUM4,                               ///< NumRule Numbering IVX.
174
NUMRULE_NUM5,                               ///< NumRule Numbering ivx.
175
NUMRULE_BUL1,                               ///< NumRule Bullets 1.
176
NUMRULE_BUL2,                               ///< NumRule Bullets 2.
177
NUMRULE_BUL3,                               ///< NumRule Bullets 3.
178
NUMRULE_BUL4,                               ///< NumRule Bullets 4.
179
NUMRULE_BUL5,                               ///< NumRule Bullets 5.
180
NUMRULE_END,
181
182
// IDs for table styles.
183
TABLESTYLE_BEGIN = POOLGRP_TABSTYLE,
184
TABLESTYLE_DEFAULT = TABLESTYLE_BEGIN,
185
// 16 old styles
186
TABLESTYLE_3D,
187
TABLESTYLE_BLACK1,
188
TABLESTYLE_BLACK2,
189
TABLESTYLE_BLUE,
190
TABLESTYLE_BROWN,
191
TABLESTYLE_CURRENCY,
192
TABLESTYLE_CURRENCY_3D,
193
TABLESTYLE_CURRENCY_GRAY,
194
TABLESTYLE_CURRENCY_LAVENDER,
195
TABLESTYLE_CURRENCY_TURQUOISE,
196
TABLESTYLE_GRAY,
197
TABLESTYLE_GREEN,
198
TABLESTYLE_LAVENDER,
199
TABLESTYLE_RED,
200
TABLESTYLE_TURQUOISE,
201
TABLESTYLE_YELLOW,
202
// 10 new styles since LibreOffice 6.0
203
TABLESTYLE_LO6_ACADEMIC,
204
TABLESTYLE_LO6_BOX_LIST_BLUE,
205
TABLESTYLE_LO6_BOX_LIST_GREEN,
206
TABLESTYLE_LO6_BOX_LIST_RED,
207
TABLESTYLE_LO6_BOX_LIST_YELLOW,
208
TABLESTYLE_LO6_ELEGANT,
209
TABLESTYLE_LO6_FINANCIAL,
210
TABLESTYLE_LO6_SIMPLE_GRID_COLUMNS,
211
TABLESTYLE_LO6_SIMPLE_GRID_ROWS,
212
TABLESTYLE_LO6_SIMPLE_LIST_SHADED,
213
TABLESTYLE_END,
214
215
CELLSTYLE_BEGIN = POOLGRP_CELLSTYLE,
216
CELLSTYLE_END = CELLSTYLE_BEGIN,
217
218
// IDs for paragraph styles.
219
// Group text.
220
COLL_TEXT_BEGIN = COLL_TEXT_BITS,
221
222
COLL_STANDARD = COLL_TEXT_BEGIN,        ///< Standard.
223
COLL_TEXT,                                      ///< Text body.
224
COLL_TEXT_IDENT,                                ///< Text body first line indent.
225
COLL_TEXT_NEGIDENT,                             ///< Text body hanging indent.
226
COLL_TEXT_MOVE,                                 ///< Text body indent.
227
COLL_GREETING,                                  ///< Complimentary close.
228
COLL_SIGNATURE,                                 ///< Signature.
229
COLL_CONFRONTATION,                             ///< List indent.
230
COLL_MARGINAL,                                  ///< Marginalia.
231
232
COLL_TEXT_END,
233
234
/// Group lists.
235
COLL_LISTS_BEGIN = COLL_LISTS_BITS,
236
237
COLL_NUMBER_BULLET_BASE = COLL_LISTS_BEGIN,    ///< Base list.
238
239
/// Subgroup numberings.
240
COLL_NUM_LEVEL1S,                               ///< Start 1st level.
241
COLL_NUM_LEVEL1,                                ///< 1st level.
242
COLL_NUM_LEVEL1E,                               ///< End 1st level.
243
COLL_NUM_NONUM1,                                ///< No numbering.
244
COLL_NUM_LEVEL2S,                               ///< Start 2nd level.
245
COLL_NUM_LEVEL2,                                ///< 2nd level.
246
COLL_NUM_LEVEL2E,                               ///< End 2nd level.
247
COLL_NUM_NONUM2,                                ///< No numbering.
248
COLL_NUM_LEVEL3S,                               ///< Start 3rd level.
249
COLL_NUM_LEVEL3,                                ///< 3rd level.
250
COLL_NUM_LEVEL3E,                               ///< End 3rd level.
251
COLL_NUM_NONUM3,                                ///< No numbering.
252
COLL_NUM_LEVEL4S,                               ///< Start 4th level.
253
COLL_NUM_LEVEL4,                                ///< 4th level.
254
COLL_NUM_LEVEL4E,                               ///< End 4th level.
255
COLL_NUM_NONUM4,                                ///< No numbering.
256
COLL_NUM_LEVEL5S,                               ///< Start 5th level.
257
COLL_NUM_LEVEL5,                                ///< 5th level.
258
COLL_NUM_LEVEL5E,                               ///< End 5th level.
259
COLL_NUM_NONUM5,                                ///< No numbering.
260
261
///Subgroup bullets.
262
COLL_BULLET_LEVEL1S,                               ///< Start 1st level.
263
COLL_BULLET_LEVEL1,                                ///< 1st level.
264
COLL_BULLET_LEVEL1E,                               ///< End 1st level
265
COLL_BULLET_NONUM1,                                ///< No numbering.
266
COLL_BULLET_LEVEL2S,                               ///< Start 2nd level.
267
COLL_BULLET_LEVEL2,                                ///< 2nd level.
268
COLL_BULLET_LEVEL2E,                               ///< End 2nd level.
269
COLL_BULLET_NONUM2,                                ///< No numbering.
270
COLL_BULLET_LEVEL3S,                               ///< Start 3rd level.
271
COLL_BULLET_LEVEL3,                                ///< 3rd Level.
272
COLL_BULLET_LEVEL3E,                               ///< End 3rd level.
273
COLL_BULLET_NONUM3,                                ///< No numbering.
274
COLL_BULLET_LEVEL4S,                               ///< Start 4th level.
275
COLL_BULLET_LEVEL4,                                ///< 4th level.
276
COLL_BULLET_LEVEL4E,                               ///< End 4th level.
277
COLL_BULLET_NONUM4,                                ///< No numbering.
278
COLL_BULLET_LEVEL5S,                               ///< Start 5th level.
279
COLL_BULLET_LEVEL5,                                ///< 5th level.
280
COLL_BULLET_LEVEL5E,                               ///< End 5th Level.
281
COLL_BULLET_NONUM5,                                ///< No numbering.
282
283
COLL_LISTS_END,
284
285
/// Special ranges.
286
COLL_EXTRA_BEGIN = COLL_EXTRA_BITS,
287
288
/// Subgroup header.
289
COLL_HEADERFOOTER = COLL_EXTRA_BEGIN,   ///< Header and Footer.
290
COLL_HEADER,                                    ///< Header Left&Right.
291
COLL_HEADERL,                                   ///< Header Left.
292
COLL_HEADERR,                                   ///< Header Right.
293
294
/// Subgroup footer.
295
COLL_FOOTER,                                    ///< Footer Left&Right.
296
COLL_FOOTERL,                                   ///< Footer Left.
297
COLL_FOOTERR,                                   ///< Footer Right.
298
299
/// Subgroup table.
300
COLL_TABLE,                                     ///< Table of Contents.
301
COLL_TABLE_HDLN,                                ///< Table of Contents - heading.
302
303
/// Subgroup labels.
304
COLL_LABEL,                                     ///< Base labels.
305
COLL_LABEL_ABB,                                 ///< Label illustration.
306
COLL_LABEL_TABLE,                               ///< Label table.
307
COLL_LABEL_FRAME,                               ///< Label frame.
308
COLL_LABEL_FIGURE,                              ///< Label figure
309
310
/// Other stuff.
311
COLL_FRAME,                                     ///< Frames.
312
COLL_FOOTNOTE,                                  ///< Footnotes.
313
COLL_ENVELOPE_ADDRESS,                          ///< Addressee.
314
COLL_SEND_ADDRESS,                              ///< Sender.
315
COLL_ENDNOTE,                                   ///< Endnotes.
316
317
COLL_LABEL_DRAWING,                             ///< Label drawing objects.
318
COLL_COMMENT,                                   ///< Comment
319
320
COLL_EXTRA_END,
321
322
/// Group indices.
323
COLL_REGISTER_BEGIN = COLL_REGISTER_BITS,
324
325
COLL_REGISTER_BASE = COLL_REGISTER_BEGIN,   ///< Base index.
326
327
/// Subgroup index tables.
328
COLL_TOX_IDXH,                                  ///< Header.
329
COLL_TOX_IDX1,                                  ///< 1st level.
330
COLL_TOX_IDX2,                                  ///< 2nd level.
331
COLL_TOX_IDX3,                                  ///< 3rd level.
332
COLL_TOX_IDXBREAK,                              ///< Separator.
333
334
/// Subgroup table of contents.
335
COLL_TOX_CNTNTH,                                ///< Header.
336
COLL_TOX_CNTNT1,                                ///< Content 1st level.
337
COLL_TOX_CNTNT2,                                ///< Content 2nd level.
338
COLL_TOX_CNTNT3,                                ///< Content 3rd level.
339
COLL_TOX_CNTNT4,                                ///< Content 4th level.
340
COLL_TOX_CNTNT5,                                ///< Content 5th level.
341
342
/// Subgroup user indices.
343
COLL_TOX_USERH,                                 ///< Header.
344
COLL_TOX_USER1,                                 ///< 1st level.
345
COLL_TOX_USER2,                                 ///< 2nd level.
346
COLL_TOX_USER3,                                 ///< 3rd level.
347
COLL_TOX_USER4,                                 ///< 4th level.
348
COLL_TOX_USER5,                                 ///< 5th level.
349
350
COLL_TOX_CNTNT6,                                ///< Content  6th level.
351
COLL_TOX_CNTNT7,                                ///< Content  7th level.
352
COLL_TOX_CNTNT8,                                ///< Content  8th level.
353
COLL_TOX_CNTNT9,                                ///< Content  9th level.
354
COLL_TOX_CNTNT10,                               ///< Content 10th level.
355
356
/// illustrations index.
357
COLL_TOX_ILLUSH,                                ///< Illustrations header.
358
COLL_TOX_ILLUS1,                                ///< Illustrations all levels.
359
360
///  object index.
361
COLL_TOX_OBJECTH,                               ///< Objects header.
362
COLL_TOX_OBJECT1,                               ///< Objects all levels.
363
364
///  tables index.
365
COLL_TOX_TABLESH,                               ///< Tables header.
366
COLL_TOX_TABLES1,                               ///< Tables all levels.
367
368
///  index of authorities.
369
COLL_TOX_AUTHORITIESH,                          ///< Authorities header.
370
COLL_TOX_AUTHORITIES1,                          ///< Authorities all levels.
371
372
/// user index 6..10.
373
COLL_TOX_USER6,                                 ///< 6th  level.
374
COLL_TOX_USER7,                                 ///< 7th  level.
375
COLL_TOX_USER8,                                 ///< 8th  level.
376
COLL_TOX_USER9,                                 ///< 9th  level.
377
COLL_TOX_USER10,                                ///< 10th level.
378
379
COLL_REGISTER_END,
380
381
/// Group chapter / document.
382
COLL_DOC_BEGIN = COLL_DOC_BITS,
383
384
COLL_DOC_TITLE = COLL_DOC_BEGIN,        ///< Doc. title.
385
COLL_DOC_SUBTITLE,                              ///< Doc. subtitle.
386
COLL_DOC_APPENDIX,                              ///< Doc. appendix.
387
388
/// Subgroup headings.
389
COLL_HEADLINE_BASE, ///< Base heading.
390
COLL_HEADLINE1, ///< Heading 1.
391
COLL_HEADLINE2, ///< Heading 2.
392
COLL_HEADLINE3, ///< Heading 3.
393
COLL_HEADLINE4, ///< Heading 4.
394
COLL_HEADLINE5, ///< Heading 5.
395
COLL_HEADLINE6, ///< Heading 6.
396
COLL_HEADLINE7, ///< Heading 7.
397
COLL_HEADLINE8, ///< Heading 8.
398
COLL_HEADLINE9, ///< Heading 9.
399
COLL_HEADLINE10, ///< Heading 10.
400
401
COLL_DOC_END,
402
403
/// Group HTML-styles.
404
COLL_HTML_BEGIN = COLL_HTML_BITS,
405
406
COLL_HTML_BLOCKQUOTE = COLL_HTML_BEGIN,
407
COLL_HTML_PRE,
408
COLL_HTML_HR,
409
COLL_HTML_DD,
410
COLL_HTML_DT,
411
412
COLL_HTML_END,
413
414
/// End of text styles collection.
415
416
UNKNOWN = USHRT_MAX
417
418
};
419
/// End of SwPoolFormatId
420
421
// We do a fair amount of calculation on these values to extract sub-ranges, etc, so
422
// add some operators to make that less verbose.
423
inline constexpr SwPoolFormatId operator-(SwPoolFormatId lhs, SwPoolFormatId rhs)
424
6.86M
{ return SwPoolFormatId(sal_uInt16(lhs) - sal_uInt16(rhs)); }
425
inline constexpr SwPoolFormatId operator&(SwPoolFormatId lhs, SwPoolFormatId rhs)
426
0
{ return SwPoolFormatId(sal_uInt16(lhs) & sal_uInt16(rhs)); }
427
inline constexpr SwPoolFormatId operator+(SwPoolFormatId lhs, sal_uInt16 rhs)
428
1.44k
{ return SwPoolFormatId(sal_uInt16(lhs) + rhs); }
429
inline constexpr SwPoolFormatId operator-(SwPoolFormatId lhs, sal_uInt16 rhs)
430
1.44k
{ return SwPoolFormatId(sal_uInt16(lhs) - rhs); }
431
432
/// Recognize whether it's a user defined style or not:
433
const sal_uInt16 POOL_IDUSER_FMT =
434
        USHRT_MAX & ~(COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID);
435
436
inline bool IsPoolUserFormat( SwPoolFormatId nId )
437
24.9k
{
438
24.9k
    return POOL_IDUSER_FMT == (sal_uInt16(nId) & ~(COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID));
439
24.9k
}
440
441
/** Query defined parent of a POOL-ID
442
   Returns  0 if standard
443
            SwPoolFormatId::UNKNOWN if no parent
444
            the parent in all other cases. */
445
SwPoolFormatId GetPoolParent( SwPoolFormatId nId );
446
447
SvxFrameDirection GetDefaultFrameDirection(LanguageType nLanguage);
448
449
bool IsConditionalByPoolId(SwPoolFormatId nId);
450
451
#endif
452
453
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */