/src/libreoffice/sw/source/uibase/app/swmodul1.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 <sal/config.h> |
21 | | |
22 | | #include <memory> |
23 | | |
24 | | #include <hintids.hxx> |
25 | | #include <sfx2/request.hxx> |
26 | | #include <unotools/useroptions.hxx> |
27 | | #include <com/sun/star/frame/FrameSearchFlag.hpp> |
28 | | #include <com/sun/star/frame/XFrame.hpp> |
29 | | #include <com/sun/star/view/XSelectionSupplier.hpp> |
30 | | #include <svx/colorwindow.hxx> |
31 | | #include <svx/dataaccessdescriptor.hxx> |
32 | | #include <editeng/editids.hrc> |
33 | | #include <editeng/wghtitem.hxx> |
34 | | #include <editeng/postitem.hxx> |
35 | | #include <editeng/udlnitem.hxx> |
36 | | #include <editeng/crossedoutitem.hxx> |
37 | | #include <editeng/cmapitem.hxx> |
38 | | #include <editeng/colritem.hxx> |
39 | | #include <editeng/brushitem.hxx> |
40 | | #include <svl/cjkoptions.hxx> |
41 | | #include <osl/diagnose.h> |
42 | | #include <swmodule.hxx> |
43 | | #include <swtypes.hxx> |
44 | | #include <usrpref.hxx> |
45 | | #include <modcfg.hxx> |
46 | | #include <view.hxx> |
47 | | #include <pview.hxx> |
48 | | #include <wview.hxx> |
49 | | #include <wrtsh.hxx> |
50 | | #include <docsh.hxx> |
51 | | #include <uinums.hxx> |
52 | | #include <prtopt.hxx> |
53 | | #include <navicfg.hxx> |
54 | | #include <doc.hxx> |
55 | | #include <strings.hrc> |
56 | | #include <IDocumentLayoutAccess.hxx> |
57 | | #include <svtools/colorcfg.hxx> |
58 | | |
59 | | #include <tools/color.hxx> |
60 | | #include <tools/json_writer.hxx> |
61 | | #include <PostItMgr.hxx> |
62 | | |
63 | | using namespace ::svx; |
64 | | using namespace ::com::sun::star; |
65 | | using namespace ::com::sun::star::uno; |
66 | | using namespace ::com::sun::star::frame; |
67 | | using namespace ::com::sun::star::view; |
68 | | |
69 | | static void lcl_SetUIPrefs(const SwViewOption &rPref, SwView* pView, SwViewShell* pSh ) |
70 | 112 | { |
71 | | // in FrameSets the actual visibility can differ from the ViewOption's setting |
72 | 112 | bool bVScrollChanged = rPref.IsViewVScrollBar() != pSh->GetViewOptions()->IsViewVScrollBar(); |
73 | 112 | bool bHScrollChanged = rPref.IsViewHScrollBar() != pSh->GetViewOptions()->IsViewHScrollBar(); |
74 | 112 | bool bVAlignChanged = rPref.IsVRulerRight() != pSh->GetViewOptions()->IsVRulerRight(); |
75 | | |
76 | 112 | pSh->SetUIOptions(rPref); |
77 | 112 | const SwViewOption* pNewPref = pSh->GetViewOptions(); |
78 | | |
79 | | // Scrollbars on / off |
80 | 112 | if(bVScrollChanged) |
81 | 0 | { |
82 | 0 | pView->EnableVScrollbar(pNewPref->IsViewVScrollBar()); |
83 | 0 | } |
84 | 112 | if(bHScrollChanged) |
85 | 0 | { |
86 | 0 | pView->EnableHScrollbar( pNewPref->IsViewHScrollBar() || pNewPref->getBrowseMode() ); |
87 | 0 | } |
88 | | //if only the position of the vertical ruler has been changed initiate an update |
89 | 112 | if(bVAlignChanged && !bHScrollChanged && !bVScrollChanged) |
90 | 0 | pView->InvalidateBorder(); |
91 | | |
92 | | // Rulers on / off |
93 | 112 | if(pNewPref->IsViewVRuler()) |
94 | 0 | pView->CreateVRuler(); |
95 | 112 | else |
96 | 112 | pView->KillVRuler(); |
97 | | |
98 | | // TabWindow on / off |
99 | 112 | if(pNewPref->IsViewHRuler()) |
100 | 0 | pView->CreateTab(); |
101 | 112 | else |
102 | 112 | pView->KillTab(); |
103 | | |
104 | 112 | bool bWeb = dynamic_cast<const SwWebView*>(pView) != nullptr; |
105 | 112 | SwModule* pModule = SwModule::get(); |
106 | 112 | auto pUsrPref = const_cast<SwMasterUsrPref*>(pModule->GetUsrPref(bWeb)); |
107 | 112 | if (rPref.GetZoomType() != pUsrPref->GetZoomType() || rPref.GetZoom() != pUsrPref->GetZoom()) |
108 | 80 | { |
109 | | // The current zoom is different, then set the new type and value. See how |
110 | | // SwView::SetZoom_() stores these applied values in SwMasterUsrPref. |
111 | 80 | pView->SetZoom(rPref.GetZoomType(), rPref.GetZoom(), true); |
112 | 80 | } |
113 | | |
114 | 112 | pView->GetPostItMgr()->PrepareView(true); |
115 | 112 | } |
116 | | |
117 | | SwWrtShell* GetActiveWrtShell() |
118 | 0 | { |
119 | 0 | if (SwView *pActive = GetActiveView()) |
120 | 0 | return &pActive->GetWrtShell(); |
121 | 0 | return nullptr; |
122 | 0 | } |
123 | | |
124 | | SwView* GetActiveView() |
125 | 79.6k | { |
126 | 79.6k | SfxViewShell* pView = SfxViewShell::Current(); |
127 | 79.6k | return dynamic_cast<SwView*>( pView ); |
128 | 79.6k | } |
129 | | |
130 | | SwView* SwModule::GetFirstView() |
131 | 0 | { |
132 | | // returns only visible SwView |
133 | 0 | SwView* pView = static_cast<SwView*>(SfxViewShell::GetFirst(true, checkSfxViewShell<SwView>)); |
134 | 0 | return pView; |
135 | 0 | } |
136 | | |
137 | | SwView* SwModule::GetNextView(SwView const * pView) |
138 | 0 | { |
139 | 0 | OSL_ENSURE( pView,"return no SwView" ); |
140 | 0 | SwView* pNView = static_cast<SwView*>(SfxViewShell::GetNext(*pView, true, checkSfxViewShell<SwView>)); |
141 | 0 | return pNView; |
142 | 0 | } |
143 | | |
144 | | // New Master for the settings is set; this affects the current view and all following. |
145 | | void SwModule::ApplyUsrPref(const SwViewOption &rUsrPref, SwView* pActView, |
146 | | SvViewOpt nDest ) |
147 | 112 | { |
148 | 112 | SwView* pCurrView = pActView; |
149 | 112 | SwViewShell* pSh = pCurrView ? &pCurrView->GetWrtShell() : nullptr; |
150 | | |
151 | 112 | SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(GetUsrPref( |
152 | 112 | nDest == SvViewOpt::DestWeb |
153 | 112 | || (nDest != SvViewOpt::DestText |
154 | 112 | && dynamic_cast< const SwWebView *>( pCurrView )) )); |
155 | | |
156 | | // with Uno, only sdbcx::View, but not the Module should be changed |
157 | 112 | bool bViewOnly = SvViewOpt::DestViewOnly == nDest; |
158 | | // fob Preview off |
159 | 112 | SwPagePreview* pPPView; |
160 | 112 | if( !pCurrView && nullptr != (pPPView = dynamic_cast<SwPagePreview*>( SfxViewShell::Current())) ) |
161 | 0 | { |
162 | 0 | if(!bViewOnly) |
163 | 0 | pPref->SetUIOptions( rUsrPref ); |
164 | 0 | pPPView->EnableVScrollbar(pPref->IsViewVScrollBar()); |
165 | 0 | pPPView->EnableHScrollbar(pPref->IsViewHScrollBar()); |
166 | 0 | if(!bViewOnly) |
167 | 0 | { |
168 | 0 | pPref->SetPagePrevRow(rUsrPref.GetPagePrevRow()); |
169 | 0 | pPref->SetPagePrevCol(rUsrPref.GetPagePrevCol()); |
170 | 0 | } |
171 | 0 | return; |
172 | 0 | } |
173 | | |
174 | 112 | if(!bViewOnly) |
175 | 0 | { |
176 | 0 | pPref->SetUsrPref( rUsrPref ); |
177 | 0 | pPref->SetModified(); |
178 | 0 | } |
179 | | |
180 | 112 | if( !pCurrView ) |
181 | 0 | return; |
182 | | |
183 | | // Passing on to CORE |
184 | 112 | bool bReadonly; |
185 | 112 | const SwDocShell* pDocSh = pCurrView->GetDocShell(); |
186 | 112 | if (pDocSh) |
187 | 112 | bReadonly = pDocSh->IsReadOnly(); |
188 | 0 | else //Use existing option if DocShell missing |
189 | 0 | bReadonly = pSh->GetViewOptions()->IsReadonly(); |
190 | 112 | std::unique_ptr<SwViewOption> xViewOpt; |
191 | 112 | if (!bViewOnly) |
192 | 0 | xViewOpt.reset(new SwViewOption(*pPref)); |
193 | 112 | else |
194 | 112 | xViewOpt.reset(new SwViewOption(rUsrPref)); |
195 | 112 | xViewOpt->SetReadonly( bReadonly ); |
196 | 112 | if( !(*pSh->GetViewOptions() == *xViewOpt) ) |
197 | 0 | { |
198 | | //is maybe only a SwViewShell |
199 | 0 | pSh->StartAction(); |
200 | 0 | pSh->ApplyViewOptions( *xViewOpt ); |
201 | 0 | static_cast<SwWrtShell*>(pSh)->SetReadOnlyAvailable(xViewOpt->IsCursorInProtectedArea()); |
202 | 0 | pSh->EndAction(); |
203 | 0 | } |
204 | 112 | if ( pSh->GetViewOptions()->IsReadonly() != bReadonly ) |
205 | 0 | pSh->SetReadonlyOption(bReadonly); |
206 | | |
207 | 112 | lcl_SetUIPrefs(*xViewOpt, pCurrView, pSh); |
208 | | |
209 | | // in the end the Idle-Flag is set again |
210 | 112 | pPref->SetIdle(true); |
211 | 112 | } |
212 | | |
213 | | void SwModule::ApplyUserMetric( FieldUnit eMetric, bool bWeb ) |
214 | 0 | { |
215 | 0 | SwMasterUsrPref* pPref; |
216 | 0 | if(bWeb) |
217 | 0 | { |
218 | 0 | if(!m_pWebUsrPref) |
219 | 0 | GetUsrPref(true); |
220 | 0 | pPref = m_pWebUsrPref.get(); |
221 | 0 | } |
222 | 0 | else |
223 | 0 | { |
224 | 0 | if(!m_pUsrPref) |
225 | 0 | GetUsrPref(false); |
226 | 0 | pPref = m_pUsrPref.get(); |
227 | 0 | } |
228 | 0 | assert(pPref && "pPref is set by here"); |
229 | 0 | FieldUnit eOldMetric = pPref->GetMetric(); |
230 | 0 | if(eOldMetric != eMetric) |
231 | 0 | pPref->SetMetric(eMetric); |
232 | |
|
233 | 0 | FieldUnit eHScrollMetric = pPref->IsHScrollMetric() ? pPref->GetHScrollMetric() : eMetric; |
234 | 0 | FieldUnit eVScrollMetric = pPref->IsVScrollMetric() ? pPref->GetVScrollMetric() : eMetric; |
235 | |
|
236 | 0 | SwView* pTmpView = SwModule::GetFirstView(); |
237 | | // switch the ruler for all MDI-Windows |
238 | 0 | while(pTmpView) |
239 | 0 | { |
240 | 0 | if(bWeb == (dynamic_cast<SwWebView*>( pTmpView) != nullptr) ) |
241 | 0 | { |
242 | 0 | pTmpView->ChangeVRulerMetric(eVScrollMetric); |
243 | 0 | pTmpView->ChangeTabMetric(eHScrollMetric); |
244 | 0 | } |
245 | |
|
246 | 0 | pTmpView = SwModule::GetNextView(pTmpView); |
247 | 0 | } |
248 | 0 | } |
249 | | |
250 | | void SwModule::ApplyRulerMetric( FieldUnit eMetric, bool bHorizontal, bool bWeb ) |
251 | 0 | { |
252 | 0 | SwMasterUsrPref* pPref; |
253 | 0 | if(bWeb) |
254 | 0 | { |
255 | 0 | if(!m_pWebUsrPref) |
256 | 0 | GetUsrPref(true); |
257 | 0 | pPref = m_pWebUsrPref.get(); |
258 | 0 | } |
259 | 0 | else |
260 | 0 | { |
261 | 0 | if(!m_pUsrPref) |
262 | 0 | GetUsrPref(false); |
263 | 0 | pPref = m_pUsrPref.get(); |
264 | 0 | } |
265 | 0 | assert(pPref && "pPref will be set by now"); |
266 | 0 | if( bHorizontal ) |
267 | 0 | pPref->SetHScrollMetric(eMetric); |
268 | 0 | else |
269 | 0 | pPref->SetVScrollMetric(eMetric); |
270 | |
|
271 | 0 | SwView* pTmpView = SwModule::GetFirstView(); |
272 | | // switch metric at the appropriate rulers |
273 | 0 | while(pTmpView) |
274 | 0 | { |
275 | 0 | if(bWeb == (dynamic_cast<SwWebView *>( pTmpView ) != nullptr)) |
276 | 0 | { |
277 | 0 | if( bHorizontal ) |
278 | 0 | pTmpView->ChangeTabMetric(eMetric); |
279 | 0 | else |
280 | 0 | pTmpView->ChangeVRulerMetric(eMetric); |
281 | 0 | } |
282 | 0 | pTmpView = SwModule::GetNextView(pTmpView); |
283 | 0 | } |
284 | 0 | } |
285 | | |
286 | | //set the usrpref 's char unit attribute and set rulers unit as char if the "apply char unit" is checked |
287 | | void SwModule::ApplyUserCharUnit(bool bApplyChar, bool bWeb) |
288 | 0 | { |
289 | 0 | SwMasterUsrPref* pPref; |
290 | 0 | if(bWeb) |
291 | 0 | { |
292 | 0 | if(!m_pWebUsrPref) |
293 | 0 | GetUsrPref(true); |
294 | 0 | pPref = m_pWebUsrPref.get(); |
295 | 0 | } |
296 | 0 | else |
297 | 0 | { |
298 | 0 | if(!m_pUsrPref) |
299 | 0 | GetUsrPref(false); |
300 | 0 | pPref = m_pUsrPref.get(); |
301 | 0 | } |
302 | 0 | assert(pPref && "pPref is set by here"); |
303 | 0 | bool bOldApplyCharUnit = pPref->IsApplyCharUnit(); |
304 | 0 | bool bHasChanged = false; |
305 | 0 | if(bOldApplyCharUnit != bApplyChar) |
306 | 0 | { |
307 | 0 | pPref->SetApplyCharUnit(bApplyChar); |
308 | 0 | bHasChanged = true; |
309 | 0 | } |
310 | |
|
311 | 0 | if( !bHasChanged ) |
312 | 0 | return; |
313 | | |
314 | 0 | FieldUnit eHScrollMetric = pPref->IsHScrollMetric() ? pPref->GetHScrollMetric() : pPref->GetMetric(); |
315 | 0 | FieldUnit eVScrollMetric = pPref->IsVScrollMetric() ? pPref->GetVScrollMetric() : pPref->GetMetric(); |
316 | 0 | if(bApplyChar) |
317 | 0 | { |
318 | 0 | eHScrollMetric = FieldUnit::CHAR; |
319 | 0 | eVScrollMetric = FieldUnit::LINE; |
320 | 0 | } |
321 | 0 | else |
322 | 0 | { |
323 | 0 | if ( !SvtCJKOptions::IsAsianTypographyEnabled() && ( eHScrollMetric == FieldUnit::CHAR )) |
324 | 0 | eHScrollMetric = FieldUnit::INCH; |
325 | 0 | else if ( eHScrollMetric == FieldUnit::CHAR ) |
326 | 0 | eHScrollMetric = FieldUnit::CM; |
327 | 0 | if ( !SvtCJKOptions::IsAsianTypographyEnabled() && ( eVScrollMetric == FieldUnit::LINE )) |
328 | 0 | eVScrollMetric = FieldUnit::INCH; |
329 | 0 | else if ( eVScrollMetric == FieldUnit::LINE ) |
330 | 0 | eVScrollMetric = FieldUnit::CM; |
331 | 0 | } |
332 | 0 | SwView* pTmpView = SwModule::GetFirstView(); |
333 | | // switch rulers for all MDI-Windows |
334 | 0 | while(pTmpView) |
335 | 0 | { |
336 | 0 | if(bWeb == (dynamic_cast<SwWebView*>( pTmpView) != nullptr) ) |
337 | 0 | { |
338 | 0 | pTmpView->ChangeVRulerMetric(eVScrollMetric); |
339 | 0 | pTmpView->ChangeTabMetric(eHScrollMetric); |
340 | 0 | } |
341 | |
|
342 | 0 | pTmpView = SwModule::GetNextView(pTmpView); |
343 | 0 | } |
344 | 0 | } |
345 | | |
346 | | SwNavigationConfig* SwModule::GetNavigationConfig() |
347 | 0 | { |
348 | 0 | if(!m_pNavigationConfig) |
349 | 0 | { |
350 | 0 | m_pNavigationConfig.reset( new SwNavigationConfig ); |
351 | 0 | } |
352 | 0 | return m_pNavigationConfig.get(); |
353 | 0 | } |
354 | | |
355 | | SwPrintOptions* SwModule::GetPrtOptions(bool bWeb) |
356 | 3.93k | { |
357 | 3.93k | if(bWeb && !m_pWebPrintOptions) |
358 | 0 | { |
359 | 0 | m_pWebPrintOptions.reset(new SwPrintOptions(true)); |
360 | 0 | } |
361 | 3.93k | else if(!bWeb && !m_pPrintOptions) |
362 | 2 | { |
363 | 2 | m_pPrintOptions.reset(new SwPrintOptions(false)); |
364 | 2 | } |
365 | | |
366 | 3.93k | return bWeb ? m_pWebPrintOptions.get() : m_pPrintOptions.get(); |
367 | 3.93k | } |
368 | | |
369 | | SwChapterNumRules* SwModule::GetChapterNumRules() |
370 | 0 | { |
371 | 0 | if(!m_pChapterNumRules) |
372 | 0 | m_pChapterNumRules.reset(new SwChapterNumRules); |
373 | 0 | return m_pChapterNumRules.get(); |
374 | 0 | } |
375 | | |
376 | | void SwModule::ShowDBObj(SwView const & rView, const SwDBData& rData) |
377 | 0 | { |
378 | 0 | Reference<XFrame> xFrame = rView.GetViewFrame().GetFrame().GetFrameInterface(); |
379 | |
|
380 | 0 | uno::Reference<XFrame> xBeamerFrame = xFrame->findFrame(u"_beamer"_ustr, FrameSearchFlag::CHILDREN); |
381 | 0 | if (!xBeamerFrame.is()) |
382 | 0 | return; |
383 | | |
384 | | // the beamer has been opened by the SfxViewFrame |
385 | 0 | Reference<XController> xController = xBeamerFrame->getController(); |
386 | 0 | Reference<XSelectionSupplier> xControllerSelection(xController, UNO_QUERY); |
387 | 0 | if (xControllerSelection.is()) |
388 | 0 | { |
389 | |
|
390 | 0 | ODataAccessDescriptor aSelection; |
391 | 0 | aSelection.setDataSource(rData.sDataSource); |
392 | 0 | aSelection[DataAccessDescriptorProperty::Command] <<= rData.sCommand; |
393 | 0 | aSelection[DataAccessDescriptorProperty::CommandType] <<= rData.nCommandType; |
394 | 0 | xControllerSelection->select(Any(aSelection.createPropertyValueSequence())); |
395 | 0 | } |
396 | 0 | else { |
397 | 0 | OSL_FAIL("no selection supplier in the beamer!"); |
398 | 0 | } |
399 | 0 | } |
400 | | |
401 | | std::size_t SwModule::GetRedlineAuthor() |
402 | 3.93k | { |
403 | 3.93k | if (!m_bAuthorInitialised) |
404 | 2 | { |
405 | 2 | const SvtUserOptions& rOpt = GetUserOptions(); |
406 | 2 | m_sActAuthor = rOpt.GetFullName(); |
407 | 2 | if (m_sActAuthor.isEmpty()) |
408 | 2 | { |
409 | 2 | m_sActAuthor = rOpt.GetID(); |
410 | 2 | if (m_sActAuthor.isEmpty()) |
411 | 2 | m_sActAuthor = SwResId( STR_REDLINE_UNKNOWN_AUTHOR ); |
412 | 2 | } |
413 | 2 | m_bAuthorInitialised = true; |
414 | 2 | } |
415 | 3.93k | return InsertRedlineAuthor( m_sActAuthor ); |
416 | 3.93k | } |
417 | | |
418 | | void SwModule::SetRedlineAuthor(const OUString &rAuthor) |
419 | 0 | { |
420 | 0 | m_bAuthorInitialised = true; |
421 | 0 | m_sActAuthor = rAuthor; |
422 | 0 | InsertRedlineAuthor( m_sActAuthor ); |
423 | 0 | } |
424 | | |
425 | | OUString const & SwModule::GetRedlineAuthor(std::size_t nPos) |
426 | 0 | { |
427 | 0 | OSL_ENSURE(nPos < m_pAuthorNames.size(), "author not found!"); //#i45342# RTF doc with no author table caused reader to crash |
428 | 0 | while(nPos >= m_pAuthorNames.size()) |
429 | 0 | { |
430 | 0 | InsertRedlineAuthor(u"nn"_ustr); |
431 | 0 | } |
432 | 0 | return m_pAuthorNames[nPos]; |
433 | 0 | } |
434 | | |
435 | | void SwModule::ClearRedlineAuthors() |
436 | 0 | { |
437 | 0 | m_pAuthorNames.clear(); |
438 | 0 | } |
439 | | |
440 | | static Color lcl_GetAuthorColor(std::size_t nPos) |
441 | 158 | { |
442 | | // same as SwPostItMgr::GetColorAnchor() |
443 | 158 | switch (nPos % 9) |
444 | 158 | { |
445 | 7 | case 0: return SwModule::get()->GetColorConfig().GetColorValue(svtools::AUTHOR1).nColor; |
446 | 151 | case 1: return SwModule::get()->GetColorConfig().GetColorValue(svtools::AUTHOR2).nColor; |
447 | 0 | case 2: return SwModule::get()->GetColorConfig().GetColorValue(svtools::AUTHOR3).nColor; |
448 | 0 | case 3: return SwModule::get()->GetColorConfig().GetColorValue(svtools::AUTHOR4).nColor; |
449 | 0 | case 4: return SwModule::get()->GetColorConfig().GetColorValue(svtools::AUTHOR5).nColor; |
450 | 0 | case 5: return SwModule::get()->GetColorConfig().GetColorValue(svtools::AUTHOR6).nColor; |
451 | 0 | case 6: return SwModule::get()->GetColorConfig().GetColorValue(svtools::AUTHOR7).nColor; |
452 | 0 | case 7: return SwModule::get()->GetColorConfig().GetColorValue(svtools::AUTHOR8).nColor; |
453 | 0 | case 8: return SwModule::get()->GetColorConfig().GetColorValue(svtools::AUTHOR9).nColor; |
454 | 0 | default: return COL_AUTO; // silence -Wreturn-type |
455 | 158 | } |
456 | 158 | } |
457 | | |
458 | | /// Returns a JSON representation of a redline author. |
459 | | void SwModule::GetRedlineAuthorInfo(tools::JsonWriter& rJsonWriter) |
460 | 0 | { |
461 | 0 | auto authorsNode = rJsonWriter.startArray("authors"); |
462 | 0 | for (std::size_t nAuthor = 0; nAuthor < m_pAuthorNames.size(); ++nAuthor) |
463 | 0 | { |
464 | 0 | auto authorNode = rJsonWriter.startStruct(); |
465 | 0 | rJsonWriter.put("index", static_cast<sal_Int64>(nAuthor)); |
466 | 0 | rJsonWriter.put("name", m_pAuthorNames[nAuthor]); |
467 | 0 | rJsonWriter.put("color", sal_uInt32(lcl_GetAuthorColor(nAuthor))); |
468 | 0 | } |
469 | 0 | } |
470 | | |
471 | | std::size_t SwModule::InsertRedlineAuthor(const OUString& rAuthor) |
472 | 33.6M | { |
473 | 33.6M | std::size_t nPos = 0; |
474 | | |
475 | 290M | while(nPos < m_pAuthorNames.size() && m_pAuthorNames[nPos] != rAuthor) |
476 | 256M | ++nPos; |
477 | | |
478 | 33.6M | if (nPos == m_pAuthorNames.size()) |
479 | 20.5k | m_pAuthorNames.push_back(rAuthor); |
480 | | |
481 | 33.6M | return nPos; |
482 | 33.6M | } |
483 | | |
484 | | static void lcl_FillAuthorAttr( std::size_t nAuthor, SfxItemSet &rSet, |
485 | | const AuthorCharAttr &rAttr, SwRedlineRenderMode eRenderMode = SwRedlineRenderMode::Standard ) |
486 | 158 | { |
487 | 158 | if (eRenderMode != SwRedlineRenderMode::Standard) |
488 | 0 | { |
489 | 0 | return; |
490 | 0 | } |
491 | | |
492 | 158 | Color aCol( rAttr.m_nColor ); |
493 | | |
494 | 158 | if( rAttr.m_nColor == COL_TRANSPARENT ) |
495 | 158 | { |
496 | 158 | aCol = lcl_GetAuthorColor(nAuthor); |
497 | 158 | } |
498 | | |
499 | 158 | bool bBackGr = rAttr.m_nColor == COL_NONE_COLOR; |
500 | | |
501 | 158 | switch (rAttr.m_nItemId) |
502 | 158 | { |
503 | 0 | case SID_ATTR_CHAR_WEIGHT: |
504 | 0 | { |
505 | 0 | SvxWeightItem aW( static_cast<FontWeight>(rAttr.m_nAttr), RES_CHRATR_WEIGHT ); |
506 | 0 | rSet.Put( aW ); |
507 | 0 | aW.SetWhich( RES_CHRATR_CJK_WEIGHT ); |
508 | 0 | rSet.Put( aW ); |
509 | 0 | aW.SetWhich( RES_CHRATR_CTL_WEIGHT ); |
510 | 0 | rSet.Put( aW ); |
511 | 0 | } |
512 | 0 | break; |
513 | | |
514 | 0 | case SID_ATTR_CHAR_POSTURE: |
515 | 0 | { |
516 | 0 | SvxPostureItem aP( static_cast<FontItalic>(rAttr.m_nAttr), RES_CHRATR_POSTURE ); |
517 | 0 | rSet.Put( aP ); |
518 | 0 | aP.SetWhich( RES_CHRATR_CJK_POSTURE ); |
519 | 0 | rSet.Put( aP ); |
520 | 0 | aP.SetWhich( RES_CHRATR_CTL_POSTURE ); |
521 | 0 | rSet.Put( aP ); |
522 | 0 | } |
523 | 0 | break; |
524 | | |
525 | 158 | case SID_ATTR_CHAR_UNDERLINE: |
526 | 158 | rSet.Put( SvxUnderlineItem( static_cast<FontLineStyle>(rAttr.m_nAttr), |
527 | 158 | RES_CHRATR_UNDERLINE)); |
528 | 158 | break; |
529 | | |
530 | 0 | case SID_ATTR_CHAR_STRIKEOUT: |
531 | 0 | rSet.Put(SvxCrossedOutItem( static_cast<FontStrikeout>(rAttr.m_nAttr), |
532 | 0 | RES_CHRATR_CROSSEDOUT)); |
533 | 0 | break; |
534 | | |
535 | 0 | case SID_ATTR_CHAR_CASEMAP: |
536 | 0 | rSet.Put( SvxCaseMapItem( static_cast<SvxCaseMap>(rAttr.m_nAttr), |
537 | 0 | RES_CHRATR_CASEMAP)); |
538 | 0 | break; |
539 | | |
540 | 0 | case SID_ATTR_BRUSH: |
541 | 0 | rSet.Put( SvxBrushItem( aCol, RES_CHRATR_BACKGROUND )); |
542 | 0 | bBackGr = true; |
543 | 0 | break; |
544 | 158 | } |
545 | | |
546 | 158 | if( !bBackGr ) |
547 | 158 | rSet.Put( SvxColorItem( aCol, RES_CHRATR_COLOR ) ); |
548 | 158 | } |
549 | | |
550 | | void SwModule::GetInsertAuthorAttr(std::size_t nAuthor, SfxItemSet &rSet, SwRedlineRenderMode eRenderMode) |
551 | 158 | { |
552 | 158 | lcl_FillAuthorAttr(nAuthor, rSet, m_pModuleConfig->GetInsertAuthorAttr(), eRenderMode); |
553 | 158 | } |
554 | | |
555 | | void SwModule::GetDeletedAuthorAttr(std::size_t nAuthor, SfxItemSet &rSet, SwRedlineRenderMode eRenderMode) |
556 | 0 | { |
557 | 0 | lcl_FillAuthorAttr(nAuthor, rSet, m_pModuleConfig->GetDeletedAuthorAttr(), eRenderMode); |
558 | 0 | } |
559 | | |
560 | | // For future extension: |
561 | | void SwModule::GetFormatAuthorAttr( std::size_t nAuthor, SfxItemSet &rSet ) |
562 | 0 | { |
563 | 0 | lcl_FillAuthorAttr( nAuthor, rSet, m_pModuleConfig->GetFormatAuthorAttr() ); |
564 | 0 | } |
565 | | |
566 | | sal_uInt16 SwModule::GetRedlineMarkPos() const |
567 | 163k | { |
568 | 163k | return m_pModuleConfig->GetMarkAlignMode(); |
569 | 163k | } |
570 | | |
571 | | bool SwModule::IsInsTableFormatNum(bool bHTML) const |
572 | 0 | { |
573 | 0 | return m_pModuleConfig->IsInsTableFormatNum(bHTML); |
574 | 0 | } |
575 | | |
576 | | bool SwModule::IsInsTableChangeNumFormat(bool bHTML) const |
577 | 0 | { |
578 | 0 | return m_pModuleConfig->IsInsTableChangeNumFormat(bHTML); |
579 | 0 | } |
580 | | |
581 | | bool SwModule::IsInsTableAlignNum(bool bHTML) const |
582 | 49.7k | { |
583 | 49.7k | return m_pModuleConfig->IsInsTableAlignNum(bHTML); |
584 | 49.7k | } |
585 | | |
586 | | bool SwModule::IsSplitVerticalByDefault(bool bHTML) const |
587 | 0 | { |
588 | 0 | return m_pModuleConfig->IsSplitVerticalByDefault(bHTML); |
589 | 0 | } |
590 | | |
591 | | void SwModule::SetSplitVerticalByDefault(bool bHTML, bool value) |
592 | 0 | { |
593 | 0 | m_pModuleConfig->SetSplitVerticalByDefault(bHTML, value); |
594 | 0 | } |
595 | | |
596 | | const Color &SwModule::GetRedlineMarkColor() const |
597 | 0 | { |
598 | 0 | return m_pModuleConfig->GetMarkAlignColor(); |
599 | 0 | } |
600 | | |
601 | | const SwViewOption* SwModule::GetViewOption(bool bWeb) |
602 | 0 | { |
603 | 0 | return GetUsrPref( bWeb ); |
604 | 0 | } |
605 | | |
606 | | OUString const & SwModule::GetDocStatWordDelim() const |
607 | 0 | { |
608 | 0 | return m_pModuleConfig->GetWordDelimiter(); |
609 | 0 | } |
610 | | |
611 | | // Passing-through of the ModuleConfig's Metric (for HTML-Export) |
612 | | FieldUnit SwModule::GetMetric( bool bWeb ) const |
613 | 0 | { |
614 | 0 | SwMasterUsrPref* pPref; |
615 | 0 | if(bWeb) |
616 | 0 | { |
617 | 0 | if(!m_pWebUsrPref) |
618 | 0 | GetUsrPref(true); |
619 | 0 | pPref = m_pWebUsrPref.get(); |
620 | 0 | } |
621 | 0 | else |
622 | 0 | { |
623 | 0 | if(!m_pUsrPref) |
624 | 0 | GetUsrPref(false); |
625 | 0 | pPref = m_pUsrPref.get(); |
626 | 0 | } |
627 | 0 | assert(pPref && "pPref is set by here"); |
628 | 0 | return pPref->GetMetric(); |
629 | 0 | } |
630 | | |
631 | | // Pass-through Update-Status |
632 | | sal_uInt16 SwModule::GetLinkUpdMode() const |
633 | 14.2k | { |
634 | 14.2k | if (!m_pUsrPref) |
635 | 0 | GetUsrPref(false); |
636 | 14.2k | assert(m_pUsrPref && "m_pUsrPref is set by here"); |
637 | 14.2k | return o3tl::narrowing<sal_uInt16>(m_pUsrPref->GetUpdateLinkMode()); |
638 | 14.2k | } |
639 | | |
640 | | SwFieldUpdateFlags SwModule::GetFieldUpdateFlags() const |
641 | 0 | { |
642 | 0 | if (!m_pUsrPref) |
643 | 0 | GetUsrPref(false); |
644 | 0 | assert(m_pUsrPref && "m_pUsrPref is set by here"); |
645 | 0 | return m_pUsrPref->GetFieldUpdateFlags(); |
646 | 0 | } |
647 | | |
648 | | void SwModule::ApplyFieldUpdateFlags(SwFieldUpdateFlags eFieldFlags) |
649 | 0 | { |
650 | 0 | if (!m_pUsrPref) |
651 | 0 | GetUsrPref(false); |
652 | 0 | assert(m_pUsrPref && "m_pUsrPref is set by here"); |
653 | 0 | m_pUsrPref->SetFieldUpdateFlags(eFieldFlags); |
654 | 0 | } |
655 | | |
656 | | void SwModule::ApplyLinkMode(sal_Int32 nNewLinkMode) |
657 | 0 | { |
658 | 0 | if (!m_pUsrPref) |
659 | 0 | GetUsrPref(false); |
660 | 0 | assert(m_pUsrPref && "m_pUsrPref is set by here"); |
661 | 0 | m_pUsrPref->SetUpdateLinkMode(nNewLinkMode); |
662 | 0 | } |
663 | | |
664 | | void SwModule::CheckSpellChanges( bool bOnlineSpelling, |
665 | | bool bIsSpellWrongAgain, bool bIsSpellAllAgain, bool bSmartTags ) |
666 | 0 | { |
667 | 0 | bool bOnlyWrong = bIsSpellWrongAgain && !bIsSpellAllAgain; |
668 | 0 | bool bInvalid = bOnlyWrong || bIsSpellAllAgain; |
669 | 0 | if( !(bOnlineSpelling || bInvalid) ) |
670 | 0 | return; |
671 | | |
672 | 0 | for( SwDocShell *pDocSh = static_cast<SwDocShell*>(SfxObjectShell::GetFirst(checkSfxObjectShell<SwDocShell>)); |
673 | 0 | pDocSh; |
674 | 0 | pDocSh = static_cast<SwDocShell*>(SfxObjectShell::GetNext( *pDocSh, checkSfxObjectShell<SwDocShell> ) ) ) |
675 | 0 | { |
676 | 0 | SwDoc* pTmp = pDocSh->GetDoc(); |
677 | 0 | if ( pTmp->getIDocumentLayoutAccess().GetCurrentViewShell() ) |
678 | 0 | { |
679 | 0 | pTmp->SpellItAgainSam( bInvalid, bOnlyWrong, bSmartTags ); |
680 | 0 | SwViewShell* pViewShell = pTmp->getIDocumentLayoutAccess().GetCurrentViewShell(); |
681 | 0 | if ( bSmartTags && pViewShell && pViewShell->GetWin() ) |
682 | 0 | pViewShell->GetWin()->Invalidate(); |
683 | 0 | } |
684 | 0 | } |
685 | 0 | } |
686 | | |
687 | | void SwModule::ApplyDefaultPageMode(bool bIsSquaredPageMode) |
688 | 0 | { |
689 | 0 | if (!m_pUsrPref) |
690 | 0 | GetUsrPref(false); |
691 | 0 | assert(m_pUsrPref && "pPref is set by here"); |
692 | 0 | m_pUsrPref->SetDefaultPageMode(bIsSquaredPageMode); |
693 | 0 | } |
694 | | |
695 | | SwCompareMode SwModule::GetCompareMode() const |
696 | 0 | { |
697 | 0 | return m_pModuleConfig->GetCompareMode(); |
698 | 0 | } |
699 | | |
700 | | bool SwModule::IsUseRsid() const |
701 | 0 | { |
702 | 0 | return m_pModuleConfig->IsUseRsid(); |
703 | 0 | } |
704 | | |
705 | | bool SwModule::IsIgnorePieces() const |
706 | 0 | { |
707 | 0 | return m_pModuleConfig->IsIgnorePieces(); |
708 | 0 | } |
709 | | |
710 | | sal_uInt16 SwModule::GetPieceLen() const |
711 | 0 | { |
712 | 0 | return m_pModuleConfig->GetPieceLen(); |
713 | 0 | } |
714 | | |
715 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |