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);
63
65sal_uInt16 SwViewOption::s_nPixelTwips = 0; // one pixel on the screen
66
68{
69 return m_nCoreOptions == rOpt.m_nCoreOptions
71 && m_aSnapSize == rOpt.m_aSnapSize
73 && m_nDivisionX == rOpt.GetDivisionX()
74 && m_nDivisionY == rOpt.GetDivisionY()
78 && mbFormView == rOpt.IsFormView()
79 && mbBrowseMode == rOpt.getBrowseMode()
83 && m_bIdle == rOpt.m_bIdle
85#ifdef DBG_UTIL
86 // correspond to the statements in ui/config/cfgvw.src
87 && m_bTest1 == rOpt.IsTest1()
88 && m_bTest2 == rOpt.IsTest2()
89 && m_bTest3 == rOpt.IsTest3()
90 && m_bTest4 == rOpt.IsTest4()
91 && m_bTest5 == rOpt.IsTest5()
92 && m_bTest6 == rOpt.IsTest6()
93 && m_bTest7 == rOpt.IsTest7()
94 && m_bTest8 == rOpt.IsTest8()
95 && m_bTest10 == rOpt.IsTest10()
96#endif
97 ;
98}
99
101{
103}
104
106{
108}
109
111 const SwRect &rRect, ::Color nCol )
112{
113 if ( pOut->GetOutDevType() != OUTDEV_PRINTER )
114 {
115 const Color aCol( nCol );
116 const Color aOldColor( pOut->GetFillColor() );
117 pOut->SetFillColor( aCol );
118 pOut->DrawRect( rRect.SVRect() );
119 pOut->SetFillColor( aOldColor );
120 }
121 else
122 DrawRectPrinter( pOut, rRect );
123}
124
126 const SwRect &rRect )
127{
128 Color aOldColor(pOut->GetLineColor());
129 Color aOldFillColor( pOut->GetFillColor() );
130 pOut->SetLineColor( COL_BLACK );
131 pOut->SetFillColor( COL_TRANSPARENT);
132 pOut->DrawRect( rRect.SVRect() );
133 pOut->SetFillColor( aOldFillColor );
134 pOut->SetLineColor( aOldColor );
135}
136
138{
139 assert(pOut && "no Outdev");
140 return sal_uInt16(pOut->GetTextWidth(" "));
141}
142
143void SwViewOption::PaintPostIts( OutputDevice *pOut, const SwRect &rRect, bool bIsScript )
144{
145 if( !(pOut && bIsScript) )
146 return;
147
148 Color aOldLineColor( pOut->GetLineColor() );
149 pOut->SetLineColor( COL_GRAY );
150 // to make it look nice, we subtract two pixels everywhere
151 sal_uInt16 nPix = s_nPixelTwips * 2;
152 if( rRect.Width() <= 2 * nPix || rRect.Height() <= 2 * nPix )
153 nPix = 0;
154 const Point aTopLeft( rRect.Left() + nPix, rRect.Top() + nPix );
155 const Point aBotRight( rRect.Right() - nPix, rRect.Bottom() - nPix );
156 const SwRect aRect( aTopLeft, aBotRight );
158 pOut->SetLineColor( aOldLineColor );
159}
160
162 m_sSymbolFont( "symbol" ),
163 m_aRetouchColor( COL_TRANSPARENT ),
164 mnViewLayoutColumns( 0 ),
165 m_nPagePreviewRow( 1 ),
166 m_nPagePreviewCol( 2 ),
167 m_nShadowCursorFillMode( SwFillMode::Tab ),
168 m_bReadonly(false),
169 m_bStarOneSetting(false),
170 m_bIsPagePreview(false),
171 m_bSelectionInReadonly(false),
172 mbFormView(false),
173 mbBrowseMode(false),
174 mbBookView(false),
175 mbViewLayoutBookMode(false),
176 mbHideWhitespaceMode(false),
177 m_bShowPlaceHolderFields( true ),
178 m_nZoom( 100 ),
179 m_eZoom( SvxZoomType::PERCENT ),
180 m_nTableDestination(TBL_DEST_CELL)
181{
185
191
192 if (!utl::ConfigManager::IsFuzzing() && MeasurementSystem::Metric != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum())
193 {
194 m_aSnapSize.setWidth(720); // 1/2"
195 m_aSnapSize.setHeight(720); // 1/2"
196
197 }
198 else
199 {
200 m_aSnapSize.setWidth(567); // 1 cm
201 m_aSnapSize.setHeight(567); // 1 cm
202 }
204
205 m_bSelectionInReadonly = !utl::ConfigManager::IsFuzzing() && SW_MOD()->GetAccessibilityOptions().IsSelectionInReadonly();
206
207 m_bIdle = true;
208
209 m_nDefaultAnchor = 1; //FLY_TO_CHAR
210
211#ifdef DBG_UTIL
212 // correspond to the statements in ui/config/cfgvw.src
215#endif
218}
219
221{
222 m_bReadonly = false;
224 // #114856# Form view
225 mbFormView = rVOpt.mbFormView;
226 m_nZoom = rVOpt.m_nZoom ;
227 m_aSnapSize = rVOpt.m_aSnapSize ;
229 m_nDivisionX = rVOpt.m_nDivisionX ;
230 m_nDivisionY = rVOpt.m_nDivisionY ;
234 m_eZoom = rVOpt.m_eZoom ;
236 m_nUIOptions = rVOpt.m_nUIOptions ;
243 mbBookView = rVOpt.mbBookView;
248 m_bIdle = rVOpt.m_bIdle;
250
251#ifdef DBG_UTIL
252 m_bTest1 = rVOpt.m_bTest1;
253 m_bTest2 = rVOpt.m_bTest2;
254 m_bTest3 = rVOpt.m_bTest3;
255 m_bTest4 = rVOpt.m_bTest4;
256 m_bTest5 = rVOpt.m_bTest5;
257 m_bTest6 = rVOpt.m_bTest6;
258 m_bTest7 = rVOpt.m_bTest7;
259 m_bTest8 = rVOpt.m_bTest8;
260 m_bTest10 = rVOpt.m_bTest10;
261#endif
262}
263
265{
266 // #114856# Form view
267 mbFormView = rVOpt.mbFormView ;
268 m_nZoom = rVOpt.m_nZoom ;
269 m_aSnapSize = rVOpt.m_aSnapSize ;
271 m_nDivisionX = rVOpt.m_nDivisionX ;
272 m_nDivisionY = rVOpt.m_nDivisionY ;
276 m_eZoom = rVOpt.m_eZoom ;
278 m_nUIOptions = rVOpt.m_nUIOptions ;
285 mbBookView = rVOpt.mbBookView;
290 m_bIdle = rVOpt.m_bIdle;
292
293#ifdef DBG_UTIL
294 m_bTest1 = rVOpt.m_bTest1;
295 m_bTest2 = rVOpt.m_bTest2;
296 m_bTest3 = rVOpt.m_bTest3;
297 m_bTest4 = rVOpt.m_bTest4;
298 m_bTest5 = rVOpt.m_bTest5;
299 m_bTest6 = rVOpt.m_bTest6;
300 m_bTest7 = rVOpt.m_bTest7;
301 m_bTest8 = rVOpt.m_bTest8;
302 m_bTest10 = rVOpt.m_bTest10;
303#endif
304 return *this;
305}
306
308{
309}
310
312{
313 if( !s_nPixelTwips && pWin )
314 {
315 s_nPixelTwips = o3tl::narrowing<sal_uInt16>(pWin->PixelToLogic( Size(1,1) ).Height());
316 }
317}
318
320{
322 return rFlags.bAutoCmpltCollectWords;
323}
324
326 m_nItemId (SID_ATTR_CHAR_UNDERLINE),
327 m_nAttr (LINESTYLE_SINGLE),
328 m_nColor (COL_TRANSPARENT)
329{
330}
331
332sal_uInt16 GetHtmlMode(const SwDocShell* pShell)
333{
334 sal_uInt16 nRet = 0;
335 if(!pShell || dynamic_cast<const SwWebDocShell*>( pShell) )
336 {
339 {
340 case HTML_CFG_MSIE:
341 nRet |= HTMLMODE_FULL_STYLES;
342 break;
343 case HTML_CFG_NS40:
344 // no special features for this browser
345 break;
346 case HTML_CFG_WRITER:
347 nRet |= HTMLMODE_FULL_STYLES;
348 break;
349 }
350 }
351 return nRet;
352}
353
355{
356 switch ( m_nDefaultAnchor )
357 {
358 case 0:
359 return RndStdIds::FLY_AT_PARA; //0
360 case 1:
361 return RndStdIds::FLY_AT_CHAR; //4
362 case 2:
363 return RndStdIds::FLY_AS_CHAR; //1
364 default:
365 return RndStdIds::FLY_AT_CHAR; //4
366 }//switch
367}
368
370{
371 return s_aDocColor;
372}
373
375{
376 return s_aDocBoundColor;
377}
378
380{
381 return s_aObjectBoundColor;
382}
383
385{
387}
388
390{
391 return s_aTableBoundColor;
392}
393
395{
397}
398
400{
401 return s_aLinksColor;
402}
403
405{
407}
408
410{
412}
413
415{
416 return s_aTextGridColor;
417}
418
420{
421 return s_aSpellColor;
422}
423
425{
426 return s_aGrammarColor;
427}
428
430{
431 return s_aSmarttagColor;
432}
433
435{
436 return s_aShadowColor;
437}
438
440{
441 return s_aFontColor;
442}
443
445{
447}
448
450{
452}
453
455{
456 return s_aPageBreakColor;
457}
458
460{
462}
463
465{
467
469 s_aDocBoundColor = aValue.nColor;
471 if(aValue.bIsVisible)
473
475
478 if(aValue.bIsVisible)
480
481 aValue = rConfig.GetColorValue(svtools::TABLEBOUNDARIES);
482 s_aTableBoundColor = aValue.nColor;
483 if(aValue.bIsVisible)
485
488 if(aValue.bIsVisible)
490
491 aValue = rConfig.GetColorValue(svtools::LINKS);
492 s_aLinksColor = aValue.nColor;
493 if(aValue.bIsVisible)
495
496 aValue = rConfig.GetColorValue(svtools::LINKSVISITED);
498 if(aValue.bIsVisible)
500
501 aValue = rConfig.GetColorValue(svtools::SHADOWCOLOR);
502 s_aShadowColor = aValue.nColor;
503 if(aValue.bIsVisible)
505
507
509
512
514
516
519 if(aValue.bIsVisible)
521
524 if(aValue.bIsVisible)
526
528 s_aPageBreakColor = aValue.nColor;
529
532
534}
535
536void SwViewOption::SetAppearanceFlag(ViewOptFlags nFlag, bool bSet, bool bSaveInConfig )
537{
538 if(bSet)
539 s_nAppearanceFlags |= nFlag;
540 else
541 s_nAppearanceFlags &= ~nFlag;
542 if(!bSaveInConfig)
543 return;
544
545 //create an editable svtools::ColorConfig and store the change
546 svtools::EditableColorConfig aEditableConfig;
547 struct FlagToConfig_Impl
548 {
549 ViewOptFlags nFlag;
551 };
552 static const FlagToConfig_Impl aFlags[] =
553 {
564 };
565 sal_uInt16 nPos = 0;
566 while(aFlags[nPos].nFlag != ViewOptFlags::NONE)
567 {
568 if(nFlag & aFlags[nPos].nFlag)
569 {
570 svtools::ColorConfigValue aValue = aEditableConfig.GetColorValue(aFlags[nPos].eEntry);
571 aValue.bIsVisible = bSet;
572 aEditableConfig.SetColorValue(aFlags[nPos].eEntry, aValue);
573 }
574 nPos++;
575 }
576}
577
579{
580 return bool(s_nAppearanceFlags & nFlag);
581}
582
583namespace{
584rtl::Reference<comphelper::ConfigurationListener> const & getWCOptionListener()
585{
586 static rtl::Reference<comphelper::ConfigurationListener> xListener(new comphelper::ConfigurationListener("/org.openoffice.Office.Writer/Cursor/Option"));
587 return xListener;
588}
589}
590
592{
593 static comphelper::ConfigurationListenerProperty<bool> gIgnoreProtectedArea(getWCOptionListener(), "IgnoreProtectedArea");
594 return gIgnoreProtectedArea.get();
595}
596
597/* 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:379
OUString m_sSymbolFont
Definition: viewopt.hxx:222
static Color s_aVisitedLinksColor
Definition: viewopt.hxx:206
static void PaintPostIts(OutputDevice *pOut, const SwRect &rRect, bool bIsScript)
Definition: viewopt.cxx:143
static Color & GetVisitedLinksColor()
Definition: viewopt.cxx:404
bool m_bTest6
Definition: viewopt.hxx:260
static bool IsIgnoreProtectedArea()
Definition: viewopt.cxx:591
static Color & GetTableBoundariesColor()
Definition: viewopt.cxx:389
bool m_bIsPagePreview
Definition: viewopt.hxx:236
static Color & GetIndexShadingsColor()
Definition: viewopt.cxx:394
static Color & GetLinksColor()
Definition: viewopt.cxx:399
static Color s_aPageBreakColor
Definition: viewopt.hxx:214
sal_uInt8 m_nPagePreviewCol
Definition: viewopt.hxx:232
static Color & GetSmarttagColor()
Definition: viewopt.cxx:429
bool IsTest3() const
Definition: viewopt.hxx:604
bool m_bTest4
Definition: viewopt.hxx:258
static Color s_aGrammarColor
Definition: viewopt.hxx:210
static Color & GetSectionBoundColor()
Definition: viewopt.cxx:449
static bool IsAutoCompleteWords()
Definition: viewopt.cxx:319
static Color s_aTextGridColor
Definition: viewopt.hxx:208
bool mbBookView
Definition: viewopt.hxx:240
SwFillMode m_nShadowCursorFillMode
Definition: viewopt.hxx:233
static Color s_aIndexShadingsColor
Definition: viewopt.hxx:204
sal_uInt16 m_nZoom
Definition: viewopt.hxx:248
bool m_bTest3
Definition: viewopt.hxx:257
bool IsShowOutlineContentVisibilityButton() const
Definition: viewopt.cxx:100
bool mbFormView
Definition: viewopt.hxx:238
static Color s_aFontColor
Definition: viewopt.hxx:203
static Color s_aShadowColor
Definition: viewopt.hxx:216
SwViewOption & operator=(const SwViewOption &rOpt)
Definition: viewopt.cxx:264
short GetDivisionY() const
Definition: viewopt.hxx:554
static Color s_aFieldShadingsColor
Definition: viewopt.hxx:212
ViewOptCoreFlags2 m_nCore2Options
Definition: viewopt.hxx:224
static Color s_aTableBoundColor
Definition: viewopt.hxx:202
bool m_bReadonly
Definition: viewopt.hxx:234
static Color & GetDocBoundariesColor()
Definition: viewopt.cxx:374
static void Init(const OutputDevice *pWin)
Definition: viewopt.cxx:311
sal_uInt8 m_nPagePreviewRow
Definition: viewopt.hxx:231
static Color & GetGrammarColor()
Definition: viewopt.cxx:424
sal_uInt16 mnViewLayoutColumns
Definition: viewopt.hxx:228
static Color & GetSpellColor()
Definition: viewopt.cxx:419
sal_uInt8 GetPagePrevCol() const
Definition: viewopt.hxx:569
static bool IsAppearanceFlag(ViewOptFlags nFlag)
Definition: viewopt.cxx:578
ViewOptFlags2 m_nUIOptions
Definition: viewopt.hxx:225
sal_Int32 m_nDefaultAnchor
Definition: viewopt.hxx:245
RndStdIds GetDefaultAnchorType() const
Definition: viewopt.cxx:354
const Color & GetRetoucheColor() const
Definition: viewopt.hxx:686
bool IsTest7() const
Definition: viewopt.hxx:608
bool IsTreatSubOutlineLevelsAsContent() const
Definition: viewopt.cxx:105
sal_uInt8 GetPagePrevRow() const
Definition: viewopt.hxx:567
static Color & GetPageBreakColor()
Definition: viewopt.cxx:454
bool m_bTest7
Definition: viewopt.hxx:261
static Color & GetDocColor()
Definition: viewopt.cxx:369
bool m_bShowPlaceHolderFields
Definition: viewopt.hxx:243
static Color & GetShadowColor()
Definition: viewopt.cxx:434
bool mbHideWhitespaceMode
Definition: viewopt.hxx:242
bool m_bTest10
Definition: viewopt.hxx:263
bool IsTest8() const
Definition: viewopt.hxx:609
bool m_bTest8
Definition: viewopt.hxx:262
SvxZoomType m_eZoom
Definition: viewopt.hxx:249
static Color & GetHeaderFooterMarkColor()
Definition: viewopt.cxx:459
static Color s_aDocBoundColor
Definition: viewopt.hxx:199
ViewOptFlags1 m_nCoreOptions
Definition: viewopt.hxx:223
bool m_bTest1
Definition: viewopt.hxx:255
short m_nDivisionY
Definition: viewopt.hxx:230
bool mbBrowseMode
Definition: viewopt.hxx:239
bool getBrowseMode() const
Definition: viewopt.hxx:580
short m_nDivisionX
Definition: viewopt.hxx:229
bool m_bIdle
Definition: viewopt.hxx:244
static Color s_aSmarttagColor
Definition: viewopt.hxx:211
bool m_bStarOneSetting
Definition: viewopt.hxx:235
bool IsTest5() const
Definition: viewopt.hxx:606
bool IsTest1() const
Definition: viewopt.hxx:602
static void DrawRectPrinter(OutputDevice *pOut, const SwRect &rRect)
Definition: viewopt.cxx:125
static void DrawRect(OutputDevice *pOut, const SwRect &rRect, ::Color nCol)
Definition: viewopt.cxx:110
sal_uInt8 m_nTableDestination
Definition: viewopt.hxx:251
static Color s_aDocColor
Definition: viewopt.hxx:198
Size m_aSnapSize
Definition: viewopt.hxx:227
bool IsTest10() const
Definition: viewopt.hxx:610
static Color s_aHeaderFooterMarkColor
Definition: viewopt.hxx:217
bool m_bTest5
Definition: viewopt.hxx:259
Color m_aRetouchColor
Definition: viewopt.hxx:226
static Color s_aObjectBoundColor
Definition: viewopt.hxx:200
static Color s_aDirectCursorColor
Definition: viewopt.hxx:207
static Color s_aAppBackgroundColor
Definition: viewopt.hxx:201
static Color & GetFieldShadingsColor()
Definition: viewopt.cxx:444
static Color s_aLinksColor
Definition: viewopt.hxx:205
static ViewOptFlags s_nAppearanceFlags
Definition: viewopt.hxx:219
static Color s_aScriptIndicatorColor
Definition: viewopt.hxx:215
static Color s_aSectionBoundColor
Definition: viewopt.hxx:213
static void ApplyColorConfigValues(const svtools::ColorConfig &rConfig)
Definition: viewopt.cxx:464
bool IsEqualFlags(const SwViewOption &rOpt) const
Definition: viewopt.cxx:67
bool IsFormView() const
Definition: viewopt.hxx:577
static sal_uInt16 GetPostItsWidth(const OutputDevice *pOut)
Definition: viewopt.cxx:137
short GetDivisionX() const
Definition: viewopt.hxx:552
static Color & GetTextGridColor()
Definition: viewopt.cxx:414
bool IsTest4() const
Definition: viewopt.hxx:605
bool m_bSelectionInReadonly
Definition: viewopt.hxx:237
static Color & GetAppBackgroundColor()
Definition: viewopt.cxx:384
bool m_bTest2
Definition: viewopt.hxx:256
static Color s_aSpellColor
Definition: viewopt.hxx:209
static void SetAppearanceFlag(ViewOptFlags nFlag, bool bSet, bool bSaveInConfig=false)
Definition: viewopt.cxx:536
static sal_uInt16 s_nPixelTwips
Definition: viewopt.hxx:220
bool IsTest6() const
Definition: viewopt.hxx:607
static Color & GetFontColor()
Definition: viewopt.cxx:439
static Color & GetDirectCursorColor()
Definition: viewopt.cxx:409
bool IsTest2() const
Definition: viewopt.hxx:603
bool mbViewLayoutBookMode
Definition: viewopt.hxx:241
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
bool bTreatSubOutlineLevelsAsContent
Definition: viewopt.hxx:64
bool bShowOutlineContentVisibilityButton
Definition: viewopt.hxx:68
RndStdIds
#define SW_MOD()
Definition: swmodule.hxx:256
constexpr OUStringLiteral PERCENT(u"Percent")
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:332
ViewOptFlags
Definition: viewopt.hxx:180
#define TBL_DEST_CELL
Definition: viewopt.hxx:175
oslFileHandle & pOut
SvxZoomType