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 <sfx2/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 33 : Color SwViewOption::aDocBoundColor(COL_LIGHTGRAY);
46 33 : Color SwViewOption::aObjectBoundColor(COL_LIGHTGRAY);
47 33 : Color SwViewOption::aDocColor(COL_LIGHTGRAY);
48 33 : Color SwViewOption::aAppBackgroundColor(COL_LIGHTGRAY);
49 33 : Color SwViewOption::aTableBoundColor(COL_LIGHTGRAY);
50 33 : Color SwViewOption::aIndexShadingsColor(COL_LIGHTGRAY);
51 33 : Color SwViewOption::aLinksColor(COL_BLUE);
52 33 : Color SwViewOption::aVisitedLinksColor(COL_RED);
53 33 : Color SwViewOption::aDirectCursorColor(COL_BLUE);
54 33 : Color SwViewOption::aTextGridColor(COL_LIGHTGRAY);
55 33 : Color SwViewOption::aSpellColor(COL_LIGHTRED);
56 33 : Color SwViewOption::aSmarttagColor(COL_LIGHTMAGENTA);
57 33 : Color SwViewOption::aFontColor(COL_BLACK);
58 33 : Color SwViewOption::aFieldShadingsColor(COL_LIGHTGRAY);
59 33 : Color SwViewOption::aSectionBoundColor(COL_LIGHTGRAY);
60 33 : Color SwViewOption::aPageBreakColor(COL_BLUE);
61 33 : Color SwViewOption::aScriptIndicatorColor(COL_GREEN);
62 33 : Color SwViewOption::aShadowColor(COL_GRAY);
63 33 : 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 262 : bool SwViewOption::IsEqualFlags( const SwViewOption &rOpt ) const
71 : {
72 262 : return nCoreOptions == rOpt.nCoreOptions
73 174 : && nCore2Options == rOpt.nCore2Options
74 162 : && aSnapSize == rOpt.aSnapSize
75 154 : && mnViewLayoutColumns == rOpt.mnViewLayoutColumns
76 152 : && nDivisionX == rOpt.GetDivisionX()
77 148 : && nDivisionY == rOpt.GetDivisionY()
78 144 : && nPagePrevRow == rOpt.GetPagePrevRow()
79 144 : && nPagePrevCol == rOpt.GetPagePrevCol()
80 144 : && aRetoucheColor == rOpt.GetRetoucheColor()
81 144 : && mbFormView == rOpt.IsFormView()
82 144 : && mbBrowseMode == rOpt.getBrowseMode()
83 143 : && mbViewLayoutBookMode == rOpt.mbViewLayoutBookMode
84 143 : && bShowPlaceHolderFields == rOpt.bShowPlaceHolderFields
85 405 : && 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 0 : sal_uInt16 SwViewOption::GetPostItsWidth( const OutputDevice *pOut ) const
129 : {
130 : OSL_ENSURE( pOut, "no Outdev" );
131 0 : return sal_uInt16(pOut->GetTextWidth( OUString(aPostItStr )));
132 : }
133 :
134 0 : void SwViewOption::PaintPostIts( OutputDevice *pOut, const SwRect &rRect, sal_Bool bIsScript ) const
135 : {
136 0 : 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 0 : }
151 :
152 842 : SwViewOption::SwViewOption() :
153 : sSymbolFont( "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 842 : nTblDest(TBL_DEST_CELL)
171 : {
172 : // Initialisation is a little simpler now
173 : // all Bits to 0
174 : nCoreOptions =
175 : VIEWOPT_1_HARDBLANK |
176 : VIEWOPT_1_SOFTHYPH |
177 : VIEWOPT_1_REF |
178 : VIEWOPT_1_GRAPHIC |
179 : VIEWOPT_1_TABLE |
180 : VIEWOPT_1_DRAW |
181 : VIEWOPT_1_CONTROL |
182 : VIEWOPT_1_PAGEBACK |
183 842 : VIEWOPT_1_POSTITS;
184 :
185 : nCore2Options =
186 : VIEWOPT_CORE2_BLACKFONT |
187 842 : VIEWOPT_CORE2_HIDDENPARA;
188 :
189 : nUIOptions =
190 : VIEWOPT_2_MODIFIED |
191 : VIEWOPT_2_GRFKEEPZOOM |
192 842 : VIEWOPT_2_ANY_RULER;
193 :
194 842 : if(MEASURE_METRIC != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum())
195 842 : aSnapSize.Width() = aSnapSize.Height() = 720; // 1/2"
196 : else
197 0 : aSnapSize.Width() = aSnapSize.Height() = 567; // 1 cm
198 842 : nDivisionX = nDivisionY = 1;
199 :
200 842 : bSelectionInReadonly = SW_MOD()->GetAccessibilityOptions().IsSelectionInReadonly();
201 :
202 842 : bIdle = true;
203 :
204 : #ifdef DBG_UTIL
205 : // correspond to the statements in ui/config/cfgvw.src
206 : m_bTest1 = m_bTest2 = m_bTest3 = m_bTest4 =
207 : m_bTest5 = m_bTest6 = m_bTest7 = m_bTest8 = m_bTest10 = false;
208 : #endif
209 842 : }
210 :
211 1106 : SwViewOption::SwViewOption(const SwViewOption& rVOpt)
212 : {
213 1106 : bReadonly = sal_False;
214 1106 : bSelectionInReadonly = sal_False;
215 : // #114856# Formular view
216 1106 : mbFormView = rVOpt.mbFormView;
217 1106 : nZoom = rVOpt.nZoom ;
218 1106 : aSnapSize = rVOpt.aSnapSize ;
219 1106 : mnViewLayoutColumns = rVOpt.mnViewLayoutColumns ;
220 1106 : nDivisionX = rVOpt.nDivisionX ;
221 1106 : nDivisionY = rVOpt.nDivisionY ;
222 1106 : nPagePrevRow = rVOpt.nPagePrevRow;
223 1106 : nPagePrevCol = rVOpt.nPagePrevCol;
224 1106 : bIsPagePreview = rVOpt.bIsPagePreview;
225 1106 : eZoom = rVOpt.eZoom ;
226 1106 : nTblDest = rVOpt.nTblDest ;
227 1106 : nUIOptions = rVOpt.nUIOptions ;
228 1106 : nCoreOptions = rVOpt.nCoreOptions ;
229 1106 : nCore2Options = rVOpt.nCore2Options ;
230 1106 : aRetoucheColor = rVOpt.GetRetoucheColor();
231 1106 : sSymbolFont = rVOpt.sSymbolFont;
232 1106 : nShdwCrsrFillMode = rVOpt.nShdwCrsrFillMode;
233 1106 : bStarOneSetting = rVOpt.bStarOneSetting;
234 1106 : mbBookView = rVOpt.mbBookView;
235 1106 : mbBrowseMode = rVOpt.mbBrowseMode;
236 1106 : mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode;
237 1106 : bShowPlaceHolderFields = rVOpt.bShowPlaceHolderFields;
238 1106 : bIdle = rVOpt.bIdle;
239 :
240 : #ifdef DBG_UTIL
241 : m_bTest1 = rVOpt.m_bTest1;
242 : m_bTest2 = rVOpt.m_bTest2;
243 : m_bTest3 = rVOpt.m_bTest3;
244 : m_bTest4 = rVOpt.m_bTest4;
245 : m_bTest5 = rVOpt.m_bTest5;
246 : m_bTest6 = rVOpt.m_bTest6;
247 : m_bTest7 = rVOpt.m_bTest7;
248 : m_bTest8 = rVOpt.m_bTest8;
249 : m_bTest10 = rVOpt.m_bTest10;
250 : #endif
251 1106 : }
252 :
253 :
254 959 : SwViewOption& SwViewOption::operator=( const SwViewOption &rVOpt )
255 : {
256 : // #114856# Formular view
257 959 : mbFormView = rVOpt.mbFormView ;
258 959 : nZoom = rVOpt.nZoom ;
259 959 : aSnapSize = rVOpt.aSnapSize ;
260 959 : mnViewLayoutColumns = rVOpt.mnViewLayoutColumns ;
261 959 : nDivisionX = rVOpt.nDivisionX ;
262 959 : nDivisionY = rVOpt.nDivisionY ;
263 959 : nPagePrevRow = rVOpt.nPagePrevRow;
264 959 : nPagePrevCol = rVOpt.nPagePrevCol;
265 959 : bIsPagePreview = rVOpt.bIsPagePreview;
266 959 : eZoom = rVOpt.eZoom ;
267 959 : nTblDest = rVOpt.nTblDest ;
268 959 : nUIOptions = rVOpt.nUIOptions ;
269 959 : nCoreOptions = rVOpt.nCoreOptions;
270 959 : nCore2Options = rVOpt.nCore2Options;
271 959 : aRetoucheColor = rVOpt.GetRetoucheColor();
272 959 : sSymbolFont = rVOpt.sSymbolFont;
273 959 : nShdwCrsrFillMode = rVOpt.nShdwCrsrFillMode;
274 959 : bStarOneSetting = rVOpt.bStarOneSetting;
275 959 : mbBookView = rVOpt.mbBookView;
276 959 : mbBrowseMode = rVOpt.mbBrowseMode;
277 959 : mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode;
278 959 : bShowPlaceHolderFields = rVOpt.bShowPlaceHolderFields;
279 959 : bIdle = rVOpt.bIdle;
280 :
281 : #ifdef DBG_UTIL
282 : m_bTest1 = rVOpt.m_bTest1;
283 : m_bTest2 = rVOpt.m_bTest2;
284 : m_bTest3 = rVOpt.m_bTest3;
285 : m_bTest4 = rVOpt.m_bTest4;
286 : m_bTest5 = rVOpt.m_bTest5;
287 : m_bTest6 = rVOpt.m_bTest6;
288 : m_bTest7 = rVOpt.m_bTest7;
289 : m_bTest8 = rVOpt.m_bTest8;
290 : m_bTest10 = rVOpt.m_bTest10;
291 : #endif
292 959 : return *this;
293 : }
294 :
295 :
296 1931 : SwViewOption::~SwViewOption()
297 : {
298 1931 : }
299 :
300 793 : void SwViewOption::Init( Window *pWin )
301 : {
302 793 : if( !nPixelTwips && pWin )
303 : {
304 31 : nPixelTwips = (sal_uInt16)pWin->PixelToLogic( Size(1,1) ).Height();
305 : }
306 793 : }
307 :
308 3877 : sal_Bool SwViewOption::IsAutoCompleteWords() const
309 : {
310 3877 : const SvxSwAutoFmtFlags& rFlags = SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags();
311 3877 : return rFlags.bAutoCmpltCollectWords;
312 : }
313 :
314 99 : AuthorCharAttr::AuthorCharAttr() :
315 : nItemId (SID_ATTR_CHAR_UNDERLINE),
316 : nAttr (UNDERLINE_SINGLE),
317 99 : nColor (COL_TRANSPARENT)
318 : {
319 99 : }
320 :
321 2855 : sal_uInt16 GetHtmlMode(const SwDocShell* pShell)
322 : {
323 2855 : sal_uInt16 nRet = 0;
324 2855 : if(!pShell || PTR_CAST(SwWebDocShell, pShell))
325 : {
326 10 : nRet = HTMLMODE_ON | HTMLMODE_SOME_STYLES;
327 10 : SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
328 10 : switch ( rHtmlOpt.GetExportMode() )
329 : {
330 : case HTML_CFG_MSIE:
331 0 : nRet |= HTMLMODE_FULL_STYLES;
332 0 : break;
333 : case HTML_CFG_NS40:
334 : // no special features for this browser
335 10 : break;
336 : case HTML_CFG_WRITER:
337 0 : nRet |= HTMLMODE_FULL_STYLES;
338 0 : break;
339 : }
340 : }
341 2855 : return nRet;
342 : }
343 :
344 5858 : Color& SwViewOption::GetDocColor()
345 : {
346 5858 : return aDocColor;
347 : }
348 :
349 5837 : Color& SwViewOption::GetDocBoundariesColor()
350 : {
351 5837 : return aDocBoundColor;
352 : }
353 :
354 757 : Color& SwViewOption::GetObjectBoundariesColor()
355 : {
356 757 : return aObjectBoundColor;
357 : }
358 :
359 25241 : Color& SwViewOption::GetAppBackgroundColor()
360 : {
361 25241 : return aAppBackgroundColor;
362 : }
363 :
364 302 : Color& SwViewOption::GetTableBoundariesColor()
365 : {
366 302 : return aTableBoundColor;
367 : }
368 :
369 45 : Color& SwViewOption::GetIndexShadingsColor()
370 : {
371 45 : return aIndexShadingsColor;
372 : }
373 :
374 0 : Color& SwViewOption::GetLinksColor()
375 : {
376 0 : return aLinksColor;
377 : }
378 :
379 0 : Color& SwViewOption::GetVisitedLinksColor()
380 : {
381 0 : return aVisitedLinksColor;
382 : }
383 :
384 0 : Color& SwViewOption::GetDirectCursorColor()
385 : {
386 0 : return aDirectCursorColor;
387 : }
388 :
389 13 : Color& SwViewOption::GetTextGridColor()
390 : {
391 13 : return aTextGridColor;
392 : }
393 :
394 284 : Color& SwViewOption::GetSpellColor()
395 : {
396 284 : return aSpellColor;
397 : }
398 :
399 0 : Color& SwViewOption::GetSmarttagColor()
400 : {
401 0 : return aSmarttagColor;
402 : }
403 :
404 5810 : Color& SwViewOption::GetShadowColor()
405 : {
406 5810 : return aShadowColor;
407 : }
408 :
409 10727 : Color& SwViewOption::GetFontColor()
410 : {
411 10727 : return aFontColor;
412 : }
413 :
414 1280 : Color& SwViewOption::GetFieldShadingsColor()
415 : {
416 1280 : return aFieldShadingsColor;
417 : }
418 :
419 330 : Color& SwViewOption::GetSectionBoundColor()
420 : {
421 330 : return aSectionBoundColor;
422 : }
423 :
424 42 : Color& SwViewOption::GetPageBreakColor()
425 : {
426 42 : return aPageBreakColor;
427 : }
428 :
429 0 : Color& SwViewOption::GetHeaderFooterMarkColor()
430 : {
431 0 : return aHeaderFooterMarkColor;
432 : }
433 :
434 57 : void SwViewOption::ApplyColorConfigValues(const svtools::ColorConfig& rConfig )
435 : {
436 57 : aDocColor.SetColor(rConfig.GetColorValue(svtools::DOCCOLOR).nColor);
437 :
438 57 : svtools::ColorConfigValue aValue = rConfig.GetColorValue(svtools::DOCBOUNDARIES);
439 57 : aDocBoundColor.SetColor(aValue.nColor);
440 57 : nAppearanceFlags = 0;
441 57 : if(aValue.bIsVisible)
442 57 : nAppearanceFlags |= VIEWOPT_DOC_BOUNDARIES;
443 :
444 57 : aAppBackgroundColor.SetColor(rConfig.GetColorValue(svtools::APPBACKGROUND).nColor);
445 :
446 57 : aValue = rConfig.GetColorValue(svtools::OBJECTBOUNDARIES);
447 57 : aObjectBoundColor.SetColor(aValue.nColor);
448 57 : if(aValue.bIsVisible)
449 57 : nAppearanceFlags |= VIEWOPT_OBJECT_BOUNDARIES;
450 :
451 57 : aValue = rConfig.GetColorValue(svtools::TABLEBOUNDARIES);
452 57 : aTableBoundColor.SetColor(aValue.nColor);
453 57 : if(aValue.bIsVisible)
454 45 : nAppearanceFlags |= VIEWOPT_TABLE_BOUNDARIES;
455 :
456 57 : aValue = rConfig.GetColorValue(svtools::WRITERIDXSHADINGS);
457 57 : aIndexShadingsColor.SetColor(aValue.nColor);
458 57 : if(aValue.bIsVisible)
459 57 : nAppearanceFlags |= VIEWOPT_INDEX_SHADINGS;
460 :
461 57 : aValue = rConfig.GetColorValue(svtools::LINKS);
462 57 : aLinksColor.SetColor(aValue.nColor);
463 57 : if(aValue.bIsVisible)
464 0 : nAppearanceFlags |= VIEWOPT_LINKS;
465 :
466 57 : aValue = rConfig.GetColorValue(svtools::LINKSVISITED);
467 57 : aVisitedLinksColor.SetColor(aValue.nColor);
468 57 : if(aValue.bIsVisible)
469 0 : nAppearanceFlags |= VIEWOPT_VISITED_LINKS;
470 :
471 57 : aValue = rConfig.GetColorValue(svtools::SHADOWCOLOR);
472 57 : aShadowColor.SetColor(aValue.nColor);
473 57 : if(aValue.bIsVisible)
474 57 : nAppearanceFlags |= VIEWOPT_SHADOW;
475 :
476 57 : aDirectCursorColor.SetColor(rConfig.GetColorValue(svtools::WRITERDIRECTCURSOR).nColor);
477 :
478 57 : aTextGridColor.SetColor(rConfig.GetColorValue(svtools::WRITERTEXTGRID).nColor);
479 :
480 57 : aSpellColor.SetColor(rConfig.GetColorValue(svtools::SPELL).nColor);
481 :
482 57 : aSmarttagColor.SetColor(rConfig.GetColorValue(svtools::SMARTTAGS).nColor);
483 :
484 57 : aFontColor.SetColor(rConfig.GetColorValue(svtools::FONTCOLOR).nColor);
485 :
486 57 : aValue = rConfig.GetColorValue(svtools::WRITERFIELDSHADINGS);
487 57 : aFieldShadingsColor.SetColor(aValue.nColor);
488 57 : if(aValue.bIsVisible)
489 45 : nAppearanceFlags |= VIEWOPT_FIELD_SHADINGS;
490 :
491 57 : aValue = rConfig.GetColorValue(svtools::WRITERSECTIONBOUNDARIES);
492 57 : aSectionBoundColor.SetColor(aValue.nColor);
493 57 : if(aValue.bIsVisible)
494 57 : nAppearanceFlags |= VIEWOPT_SECTION_BOUNDARIES;
495 :
496 57 : aValue = rConfig.GetColorValue(svtools::WRITERPAGEBREAKS);
497 57 : aPageBreakColor.SetColor(aValue.nColor);
498 :
499 57 : aValue = rConfig.GetColorValue(svtools::WRITERHEADERFOOTERMARK);
500 57 : aHeaderFooterMarkColor.SetColor(aValue.nColor);
501 :
502 57 : aScriptIndicatorColor.SetColor(rConfig.GetColorValue(svtools::WRITERSCRIPTINDICATOR).nColor);
503 57 : }
504 :
505 15 : void SwViewOption::SetAppearanceFlag(sal_Int32 nFlag, sal_Bool bSet, sal_Bool bSaveInConfig )
506 : {
507 15 : if(bSet)
508 5 : nAppearanceFlags |= nFlag;
509 : else
510 10 : nAppearanceFlags &= ~nFlag;
511 15 : if(bSaveInConfig)
512 : {
513 : //create an editable svtools::ColorConfig and store the change
514 12 : svtools::EditableColorConfig aEditableConfig;
515 : struct FlagToConfig_Impl
516 : {
517 : sal_Int32 nFlag;
518 : svtools::ColorConfigEntry eEntry;
519 : };
520 : static const FlagToConfig_Impl aFlags[] =
521 : {
522 : { VIEWOPT_DOC_BOUNDARIES , svtools::DOCBOUNDARIES },
523 : { VIEWOPT_OBJECT_BOUNDARIES , svtools::OBJECTBOUNDARIES },
524 : { VIEWOPT_TABLE_BOUNDARIES , svtools::TABLEBOUNDARIES },
525 : { VIEWOPT_INDEX_SHADINGS , svtools::WRITERIDXSHADINGS },
526 : { VIEWOPT_LINKS , svtools::LINKS },
527 : { VIEWOPT_VISITED_LINKS , svtools::LINKSVISITED },
528 : { VIEWOPT_FIELD_SHADINGS , svtools::WRITERFIELDSHADINGS },
529 : { VIEWOPT_SECTION_BOUNDARIES , svtools::WRITERSECTIONBOUNDARIES },
530 : { VIEWOPT_SHADOW , svtools::SHADOWCOLOR },
531 : { 0 , svtools::ColorConfigEntryCount }
532 : };
533 12 : sal_uInt16 nPos = 0;
534 132 : while(aFlags[nPos].nFlag)
535 : {
536 108 : if(0 != (nFlag&aFlags[nPos].nFlag))
537 : {
538 12 : svtools::ColorConfigValue aValue = aEditableConfig.GetColorValue(aFlags[nPos].eEntry);
539 12 : aValue.bIsVisible = bSet;
540 12 : aEditableConfig.SetColorValue(aFlags[nPos].eEntry, aValue);
541 : }
542 108 : nPos++;
543 12 : }
544 : }
545 15 : }
546 :
547 30297 : sal_Bool SwViewOption::IsAppearanceFlag(sal_Int32 nFlag)
548 : {
549 30297 : return 0 != (nAppearanceFlags & nFlag);
550 99 : }
551 :
552 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|