Coverage Report

Created: 2025-11-16 09:57

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