Line data Source code
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 <svx/htmlmode.hxx>
21 : #include <svtools/htmlcfg.hxx>
22 :
23 : #include <svx/svxids.hrc>
24 : #include <editeng/svxenum.hxx>
25 : #include <editeng/svxacorr.hxx>
26 : #include <unotools/localedatawrapper.hxx>
27 : #include <vcl/region.hxx>
28 : #include <vcl/outdev.hxx>
29 : #include <vcl/window.hxx>
30 : #include <swmodule.hxx>
31 : #include <swtypes.hxx>
32 : #include <viewopt.hxx>
33 : #include <wdocsh.hxx>
34 : #include <swrect.hxx>
35 : #include <crstate.hxx>
36 : #include <svtools/colorcfg.hxx>
37 : #include <svtools/accessibilityoptions.hxx>
38 : #include <unotools/syslocale.hxx>
39 :
40 : #include <editeng/acorrcfg.hxx>
41 :
42 : #ifdef DBG_UTIL
43 : bool SwViewOption::s_bTest9 = false; //DrawingLayerNotLoading
44 : #endif
45 24 : Color SwViewOption::aDocBoundColor(COL_LIGHTGRAY);
46 24 : Color SwViewOption::aObjectBoundColor(COL_LIGHTGRAY);
47 24 : Color SwViewOption::aDocColor(COL_LIGHTGRAY);
48 24 : Color SwViewOption::aAppBackgroundColor(COL_LIGHTGRAY);
49 24 : Color SwViewOption::aTableBoundColor(COL_LIGHTGRAY);
50 24 : Color SwViewOption::aIndexShadingsColor(COL_LIGHTGRAY);
51 24 : Color SwViewOption::aLinksColor(COL_BLUE);
52 24 : Color SwViewOption::aVisitedLinksColor(COL_RED);
53 24 : Color SwViewOption::aDirectCursorColor(COL_BLUE);
54 24 : Color SwViewOption::aTextGridColor(COL_LIGHTGRAY);
55 24 : Color SwViewOption::aSpellColor(COL_LIGHTRED);
56 24 : Color SwViewOption::aSmarttagColor(COL_LIGHTMAGENTA);
57 24 : Color SwViewOption::aFontColor(COL_BLACK);
58 24 : Color SwViewOption::aFieldShadingsColor(COL_LIGHTGRAY);
59 24 : Color SwViewOption::aSectionBoundColor(COL_LIGHTGRAY);
60 24 : Color SwViewOption::aPageBreakColor(COL_BLUE);
61 24 : Color SwViewOption::aScriptIndicatorColor(COL_GREEN);
62 24 : Color SwViewOption::aShadowColor(COL_GRAY);
63 24 : Color SwViewOption::aHeaderFooterMarkColor(COL_BLUE);
64 :
65 : sal_Int32 SwViewOption::nAppearanceFlags = VIEWOPT_DOC_BOUNDARIES|VIEWOPT_OBJECT_BOUNDARIES;
66 : sal_uInt16 SwViewOption::nPixelTwips = 0; // one pixel on the screen
67 :
68 : static const char aPostItStr[] = " ";
69 :
70 66 : sal_Bool SwViewOption::IsEqualFlags( const SwViewOption &rOpt ) const
71 : {
72 : return nCoreOptions == rOpt.nCoreOptions
73 : && nCore2Options == rOpt.nCore2Options
74 66 : && aSnapSize == rOpt.aSnapSize
75 : && mnViewLayoutColumns == rOpt.mnViewLayoutColumns
76 66 : && nDivisionX == rOpt.GetDivisionX()
77 66 : && nDivisionY == rOpt.GetDivisionY()
78 66 : && nPagePrevRow == rOpt.GetPagePrevRow()
79 66 : && nPagePrevCol == rOpt.GetPagePrevCol()
80 66 : && aRetoucheColor == rOpt.GetRetoucheColor()
81 66 : && mbFormView == rOpt.IsFormView()
82 66 : && mbBrowseMode == rOpt.getBrowseMode()
83 : && mbViewLayoutBookMode == rOpt.mbViewLayoutBookMode
84 : && bShowPlaceHolderFields == rOpt.bShowPlaceHolderFields
85 594 : && bIdle == rOpt.bIdle
86 : #ifdef DBG_UTIL
87 : // correspond to the statements in ui/config/cfgvw.src
88 : && m_bTest1 == rOpt.IsTest1()
89 : && m_bTest2 == rOpt.IsTest2()
90 : && m_bTest3 == rOpt.IsTest3()
91 : && m_bTest4 == rOpt.IsTest4()
92 : && m_bTest5 == rOpt.IsTest5()
93 : && m_bTest6 == rOpt.IsTest6()
94 : && m_bTest7 == rOpt.IsTest7()
95 : && m_bTest8 == rOpt.IsTest8()
96 : && m_bTest10 == rOpt.IsTest10()
97 : #endif
98 : ;
99 : }
100 :
101 0 : void SwViewOption::DrawRect( OutputDevice *pOut,
102 : const SwRect &rRect, long nCol ) const
103 : {
104 0 : if ( pOut->GetOutDevType() != OUTDEV_PRINTER )
105 : {
106 0 : const Color aCol( nCol );
107 0 : const Color aOldColor( pOut->GetFillColor() );
108 0 : pOut->SetFillColor( aCol );
109 0 : pOut->DrawRect( rRect.SVRect() );
110 0 : pOut->SetFillColor( aOldColor );
111 : }
112 : else
113 0 : DrawRectPrinter( pOut, rRect );
114 0 : }
115 :
116 0 : void SwViewOption::DrawRectPrinter( OutputDevice *pOut,
117 : const SwRect &rRect ) const
118 : {
119 0 : Color aOldColor(pOut->GetLineColor());
120 0 : Color aOldFillColor( pOut->GetFillColor() );
121 0 : pOut->SetLineColor( Color(COL_BLACK) );
122 0 : pOut->SetFillColor( Color(COL_TRANSPARENT ));
123 0 : pOut->DrawRect( rRect.SVRect() );
124 0 : pOut->SetFillColor( aOldFillColor );
125 0 : pOut->SetLineColor( aOldColor );
126 0 : }
127 :
128 16 : sal_uInt16 SwViewOption::GetPostItsWidth( const OutputDevice *pOut ) const
129 : {
130 : OSL_ENSURE( pOut, "no Outdev" );
131 16 : return sal_uInt16(pOut->GetTextWidth( rtl::OUString(aPostItStr )));
132 : }
133 :
134 8 : void SwViewOption::PaintPostIts( OutputDevice *pOut, const SwRect &rRect, sal_Bool bIsScript ) const
135 : {
136 8 : if( pOut && bIsScript )
137 : {
138 0 : Color aOldLineColor( pOut->GetLineColor() );
139 0 : pOut->SetLineColor( Color(COL_GRAY ) );
140 : // to make it look nice, we subtract two pixels everywhere
141 0 : sal_uInt16 nPix = GetPixelTwips() * 2;
142 0 : if( rRect.Width() <= 2 * nPix || rRect.Height() <= 2 * nPix )
143 0 : nPix = 0;
144 0 : const Point aTopLeft( rRect.Left() + nPix, rRect.Top() + nPix );
145 0 : const Point aBotRight( rRect.Right() - nPix, rRect.Bottom() - nPix );
146 0 : const SwRect aRect( aTopLeft, aBotRight );
147 0 : DrawRect( pOut, aRect, aScriptIndicatorColor.GetColor() );
148 0 : pOut->SetLineColor( aOldLineColor );
149 : }
150 8 : }
151 :
152 506 : SwViewOption::SwViewOption() :
153 : sSymbolFont( RTL_CONSTASCII_USTRINGPARAM( "symbol" ) ),
154 : aRetoucheColor( COL_TRANSPARENT ),
155 : mnViewLayoutColumns( 0 ),
156 : nPagePrevRow( 1 ),
157 : nPagePrevCol( 2 ),
158 : nShdwCrsrFillMode( FILL_TAB ),
159 : bReadonly(sal_False),
160 : bStarOneSetting(sal_False),
161 : bIsPagePreview(sal_False),
162 : bSelectionInReadonly(sal_False),
163 : mbFormView(sal_False),
164 : mbBrowseMode(sal_False),
165 : mbBookView(sal_False),
166 : mbViewLayoutBookMode(sal_False),
167 : bShowPlaceHolderFields( sal_True ),
168 : nZoom( 100 ),
169 : eZoom( SVX_ZOOM_PERCENT ),
170 506 : nTblDest(TBL_DEST_CELL)
171 : {
172 : // Initialisation is a little simpler now
173 : // all Bits to 0
174 : nCoreOptions = VIEWOPT_1_HARDBLANK | VIEWOPT_1_SOFTHYPH |
175 : VIEWOPT_1_REF |
176 : VIEWOPT_1_GRAPHIC |
177 : VIEWOPT_1_TABLE | VIEWOPT_1_DRAW | VIEWOPT_1_CONTROL |
178 : VIEWOPT_1_PAGEBACK |
179 506 : VIEWOPT_1_POSTITS;
180 506 : nCore2Options = VIEWOPT_CORE2_BLACKFONT | VIEWOPT_CORE2_HIDDENPARA;
181 506 : nUIOptions = VIEWOPT_2_MODIFIED | VIEWOPT_2_GRFKEEPZOOM |VIEWOPT_2_ANY_RULER;
182 :
183 506 : if(MEASURE_METRIC != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum())
184 506 : aSnapSize.Width() = aSnapSize.Height() = 720; // 1/2"
185 : else
186 0 : aSnapSize.Width() = aSnapSize.Height() = 567; // 1 cm
187 506 : nDivisionX = nDivisionY = 1;
188 :
189 506 : bSelectionInReadonly = SW_MOD()->GetAccessibilityOptions().IsSelectionInReadonly();
190 :
191 506 : bIdle = true;
192 :
193 : #ifdef DBG_UTIL
194 : // correspond to the statements in ui/config/cfgvw.src
195 : m_bTest1 = m_bTest2 = m_bTest3 = m_bTest4 =
196 : m_bTest5 = m_bTest6 = m_bTest7 = m_bTest8 = m_bTest10 = false;
197 : #endif
198 506 : }
199 :
200 546 : SwViewOption::SwViewOption(const SwViewOption& rVOpt)
201 : {
202 546 : bReadonly = sal_False;
203 546 : bSelectionInReadonly = sal_False;
204 : // #114856# Formular view
205 546 : mbFormView = rVOpt.mbFormView;
206 546 : nZoom = rVOpt.nZoom ;
207 546 : aSnapSize = rVOpt.aSnapSize ;
208 546 : mnViewLayoutColumns = rVOpt.mnViewLayoutColumns ;
209 546 : nDivisionX = rVOpt.nDivisionX ;
210 546 : nDivisionY = rVOpt.nDivisionY ;
211 546 : nPagePrevRow = rVOpt.nPagePrevRow;
212 546 : nPagePrevCol = rVOpt.nPagePrevCol;
213 546 : bIsPagePreview = rVOpt.bIsPagePreview;
214 546 : eZoom = rVOpt.eZoom ;
215 546 : nTblDest = rVOpt.nTblDest ;
216 546 : nUIOptions = rVOpt.nUIOptions ;
217 546 : nCoreOptions = rVOpt.nCoreOptions ;
218 546 : nCore2Options = rVOpt.nCore2Options ;
219 546 : aRetoucheColor = rVOpt.GetRetoucheColor();
220 546 : sSymbolFont = rVOpt.sSymbolFont;
221 546 : nShdwCrsrFillMode = rVOpt.nShdwCrsrFillMode;
222 546 : bStarOneSetting = rVOpt.bStarOneSetting;
223 546 : mbBookView = rVOpt.mbBookView;
224 546 : mbBrowseMode = rVOpt.mbBrowseMode;
225 546 : mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode;
226 546 : bShowPlaceHolderFields = rVOpt.bShowPlaceHolderFields;
227 546 : bIdle = rVOpt.bIdle;
228 :
229 : #ifdef DBG_UTIL
230 : m_bTest1 = rVOpt.m_bTest1;
231 : m_bTest2 = rVOpt.m_bTest2;
232 : m_bTest3 = rVOpt.m_bTest3;
233 : m_bTest4 = rVOpt.m_bTest4;
234 : m_bTest5 = rVOpt.m_bTest5;
235 : m_bTest6 = rVOpt.m_bTest6;
236 : m_bTest7 = rVOpt.m_bTest7;
237 : m_bTest8 = rVOpt.m_bTest8;
238 : m_bTest10 = rVOpt.m_bTest10;
239 : #endif
240 546 : }
241 :
242 :
243 548 : SwViewOption& SwViewOption::operator=( const SwViewOption &rVOpt )
244 : {
245 : // #114856# Formular view
246 548 : mbFormView = rVOpt.mbFormView ;
247 548 : nZoom = rVOpt.nZoom ;
248 548 : aSnapSize = rVOpt.aSnapSize ;
249 548 : mnViewLayoutColumns = rVOpt.mnViewLayoutColumns ;
250 548 : nDivisionX = rVOpt.nDivisionX ;
251 548 : nDivisionY = rVOpt.nDivisionY ;
252 548 : nPagePrevRow = rVOpt.nPagePrevRow;
253 548 : nPagePrevCol = rVOpt.nPagePrevCol;
254 548 : bIsPagePreview = rVOpt.bIsPagePreview;
255 548 : eZoom = rVOpt.eZoom ;
256 548 : nTblDest = rVOpt.nTblDest ;
257 548 : nUIOptions = rVOpt.nUIOptions ;
258 548 : nCoreOptions = rVOpt.nCoreOptions;
259 548 : nCore2Options = rVOpt.nCore2Options;
260 548 : aRetoucheColor = rVOpt.GetRetoucheColor();
261 548 : sSymbolFont = rVOpt.sSymbolFont;
262 548 : nShdwCrsrFillMode = rVOpt.nShdwCrsrFillMode;
263 548 : bStarOneSetting = rVOpt.bStarOneSetting;
264 548 : mbBookView = rVOpt.mbBookView;
265 548 : mbBrowseMode = rVOpt.mbBrowseMode;
266 548 : mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode;
267 548 : bShowPlaceHolderFields = rVOpt.bShowPlaceHolderFields;
268 548 : bIdle = rVOpt.bIdle;
269 :
270 : #ifdef DBG_UTIL
271 : m_bTest1 = rVOpt.m_bTest1;
272 : m_bTest2 = rVOpt.m_bTest2;
273 : m_bTest3 = rVOpt.m_bTest3;
274 : m_bTest4 = rVOpt.m_bTest4;
275 : m_bTest5 = rVOpt.m_bTest5;
276 : m_bTest6 = rVOpt.m_bTest6;
277 : m_bTest7 = rVOpt.m_bTest7;
278 : m_bTest8 = rVOpt.m_bTest8;
279 : m_bTest10 = rVOpt.m_bTest10;
280 : #endif
281 548 : return *this;
282 : }
283 :
284 :
285 624 : SwViewOption::~SwViewOption()
286 : {
287 624 : }
288 :
289 478 : void SwViewOption::Init( Window *pWin )
290 : {
291 478 : if( !nPixelTwips && pWin )
292 : {
293 20 : nPixelTwips = (sal_uInt16)pWin->PixelToLogic( Size(1,1) ).Height();
294 : }
295 478 : }
296 :
297 3509 : sal_Bool SwViewOption::IsAutoCompleteWords() const
298 : {
299 3509 : const SvxSwAutoFmtFlags& rFlags = SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags();
300 3509 : return rFlags.bAutoCmpltCollectWords;
301 : }
302 :
303 72 : AuthorCharAttr::AuthorCharAttr() :
304 : nItemId (SID_ATTR_CHAR_UNDERLINE),
305 : nAttr (UNDERLINE_SINGLE),
306 72 : nColor (COL_TRANSPARENT)
307 : {
308 72 : }
309 :
310 563 : sal_uInt16 GetHtmlMode(const SwDocShell* pShell)
311 : {
312 563 : sal_uInt16 nRet = 0;
313 563 : if(!pShell || PTR_CAST(SwWebDocShell, pShell))
314 : {
315 0 : nRet = HTMLMODE_ON | HTMLMODE_SOME_STYLES;
316 0 : SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
317 0 : switch ( rHtmlOpt.GetExportMode() )
318 : {
319 : case HTML_CFG_MSIE:
320 0 : nRet |= HTMLMODE_FULL_STYLES;
321 0 : break;
322 : case HTML_CFG_NS40:
323 0 : nRet |= HTMLMODE_FRM_COLUMNS;
324 0 : break;
325 : case HTML_CFG_WRITER:
326 0 : nRet |= HTMLMODE_FRM_COLUMNS|HTMLMODE_FULL_STYLES;
327 0 : break;
328 : }
329 : }
330 563 : return nRet;
331 : }
332 :
333 669 : Color& SwViewOption::GetDocColor()
334 : {
335 669 : return aDocColor;
336 : }
337 :
338 693 : Color& SwViewOption::GetDocBoundariesColor()
339 : {
340 693 : return aDocBoundColor;
341 : }
342 :
343 3544 : Color& SwViewOption::GetObjectBoundariesColor()
344 : {
345 3544 : return aObjectBoundColor;
346 : }
347 :
348 4008 : Color& SwViewOption::GetAppBackgroundColor()
349 : {
350 4008 : return aAppBackgroundColor;
351 : }
352 :
353 68 : Color& SwViewOption::GetTableBoundariesColor()
354 : {
355 68 : return aTableBoundColor;
356 : }
357 :
358 0 : Color& SwViewOption::GetIndexShadingsColor()
359 : {
360 0 : return aIndexShadingsColor;
361 : }
362 :
363 0 : Color& SwViewOption::GetLinksColor()
364 : {
365 0 : return aLinksColor;
366 : }
367 :
368 0 : Color& SwViewOption::GetVisitedLinksColor()
369 : {
370 0 : return aVisitedLinksColor;
371 : }
372 :
373 0 : Color& SwViewOption::GetDirectCursorColor()
374 : {
375 0 : return aDirectCursorColor;
376 : }
377 :
378 0 : Color& SwViewOption::GetTextGridColor()
379 : {
380 0 : return aTextGridColor;
381 : }
382 :
383 5 : Color& SwViewOption::GetSpellColor()
384 : {
385 5 : return aSpellColor;
386 : }
387 :
388 0 : Color& SwViewOption::GetSmarttagColor()
389 : {
390 0 : return aSmarttagColor;
391 : }
392 :
393 695 : Color& SwViewOption::GetShadowColor()
394 : {
395 695 : return aShadowColor;
396 : }
397 :
398 919 : Color& SwViewOption::GetFontColor()
399 : {
400 919 : return aFontColor;
401 : }
402 :
403 85 : Color& SwViewOption::GetFieldShadingsColor()
404 : {
405 85 : return aFieldShadingsColor;
406 : }
407 :
408 504 : Color& SwViewOption::GetSectionBoundColor()
409 : {
410 504 : return aSectionBoundColor;
411 : }
412 :
413 44 : Color& SwViewOption::GetPageBreakColor()
414 : {
415 44 : return aPageBreakColor;
416 : }
417 :
418 0 : Color& SwViewOption::GetHeaderFooterMarkColor()
419 : {
420 0 : return aHeaderFooterMarkColor;
421 : }
422 :
423 24 : void SwViewOption::ApplyColorConfigValues(const svtools::ColorConfig& rConfig )
424 : {
425 24 : aDocColor.SetColor(rConfig.GetColorValue(svtools::DOCCOLOR).nColor);
426 :
427 24 : svtools::ColorConfigValue aValue = rConfig.GetColorValue(svtools::DOCBOUNDARIES);
428 24 : aDocBoundColor.SetColor(aValue.nColor);
429 24 : nAppearanceFlags = 0;
430 24 : if(aValue.bIsVisible)
431 24 : nAppearanceFlags |= VIEWOPT_DOC_BOUNDARIES;
432 :
433 24 : aAppBackgroundColor.SetColor(rConfig.GetColorValue(svtools::APPBACKGROUND).nColor);
434 :
435 24 : aValue = rConfig.GetColorValue(svtools::OBJECTBOUNDARIES);
436 24 : aObjectBoundColor.SetColor(aValue.nColor);
437 24 : if(aValue.bIsVisible)
438 24 : nAppearanceFlags |= VIEWOPT_OBJECT_BOUNDARIES;
439 :
440 24 : aValue = rConfig.GetColorValue(svtools::TABLEBOUNDARIES);
441 24 : aTableBoundColor.SetColor(aValue.nColor);
442 24 : if(aValue.bIsVisible)
443 24 : nAppearanceFlags |= VIEWOPT_TABLE_BOUNDARIES;
444 :
445 24 : aValue = rConfig.GetColorValue(svtools::WRITERIDXSHADINGS);
446 24 : aIndexShadingsColor.SetColor(aValue.nColor);
447 24 : if(aValue.bIsVisible)
448 24 : nAppearanceFlags |= VIEWOPT_INDEX_SHADINGS;
449 :
450 24 : aValue = rConfig.GetColorValue(svtools::LINKS);
451 24 : aLinksColor.SetColor(aValue.nColor);
452 24 : if(aValue.bIsVisible)
453 0 : nAppearanceFlags |= VIEWOPT_LINKS;
454 :
455 24 : aValue = rConfig.GetColorValue(svtools::LINKSVISITED);
456 24 : aVisitedLinksColor.SetColor(aValue.nColor);
457 24 : if(aValue.bIsVisible)
458 0 : nAppearanceFlags |= VIEWOPT_VISITED_LINKS;
459 :
460 24 : aValue = rConfig.GetColorValue(svtools::SHADOWCOLOR);
461 24 : aShadowColor.SetColor(aValue.nColor);
462 24 : if(aValue.bIsVisible)
463 24 : nAppearanceFlags |= VIEWOPT_SHADOW;
464 :
465 24 : aDirectCursorColor.SetColor(rConfig.GetColorValue(svtools::WRITERDIRECTCURSOR).nColor);
466 :
467 24 : aTextGridColor.SetColor(rConfig.GetColorValue(svtools::WRITERTEXTGRID).nColor);
468 :
469 24 : aSpellColor.SetColor(rConfig.GetColorValue(svtools::SPELL).nColor);
470 :
471 24 : aSmarttagColor.SetColor(rConfig.GetColorValue(svtools::SMARTTAGS).nColor);
472 :
473 24 : aFontColor.SetColor(rConfig.GetColorValue(svtools::FONTCOLOR).nColor);
474 :
475 24 : aValue = rConfig.GetColorValue(svtools::WRITERFIELDSHADINGS);
476 24 : aFieldShadingsColor.SetColor(aValue.nColor);
477 24 : if(aValue.bIsVisible)
478 24 : nAppearanceFlags |= VIEWOPT_FIELD_SHADINGS;
479 :
480 24 : aValue = rConfig.GetColorValue(svtools::WRITERSECTIONBOUNDARIES);
481 24 : aSectionBoundColor.SetColor(aValue.nColor);
482 24 : if(aValue.bIsVisible)
483 24 : nAppearanceFlags |= VIEWOPT_SECTION_BOUNDARIES;
484 :
485 24 : aValue = rConfig.GetColorValue(svtools::WRITERPAGEBREAKS);
486 24 : aPageBreakColor.SetColor(aValue.nColor);
487 :
488 24 : aValue = rConfig.GetColorValue(svtools::WRITERHEADERFOOTERMARK);
489 24 : aHeaderFooterMarkColor.SetColor(aValue.nColor);
490 :
491 24 : aScriptIndicatorColor.SetColor(rConfig.GetColorValue(svtools::WRITERSCRIPTINDICATOR).nColor);
492 24 : }
493 :
494 0 : void SwViewOption::SetAppearanceFlag(sal_Int32 nFlag, sal_Bool bSet, sal_Bool bSaveInConfig )
495 : {
496 0 : if(bSet)
497 0 : nAppearanceFlags |= nFlag;
498 : else
499 0 : nAppearanceFlags &= ~nFlag;
500 0 : if(bSaveInConfig)
501 : {
502 : //create an editable svtools::ColorConfig and store the change
503 0 : svtools::EditableColorConfig aEditableConfig;
504 : struct FlagToConfig_Impl
505 : {
506 : sal_Int32 nFlag;
507 : svtools::ColorConfigEntry eEntry;
508 : };
509 : static const FlagToConfig_Impl aFlags[] =
510 : {
511 : { VIEWOPT_DOC_BOUNDARIES , svtools::DOCBOUNDARIES },
512 : { VIEWOPT_OBJECT_BOUNDARIES , svtools::OBJECTBOUNDARIES },
513 : { VIEWOPT_TABLE_BOUNDARIES , svtools::TABLEBOUNDARIES },
514 : { VIEWOPT_INDEX_SHADINGS , svtools::WRITERIDXSHADINGS },
515 : { VIEWOPT_LINKS , svtools::LINKS },
516 : { VIEWOPT_VISITED_LINKS , svtools::LINKSVISITED },
517 : { VIEWOPT_FIELD_SHADINGS , svtools::WRITERFIELDSHADINGS },
518 : { VIEWOPT_SECTION_BOUNDARIES , svtools::WRITERSECTIONBOUNDARIES },
519 : { VIEWOPT_SHADOW , svtools::SHADOWCOLOR },
520 : { 0 , svtools::ColorConfigEntryCount }
521 : };
522 0 : sal_uInt16 nPos = 0;
523 0 : while(aFlags[nPos].nFlag)
524 : {
525 0 : if(0 != (nFlag&aFlags[nPos].nFlag))
526 : {
527 0 : svtools::ColorConfigValue aValue = aEditableConfig.GetColorValue(aFlags[nPos].eEntry);
528 0 : aValue.bIsVisible = bSet;
529 0 : aEditableConfig.SetColorValue(aFlags[nPos].eEntry, aValue);
530 : }
531 0 : nPos++;
532 0 : }
533 : }
534 0 : }
535 :
536 4651 : sal_Bool SwViewOption::IsAppearanceFlag(sal_Int32 nFlag)
537 : {
538 4651 : return 0 != (nAppearanceFlags & nFlag);
539 72 : }
540 :
541 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|