Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/viewopt.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_SW_INC_VIEWOPT_HXX
21
#define INCLUDED_SW_INC_VIEWOPT_HXX
22
23
#include <config_feature_desktop.h>
24
25
#include <tools/gen.hxx>
26
#include <tools/color.hxx>
27
28
#include <svx/swframetypes.hxx>
29
#include <sfx2/zoomitem.hxx>
30
#include "swdllapi.h"
31
#include "swtypes.hxx"
32
33
class SwRect;
34
class OutputDevice;
35
class SwDocShell;
36
namespace svtools{ class ColorConfig;}
37
enum class SwFillMode;
38
39
struct ViewOptFlags1
40
{
41
    bool bUseHeaderFooterMenu : 1;
42
    bool bTab : 1;
43
    bool bBlank : 1;
44
    bool bHardBlank : 1;
45
    bool bParagraph : 1;
46
    bool bLinebreak : 1;
47
    bool bPagebreak : 1;
48
    bool bColumnbreak : 1;
49
    bool bSoftHyph : 1;
50
    bool bBookmarks : 1;
51
    bool bRef : 1;
52
    bool bFieldName : 1;
53
    bool bPostits : 1;
54
    bool bFieldHidden : 1;
55
    bool bCharHidden : 1;
56
    bool bGraphic : 1;
57
    bool bTable : 1;
58
    bool bDraw : 1;
59
    bool bControl : 1;
60
    bool bCrosshair : 1;
61
    bool bSnap : 1;
62
    bool bSynchronize : 1;
63
    bool bGridVisible : 1;
64
    bool bBaselineGridVisible : 1;
65
    bool bOnlineSpell : 1;
66
    bool bTreatSubOutlineLevelsAsContent : 1;
67
    bool bShowInlineTooltips : 1; //tooltips on tracked changes
68
    bool bViewMetachars : 1;
69
70
    /// Track changes: recording is on
71
    bool bRedlineRecordingOn : 1;
72
73
    bool bPageback : 1;
74
    bool bShowOutlineContentVisibilityButton : 1;
75
    bool bShowChangesInMargin : 1; //tracked deletions in margin
76
    bool bShowChangesInMargin2 : 1; //tracked insertions in margin
77
    bool bTextBoundaries : 1;   // text boundaries
78
    bool bTextBoundariesFull : 1;   // true = frame around text, false = crop marks at edges
79
    bool bSectionBoundaries : 1;   // section boundaries
80
    bool bTableBoundaries : 1;   // table boundaries
81
    bool bShowBoundaries : 1;   // show all boundaries
82
    bool bClickChangeRotation : 1; // change with single click into rotate mode
83
84
    ViewOptFlags1()
85
73.5k
        : bUseHeaderFooterMenu(false)
86
73.5k
        , bTab(false)
87
73.5k
        , bBlank(false)
88
73.5k
        , bHardBlank(true)
89
73.5k
        , bParagraph(false)
90
73.5k
        , bLinebreak(false)
91
73.5k
        , bPagebreak(false)
92
73.5k
        , bColumnbreak(false)
93
73.5k
        , bSoftHyph(true)
94
73.5k
        , bBookmarks(false)
95
73.5k
        , bRef(true)
96
73.5k
        , bFieldName(false)
97
73.5k
        , bPostits(true)
98
73.5k
        , bFieldHidden(false)
99
73.5k
        , bCharHidden(false)
100
73.5k
        , bGraphic(true)
101
73.5k
        , bTable(true)
102
73.5k
        , bDraw(true)
103
73.5k
        , bControl(true)
104
73.5k
        , bCrosshair(false)
105
73.5k
        , bSnap(false)
106
73.5k
        , bSynchronize(false)
107
73.5k
        , bGridVisible(false)
108
73.5k
        , bBaselineGridVisible(false)
109
73.5k
        , bOnlineSpell(false)
110
73.5k
        , bTreatSubOutlineLevelsAsContent(false)
111
73.5k
        , bShowInlineTooltips(false)
112
73.5k
        , bViewMetachars(false)
113
73.5k
        , bRedlineRecordingOn(false)
114
73.5k
        , bPageback(true)
115
73.5k
        , bShowOutlineContentVisibilityButton(false)
116
73.5k
        , bShowChangesInMargin(false)
117
73.5k
        , bShowChangesInMargin2(false)
118
73.5k
        , bTextBoundaries(true)
119
73.5k
        , bTextBoundariesFull(false)
120
73.5k
        , bSectionBoundaries(true)
121
73.5k
        , bTableBoundaries(true)
122
73.5k
        , bShowBoundaries(true)
123
73.5k
        , bClickChangeRotation(false)
124
73.5k
    {}
125
126
    bool operator==(const ViewOptFlags1& rOther) const
127
12.5k
    {
128
12.5k
        return bUseHeaderFooterMenu == rOther.bUseHeaderFooterMenu
129
12.5k
            && bTab == rOther.bTab
130
12.5k
            && bBlank == rOther.bBlank
131
12.5k
            && bHardBlank == rOther.bHardBlank
132
466
            && bParagraph == rOther.bParagraph
133
466
            && bLinebreak == rOther.bLinebreak
134
466
            && bPagebreak == rOther.bPagebreak
135
466
            && bColumnbreak == rOther.bColumnbreak
136
466
            && bSoftHyph == rOther.bSoftHyph
137
466
            && bBookmarks == rOther.bBookmarks
138
466
            && bRef == rOther.bRef
139
466
            && bFieldName == rOther.bFieldName
140
466
            && bPostits == rOther.bPostits
141
466
            && bFieldHidden == rOther.bFieldHidden
142
466
            && bCharHidden == rOther.bCharHidden
143
466
            && bGraphic == rOther.bGraphic
144
466
            && bTable == rOther.bTable
145
466
            && bDraw == rOther.bDraw
146
466
            && bControl == rOther.bControl
147
466
            && bCrosshair == rOther.bCrosshair
148
466
            && bSnap == rOther.bSnap
149
466
            && bSynchronize == rOther.bSynchronize
150
466
            && bGridVisible == rOther.bGridVisible
151
466
            && bBaselineGridVisible == rOther.bBaselineGridVisible
152
466
            && bOnlineSpell == rOther.bOnlineSpell
153
466
            && bTreatSubOutlineLevelsAsContent == rOther.bTreatSubOutlineLevelsAsContent
154
466
            && bShowInlineTooltips == rOther.bShowInlineTooltips
155
466
            && bViewMetachars == rOther.bViewMetachars
156
466
            && bRedlineRecordingOn == rOther.bRedlineRecordingOn
157
466
            && bPageback == rOther.bPageback
158
466
            && bShowOutlineContentVisibilityButton == rOther.bShowOutlineContentVisibilityButton
159
466
            && bShowChangesInMargin == rOther.bShowChangesInMargin
160
466
            && bShowChangesInMargin2 == rOther.bShowChangesInMargin2
161
466
            && bTextBoundaries == rOther.bTextBoundaries
162
466
            && bTextBoundariesFull == rOther.bTextBoundariesFull
163
466
            && bSectionBoundaries == rOther.bSectionBoundaries
164
466
            && bTableBoundaries == rOther.bTableBoundaries
165
466
            && bShowBoundaries == rOther.bShowBoundaries
166
466
            && bClickChangeRotation == rOther.bClickChangeRotation;
167
12.5k
    }
168
169
    void dumpAsXml(xmlTextWriterPtr pWriter) const;
170
};
171
172
enum class ViewOptCoreFlags2 {
173
    BlackFont         = 0x0001,
174
    HiddenPara        = 0x0002,
175
    SmoothScroll      = 0x0004,
176
    CursorInProt      = 0x0008,
177
    PdfExport         = 0x0010,
178
    Printing          = 0x0020,
179
};
180
namespace o3tl {
181
    template<> struct typed_flags<ViewOptCoreFlags2> : is_typed_flags<ViewOptCoreFlags2, 0x003f> {};
182
};
183
184
enum class ViewOptFlags2 {
185
    HRuler          = 0x00000400,
186
    VScrollbar      = 0x00000800,
187
    HScrollbar      = 0x00001000,
188
    VRuler          = 0x00004000,
189
    AnyRuler        = 0x00008000,
190
    Modified        = 0x00010000,
191
    KeepAspectRatio = 0x00020000,
192
    GrfKeepZoom     = 0x00040000,
193
    ContentTips     = 0x00100000,
194
    ScrollbarTips   = 0x00400000,
195
    PrintFormat     = 0x00800000,
196
    ShadowCursor    = 0x01000000,
197
    VRulerRight     = 0x02000000,
198
    ResolvedPostits = 0x04000000,
199
};
200
namespace o3tl {
201
    template<> struct typed_flags<ViewOptFlags2> : is_typed_flags<ViewOptFlags2, 0x07d7dc00> {};
202
};
203
204
// Table background.
205
60.9k
#define TBL_DEST_CELL   0
206
#define TBL_DEST_ROW    1
207
#define TBL_DEST_TBL    2
208
209
// Appearance flags.
210
enum class ViewOptFlags {
211
    NONE               = 0x0000,
212
    IndexShadings      = 0x0001,
213
    Links              = 0x0002,
214
    VisitedLinks       = 0x0004,
215
    FieldShadings      = 0x0008,
216
    Shadow             = 0x0010,
217
};
218
namespace o3tl {
219
    template<> struct typed_flags<ViewOptFlags> : is_typed_flags<ViewOptFlags, 0x01ff> {};
220
}
221
222
struct SwViewColors
223
{
224
    SwViewColors();
225
    SwViewColors(const svtools::ColorConfig& rConfig);
226
    bool operator==(const SwViewColors& rOther) const
227
108
    {
228
108
        return m_aDocColor == rOther.m_aDocColor
229
108
            && m_aDocBoundColor == rOther.m_aDocBoundColor
230
108
            && m_aAppBackgroundColor == rOther.m_aAppBackgroundColor
231
108
            && m_aTableBoundColor == rOther.m_aTableBoundColor
232
108
            && m_aFontColor == rOther.m_aFontColor
233
108
            && m_aIndexShadingsColor == rOther.m_aIndexShadingsColor
234
108
            && m_aLinksColor == rOther.m_aLinksColor
235
108
            && m_aVisitedLinksColor == rOther.m_aVisitedLinksColor
236
108
            && m_aTextGridColor == rOther.m_aTextGridColor
237
108
            && m_aBaselineGridColor == rOther.m_aBaselineGridColor
238
108
            && m_aSpellColor == rOther.m_aSpellColor
239
108
            && m_aGrammarColor == rOther.m_aGrammarColor
240
108
            && m_aSmarttagColor == rOther.m_aSmarttagColor
241
108
            && m_aFieldShadingsColor == rOther.m_aFieldShadingsColor
242
108
            && m_aSectionBoundColor == rOther.m_aSectionBoundColor
243
108
            && m_aPageBreakColor == rOther.m_aPageBreakColor
244
108
            && m_aNonPrintingCharacterColor == rOther.m_aNonPrintingCharacterColor
245
108
            && m_aShadowColor == rOther.m_aShadowColor
246
108
            && m_aHeaderFooterMarkColor == rOther.m_aHeaderFooterMarkColor
247
108
            && m_nAppearanceFlags == rOther.m_nAppearanceFlags;
248
108
    }
249
    Color m_aDocColor;  // color of document boundaries
250
    Color m_aDocBoundColor;  // color of document boundaries
251
    Color m_aAppBackgroundColor; // application background
252
    Color m_aTableBoundColor; // color of table boundaries
253
    Color m_aFontColor;
254
    Color m_aIndexShadingsColor; // background color of indexes
255
    Color m_aLinksColor;
256
    Color m_aVisitedLinksColor;
257
    Color m_aTextGridColor;
258
    Color m_aBaselineGridColor;
259
    Color m_aSpellColor;     // mark color of online spell checking
260
    Color m_aGrammarColor;
261
    Color m_aSmarttagColor;
262
    Color m_aFieldShadingsColor;
263
    Color m_aSectionBoundColor;
264
    Color m_aPageBreakColor;
265
    Color m_aNonPrintingCharacterColor;
266
    Color m_aShadowColor;
267
    Color m_aHeaderFooterMarkColor;
268
    ViewOptFlags m_nAppearanceFlags;
269
};
270
271
/// View option to determine if some of the redlines should be omitted during rendering or not.
272
///
273
/// This is exposed on the LOK API, don't reorder the names.
274
enum class SwRedlineRenderMode
275
{
276
    /// Normal rendering.
277
    Standard,
278
    /// Special handling of inserts to ~omit them / paint with small saturation.
279
    OmitInserts,
280
    /// Special handling of deletes to ~omit them / paint with small saturation.
281
    OmitDeletes,
282
};
283
284
class SwViewOption
285
{
286
    SwViewColors m_aColorConfig;
287
    static SwViewColors s_aInitialColorConfig;
288
    OUString m_sThemeName;
289
290
    OUString          m_sSymbolFont;                // Symbolfont.
291
    ViewOptFlags1     m_nCoreOptions;               // Bits for SwViewShell.
292
    ViewOptCoreFlags2 m_nCore2Options;              // Bits for SwViewShell.
293
    ViewOptFlags2     m_nUIOptions;                 // UI-Bits
294
    Color             m_aRetouchColor;              // DefaultBackground for BrowseView
295
    Size              m_aSnapSize;                  // Describes horizontal and vertical snap.
296
    sal_uInt16        mnViewLayoutColumns;          // # columns for edit view
297
    short             m_nDivisionX;                 // Grid division.
298
    short             m_nDivisionY;
299
    sal_uInt8         m_nPagePreviewRow;            // Page Preview Row/Columns.
300
    sal_uInt8         m_nPagePreviewCol;            // Page Preview Row/Columns.
301
    SwFillMode        m_nShadowCursorFillMode;      // FillMode for ShadowCursor.
302
    SwRedlineRenderMode m_eRedlineRenderMode;
303
    bool              m_bReadonly : 1;              // Readonly-Doc.
304
    bool              m_bStarOneSetting : 1;        // Prevent from UI automatics (no scrollbars in readonly documents).
305
    bool              m_bIsPagePreview : 1;         // The preview mustn't print field/footnote/... shadings.
306
    bool              m_bSelectionInReadonly : 1;   // Determines whether selection is switched on in readonly documents.
307
    bool              mbFormView : 1;
308
    bool              mbBrowseMode : 1;
309
    bool              mbDraftView : 1;              // Draft View
310
    bool              mbBookView : 1;               // View mode for page preview.
311
    bool              mbViewLayoutBookMode : 1;     // Book view mode for edit view.
312
    bool              mbHideWhitespaceMode : 1;     // Hide header, footer, and pagebreak.
313
    bool              m_bShowPlaceHolderFields : 1; // Only used in printing!
314
    bool              m_bEncloseWithCharactersOn : 1;
315
    mutable bool      m_bIdle;
316
    sal_Int32         m_nDefaultAnchor;             // GetDefaultAnchorType() to convert int to RndStdIds
317
    // tdf#135266 - tox dialog: remember last used entry level depending on the index type
318
    sal_uInt8         m_nTocEntryLvl;
319
    sal_uInt8         m_nIdxEntryLvl;
320
321
    // Scale
322
    sal_uInt16        m_nZoom;                     // In percent.
323
    SvxZoomType       m_eZoom;                     // 'enum' for zoom.
324
325
    sal_uInt8         m_nTableDestination;         // Destination for table background.
326
327
#ifdef DBG_UTIL
328
    // Corresponds to statements in ui/config/cfgvw.src.
329
    bool  m_bTest1        :1;     // Test-flag  "Layout not loading"
330
    bool  m_bTest2        :1;     // Test-flag  "WYSIWYG++"
331
    bool  m_bTest3        :1;     // Test-flag  ""
332
    bool  m_bTest4        :1;     // Test-flag  "WYSIWYG debug"
333
    bool  m_bTest5        :1;     // Test-flag  "No idle format"
334
    bool  m_bTest6        :1;     // Test-flag  "No screen adj"
335
    bool  m_bTest7        :1;     // Test-flag  "win format"
336
    bool  m_bTest8        :1;     // Test-flag  ""
337
    bool  m_bTest10       :1;     // Test-Flag  "Format by Input"
338
#endif
339
340
public:
341
    SW_DLLPUBLIC SwViewOption();                     // CTOR
342
    SW_DLLPUBLIC SwViewOption(const SwViewOption&);
343
    SW_DLLPUBLIC ~SwViewOption();
344
345
    inline void     SetUIOptions( const SwViewOption& );
346
347
    void SetColorConfig(const SwViewColors& rColorConfig)
348
0
    {
349
0
        m_aColorConfig = rColorConfig;
350
0
    }
351
352
    const SwViewColors& GetColorConfig() const
353
0
    {
354
0
        return m_aColorConfig;
355
0
    }
356
357
    void SetThemeName(const OUString& rThemeName)
358
0
    {
359
0
        m_sThemeName = rThemeName;
360
0
    }
361
362
    const OUString & GetThemeName() const
363
8.38k
    {
364
8.38k
        return m_sThemeName;
365
8.38k
    }
366
367
    static void SetInitialColorConfig(const SwViewColors& rColorConfig)
368
1
    {
369
1
        s_aInitialColorConfig = rColorConfig;
370
1
    }
371
372
    // Options from nCoreOptions
373
    bool IsIdle() const
374
0
        { return m_bIdle; }
375
376
    // Logically this is a const function since it does not modify the viewoptions
377
    // but only effects idle formatting. Of course that member is already implement
378
    // in the wrong place here... Also currently there are many const modifying casts in the code
379
    // just to call this function on otherwise const objects. Thus declaring it as const now.
380
    void SetIdle( bool b ) const
381
108
    { m_bIdle = b; }
382
383
    bool IsTab(bool bHard = false) const
384
0
    {
385
0
        return !m_bReadonly && m_nCoreOptions.bTab && (m_nCoreOptions.bViewMetachars || bHard);
386
0
    }
387
    void SetTab( bool b )
388
4.01k
    {
389
4.01k
        m_nCoreOptions.bTab = b;
390
4.01k
    }
391
392
    bool IsBlank(bool bHard = false) const
393
0
    {
394
0
        return !m_bReadonly && m_nCoreOptions.bBlank && (m_nCoreOptions.bViewMetachars || bHard);
395
0
    }
396
    void SetBlank(bool b)
397
4.01k
    {
398
4.01k
        m_nCoreOptions.bBlank = b;
399
4.01k
    }
400
401
    bool IsHardBlank() const
402
5.53k
    {
403
5.53k
        return !m_bReadonly && (m_nCoreOptions.bHardBlank);
404
5.53k
    }
405
    void SetHardBlank( bool b )
406
4.01k
    {
407
4.01k
        m_nCoreOptions.bHardBlank = b;
408
4.01k
    }
409
410
    bool IsParagraph(bool bHard = false) const
411
989k
    {
412
989k
        return !m_bReadonly && m_nCoreOptions.bParagraph &&
413
0
                            (m_nCoreOptions.bViewMetachars || bHard);
414
989k
    }
415
    void SetParagraph( bool b )
416
4.01k
    {
417
4.01k
        m_nCoreOptions.bParagraph = b;
418
4.01k
    }
419
420
    void SetShowBookmarks(bool const b)
421
4.01k
    {
422
4.01k
        m_nCoreOptions.bBookmarks = b;
423
4.01k
    }
424
    bool IsShowBookmarks(bool const bHard = false) const
425
45
    {
426
45
        return !m_bReadonly && (m_nCoreOptions.bBookmarks)
427
0
                && (bHard || IsFieldShadings());
428
45
    }
429
430
    bool IsLineBreak(bool bHard = false) const
431
630k
    {
432
630k
        return !m_bReadonly && (m_nCoreOptions.bLinebreak) &&
433
0
                            ((m_nCoreOptions.bViewMetachars) || bHard);
434
630k
    }
435
    void SetLineBreak( bool b )
436
4.01k
    {
437
4.01k
        m_nCoreOptions.bLinebreak = b;
438
4.01k
    }
439
440
    void SetPageBreak( bool b )
441
4.01k
    {
442
4.01k
        m_nCoreOptions.bPagebreak = b;
443
4.01k
    }
444
445
    void SetColumnBreak( bool b)
446
4.01k
    {
447
4.01k
        m_nCoreOptions.bColumnbreak = b;
448
4.01k
    }
449
450
    bool IsSoftHyph() const
451
0
    { return !m_bReadonly && (m_nCoreOptions.bSoftHyph); }
452
453
    void SetSoftHyph( bool b )
454
4.01k
    {
455
4.01k
        m_nCoreOptions.bSoftHyph = b;
456
4.01k
    }
457
458
    bool IsFieldName() const
459
28.6k
    { return !m_bReadonly && (m_nCoreOptions.bFieldName); }
460
461
    void SetFieldName( bool b )
462
665
    {
463
665
        m_nCoreOptions.bFieldName = b;
464
665
    }
465
466
    bool IsPostIts() const
467
4.31M
    {
468
4.31M
        return m_nCoreOptions.bPostits;
469
4.31M
    }
470
471
    void SetPostIts( bool b )
472
0
    {
473
0
        m_nCoreOptions.bPostits = b;
474
0
    }
475
476
    bool IsResolvedPostIts() const
477
0
    { return bool(m_nUIOptions & ViewOptFlags2::ResolvedPostits); }
478
479
    void SetResolvedPostIts( bool b )
480
0
    { SetUIOption(b, ViewOptFlags2::ResolvedPostits); }
481
482
    static void PaintPostIts( OutputDevice *pOut, const SwRect &rRect,
483
                              bool bIsScript );
484
    static SwTwips GetPostItsWidth(const OutputDevice* pOut);
485
486
    //show/hide tooltips on tracked changes
487
    bool IsShowInlineTooltips() const
488
0
    {
489
0
        return m_nCoreOptions.bShowInlineTooltips;
490
0
    }
491
492
    void SetShowInlineTooltips( bool b )
493
0
    { m_nCoreOptions.bShowInlineTooltips = b; }
494
495
    //show/hide tracked deletions in text
496
    bool IsShowChangesInMargin() const
497
95.2k
    {
498
95.2k
        return m_nCoreOptions.bShowChangesInMargin;
499
95.2k
    }
500
501
    void SetShowChangesInMargin( bool b )
502
0
    {
503
0
        m_nCoreOptions.bShowChangesInMargin = b;
504
0
    }
505
506
    //show/hide tracked insertions in text
507
    bool IsShowChangesInMargin2() const
508
16.7k
    { return m_nCoreOptions.bShowChangesInMargin2; }
509
510
    void SetShowChangesInMargin2( bool b )
511
0
    { m_nCoreOptions.bShowChangesInMargin2 = b; }
512
513
    //show/hide interactive header/footer on top/bottom of pages
514
    bool IsUseHeaderFooterMenu() const
515
0
    { return m_nCoreOptions.bUseHeaderFooterMenu; }
516
    void SetUseHeaderFooterMenu( bool b )
517
0
    { m_nCoreOptions.bUseHeaderFooterMenu = b; }
518
519
    //show/hide outline content visibility button
520
    SW_DLLPUBLIC bool IsShowOutlineContentVisibilityButton() const;
521
    void SetShowOutlineContentVisibilityButton(bool b)
522
0
    { m_nCoreOptions.bShowOutlineContentVisibilityButton = b; }
523
524
    bool IsTreatSubOutlineLevelsAsContent() const;
525
    void SetTreatSubOutlineLevelsAsContent(bool b)
526
0
    { m_nCoreOptions.bTreatSubOutlineLevelsAsContent = b; }
527
528
    bool IsShowHiddenChar(bool bHard = false) const
529
3.73M
    { return !m_bReadonly && m_nCoreOptions.bCharHidden &&
530
0
                            (m_nCoreOptions.bViewMetachars || bHard); }
531
532
    void SetShowHiddenChar( bool b )
533
1
    { m_nCoreOptions.bCharHidden = b; }
534
535
    bool IsShowHiddenField() const
536
77.6k
    { return !m_bReadonly && m_nCoreOptions.bFieldHidden; }
537
    void SetShowHiddenField( bool b )
538
0
    { m_nCoreOptions.bFieldHidden = b; }
539
540
    bool IsGraphic() const
541
5.65k
    { return m_nCoreOptions.bGraphic; }
542
    void SetGraphic( bool b )
543
56.8k
    { m_nCoreOptions.bGraphic = b; }
544
545
    bool IsPageBack() const
546
455k
    { return m_nCoreOptions.bPageback; }
547
    void SetPageBack( bool b )
548
56.8k
    { m_nCoreOptions.bPageback = b; }
549
550
    bool IsTable() const
551
5.16k
    { return m_nCoreOptions.bTable; }
552
    void SetTable( bool b )
553
0
    { m_nCoreOptions.bTable = b; }
554
555
    bool IsDraw() const
556
4.68k
    { return m_nCoreOptions.bDraw; }
557
    void SetDraw( bool b )
558
56.8k
    { m_nCoreOptions.bDraw = b; }
559
560
    bool IsControl() const
561
0
    { return m_nCoreOptions.bControl; }
562
    void SetControl( bool b )
563
56.8k
    { m_nCoreOptions.bControl = b; }
564
565
    bool IsSnap() const
566
69.2k
    { return m_nCoreOptions.bSnap; }
567
    void SetSnap( bool b )
568
0
    { m_nCoreOptions.bSnap = b; }
569
570
10
    void SetSnapSize( Size const &rSz ){ m_aSnapSize = rSz; }
571
69.2k
    const Size &GetSnapSize() const { return m_aSnapSize; }
572
573
    bool IsGridVisible() const
574
130k
    { return !m_bReadonly && m_nCoreOptions.bGridVisible; }
575
    void SetGridVisible( bool b )
576
0
    { m_nCoreOptions.bGridVisible = b; }
577
578
    bool IsBaselineGridVisible() const
579
56.8k
    {
580
56.8k
        return m_nCoreOptions.bBaselineGridVisible;
581
56.8k
    }
582
    void SetBaselineGridVisible( bool bVisible )
583
0
    {
584
0
        m_nCoreOptions.bBaselineGridVisible = bVisible;
585
0
    }
586
587
    bool IsOnlineSpell() const
588
29.1k
    {
589
29.1k
        return m_nCoreOptions.bOnlineSpell;
590
29.1k
    }
591
    void SetOnlineSpell( bool b )
592
4.01k
    {
593
4.01k
        m_nCoreOptions.bOnlineSpell = b;
594
4.01k
    }
595
596
    bool IsViewMetaChars() const
597
14.0k
    { return !m_bReadonly && m_nCoreOptions.bViewMetachars; }
598
    void SetViewMetaChars( bool b)
599
4.01k
    { m_nCoreOptions.bViewMetachars = b; }
600
601
601k
    bool IsRedlineRecordingOn() const { return m_nCoreOptions.bRedlineRecordingOn; }
602
603
4.01k
    void SetRedlineRecordingOn(bool b) { m_nCoreOptions.bRedlineRecordingOn = b; }
604
605
    bool IsSynchronize() const
606
0
    {  return m_nCoreOptions.bSynchronize; }
607
    void SetSynchronize( bool b )
608
0
    { m_nCoreOptions.bSynchronize = b; }
609
610
    bool IsCrossHair() const
611
69.2k
    { return m_nCoreOptions.bCrosshair; }
612
    void SetCrossHair( bool b )
613
0
    { m_nCoreOptions.bCrosshair = b; }
614
615
    // Options from nCore2Options
616
    bool IsBlackFont() const
617
350k
        {return bool(m_nCore2Options & ViewOptCoreFlags2::BlackFont); }
618
619
    void SetBlackFont(bool b)
620
56.8k
        { SetCore2Option(b, ViewOptCoreFlags2::BlackFont); }
621
622
    bool IsShowHiddenPara() const
623
16.7k
        {return bool(m_nCore2Options & ViewOptCoreFlags2::HiddenPara); }
624
625
    void SetShowHiddenPara(bool b)
626
0
        { SetCore2Option(b, ViewOptCoreFlags2::HiddenPara); }
627
628
    bool IsSmoothScroll() const
629
0
        {return bool(m_nCore2Options & ViewOptCoreFlags2::SmoothScroll); }
630
631
    void SetSmoothScroll(bool b)
632
0
        { SetCore2Option(b, ViewOptCoreFlags2::SmoothScroll); }
633
634
    bool IsCursorInProtectedArea() const
635
4.01k
        {return bool(m_nCore2Options & ViewOptCoreFlags2::CursorInProt); }
636
637
    void SetCursorInProtectedArea(bool b)
638
0
        { SetCore2Option(b, ViewOptCoreFlags2::CursorInProt); }
639
640
    static bool IsIgnoreProtectedArea();
641
642
    static bool IsAllowDragDropText();
643
644
    static bool IsTypingReplacesSelection();
645
646
    bool IsPDFExport() const
647
2.31M
        {return bool(m_nCore2Options & ViewOptCoreFlags2::PdfExport); }
648
649
    void SetPDFExport(bool b)
650
121k
        { SetCore2Option(b, ViewOptCoreFlags2::PdfExport); }
651
652
    bool IsPrinting() const
653
94
        {return bool(m_nCore2Options & ViewOptCoreFlags2::Printing); }
654
655
    void SetPrinting(bool b)
656
4.01k
        { SetCore2Option(b, ViewOptCoreFlags2::Printing); }
657
658
    void SetCore2Option(bool b, ViewOptCoreFlags2 f)
659
182k
    {
660
182k
        if (b)
661
60.9k
            m_nCore2Options |= f;
662
121k
        else
663
121k
            m_nCore2Options &= ~f;
664
182k
    }
665
666
138k
    short GetDivisionX() const   { return m_nDivisionX; }
667
0
    void  SetDivisionX( short n ){ m_nDivisionX = n; }
668
138k
    short GetDivisionY() const   { return m_nDivisionY; }
669
0
    void  SetDivisionY( short n ){ m_nDivisionY = n; }
670
671
    // Default margin left and above document: 284 twips == 5.0 mm.
672
    static constexpr sal_uInt16 defDocumentBorder = 284;
673
    // Default gap between pages: 284 twips == 5.0 mm.
674
    static constexpr sal_uInt16 defGapBetweenPages = 284;
675
    // Minimum edge-to-text distance: 22 twips == 0.4 mm.
676
    static constexpr sal_uInt16 minGapBetweenPages = 22;
677
678
0
    sal_uInt16 GetDocumentBorder() const { return IsWhitespaceHidden() ? minGapBetweenPages : defDocumentBorder; }
679
75.4k
    sal_uInt16 GetGapBetweenPages() const { return IsWhitespaceHidden() ? minGapBetweenPages : defGapBetweenPages; }
680
681
447
    sal_uInt8  GetPagePrevRow() const      { return m_nPagePreviewRow; }
682
0
    void  SetPagePrevRow( sal_uInt8 n ) { m_nPagePreviewRow = n; }
683
447
    sal_uInt8  GetPagePrevCol() const      { return m_nPagePreviewCol; }
684
0
    void  SetPagePrevCol( sal_uInt8 n ) { m_nPagePreviewCol = n; }
685
139k
    bool         IsReadonly() const { return m_bReadonly; }
686
4.35k
    void         SetReadonly(bool bSet) { m_bReadonly = bSet; }
687
688
0
    bool         IsSelectionInReadonly() const {return m_bSelectionInReadonly;}
689
0
    void         SetSelectionInReadonly(bool bSet) {m_bSelectionInReadonly = bSet;}
690
691
84.4k
    bool         IsFormView() const { return mbFormView; }
692
0
    void         SetFormView( bool bSet ) { mbFormView = bSet; }
693
694
51.9M
    bool  getBrowseMode() const { return mbBrowseMode; }
695
4.22k
    void  setBrowseMode(bool bSet) { mbBrowseMode = bSet; }
696
82.2k
    bool  getDraftView() const { return mbDraftView; }
697
4.12k
    void  setDraftView(bool bSet) { mbDraftView = bSet; }
698
0
    bool  IsPagePrevBookview() const { return mbBookView; }
699
0
    void  SetPagePrevBookview(bool bSet) { mbBookView = bSet; }
700
701
    static bool IsAutoCompleteWords();
702
703
15.4M
    bool   IsViewLayoutBookMode() const { return mbViewLayoutBookMode; }
704
19
    void   SetViewLayoutBookMode( bool bNew ) { mbViewLayoutBookMode = bNew; }
705
40.4k
    sal_uInt16 GetViewLayoutColumns() const { return mnViewLayoutColumns; }
706
19
    void   SetViewLayoutColumns( sal_uInt16 nNew ) { mnViewLayoutColumns = nNew; }
707
465k
    bool   IsHideWhitespaceMode() const { return mbHideWhitespaceMode; }
708
0
    void   SetHideWhitespaceMode( bool bMode ) { mbHideWhitespaceMode = bMode; }
709
710
    /// The rules that allow for hiding whitespace.
711
19
    bool   CanHideWhitespace() const { return !IsMultipageView(); }
712
401k
    bool   IsWhitespaceHidden() const { return IsHideWhitespaceMode() && !IsMultipageView(); }
713
19
    bool   IsMultipageView() const { return IsViewLayoutBookMode() ||
714
19
                                            GetViewLayoutColumns() == 0; }
715
716
3
    bool IsTextBoundaries() const { return m_nCoreOptions.bTextBoundaries; }
717
0
    void SetTextBoundaries( bool b) { m_nCoreOptions.bTextBoundaries = b; }
718
719
3
    bool IsTextBoundariesFull() const { return m_nCoreOptions.bTextBoundariesFull; }
720
0
    void SetTextBoundariesFull( bool b) { m_nCoreOptions.bTextBoundariesFull = b; }
721
722
0
    bool IsSectionBoundaries() const { return m_nCoreOptions.bSectionBoundaries; }
723
0
    void SetSectionBoundaries( bool b) { m_nCoreOptions.bSectionBoundaries = b; }
724
725
844
    bool IsTableBoundaries() const { return m_nCoreOptions.bTableBoundaries; }
726
0
    void SetTableBoundaries( bool b) { m_nCoreOptions.bTableBoundaries = b; }
727
728
850
    bool IsShowBoundaries() const { return m_nCoreOptions.bShowBoundaries; }
729
0
    void SetShowBoundaries( bool b ) { m_nCoreOptions.bShowBoundaries = b; }
730
731
0
    bool IsClickChangeRotation() const { return m_nCoreOptions.bClickChangeRotation; }
732
0
    void SetClickChangeRotation( bool b ) { m_nCoreOptions.bClickChangeRotation = b; }
733
734
#ifdef DBG_UTIL
735
    // Correspond to statements in ui/config/cfgvw.src.
736
    bool IsTest1() const     { return m_bTest1; }
737
    bool IsTest2() const     { return m_bTest2; }
738
    bool IsTest3() const     { return m_bTest3; }
739
    bool IsTest4() const     { return m_bTest4; }
740
    bool IsTest5() const     { return m_bTest5; }
741
    bool IsTest6() const     { return m_bTest6; }
742
    bool IsTest7() const     { return m_bTest7; }
743
    bool IsTest8() const     { return m_bTest8; }
744
    bool IsTest10() const    { return m_bTest10; }
745
#endif
746
747
9.16M
    sal_uInt16 GetZoom() const    { return m_nZoom; }
748
231
    void   SetZoom( sal_uInt16 n ){ m_nZoom = n; }
749
750
    static void DrawRect( OutputDevice* pOut, const SwRect &rRect, ::Color nCol );
751
    static void DrawRectPrinter( OutputDevice* pOut, const SwRect& rRect );
752
753
    SwViewOption& operator=( const SwViewOption &rOpt );
754
755
    // Compare methods.
756
    bool IsEqualFlags ( const SwViewOption &rOpt ) const;
757
    inline bool operator == ( const SwViewOption &rOpt ) const;
758
4.01k
    bool operator != ( const SwViewOption &rOpt ) const  { return !(*this == rOpt); }
759
760
    // Options from nUIOptions
761
    bool    IsViewVScrollBar() const
762
4.22k
        {
763
#if HAVE_FEATURE_DESKTOP
764
            return bool(m_nUIOptions & ViewOptFlags2::VScrollbar);
765
#else
766
4.22k
            return false;
767
4.22k
#endif
768
4.22k
        }
769
    bool    IsViewHScrollBar() const
770
4.22k
        {
771
#if HAVE_FEATURE_DESKTOP
772
            return bool(m_nUIOptions & ViewOptFlags2::HScrollbar);
773
#else
774
4.22k
            return false;
775
4.22k
#endif
776
4.22k
        }
777
    bool    IsKeepRatio()      const
778
11.2k
        { return bool(m_nUIOptions & ViewOptFlags2::KeepAspectRatio); }
779
    bool    IsGrfKeepZoom()    const
780
0
        { return bool(m_nUIOptions & ViewOptFlags2::GrfKeepZoom); }
781
    bool    IsShowContentTips() const
782
0
        { return bool(m_nUIOptions & ViewOptFlags2::ContentTips); }
783
    bool    IsPrtFormat() const
784
8.18k
        { return bool(m_nUIOptions & ViewOptFlags2::PrintFormat); }
785
    bool    IsShowScrollBarTips() const
786
0
        { return bool(m_nUIOptions & ViewOptFlags2::ScrollbarTips); }
787
788
12.7k
    SvxZoomType    GetZoomType()      const { return m_eZoom; }
789
790
0
    sal_uInt8   GetTableDest() const    { return m_nTableDestination; }
791
792
    void   SetViewVScrollBar(bool b)
793
0
        { SetUIOption(b, ViewOptFlags2::VScrollbar); }
794
    void   SetViewHScrollBar(bool b)
795
0
        { SetUIOption(b, ViewOptFlags2::HScrollbar); }
796
    void   SetKeepRatio     (bool b)
797
0
        { SetUIOption(b, ViewOptFlags2::KeepAspectRatio); }
798
    void   SetGrfKeepZoom   (bool b)
799
0
        { SetUIOption(b, ViewOptFlags2::GrfKeepZoom); }
800
    void SetShowContentTips( bool b)
801
0
        { SetUIOption(b, ViewOptFlags2::ContentTips); }
802
    void SetPrtFormat( bool b)
803
0
        { SetUIOption(b, ViewOptFlags2::PrintFormat); }
804
    void SetShowScrollBarTips( bool b)
805
0
        { SetUIOption(b, ViewOptFlags2::ScrollbarTips); }
806
    void SetUIOption( bool b, ViewOptFlags2 f)
807
0
    {
808
0
        if (b)
809
0
            m_nUIOptions |= f;
810
0
        else
811
0
            m_nUIOptions &= ~f;
812
0
    }
813
814
606
    void            SetZoomType     (SvxZoomType eZoom_){ m_eZoom = eZoom_;  }
815
0
    void            SetTableDest( sal_uInt8 nNew )    { m_nTableDestination = nNew;  }
816
817
4.12k
    const OUString& GetSymbolFont() const {return m_sSymbolFont;}
818
4.12k
    void            SetSymbolFont(const OUString& sSet) {m_sSymbolFont = sSet;}
819
820
82.4k
    const Color&    GetRetoucheColor() const        { return m_aRetouchColor;}
821
0
    void            SetRetoucheColor(const Color&r) { m_aRetouchColor = r;   }
822
823
    bool        IsViewAnyRuler() const
824
0
        {
825
#if HAVE_FEATURE_DESKTOP
826
            return bool(m_nUIOptions & ViewOptFlags2::AnyRuler);
827
#else
828
0
            return false;
829
0
#endif
830
0
        }
831
    void            SetViewAnyRuler(bool bSet)
832
0
                        { SetUIOption(bSet, ViewOptFlags2::AnyRuler);}
833
834
    bool        IsViewHRuler(bool bDirect = false)     const
835
4.12k
                        {
836
#if HAVE_FEATURE_DESKTOP
837
                            return bDirect
838
                                   ? bool(m_nUIOptions & ViewOptFlags2::HRuler)
839
                                   : !m_bReadonly && (m_nUIOptions & (ViewOptFlags2::AnyRuler|ViewOptFlags2::HRuler)) == (ViewOptFlags2::AnyRuler|ViewOptFlags2::HRuler);
840
#else
841
4.12k
                            (void) bDirect;
842
4.12k
                            return false;
843
4.12k
#endif
844
4.12k
                        }
845
    void            SetViewHRuler   (bool b)
846
0
                        { SetUIOption(b, ViewOptFlags2::HRuler ); }
847
848
    bool            IsViewVRuler(bool bDirect = false) const
849
4.12k
                        {
850
#if HAVE_FEATURE_DESKTOP
851
                            return bDirect
852
                                   ? bool(m_nUIOptions & ViewOptFlags2::VRuler)
853
                                   : !m_bReadonly && (m_nUIOptions & (ViewOptFlags2::AnyRuler|ViewOptFlags2::VRuler)) == (ViewOptFlags2::AnyRuler|ViewOptFlags2::VRuler);
854
#else
855
4.12k
                            (void) bDirect;
856
4.12k
                            return false;
857
4.12k
#endif
858
4.12k
                        }
859
    void            SetViewVRuler     (bool b)
860
0
                        { SetUIOption(b, ViewOptFlags2::VRuler); }
861
862
    // ShadowCursor, switch on/off, get/set color/mode.
863
    bool    IsShadowCursor()    const
864
0
        { return bool(m_nUIOptions & ViewOptFlags2::ShadowCursor); }
865
    void   SetShadowCursor(bool b)
866
0
        { SetUIOption(b, ViewOptFlags2::ShadowCursor); }
867
868
    // Enclose with characters autocomplete, switch on/off
869
0
    bool IsEncloseWithCharactersOn() const { return m_bEncloseWithCharactersOn; }
870
0
    void SetEncloseWithCharactersOn(bool b) { m_bEncloseWithCharactersOn = b; }
871
872
    static bool IsEncloseWithCharactersTrigger(sal_Unicode cChar)
873
0
    {
874
0
        switch (cChar)
875
0
        {
876
0
            case '(':  [[fallthrough]];
877
0
            case '{':  [[fallthrough]];
878
0
            case '[':  [[fallthrough]];
879
0
            case '\'': [[fallthrough]];
880
0
            case '\"':
881
0
                return true;
882
0
            default:
883
0
                return false;
884
0
        }
885
0
    }
886
887
    //move vertical ruler to the right
888
    bool    IsVRulerRight()    const
889
216
        { return bool(m_nUIOptions & ViewOptFlags2::VRulerRight); }
890
    void   SetVRulerRight(bool b)
891
0
        { SetUIOption(b, ViewOptFlags2::VRulerRight); }
892
893
4.12k
    bool            IsStarOneSetting() const {return m_bStarOneSetting; }
894
216
    void            SetStarOneSetting(bool bSet) {m_bStarOneSetting = bSet; }
895
896
928
    bool            IsPagePreview() const {return m_bIsPagePreview; }
897
0
    void            SetPagePreview(bool bSet) { m_bIsPagePreview= bSet; }
898
899
0
    SwFillMode      GetShdwCursorFillMode() const { return m_nShadowCursorFillMode; }
900
0
    void            SetShdwCursorFillMode( SwFillMode nMode ) { m_nShadowCursorFillMode = nMode; };
901
902
352k
    SwRedlineRenderMode GetRedlineRenderMode() const { return m_eRedlineRenderMode; }
903
0
    void SetRedlineRenderMode(SwRedlineRenderMode eMode) { m_eRedlineRenderMode = eMode; };
904
905
0
    bool        IsShowPlaceHolderFields() const { return m_bShowPlaceHolderFields; }
906
0
    void            SetShowPlaceHolderFields(bool bSet) { m_bShowPlaceHolderFields = bSet; }
907
908
    SW_DLLPUBLIC const Color& GetDocColor() const;
909
    SW_DLLPUBLIC const Color& GetDocBoundariesColor() const;
910
    const Color& GetAppBackgroundColor() const;
911
    const Color& GetTableBoundariesColor() const;
912
    const Color& GetIndexShadingsColor() const;
913
    const Color& GetLinksColor() const;
914
    const Color& GetVisitedLinksColor() const;
915
    const Color& GetTextGridColor() const;
916
    const Color& GetBaselineGridColor() const;
917
    const Color& GetSpellColor() const;
918
    const Color& GetGrammarColor() const;
919
    const Color& GetSmarttagColor() const;
920
    const Color& GetShadowColor() const;
921
    SW_DLLPUBLIC const Color& GetFontColor() const;
922
    const Color& GetFieldShadingsColor() const;
923
    const Color& GetSectionBoundColor() const;
924
    const Color& GetPageBreakColor() const;
925
    const Color& GetNonPrintingCharacterColor() const;
926
    const Color& GetHeaderFooterMarkColor() const;
927
928
    bool IsAppearanceFlag(ViewOptFlags nFlag) const;
929
930
54
    bool IsIndexShadings() const {return IsAppearanceFlag(ViewOptFlags::IndexShadings);}
931
21
    bool IsLinks() const {return IsAppearanceFlag(ViewOptFlags::Links);}
932
0
    bool IsVisitedLinks() const {return IsAppearanceFlag(ViewOptFlags::VisitedLinks);}
933
0
    bool IsFieldShadings() const {return IsAppearanceFlag(ViewOptFlags::FieldShadings);}
934
3
    bool IsShadow() const {return IsAppearanceFlag(ViewOptFlags::Shadow);}
935
936
    void     SetAppearanceFlag(ViewOptFlags nFlag, bool bSet, bool bSaveInConfig = false);
937
938
    // get/set default anchor (0..2); use GetDefaultAnchorType() to convert into RndStdIds::FLY_*
939
    sal_Int32 GetDefaultAnchor() const
940
0
        {   return m_nDefaultAnchor; }
941
    void SetDefaultAnchor( const sal_Int32 aFlag )
942
0
        { m_nDefaultAnchor = aFlag; }
943
944
    RndStdIds GetDefaultAnchorType() const;
945
946
    // tdf#135266 - tox dialog: remember last used entry level depending on the index type
947
0
    sal_uInt8 GetTocEntryLvl() const { return m_nTocEntryLvl; }
948
0
    void SetTocEntryLvl(sal_uInt8 n) { m_nTocEntryLvl = n; }
949
0
    sal_uInt8 GetIdxEntryLvl() const { return m_nIdxEntryLvl; }
950
0
    void SetIdxEntryLvl(sal_uInt8 n) { m_nIdxEntryLvl = n; }
951
952
    void dumpAsXml(xmlTextWriterPtr pWriter) const;
953
954
    // Useful for when getting the current view SwViewOption is not possible otherwise
955
    SW_DLLPUBLIC static const SwViewOption& GetCurrentViewOptions();
956
957
    void SyncLayoutRelatedViewOptions(const SwViewOption& rOpt);
958
};
959
960
inline bool SwViewOption::operator==( const SwViewOption &rOpt ) const
961
12.5k
{
962
12.5k
    return IsEqualFlags( rOpt ) && m_nZoom == rOpt.GetZoom() && m_aColorConfig == rOpt.m_aColorConfig;
963
12.5k
}
964
965
inline void SwViewOption::SetUIOptions( const SwViewOption& rVOpt )
966
12.5k
{
967
12.5k
    m_nUIOptions = rVOpt.m_nUIOptions;
968
12.5k
    m_nTableDestination = rVOpt.m_nTableDestination;
969
12.5k
    m_nShadowCursorFillMode = rVOpt.m_nShadowCursorFillMode;
970
12.5k
    m_bEncloseWithCharactersOn = rVOpt.m_bEncloseWithCharactersOn;
971
12.5k
}
972
973
// Helper function for checking HTML-capabilities.
974
SW_DLLPUBLIC sal_uInt16     GetHtmlMode(const SwDocShell*);
975
976
#endif
977
978
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */