LibreOffice Module sw (master) 1
viewopt.cxx
Go to the documentation of this file.
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#include <sfx2/htmlmode.hxx>
21#include <svtools/htmlcfg.hxx>
22
23#include <editeng/editids.hrc>
24#include <editeng/svxacorr.hxx>
25#include <officecfg/Office/Common.hxx>
27#include <vcl/outdev.hxx>
28#include <swmodule.hxx>
29#include <viewopt.hxx>
30#include <wdocsh.hxx>
31#include <swrect.hxx>
32#include <crstate.hxx>
33#include <authratr.hxx>
34#include <svtools/colorcfg.hxx>
38
39#include <editeng/acorrcfg.hxx>
40#include <comphelper/lok.hxx>
42
45Color SwViewOption::s_aDocColor(COL_LIGHTGRAY);
62
64sal_uInt16 SwViewOption::s_nPixelTwips = 0; // one pixel on the screen
65
67{
68 return m_nCoreOptions == rOpt.m_nCoreOptions
70 && m_aSnapSize == rOpt.m_aSnapSize
72 && m_nDivisionX == rOpt.GetDivisionX()
73 && m_nDivisionY == rOpt.GetDivisionY()
77 && mbFormView == rOpt.IsFormView()
78 && mbBrowseMode == rOpt.getBrowseMode()
82 && m_bIdle == rOpt.m_bIdle
84#ifdef DBG_UTIL
85 // correspond to the statements in ui/config/cfgvw.src
86 && m_bTest1 == rOpt.IsTest1()
87 && m_bTest2 == rOpt.IsTest2()
88 && m_bTest3 == rOpt.IsTest3()
89 && m_bTest4 == rOpt.IsTest4()
90 && m_bTest5 == rOpt.IsTest5()
91 && m_bTest6 == rOpt.IsTest6()
92 && m_bTest7 == rOpt.IsTest7()
93 && m_bTest8 == rOpt.IsTest8()
94 && m_bTest10 == rOpt.IsTest10()
95#endif
96 ;
97}
98
100{
102}
103
105{
107}
108
110 const SwRect &rRect, ::Color nCol )
111{
112 if ( pOut->GetOutDevType() != OUTDEV_PRINTER )
113 {
114 const Color aCol( nCol );
115 const Color aOldColor( pOut->GetFillColor() );
116 pOut->SetFillColor( aCol );
117 pOut->DrawRect( rRect.SVRect() );
118 pOut->SetFillColor( aOldColor );
119 }
120 else
121 DrawRectPrinter( pOut, rRect );
122}
123
125 const SwRect &rRect )
126{
127 Color aOldColor(pOut->GetLineColor());
128 Color aOldFillColor( pOut->GetFillColor() );
129 pOut->SetLineColor( COL_BLACK );
130 pOut->SetFillColor( COL_TRANSPARENT);
131 pOut->DrawRect( rRect.SVRect() );
132 pOut->SetFillColor( aOldFillColor );
133 pOut->SetLineColor( aOldColor );
134}
135
137{
138 assert(pOut && "no Outdev");
139 return sal_uInt16(pOut->GetTextWidth(" "));
140}
141
142void SwViewOption::PaintPostIts( OutputDevice *pOut, const SwRect &rRect, bool bIsScript )
143{
144 if( !(pOut && bIsScript) )
145 return;
146
147 Color aOldLineColor( pOut->GetLineColor() );
148 pOut->SetLineColor( COL_GRAY );
149 // to make it look nice, we subtract two pixels everywhere
150 sal_uInt16 nPix = s_nPixelTwips * 2;
151 if( rRect.Width() <= 2 * nPix || rRect.Height() <= 2 * nPix )
152 nPix = 0;
153 const Point aTopLeft( rRect.Left() + nPix, rRect.Top() + nPix );
154 const Point aBotRight( rRect.Right() - nPix, rRect.Bottom() - nPix );
155 const SwRect aRect( aTopLeft, aBotRight );
157 pOut->SetLineColor( aOldLineColor );
158}
159
161 m_sSymbolFont( "symbol" ),
162 m_aRetouchColor( COL_TRANSPARENT ),
163 mnViewLayoutColumns( 0 ),
164 m_nPagePreviewRow( 1 ),
165 m_nPagePreviewCol( 2 ),
166 m_nShadowCursorFillMode( SwFillMode::Tab ),
167 m_bReadonly(false),
168 m_bStarOneSetting(false),
169 m_bIsPagePreview(false),
170 m_bSelectionInReadonly(false),
171 mbFormView(false),
172 mbBrowseMode(false),
173 mbBookView(false),
174 mbViewLayoutBookMode(false),
175 mbHideWhitespaceMode(false),
176 m_bShowPlaceHolderFields( true ),
177 m_nZoom( 100 ),
178 m_eZoom( SvxZoomType::PERCENT ),
179 m_nTableDestination(TBL_DEST_CELL)
180{
181 // Initialisation is a little simpler now
182 // all Bits to 0
193
197
203
204 if (!utl::ConfigManager::IsFuzzing() && MeasurementSystem::Metric != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum())
205 {
206 m_aSnapSize.setWidth(720); // 1/2"
207 m_aSnapSize.setHeight(720); // 1/2"
208
209 }
210 else
211 {
212 m_aSnapSize.setWidth(567); // 1 cm
213 m_aSnapSize.setHeight(567); // 1 cm
214 }
216
217 m_bSelectionInReadonly = !utl::ConfigManager::IsFuzzing() && SW_MOD()->GetAccessibilityOptions().IsSelectionInReadonly();
218
219 m_bIdle = true;
220
221 m_nDefaultAnchor = 1; //FLY_TO_CHAR
222
223#ifdef DBG_UTIL
224 // correspond to the statements in ui/config/cfgvw.src
227#endif
230}
231
233{
234 m_bReadonly = false;
236 // #114856# Form view
237 mbFormView = rVOpt.mbFormView;
238 m_nZoom = rVOpt.m_nZoom ;
239 m_aSnapSize = rVOpt.m_aSnapSize ;
241 m_nDivisionX = rVOpt.m_nDivisionX ;
242 m_nDivisionY = rVOpt.m_nDivisionY ;
246 m_eZoom = rVOpt.m_eZoom ;
248 m_nUIOptions = rVOpt.m_nUIOptions ;
255 mbBookView = rVOpt.mbBookView;
260 m_bIdle = rVOpt.m_bIdle;
262
263#ifdef DBG_UTIL
264 m_bTest1 = rVOpt.m_bTest1;
265 m_bTest2 = rVOpt.m_bTest2;
266 m_bTest3 = rVOpt.m_bTest3;
267 m_bTest4 = rVOpt.m_bTest4;
268 m_bTest5 = rVOpt.m_bTest5;
269 m_bTest6 = rVOpt.m_bTest6;
270 m_bTest7 = rVOpt.m_bTest7;
271 m_bTest8 = rVOpt.m_bTest8;
272 m_bTest10 = rVOpt.m_bTest10;
273#endif
274}
275
277{
278 // #114856# Form view
279 mbFormView = rVOpt.mbFormView ;
280 m_nZoom = rVOpt.m_nZoom ;
281 m_aSnapSize = rVOpt.m_aSnapSize ;
283 m_nDivisionX = rVOpt.m_nDivisionX ;
284 m_nDivisionY = rVOpt.m_nDivisionY ;
288 m_eZoom = rVOpt.m_eZoom ;
290 m_nUIOptions = rVOpt.m_nUIOptions ;
297 mbBookView = rVOpt.mbBookView;
302 m_bIdle = rVOpt.m_bIdle;
304
305#ifdef DBG_UTIL
306 m_bTest1 = rVOpt.m_bTest1;
307 m_bTest2 = rVOpt.m_bTest2;
308 m_bTest3 = rVOpt.m_bTest3;
309 m_bTest4 = rVOpt.m_bTest4;
310 m_bTest5 = rVOpt.m_bTest5;
311 m_bTest6 = rVOpt.m_bTest6;
312 m_bTest7 = rVOpt.m_bTest7;
313 m_bTest8 = rVOpt.m_bTest8;
314 m_bTest10 = rVOpt.m_bTest10;
315#endif
316 return *this;
317}
318
320{
321}
322
324{
325 if( !s_nPixelTwips && pWin )
326 {
327 s_nPixelTwips = o3tl::narrowing<sal_uInt16>(pWin->PixelToLogic( Size(1,1) ).Height());
328 }
329}
330
332{
334 return rFlags.bAutoCmpltCollectWords;
335}
336
338{
339 if (b)
341 else
343}
344
346 m_nItemId (SID_ATTR_CHAR_UNDERLINE),
347 m_nAttr (LINESTYLE_SINGLE),
348 m_nColor (COL_TRANSPARENT)
349{
350}
351
352sal_uInt16 GetHtmlMode(const SwDocShell* pShell)
353{
354 sal_uInt16 nRet = 0;
355 if(!pShell || dynamic_cast<const SwWebDocShell*>( pShell) )
356 {
359 {
360 case HTML_CFG_MSIE:
361 nRet |= HTMLMODE_FULL_STYLES;
362 break;
363 case HTML_CFG_NS40:
364 // no special features for this browser
365 break;
366 case HTML_CFG_WRITER:
367 nRet |= HTMLMODE_FULL_STYLES;
368 break;
369 }
370 }
371 return nRet;
372}
373
375{
376 switch ( m_nDefaultAnchor )
377 {
378 case 0:
379 return RndStdIds::FLY_AT_PARA; //0
380 case 1:
381 return RndStdIds::FLY_AT_CHAR; //4
382 case 2:
383 return RndStdIds::FLY_AS_CHAR; //1
384 default:
385 return RndStdIds::FLY_AT_CHAR; //4
386 }//switch
387}
388
390{
391 return s_aDocColor;
392}
393
395{
396 return s_aDocBoundColor;
397}
398
400{
401 return s_aObjectBoundColor;
402}
403
405{
407}
408
410{
411 return s_aTableBoundColor;
412}
413
415{
417}
418
420{
421 return s_aLinksColor;
422}
423
425{
427}
428
430{
432}
433
435{
436 return s_aTextGridColor;
437}
438
440{
441 return s_aSpellColor;
442}
443
445{
446 return s_aSmarttagColor;
447}
448
450{
451 return s_aShadowColor;
452}
453
455{
456 return s_aFontColor;
457}
458
460{
462}
463
465{
467}
468
470{
471 return s_aPageBreakColor;
472}
473
475{
477}
478
480{
482
484 s_aDocBoundColor = aValue.nColor;
486 if(aValue.bIsVisible)
488
490
493 if(aValue.bIsVisible)
495
496 aValue = rConfig.GetColorValue(svtools::TABLEBOUNDARIES);
497 s_aTableBoundColor = aValue.nColor;
498 if(aValue.bIsVisible)
500
503 if(aValue.bIsVisible)
505
506 aValue = rConfig.GetColorValue(svtools::LINKS);
507 s_aLinksColor = aValue.nColor;
508 if(aValue.bIsVisible)
510
511 aValue = rConfig.GetColorValue(svtools::LINKSVISITED);
513 if(aValue.bIsVisible)
515
516 aValue = rConfig.GetColorValue(svtools::SHADOWCOLOR);
517 s_aShadowColor = aValue.nColor;
518 if(aValue.bIsVisible)
520
522
524
526
528
530
533 if(aValue.bIsVisible)
535
538 if(aValue.bIsVisible)
540
542 s_aPageBreakColor = aValue.nColor;
543
546
548}
549
550void SwViewOption::SetAppearanceFlag(ViewOptFlags nFlag, bool bSet, bool bSaveInConfig )
551{
552 if(bSet)
553 s_nAppearanceFlags |= nFlag;
554 else
555 s_nAppearanceFlags &= ~nFlag;
556 if(!bSaveInConfig)
557 return;
558
559 //create an editable svtools::ColorConfig and store the change
560 svtools::EditableColorConfig aEditableConfig;
561 struct FlagToConfig_Impl
562 {
563 ViewOptFlags nFlag;
565 };
566 static const FlagToConfig_Impl aFlags[] =
567 {
578 };
579 sal_uInt16 nPos = 0;
580 while(aFlags[nPos].nFlag != ViewOptFlags::NONE)
581 {
582 if(nFlag & aFlags[nPos].nFlag)
583 {
584 svtools::ColorConfigValue aValue = aEditableConfig.GetColorValue(aFlags[nPos].eEntry);
585 aValue.bIsVisible = bSet;
586 aEditableConfig.SetColorValue(aFlags[nPos].eEntry, aValue);
587 }
588 nPos++;
589 }
590}
591
593{
594 return bool(s_nAppearanceFlags & nFlag);
595}
596
597namespace{
598rtl::Reference<comphelper::ConfigurationListener> const & getWCOptionListener()
599{
600 static rtl::Reference<comphelper::ConfigurationListener> xListener(new comphelper::ConfigurationListener("/org.openoffice.Office.Writer/Cursor/Option"));
601 return xListener;
602}
603}
604
606{
607 static comphelper::ConfigurationListenerProperty<bool> gIgnoreProtectedArea(getWCOptionListener(), "IgnoreProtectedArea");
608 return gIgnoreProtectedArea.get();
609}
610
611/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
SvxAutoCorrect * GetAutoCorrect()
static SvxAutoCorrCfg & Get()
SvxSwAutoFormatFlags & GetSwFlags()
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void Height(tools::Long nNew)
Definition: swrect.hxx:193
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
void Right(const tools::Long nRight)
Definition: swrect.hxx:202
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:211
tools::Rectangle SVRect() const
Definition: swrect.hxx:292
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
void Width(tools::Long nNew)
Definition: swrect.hxx:189
static Color & GetObjectBoundariesColor()
Definition: viewopt.cxx:399
OUString m_sSymbolFont
Definition: viewopt.hxx:154
static Color s_aVisitedLinksColor
Definition: viewopt.hxx:139
static void PaintPostIts(OutputDevice *pOut, const SwRect &rRect, bool bIsScript)
Definition: viewopt.cxx:142
static Color & GetVisitedLinksColor()
Definition: viewopt.cxx:424
bool m_bTest6
Definition: viewopt.hxx:192
static bool IsIgnoreProtectedArea()
Definition: viewopt.cxx:605
static Color & GetTableBoundariesColor()
Definition: viewopt.cxx:409
bool m_bIsPagePreview
Definition: viewopt.hxx:168
static Color & GetIndexShadingsColor()
Definition: viewopt.cxx:414
static Color & GetLinksColor()
Definition: viewopt.cxx:419
static Color s_aPageBreakColor
Definition: viewopt.hxx:146
sal_uInt8 m_nPagePreviewCol
Definition: viewopt.hxx:164
static Color & GetSmarttagColor()
Definition: viewopt.cxx:444
bool IsTest3() const
Definition: viewopt.hxx:496
bool m_bTest4
Definition: viewopt.hxx:190
static Color & GetSectionBoundColor()
Definition: viewopt.cxx:464
static bool IsAutoCompleteWords()
Definition: viewopt.cxx:331
static Color s_aTextGridColor
Definition: viewopt.hxx:141
bool mbBookView
Definition: viewopt.hxx:172
SwFillMode m_nShadowCursorFillMode
Definition: viewopt.hxx:165
static Color s_aIndexShadingsColor
Definition: viewopt.hxx:137
sal_uInt16 m_nZoom
Definition: viewopt.hxx:180
bool m_bTest3
Definition: viewopt.hxx:189
bool IsShowOutlineContentVisibilityButton() const
Definition: viewopt.cxx:99
bool mbFormView
Definition: viewopt.hxx:170
static Color s_aFontColor
Definition: viewopt.hxx:136
static Color s_aShadowColor
Definition: viewopt.hxx:148
SwViewOption & operator=(const SwViewOption &rOpt)
Definition: viewopt.cxx:276
short GetDivisionY() const
Definition: viewopt.hxx:446
static Color s_aFieldShadingsColor
Definition: viewopt.hxx:144
ViewOptCoreFlags2 m_nCore2Options
Definition: viewopt.hxx:156
static Color s_aTableBoundColor
Definition: viewopt.hxx:135
bool m_bReadonly
Definition: viewopt.hxx:166
static Color & GetDocBoundariesColor()
Definition: viewopt.cxx:394
static void Init(const OutputDevice *pWin)
Definition: viewopt.cxx:323
sal_uInt8 m_nPagePreviewRow
Definition: viewopt.hxx:163
sal_uInt16 mnViewLayoutColumns
Definition: viewopt.hxx:160
static Color & GetSpellColor()
Definition: viewopt.cxx:439
sal_uInt8 GetPagePrevCol() const
Definition: viewopt.hxx:461
static bool IsAppearanceFlag(ViewOptFlags nFlag)
Definition: viewopt.cxx:592
ViewOptFlags2 m_nUIOptions
Definition: viewopt.hxx:157
sal_Int32 m_nDefaultAnchor
Definition: viewopt.hxx:177
RndStdIds GetDefaultAnchorType() const
Definition: viewopt.cxx:374
const Color & GetRetoucheColor() const
Definition: viewopt.hxx:578
bool IsTest7() const
Definition: viewopt.hxx:500
bool IsTreatSubOutlineLevelsAsContent() const
Definition: viewopt.cxx:104
sal_uInt8 GetPagePrevRow() const
Definition: viewopt.hxx:459
static Color & GetPageBreakColor()
Definition: viewopt.cxx:469
bool m_bTest7
Definition: viewopt.hxx:193
static Color & GetDocColor()
Definition: viewopt.cxx:389
bool m_bShowPlaceHolderFields
Definition: viewopt.hxx:175
static Color & GetShadowColor()
Definition: viewopt.cxx:449
bool mbHideWhitespaceMode
Definition: viewopt.hxx:174
bool m_bTest10
Definition: viewopt.hxx:195
bool IsTest8() const
Definition: viewopt.hxx:501
bool m_bTest8
Definition: viewopt.hxx:194
SvxZoomType m_eZoom
Definition: viewopt.hxx:181
static Color & GetHeaderFooterMarkColor()
Definition: viewopt.cxx:474
static Color s_aDocBoundColor
Definition: viewopt.hxx:132
ViewOptFlags1 m_nCoreOptions
Definition: viewopt.hxx:155
bool m_bTest1
Definition: viewopt.hxx:187
short m_nDivisionY
Definition: viewopt.hxx:162
bool mbBrowseMode
Definition: viewopt.hxx:171
bool getBrowseMode() const
Definition: viewopt.hxx:472
short m_nDivisionX
Definition: viewopt.hxx:161
bool m_bIdle
Definition: viewopt.hxx:176
void SetOnlineSpell(bool b)
Definition: viewopt.cxx:337
static Color s_aSmarttagColor
Definition: viewopt.hxx:143
bool m_bStarOneSetting
Definition: viewopt.hxx:167
bool IsTest5() const
Definition: viewopt.hxx:498
bool IsTest1() const
Definition: viewopt.hxx:494
static void DrawRectPrinter(OutputDevice *pOut, const SwRect &rRect)
Definition: viewopt.cxx:124
static void DrawRect(OutputDevice *pOut, const SwRect &rRect, ::Color nCol)
Definition: viewopt.cxx:109
sal_uInt8 m_nTableDestination
Definition: viewopt.hxx:183
static Color s_aDocColor
Definition: viewopt.hxx:131
Size m_aSnapSize
Definition: viewopt.hxx:159
bool IsTest10() const
Definition: viewopt.hxx:502
static Color s_aHeaderFooterMarkColor
Definition: viewopt.hxx:149
bool m_bTest5
Definition: viewopt.hxx:191
Color m_aRetouchColor
Definition: viewopt.hxx:158
static Color s_aObjectBoundColor
Definition: viewopt.hxx:133
static Color s_aDirectCursorColor
Definition: viewopt.hxx:140
static Color s_aAppBackgroundColor
Definition: viewopt.hxx:134
static Color & GetFieldShadingsColor()
Definition: viewopt.cxx:459
static Color s_aLinksColor
Definition: viewopt.hxx:138
static ViewOptFlags s_nAppearanceFlags
Definition: viewopt.hxx:151
static Color s_aScriptIndicatorColor
Definition: viewopt.hxx:147
static Color s_aSectionBoundColor
Definition: viewopt.hxx:145
static void ApplyColorConfigValues(const svtools::ColorConfig &rConfig)
Definition: viewopt.cxx:479
bool IsEqualFlags(const SwViewOption &rOpt) const
Definition: viewopt.cxx:66
bool IsFormView() const
Definition: viewopt.hxx:469
static sal_uInt16 GetPostItsWidth(const OutputDevice *pOut)
Definition: viewopt.cxx:136
short GetDivisionX() const
Definition: viewopt.hxx:444
static Color & GetTextGridColor()
Definition: viewopt.cxx:434
bool IsTest4() const
Definition: viewopt.hxx:497
bool m_bSelectionInReadonly
Definition: viewopt.hxx:169
static Color & GetAppBackgroundColor()
Definition: viewopt.cxx:404
bool m_bTest2
Definition: viewopt.hxx:188
static Color s_aSpellColor
Definition: viewopt.hxx:142
static void SetAppearanceFlag(ViewOptFlags nFlag, bool bSet, bool bSaveInConfig=false)
Definition: viewopt.cxx:550
static sal_uInt16 s_nPixelTwips
Definition: viewopt.hxx:152
bool IsTest6() const
Definition: viewopt.hxx:499
static Color & GetFontColor()
Definition: viewopt.cxx:454
static Color & GetDirectCursorColor()
Definition: viewopt.cxx:429
bool IsTest2() const
Definition: viewopt.hxx:495
bool mbViewLayoutBookMode
Definition: viewopt.hxx:173
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
void SetColorValue(ColorConfigEntry eEntry, const ColorConfigValue &rValue)
const ColorConfigValue & GetColorValue(ColorConfigEntry eEntry) const
static bool IsFuzzing()
constexpr ::Color COL_GRAY(0x80, 0x80, 0x80)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
SwFillMode
Definition: crstate.hxx:29
LINESTYLE_SINGLE
#define HTML_CFG_NS40
#define HTML_CFG_WRITER
#define HTML_CFG_MSIE
HTMLMODE_SOME_STYLES
HTMLMODE_ON
HTMLMODE_FULL_STYLES
sal_uInt16 nPos
sal_uInt16 GetExportMode()
WRITERDIRECTCURSOR
WRITERFIELDSHADINGS
WRITERSCRIPTINDICATOR
ColorConfigEntryCount
WRITERHEADERFOOTERMARK
WRITERSECTIONBOUNDARIES
const LocaleDataWrapper & GetLocaleData()
OUTDEV_PRINTER
RndStdIds
#define SW_MOD()
Definition: swmodule.hxx:256
constexpr OUStringLiteral PERCENT(u"Percent")
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:352
ViewOptFlags
Definition: viewopt.hxx:113
#define TBL_DEST_CELL
Definition: viewopt.hxx:108
ViewOptFlags1
Definition: viewopt.hxx:38
@ TreatSubOutlineLevelsAsContent
@ ShowOutlineContentVisibilityButton
oslFileHandle & pOut
SvxZoomType