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 <sfx2/zoomitem.hxx>
29 #include "swdllapi.h"
30 
31 class SwRect;
32 namespace vcl { class Window; }
33 class OutputDevice;
34 class SwDocShell;
35 namespace svtools{ class ColorConfig;}
36 
37 enum class ViewOptFlags1 {
38     UseHeaderFooterMenu = 0x00000001,
39     Tab           = 0x00000002,
40     Blank         = 0x00000004,
41     HardBlank     = 0x00000008,
42     Paragraph     = 0x00000010,
43     Linebreak     = 0x00000020,
44     Pagebreak     = 0x00000040,
45     Columnbreak   = 0x00000080,
46     SoftHyph      = 0x00000100,
47     Ref           = 0x00000400,
48     FieldName     = 0x00000800,
49     Postits       = 0x00004000,
50     FieldHidden   = 0x00008000,
51     CharHidden    = 0x00010000,
52     Graphic       = 0x00020000,
53     Table         = 0x00040000,
54     Draw          = 0x00080000,
55     Control       = 0x00100000,
56     Crosshair     = 0x00400000,
57     Snap          = 0x00800000,
58     Synchronize   = 0x01000000,
59     GridVisible   = 0x02000000,
60     OnlineSpell   = 0x04000000,
61     ShowInlineTooltips = 0x10000000, //tooltips on tracked changes
62     ViewMetachars = 0x20000000,
63     Pageback      = 0x40000000
64 };
65 namespace o3tl {
66     template<> struct typed_flags<ViewOptFlags1> : is_typed_flags<ViewOptFlags1, 0x77dfcdff> {};
67 }
68 
69 enum class ViewOptCoreFlags2 {
70     BlackFont         = 0x0001,
71     HiddenPara        = 0x0002,
72     SmoothScroll      = 0x0004,
73     CursorInProt      = 0x0008,
74     PdfExport         = 0x0010,
75     Printing          = 0x0020,
76 };
77 namespace o3tl {
78     template<> struct typed_flags<ViewOptCoreFlags2> : is_typed_flags<ViewOptCoreFlags2, 0x007f> {};
79 };
80 
81 enum class ViewOptFlags2 {
82     HRuler          = 0x00000400,
83     VScrollbar      = 0x00000800,
84     HScrollbar      = 0x00001000,
85     VRuler          = 0x00004000,
86     AnyRuler        = 0x00008000,
87     Modified        = 0x00010000,
88     KeepAspectRatio = 0x00020000,
89     GrfKeepZoom     = 0x00040000,
90     ContentTips     = 0x00100000,
91     ScrollbarTips   = 0x00400000,
92     PrintFormat     = 0x00800000,
93     ShadowCursor    = 0x01000000,
94     VRulerRight     = 0x02000000,
95     ResolvedPostits = 0x04000000,
96 };
97 namespace o3tl {
98     template<> struct typed_flags<ViewOptFlags2> : is_typed_flags<ViewOptFlags2, 0x07d7dc00> {};
99 };
100 
101 // Table background.
102 #define TBL_DEST_CELL   0
103 #define TBL_DEST_ROW    1
104 #define TBL_DEST_TBL    2
105 
106 // Appearance flags.
107 enum class ViewOptFlags {
108     NONE               = 0x0000,
109     DocBoundaries      = 0x0001,
110     ObjectBoundaries   = 0x0002,
111     TableBoundaries    = 0x0004,
112     IndexShadings      = 0x0008,
113     Links              = 0x0010,
114     VisitedLinks       = 0x0020,
115     FieldShadings      = 0x0040,
116     SectionBoundaries  = 0x0080,
117     Shadow             = 0x0100,
118 };
119 namespace o3tl {
120     template<> struct typed_flags<ViewOptFlags> : is_typed_flags<ViewOptFlags, 0x01ff> {};
121 }
122 
123 class SW_DLLPUBLIC SwViewOption
124 {
125     static Color    s_aDocColor;  // color of document boundaries
126     static Color    s_aDocBoundColor;  // color of document boundaries
127     static Color    s_aObjectBoundColor; // color of object boundaries
128     static Color    s_aAppBackgroundColor; // application background
129     static Color    s_aTableBoundColor; // color of table boundaries
130     static Color    s_aFontColor;
131     static Color    s_aIndexShadingsColor; // background color of indexes
132     static Color    s_aLinksColor;
133     static Color    s_aVisitedLinksColor;
134     static Color    s_aDirectCursorColor;
135     static Color    s_aTextGridColor;
136     static Color    s_aSpellColor;     // mark color of online spell checking
137     static Color    s_aSmarttagColor;
138     static Color    s_aFieldShadingsColor;
139     static Color    s_aSectionBoundColor;
140     static Color    s_aPageBreakColor;
141     static Color    s_aScriptIndicatorColor;
142     static Color    s_aShadowColor;
143     static Color    s_aHeaderFooterMarkColor;
144 
145     static ViewOptFlags s_nAppearanceFlags;
146     static sal_uInt16   s_nPixelTwips;// 1 Pixel == ? Twips
147 
148     OUString        m_sSymbolFont;        // Symbolfont.
149     ViewOptFlags1   m_nCoreOptions;       // Bits for SwViewShell.
150     ViewOptCoreFlags2 m_nCore2Options;    // Bits for SwViewShell.
151     ViewOptFlags2   m_nUIOptions;         // UI-Bits
152     Color           m_aRetouchColor;      // DefaultBackground for BrowseView
153     Size            m_aSnapSize;          // Describes horizontal and vertical snap.
154     sal_uInt16      mnViewLayoutColumns;  // # columns for edit view
155     short           m_nDivisionX;         // Grid division.
156     short           m_nDivisionY;
157     sal_uInt8       m_nPagePreviewRow;       // Page Preview Row/Columns.
158     sal_uInt8       m_nPagePreviewCol;       // Page Preview Row/Columns.
159     sal_uInt8       m_nShadowCursorFillMode;  // FillMode for ShadowCursor.
160     bool            m_bReadonly : 1;      // Readonly-Doc.
161     bool            m_bStarOneSetting : 1;// Prevent from UI automatics (no scrollbars in readonly documents).
162     bool            m_bIsPagePreview : 1; // The preview mustn't print field/footnote/... shadings.
163     bool            m_bSelectionInReadonly : 1; // Determines whether selection is switched on in readonly documents.
164     bool            mbFormView : 1;
165     bool            mbBrowseMode : 1;
166     bool            mbBookView : 1;      // View mode for page preview.
167     bool            mbViewLayoutBookMode : 1; // Book view mode for edit view.
168     bool            mbHideWhitespaceMode : 1; // Hide header, footer, and pagebreak.
169     bool            m_bShowPlaceHolderFields : 1; // Only used in printing!
170     mutable bool    m_bIdle;
171 
172     // Scale
173     sal_uInt16          m_nZoom;          // In percent.
174     SvxZoomType     m_eZoom;              // 'enum' for zoom.
175 
176     sal_uInt8            m_nTableDestination;      // Destination for table background.
177 
178 #ifdef DBG_UTIL
179     // Corresponds to statements in ui/config/cfgvw.src.
180     bool  m_bTest1        :1;     // Test-flag  "Layout not loading"
181     bool  m_bTest2        :1;     // Test-flag  "WYSIWYG++"
182     bool  m_bTest3        :1;     // Test-flag  ""
183     bool  m_bTest4        :1;     // Test-flag  "WYSIWYG debug"
184     bool  m_bTest5        :1;     // Test-flag  "No idle format"
185     bool  m_bTest6        :1;     // Test-flag  "No screen adj"
186     bool  m_bTest7        :1;     // Test-flag  "win format"
187     bool  m_bTest8        :1;     // Test-flag  ""
188     bool  m_bTest10       :1;     // Test-Flag  "Format by Input"
189 #endif
190 
191 public:
192             SwViewOption();                     // CTOR
193             SwViewOption(const SwViewOption&);
194             ~SwViewOption();
195 
196     static void Init( vcl::Window const *pWin );        // Initializing of static data.
197 
GetCoreOptions() const198     ViewOptFlags1   GetCoreOptions() const {return m_nCoreOptions;}
199     inline void     SetUIOptions( const SwViewOption& );
200 
201     // Options from nCoreOptions
IsIdle() const202     bool IsIdle() const
203         { return m_bIdle; }
204 
205     // Logically this is a const function since it does not modify the viewoptions
206     // but only effects idle formatting. Of course that member is already implement
207     // in the wrong place here... Also currently there are many const modifying casts in the code
208     // just to call this function on otherwise const objects. Thus declaring it as const now.
SetIdle(bool b) const209     void SetIdle( bool b ) const
210         { m_bIdle = b; }
211 
IsTab(bool bHard=false) const212     bool IsTab(bool bHard = false) const
213                     {   return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::Tab) &&
214                             ((m_nCoreOptions & ViewOptFlags1::ViewMetachars)||bHard); }
SetTab(bool b)215     void SetTab( bool b )
216         { SetCoreOption(b, ViewOptFlags1::Tab); }
217 
IsBlank(bool bHard=false) const218     bool IsBlank(bool bHard = false) const
219                     { return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::Blank) &&
220                             ((m_nCoreOptions & ViewOptFlags1::ViewMetachars)||bHard); }
SetBlank(bool b)221     void SetBlank( bool b )
222         { SetCoreOption(b, ViewOptFlags1::Blank); }
223 
IsHardBlank() const224     bool IsHardBlank() const
225                     { return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::HardBlank); }
SetHardBlank(bool b)226     void SetHardBlank( bool b )
227         { SetCoreOption(b, ViewOptFlags1::HardBlank); }
228 
IsParagraph(bool bHard=false) const229     bool IsParagraph(bool bHard = false) const
230                     {   return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::Paragraph) &&
231                             ((m_nCoreOptions & ViewOptFlags1::ViewMetachars)||bHard); }
SetParagraph(bool b)232     void SetParagraph( bool b )
233         { SetCoreOption(b, ViewOptFlags1::Paragraph); }
234 
IsLineBreak(bool bHard=false) const235     bool IsLineBreak(bool bHard = false) const
236                     {   return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::Linebreak) &&
237                             ((m_nCoreOptions & ViewOptFlags1::ViewMetachars)||bHard); }
SetLineBreak(bool b)238     void SetLineBreak( bool b )
239         { SetCoreOption(b, ViewOptFlags1::Linebreak); }
240 
SetPageBreak(bool b)241     void SetPageBreak( bool b )
242         { SetCoreOption(b, ViewOptFlags1::Pagebreak); }
243 
SetColumnBreak(bool b)244     void SetColumnBreak( bool b)
245         { SetCoreOption(b, ViewOptFlags1::Columnbreak); }
246 
IsSoftHyph() const247     bool IsSoftHyph() const
248                     { return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::SoftHyph); }
SetSoftHyph(bool b)249     void SetSoftHyph( bool b )
250         { SetCoreOption(b, ViewOptFlags1::SoftHyph); }
251 
IsFieldName() const252     bool IsFieldName() const       { return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::FieldName); }
SetFieldName(bool b)253     void SetFieldName( bool b )
254         { SetCoreOption(b, ViewOptFlags1::FieldName); }
255 
IsPostIts() const256     bool IsPostIts() const
257         { return bool(m_nCoreOptions & ViewOptFlags1::Postits); }
SetPostIts(bool b)258     void SetPostIts( bool b )
259         { SetCoreOption(b, ViewOptFlags1::Postits); }
260 
IsResolvedPostIts() const261     bool IsResolvedPostIts() const
262         { return bool(m_nUIOptions & ViewOptFlags2::ResolvedPostits); }
SetResolvedPostIts(bool b)263     void SetResolvedPostIts( bool b )
264         { SetUIOption(b, ViewOptFlags2::ResolvedPostits); }
265 
266     static void PaintPostIts( OutputDevice *pOut, const SwRect &rRect,
267                               bool bIsScript );
268     static sal_uInt16 GetPostItsWidth( const OutputDevice *pOut );
269 
270     //show/hide tooltips on tracked changes
IsShowInlineTooltips() const271     bool IsShowInlineTooltips() const
272         { return bool(m_nCoreOptions & ViewOptFlags1::ShowInlineTooltips); }
SetShowInlineTooltips(bool b)273     void SetShowInlineTooltips( bool b )
274         { SetCoreOption(b, ViewOptFlags1::ShowInlineTooltips); }
275 
276     //show/hide interactive header/footer on top/bottom of pages
IsUseHeaderFooterMenu() const277     bool IsUseHeaderFooterMenu() const
278         { return bool(m_nCoreOptions & ViewOptFlags1::UseHeaderFooterMenu ); }
SetUseHeaderFooterMenu(bool b)279     void SetUseHeaderFooterMenu( bool b )
280         { SetCoreOption(b, ViewOptFlags1::UseHeaderFooterMenu); }
281 
IsShowHiddenChar(bool bHard=false) const282     bool IsShowHiddenChar(bool bHard = false) const
283         { return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::CharHidden) &&
284                             ((m_nCoreOptions & ViewOptFlags1::ViewMetachars)||bHard); }
285 
SetShowHiddenChar(bool b)286     void SetShowHiddenChar( bool b )
287         { SetCoreOption(b, ViewOptFlags1::CharHidden); }
288 
IsShowHiddenField() const289     bool IsShowHiddenField() const
290         { return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::FieldHidden); }
SetShowHiddenField(bool b)291     void SetShowHiddenField( bool b )
292         { SetCoreOption(b, ViewOptFlags1::FieldHidden); }
293 
IsGraphic() const294     bool IsGraphic() const
295         { return bool(m_nCoreOptions & ViewOptFlags1::Graphic); }
SetGraphic(bool b)296     void SetGraphic( bool b )
297         { SetCoreOption(b, ViewOptFlags1::Graphic); }
298 
IsPageBack() const299     bool IsPageBack() const
300         { return bool(m_nCoreOptions & ViewOptFlags1::Pageback); }
SetPageBack(bool b)301     void SetPageBack( bool b )
302         { SetCoreOption(b, ViewOptFlags1::Pageback); }
303 
IsTable() const304     bool IsTable() const
305         { return bool(m_nCoreOptions & ViewOptFlags1::Table); }
SetTable(bool b)306     void SetTable( bool b )
307         { SetCoreOption(b, ViewOptFlags1::Table); }
308 
IsDraw() const309     bool IsDraw() const
310         { return bool(m_nCoreOptions & ViewOptFlags1::Draw); }
SetDraw(bool b)311     void SetDraw( bool b )
312         { SetCoreOption(b, ViewOptFlags1::Draw); }
313 
IsControl() const314     bool IsControl() const
315         { return bool(m_nCoreOptions & ViewOptFlags1::Control); }
SetControl(bool b)316     void SetControl( bool b )
317         { SetCoreOption(b, ViewOptFlags1::Control); }
318 
IsSnap() const319     bool IsSnap() const
320         { return bool(m_nCoreOptions & ViewOptFlags1::Snap); }
SetSnap(bool b)321     void SetSnap( bool b )
322         { SetCoreOption(b, ViewOptFlags1::Snap); }
323 
SetSnapSize(Size const & rSz)324     void SetSnapSize( Size const &rSz ){ m_aSnapSize = rSz; }
GetSnapSize() const325     const Size &GetSnapSize() const { return m_aSnapSize; }
326 
IsGridVisible() const327     bool IsGridVisible() const
328         { return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::GridVisible); }
SetGridVisible(bool b)329     void SetGridVisible( bool b )
330         { SetCoreOption(b, ViewOptFlags1::GridVisible); }
331 
IsOnlineSpell() const332     bool IsOnlineSpell() const
333         { return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::OnlineSpell); }
334     void SetOnlineSpell( bool b );
335 
IsViewMetaChars() const336     bool IsViewMetaChars() const
337         { return !m_bReadonly && (m_nCoreOptions & ViewOptFlags1::ViewMetachars); }
SetViewMetaChars(bool b)338     void SetViewMetaChars( bool b)
339         { SetCoreOption(b, ViewOptFlags1::ViewMetachars); }
340 
IsSynchronize() const341     bool IsSynchronize() const
342         {  return bool(m_nCoreOptions & ViewOptFlags1::Synchronize); }
SetSynchronize(bool b)343     void SetSynchronize( bool b )
344         { SetCoreOption(b, ViewOptFlags1::Synchronize); }
345 
IsCrossHair() const346     bool IsCrossHair() const
347         { return bool(m_nCoreOptions & ViewOptFlags1::Crosshair); }
SetCrossHair(bool b)348     void SetCrossHair( bool b )
349         { SetCoreOption(b, ViewOptFlags1::Crosshair); }
350 
351     // Options from nCore2Options
IsBlackFont() const352     bool IsBlackFont() const
353         {return bool(m_nCore2Options & ViewOptCoreFlags2::BlackFont); }
354 
SetBlackFont(bool b)355     void SetBlackFont(bool b)
356         { SetCore2Option(b, ViewOptCoreFlags2::BlackFont); }
357 
IsShowHiddenPara() const358     bool IsShowHiddenPara() const
359         {return bool(m_nCore2Options & ViewOptCoreFlags2::HiddenPara); }
360 
SetShowHiddenPara(bool b)361     void SetShowHiddenPara(bool b)
362         { SetCore2Option(b, ViewOptCoreFlags2::HiddenPara); }
363 
IsSmoothScroll() const364     bool IsSmoothScroll() const
365         {return bool(m_nCore2Options & ViewOptCoreFlags2::SmoothScroll); }
366 
SetSmoothScroll(bool b)367     void SetSmoothScroll(bool b)
368         { SetCore2Option(b, ViewOptCoreFlags2::SmoothScroll); }
369 
IsCursorInProtectedArea() const370     bool IsCursorInProtectedArea() const
371         {return bool(m_nCore2Options & ViewOptCoreFlags2::CursorInProt); }
372 
SetCursorInProtectedArea(bool b)373     void SetCursorInProtectedArea(bool b)
374         { SetCore2Option(b, ViewOptCoreFlags2::CursorInProt); }
375 
376     static bool IsIgnoreProtectedArea();
377 
IsPDFExport() const378     bool IsPDFExport() const
379         {return bool(m_nCore2Options & ViewOptCoreFlags2::PdfExport); }
380 
SetPDFExport(bool b)381     void SetPDFExport(bool b)
382         { SetCore2Option(b, ViewOptCoreFlags2::PdfExport); }
383 
IsPrinting() const384     bool IsPrinting() const
385         {return bool(m_nCore2Options & ViewOptCoreFlags2::Printing); }
386 
SetPrinting(bool b)387     void SetPrinting(bool b)
388         { SetCore2Option(b, ViewOptCoreFlags2::Printing); }
389 
SetCore2Option(bool b,ViewOptCoreFlags2 f)390     void SetCore2Option(bool b, ViewOptCoreFlags2 f)
391     {
392         if (b)
393             m_nCore2Options |= f;
394         else
395             m_nCore2Options &= ~f;
396     }
SetCoreOption(bool b,ViewOptFlags1 f)397     void SetCoreOption(bool b, ViewOptFlags1 f)
398     {
399         if (b)
400             m_nCoreOptions |= f;
401         else
402             m_nCoreOptions &= ~f;
403     }
404 
GetDivisionX() const405     short GetDivisionX() const   { return m_nDivisionX; }
SetDivisionX(short n)406     void  SetDivisionX( short n ){ m_nDivisionX = n; }
GetDivisionY() const407     short GetDivisionY() const   { return m_nDivisionY; }
SetDivisionY(short n)408     void  SetDivisionY( short n ){ m_nDivisionY = n; }
409 
410     // Default margin left and above document: 284 twips == 5.0 mm.
411     static constexpr sal_uInt16 defDocumentBorder = 284;
412     // Default gap between pages: 284 twips == 5.0 mm.
413     static constexpr sal_uInt16 defGapBetweenPages = 284;
414     // Minimum edge-to-text distance: 22 twips == 0.4 mm.
415     static constexpr sal_uInt16 minGapBetweenPages = 22;
416 
GetDocumentBorder() const417     sal_uInt16 GetDocumentBorder() const { return IsWhitespaceHidden() ? minGapBetweenPages : defDocumentBorder; }
GetGapBetweenPages() const418     sal_uInt16 GetGapBetweenPages() const { return IsWhitespaceHidden() ? minGapBetweenPages : defGapBetweenPages; }
419 
GetPagePrevRow() const420     sal_uInt8  GetPagePrevRow() const      { return m_nPagePreviewRow; }
SetPagePrevRow(sal_uInt8 n)421     void  SetPagePrevRow( sal_uInt8 n ) { m_nPagePreviewRow = n; }
GetPagePrevCol() const422     sal_uInt8  GetPagePrevCol() const      { return m_nPagePreviewCol; }
SetPagePrevCol(sal_uInt8 n)423     void  SetPagePrevCol( sal_uInt8 n ) { m_nPagePreviewCol = n; }
IsReadonly() const424     bool         IsReadonly() const { return m_bReadonly; }
SetReadonly(bool bSet)425     void         SetReadonly(bool bSet) { m_bReadonly = bSet; }
426 
IsSelectionInReadonly() const427     bool         IsSelectionInReadonly() const {return m_bSelectionInReadonly;}
SetSelectionInReadonly(bool bSet)428     void         SetSelectionInReadonly(bool bSet) {m_bSelectionInReadonly = bSet;}
429 
IsFormView() const430     bool         IsFormView() const { return mbFormView; }
SetFormView(bool bSet)431     void         SetFormView( bool bSet ) { mbFormView = bSet; }
432 
getBrowseMode() const433     bool  getBrowseMode() const { return mbBrowseMode; }
setBrowseMode(bool bSet)434     void  setBrowseMode(bool bSet) { mbBrowseMode = bSet; }
IsPagePrevBookview() const435     bool  IsPagePrevBookview() const { return mbBookView; }
SetPagePrevBookview(bool bSet)436     void  SetPagePrevBookview(bool bSet) { mbBookView = bSet; }
437 
438     static bool IsAutoCompleteWords();
439 
IsViewLayoutBookMode() const440     bool   IsViewLayoutBookMode() const { return mbViewLayoutBookMode; }
SetViewLayoutBookMode(bool bNew)441     void   SetViewLayoutBookMode( bool bNew ) { mbViewLayoutBookMode = bNew; }
GetViewLayoutColumns() const442     sal_uInt16 GetViewLayoutColumns() const { return mnViewLayoutColumns; }
SetViewLayoutColumns(sal_uInt16 nNew)443     void   SetViewLayoutColumns( sal_uInt16 nNew ) { mnViewLayoutColumns = nNew; }
IsHideWhitespaceMode() const444     bool   IsHideWhitespaceMode() const { return mbHideWhitespaceMode; }
SetHideWhitespaceMode(bool bMode)445     void   SetHideWhitespaceMode( bool bMode ) { mbHideWhitespaceMode = bMode; }
446 
447     /// The rules that allow for hiding whitespace.
CanHideWhitespace() const448     bool   CanHideWhitespace() const { return !IsMultipageView(); }
IsWhitespaceHidden() const449     bool   IsWhitespaceHidden() const { return IsHideWhitespaceMode() && !IsMultipageView(); }
IsMultipageView() const450     bool   IsMultipageView() const { return IsViewLayoutBookMode() ||
451                                             GetViewLayoutColumns() == 0; }
452 
453 #ifdef DBG_UTIL
454     // Correspond to statements in ui/config/cfgvw.src.
IsTest1() const455     bool IsTest1() const     { return m_bTest1; }
IsTest2() const456     bool IsTest2() const     { return m_bTest2; }
IsTest3() const457     bool IsTest3() const     { return m_bTest3; }
IsTest4() const458     bool IsTest4() const     { return m_bTest4; }
IsTest5() const459     bool IsTest5() const     { return m_bTest5; }
IsTest6() const460     bool IsTest6() const     { return m_bTest6; }
IsTest7() const461     bool IsTest7() const     { return m_bTest7; }
IsTest8() const462     bool IsTest8() const     { return m_bTest8; }
IsTest10() const463     bool IsTest10() const    { return m_bTest10; }
464 #endif
465 
GetZoom() const466     sal_uInt16 GetZoom() const    { return m_nZoom; }
SetZoom(sal_uInt16 n)467     void   SetZoom( sal_uInt16 n ){ m_nZoom = n; }
468 
469     static void DrawRect( OutputDevice* pOut, const SwRect &rRect, ::Color nCol );
470     static void DrawRectPrinter( OutputDevice* pOut, const SwRect& rRect );
471 
472     SwViewOption& operator=( const SwViewOption &rOpt );
473 
474     // Compare methods.
475     bool IsEqualFlags ( const SwViewOption &rOpt ) const;
476     inline bool operator == ( const SwViewOption &rOpt ) const;
operator !=(const SwViewOption & rOpt) const477     bool operator != ( const SwViewOption &rOpt ) const  { return !(*this == rOpt); }
478 
479     // Options from nUIOptions
IsViewVScrollBar() const480     bool    IsViewVScrollBar() const
481         {
482 #if HAVE_FEATURE_DESKTOP
483             return bool(m_nUIOptions & ViewOptFlags2::VScrollbar);
484 #else
485             return false;
486 #endif
487         }
IsViewHScrollBar() const488     bool    IsViewHScrollBar() const
489         {
490 #if HAVE_FEATURE_DESKTOP
491             return bool(m_nUIOptions & ViewOptFlags2::HScrollbar);
492 #else
493             return false;
494 #endif
495         }
IsKeepRatio() const496     bool    IsKeepRatio()      const
497         { return bool(m_nUIOptions & ViewOptFlags2::KeepAspectRatio); }
IsGrfKeepZoom() const498     bool    IsGrfKeepZoom()    const
499         { return bool(m_nUIOptions & ViewOptFlags2::GrfKeepZoom); }
IsShowContentTips() const500     bool    IsShowContentTips() const
501         { return bool(m_nUIOptions & ViewOptFlags2::ContentTips); }
IsPrtFormat() const502     bool    IsPrtFormat() const
503         { return bool(m_nUIOptions & ViewOptFlags2::PrintFormat); }
IsShowScrollBarTips() const504     bool    IsShowScrollBarTips() const
505         { return bool(m_nUIOptions & ViewOptFlags2::ScrollbarTips); }
506 
GetZoomType() const507     SvxZoomType    GetZoomType()      const { return m_eZoom; }
508 
GetTableDest() const509     sal_uInt8   GetTableDest() const    { return m_nTableDestination; }
510 
SetViewVScrollBar(bool b)511     void   SetViewVScrollBar(bool b)
512         { SetUIOption(b, ViewOptFlags2::VScrollbar); }
SetViewHScrollBar(bool b)513     void   SetViewHScrollBar(bool b)
514         { SetUIOption(b, ViewOptFlags2::HScrollbar); }
SetKeepRatio(bool b)515     void   SetKeepRatio     (bool b)
516         { SetUIOption(b, ViewOptFlags2::KeepAspectRatio); }
SetGrfKeepZoom(bool b)517     void   SetGrfKeepZoom   (bool b)
518         { SetUIOption(b, ViewOptFlags2::GrfKeepZoom); }
SetShowContentTips(bool b)519     void SetShowContentTips( bool b)
520         { SetUIOption(b, ViewOptFlags2::ContentTips); }
SetPrtFormat(bool b)521     void SetPrtFormat( bool b)
522         { SetUIOption(b, ViewOptFlags2::PrintFormat); }
SetShowScrollBarTips(bool b)523     void SetShowScrollBarTips( bool b)
524         { SetUIOption(b, ViewOptFlags2::ScrollbarTips); }
SetUIOption(bool b,ViewOptFlags2 f)525     void SetUIOption( bool b, ViewOptFlags2 f)
526     {
527         if (b)
528             m_nUIOptions |= f;
529         else
530             m_nUIOptions &= ~f;
531     }
532 
SetZoomType(SvxZoomType eZoom_)533     void            SetZoomType     (SvxZoomType eZoom_){ m_eZoom = eZoom_;  }
SetTableDest(sal_uInt8 nNew)534     void            SetTableDest( sal_uInt8 nNew )    { m_nTableDestination = nNew;  }
535 
GetSymbolFont() const536     const OUString& GetSymbolFont() const {return m_sSymbolFont;}
SetSymbolFont(const OUString & sSet)537     void            SetSymbolFont(const OUString& sSet) {m_sSymbolFont = sSet;}
538 
GetRetoucheColor() const539     const Color&    GetRetoucheColor() const        { return m_aRetouchColor;}
SetRetoucheColor(const Color & r)540     void            SetRetoucheColor(const Color&r) { m_aRetouchColor = r;   }
541 
IsViewAnyRuler() const542     bool        IsViewAnyRuler() const
543         {
544 #if HAVE_FEATURE_DESKTOP
545             return bool(m_nUIOptions & ViewOptFlags2::AnyRuler);
546 #else
547             return false;
548 #endif
549         }
SetViewAnyRuler(bool bSet)550     void            SetViewAnyRuler(bool bSet)
551                         { SetUIOption(bSet, ViewOptFlags2::AnyRuler);}
552 
IsViewHRuler(bool bDirect=false) const553     bool        IsViewHRuler(bool bDirect = false)     const
554                         {
555 #if HAVE_FEATURE_DESKTOP
556                             return bDirect
557                                    ? bool(m_nUIOptions & ViewOptFlags2::HRuler)
558                                    : !m_bReadonly && (m_nUIOptions & (ViewOptFlags2::AnyRuler|ViewOptFlags2::HRuler)) == (ViewOptFlags2::AnyRuler|ViewOptFlags2::HRuler);
559 #else
560                             (void) bDirect;
561                             return false;
562 #endif
563                         }
SetViewHRuler(bool b)564     void            SetViewHRuler   (bool b)
565                         { SetUIOption(b, ViewOptFlags2::HRuler ); }
566 
IsViewVRuler(bool bDirect=false) const567     bool            IsViewVRuler(bool bDirect = false) const
568                         {
569 #if HAVE_FEATURE_DESKTOP
570                             return bDirect
571                                    ? bool(m_nUIOptions & ViewOptFlags2::VRuler)
572                                    : !m_bReadonly && (m_nUIOptions & (ViewOptFlags2::AnyRuler|ViewOptFlags2::VRuler)) == (ViewOptFlags2::AnyRuler|ViewOptFlags2::VRuler);
573 #else
574                             (void) bDirect;
575                             return false;
576 #endif
577                         }
SetViewVRuler(bool b)578     void            SetViewVRuler     (bool b)
579                         { SetUIOption(b, ViewOptFlags2::VRuler); }
580 
581     // ShadowCursor, switch on/off, get/set color/mode.
IsShadowCursor() const582     bool    IsShadowCursor()    const
583         { return bool(m_nUIOptions & ViewOptFlags2::ShadowCursor); }
SetShadowCursor(bool b)584     void   SetShadowCursor(bool b)
585         { SetUIOption(b, ViewOptFlags2::ShadowCursor); }
586 
587     //move vertical ruler to the right
IsVRulerRight() const588     bool    IsVRulerRight()    const
589         { return bool(m_nUIOptions & ViewOptFlags2::VRulerRight); }
SetVRulerRight(bool b)590     void   SetVRulerRight(bool b)
591         { SetUIOption(b, ViewOptFlags2::VRulerRight); }
592 
IsStarOneSetting() const593     bool            IsStarOneSetting() const {return m_bStarOneSetting; }
SetStarOneSetting(bool bSet)594     void            SetStarOneSetting(bool bSet) {m_bStarOneSetting = bSet; }
595 
IsPagePreview() const596     bool            IsPagePreview() const {return m_bIsPagePreview; }
SetPagePreview(bool bSet)597     void            SetPagePreview(bool bSet) { m_bIsPagePreview= bSet; }
598 
GetShdwCursorFillMode() const599     sal_uInt8           GetShdwCursorFillMode() const { return m_nShadowCursorFillMode; }
SetShdwCursorFillMode(sal_uInt8 nMode)600     void            SetShdwCursorFillMode( sal_uInt8 nMode ) { m_nShadowCursorFillMode = nMode; };
601 
IsShowPlaceHolderFields() const602     bool        IsShowPlaceHolderFields() const { return m_bShowPlaceHolderFields; }
SetShowPlaceHolderFields(bool bSet)603     void            SetShowPlaceHolderFields(bool bSet) { m_bShowPlaceHolderFields = bSet; }
604 
605     static Color&   GetDocColor();
606     static Color&   GetDocBoundariesColor();
607     static Color&   GetAppBackgroundColor();
608     static Color&   GetObjectBoundariesColor();
609     static Color&   GetTableBoundariesColor();
610     static Color&   GetIndexShadingsColor();
611     static Color&   GetLinksColor();
612     static Color&   GetVisitedLinksColor();
613     static Color&   GetDirectCursorColor();
614     static Color&   GetTextGridColor();
615     static Color&   GetSpellColor();
616     static Color&   GetSmarttagColor();
617     static Color&   GetShadowColor();
618     static Color&   GetFontColor();
619     static Color&   GetFieldShadingsColor();
620     static Color&   GetSectionBoundColor();
621     static Color&   GetPageBreakColor();
622     static Color&   GetHeaderFooterMarkColor();
623 
624     static bool     IsAppearanceFlag(ViewOptFlags nFlag);
625 
IsDocBoundaries()626     static bool     IsDocBoundaries()     {return IsAppearanceFlag(ViewOptFlags::DocBoundaries);}
IsObjectBoundaries()627     static bool     IsObjectBoundaries()  {return IsAppearanceFlag(ViewOptFlags::ObjectBoundaries);}
IsTableBoundaries()628     static bool     IsTableBoundaries()   {return IsAppearanceFlag(ViewOptFlags::TableBoundaries );}
IsIndexShadings()629     static bool     IsIndexShadings()     {return IsAppearanceFlag(ViewOptFlags::IndexShadings   );}
IsLinks()630     static bool     IsLinks()             {return IsAppearanceFlag(ViewOptFlags::Links            );}
IsVisitedLinks()631     static bool     IsVisitedLinks()      {return IsAppearanceFlag(ViewOptFlags::VisitedLinks    );}
IsFieldShadings()632     static bool     IsFieldShadings()     {return IsAppearanceFlag(ViewOptFlags::FieldShadings);}
IsSectionBoundaries()633     static bool     IsSectionBoundaries() {return IsAppearanceFlag(ViewOptFlags::SectionBoundaries);}
IsShadow()634     static bool     IsShadow()            {return IsAppearanceFlag(ViewOptFlags::Shadow           );}
635 
636     static void     SetAppearanceFlag(ViewOptFlags nFlag, bool bSet, bool bSaveInConfig = false);
637 
SetDocBoundaries(bool bSet)638     static void     SetDocBoundaries(bool bSet)   {SetAppearanceFlag(ViewOptFlags::DocBoundaries, bSet);}
639 
640     static void     ApplyColorConfigValues(const svtools::ColorConfig& rConfig);
641 };
642 
operator ==(const SwViewOption & rOpt) const643 inline bool SwViewOption::operator==( const SwViewOption &rOpt ) const
644 {
645     return IsEqualFlags( rOpt ) && m_nZoom == rOpt.GetZoom();
646 }
647 
SetUIOptions(const SwViewOption & rVOpt)648 inline void SwViewOption::SetUIOptions( const SwViewOption& rVOpt )
649 {
650     m_nUIOptions = rVOpt.m_nUIOptions;
651     m_nTableDestination = rVOpt.m_nTableDestination;
652     m_nShadowCursorFillMode = rVOpt.m_nShadowCursorFillMode;
653 }
654 
655 // Helper function for checking HTML-capabilities.
656 SW_DLLPUBLIC sal_uInt16     GetHtmlMode(const SwDocShell*);
657 
658 #endif
659 
660 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
661