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