/src/libreoffice/sw/source/uibase/config/viewopt.cxx
Line | Count | Source |
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> |
26 | | #include <unotools/localedatawrapper.hxx> |
27 | | #include <vcl/outdev.hxx> |
28 | | #include <swmodule.hxx> |
29 | | #include <viewopt.hxx> |
30 | | #include <wdocsh.hxx> |
31 | | #include <swrect.hxx> |
32 | | #include <viewsh.hxx> |
33 | | #include <view.hxx> |
34 | | #include <wrtsh.hxx> |
35 | | #include <crstate.hxx> |
36 | | #include <authratr.hxx> |
37 | | #include <svtools/colorcfg.hxx> |
38 | | #include <unotools/syslocale.hxx> |
39 | | |
40 | | #include <editeng/acorrcfg.hxx> |
41 | | #include <comphelper/lok.hxx> |
42 | | #include <comphelper/configurationlistener.hxx> |
43 | | |
44 | | SwViewColors SwViewOption::s_aInitialColorConfig {}; |
45 | | |
46 | | SwViewColors::SwViewColors() : |
47 | 75.9k | m_aDocColor(COL_LIGHTGRAY), |
48 | 75.9k | m_aDocBoundColor(COL_LIGHTGRAY), |
49 | 75.9k | m_aAppBackgroundColor(COL_LIGHTGRAY), |
50 | 75.9k | m_aTableBoundColor(COL_LIGHTGRAY), |
51 | 75.9k | m_aFontColor(COL_BLACK), |
52 | 75.9k | m_aIndexShadingsColor(COL_LIGHTGRAY), |
53 | 75.9k | m_aLinksColor(COL_BLUE), |
54 | 75.9k | m_aVisitedLinksColor(COL_RED), |
55 | 75.9k | m_aTextGridColor(COL_LIGHTGRAY), |
56 | 75.9k | m_aSpellColor(COL_LIGHTRED), |
57 | 75.9k | m_aGrammarColor(COL_LIGHTBLUE), |
58 | 75.9k | m_aSmarttagColor(COL_LIGHTMAGENTA), |
59 | 75.9k | m_aFieldShadingsColor(COL_LIGHTGRAY), |
60 | 75.9k | m_aSectionBoundColor(COL_LIGHTGRAY), |
61 | 75.9k | m_aPageBreakColor(COL_BLUE), |
62 | 75.9k | m_aNonPrintingCharacterColor(Color(0x268bd2)), |
63 | 75.9k | m_aShadowColor(COL_GRAY), |
64 | 75.9k | m_aHeaderFooterMarkColor(COL_BLUE), |
65 | 75.9k | m_nAppearanceFlags(ViewOptFlags::NONE) |
66 | 75.9k | {} |
67 | | |
68 | | SwViewColors::SwViewColors(const svtools::ColorConfig& rConfig) |
69 | 1 | { |
70 | 1 | m_aDocColor = rConfig.GetColorValue(svtools::DOCCOLOR).nColor; |
71 | | |
72 | 1 | m_aDocBoundColor = rConfig.GetColorValue(svtools::DOCBOUNDARIES).nColor; |
73 | 1 | m_nAppearanceFlags = ViewOptFlags::NONE; |
74 | 1 | m_aAppBackgroundColor = rConfig.GetColorValue(svtools::APPBACKGROUND).nColor; |
75 | 1 | m_aTableBoundColor = rConfig.GetColorValue(svtools::TABLEBOUNDARIES).nColor; |
76 | | |
77 | 1 | svtools::ColorConfigValue aValue; |
78 | | |
79 | 1 | aValue = rConfig.GetColorValue(svtools::WRITERIDXSHADINGS); |
80 | 1 | m_aIndexShadingsColor = aValue.nColor; |
81 | 1 | if(aValue.bIsVisible) |
82 | 0 | m_nAppearanceFlags |= ViewOptFlags::IndexShadings; |
83 | | |
84 | 1 | aValue = rConfig.GetColorValue(svtools::LINKS); |
85 | 1 | m_aLinksColor = aValue.nColor; |
86 | 1 | if(aValue.bIsVisible) |
87 | 0 | m_nAppearanceFlags |= ViewOptFlags::Links; |
88 | | |
89 | 1 | aValue = rConfig.GetColorValue(svtools::LINKSVISITED); |
90 | 1 | m_aVisitedLinksColor = aValue.nColor; |
91 | 1 | if(aValue.bIsVisible) |
92 | 0 | m_nAppearanceFlags |= ViewOptFlags::VisitedLinks; |
93 | | |
94 | 1 | aValue = rConfig.GetColorValue(svtools::SHADOWCOLOR); |
95 | 1 | m_aShadowColor = aValue.nColor; |
96 | 1 | if(aValue.bIsVisible) |
97 | 0 | m_nAppearanceFlags |= ViewOptFlags::Shadow; |
98 | | |
99 | 1 | m_aTextGridColor = rConfig.GetColorValue(svtools::WRITERTEXTGRID).nColor; |
100 | | |
101 | 1 | m_aSpellColor = rConfig.GetColorValue(svtools::SPELL).nColor; |
102 | 1 | m_aGrammarColor = rConfig.GetColorValue(svtools::GRAMMAR).nColor; |
103 | | |
104 | 1 | m_aSmarttagColor = rConfig.GetColorValue(svtools::SMARTTAGS).nColor; |
105 | | |
106 | 1 | m_aFontColor = rConfig.GetColorValue(svtools::FONTCOLOR).nColor; |
107 | | |
108 | 1 | aValue = rConfig.GetColorValue(svtools::WRITERFIELDSHADINGS); |
109 | 1 | m_aFieldShadingsColor = aValue.nColor; |
110 | | // as in initializeForTiledRendering we don't want to enable |
111 | | // field shadings for the online case |
112 | 1 | if (aValue.bIsVisible && !comphelper::LibreOfficeKit::isActive()) |
113 | 0 | m_nAppearanceFlags |= ViewOptFlags::FieldShadings; |
114 | | |
115 | 1 | m_aSectionBoundColor = rConfig.GetColorValue(svtools::WRITERSECTIONBOUNDARIES).nColor; |
116 | | |
117 | 1 | aValue = rConfig.GetColorValue(svtools::WRITERPAGEBREAKS); |
118 | 1 | m_aPageBreakColor = aValue.nColor; |
119 | | |
120 | 1 | aValue = rConfig.GetColorValue(svtools::WRITERNONPRINTCHARS); |
121 | 1 | m_aNonPrintingCharacterColor = aValue.nColor; |
122 | | |
123 | 1 | aValue = rConfig.GetColorValue(svtools::WRITERHEADERFOOTERMARK); |
124 | 1 | m_aHeaderFooterMarkColor = aValue.nColor; |
125 | 1 | } |
126 | | |
127 | | bool SwViewOption::IsEqualFlags( const SwViewOption &rOpt ) const |
128 | 11.4k | { |
129 | 11.4k | return m_nCoreOptions == rOpt.m_nCoreOptions |
130 | 434 | && m_nCore2Options == rOpt.m_nCore2Options |
131 | 434 | && m_aSnapSize == rOpt.m_aSnapSize |
132 | 434 | && mnViewLayoutColumns == rOpt.mnViewLayoutColumns |
133 | 418 | && m_nDivisionX == rOpt.GetDivisionX() |
134 | 418 | && m_nDivisionY == rOpt.GetDivisionY() |
135 | 418 | && m_nPagePreviewRow == rOpt.GetPagePrevRow() |
136 | 418 | && m_nPagePreviewCol == rOpt.GetPagePrevCol() |
137 | 418 | && m_aRetouchColor == rOpt.GetRetoucheColor() |
138 | 418 | && mbFormView == rOpt.IsFormView() |
139 | 418 | && mbBrowseMode == rOpt.getBrowseMode() |
140 | 320 | && mbViewLayoutBookMode == rOpt.mbViewLayoutBookMode |
141 | 320 | && mbHideWhitespaceMode == rOpt.mbHideWhitespaceMode |
142 | 320 | && m_bShowPlaceHolderFields == rOpt.m_bShowPlaceHolderFields |
143 | 320 | && m_bIdle == rOpt.m_bIdle |
144 | 320 | && m_nDefaultAnchor == rOpt.m_nDefaultAnchor |
145 | | #ifdef DBG_UTIL |
146 | | // correspond to the statements in ui/config/cfgvw.src |
147 | | && m_bTest1 == rOpt.IsTest1() |
148 | | && m_bTest2 == rOpt.IsTest2() |
149 | | && m_bTest3 == rOpt.IsTest3() |
150 | | && m_bTest4 == rOpt.IsTest4() |
151 | | && m_bTest5 == rOpt.IsTest5() |
152 | | && m_bTest6 == rOpt.IsTest6() |
153 | | && m_bTest7 == rOpt.IsTest7() |
154 | | && m_bTest8 == rOpt.IsTest8() |
155 | | && m_bTest10 == rOpt.IsTest10() |
156 | | #endif |
157 | 11.4k | ; |
158 | 11.4k | } |
159 | | |
160 | | bool SwViewOption::IsShowOutlineContentVisibilityButton() const |
161 | 189k | { |
162 | 189k | return m_nCoreOptions.bShowOutlineContentVisibilityButton; |
163 | 189k | } |
164 | | |
165 | | bool SwViewOption::IsTreatSubOutlineLevelsAsContent() const |
166 | 0 | { |
167 | 0 | return m_nCoreOptions.bTreatSubOutlineLevelsAsContent; |
168 | 0 | } |
169 | | |
170 | | void SwViewOption::DrawRect( OutputDevice *pOut, |
171 | | const SwRect &rRect, ::Color nCol ) |
172 | 0 | { |
173 | 0 | if ( pOut->GetOutDevType() != OUTDEV_PRINTER ) |
174 | 0 | { |
175 | 0 | const Color aCol( nCol ); |
176 | 0 | const Color aOldColor( pOut->GetFillColor() ); |
177 | 0 | pOut->SetFillColor( aCol ); |
178 | 0 | pOut->DrawRect( rRect.SVRect() ); |
179 | 0 | pOut->SetFillColor( aOldColor ); |
180 | 0 | } |
181 | 0 | else |
182 | 0 | DrawRectPrinter( pOut, rRect ); |
183 | 0 | } |
184 | | |
185 | | void SwViewOption::DrawRectPrinter( OutputDevice *pOut, |
186 | | const SwRect &rRect ) |
187 | 0 | { |
188 | 0 | Color aOldColor(pOut->GetLineColor()); |
189 | 0 | Color aOldFillColor( pOut->GetFillColor() ); |
190 | 0 | pOut->SetLineColor( COL_BLACK ); |
191 | 0 | pOut->SetFillColor( COL_TRANSPARENT); |
192 | 0 | pOut->DrawRect( rRect.SVRect() ); |
193 | 0 | pOut->SetFillColor( aOldFillColor ); |
194 | 0 | pOut->SetLineColor( aOldColor ); |
195 | 0 | } |
196 | | |
197 | | SwTwips SwViewOption::GetPostItsWidth(const OutputDevice* pOut) |
198 | 0 | { |
199 | 0 | assert(pOut && "no Outdev"); |
200 | 0 | return pOut->GetTextWidth(u" "_ustr); |
201 | 0 | } |
202 | | |
203 | | void SwViewOption::PaintPostIts( OutputDevice *pOut, const SwRect &rRect, bool bIsScript ) |
204 | 0 | { |
205 | 0 | if( !(pOut && bIsScript) ) |
206 | 0 | return; |
207 | | |
208 | 0 | Color aOldLineColor( pOut->GetLineColor() ); |
209 | 0 | pOut->SetLineColor( COL_GRAY ); |
210 | | // to make it look nice, we subtract two pixels everywhere |
211 | 0 | SwTwips nPix = o3tl::narrowing<sal_uInt16>(pOut->PixelToLogic( Size(1,1) ).Height()) * 2; |
212 | 0 | if( rRect.Width() <= 2 * nPix || rRect.Height() <= 2 * nPix ) |
213 | 0 | nPix = 0; |
214 | 0 | const Point aTopLeft( rRect.Left() + nPix, rRect.Top() + nPix ); |
215 | 0 | const Point aBotRight( rRect.Right() - nPix, rRect.Bottom() - nPix ); |
216 | 0 | const SwRect aRect( aTopLeft, aBotRight ); |
217 | 0 | DrawRect( pOut, aRect, COL_GREEN ); |
218 | 0 | pOut->SetLineColor( aOldLineColor ); |
219 | 0 | } |
220 | | |
221 | | SwViewOption::SwViewOption() : |
222 | 64.2k | m_sThemeName( u"Default"_ustr ), |
223 | 64.2k | m_sSymbolFont( u"symbol"_ustr ), |
224 | 64.2k | m_aRetouchColor( COL_TRANSPARENT ), |
225 | 64.2k | mnViewLayoutColumns( 0 ), |
226 | 64.2k | m_nPagePreviewRow( 1 ), |
227 | 64.2k | m_nPagePreviewCol( 2 ), |
228 | 64.2k | m_nShadowCursorFillMode( SwFillMode::Tab ), |
229 | 64.2k | m_bReadonly(false), |
230 | 64.2k | m_bStarOneSetting(false), |
231 | 64.2k | m_bIsPagePreview(false), |
232 | 64.2k | m_bSelectionInReadonly(false), |
233 | 64.2k | mbFormView(false), |
234 | 64.2k | mbBrowseMode(false), |
235 | 64.2k | mbBookView(false), |
236 | 64.2k | mbViewLayoutBookMode(false), |
237 | 64.2k | mbHideWhitespaceMode(false), |
238 | 64.2k | m_bShowPlaceHolderFields( true ), |
239 | 64.2k | m_bEncloseWithCharactersOn( true ), |
240 | 64.2k | m_nZoom( 100 ), |
241 | 64.2k | m_eZoom( SvxZoomType::PERCENT ), |
242 | 64.2k | m_nTableDestination(TBL_DEST_CELL) |
243 | 64.2k | { |
244 | 64.2k | m_nCore2Options = |
245 | 64.2k | ViewOptCoreFlags2::BlackFont | |
246 | 64.2k | ViewOptCoreFlags2::HiddenPara; |
247 | | |
248 | 64.2k | m_nUIOptions = |
249 | 64.2k | ViewOptFlags2::Modified | |
250 | 64.2k | ViewOptFlags2::GrfKeepZoom | |
251 | 64.2k | ViewOptFlags2::ResolvedPostits | |
252 | 64.2k | ViewOptFlags2::AnyRuler; |
253 | | |
254 | 64.2k | if (!comphelper::IsFuzzing() && MeasurementSystem::Metric != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()) |
255 | 0 | { |
256 | 0 | m_aSnapSize.setWidth(720); // 1/2" |
257 | 0 | m_aSnapSize.setHeight(720); // 1/2" |
258 | |
|
259 | 0 | } |
260 | 64.2k | else |
261 | 64.2k | { |
262 | 64.2k | m_aSnapSize.setWidth(567); // 1 cm |
263 | 64.2k | m_aSnapSize.setHeight(567); // 1 cm |
264 | 64.2k | } |
265 | 64.2k | m_nDivisionX = m_nDivisionY = 1; |
266 | | |
267 | 64.2k | m_bSelectionInReadonly = officecfg::Office::Common::Accessibility::IsSelectionInReadonly::get(); |
268 | | |
269 | 64.2k | m_bIdle = true; |
270 | | |
271 | 64.2k | m_nDefaultAnchor = 1; //FLY_TO_CHAR |
272 | | |
273 | | // tdf#135266 - tox dialog: remember last used entry level depending on the index type |
274 | 64.2k | m_nTocEntryLvl = 0; |
275 | 64.2k | m_nIdxEntryLvl = 1; |
276 | | |
277 | | #ifdef DBG_UTIL |
278 | | // correspond to the statements in ui/config/cfgvw.src |
279 | | m_bTest1 = m_bTest2 = m_bTest3 = m_bTest4 = |
280 | | m_bTest5 = m_bTest6 = m_bTest7 = m_bTest8 = m_bTest10 = false; |
281 | | #endif |
282 | 64.2k | m_aColorConfig = s_aInitialColorConfig; |
283 | 64.2k | if (comphelper::LibreOfficeKit::isActive()) |
284 | 0 | m_aColorConfig.m_aAppBackgroundColor = COL_TRANSPARENT; |
285 | 64.2k | } |
286 | | |
287 | | SwViewOption::SwViewOption(const SwViewOption& rVOpt) |
288 | 11.6k | { |
289 | 11.6k | m_bReadonly = false; |
290 | 11.6k | m_bSelectionInReadonly = false; |
291 | | // #114856# Form view |
292 | 11.6k | m_sThemeName = rVOpt.m_sThemeName; |
293 | 11.6k | mbFormView = rVOpt.mbFormView; |
294 | 11.6k | m_nZoom = rVOpt.m_nZoom ; |
295 | 11.6k | m_aSnapSize = rVOpt.m_aSnapSize ; |
296 | 11.6k | mnViewLayoutColumns = rVOpt.mnViewLayoutColumns ; |
297 | 11.6k | m_nDivisionX = rVOpt.m_nDivisionX ; |
298 | 11.6k | m_nDivisionY = rVOpt.m_nDivisionY ; |
299 | 11.6k | m_nPagePreviewRow = rVOpt.m_nPagePreviewRow; |
300 | 11.6k | m_nPagePreviewCol = rVOpt.m_nPagePreviewCol; |
301 | 11.6k | m_bIsPagePreview = rVOpt.m_bIsPagePreview; |
302 | 11.6k | m_eZoom = rVOpt.m_eZoom ; |
303 | 11.6k | m_nTableDestination = rVOpt.m_nTableDestination ; |
304 | 11.6k | m_nUIOptions = rVOpt.m_nUIOptions ; |
305 | 11.6k | m_nCoreOptions = rVOpt.m_nCoreOptions ; |
306 | 11.6k | m_nCore2Options = rVOpt.m_nCore2Options ; |
307 | 11.6k | m_aRetouchColor = rVOpt.GetRetoucheColor(); |
308 | 11.6k | m_sSymbolFont = rVOpt.m_sSymbolFont; |
309 | 11.6k | m_nShadowCursorFillMode = rVOpt.m_nShadowCursorFillMode; |
310 | 11.6k | m_bStarOneSetting = rVOpt.m_bStarOneSetting; |
311 | 11.6k | mbBookView = rVOpt.mbBookView; |
312 | 11.6k | mbBrowseMode = rVOpt.mbBrowseMode; |
313 | 11.6k | mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode; |
314 | 11.6k | mbHideWhitespaceMode = rVOpt.mbHideWhitespaceMode; |
315 | 11.6k | m_bShowPlaceHolderFields = rVOpt.m_bShowPlaceHolderFields; |
316 | 11.6k | m_bEncloseWithCharactersOn = rVOpt.m_bEncloseWithCharactersOn; |
317 | 11.6k | m_bIdle = rVOpt.m_bIdle; |
318 | 11.6k | m_nDefaultAnchor = rVOpt.m_nDefaultAnchor; |
319 | 11.6k | m_nTocEntryLvl = rVOpt.m_nTocEntryLvl; |
320 | 11.6k | m_nIdxEntryLvl = rVOpt.m_nIdxEntryLvl; |
321 | 11.6k | m_aColorConfig = rVOpt.m_aColorConfig; |
322 | | |
323 | | #ifdef DBG_UTIL |
324 | | m_bTest1 = rVOpt.m_bTest1; |
325 | | m_bTest2 = rVOpt.m_bTest2; |
326 | | m_bTest3 = rVOpt.m_bTest3; |
327 | | m_bTest4 = rVOpt.m_bTest4; |
328 | | m_bTest5 = rVOpt.m_bTest5; |
329 | | m_bTest6 = rVOpt.m_bTest6; |
330 | | m_bTest7 = rVOpt.m_bTest7; |
331 | | m_bTest8 = rVOpt.m_bTest8; |
332 | | m_bTest10 = rVOpt.m_bTest10; |
333 | | #endif |
334 | 11.6k | } |
335 | | |
336 | | SwViewOption& SwViewOption::operator=( const SwViewOption &rVOpt ) |
337 | 71.9k | { |
338 | | // #114856# Form view |
339 | 71.9k | m_sThemeName = rVOpt.m_sThemeName; |
340 | 71.9k | mbFormView = rVOpt.mbFormView ; |
341 | 71.9k | m_nZoom = rVOpt.m_nZoom ; |
342 | 71.9k | m_aSnapSize = rVOpt.m_aSnapSize ; |
343 | 71.9k | mnViewLayoutColumns = rVOpt.mnViewLayoutColumns ; |
344 | 71.9k | m_nDivisionX = rVOpt.m_nDivisionX ; |
345 | 71.9k | m_nDivisionY = rVOpt.m_nDivisionY ; |
346 | 71.9k | m_nPagePreviewRow = rVOpt.m_nPagePreviewRow; |
347 | 71.9k | m_nPagePreviewCol = rVOpt.m_nPagePreviewCol; |
348 | 71.9k | m_bIsPagePreview = rVOpt.m_bIsPagePreview; |
349 | 71.9k | m_eZoom = rVOpt.m_eZoom ; |
350 | 71.9k | m_nTableDestination = rVOpt.m_nTableDestination ; |
351 | 71.9k | m_nUIOptions = rVOpt.m_nUIOptions ; |
352 | 71.9k | m_nCoreOptions = rVOpt.m_nCoreOptions; |
353 | 71.9k | m_nCore2Options = rVOpt.m_nCore2Options; |
354 | 71.9k | m_aRetouchColor = rVOpt.GetRetoucheColor(); |
355 | 71.9k | m_sSymbolFont = rVOpt.m_sSymbolFont; |
356 | 71.9k | m_nShadowCursorFillMode = rVOpt.m_nShadowCursorFillMode; |
357 | 71.9k | m_bStarOneSetting = rVOpt.m_bStarOneSetting; |
358 | 71.9k | mbBookView = rVOpt.mbBookView; |
359 | 71.9k | mbBrowseMode = rVOpt.mbBrowseMode; |
360 | 71.9k | mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode; |
361 | 71.9k | mbHideWhitespaceMode = rVOpt.mbHideWhitespaceMode; |
362 | 71.9k | m_bShowPlaceHolderFields = rVOpt.m_bShowPlaceHolderFields; |
363 | 71.9k | m_bEncloseWithCharactersOn = rVOpt.m_bEncloseWithCharactersOn; |
364 | 71.9k | m_bIdle = rVOpt.m_bIdle; |
365 | 71.9k | m_nDefaultAnchor = rVOpt.m_nDefaultAnchor; |
366 | 71.9k | m_aColorConfig = rVOpt.m_aColorConfig; |
367 | | |
368 | | #ifdef DBG_UTIL |
369 | | m_bTest1 = rVOpt.m_bTest1; |
370 | | m_bTest2 = rVOpt.m_bTest2; |
371 | | m_bTest3 = rVOpt.m_bTest3; |
372 | | m_bTest4 = rVOpt.m_bTest4; |
373 | | m_bTest5 = rVOpt.m_bTest5; |
374 | | m_bTest6 = rVOpt.m_bTest6; |
375 | | m_bTest7 = rVOpt.m_bTest7; |
376 | | m_bTest8 = rVOpt.m_bTest8; |
377 | | m_bTest10 = rVOpt.m_bTest10; |
378 | | #endif |
379 | 71.9k | return *this; |
380 | 71.9k | } |
381 | | |
382 | | SwViewOption::~SwViewOption() |
383 | 75.9k | { |
384 | 75.9k | } |
385 | | |
386 | | bool SwViewOption::IsAutoCompleteWords() |
387 | 0 | { |
388 | 0 | const SvxSwAutoFormatFlags& rFlags = SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags(); |
389 | 0 | return rFlags.bAutoCmpltCollectWords; |
390 | 0 | } |
391 | | |
392 | | AuthorCharAttr::AuthorCharAttr() : |
393 | 27 | m_nItemId (SID_ATTR_CHAR_UNDERLINE), |
394 | 27 | m_nAttr (LINESTYLE_SINGLE), |
395 | 27 | m_nColor (COL_TRANSPARENT) |
396 | 27 | { |
397 | 27 | } |
398 | | |
399 | | sal_uInt16 GetHtmlMode(const SwDocShell* pShell) |
400 | 71.9k | { |
401 | 71.9k | sal_uInt16 nRet = 0; |
402 | 71.9k | if(!pShell || dynamic_cast<const SwWebDocShell*>( pShell) ) |
403 | 0 | { |
404 | 0 | nRet = HTMLMODE_ON | HTMLMODE_SOME_STYLES; |
405 | 0 | switch ( SvxHtmlOptions::GetExportMode() ) |
406 | 0 | { |
407 | 0 | case HTML_CFG_MSIE: |
408 | 0 | nRet |= HTMLMODE_FULL_STYLES; |
409 | 0 | break; |
410 | 0 | case HTML_CFG_NS40: |
411 | | // no special features for this browser |
412 | 0 | break; |
413 | 0 | case HTML_CFG_WRITER: |
414 | 0 | nRet |= HTMLMODE_FULL_STYLES; |
415 | 0 | break; |
416 | 0 | } |
417 | 0 | } |
418 | 71.9k | return nRet; |
419 | 71.9k | } |
420 | | |
421 | | RndStdIds SwViewOption::GetDefaultAnchorType() const |
422 | 0 | { |
423 | 0 | switch ( m_nDefaultAnchor ) |
424 | 0 | { |
425 | 0 | case 0: |
426 | 0 | return RndStdIds::FLY_AT_PARA; //0 |
427 | 0 | case 1: |
428 | 0 | return RndStdIds::FLY_AT_CHAR; //4 |
429 | 0 | case 2: |
430 | 0 | return RndStdIds::FLY_AS_CHAR; //1 |
431 | 0 | default: |
432 | 0 | return RndStdIds::FLY_AT_CHAR; //4 |
433 | 0 | }//switch |
434 | 0 | } |
435 | | |
436 | | const Color& SwViewOption::GetDocColor() const |
437 | 190k | { |
438 | 190k | return m_aColorConfig.m_aDocColor; |
439 | 190k | } |
440 | | |
441 | | const Color& SwViewOption::GetDocBoundariesColor() const |
442 | 3 | { |
443 | 3 | return m_aColorConfig.m_aDocBoundColor; |
444 | 3 | } |
445 | | |
446 | | const Color& SwViewOption::GetAppBackgroundColor() const |
447 | 0 | { |
448 | 0 | return m_aColorConfig.m_aAppBackgroundColor; |
449 | 0 | } |
450 | | |
451 | | const Color& SwViewOption::GetTableBoundariesColor() const |
452 | 16 | { |
453 | 16 | return m_aColorConfig.m_aTableBoundColor; |
454 | 16 | } |
455 | | |
456 | | const Color& SwViewOption::GetIndexShadingsColor() const |
457 | 0 | { |
458 | 0 | return m_aColorConfig.m_aIndexShadingsColor; |
459 | 0 | } |
460 | | |
461 | | const Color& SwViewOption::GetLinksColor() const |
462 | 0 | { |
463 | 0 | return m_aColorConfig.m_aLinksColor; |
464 | 0 | } |
465 | | |
466 | | const Color& SwViewOption::GetVisitedLinksColor() const |
467 | 0 | { |
468 | 0 | return m_aColorConfig.m_aVisitedLinksColor; |
469 | 0 | } |
470 | | |
471 | | const Color& SwViewOption::GetTextGridColor() const |
472 | 0 | { |
473 | 0 | return m_aColorConfig.m_aTextGridColor; |
474 | 0 | } |
475 | | |
476 | | const Color& SwViewOption::GetSpellColor() const |
477 | 0 | { |
478 | 0 | return m_aColorConfig.m_aSpellColor; |
479 | 0 | } |
480 | | |
481 | | const Color& SwViewOption::GetGrammarColor() const |
482 | 0 | { |
483 | 0 | return m_aColorConfig.m_aGrammarColor; |
484 | 0 | } |
485 | | |
486 | | const Color& SwViewOption::GetSmarttagColor() const |
487 | 0 | { |
488 | 0 | return m_aColorConfig.m_aSmarttagColor; |
489 | 0 | } |
490 | | |
491 | | const Color& SwViewOption::GetShadowColor() const |
492 | 0 | { |
493 | 0 | return m_aColorConfig.m_aShadowColor; |
494 | 0 | } |
495 | | |
496 | | const Color& SwViewOption::GetFontColor() const |
497 | 0 | { |
498 | 0 | return m_aColorConfig.m_aFontColor; |
499 | 0 | } |
500 | | |
501 | | const Color& SwViewOption::GetFieldShadingsColor() const |
502 | 0 | { |
503 | 0 | return m_aColorConfig.m_aFieldShadingsColor; |
504 | 0 | } |
505 | | |
506 | | const Color& SwViewOption::GetSectionBoundColor() const |
507 | 0 | { |
508 | 0 | return m_aColorConfig.m_aSectionBoundColor; |
509 | 0 | } |
510 | | |
511 | | const Color& SwViewOption::GetPageBreakColor() const |
512 | 0 | { |
513 | 0 | return m_aColorConfig.m_aPageBreakColor; |
514 | 0 | } |
515 | | |
516 | | const Color& SwViewOption::GetNonPrintingCharacterColor() const |
517 | 0 | { |
518 | 0 | return m_aColorConfig.m_aNonPrintingCharacterColor; |
519 | 0 | } |
520 | | |
521 | | const Color& SwViewOption::GetHeaderFooterMarkColor() const |
522 | 0 | { |
523 | 0 | return m_aColorConfig.m_aHeaderFooterMarkColor; |
524 | 0 | } |
525 | | |
526 | | void SwViewOption::SetAppearanceFlag(ViewOptFlags nFlag, bool bSet, bool bSaveInConfig ) |
527 | 0 | { |
528 | 0 | if(bSet) |
529 | 0 | m_aColorConfig.m_nAppearanceFlags |= nFlag; |
530 | 0 | else |
531 | 0 | m_aColorConfig.m_nAppearanceFlags &= ~nFlag; |
532 | 0 | if(!bSaveInConfig) |
533 | 0 | return; |
534 | | |
535 | | //create an editable svtools::ColorConfig and store the change |
536 | 0 | svtools::EditableColorConfig aEditableConfig; |
537 | 0 | struct FlagToConfig_Impl |
538 | 0 | { |
539 | 0 | ViewOptFlags nFlag; |
540 | 0 | svtools::ColorConfigEntry eEntry; |
541 | 0 | }; |
542 | 0 | static const FlagToConfig_Impl aFlags[] = |
543 | 0 | { |
544 | 0 | { ViewOptFlags::IndexShadings , svtools::WRITERIDXSHADINGS }, |
545 | 0 | { ViewOptFlags::Links , svtools::LINKS }, |
546 | 0 | { ViewOptFlags::VisitedLinks , svtools::LINKSVISITED }, |
547 | 0 | { ViewOptFlags::FieldShadings , svtools::WRITERFIELDSHADINGS }, |
548 | 0 | { ViewOptFlags::Shadow , svtools::SHADOWCOLOR }, |
549 | 0 | }; |
550 | 0 | for (auto& item : aFlags) |
551 | 0 | { |
552 | 0 | if (nFlag & item.nFlag) |
553 | 0 | { |
554 | 0 | svtools::ColorConfigValue aValue = aEditableConfig.GetColorValue(item.eEntry); |
555 | 0 | aValue.bIsVisible = bSet; |
556 | 0 | aEditableConfig.SetColorValue(item.eEntry, aValue); |
557 | 0 | } |
558 | 0 | } |
559 | 0 | } |
560 | | |
561 | | bool SwViewOption::IsAppearanceFlag(ViewOptFlags nFlag) const |
562 | 84 | { |
563 | 84 | return bool(m_aColorConfig.m_nAppearanceFlags & nFlag); |
564 | 84 | } |
565 | | |
566 | | namespace{ |
567 | | rtl::Reference<comphelper::ConfigurationListener> const & getWCOptionListener() |
568 | 0 | { |
569 | 0 | static rtl::Reference<comphelper::ConfigurationListener> xListener(new comphelper::ConfigurationListener(u"/org.openoffice.Office.Writer/Cursor/Option"_ustr)); |
570 | 0 | return xListener; |
571 | 0 | } |
572 | | } |
573 | | |
574 | | bool SwViewOption::IsIgnoreProtectedArea() |
575 | 11.7k | { |
576 | 11.7k | if (comphelper::IsFuzzing()) |
577 | 11.7k | return false; |
578 | 0 | static comphelper::ConfigurationListenerProperty<bool> gIgnoreProtectedArea(getWCOptionListener(), u"IgnoreProtectedArea"_ustr); |
579 | 0 | return gIgnoreProtectedArea.get(); |
580 | 11.7k | } |
581 | | |
582 | | bool SwViewOption::IsAllowDragDropText() |
583 | 0 | { |
584 | 0 | if (comphelper::IsFuzzing()) |
585 | 0 | return true; |
586 | 0 | static comphelper::ConfigurationListenerProperty<bool> gAllowDragDrop(getWCOptionListener(), u"AllowDragDrop"_ustr); |
587 | 0 | return gAllowDragDrop.get(); |
588 | 0 | } |
589 | | |
590 | | void SwViewOption::SyncLayoutRelatedViewOptions(const SwViewOption& rOpt) |
591 | 0 | { |
592 | 0 | SetFieldName(rOpt.IsFieldName()); |
593 | 0 | SetShowHiddenField(rOpt.IsShowHiddenField()); |
594 | 0 | SetShowHiddenPara(rOpt.IsShowHiddenPara()); |
595 | 0 | SetShowHiddenChar(rOpt.IsShowHiddenChar()); |
596 | 0 | SetViewLayoutBookMode(rOpt.IsViewLayoutBookMode()); |
597 | 0 | SetHideWhitespaceMode(rOpt.IsHideWhitespaceMode()); |
598 | 0 | SetViewLayoutColumns(rOpt.GetViewLayoutColumns()); |
599 | 0 | SetPostIts(rOpt.IsPostIts()); |
600 | 0 | } |
601 | | |
602 | | const SwViewOption& SwViewOption::GetCurrentViewOptions() |
603 | 3 | { |
604 | 3 | SfxViewShell* pCurrentShell = SfxViewShell::Current(); |
605 | 3 | SwView* pView = dynamic_cast<SwView*>(pCurrentShell); |
606 | 3 | if(pView) |
607 | 3 | { |
608 | 3 | return *pView->GetWrtShell().GetViewOptions(); |
609 | 3 | } |
610 | | |
611 | | // Some unit tests don't have a SfxViewShell, so we need to return something |
612 | 0 | static SwViewOption aDefaultViewOptions; |
613 | 0 | return aDefaultViewOptions; |
614 | 3 | } |
615 | | |
616 | | void SwViewOption::dumpAsXml(xmlTextWriterPtr pWriter) const |
617 | 0 | { |
618 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwViewOption")); |
619 | 0 | (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); |
620 | 0 | m_nCoreOptions.dumpAsXml(pWriter); |
621 | 0 | (void)xmlTextWriterEndElement(pWriter); |
622 | 0 | } |
623 | | |
624 | | void ViewOptFlags1::dumpAsXml(xmlTextWriterPtr pWriter) const |
625 | 0 | { |
626 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("ViewOptFlags1")); |
627 | 0 | (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); |
628 | |
|
629 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bUseHeaderFooterMenu")); |
630 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
631 | 0 | BAD_CAST(OString::boolean(bUseHeaderFooterMenu).getStr())); |
632 | 0 | (void)xmlTextWriterEndElement(pWriter); |
633 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bTab")); |
634 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
635 | 0 | BAD_CAST(OString::boolean(bTab).getStr())); |
636 | 0 | (void)xmlTextWriterEndElement(pWriter); |
637 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bBlank")); |
638 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
639 | 0 | BAD_CAST(OString::boolean(bBlank).getStr())); |
640 | 0 | (void)xmlTextWriterEndElement(pWriter); |
641 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bHardBlank")); |
642 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
643 | 0 | BAD_CAST(OString::boolean(bHardBlank).getStr())); |
644 | 0 | (void)xmlTextWriterEndElement(pWriter); |
645 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bParagraph")); |
646 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
647 | 0 | BAD_CAST(OString::boolean(bParagraph).getStr())); |
648 | 0 | (void)xmlTextWriterEndElement(pWriter); |
649 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bLinebreak")); |
650 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
651 | 0 | BAD_CAST(OString::boolean(bLinebreak).getStr())); |
652 | 0 | (void)xmlTextWriterEndElement(pWriter); |
653 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bPagebreak")); |
654 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
655 | 0 | BAD_CAST(OString::boolean(bPagebreak).getStr())); |
656 | 0 | (void)xmlTextWriterEndElement(pWriter); |
657 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bColumnbreak")); |
658 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
659 | 0 | BAD_CAST(OString::boolean(bColumnbreak).getStr())); |
660 | 0 | (void)xmlTextWriterEndElement(pWriter); |
661 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bSoftHyph")); |
662 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
663 | 0 | BAD_CAST(OString::boolean(bSoftHyph).getStr())); |
664 | 0 | (void)xmlTextWriterEndElement(pWriter); |
665 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bBookmarks")); |
666 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
667 | 0 | BAD_CAST(OString::boolean(bBookmarks).getStr())); |
668 | 0 | (void)xmlTextWriterEndElement(pWriter); |
669 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bRef")); |
670 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
671 | 0 | BAD_CAST(OString::boolean(bRef).getStr())); |
672 | 0 | (void)xmlTextWriterEndElement(pWriter); |
673 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bFieldName")); |
674 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
675 | 0 | BAD_CAST(OString::boolean(bFieldName).getStr())); |
676 | 0 | (void)xmlTextWriterEndElement(pWriter); |
677 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bPostits")); |
678 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
679 | 0 | BAD_CAST(OString::boolean(bPostits).getStr())); |
680 | 0 | (void)xmlTextWriterEndElement(pWriter); |
681 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bFieldHidden")); |
682 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
683 | 0 | BAD_CAST(OString::boolean(bFieldHidden).getStr())); |
684 | 0 | (void)xmlTextWriterEndElement(pWriter); |
685 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bCharHidden")); |
686 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
687 | 0 | BAD_CAST(OString::boolean(bCharHidden).getStr())); |
688 | 0 | (void)xmlTextWriterEndElement(pWriter); |
689 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bGraphic")); |
690 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
691 | 0 | BAD_CAST(OString::boolean(bGraphic).getStr())); |
692 | 0 | (void)xmlTextWriterEndElement(pWriter); |
693 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bTable")); |
694 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
695 | 0 | BAD_CAST(OString::boolean(bTable).getStr())); |
696 | 0 | (void)xmlTextWriterEndElement(pWriter); |
697 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bDraw")); |
698 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
699 | 0 | BAD_CAST(OString::boolean(bDraw).getStr())); |
700 | 0 | (void)xmlTextWriterEndElement(pWriter); |
701 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bControl")); |
702 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
703 | 0 | BAD_CAST(OString::boolean(bControl).getStr())); |
704 | 0 | (void)xmlTextWriterEndElement(pWriter); |
705 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bCrosshair")); |
706 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
707 | 0 | BAD_CAST(OString::boolean(bCrosshair).getStr())); |
708 | 0 | (void)xmlTextWriterEndElement(pWriter); |
709 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bSnap")); |
710 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
711 | 0 | BAD_CAST(OString::boolean(bSnap).getStr())); |
712 | 0 | (void)xmlTextWriterEndElement(pWriter); |
713 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bSynchronize")); |
714 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
715 | 0 | BAD_CAST(OString::boolean(bSynchronize).getStr())); |
716 | 0 | (void)xmlTextWriterEndElement(pWriter); |
717 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bGridVisible")); |
718 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
719 | 0 | BAD_CAST(OString::boolean(bGridVisible).getStr())); |
720 | 0 | (void)xmlTextWriterEndElement(pWriter); |
721 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bOnlineSpell")); |
722 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
723 | 0 | BAD_CAST(OString::boolean(bOnlineSpell).getStr())); |
724 | 0 | (void)xmlTextWriterEndElement(pWriter); |
725 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bTreatSubOutlineLevelsAsContent")); |
726 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
727 | 0 | BAD_CAST(OString::boolean(bTreatSubOutlineLevelsAsContent).getStr())); |
728 | 0 | (void)xmlTextWriterEndElement(pWriter); |
729 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bShowInlineTooltips")); |
730 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
731 | 0 | BAD_CAST(OString::boolean(bShowInlineTooltips).getStr())); |
732 | 0 | (void)xmlTextWriterEndElement(pWriter); |
733 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bViewMetachars")); |
734 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
735 | 0 | BAD_CAST(OString::boolean(bViewMetachars).getStr())); |
736 | 0 | (void)xmlTextWriterEndElement(pWriter); |
737 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bRedlineRecordingOn")); |
738 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
739 | 0 | BAD_CAST(OString::boolean(bRedlineRecordingOn).getStr())); |
740 | 0 | (void)xmlTextWriterEndElement(pWriter); |
741 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bPageback")); |
742 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
743 | 0 | BAD_CAST(OString::boolean(bPageback).getStr())); |
744 | 0 | (void)xmlTextWriterEndElement(pWriter); |
745 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bShowOutlineContentVisibilityButton")); |
746 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
747 | 0 | BAD_CAST(OString::boolean(bShowOutlineContentVisibilityButton).getStr())); |
748 | 0 | (void)xmlTextWriterEndElement(pWriter); |
749 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bShowChangesInMargin")); |
750 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
751 | 0 | BAD_CAST(OString::boolean(bShowChangesInMargin).getStr())); |
752 | 0 | (void)xmlTextWriterEndElement(pWriter); |
753 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bShowChangesInMargin2")); |
754 | 0 | (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), |
755 | 0 | BAD_CAST(OString::boolean(bShowChangesInMargin2).getStr())); |
756 | 0 | (void)xmlTextWriterEndElement(pWriter); |
757 | |
|
758 | 0 | (void)xmlTextWriterEndElement(pWriter); |
759 | 0 | } |
760 | | |
761 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |