xref: /aoo42x/main/sw/source/ui/config/viewopt.cxx (revision 5ba3629c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <svx/htmlmode.hxx>
29 #include <svtools/htmlcfg.hxx>
30 
31 #ifndef _SVX_SVXIDS_HRC //autogen
32 #include <svx/svxids.hrc>
33 #endif
34 #include <editeng/svxenum.hxx>
35 #include <editeng/svxacorr.hxx>
36 #include <unotools/localedatawrapper.hxx>
37 #ifndef _REGION_HXX //autogen
38 #include <vcl/region.hxx>
39 #endif
40 #ifndef _OUTDEV_HXX //autogen
41 #include <vcl/outdev.hxx>
42 #endif
43 #include <vcl/window.hxx>
44 #include <swmodule.hxx>
45 #include <swtypes.hxx>
46 #include <viewopt.hxx>
47 #ifndef _WDOCSH_HXX
48 #include <wdocsh.hxx>
49 #endif
50 #include <swrect.hxx>
51 #include <crstate.hxx>
52 #include <svtools/colorcfg.hxx>
53 #include <svtools/accessibilityoptions.hxx>
54 #include <unotools/syslocale.hxx>
55 
56 #include <editeng/acorrcfg.hxx>
57 
58 #ifdef DBG_UTIL
59 sal_Bool   SwViewOption::bTest9 = sal_False;		//DrawingLayerNotLoading
60 #endif
61 Color SwViewOption::aDocBoundColor(COL_LIGHTGRAY);
62 Color SwViewOption::aObjectBoundColor(COL_LIGHTGRAY);
63 Color SwViewOption::aDocColor(COL_LIGHTGRAY);
64 Color SwViewOption::aAppBackgroundColor(COL_LIGHTGRAY);
65 Color SwViewOption::aTableBoundColor(COL_LIGHTGRAY);
66 Color SwViewOption::aIndexShadingsColor(COL_LIGHTGRAY);
67 Color SwViewOption::aLinksColor(COL_BLUE);
68 Color SwViewOption::aVisitedLinksColor(COL_RED);
69 Color SwViewOption::aDirectCursorColor(COL_BLUE);
70 Color SwViewOption::aTextGridColor(COL_LIGHTGRAY);
71 Color SwViewOption::aSpellColor(COL_LIGHTRED);
72 Color SwViewOption::aSmarttagColor(COL_LIGHTMAGENTA);
73 Color SwViewOption::aFontColor(COL_BLACK);
74 Color SwViewOption::aFieldShadingsColor(COL_LIGHTGRAY);
75 Color SwViewOption::aSectionBoundColor(COL_LIGHTGRAY);
76 Color SwViewOption::aPageBreakColor(COL_BLUE);
77 Color SwViewOption::aScriptIndicatorColor(COL_GREEN);
78 
79 sal_Int32 SwViewOption::nAppearanceFlags = VIEWOPT_DOC_BOUNDARIES|VIEWOPT_OBJECT_BOUNDARIES;
80 sal_uInt16 SwViewOption::nPixelTwips = 0;   //ein Pixel auf dem Bildschirm
81 
82 
83 #define LINEBREAK_SIZE 12, 8
84 #define TAB_SIZE 12, 6
85 
86 #define MIN_BLANKWIDTH		 40
87 #define MIN_BLANKHEIGHT 	 40
88 #define MIN_TABWIDTH		120
89 #define MIN_TABHEIGHT		200
90 
91 static const char __FAR_DATA aPostItStr[] = "  ";
92 
93 /*************************************************************************
94  *					  SwViewOption::IsEqualFlags()
95  *************************************************************************/
96 
IsEqualFlags(const SwViewOption & rOpt) const97 sal_Bool SwViewOption::IsEqualFlags( const SwViewOption &rOpt ) const
98 {
99 	return	nCoreOptions == rOpt.nCoreOptions
100 			&& nCore2Options == rOpt.nCore2Options
101 			&& aSnapSize	== rOpt.aSnapSize
102             && mnViewLayoutColumns == rOpt.mnViewLayoutColumns
103 			&& nDivisionX	== rOpt.GetDivisionX()
104 			&& nDivisionY	== rOpt.GetDivisionY()
105 			&& nPagePrevRow == rOpt.GetPagePrevRow()
106 			&& nPagePrevCol == rOpt.GetPagePrevCol()
107 			&& aRetoucheColor == rOpt.GetRetoucheColor()
108             && mbFormView == rOpt.IsFormView()
109             && mbBrowseMode == rOpt.getBrowseMode()
110             && mbViewLayoutBookMode == rOpt.mbViewLayoutBookMode
111             && bShowPlaceHolderFields == rOpt.bShowPlaceHolderFields
112             && bIdle == rOpt.bIdle
113 #ifdef DBG_UTIL
114 			// korrespondieren zu den Angaben in ui/config/cfgvw.src
115 			&& bTest1 == rOpt.IsTest1()
116 			&& bTest2 == rOpt.IsTest2()
117 			&& bTest3 == rOpt.IsTest3()
118 			&& bTest4 == rOpt.IsTest4()
119 			&& bTest5 == rOpt.IsTest5()
120 			&& bTest6 == rOpt.IsTest6()
121 			&& bTest7 == rOpt.IsTest7()
122 			&& bTest8 == rOpt.IsTest8()
123 			&& bTest10 == rOpt.IsTest10()
124 #endif
125 			;
126 }
127 
128 /*************************************************************************
129  *					  SwViewOption::DrawRect()
130  *************************************************************************/
131 
DrawRect(OutputDevice * pOut,const SwRect & rRect,long nCol) const132 void SwViewOption::DrawRect( OutputDevice *pOut,
133 							 const SwRect &rRect, long nCol ) const
134 {
135 	if ( pOut->GetOutDevType() != OUTDEV_PRINTER )
136 	{
137 		const Color aCol( nCol );
138 		const Color aOldColor( pOut->GetFillColor() );
139 		pOut->SetFillColor( aCol );
140 		pOut->DrawRect( rRect.SVRect() );
141 		pOut->SetFillColor( aOldColor );
142 	}
143 	else
144 		DrawRectPrinter( pOut, rRect );
145 }
146 
147 /*************************************************************************
148  *					  SwViewOption::DrawRectPrinter()
149  *************************************************************************/
150 
DrawRectPrinter(OutputDevice * pOut,const SwRect & rRect) const151 void SwViewOption::DrawRectPrinter( OutputDevice *pOut,
152 									const SwRect &rRect ) const
153 {
154 	Color aOldColor(pOut->GetLineColor());
155 	Color aOldFillColor( pOut->GetFillColor() );
156 	pOut->SetLineColor( Color(COL_BLACK) );
157 	pOut->SetFillColor( Color(COL_TRANSPARENT ));
158 	pOut->DrawRect( rRect.SVRect() );
159 	pOut->SetFillColor( aOldFillColor );
160 	pOut->SetLineColor( aOldColor );
161 }
162 
163 /*************************************************************************
164  *					  SwViewOption::GetPostItsWidth()
165  *************************************************************************/
166 
GetPostItsWidth(const OutputDevice * pOut) const167 sal_uInt16 SwViewOption::GetPostItsWidth( const OutputDevice *pOut ) const
168 {
169 	ASSERT( pOut, "no Outdev" );
170 	return sal_uInt16(pOut->GetTextWidth( String::CreateFromAscii(aPostItStr )));
171 }
172 
173 /*************************************************************************
174  *					  SwViewOption::PaintPostIts()
175  *************************************************************************/
176 
PaintPostIts(OutputDevice * pOut,const SwRect & rRect,sal_Bool bIsScript) const177 void SwViewOption::PaintPostIts( OutputDevice *pOut, const SwRect &rRect, sal_Bool bIsScript ) const
178 {
179 	if( pOut && bIsScript )
180 	{
181         	Color aOldLineColor( pOut->GetLineColor() );
182 		pOut->SetLineColor( Color(COL_GRAY ) );
183 		// Wir ziehen ueberall zwei Pixel ab, damit es schick aussieht
184 		sal_uInt16 nPix = GetPixelTwips() * 2;
185 		if( rRect.Width() <= 2 * nPix || rRect.Height() <= 2 * nPix )
186 			nPix = 0;
187 		const Point aTopLeft(  rRect.Left()  + nPix, rRect.Top()	+ nPix );
188 		const Point aBotRight( rRect.Right() - nPix, rRect.Bottom() - nPix );
189 		const SwRect aRect( aTopLeft, aBotRight );
190         DrawRect( pOut, aRect, aScriptIndicatorColor.GetColor() );
191 	pOut->SetLineColor( aOldLineColor );
192 	}
193 }
194 
195 
196 /*************************************************************************
197 |*
198 |*	ViewOption::ViewOption()
199 |*
200 |*	Letzte Aenderung	MA 04. Aug. 93
201 |*
202 |*************************************************************************/
203 
SwViewOption()204 SwViewOption::SwViewOption() :
205     aRetoucheColor( COL_TRANSPARENT ),
206     mnViewLayoutColumns( 0 ),
207     nPagePrevRow( 1 ),
208     nPagePrevCol( 2 ),
209     nShdwCrsrFillMode( FILL_TAB ),
210     bReadonly(sal_False),
211     bStarOneSetting(sal_False),
212     bIsPagePreview(sal_False),
213     bSelectionInReadonly(sal_False),
214     mbFormView(sal_False),
215 	mbBrowseMode(sal_False),
216     mbBookView(sal_False),
217     mbViewLayoutBookMode(sal_False),
218     bShowPlaceHolderFields( sal_True ),
219 
220     nZoom( 100 ),
221     eZoom( SVX_ZOOM_PERCENT ),
222     nTblDest(TBL_DEST_CELL)
223 {
224 	// Initialisierung ist jetzt etwas einfacher
225 	// alle Bits auf 0
226     nCoreOptions =
227         VIEWOPT_1_HARDBLANK |
228         VIEWOPT_1_SOFTHYPH |
229         VIEWOPT_1_REF |
230         VIEWOPT_1_GRAPHIC |
231         VIEWOPT_1_TABLE |
232         VIEWOPT_1_DRAW |
233         VIEWOPT_1_CONTROL |
234         VIEWOPT_1_PAGEBACK |
235         VIEWOPT_1_POSTITS;
236 
237     nCore2Options =
238         VIEWOPT_CORE2_BLACKFONT |
239         VIEWOPT_CORE2_HIDDENPARA |
240         VIEWOPT_CORE2_BIGMARKHDL; // default is big handles
241 
242     nUIOptions =
243         VIEWOPT_2_MODIFIED |
244         VIEWOPT_2_GRFKEEPZOOM |
245         VIEWOPT_2_ANY_RULER;
246 
247 	if(MEASURE_METRIC != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum())
248 		aSnapSize.Width() = aSnapSize.Height() = 720;	// 1/2"
249 	else
250 		aSnapSize.Width() = aSnapSize.Height() = 567;	// 1 cm
251 	nDivisionX = nDivisionY = 1;
252 
253     bSelectionInReadonly = SW_MOD()->GetAccessibilityOptions().IsSelectionInReadonly();
254 
255     bIdle = true;
256 
257 #ifdef DBG_UTIL
258 	// korrespondieren zu den Angaben in ui/config/cfgvw.src
259 	bTest1 = bTest2 = bTest3 = bTest4 =
260 			 bTest5 = bTest6 = bTest7 = bTest8 = bTest10 = sal_False;
261 #endif
262 }
263 
SwViewOption(const SwViewOption & rVOpt)264 SwViewOption::SwViewOption(const SwViewOption& rVOpt)
265 {
266 	bReadonly = sal_False;
267     bSelectionInReadonly = sal_False;
268     // --> FME 2004-06-29 #114856# Formular view
269     mbFormView       = rVOpt.mbFormView;
270     // <--
271     nZoom           = rVOpt.nZoom       ;
272 	aSnapSize   	= rVOpt.aSnapSize   ;
273     mnViewLayoutColumns = rVOpt.mnViewLayoutColumns ;
274 	nDivisionX  	= rVOpt.nDivisionX  ;
275 	nDivisionY  	= rVOpt.nDivisionY  ;
276 	nPagePrevRow	= rVOpt.nPagePrevRow;
277 	nPagePrevCol	= rVOpt.nPagePrevCol;
278     bIsPagePreview  = rVOpt.bIsPagePreview;
279 	eZoom      		= rVOpt.eZoom       ;
280 	nTblDest    	= rVOpt.nTblDest    ;
281 	nUIOptions		= rVOpt.nUIOptions  ;
282 	nCoreOptions	= rVOpt.nCoreOptions  ;
283 	nCore2Options	= rVOpt.nCore2Options  ;
284 	aRetoucheColor	= rVOpt.GetRetoucheColor();
285 	sSymbolFont 	= rVOpt.sSymbolFont;
286 	nShdwCrsrFillMode = rVOpt.nShdwCrsrFillMode;
287 	bStarOneSetting = rVOpt.bStarOneSetting;
288 	mbBookView	    = rVOpt.mbBookView;
289 	mbBrowseMode	= rVOpt.mbBrowseMode;
290     mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode;
291     bShowPlaceHolderFields = rVOpt.bShowPlaceHolderFields;
292     bIdle           = rVOpt.bIdle;
293 
294 #ifdef DBG_UTIL
295 	bTest1          = rVOpt.bTest1      ;
296 	bTest2          = rVOpt.bTest2      ;
297 	bTest3          = rVOpt.bTest3      ;
298 	bTest4          = rVOpt.bTest4      ;
299 	bTest5          = rVOpt.bTest5      ;
300 	bTest6          = rVOpt.bTest6      ;
301 	bTest7          = rVOpt.bTest7      ;
302 	bTest8          = rVOpt.bTest8      ;
303 	bTest10         = rVOpt.bTest10     ;
304 #endif
305 }
306 
307 
operator =(const SwViewOption & rVOpt)308 SwViewOption& SwViewOption::operator=( const SwViewOption &rVOpt )
309 {
310     // --> DVO FME 2004-06-29 #114856# Formular view
311     mbFormView       = rVOpt.mbFormView   ;
312     // <--
313 	nZoom   		= rVOpt.nZoom   	;
314 	aSnapSize   	= rVOpt.aSnapSize   ;
315     mnViewLayoutColumns = rVOpt.mnViewLayoutColumns ;
316 	nDivisionX  	= rVOpt.nDivisionX  ;
317 	nDivisionY  	= rVOpt.nDivisionY  ;
318 	nPagePrevRow	= rVOpt.nPagePrevRow;
319 	nPagePrevCol	= rVOpt.nPagePrevCol;
320     bIsPagePreview  = rVOpt.bIsPagePreview;
321 	eZoom      		= rVOpt.eZoom       ;
322 	nTblDest    	= rVOpt.nTblDest    ;
323 	nUIOptions		= rVOpt.nUIOptions  ;
324 	nCoreOptions	= rVOpt.nCoreOptions;
325 	nCore2Options	= rVOpt.nCore2Options;
326 	aRetoucheColor	= rVOpt.GetRetoucheColor();
327 	sSymbolFont 	= rVOpt.sSymbolFont;
328 	nShdwCrsrFillMode = rVOpt.nShdwCrsrFillMode;
329 	bStarOneSetting = rVOpt.bStarOneSetting;
330 	mbBookView	    = rVOpt.mbBookView;
331 	mbBrowseMode	= rVOpt.mbBrowseMode;
332     mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode;
333     bShowPlaceHolderFields = rVOpt.bShowPlaceHolderFields;
334     bIdle           = rVOpt.bIdle;
335 
336 #ifdef DBG_UTIL
337 	bTest1          = rVOpt.bTest1      ;
338 	bTest2          = rVOpt.bTest2      ;
339 	bTest3          = rVOpt.bTest3      ;
340 	bTest4          = rVOpt.bTest4      ;
341 	bTest5          = rVOpt.bTest5      ;
342 	bTest6          = rVOpt.bTest6      ;
343 	bTest7          = rVOpt.bTest7      ;
344 	bTest8          = rVOpt.bTest8      ;
345 	bTest10         = rVOpt.bTest10     ;
346 #endif
347 	return *this;
348 }
349 
350 
~SwViewOption()351 SwViewOption::~SwViewOption()
352 {
353 }
354 
355 /*************************************************************************
356 |*
357 |*	ViewOption::Init()
358 |*
359 |*	Letzte Aenderung	MA 04. Aug. 93
360 |*
361 |*************************************************************************/
362 
Init(Window * pWin)363 void SwViewOption::Init( Window *pWin )
364 {
365 	if( !nPixelTwips && pWin )
366 	{
367 		nPixelTwips = (sal_uInt16)pWin->PixelToLogic( Size(1,1) ).Height();
368 	}
369 }
370 
IsAutoCompleteWords() const371 sal_Bool SwViewOption::IsAutoCompleteWords() const
372 {
373 	const SvxSwAutoFmtFlags& rFlags = SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags();
374 	return /*rFlags.bAutoCompleteWords &&*/ rFlags.bAutoCmpltCollectWords;
375 }
376 
377 /*************************************************************************/
378 /*                                                                       */
379 /*************************************************************************/
380 
AuthorCharAttr()381 AuthorCharAttr::AuthorCharAttr() :
382 	nItemId	(SID_ATTR_CHAR_UNDERLINE),
383 	nAttr	(UNDERLINE_SINGLE),
384 	nColor	(COL_TRANSPARENT)
385 {
386 }
387 
388 /*-----------------07.01.97 13.50-------------------
389 
390 --------------------------------------------------*/
391 
GetHtmlMode(const SwDocShell * pShell)392 sal_uInt16		GetHtmlMode(const SwDocShell* pShell)
393 {
394 	sal_uInt16 nRet = 0;
395 	if(!pShell || PTR_CAST(SwWebDocShell, pShell))
396 	{
397 		nRet = HTMLMODE_ON;
398 		SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
399 		switch ( pHtmlOpt->GetExportMode() )
400 		{
401 			case HTML_CFG_MSIE_40:
402 				nRet |= HTMLMODE_PARA_BORDER|HTMLMODE_SMALL_CAPS|
403 						HTMLMODE_SOME_STYLES|
404 						HTMLMODE_FULL_STYLES|HTMLMODE_GRAPH_POS|
405 						HTMLMODE_FULL_ABS_POS|HTMLMODE_SOME_ABS_POS;
406 			break;
407 			case HTML_CFG_NS40:
408 				nRet |= HTMLMODE_PARA_BORDER|HTMLMODE_SOME_STYLES|
409 						HTMLMODE_FRM_COLUMNS|HTMLMODE_BLINK|HTMLMODE_GRAPH_POS|
410 						HTMLMODE_SOME_ABS_POS;
411 			break;
412 			case HTML_CFG_WRITER:
413 				nRet |= HTMLMODE_PARA_BORDER|HTMLMODE_SMALL_CAPS|
414 						HTMLMODE_SOME_STYLES|
415 						HTMLMODE_FRM_COLUMNS|HTMLMODE_FULL_STYLES|
416 						HTMLMODE_BLINK|HTMLMODE_DROPCAPS|HTMLMODE_GRAPH_POS|
417 						HTMLMODE_FULL_ABS_POS|HTMLMODE_SOME_ABS_POS;
418 			break;
419 			case HTML_CFG_HTML32:
420 			break;
421 		}
422 	}
423 	return nRet;
424 }
425 /* -----------------------------24.04.2002 10:20------------------------------
426 
427  ---------------------------------------------------------------------------*/
GetDocColor()428 Color&   SwViewOption::GetDocColor()
429 {
430     return aDocColor;
431 }
432 /* -----------------------------23.04.2002 17:18------------------------------
433 
434  ---------------------------------------------------------------------------*/
GetDocBoundariesColor()435 Color&   SwViewOption::GetDocBoundariesColor()
436 {
437     return aDocBoundColor;
438 }
439 /* -----------------------------23.04.2002 17:53------------------------------
440 
441  ---------------------------------------------------------------------------*/
GetObjectBoundariesColor()442 Color&   SwViewOption::GetObjectBoundariesColor()
443 {
444     return aObjectBoundColor;
445 }
446 /* -----------------------------24.04.2002 10:41------------------------------
447 
448  ---------------------------------------------------------------------------*/
GetAppBackgroundColor()449 Color& SwViewOption::GetAppBackgroundColor()
450 {
451     return aAppBackgroundColor;
452 }
453 /*-- 24.04.2002 10:50:11---------------------------------------------------
454 
455   -----------------------------------------------------------------------*/
GetTableBoundariesColor()456 Color&   SwViewOption::GetTableBoundariesColor()
457 {
458     return aTableBoundColor;
459 }
460 /*-- 24.04.2002 10:50:12---------------------------------------------------
461 
462   -----------------------------------------------------------------------*/
GetIndexShadingsColor()463 Color&   SwViewOption::GetIndexShadingsColor()
464 {
465     return aIndexShadingsColor;
466 }
467 /*-- 24.04.2002 10:50:12---------------------------------------------------
468 
469   -----------------------------------------------------------------------*/
GetLinksColor()470 Color&   SwViewOption::GetLinksColor()
471 {
472     return aLinksColor;
473 }
474 /*-- 24.04.2002 10:50:13---------------------------------------------------
475 
476   -----------------------------------------------------------------------*/
GetVisitedLinksColor()477 Color&   SwViewOption::GetVisitedLinksColor()
478 {
479     return aVisitedLinksColor;
480 }
481 /*-- 24.04.2002 10:50:13---------------------------------------------------
482 
483   -----------------------------------------------------------------------*/
GetDirectCursorColor()484 Color&   SwViewOption::GetDirectCursorColor()
485 {
486     return aDirectCursorColor;
487 }
488 /*-- 24.04.2002 10:50:14---------------------------------------------------
489 
490   -----------------------------------------------------------------------*/
GetTextGridColor()491 Color&   SwViewOption::GetTextGridColor()
492 {
493     return aTextGridColor;
494 }
495 /*-- 24.04.2002 10:50:14---------------------------------------------------
496 
497   -----------------------------------------------------------------------*/
GetSpellColor()498 Color&   SwViewOption::GetSpellColor()
499 {
500     return aSpellColor;
501 }
502 /*-- 24.04.2007 10:50:14---------------------------------------------------
503 
504   -----------------------------------------------------------------------*/
GetSmarttagColor()505 Color&   SwViewOption::GetSmarttagColor()
506 {
507     return aSmarttagColor;
508 }
509 /*-- 06.12.2002 10:50:11---------------------------------------------------
510 
511   -----------------------------------------------------------------------*/
GetFontColor()512 Color&   SwViewOption::GetFontColor()
513 {
514     return aFontColor;
515 }
516 /*-- 24.04.2002 10:50:15---------------------------------------------------
517 
518   -----------------------------------------------------------------------*/
GetFieldShadingsColor()519 Color&   SwViewOption::GetFieldShadingsColor()
520 {
521     return aFieldShadingsColor;
522 }
523 /*-- 24.04.2002 10:50:15---------------------------------------------------
524 
525   -----------------------------------------------------------------------*/
GetSectionBoundColor()526 Color&   SwViewOption::GetSectionBoundColor()
527 {
528     return aSectionBoundColor;
529 }
530 /* -----------------------------2002/07/31 14:00------------------------------
531 
532  ---------------------------------------------------------------------------*/
GetPageBreakColor()533 Color& SwViewOption::GetPageBreakColor()
534 {
535     return aPageBreakColor;
536 }
537 
538 /* -----------------------------23.04.2002 17:41------------------------------
539 
540  ---------------------------------------------------------------------------*/
ApplyColorConfigValues(const svtools::ColorConfig & rConfig)541 void SwViewOption::ApplyColorConfigValues(const svtools::ColorConfig& rConfig )
542 {
543     aDocColor.SetColor(rConfig.GetColorValue(svtools::DOCCOLOR).nColor);
544 
545     svtools::ColorConfigValue aValue = rConfig.GetColorValue(svtools::DOCBOUNDARIES);
546     aDocBoundColor.SetColor(aValue.nColor);
547     nAppearanceFlags = 0;
548     if(aValue.bIsVisible)
549         nAppearanceFlags |= VIEWOPT_DOC_BOUNDARIES;
550 
551     aAppBackgroundColor.SetColor(rConfig.GetColorValue(svtools::APPBACKGROUND).nColor);
552 
553     aValue = rConfig.GetColorValue(svtools::OBJECTBOUNDARIES);
554     aObjectBoundColor.SetColor(aValue.nColor);
555     if(aValue.bIsVisible)
556         nAppearanceFlags |= VIEWOPT_OBJECT_BOUNDARIES;
557 
558     aValue = rConfig.GetColorValue(svtools::TABLEBOUNDARIES);
559     aTableBoundColor.SetColor(aValue.nColor);
560     if(aValue.bIsVisible)
561         nAppearanceFlags |= VIEWOPT_TABLE_BOUNDARIES;
562 
563     aValue = rConfig.GetColorValue(svtools::WRITERIDXSHADINGS);
564     aIndexShadingsColor.SetColor(aValue.nColor);
565     if(aValue.bIsVisible)
566         nAppearanceFlags |= VIEWOPT_INDEX_SHADINGS;
567 
568     aValue = rConfig.GetColorValue(svtools::LINKS);
569     aLinksColor.SetColor(aValue.nColor);
570     if(aValue.bIsVisible)
571         nAppearanceFlags |= VIEWOPT_LINKS;
572 
573     aValue = rConfig.GetColorValue(svtools::LINKSVISITED);
574     aVisitedLinksColor.SetColor(aValue.nColor);
575     if(aValue.bIsVisible)
576         nAppearanceFlags |= VIEWOPT_VISITED_LINKS;
577 
578     aDirectCursorColor.SetColor(rConfig.GetColorValue(svtools::WRITERDIRECTCURSOR).nColor);
579 
580     aTextGridColor.SetColor(rConfig.GetColorValue(svtools::WRITERTEXTGRID).nColor);
581 
582     aSpellColor.SetColor(rConfig.GetColorValue(svtools::SPELL).nColor);
583 
584     aSmarttagColor.SetColor(rConfig.GetColorValue(svtools::SMARTTAGS).nColor);
585 
586     aFontColor.SetColor(rConfig.GetColorValue(svtools::FONTCOLOR).nColor);
587 
588     aValue = rConfig.GetColorValue(svtools::WRITERFIELDSHADINGS);
589     aFieldShadingsColor.SetColor(aValue.nColor);
590     if(aValue.bIsVisible)
591         nAppearanceFlags |= VIEWOPT_FIELD_SHADINGS;
592 
593     aValue = rConfig.GetColorValue(svtools::WRITERSECTIONBOUNDARIES);
594     aSectionBoundColor.SetColor(aValue.nColor);
595     if(aValue.bIsVisible)
596         nAppearanceFlags |= VIEWOPT_SECTION_BOUNDARIES;
597 
598     aValue = rConfig.GetColorValue(svtools::WRITERPAGEBREAKS);
599     aPageBreakColor.SetColor(aValue.nColor);
600 
601     aScriptIndicatorColor.SetColor(rConfig.GetColorValue(svtools::WRITERSCRIPTINDICATOR).nColor);
602 }
603 /* -----------------------------23.04.2002 17:48------------------------------
604 
605  ---------------------------------------------------------------------------*/
SetAppearanceFlag(sal_Int32 nFlag,sal_Bool bSet,sal_Bool bSaveInConfig)606 void SwViewOption::SetAppearanceFlag(sal_Int32 nFlag, sal_Bool bSet, sal_Bool bSaveInConfig )
607 {
608     if(bSet)
609         nAppearanceFlags |= nFlag;
610     else
611         nAppearanceFlags &= ~nFlag;
612     if(bSaveInConfig)
613     {
614         //create an editable svtools::ColorConfig and store the change
615         svtools::EditableColorConfig aEditableConfig;
616         struct FlagToConfig_Impl
617         {
618             sal_Int32               nFlag;
619             svtools::ColorConfigEntry   eEntry;
620         };
621         static const FlagToConfig_Impl aFlags[] =
622         {
623             { VIEWOPT_DOC_BOUNDARIES     ,   svtools::DOCBOUNDARIES },
624             { VIEWOPT_OBJECT_BOUNDARIES  ,   svtools::OBJECTBOUNDARIES },
625             { VIEWOPT_TABLE_BOUNDARIES   ,   svtools::TABLEBOUNDARIES },
626             { VIEWOPT_INDEX_SHADINGS     ,   svtools::WRITERIDXSHADINGS },
627             { VIEWOPT_LINKS              ,   svtools::LINKS },
628             { VIEWOPT_VISITED_LINKS      ,   svtools::LINKSVISITED },
629             { VIEWOPT_FIELD_SHADINGS     ,   svtools::WRITERFIELDSHADINGS },
630             { VIEWOPT_SECTION_BOUNDARIES ,   svtools::WRITERSECTIONBOUNDARIES },
631             { 0                          ,   svtools::ColorConfigEntryCount }
632         };
633         sal_uInt16 nPos = 0;
634         while(aFlags[nPos].nFlag)
635         {
636             if(0 != (nFlag&aFlags[nPos].nFlag))
637             {
638                 svtools::ColorConfigValue aValue = aEditableConfig.GetColorValue(aFlags[nPos].eEntry);
639                 aValue.bIsVisible = bSet;
640                 aEditableConfig.SetColorValue(aFlags[nPos].eEntry, aValue);
641             }
642             nPos++;
643         }
644     }
645 }
646 /* -----------------------------24.04.2002 10:42------------------------------
647 
648  ---------------------------------------------------------------------------*/
IsAppearanceFlag(sal_Int32 nFlag)649 sal_Bool SwViewOption::IsAppearanceFlag(sal_Int32 nFlag)
650 {
651     return 0 != (nAppearanceFlags & nFlag);
652 }
653 
654