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
ViewOptFlags1ViewOptFlags183 ViewOptFlags1()
84 : bUseHeaderFooterMenu(false)
85 , bTab(false)
86 , bBlank(false)
87 , bHardBlank(true)
88 , bParagraph(false)
89 , bLinebreak(false)
90 , bPagebreak(false)
91 , bColumnbreak(false)
92 , bSoftHyph(true)
93 , bBookmarks(false)
94 , bRef(true)
95 , bFieldName(false)
96 , bPostits(true)
97 , bFieldHidden(false)
98 , bCharHidden(false)
99 , bGraphic(true)
100 , bTable(true)
101 , bDraw(true)
102 , bControl(true)
103 , bCrosshair(false)
104 , bSnap(false)
105 , bSynchronize(false)
106 , bGridVisible(false)
107 , bOnlineSpell(false)
108 , bTreatSubOutlineLevelsAsContent(false)
109 , bShowInlineTooltips(false)
110 , bViewMetachars(false)
111 , bRedlineRecordingOn(false)
112 , bPageback(true)
113 , bShowOutlineContentVisibilityButton(false)
114 , bShowChangesInMargin(false)
115 , bShowChangesInMargin2(false)
116 , bTextBoundaries(true)
117 , bTextBoundariesFull(false)
118 , bSectionBoundaries(true)
119 , bTableBoundaries(true)
120 , bShowBoundaries(true)
121 , bClickChangeRotation(false)
122 {}
123
operator ==ViewOptFlags1124 bool operator==(const ViewOptFlags1& rOther) const
125 {
126 return bUseHeaderFooterMenu == rOther.bUseHeaderFooterMenu
127 && bTab == rOther.bTab
128 && bBlank == rOther.bBlank
129 && bHardBlank == rOther.bHardBlank
130 && bParagraph == rOther.bParagraph
131 && bLinebreak == rOther.bLinebreak
132 && bPagebreak == rOther.bPagebreak
133 && bColumnbreak == rOther.bColumnbreak
134 && bSoftHyph == rOther.bSoftHyph
135 && bBookmarks == rOther.bBookmarks
136 && bRef == rOther.bRef
137 && bFieldName == rOther.bFieldName
138 && bPostits == rOther.bPostits
139 && bFieldHidden == rOther.bFieldHidden
140 && bCharHidden == rOther.bCharHidden
141 && bGraphic == rOther.bGraphic
142 && bTable == rOther.bTable
143 && bDraw == rOther.bDraw
144 && bControl == rOther.bControl
145 && bCrosshair == rOther.bCrosshair
146 && bSnap == rOther.bSnap
147 && bSynchronize == rOther.bSynchronize
148 && bGridVisible == rOther.bGridVisible
149 && bOnlineSpell == rOther.bOnlineSpell
150 && bTreatSubOutlineLevelsAsContent == rOther.bTreatSubOutlineLevelsAsContent
151 && bShowInlineTooltips == rOther.bShowInlineTooltips
152 && bViewMetachars == rOther.bViewMetachars
153 && bRedlineRecordingOn == rOther.bRedlineRecordingOn
154 && bPageback == rOther.bPageback
155 && bShowOutlineContentVisibilityButton == rOther.bShowOutlineContentVisibilityButton
156 && bShowChangesInMargin == rOther.bShowChangesInMargin
157 && bShowChangesInMargin2 == rOther.bShowChangesInMargin2
158 && bTextBoundaries == rOther.bTextBoundaries
159 && bTextBoundariesFull == rOther.bTextBoundariesFull
160 && bSectionBoundaries == rOther.bSectionBoundaries
161 && bTableBoundaries == rOther.bTableBoundaries
162 && bShowBoundaries == rOther.bShowBoundaries
163 && bClickChangeRotation == rOther.bClickChangeRotation;
164 }
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 #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);
operator ==SwViewColors223 bool operator==(const SwViewColors& rOther) const
224 {
225 return m_aDocColor == rOther.m_aDocColor
226 && m_aDocBoundColor == rOther.m_aDocBoundColor
227 && m_aAppBackgroundColor == rOther.m_aAppBackgroundColor
228 && m_aTableBoundColor == rOther.m_aTableBoundColor
229 && m_aFontColor == rOther.m_aFontColor
230 && m_aIndexShadingsColor == rOther.m_aIndexShadingsColor
231 && m_aLinksColor == rOther.m_aLinksColor
232 && m_aVisitedLinksColor == rOther.m_aVisitedLinksColor
233 && m_aTextGridColor == rOther.m_aTextGridColor
234 && m_aSpellColor == rOther.m_aSpellColor
235 && m_aGrammarColor == rOther.m_aGrammarColor
236 && m_aSmarttagColor == rOther.m_aSmarttagColor
237 && m_aFieldShadingsColor == rOther.m_aFieldShadingsColor
238 && m_aSectionBoundColor == rOther.m_aSectionBoundColor
239 && m_aPageBreakColor == rOther.m_aPageBreakColor
240 && m_aNonPrintingCharacterColor == rOther.m_aNonPrintingCharacterColor
241 && m_aScriptIndicatorColor == rOther.m_aScriptIndicatorColor
242 && m_aShadowColor == rOther.m_aShadowColor
243 && m_aHeaderFooterMarkColor == rOther.m_aHeaderFooterMarkColor
244 && m_nAppearanceFlags == rOther.m_nAppearanceFlags;
245 }
246 Color m_aDocColor; // color of document boundaries
247 Color m_aDocBoundColor; // color of document boundaries
248 Color m_aAppBackgroundColor; // application background
249 Color m_aTableBoundColor; // color of table boundaries
250 Color m_aFontColor;
251 Color m_aIndexShadingsColor; // background color of indexes
252 Color m_aLinksColor;
253 Color m_aVisitedLinksColor;
254 Color m_aTextGridColor;
255 Color m_aSpellColor; // mark color of online spell checking
256 Color m_aGrammarColor;
257 Color m_aSmarttagColor;
258 Color m_aFieldShadingsColor;
259 Color m_aSectionBoundColor;
260 Color m_aPageBreakColor;
261 Color m_aNonPrintingCharacterColor;
262 Color m_aScriptIndicatorColor;
263 Color m_aShadowColor;
264 Color m_aHeaderFooterMarkColor;
265 ViewOptFlags m_nAppearanceFlags;
266 };
267
268 class SwViewOption
269 {
270 SwViewColors m_aColorConfig;
271 static SwViewColors s_aInitialColorConfig;
272 OUString m_sThemeName;
273
274 OUString m_sSymbolFont; // Symbolfont.
275 ViewOptFlags1 m_nCoreOptions; // Bits for SwViewShell.
276 ViewOptCoreFlags2 m_nCore2Options; // Bits for SwViewShell.
277 ViewOptFlags2 m_nUIOptions; // UI-Bits
278 Color m_aRetouchColor; // DefaultBackground for BrowseView
279 Size m_aSnapSize; // Describes horizontal and vertical snap.
280 sal_uInt16 mnViewLayoutColumns; // # columns for edit view
281 short m_nDivisionX; // Grid division.
282 short m_nDivisionY;
283 sal_uInt8 m_nPagePreviewRow; // Page Preview Row/Columns.
284 sal_uInt8 m_nPagePreviewCol; // Page Preview Row/Columns.
285 SwFillMode m_nShadowCursorFillMode; // FillMode for ShadowCursor.
286 bool m_bReadonly : 1; // Readonly-Doc.
287 bool m_bStarOneSetting : 1; // Prevent from UI automatics (no scrollbars in readonly documents).
288 bool m_bIsPagePreview : 1; // The preview mustn't print field/footnote/... shadings.
289 bool m_bSelectionInReadonly : 1; // Determines whether selection is switched on in readonly documents.
290 bool mbFormView : 1;
291 bool mbBrowseMode : 1;
292 bool mbBookView : 1; // View mode for page preview.
293 bool mbViewLayoutBookMode : 1; // Book view mode for edit view.
294 bool mbHideWhitespaceMode : 1; // Hide header, footer, and pagebreak.
295 bool m_bShowPlaceHolderFields : 1; // Only used in printing!
296 bool m_bEncloseWithCharactersOn : 1;
297 mutable bool m_bIdle;
298 sal_Int32 m_nDefaultAnchor; // GetDefaultAnchorType() to convert int to RndStdIds
299 // tdf#135266 - tox dialog: remember last used entry level depending on the index type
300 sal_uInt8 m_nTocEntryLvl;
301 sal_uInt8 m_nIdxEntryLvl;
302
303 // Scale
304 sal_uInt16 m_nZoom; // In percent.
305 SvxZoomType m_eZoom; // 'enum' for zoom.
306
307 sal_uInt8 m_nTableDestination; // Destination for table background.
308
309 #ifdef DBG_UTIL
310 // Corresponds to statements in ui/config/cfgvw.src.
311 bool m_bTest1 :1; // Test-flag "Layout not loading"
312 bool m_bTest2 :1; // Test-flag "WYSIWYG++"
313 bool m_bTest3 :1; // Test-flag ""
314 bool m_bTest4 :1; // Test-flag "WYSIWYG debug"
315 bool m_bTest5 :1; // Test-flag "No idle format"
316 bool m_bTest6 :1; // Test-flag "No screen adj"
317 bool m_bTest7 :1; // Test-flag "win format"
318 bool m_bTest8 :1; // Test-flag ""
319 bool m_bTest10 :1; // Test-Flag "Format by Input"
320 #endif
321
322 public:
323 SW_DLLPUBLIC SwViewOption(); // CTOR
324 SW_DLLPUBLIC SwViewOption(const SwViewOption&);
325 SW_DLLPUBLIC ~SwViewOption();
326
327 inline void SetUIOptions( const SwViewOption& );
328
SetColorConfig(const SwViewColors & rColorConfig)329 void SetColorConfig(const SwViewColors& rColorConfig)
330 {
331 m_aColorConfig = rColorConfig;
332 }
333
GetColorConfig() const334 const SwViewColors& GetColorConfig() const
335 {
336 return m_aColorConfig;
337 }
338
SetThemeName(const OUString & rThemeName)339 void SetThemeName(const OUString& rThemeName)
340 {
341 m_sThemeName = rThemeName;
342 }
343
GetThemeName() const344 const OUString & GetThemeName() const
345 {
346 return m_sThemeName;
347 }
348
SetInitialColorConfig(const SwViewColors & rColorConfig)349 static void SetInitialColorConfig(const SwViewColors& rColorConfig)
350 {
351 s_aInitialColorConfig = rColorConfig;
352 }
353
354 // Options from nCoreOptions
IsIdle() const355 bool IsIdle() const
356 { return m_bIdle; }
357
358 // Logically this is a const function since it does not modify the viewoptions
359 // but only effects idle formatting. Of course that member is already implement
360 // in the wrong place here... Also currently there are many const modifying casts in the code
361 // just to call this function on otherwise const objects. Thus declaring it as const now.
SetIdle(bool b) const362 void SetIdle( bool b ) const
363 { m_bIdle = b; }
364
IsTab(bool bHard=false) const365 bool IsTab(bool bHard = false) const
366 {
367 return !m_bReadonly && m_nCoreOptions.bTab && (m_nCoreOptions.bViewMetachars || bHard);
368 }
SetTab(bool b)369 void SetTab( bool b )
370 {
371 m_nCoreOptions.bTab = b;
372 }
373
IsBlank(bool bHard=false) const374 bool IsBlank(bool bHard = false) const
375 {
376 return !m_bReadonly && m_nCoreOptions.bBlank && (m_nCoreOptions.bViewMetachars || bHard);
377 }
SetBlank(bool b)378 void SetBlank(bool b)
379 {
380 m_nCoreOptions.bBlank = b;
381 }
382
IsHardBlank() const383 bool IsHardBlank() const
384 {
385 return !m_bReadonly && (m_nCoreOptions.bHardBlank);
386 }
SetHardBlank(bool b)387 void SetHardBlank( bool b )
388 {
389 m_nCoreOptions.bHardBlank = b;
390 }
391
IsParagraph(bool bHard=false) const392 bool IsParagraph(bool bHard = false) const
393 {
394 return !m_bReadonly && m_nCoreOptions.bParagraph &&
395 (m_nCoreOptions.bViewMetachars || bHard);
396 }
SetParagraph(bool b)397 void SetParagraph( bool b )
398 {
399 m_nCoreOptions.bParagraph = b;
400 }
401
SetShowBookmarks(bool const b)402 void SetShowBookmarks(bool const b)
403 {
404 m_nCoreOptions.bBookmarks = b;
405 }
IsShowBookmarks(bool const bHard=false) const406 bool IsShowBookmarks(bool const bHard = false) const
407 {
408 return !m_bReadonly && (m_nCoreOptions.bBookmarks)
409 && (bHard || IsFieldShadings());
410 }
411
IsLineBreak(bool bHard=false) const412 bool IsLineBreak(bool bHard = false) const
413 {
414 return !m_bReadonly && (m_nCoreOptions.bLinebreak) &&
415 ((m_nCoreOptions.bViewMetachars) || bHard);
416 }
SetLineBreak(bool b)417 void SetLineBreak( bool b )
418 {
419 m_nCoreOptions.bLinebreak = b;
420 }
421
SetPageBreak(bool b)422 void SetPageBreak( bool b )
423 {
424 m_nCoreOptions.bPagebreak = b;
425 }
426
SetColumnBreak(bool b)427 void SetColumnBreak( bool b)
428 {
429 m_nCoreOptions.bColumnbreak = b;
430 }
431
IsSoftHyph() const432 bool IsSoftHyph() const
433 { return !m_bReadonly && (m_nCoreOptions.bSoftHyph); }
434
SetSoftHyph(bool b)435 void SetSoftHyph( bool b )
436 {
437 m_nCoreOptions.bSoftHyph = b;
438 }
439
IsFieldName() const440 bool IsFieldName() const
441 { return !m_bReadonly && (m_nCoreOptions.bFieldName); }
442
SetFieldName(bool b)443 void SetFieldName( bool b )
444 {
445 m_nCoreOptions.bFieldName = b;
446 }
447
IsPostIts() const448 bool IsPostIts() const
449 {
450 return m_nCoreOptions.bPostits;
451 }
452
SetPostIts(bool b)453 void SetPostIts( bool b )
454 {
455 m_nCoreOptions.bPostits = b;
456 }
457
IsResolvedPostIts() const458 bool IsResolvedPostIts() const
459 { return bool(m_nUIOptions & ViewOptFlags2::ResolvedPostits); }
460
SetResolvedPostIts(bool b)461 void SetResolvedPostIts( bool b )
462 { SetUIOption(b, ViewOptFlags2::ResolvedPostits); }
463
464 void PaintPostIts( OutputDevice *pOut, const SwRect &rRect,
465 bool bIsScript ) const;
466 static SwTwips GetPostItsWidth(const OutputDevice* pOut);
467
468 //show/hide tooltips on tracked changes
IsShowInlineTooltips() const469 bool IsShowInlineTooltips() const
470 {
471 return m_nCoreOptions.bShowInlineTooltips;
472 }
473
SetShowInlineTooltips(bool b)474 void SetShowInlineTooltips( bool b )
475 { m_nCoreOptions.bShowInlineTooltips = b; }
476
477 //show/hide tracked deletions in text
IsShowChangesInMargin() const478 bool IsShowChangesInMargin() const
479 {
480 return m_nCoreOptions.bShowChangesInMargin;
481 }
482
SetShowChangesInMargin(bool b)483 void SetShowChangesInMargin( bool b )
484 {
485 m_nCoreOptions.bShowChangesInMargin = b;
486 }
487
488 //show/hide tracked insertions in text
IsShowChangesInMargin2() const489 bool IsShowChangesInMargin2() const
490 { return m_nCoreOptions.bShowChangesInMargin2; }
491
SetShowChangesInMargin2(bool b)492 void SetShowChangesInMargin2( bool b )
493 { m_nCoreOptions.bShowChangesInMargin2 = b; }
494
495 //show/hide interactive header/footer on top/bottom of pages
IsUseHeaderFooterMenu() const496 bool IsUseHeaderFooterMenu() const
497 { return m_nCoreOptions.bUseHeaderFooterMenu; }
SetUseHeaderFooterMenu(bool b)498 void SetUseHeaderFooterMenu( bool b )
499 { m_nCoreOptions.bUseHeaderFooterMenu = b; }
500
501 //show/hide outline content visibility button
502 SW_DLLPUBLIC bool IsShowOutlineContentVisibilityButton() const;
SetShowOutlineContentVisibilityButton(bool b)503 void SetShowOutlineContentVisibilityButton(bool b)
504 { m_nCoreOptions.bShowOutlineContentVisibilityButton = b; }
505
506 bool IsTreatSubOutlineLevelsAsContent() const;
SetTreatSubOutlineLevelsAsContent(bool b)507 void SetTreatSubOutlineLevelsAsContent(bool b)
508 { m_nCoreOptions.bTreatSubOutlineLevelsAsContent = b; }
509
IsShowHiddenChar(bool bHard=false) const510 bool IsShowHiddenChar(bool bHard = false) const
511 { return !m_bReadonly && m_nCoreOptions.bCharHidden &&
512 (m_nCoreOptions.bViewMetachars || bHard); }
513
SetShowHiddenChar(bool b)514 void SetShowHiddenChar( bool b )
515 { m_nCoreOptions.bCharHidden = b; }
516
IsShowHiddenField() const517 bool IsShowHiddenField() const
518 { return !m_bReadonly && m_nCoreOptions.bFieldHidden; }
SetShowHiddenField(bool b)519 void SetShowHiddenField( bool b )
520 { m_nCoreOptions.bFieldHidden = b; }
521
IsGraphic() const522 bool IsGraphic() const
523 { return m_nCoreOptions.bGraphic; }
SetGraphic(bool b)524 void SetGraphic( bool b )
525 { m_nCoreOptions.bGraphic = b; }
526
IsPageBack() const527 bool IsPageBack() const
528 { return m_nCoreOptions.bPageback; }
SetPageBack(bool b)529 void SetPageBack( bool b )
530 { m_nCoreOptions.bPageback = b; }
531
IsTable() const532 bool IsTable() const
533 { return m_nCoreOptions.bTable; }
SetTable(bool b)534 void SetTable( bool b )
535 { m_nCoreOptions.bTable = b; }
536
IsDraw() const537 bool IsDraw() const
538 { return m_nCoreOptions.bDraw; }
SetDraw(bool b)539 void SetDraw( bool b )
540 { m_nCoreOptions.bDraw = b; }
541
IsControl() const542 bool IsControl() const
543 { return m_nCoreOptions.bControl; }
SetControl(bool b)544 void SetControl( bool b )
545 { m_nCoreOptions.bControl = b; }
546
IsSnap() const547 bool IsSnap() const
548 { return m_nCoreOptions.bSnap; }
SetSnap(bool b)549 void SetSnap( bool b )
550 { m_nCoreOptions.bSnap = b; }
551
SetSnapSize(Size const & rSz)552 void SetSnapSize( Size const &rSz ){ m_aSnapSize = rSz; }
GetSnapSize() const553 const Size &GetSnapSize() const { return m_aSnapSize; }
554
IsGridVisible() const555 bool IsGridVisible() const
556 { return !m_bReadonly && m_nCoreOptions.bGridVisible; }
SetGridVisible(bool b)557 void SetGridVisible( bool b )
558 { m_nCoreOptions.bGridVisible = b; }
559
IsOnlineSpell() const560 bool IsOnlineSpell() const
561 {
562 return m_nCoreOptions.bOnlineSpell;
563 }
SetOnlineSpell(bool b)564 void SetOnlineSpell( bool b )
565 {
566 m_nCoreOptions.bOnlineSpell = b;
567 }
568
IsViewMetaChars() const569 bool IsViewMetaChars() const
570 { return !m_bReadonly && m_nCoreOptions.bViewMetachars; }
SetViewMetaChars(bool b)571 void SetViewMetaChars( bool b)
572 { m_nCoreOptions.bViewMetachars = b; }
573
IsRedlineRecordingOn() const574 bool IsRedlineRecordingOn() const { return m_nCoreOptions.bRedlineRecordingOn; }
575
SetRedlineRecordingOn(bool b)576 void SetRedlineRecordingOn(bool b) { m_nCoreOptions.bRedlineRecordingOn = b; }
577
IsSynchronize() const578 bool IsSynchronize() const
579 { return m_nCoreOptions.bSynchronize; }
SetSynchronize(bool b)580 void SetSynchronize( bool b )
581 { m_nCoreOptions.bSynchronize = b; }
582
IsCrossHair() const583 bool IsCrossHair() const
584 { return m_nCoreOptions.bCrosshair; }
SetCrossHair(bool b)585 void SetCrossHair( bool b )
586 { m_nCoreOptions.bCrosshair = b; }
587
588 // Options from nCore2Options
IsBlackFont() const589 bool IsBlackFont() const
590 {return bool(m_nCore2Options & ViewOptCoreFlags2::BlackFont); }
591
SetBlackFont(bool b)592 void SetBlackFont(bool b)
593 { SetCore2Option(b, ViewOptCoreFlags2::BlackFont); }
594
IsShowHiddenPara() const595 bool IsShowHiddenPara() const
596 {return bool(m_nCore2Options & ViewOptCoreFlags2::HiddenPara); }
597
SetShowHiddenPara(bool b)598 void SetShowHiddenPara(bool b)
599 { SetCore2Option(b, ViewOptCoreFlags2::HiddenPara); }
600
IsSmoothScroll() const601 bool IsSmoothScroll() const
602 {return bool(m_nCore2Options & ViewOptCoreFlags2::SmoothScroll); }
603
SetSmoothScroll(bool b)604 void SetSmoothScroll(bool b)
605 { SetCore2Option(b, ViewOptCoreFlags2::SmoothScroll); }
606
IsCursorInProtectedArea() const607 bool IsCursorInProtectedArea() const
608 {return bool(m_nCore2Options & ViewOptCoreFlags2::CursorInProt); }
609
SetCursorInProtectedArea(bool b)610 void SetCursorInProtectedArea(bool b)
611 { SetCore2Option(b, ViewOptCoreFlags2::CursorInProt); }
612
613 static bool IsIgnoreProtectedArea();
614
IsPDFExport() const615 bool IsPDFExport() const
616 {return bool(m_nCore2Options & ViewOptCoreFlags2::PdfExport); }
617
SetPDFExport(bool b)618 void SetPDFExport(bool b)
619 { SetCore2Option(b, ViewOptCoreFlags2::PdfExport); }
620
IsPrinting() const621 bool IsPrinting() const
622 {return bool(m_nCore2Options & ViewOptCoreFlags2::Printing); }
623
SetPrinting(bool b)624 void SetPrinting(bool b)
625 { SetCore2Option(b, ViewOptCoreFlags2::Printing); }
626
SetCore2Option(bool b,ViewOptCoreFlags2 f)627 void SetCore2Option(bool b, ViewOptCoreFlags2 f)
628 {
629 if (b)
630 m_nCore2Options |= f;
631 else
632 m_nCore2Options &= ~f;
633 }
634
GetDivisionX() const635 short GetDivisionX() const { return m_nDivisionX; }
SetDivisionX(short n)636 void SetDivisionX( short n ){ m_nDivisionX = n; }
GetDivisionY() const637 short GetDivisionY() const { return m_nDivisionY; }
SetDivisionY(short n)638 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
GetDocumentBorder() const647 sal_uInt16 GetDocumentBorder() const { return IsWhitespaceHidden() ? minGapBetweenPages : defDocumentBorder; }
GetGapBetweenPages() const648 sal_uInt16 GetGapBetweenPages() const { return IsWhitespaceHidden() ? minGapBetweenPages : defGapBetweenPages; }
649
GetPagePrevRow() const650 sal_uInt8 GetPagePrevRow() const { return m_nPagePreviewRow; }
SetPagePrevRow(sal_uInt8 n)651 void SetPagePrevRow( sal_uInt8 n ) { m_nPagePreviewRow = n; }
GetPagePrevCol() const652 sal_uInt8 GetPagePrevCol() const { return m_nPagePreviewCol; }
SetPagePrevCol(sal_uInt8 n)653 void SetPagePrevCol( sal_uInt8 n ) { m_nPagePreviewCol = n; }
IsReadonly() const654 bool IsReadonly() const { return m_bReadonly; }
SetReadonly(bool bSet)655 void SetReadonly(bool bSet) { m_bReadonly = bSet; }
656
IsSelectionInReadonly() const657 bool IsSelectionInReadonly() const {return m_bSelectionInReadonly;}
SetSelectionInReadonly(bool bSet)658 void SetSelectionInReadonly(bool bSet) {m_bSelectionInReadonly = bSet;}
659
IsFormView() const660 bool IsFormView() const { return mbFormView; }
SetFormView(bool bSet)661 void SetFormView( bool bSet ) { mbFormView = bSet; }
662
getBrowseMode() const663 bool getBrowseMode() const { return mbBrowseMode; }
setBrowseMode(bool bSet)664 void setBrowseMode(bool bSet) { mbBrowseMode = bSet; }
IsPagePrevBookview() const665 bool IsPagePrevBookview() const { return mbBookView; }
SetPagePrevBookview(bool bSet)666 void SetPagePrevBookview(bool bSet) { mbBookView = bSet; }
667
668 static bool IsAutoCompleteWords();
669
IsViewLayoutBookMode() const670 bool IsViewLayoutBookMode() const { return mbViewLayoutBookMode; }
SetViewLayoutBookMode(bool bNew)671 void SetViewLayoutBookMode( bool bNew ) { mbViewLayoutBookMode = bNew; }
GetViewLayoutColumns() const672 sal_uInt16 GetViewLayoutColumns() const { return mnViewLayoutColumns; }
SetViewLayoutColumns(sal_uInt16 nNew)673 void SetViewLayoutColumns( sal_uInt16 nNew ) { mnViewLayoutColumns = nNew; }
IsHideWhitespaceMode() const674 bool IsHideWhitespaceMode() const { return mbHideWhitespaceMode; }
SetHideWhitespaceMode(bool bMode)675 void SetHideWhitespaceMode( bool bMode ) { mbHideWhitespaceMode = bMode; }
676
677 /// The rules that allow for hiding whitespace.
CanHideWhitespace() const678 bool CanHideWhitespace() const { return !IsMultipageView(); }
IsWhitespaceHidden() const679 bool IsWhitespaceHidden() const { return IsHideWhitespaceMode() && !IsMultipageView(); }
IsMultipageView() const680 bool IsMultipageView() const { return IsViewLayoutBookMode() ||
681 GetViewLayoutColumns() == 0; }
682
IsTextBoundaries() const683 bool IsTextBoundaries() const { return m_nCoreOptions.bTextBoundaries; }
SetTextBoundaries(bool b)684 void SetTextBoundaries( bool b) { m_nCoreOptions.bTextBoundaries = b; }
685
IsTextBoundariesFull() const686 bool IsTextBoundariesFull() const { return m_nCoreOptions.bTextBoundariesFull; }
SetTextBoundariesFull(bool b)687 void SetTextBoundariesFull( bool b) { m_nCoreOptions.bTextBoundariesFull = b; }
688
IsSectionBoundaries() const689 bool IsSectionBoundaries() const { return m_nCoreOptions.bSectionBoundaries; }
SetSectionBoundaries(bool b)690 void SetSectionBoundaries( bool b) { m_nCoreOptions.bSectionBoundaries = b; }
691
IsTableBoundaries() const692 bool IsTableBoundaries() const { return m_nCoreOptions.bTableBoundaries; }
SetTableBoundaries(bool b)693 void SetTableBoundaries( bool b) { m_nCoreOptions.bTableBoundaries = b; }
694
IsShowBoundaries() const695 bool IsShowBoundaries() const { return m_nCoreOptions.bShowBoundaries; }
SetShowBoundaries(bool b)696 void SetShowBoundaries( bool b ) { m_nCoreOptions.bShowBoundaries = b; }
697
IsClickChangeRotation() const698 bool IsClickChangeRotation() const { return m_nCoreOptions.bClickChangeRotation; }
SetClickChangeRotation(bool b)699 void SetClickChangeRotation( bool b ) { m_nCoreOptions.bClickChangeRotation = b; }
700
701 #ifdef DBG_UTIL
702 // Correspond to statements in ui/config/cfgvw.src.
IsTest1() const703 bool IsTest1() const { return m_bTest1; }
IsTest2() const704 bool IsTest2() const { return m_bTest2; }
IsTest3() const705 bool IsTest3() const { return m_bTest3; }
IsTest4() const706 bool IsTest4() const { return m_bTest4; }
IsTest5() const707 bool IsTest5() const { return m_bTest5; }
IsTest6() const708 bool IsTest6() const { return m_bTest6; }
IsTest7() const709 bool IsTest7() const { return m_bTest7; }
IsTest8() const710 bool IsTest8() const { return m_bTest8; }
IsTest10() const711 bool IsTest10() const { return m_bTest10; }
712 #endif
713
GetZoom() const714 sal_uInt16 GetZoom() const { return m_nZoom; }
SetZoom(sal_uInt16 n)715 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;
operator !=(const SwViewOption & rOpt) const725 bool operator != ( const SwViewOption &rOpt ) const { return !(*this == rOpt); }
726
727 // Options from nUIOptions
IsViewVScrollBar() const728 bool IsViewVScrollBar() const
729 {
730 #if HAVE_FEATURE_DESKTOP
731 return bool(m_nUIOptions & ViewOptFlags2::VScrollbar);
732 #else
733 return false;
734 #endif
735 }
IsViewHScrollBar() const736 bool IsViewHScrollBar() const
737 {
738 #if HAVE_FEATURE_DESKTOP
739 return bool(m_nUIOptions & ViewOptFlags2::HScrollbar);
740 #else
741 return false;
742 #endif
743 }
IsKeepRatio() const744 bool IsKeepRatio() const
745 { return bool(m_nUIOptions & ViewOptFlags2::KeepAspectRatio); }
IsGrfKeepZoom() const746 bool IsGrfKeepZoom() const
747 { return bool(m_nUIOptions & ViewOptFlags2::GrfKeepZoom); }
IsShowContentTips() const748 bool IsShowContentTips() const
749 { return bool(m_nUIOptions & ViewOptFlags2::ContentTips); }
IsPrtFormat() const750 bool IsPrtFormat() const
751 { return bool(m_nUIOptions & ViewOptFlags2::PrintFormat); }
IsShowScrollBarTips() const752 bool IsShowScrollBarTips() const
753 { return bool(m_nUIOptions & ViewOptFlags2::ScrollbarTips); }
754
GetZoomType() const755 SvxZoomType GetZoomType() const { return m_eZoom; }
756
GetTableDest() const757 sal_uInt8 GetTableDest() const { return m_nTableDestination; }
758
SetViewVScrollBar(bool b)759 void SetViewVScrollBar(bool b)
760 { SetUIOption(b, ViewOptFlags2::VScrollbar); }
SetViewHScrollBar(bool b)761 void SetViewHScrollBar(bool b)
762 { SetUIOption(b, ViewOptFlags2::HScrollbar); }
SetKeepRatio(bool b)763 void SetKeepRatio (bool b)
764 { SetUIOption(b, ViewOptFlags2::KeepAspectRatio); }
SetGrfKeepZoom(bool b)765 void SetGrfKeepZoom (bool b)
766 { SetUIOption(b, ViewOptFlags2::GrfKeepZoom); }
SetShowContentTips(bool b)767 void SetShowContentTips( bool b)
768 { SetUIOption(b, ViewOptFlags2::ContentTips); }
SetPrtFormat(bool b)769 void SetPrtFormat( bool b)
770 { SetUIOption(b, ViewOptFlags2::PrintFormat); }
SetShowScrollBarTips(bool b)771 void SetShowScrollBarTips( bool b)
772 { SetUIOption(b, ViewOptFlags2::ScrollbarTips); }
SetUIOption(bool b,ViewOptFlags2 f)773 void SetUIOption( bool b, ViewOptFlags2 f)
774 {
775 if (b)
776 m_nUIOptions |= f;
777 else
778 m_nUIOptions &= ~f;
779 }
780
SetZoomType(SvxZoomType eZoom_)781 void SetZoomType (SvxZoomType eZoom_){ m_eZoom = eZoom_; }
SetTableDest(sal_uInt8 nNew)782 void SetTableDest( sal_uInt8 nNew ) { m_nTableDestination = nNew; }
783
GetSymbolFont() const784 const OUString& GetSymbolFont() const {return m_sSymbolFont;}
SetSymbolFont(const OUString & sSet)785 void SetSymbolFont(const OUString& sSet) {m_sSymbolFont = sSet;}
786
GetRetoucheColor() const787 const Color& GetRetoucheColor() const { return m_aRetouchColor;}
SetRetoucheColor(const Color & r)788 void SetRetoucheColor(const Color&r) { m_aRetouchColor = r; }
789
IsViewAnyRuler() const790 bool IsViewAnyRuler() const
791 {
792 #if HAVE_FEATURE_DESKTOP
793 return bool(m_nUIOptions & ViewOptFlags2::AnyRuler);
794 #else
795 return false;
796 #endif
797 }
SetViewAnyRuler(bool bSet)798 void SetViewAnyRuler(bool bSet)
799 { SetUIOption(bSet, ViewOptFlags2::AnyRuler);}
800
IsViewHRuler(bool bDirect=false) const801 bool IsViewHRuler(bool bDirect = false) const
802 {
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 (void) bDirect;
809 return false;
810 #endif
811 }
SetViewHRuler(bool b)812 void SetViewHRuler (bool b)
813 { SetUIOption(b, ViewOptFlags2::HRuler ); }
814
IsViewVRuler(bool bDirect=false) const815 bool IsViewVRuler(bool bDirect = false) const
816 {
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 (void) bDirect;
823 return false;
824 #endif
825 }
SetViewVRuler(bool b)826 void SetViewVRuler (bool b)
827 { SetUIOption(b, ViewOptFlags2::VRuler); }
828
829 // ShadowCursor, switch on/off, get/set color/mode.
IsShadowCursor() const830 bool IsShadowCursor() const
831 { return bool(m_nUIOptions & ViewOptFlags2::ShadowCursor); }
SetShadowCursor(bool b)832 void SetShadowCursor(bool b)
833 { SetUIOption(b, ViewOptFlags2::ShadowCursor); }
834
835 // Enclose with characters autocomplete, switch on/off
IsEncloseWithCharactersOn() const836 bool IsEncloseWithCharactersOn() const { return m_bEncloseWithCharactersOn; }
SetEncloseWithCharactersOn(bool b)837 void SetEncloseWithCharactersOn(bool b) { m_bEncloseWithCharactersOn = b; }
838
IsEncloseWithCharactersTrigger(sal_Unicode cChar)839 static bool IsEncloseWithCharactersTrigger(sal_Unicode cChar)
840 {
841 switch (cChar)
842 {
843 case '(': [[fallthrough]];
844 case '{': [[fallthrough]];
845 case '[': [[fallthrough]];
846 case '\'': [[fallthrough]];
847 case '\"':
848 return true;
849 default:
850 return false;
851 }
852 }
853
854 //move vertical ruler to the right
IsVRulerRight() const855 bool IsVRulerRight() const
856 { return bool(m_nUIOptions & ViewOptFlags2::VRulerRight); }
SetVRulerRight(bool b)857 void SetVRulerRight(bool b)
858 { SetUIOption(b, ViewOptFlags2::VRulerRight); }
859
IsStarOneSetting() const860 bool IsStarOneSetting() const {return m_bStarOneSetting; }
SetStarOneSetting(bool bSet)861 void SetStarOneSetting(bool bSet) {m_bStarOneSetting = bSet; }
862
IsPagePreview() const863 bool IsPagePreview() const {return m_bIsPagePreview; }
SetPagePreview(bool bSet)864 void SetPagePreview(bool bSet) { m_bIsPagePreview= bSet; }
865
GetShdwCursorFillMode() const866 SwFillMode GetShdwCursorFillMode() const { return m_nShadowCursorFillMode; }
SetShdwCursorFillMode(SwFillMode nMode)867 void SetShdwCursorFillMode( SwFillMode nMode ) { m_nShadowCursorFillMode = nMode; };
868
IsShowPlaceHolderFields() const869 bool IsShowPlaceHolderFields() const { return m_bShowPlaceHolderFields; }
SetShowPlaceHolderFields(bool bSet)870 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
IsIndexShadings() const893 bool IsIndexShadings() const {return IsAppearanceFlag(ViewOptFlags::IndexShadings);}
IsLinks() const894 bool IsLinks() const {return IsAppearanceFlag(ViewOptFlags::Links);}
IsVisitedLinks() const895 bool IsVisitedLinks() const {return IsAppearanceFlag(ViewOptFlags::VisitedLinks);}
IsFieldShadings() const896 bool IsFieldShadings() const {return IsAppearanceFlag(ViewOptFlags::FieldShadings);}
IsShadow() const897 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_*
GetDefaultAnchor() const902 sal_Int32 GetDefaultAnchor() const
903 { return m_nDefaultAnchor; }
SetDefaultAnchor(const sal_Int32 aFlag)904 void SetDefaultAnchor( const sal_Int32 aFlag )
905 { m_nDefaultAnchor = aFlag; }
906
907 RndStdIds GetDefaultAnchorType() const;
908
909 // tdf#135266 - tox dialog: remember last used entry level depending on the index type
GetTocEntryLvl() const910 sal_uInt8 GetTocEntryLvl() const { return m_nTocEntryLvl; }
SetTocEntryLvl(sal_uInt8 n)911 void SetTocEntryLvl(sal_uInt8 n) { m_nTocEntryLvl = n; }
GetIdxEntryLvl() const912 sal_uInt8 GetIdxEntryLvl() const { return m_nIdxEntryLvl; }
SetIdxEntryLvl(sal_uInt8 n)913 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
operator ==(const SwViewOption & rOpt) const923 inline bool SwViewOption::operator==( const SwViewOption &rOpt ) const
924 {
925 return IsEqualFlags( rOpt ) && m_nZoom == rOpt.GetZoom() && m_aColorConfig == rOpt.m_aColorConfig;
926 }
927
SetUIOptions(const SwViewOption & rVOpt)928 inline void SwViewOption::SetUIOptions( const SwViewOption& rVOpt )
929 {
930 m_nUIOptions = rVOpt.m_nUIOptions;
931 m_nTableDestination = rVOpt.m_nTableDestination;
932 m_nShadowCursorFillMode = rVOpt.m_nShadowCursorFillMode;
933 m_bEncloseWithCharactersOn = rVOpt.m_bEncloseWithCharactersOn;
934 }
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: */
942