/src/libreoffice/sc/source/ui/app/scmod.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 <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp> |
21 | | #include <comphelper/lok.hxx> |
22 | | #include <comphelper/processfactory.hxx> |
23 | | #include <scitems.hxx> |
24 | | #include <sfx2/app.hxx> |
25 | | |
26 | | #include <editeng/flditem.hxx> |
27 | | #include <editeng/outliner.hxx> |
28 | | |
29 | | #include <sfx2/viewfrm.hxx> |
30 | | #include <sfx2/objface.hxx> |
31 | | #include <sfx2/toolbarids.hxx> |
32 | | |
33 | | #include <IAnyRefDialog.hxx> |
34 | | |
35 | | #include <svtools/ehdl.hxx> |
36 | | #include <svtools/accessibilityoptions.hxx> |
37 | | #include <svl/ctloptions.hxx> |
38 | | #include <unotools/useroptions.hxx> |
39 | | #include <sfx2/bindings.hxx> |
40 | | #include <sfx2/request.hxx> |
41 | | #include <sfx2/printer.hxx> |
42 | | #include <editeng/langitem.hxx> |
43 | | #include <svtools/colorcfg.hxx> |
44 | | |
45 | | #include <svl/whiter.hxx> |
46 | | #include <svx/dialogs.hrc> |
47 | | #include <svl/inethist.hxx> |
48 | | #include <vcl/svapp.hxx> |
49 | | #include <svx/svxerr.hxx> |
50 | | #include <comphelper/diagnose_ex.hxx> |
51 | | |
52 | | #include <editeng/unolingu.hxx> |
53 | | #include <unotools/lingucfg.hxx> |
54 | | #include <i18nlangtag/mslangid.hxx> |
55 | | #include <i18nlangtag/languagetag.hxx> |
56 | | #include <com/sun/star/i18n/ScriptType.hpp> |
57 | | #include <com/sun/star/linguistic2/XThesaurus.hpp> |
58 | | #include <ooo/vba/XSinkCaller.hpp> |
59 | | |
60 | | #include <scmod.hxx> |
61 | | #include <global.hxx> |
62 | | #include <viewopti.hxx> |
63 | | #include <docoptio.hxx> |
64 | | #include <appoptio.hxx> |
65 | | #include <defaultsoptions.hxx> |
66 | | #include <formulaopt.hxx> |
67 | | #include <inputopt.hxx> |
68 | | #include <printopt.hxx> |
69 | | #include <navicfg.hxx> |
70 | | #include <addincfg.hxx> |
71 | | #include <tabvwsh.hxx> |
72 | | #include <prevwsh.hxx> |
73 | | #include <docsh.hxx> |
74 | | #include <drwlayer.hxx> |
75 | | #include <uiitems.hxx> |
76 | | #include <sc.hrc> |
77 | | #include <scerrors.hrc> |
78 | | #include <scstyles.hrc> |
79 | | #include <globstr.hrc> |
80 | | #include <scresid.hxx> |
81 | | #include <bitmaps.hlst> |
82 | | #include <inputhdl.hxx> |
83 | | #include <inputwin.hxx> |
84 | | #include <msgpool.hxx> |
85 | | #include <detfunc.hxx> |
86 | | #include <preview.hxx> |
87 | | #include <dragdata.hxx> |
88 | | #include <markdata.hxx> |
89 | | #include <transobj.hxx> |
90 | | #include <funcdesc.hxx> |
91 | | |
92 | | #define ShellClass_ScModule |
93 | | #include <scslots.hxx> |
94 | | |
95 | | #include <scabstdlg.hxx> |
96 | | #include <formula/errorcodes.hxx> |
97 | | #include <documentlinkmgr.hxx> |
98 | | #include <LibreOfficeKit/LibreOfficeKitEnums.h> |
99 | | #include <sfx2/lokhelper.hxx> |
100 | | |
101 | 11 | #define SC_IDLE_STEP 150 |
102 | | |
103 | | SFX_IMPL_INTERFACE(ScModule, SfxShell) |
104 | | |
105 | | void ScModule::InitInterface_Impl() |
106 | 11 | { |
107 | 11 | GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION, |
108 | 11 | SfxVisibilityFlags::Standard | SfxVisibilityFlags::Client | SfxVisibilityFlags::Viewer, |
109 | 11 | ToolbarId::Objectbar_App); |
110 | | |
111 | 11 | GetStaticInterface()->RegisterStatusBar(StatusBarId::CalcStatusBar); |
112 | 11 | } |
113 | | |
114 | | ScModule::ScModule( SfxObjectFactory* pFact ) : |
115 | 11 | SfxModule("sc"_ostr, {pFact}), |
116 | 11 | m_aIdleTimer("sc ScModule IdleTimer"), |
117 | 11 | m_pDragData(new ScDragData), |
118 | 11 | m_pSelTransfer( nullptr ), |
119 | 11 | m_pRefInputHandler( nullptr ), |
120 | 11 | m_nCurRefDlgId( 0 ), |
121 | 11 | m_bIsWaterCan( false ), |
122 | 11 | m_bIsInEditCommand( false ), |
123 | 11 | m_bIsInExecuteDrop( false ), |
124 | 11 | m_bIsInSharedDocLoading( false ), |
125 | 11 | m_bIsInSharedDocSaving( false ) |
126 | 11 | { |
127 | | // The ResManager (DLL data) is not yet initialized in the ctor! |
128 | 11 | SetName(u"StarCalc"_ustr); // for Basic |
129 | | |
130 | 11 | ResetDragObject(); |
131 | | |
132 | | // InputHandler does not need to be created |
133 | | |
134 | | // Create ErrorHandler - was in Init() |
135 | | // Between OfficeApplication::Init and ScGlobal::Init |
136 | 11 | SvxErrorHandler::ensure(); |
137 | 11 | m_pErrorHdl.reset( new SfxErrorHandler(RID_ERRHDLSC, |
138 | 11 | ErrCodeArea::Sc, |
139 | 11 | ErrCodeArea::Sc, |
140 | 11 | GetResLocale()) ); |
141 | | |
142 | 11 | m_aIdleTimer.SetPriority(TaskPriority::DEFAULT_IDLE); |
143 | 11 | m_aIdleTimer.SetTimeout(SC_IDLE_STEP); |
144 | 11 | m_aIdleTimer.SetInvokeHandler( LINK( this, ScModule, IdleHandler ) ); |
145 | 11 | m_aIdleTimer.Start(); |
146 | | |
147 | 11 | m_pMessagePool = new ScMessagePool; |
148 | 11 | SetPool( m_pMessagePool.get() ); |
149 | | |
150 | 11 | ScGlobal::InitTextHeight( *m_pMessagePool ); |
151 | | |
152 | 11 | StartListening( *SfxGetpApp() ); // for SfxHintId::Deinitializing |
153 | | |
154 | | // Initialize the color config |
155 | 11 | GetColorConfig(); |
156 | 11 | } |
157 | | |
158 | | ScModule::~ScModule() |
159 | 0 | { |
160 | 0 | OSL_ENSURE( !m_pSelTransfer, "Selection Transfer object not deleted" ); |
161 | | |
162 | | // InputHandler does not need to be deleted (there's none in the App anymore) |
163 | |
|
164 | 0 | m_pMessagePool.clear(); |
165 | |
|
166 | 0 | m_pDragData.reset(); |
167 | 0 | m_pErrorHdl.reset(); |
168 | |
|
169 | 0 | ScGlobal::Clear(); // Also calls ScDocumentPool::DeleteVersionMaps(); |
170 | |
|
171 | 0 | ScInterpreterContextPool::ModuleExiting(); |
172 | |
|
173 | 0 | DeleteCfg(); // Called from Exit() |
174 | 0 | } |
175 | | |
176 | | void ScModule::ConfigurationChanged(utl::ConfigurationBroadcaster* p, ConfigurationHints eHints) |
177 | 0 | { |
178 | 0 | if ( p == m_pColorConfig.get() ) |
179 | 0 | { |
180 | | // Test if detective objects have to be updated with new colors |
181 | | // (if the detective colors haven't been used yet, there's nothing to update) |
182 | 0 | if ( ScDetectiveFunc::IsColorsInitialized() ) |
183 | 0 | { |
184 | 0 | const svtools::ColorConfig& rColors = GetColorConfig(); |
185 | 0 | bool bArrows = |
186 | 0 | ( ScDetectiveFunc::GetArrowColor() != rColors.GetColorValue(svtools::CALCDETECTIVE).nColor || |
187 | 0 | ScDetectiveFunc::GetErrorColor() != rColors.GetColorValue(svtools::CALCDETECTIVEERROR).nColor ); |
188 | 0 | bool bComments = |
189 | 0 | ( ScDetectiveFunc::GetCommentColor() != rColors.GetColorValue(svtools::CALCNOTESBACKGROUND).nColor ); |
190 | 0 | if ( bArrows || bComments ) |
191 | 0 | { |
192 | 0 | ScDetectiveFunc::InitializeColors(); // get the new colors |
193 | | |
194 | | // update detective objects in all open documents |
195 | 0 | SfxObjectShell* pObjSh = SfxObjectShell::GetFirst(); |
196 | 0 | while ( pObjSh ) |
197 | 0 | { |
198 | 0 | if ( auto pDocSh = dynamic_cast<ScDocShell * >(pObjSh) ) |
199 | 0 | { |
200 | 0 | if ( bArrows ) |
201 | 0 | ScDetectiveFunc( pDocSh->GetDocument(), 0 ).UpdateAllArrowColors(); |
202 | 0 | if ( bComments ) |
203 | 0 | ScDetectiveFunc::UpdateAllComments( pDocSh->GetDocument() ); |
204 | 0 | } |
205 | 0 | pObjSh = SfxObjectShell::GetNext( *pObjSh ); |
206 | 0 | } |
207 | 0 | } |
208 | 0 | } |
209 | |
|
210 | 0 | const bool bKit = comphelper::LibreOfficeKit::isActive(); |
211 | | |
212 | | //invalidate only the current view in tiled rendering mode, or all views otherwise |
213 | 0 | SfxViewShell* pViewShell = bKit ? SfxViewShell::Current() : SfxViewShell::GetFirst(); |
214 | 0 | while (pViewShell) |
215 | 0 | { |
216 | 0 | if (ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(pViewShell)) |
217 | 0 | { |
218 | 0 | ScViewRenderingOptions aViewRenderingOptions(pViewSh->GetViewRenderingData()); |
219 | 0 | Color aFillColor(m_pColorConfig->GetColorValue(svtools::DOCCOLOR).nColor); |
220 | 0 | aViewRenderingOptions.SetDocColor(aFillColor); |
221 | 0 | aViewRenderingOptions.SetColorSchemeName(svtools::ColorConfig::GetCurrentSchemeName()); |
222 | 0 | const bool bUnchanged(aViewRenderingOptions == pViewSh->GetViewRenderingData()); |
223 | 0 | if (!bUnchanged) |
224 | 0 | pViewSh->SetViewRenderingData(aViewRenderingOptions); |
225 | |
|
226 | 0 | if (SfxObjectShell* pKitCurrentObjSh = bKit ? SfxObjectShell::Current() : nullptr) |
227 | 0 | { |
228 | 0 | ScModelObj* pScModelObj = comphelper::getFromUnoTunnel<ScModelObj>(pKitCurrentObjSh->GetModel()); |
229 | 0 | SfxLokHelper::notifyViewRenderState(pViewSh, pScModelObj); |
230 | | // In Online, the document color is the one used for the background, contrary to |
231 | | // Writer and Draw that use the application background color. |
232 | 0 | pViewSh->libreOfficeKitViewCallback(LOK_CALLBACK_APPLICATION_BACKGROUND_COLOR, |
233 | 0 | aFillColor.AsRGBHexString().toUtf8()); |
234 | 0 | } |
235 | | |
236 | | // if nothing changed, and the hint was OnlyCurrentDocumentColorScheme we can skip invalidate |
237 | 0 | const bool bSkipInvalidate = bKit ||(bUnchanged && eHints == ConfigurationHints::OnlyCurrentDocumentColorScheme); |
238 | 0 | if (!bSkipInvalidate) |
239 | 0 | { |
240 | 0 | pViewSh->PaintGrid(); |
241 | 0 | pViewSh->PaintTop(); |
242 | 0 | pViewSh->PaintLeft(); |
243 | 0 | pViewSh->PaintExtras(); |
244 | 0 | } |
245 | |
|
246 | 0 | ScInputHandler* pHdl = pViewSh->GetInputHandler(); |
247 | 0 | if ( pHdl ) |
248 | 0 | pHdl->ForgetLastPattern(); // EditEngine BackgroundColor may change |
249 | 0 | } |
250 | 0 | else if ( dynamic_cast<const ScPreviewShell*>( pViewShell) != nullptr ) |
251 | 0 | { |
252 | 0 | vcl::Window* pWin = pViewShell->GetWindow(); |
253 | 0 | if (pWin) |
254 | 0 | pWin->Invalidate(); |
255 | 0 | } |
256 | 0 | if (bKit) |
257 | 0 | break; |
258 | 0 | pViewShell = SfxViewShell::GetNext( *pViewShell ); |
259 | 0 | } |
260 | 0 | } |
261 | 0 | else if ( p == m_pCTLOptions.get() ) |
262 | 0 | { |
263 | | // for all documents: set digit language for printer, recalc output factor, update row heights |
264 | 0 | SfxObjectShell* pObjSh = SfxObjectShell::GetFirst(); |
265 | 0 | while ( pObjSh ) |
266 | 0 | { |
267 | 0 | if ( auto pDocSh = dynamic_cast<ScDocShell *>(pObjSh) ) |
268 | 0 | { |
269 | 0 | OutputDevice* pPrinter = pDocSh->GetPrinter(); |
270 | 0 | if ( pPrinter ) |
271 | 0 | pPrinter->SetDigitLanguage( GetOptDigitLanguage() ); |
272 | |
|
273 | 0 | pDocSh->CalcOutputFactor(); |
274 | |
|
275 | 0 | SCTAB nTabCount = pDocSh->GetDocument().GetTableCount(); |
276 | 0 | for (SCTAB nTab=0; nTab<nTabCount; nTab++) |
277 | 0 | pDocSh->AdjustRowHeight( 0, pDocSh->GetDocument().MaxRow(), nTab ); |
278 | 0 | } |
279 | 0 | pObjSh = SfxObjectShell::GetNext( *pObjSh ); |
280 | 0 | } |
281 | | |
282 | | // for all views (table and preview): update digit language |
283 | 0 | SfxViewShell* pSh = SfxViewShell::GetFirst(); |
284 | 0 | while ( pSh ) |
285 | 0 | { |
286 | 0 | if (ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(pSh)) |
287 | 0 | { |
288 | | // set ref-device for EditEngine (re-evaluates digit settings) |
289 | 0 | ScInputHandler* pHdl = GetInputHdl(pViewSh); |
290 | 0 | if (pHdl) |
291 | 0 | pHdl->UpdateRefDevice(); |
292 | |
|
293 | 0 | pViewSh->DigitLanguageChanged(); |
294 | 0 | pViewSh->PaintGrid(); |
295 | 0 | } |
296 | 0 | else if (ScPreviewShell* pPreviewSh = dynamic_cast<ScPreviewShell*>(pSh)) |
297 | 0 | { |
298 | 0 | ScPreview* pPreview = pPreviewSh->GetPreview(); |
299 | |
|
300 | 0 | pPreview->GetOutDev()->SetDigitLanguage( GetOptDigitLanguage() ); |
301 | 0 | pPreview->Invalidate(); |
302 | 0 | } |
303 | |
|
304 | 0 | pSh = SfxViewShell::GetNext( *pSh ); |
305 | 0 | } |
306 | 0 | } |
307 | 0 | } |
308 | | |
309 | | void ScModule::Notify( SfxBroadcaster&, const SfxHint& rHint ) |
310 | 103k | { |
311 | 103k | if ( rHint.GetId() == SfxHintId::Deinitializing ) |
312 | 0 | { |
313 | | // ConfigItems must be removed before ConfigManager |
314 | 0 | DeleteCfg(); |
315 | 0 | } |
316 | 103k | } |
317 | | |
318 | | void ScModule::DeleteCfg() |
319 | 0 | { |
320 | 0 | m_pViewCfg.reset(); // Saving happens automatically before Exit() |
321 | 0 | m_pDocCfg.reset(); |
322 | 0 | m_pAppCfg.reset(); |
323 | 0 | m_pDefaultsCfg.reset(); |
324 | 0 | m_pFormulaCfg.reset(); |
325 | 0 | m_pInputCfg.reset(); |
326 | 0 | m_pPrintCfg.reset(); |
327 | 0 | m_pNavipiCfg.reset(); |
328 | 0 | m_pAddInCfg.reset(); |
329 | |
|
330 | 0 | if ( m_pColorConfig ) |
331 | 0 | { |
332 | 0 | m_pColorConfig->RemoveListener(this); |
333 | 0 | m_pColorConfig.reset(); |
334 | 0 | } |
335 | 0 | if ( m_pCTLOptions ) |
336 | 0 | { |
337 | 0 | m_pCTLOptions->RemoveListener(this); |
338 | 0 | m_pCTLOptions.reset(); |
339 | 0 | } |
340 | 0 | m_pUserOptions.reset(); |
341 | 0 | } |
342 | | |
343 | | // Moved here from the App |
344 | | |
345 | | void ScModule::Execute( SfxRequest& rReq ) |
346 | 0 | { |
347 | 0 | SfxViewFrame* pViewFrm = SfxViewFrame::Current(); |
348 | 0 | SfxBindings* pBindings = pViewFrm ? &pViewFrm->GetBindings() : nullptr; |
349 | |
|
350 | 0 | const SfxItemSet* pReqArgs = rReq.GetArgs(); |
351 | 0 | sal_uInt16 nSlot = rReq.GetSlot(); |
352 | |
|
353 | 0 | switch ( nSlot ) |
354 | 0 | { |
355 | 0 | case SID_CHOOSE_DESIGN: |
356 | 0 | SfxApplication::CallAppBasic( u"Template.Samples.ShowStyles"_ustr ); |
357 | 0 | break; |
358 | 0 | case SID_EURO_CONVERTER: |
359 | 0 | SfxApplication::CallAppBasic( u"Euro.ConvertRun.Main"_ustr ); |
360 | 0 | break; |
361 | 0 | case SID_AUTOSPELL_CHECK: |
362 | 0 | { |
363 | 0 | bool bSet; |
364 | 0 | const SfxPoolItem* pItem; |
365 | 0 | if (pReqArgs && SfxItemState::SET == pReqArgs->GetItemState( FN_PARAM_1, true, &pItem )) |
366 | 0 | bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue(); |
367 | 0 | else if ( pReqArgs && SfxItemState::SET == pReqArgs->GetItemState( nSlot, true, &pItem ) ) |
368 | 0 | bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue(); |
369 | 0 | else |
370 | 0 | { // Toggle |
371 | 0 | ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()); |
372 | 0 | if (pViewSh) |
373 | 0 | bSet = !pViewSh->IsAutoSpell(); |
374 | 0 | else |
375 | 0 | bSet = !ScModule::GetAutoSpellProperty(); |
376 | 0 | } |
377 | |
|
378 | 0 | SfxItemSetFixed<SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK> aSet( GetPool() ); |
379 | 0 | aSet.Put( SfxBoolItem( SID_AUTOSPELL_CHECK, bSet ) ); |
380 | 0 | ModifyOptions( aSet ); |
381 | 0 | rReq.Done(); |
382 | 0 | } |
383 | 0 | break; |
384 | | |
385 | 0 | case SID_ATTR_METRIC: |
386 | 0 | { |
387 | 0 | const SfxPoolItem* pItem; |
388 | 0 | if ( pReqArgs && SfxItemState::SET == pReqArgs->GetItemState( nSlot, true, &pItem ) ) |
389 | 0 | { |
390 | 0 | FieldUnit eUnit = static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()); |
391 | 0 | switch( eUnit ) |
392 | 0 | { |
393 | 0 | case FieldUnit::MM: // Just the units that are also in the dialog |
394 | 0 | case FieldUnit::CM: |
395 | 0 | case FieldUnit::INCH: |
396 | 0 | case FieldUnit::PICA: |
397 | 0 | case FieldUnit::POINT: |
398 | 0 | { |
399 | 0 | PutItem( *pItem ); |
400 | 0 | ScAppOptions aNewOpts( GetAppOptions() ); |
401 | 0 | aNewOpts.SetAppMetric( eUnit ); |
402 | 0 | SetAppOptions( aNewOpts ); |
403 | 0 | rReq.Done(); |
404 | 0 | } |
405 | 0 | break; |
406 | 0 | default: |
407 | 0 | { |
408 | | // added to avoid warnings |
409 | 0 | } |
410 | 0 | } |
411 | 0 | } |
412 | 0 | } |
413 | 0 | break; |
414 | | |
415 | 0 | case FID_AUTOCOMPLETE: |
416 | 0 | { |
417 | 0 | ScAppOptions aNewOpts( GetAppOptions() ); |
418 | 0 | bool bNew = !aNewOpts.GetAutoComplete(); |
419 | 0 | aNewOpts.SetAutoComplete( bNew ); |
420 | 0 | SetAppOptions( aNewOpts ); |
421 | 0 | if (pBindings) |
422 | 0 | pBindings->Invalidate( FID_AUTOCOMPLETE ); |
423 | 0 | rReq.Done(); |
424 | 0 | } |
425 | 0 | break; |
426 | | |
427 | 0 | case SID_DETECTIVE_AUTO: |
428 | 0 | { |
429 | 0 | ScAppOptions aNewOpts( GetAppOptions() ); |
430 | 0 | bool bNew = !aNewOpts.GetDetectiveAuto(); |
431 | 0 | const SfxBoolItem* pAuto = rReq.GetArg<SfxBoolItem>(SID_DETECTIVE_AUTO); |
432 | 0 | if ( pAuto ) |
433 | 0 | bNew = pAuto->GetValue(); |
434 | |
|
435 | 0 | aNewOpts.SetDetectiveAuto( bNew ); |
436 | 0 | SetAppOptions( aNewOpts ); |
437 | 0 | if (pBindings) |
438 | 0 | pBindings->Invalidate( SID_DETECTIVE_AUTO ); |
439 | 0 | rReq.AppendItem( SfxBoolItem( SID_DETECTIVE_AUTO, bNew ) ); |
440 | 0 | rReq.Done(); |
441 | 0 | } |
442 | 0 | break; |
443 | | |
444 | 0 | case SID_PSZ_FUNCTION: |
445 | 0 | if (pReqArgs) |
446 | 0 | { |
447 | 0 | const SfxUInt32Item & rItem = pReqArgs->Get(SID_PSZ_FUNCTION); |
448 | |
|
449 | 0 | ScAppOptions aNewOpts( GetAppOptions() ); |
450 | 0 | aNewOpts.SetStatusFunc( rItem.GetValue() ); |
451 | 0 | SetAppOptions( aNewOpts ); |
452 | |
|
453 | 0 | if (pBindings) |
454 | 0 | { |
455 | 0 | pBindings->Invalidate( SID_TABLE_CELL ); |
456 | 0 | pBindings->Update( SID_TABLE_CELL ); // Immediately |
457 | |
|
458 | 0 | pBindings->Invalidate( SID_PSZ_FUNCTION ); |
459 | 0 | pBindings->Update( SID_PSZ_FUNCTION ); |
460 | | // If the menu is opened again immediately |
461 | 0 | } |
462 | 0 | } |
463 | 0 | break; |
464 | | |
465 | 0 | case SID_ATTR_LANGUAGE: |
466 | 0 | case SID_ATTR_CHAR_CJK_LANGUAGE: |
467 | 0 | case SID_ATTR_CHAR_CTL_LANGUAGE: |
468 | 0 | { |
469 | 0 | const SfxPoolItem* pItem; |
470 | 0 | if ( pReqArgs && SfxItemState::SET == pReqArgs->GetItemState( GetPool().GetWhichIDFromSlotID(nSlot), true, &pItem ) ) |
471 | 0 | { |
472 | 0 | ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() ); |
473 | 0 | if ( pDocSh ) |
474 | 0 | { |
475 | 0 | ScDocument& rDoc = pDocSh->GetDocument(); |
476 | 0 | LanguageType eNewLang = static_cast<const SvxLanguageItem*>(pItem)->GetLanguage(); |
477 | 0 | LanguageType eLatin, eCjk, eCtl; |
478 | 0 | rDoc.GetLanguage( eLatin, eCjk, eCtl ); |
479 | 0 | LanguageType eOld = ( nSlot == SID_ATTR_CHAR_CJK_LANGUAGE ) ? eCjk : |
480 | 0 | ( ( nSlot == SID_ATTR_CHAR_CTL_LANGUAGE ) ? eCtl : eLatin ); |
481 | 0 | if ( eNewLang != eOld ) |
482 | 0 | { |
483 | 0 | if ( nSlot == SID_ATTR_CHAR_CJK_LANGUAGE ) |
484 | 0 | eCjk = eNewLang; |
485 | 0 | else if ( nSlot == SID_ATTR_CHAR_CTL_LANGUAGE ) |
486 | 0 | eCtl = eNewLang; |
487 | 0 | else |
488 | 0 | eLatin = eNewLang; |
489 | |
|
490 | 0 | rDoc.SetLanguage( eLatin, eCjk, eCtl ); |
491 | |
|
492 | 0 | ScInputHandler* pInputHandler = GetInputHdl(); |
493 | 0 | if ( pInputHandler ) |
494 | 0 | pInputHandler->UpdateSpellSettings(); // EditEngine flags |
495 | 0 | ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); |
496 | 0 | if ( pViewSh ) |
497 | 0 | pViewSh->UpdateDrawTextOutliner(); // EditEngine flags |
498 | |
|
499 | 0 | pDocSh->SetDocumentModified(); |
500 | 0 | } |
501 | 0 | } |
502 | 0 | } |
503 | 0 | } |
504 | 0 | break; |
505 | | |
506 | 0 | case FID_FOCUS_POSWND: |
507 | 0 | { |
508 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
509 | 0 | if (pHdl) |
510 | 0 | { |
511 | 0 | ScInputWindow* pWin = pHdl->GetInputWindow(); |
512 | 0 | if (pWin) |
513 | 0 | pWin->PosGrabFocus(); |
514 | 0 | } |
515 | 0 | rReq.Done(); |
516 | 0 | } |
517 | 0 | break; |
518 | | |
519 | 0 | case SID_OPEN_XML_FILTERSETTINGS: |
520 | 0 | { |
521 | 0 | try |
522 | 0 | { |
523 | 0 | css::uno::Reference < css::ui::dialogs::XExecutableDialog > xDialog = css::ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext()); |
524 | 0 | (void)xDialog->execute(); |
525 | 0 | } |
526 | 0 | catch( css::uno::RuntimeException& ) |
527 | 0 | { |
528 | 0 | DBG_UNHANDLED_EXCEPTION("sc.ui"); |
529 | 0 | } |
530 | 0 | } |
531 | 0 | break; |
532 | | |
533 | 0 | default: |
534 | 0 | OSL_FAIL( "ScApplication: Unknown Message." ); |
535 | 0 | break; |
536 | 0 | } |
537 | 0 | } |
538 | | |
539 | | void ScModule::GetState( SfxItemSet& rSet ) |
540 | 0 | { |
541 | 0 | ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() ); |
542 | 0 | ScTabViewShell* pTabViewShell = pDocSh ? pDocSh->GetBestViewShell() : nullptr; |
543 | |
|
544 | 0 | SfxWhichIter aIter(rSet); |
545 | 0 | for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich()) |
546 | 0 | { |
547 | 0 | if (!pTabViewShell) |
548 | 0 | { |
549 | | // Not in the normal calc view shell (most likely in preview shell). Disable all actions. |
550 | 0 | rSet.DisableItem(nWhich); |
551 | 0 | continue; |
552 | 0 | } |
553 | | |
554 | 0 | switch ( nWhich ) |
555 | 0 | { |
556 | 0 | case FID_AUTOCOMPLETE: |
557 | 0 | rSet.Put( SfxBoolItem( nWhich, GetAppOptions().GetAutoComplete() ) ); |
558 | 0 | break; |
559 | 0 | case SID_DETECTIVE_AUTO: |
560 | 0 | rSet.Put( SfxBoolItem( nWhich, GetAppOptions().GetDetectiveAuto() ) ); |
561 | 0 | break; |
562 | 0 | case SID_PSZ_FUNCTION: |
563 | 0 | rSet.Put( SfxUInt32Item( nWhich, GetAppOptions().GetStatusFunc() ) ); |
564 | 0 | break; |
565 | 0 | case SID_ATTR_METRIC: |
566 | 0 | rSet.Put(SfxUInt16Item(nWhich, sal::static_int_cast<sal_uInt16>(GetMetric()))); |
567 | 0 | break; |
568 | 0 | case SID_AUTOSPELL_CHECK: |
569 | 0 | rSet.Put( SfxBoolItem( nWhich, pTabViewShell->IsAutoSpell()) ); |
570 | 0 | break; |
571 | 0 | case SID_ATTR_LANGUAGE: |
572 | 0 | case ATTR_CJK_FONT_LANGUAGE: // WID for SID_ATTR_CHAR_CJK_LANGUAGE |
573 | 0 | case ATTR_CTL_FONT_LANGUAGE: // WID for SID_ATTR_CHAR_CTL_LANGUAGE |
574 | 0 | { |
575 | 0 | LanguageType eLatin, eCjk, eCtl; |
576 | 0 | pDocSh->GetDocument().GetLanguage( eLatin, eCjk, eCtl ); |
577 | 0 | LanguageType eLang = ( nWhich == ATTR_CJK_FONT_LANGUAGE ) ? eCjk : |
578 | 0 | ( ( nWhich == ATTR_CTL_FONT_LANGUAGE ) ? eCtl : eLatin ); |
579 | 0 | rSet.Put( SvxLanguageItem( eLang, nWhich ) ); |
580 | 0 | } |
581 | 0 | break; |
582 | 0 | } |
583 | 0 | } |
584 | 0 | } |
585 | | |
586 | | void ScModule::HideDisabledSlots( SfxItemSet& rSet ) |
587 | 0 | { |
588 | 0 | if( SfxViewFrame* pViewFrm = SfxViewFrame::Current() ) |
589 | 0 | { |
590 | 0 | SfxBindings& rBindings = pViewFrm->GetBindings(); |
591 | 0 | SfxWhichIter aIter( rSet ); |
592 | 0 | for( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich != 0; nWhich = aIter.NextWhich() ) |
593 | 0 | { |
594 | 0 | ScViewUtil::HideDisabledSlot( rSet, rBindings, nWhich ); |
595 | | // always disable the slots |
596 | 0 | rSet.DisableItem( nWhich ); |
597 | 0 | } |
598 | 0 | } |
599 | 0 | } |
600 | | |
601 | | void ScModule::ResetDragObject() |
602 | 11 | { |
603 | 11 | if (comphelper::LibreOfficeKit::isActive()) |
604 | 0 | { |
605 | 0 | ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); |
606 | 0 | if (pViewShell) |
607 | 0 | pViewShell->ResetDragObject(); |
608 | 0 | } |
609 | 11 | else |
610 | 11 | { |
611 | 11 | m_pDragData->pCellTransfer = nullptr; |
612 | 11 | m_pDragData->pDrawTransfer = nullptr; |
613 | 11 | m_pDragData->pJumpLocalDoc = nullptr; |
614 | 11 | m_pDragData->aLinkDoc.clear(); |
615 | 11 | m_pDragData->aLinkTable.clear(); |
616 | 11 | m_pDragData->aLinkArea.clear(); |
617 | 11 | m_pDragData->aJumpTarget.clear(); |
618 | 11 | m_pDragData->aJumpText.clear(); |
619 | 11 | } |
620 | 11 | } |
621 | | |
622 | | const ScDragData* ScModule::GetDragData() const |
623 | 0 | { |
624 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
625 | 0 | { |
626 | 0 | ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); |
627 | 0 | return pViewShell ? &pViewShell->GetDragData() : nullptr; |
628 | 0 | } |
629 | | |
630 | 0 | return m_pDragData.get(); |
631 | 0 | } |
632 | | |
633 | | void ScModule::SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj ) |
634 | 0 | { |
635 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
636 | 0 | { |
637 | 0 | ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); |
638 | 0 | if (pViewShell) |
639 | 0 | pViewShell->SetDragObject(pCellObj, pDrawObj); |
640 | 0 | } |
641 | 0 | else |
642 | 0 | { |
643 | 0 | ResetDragObject(); |
644 | 0 | m_pDragData->pCellTransfer = pCellObj; |
645 | 0 | m_pDragData->pDrawTransfer = pDrawObj; |
646 | 0 | } |
647 | 0 | } |
648 | | |
649 | | void ScModule::SetDragLink( |
650 | | const OUString& rDoc, const OUString& rTab, const OUString& rArea ) |
651 | 0 | { |
652 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
653 | 0 | { |
654 | 0 | ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); |
655 | 0 | if (pViewShell) |
656 | 0 | pViewShell->SetDragLink(rDoc, rTab, rArea); |
657 | 0 | } |
658 | 0 | else |
659 | 0 | { |
660 | 0 | ResetDragObject(); |
661 | 0 | m_pDragData->aLinkDoc = rDoc; |
662 | 0 | m_pDragData->aLinkTable = rTab; |
663 | 0 | m_pDragData->aLinkArea = rArea; |
664 | 0 | } |
665 | 0 | } |
666 | | |
667 | | void ScModule::SetDragJump( |
668 | | ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText ) |
669 | 0 | { |
670 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
671 | 0 | { |
672 | 0 | ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); |
673 | 0 | if (pViewShell) |
674 | 0 | pViewShell->SetDragJump(pLocalDoc, rTarget, rText); |
675 | 0 | } |
676 | 0 | else |
677 | 0 | { |
678 | 0 | ResetDragObject(); |
679 | |
|
680 | 0 | m_pDragData->pJumpLocalDoc = pLocalDoc; |
681 | 0 | m_pDragData->aJumpTarget = rTarget; |
682 | 0 | m_pDragData->aJumpText = rText; |
683 | 0 | } |
684 | 0 | } |
685 | | |
686 | | ScDocument* ScModule::GetClipDoc() |
687 | 6.59M | { |
688 | | // called from document |
689 | 6.59M | SfxViewFrame* pViewFrame = nullptr; |
690 | 6.59M | ScTabViewShell* pViewShell = nullptr; |
691 | 6.59M | css::uno::Reference<css::datatransfer::XTransferable2> xTransferable; |
692 | | |
693 | 6.59M | if ((pViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()))) |
694 | 0 | xTransferable.set(ScTabViewShell::GetClipData(pViewShell->GetViewData().GetActiveWin())); |
695 | 6.59M | else if ((pViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::GetFirst()))) |
696 | 0 | xTransferable.set(ScTabViewShell::GetClipData(pViewShell->GetViewData().GetActiveWin())); |
697 | 6.59M | else if ((pViewFrame = SfxViewFrame::GetFirst())) |
698 | 0 | { |
699 | 0 | css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard = |
700 | 0 | pViewFrame->GetWindow().GetClipboard(); |
701 | 0 | xTransferable.set(xClipboard.is() ? xClipboard->getContents() : nullptr, css::uno::UNO_QUERY); |
702 | 0 | } |
703 | | |
704 | 6.59M | const ScTransferObj* pObj = ScTransferObj::GetOwnClipboard(xTransferable); |
705 | 6.59M | if (pObj) |
706 | 0 | { |
707 | 0 | ScDocument* pDoc = pObj->GetDocument(); |
708 | 0 | assert((!pDoc || pDoc->IsClipboard()) && "Document is not clipboard, how can that be?"); |
709 | 0 | return pDoc; |
710 | 0 | } |
711 | | |
712 | 6.59M | return nullptr; |
713 | 6.59M | } |
714 | | |
715 | | void ScModule::SetSelectionTransfer( ScSelectionTransferObj* pNew ) |
716 | 0 | { |
717 | 0 | m_pSelTransfer = pNew; |
718 | 0 | } |
719 | | |
720 | | void ScModule::SetViewOptions( const ScViewOptions& rOpt ) |
721 | 0 | { |
722 | 0 | if ( !m_pViewCfg ) |
723 | 0 | m_pViewCfg.reset(new ScViewCfg); |
724 | |
|
725 | 0 | m_pViewCfg->SetOptions( rOpt ); |
726 | 0 | } |
727 | | |
728 | | const ScViewOptions& ScModule::GetViewOptions() |
729 | 69.1k | { |
730 | 69.1k | if ( !m_pViewCfg ) |
731 | 5 | m_pViewCfg.reset( new ScViewCfg ); |
732 | | |
733 | 69.1k | return *m_pViewCfg; |
734 | 69.1k | } |
735 | | |
736 | | void ScModule::SetDocOptions( const ScDocOptions& rOpt ) |
737 | 0 | { |
738 | 0 | if ( !m_pDocCfg ) |
739 | 0 | m_pDocCfg.reset( new ScDocCfg ); |
740 | |
|
741 | 0 | m_pDocCfg->SetOptions( rOpt ); |
742 | 0 | } |
743 | | |
744 | | const ScDocOptions& ScModule::GetDocOptions() |
745 | 69.1k | { |
746 | 69.1k | if ( !m_pDocCfg ) |
747 | 5 | m_pDocCfg.reset( new ScDocCfg ); |
748 | | |
749 | 69.1k | return *m_pDocCfg; |
750 | 69.1k | } |
751 | | |
752 | | void ScModule::InsertEntryToLRUList(sal_uInt16 nFIndex) |
753 | 0 | { |
754 | 0 | if(nFIndex == 0) |
755 | 0 | return; |
756 | | |
757 | 0 | const ScAppOptions& rAppOpt = GetAppOptions(); |
758 | 0 | sal_uInt16 nLRUFuncCount = std::min( rAppOpt.GetLRUFuncListCount(), sal_uInt16(LRU_MAX) ); |
759 | 0 | sal_uInt16* pLRUListIds = rAppOpt.GetLRUFuncList(); |
760 | |
|
761 | 0 | sal_uInt16 aIdxList[LRU_MAX]; |
762 | 0 | sal_uInt16 n = 0; |
763 | 0 | bool bFound = false; |
764 | |
|
765 | 0 | while ((n < LRU_MAX) && n<nLRUFuncCount) // Iterate through old list |
766 | 0 | { |
767 | 0 | if (!bFound && (pLRUListIds[n]== nFIndex)) |
768 | 0 | bFound = true; // First hit! |
769 | 0 | else if (bFound) |
770 | 0 | aIdxList[n ] = pLRUListIds[n]; // Copy after hit |
771 | 0 | else if ((n+1) < LRU_MAX) |
772 | 0 | aIdxList[n+1] = pLRUListIds[n]; // Move before hit |
773 | 0 | n++; |
774 | 0 | } |
775 | 0 | if (!bFound && (n < LRU_MAX)) // Entry not found? |
776 | 0 | n++; // One more |
777 | 0 | aIdxList[0] = nFIndex; // Current on Top |
778 | |
|
779 | 0 | ScAppOptions aNewOpts(rAppOpt); // Let App know |
780 | 0 | aNewOpts.SetLRUFuncList(aIdxList, n); |
781 | 0 | SetAppOptions(aNewOpts); |
782 | 0 | } |
783 | | |
784 | | void ScModule::InsertOrEraseFavouritesListEntry(sal_uInt16 nFIndex, bool bInsert) |
785 | 0 | { |
786 | 0 | const ScAppOptions& rAppOpt = GetAppOptions(); |
787 | 0 | std::unordered_set<sal_uInt16> sFavouriteFunctions = rAppOpt.GetFavouritesList(); |
788 | |
|
789 | 0 | if (bInsert) |
790 | 0 | sFavouriteFunctions.insert(nFIndex); |
791 | 0 | else |
792 | 0 | sFavouriteFunctions.erase(nFIndex); |
793 | |
|
794 | 0 | ScAppOptions aNewOpts(rAppOpt); |
795 | 0 | aNewOpts.SetFavouritesList(sFavouriteFunctions); |
796 | 0 | SetAppOptions(aNewOpts); |
797 | 0 | } |
798 | | |
799 | | void ScModule::SetAppOptions( const ScAppOptions& rOpt ) |
800 | 0 | { |
801 | 0 | if ( !m_pAppCfg ) |
802 | 0 | m_pAppCfg.reset( new ScAppCfg ); |
803 | |
|
804 | 0 | m_pAppCfg->SetOptions( rOpt ); |
805 | 0 | } |
806 | | |
807 | | void global_InitAppOptions() |
808 | 9 | { |
809 | 9 | ScModule::get()->GetAppOptions(); |
810 | 9 | } |
811 | | |
812 | | const ScAppOptions& ScModule::GetAppOptions() |
813 | 20 | { |
814 | 20 | if ( !m_pAppCfg ) |
815 | 11 | m_pAppCfg.reset( new ScAppCfg ); |
816 | | |
817 | 20 | return m_pAppCfg->GetOptions(); |
818 | 20 | } |
819 | | |
820 | | void ScModule::SetDefaultsOptions( const ScDefaultsOptions& rOpt ) |
821 | 0 | { |
822 | 0 | if ( !m_pDefaultsCfg ) |
823 | 0 | m_pDefaultsCfg.reset( new ScDefaultsCfg ); |
824 | |
|
825 | 0 | m_pDefaultsCfg->SetOptions( rOpt ); |
826 | 0 | } |
827 | | |
828 | | const ScDefaultsOptions& ScModule::GetDefaultsOptions() |
829 | 352k | { |
830 | 352k | if ( !m_pDefaultsCfg ) |
831 | 11 | m_pDefaultsCfg.reset( new ScDefaultsCfg ); |
832 | | |
833 | 352k | return *m_pDefaultsCfg; |
834 | 352k | } |
835 | | |
836 | | void ScModule::SetFormulaOptions( const ScFormulaOptions& rOpt ) |
837 | 0 | { |
838 | 0 | if ( !m_pFormulaCfg ) |
839 | 0 | m_pFormulaCfg.reset( new ScFormulaCfg ); |
840 | |
|
841 | 0 | m_pFormulaCfg->SetOptions( rOpt ); |
842 | 0 | } |
843 | | |
844 | | const ScFormulaOptions& ScModule::GetFormulaOptions() |
845 | 138k | { |
846 | 138k | if ( !m_pFormulaCfg ) |
847 | 5 | m_pFormulaCfg.reset( new ScFormulaCfg ); |
848 | | |
849 | 138k | return *m_pFormulaCfg; |
850 | 138k | } |
851 | | |
852 | | void ScModule::SetInputOptions( const ScInputOptions& rOpt ) |
853 | 0 | { |
854 | 0 | if ( !m_pInputCfg ) |
855 | 0 | m_pInputCfg.reset( new ScInputCfg ); |
856 | |
|
857 | 0 | m_pInputCfg->SetOptions( rOpt ); |
858 | 0 | } |
859 | | |
860 | | const ScInputOptions& ScModule::GetInputOptions() |
861 | 218k | { |
862 | 218k | if ( !m_pInputCfg ) |
863 | 6 | m_pInputCfg.reset( new ScInputCfg ); |
864 | | |
865 | 218k | return m_pInputCfg->GetOptions(); |
866 | 218k | } |
867 | | |
868 | | void ScModule::SetPrintOptions( const ScPrintOptions& rOpt ) |
869 | 0 | { |
870 | 0 | if ( !m_pPrintCfg ) |
871 | 0 | m_pPrintCfg.reset( new ScPrintCfg ); |
872 | |
|
873 | 0 | m_pPrintCfg->SetOptions( rOpt ); |
874 | 0 | } |
875 | | |
876 | | const ScPrintOptions& ScModule::GetPrintOptions() |
877 | 91.5k | { |
878 | 91.5k | if ( !m_pPrintCfg ) |
879 | 3 | m_pPrintCfg.reset( new ScPrintCfg ); |
880 | | |
881 | 91.5k | return m_pPrintCfg->GetOptions(); |
882 | 91.5k | } |
883 | | |
884 | | ScNavipiCfg& ScModule::GetNavipiCfg() |
885 | 0 | { |
886 | 0 | if ( !m_pNavipiCfg ) |
887 | 0 | m_pNavipiCfg.reset( new ScNavipiCfg ); |
888 | |
|
889 | 0 | return *m_pNavipiCfg; |
890 | 0 | } |
891 | | |
892 | | ScAddInCfg& ScModule::GetAddInCfg() |
893 | 8 | { |
894 | 8 | if ( !m_pAddInCfg ) |
895 | 8 | m_pAddInCfg.reset( new ScAddInCfg ); |
896 | | |
897 | 8 | return *m_pAddInCfg; |
898 | 8 | } |
899 | | |
900 | | svtools::ColorConfig& ScModule::GetColorConfig() |
901 | 964k | { |
902 | 964k | if ( !m_pColorConfig ) |
903 | 11 | { |
904 | 11 | m_pColorConfig.reset( new svtools::ColorConfig ); |
905 | 11 | m_pColorConfig->AddListener(this); |
906 | 11 | } |
907 | | |
908 | 964k | return *m_pColorConfig; |
909 | 964k | } |
910 | | |
911 | | bool ScModule::IsLOKViewInDarkMode() |
912 | 0 | { |
913 | 0 | SfxViewShell* pKitSh = comphelper::LibreOfficeKit::isActive() ? SfxViewShell::Current() : nullptr; |
914 | 0 | if( pKitSh ) |
915 | 0 | { |
916 | 0 | Color aDocColor = pKitSh->GetColorConfigColor(svtools::DOCCOLOR); |
917 | 0 | if( aDocColor.IsDark() ) |
918 | 0 | return true; |
919 | 0 | } |
920 | 0 | return false; |
921 | 0 | } |
922 | | |
923 | | SvtUserOptions& ScModule::GetUserOptions() |
924 | 75 | { |
925 | 75 | if( !m_pUserOptions ) |
926 | 1 | { |
927 | 1 | m_pUserOptions.reset( new SvtUserOptions ); |
928 | 1 | } |
929 | 75 | return *m_pUserOptions; |
930 | 75 | } |
931 | | |
932 | | FieldUnit ScModule::GetMetric() |
933 | 0 | { |
934 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
935 | 0 | return SfxModule::GetFieldUnit(); |
936 | 0 | return GetAppOptions().GetAppMetric(); |
937 | 0 | } |
938 | | |
939 | | LanguageType ScModule::GetOptDigitLanguage() |
940 | 17.1k | { |
941 | 17.1k | SvtCTLOptions::TextNumerals eNumerals = SvtCTLOptions::GetCTLTextNumerals(); |
942 | 17.1k | return ( eNumerals == SvtCTLOptions::NUMERALS_ARABIC ) ? LANGUAGE_ENGLISH_US : |
943 | 17.1k | ( eNumerals == SvtCTLOptions::NUMERALS_HINDI) ? LANGUAGE_ARABIC_SAUDI_ARABIA : |
944 | 0 | LANGUAGE_SYSTEM; |
945 | 17.1k | } |
946 | | |
947 | | /** |
948 | | * Options |
949 | | * |
950 | | * Items from Calc options dialog and SID_AUTOSPELL_CHECK |
951 | | */ |
952 | | void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) |
953 | 0 | { |
954 | 0 | bool bOldAutoSpell = GetAutoSpellProperty(); |
955 | 0 | LanguageType nOldSpellLang, nOldCjkLang, nOldCtlLang; |
956 | 0 | GetSpellSettings( nOldSpellLang, nOldCjkLang, nOldCtlLang ); |
957 | |
|
958 | 0 | if (!m_pAppCfg) |
959 | 0 | GetAppOptions(); |
960 | 0 | OSL_ENSURE( m_pAppCfg, "AppOptions not initialised :-(" ); |
961 | |
|
962 | 0 | if (!m_pInputCfg) |
963 | 0 | GetInputOptions(); |
964 | 0 | OSL_ENSURE( m_pInputCfg, "InputOptions not initialised :-(" ); |
965 | |
|
966 | 0 | SfxViewFrame* pViewFrm = SfxViewFrame::Current(); |
967 | 0 | SfxBindings* pBindings = pViewFrm ? &pViewFrm->GetBindings() : nullptr; |
968 | |
|
969 | 0 | ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); |
970 | 0 | ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() ); |
971 | 0 | ScDocument* pDoc = pDocSh ? &pDocSh->GetDocument() : nullptr; |
972 | 0 | bool bRepaint = false; |
973 | 0 | bool bUpdateMarks = false; |
974 | 0 | bool bUpdateRefDev = false; |
975 | 0 | bool bCalcAll = false; |
976 | 0 | bool bSaveAppOptions = false; |
977 | 0 | bool bSaveInputOptions = false; |
978 | 0 | bool bCompileErrorCells = false; |
979 | | |
980 | | // SfxGetpApp()->SetOptions( rOptSet ); |
981 | |
|
982 | 0 | ScAppOptions aAppOptions = m_pAppCfg->GetOptions(); |
983 | | |
984 | | // No more linguistics |
985 | 0 | if (const SfxUInt16Item* pItem = rOptSet.GetItemIfSet(SID_ATTR_METRIC)) |
986 | 0 | { |
987 | 0 | PutItem( *pItem ); |
988 | 0 | aAppOptions.SetAppMetric( static_cast<FieldUnit>(pItem->GetValue()) ); |
989 | 0 | bSaveAppOptions = true; |
990 | 0 | } |
991 | |
|
992 | 0 | if (const ScUserListItem* pItem = rOptSet.GetItemIfSet(SCITEM_USERLIST)) |
993 | 0 | { |
994 | 0 | ScGlobal::SetUserList( pItem->GetUserList() ); |
995 | 0 | bSaveAppOptions = true; |
996 | 0 | } |
997 | |
|
998 | 0 | if (const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_OPT_SYNCZOOM)) |
999 | 0 | { |
1000 | 0 | aAppOptions.SetSynchronizeZoom( pItem->GetValue() ); |
1001 | 0 | bSaveAppOptions = true; |
1002 | 0 | } |
1003 | |
|
1004 | 0 | if (const SfxUInt16Item* pItem = rOptSet.GetItemIfSet(SID_SC_OPT_KEY_BINDING_COMPAT)) |
1005 | 0 | { |
1006 | 0 | sal_uInt16 nVal = pItem->GetValue(); |
1007 | 0 | ScOptionsUtil::KeyBindingType eOld = aAppOptions.GetKeyBindingType(); |
1008 | 0 | ScOptionsUtil::KeyBindingType eNew = static_cast<ScOptionsUtil::KeyBindingType>(nVal); |
1009 | 0 | if (eOld != eNew) |
1010 | 0 | { |
1011 | 0 | aAppOptions.SetKeyBindingType(eNew); |
1012 | 0 | bSaveAppOptions = true; |
1013 | 0 | ScDocShell::ResetKeyBindings(eNew); |
1014 | 0 | } |
1015 | 0 | } |
1016 | |
|
1017 | 0 | if (const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_OPT_LINKS)) |
1018 | 0 | { |
1019 | 0 | aAppOptions.SetLinksInsertedLikeMSExcel(pItem->GetValue()); |
1020 | 0 | bSaveAppOptions = true; |
1021 | 0 | } |
1022 | | |
1023 | | // DefaultsOptions |
1024 | 0 | if (const ScTpDefaultsItem* pItem = rOptSet.GetItemIfSet(SID_SCDEFAULTSOPTIONS)) |
1025 | 0 | { |
1026 | 0 | const ScDefaultsOptions& rOpt = pItem->GetDefaultsOptions(); |
1027 | 0 | SetDefaultsOptions( rOpt ); |
1028 | 0 | } |
1029 | | |
1030 | | // FormulaOptions |
1031 | 0 | if (const ScTpFormulaItem* pItem = rOptSet.GetItemIfSet(SID_SCFORMULAOPTIONS)) |
1032 | 0 | { |
1033 | 0 | const ScFormulaOptions& rOpt = pItem->GetFormulaOptions(); |
1034 | |
|
1035 | 0 | if (!m_pFormulaCfg || (*m_pFormulaCfg != rOpt)) |
1036 | | // Formula options have changed. Repaint the column headers. |
1037 | 0 | bRepaint = true; |
1038 | |
|
1039 | 0 | if (m_pFormulaCfg && m_pFormulaCfg->GetUseEnglishFuncName() != rOpt.GetUseEnglishFuncName()) |
1040 | 0 | { |
1041 | | // Re-compile formula cells with error as the error may have been |
1042 | | // caused by unresolved function names. |
1043 | 0 | bCompileErrorCells = true; |
1044 | 0 | } |
1045 | | |
1046 | | // Recalc for interpreter options changes. |
1047 | 0 | if (m_pFormulaCfg && m_pFormulaCfg->GetCalcConfig() != rOpt.GetCalcConfig()) |
1048 | 0 | bCalcAll = true; |
1049 | |
|
1050 | 0 | if ( pDocSh ) |
1051 | 0 | { |
1052 | 0 | pDocSh->SetFormulaOptions( rOpt ); |
1053 | 0 | pDocSh->SetDocumentModified(); |
1054 | 0 | } |
1055 | | |
1056 | | // ScDocShell::SetFormulaOptions() may check for changed settings, so |
1057 | | // set the new options here after that has been called. |
1058 | 0 | if (!bCalcAll || rOpt.GetWriteCalcConfig()) |
1059 | 0 | { |
1060 | | // CalcConfig is new, didn't change or is global, simply set all. |
1061 | 0 | SetFormulaOptions( rOpt ); |
1062 | 0 | } |
1063 | 0 | else |
1064 | 0 | { |
1065 | | // If "only for current document" was checked, reset those affected |
1066 | | // by that setting to previous values. |
1067 | 0 | ScFormulaOptions aNewOpt( rOpt); |
1068 | 0 | aNewOpt.GetCalcConfig().MergeDocumentSpecific( m_pFormulaCfg->GetCalcConfig()); |
1069 | 0 | SetFormulaOptions( aNewOpt); |
1070 | 0 | } |
1071 | 0 | } |
1072 | | |
1073 | | // ViewOptions |
1074 | 0 | if (const ScTpViewItem* pItem = rOptSet.GetItemIfSet(SID_SCVIEWOPTIONS)) |
1075 | 0 | { |
1076 | 0 | const ScViewOptions& rNewOpt = pItem->GetViewOptions(); |
1077 | |
|
1078 | 0 | if ( pViewSh ) |
1079 | 0 | { |
1080 | 0 | ScViewData& rViewData = pViewSh->GetViewData(); |
1081 | 0 | const ScViewOptions& rOldOpt = rViewData.GetOptions(); |
1082 | |
|
1083 | 0 | bool bAnchorList = rOldOpt.GetOption(sc::ViewOption::ANCHOR) != |
1084 | 0 | rNewOpt.GetOption(sc::ViewOption::ANCHOR); |
1085 | |
|
1086 | 0 | if ( rOldOpt != rNewOpt ) |
1087 | 0 | { |
1088 | 0 | rViewData.SetOptions( rNewOpt ); // Changes rOldOpt |
1089 | 0 | rViewData.GetDocument().SetViewOptions( rNewOpt ); |
1090 | 0 | if (pDocSh) |
1091 | 0 | pDocSh->SetDocumentModified(); |
1092 | 0 | bRepaint = true; |
1093 | 0 | } |
1094 | 0 | if ( bAnchorList ) |
1095 | 0 | pViewSh->UpdateAnchorHandles(); |
1096 | 0 | } |
1097 | 0 | SetViewOptions( rNewOpt ); |
1098 | 0 | if (pBindings) |
1099 | 0 | { |
1100 | 0 | pBindings->Invalidate(SID_HELPLINES_MOVE); |
1101 | 0 | } |
1102 | 0 | } |
1103 | | |
1104 | | // GridOptions |
1105 | | // Evaluate after ViewOptions, as GridOptions is a member of ViewOptions |
1106 | 0 | if ( const SvxGridItem* pItem = rOptSet.GetItemIfSet(SID_ATTR_GRID_OPTIONS) ) |
1107 | 0 | { |
1108 | 0 | ScGridOptions aNewGridOpt( *pItem ); |
1109 | |
|
1110 | 0 | if ( pViewSh ) |
1111 | 0 | { |
1112 | 0 | ScViewData& rViewData = pViewSh->GetViewData(); |
1113 | 0 | ScViewOptions aNewViewOpt( rViewData.GetOptions() ); |
1114 | 0 | const ScGridOptions& rOldGridOpt = aNewViewOpt.GetGridOptions(); |
1115 | |
|
1116 | 0 | if ( rOldGridOpt != aNewGridOpt ) |
1117 | 0 | { |
1118 | 0 | aNewViewOpt.SetGridOptions( aNewGridOpt ); |
1119 | 0 | rViewData.SetOptions( aNewViewOpt ); |
1120 | 0 | rViewData.GetDocument().SetViewOptions( aNewViewOpt ); |
1121 | 0 | if (pDocSh) |
1122 | 0 | pDocSh->SetDocumentModified(); |
1123 | 0 | bRepaint = true; |
1124 | 0 | } |
1125 | 0 | } |
1126 | 0 | ScViewOptions aNewViewOpt ( GetViewOptions() ); |
1127 | 0 | aNewViewOpt.SetGridOptions( aNewGridOpt ); |
1128 | 0 | SetViewOptions( aNewViewOpt ); |
1129 | 0 | if (pBindings) |
1130 | 0 | { |
1131 | 0 | pBindings->Invalidate(SID_GRID_VISIBLE); |
1132 | 0 | pBindings->Invalidate(SID_GRID_USE); |
1133 | 0 | } |
1134 | 0 | } |
1135 | | |
1136 | | // DocOptions |
1137 | 0 | if ( const ScTpCalcItem* pItem = rOptSet.GetItemIfSet(SID_SCDOCOPTIONS) ) |
1138 | 0 | { |
1139 | 0 | const ScDocOptions& rNewOpt = pItem->GetDocOptions(); |
1140 | |
|
1141 | 0 | if ( pDoc ) |
1142 | 0 | { |
1143 | 0 | const ScDocOptions& rOldOpt = pDoc->GetDocOptions(); |
1144 | |
|
1145 | 0 | bRepaint = ( bRepaint || ( rOldOpt != rNewOpt ) ); |
1146 | 0 | bCalcAll = bRepaint && |
1147 | 0 | ( rOldOpt.IsIter() != rNewOpt.IsIter() |
1148 | 0 | || rOldOpt.GetIterCount() != rNewOpt.GetIterCount() |
1149 | 0 | || rOldOpt.GetIterEps() != rNewOpt.GetIterEps() |
1150 | 0 | || rOldOpt.IsIgnoreCase() != rNewOpt.IsIgnoreCase() |
1151 | 0 | || rOldOpt.IsCalcAsShown() != rNewOpt.IsCalcAsShown() |
1152 | 0 | || (rNewOpt.IsCalcAsShown() && |
1153 | 0 | rOldOpt.GetStdPrecision() != rNewOpt.GetStdPrecision()) |
1154 | 0 | || rOldOpt.IsMatchWholeCell() != rNewOpt.IsMatchWholeCell() |
1155 | 0 | || rOldOpt.GetYear2000() != rNewOpt.GetYear2000() |
1156 | 0 | || rOldOpt.IsFormulaRegexEnabled() != rNewOpt.IsFormulaRegexEnabled() |
1157 | 0 | || rOldOpt.IsFormulaWildcardsEnabled() != rNewOpt.IsFormulaWildcardsEnabled() |
1158 | 0 | ); |
1159 | 0 | pDoc->SetDocOptions( rNewOpt ); |
1160 | 0 | pDocSh->SetDocumentModified(); |
1161 | 0 | } |
1162 | 0 | SetDocOptions( rNewOpt ); |
1163 | 0 | } |
1164 | | |
1165 | | // Set TabDistance after the actual DocOptions |
1166 | 0 | if ( const SfxUInt16Item* pItem = rOptSet.GetItemIfSet(SID_ATTR_DEFTABSTOP) ) |
1167 | 0 | { |
1168 | 0 | sal_uInt16 nTabDist = pItem->GetValue(); |
1169 | 0 | ScDocOptions aOpt(GetDocOptions()); |
1170 | 0 | aOpt.SetTabDistance(nTabDist); |
1171 | 0 | SetDocOptions( aOpt ); |
1172 | |
|
1173 | 0 | if ( pDoc ) |
1174 | 0 | { |
1175 | 0 | ScDocOptions aDocOpt(pDoc->GetDocOptions()); |
1176 | 0 | aDocOpt.SetTabDistance(nTabDist); |
1177 | 0 | pDoc->SetDocOptions( aDocOpt ); |
1178 | 0 | pDocSh->SetDocumentModified(); |
1179 | 0 | if(pDoc->GetDrawLayer()) |
1180 | 0 | pDoc->GetDrawLayer()->SetDefaultTabulator(nTabDist); |
1181 | 0 | } |
1182 | 0 | } |
1183 | | |
1184 | | // AutoSpell after the DocOptions (due to being a member) |
1185 | 0 | if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_AUTOSPELL_CHECK) ) // At DocOptions |
1186 | 0 | { |
1187 | 0 | bool bDoAutoSpell = pItem->GetValue(); |
1188 | |
|
1189 | 0 | if (pViewSh) |
1190 | 0 | { |
1191 | 0 | if (pViewSh->IsAutoSpell() != bDoAutoSpell) |
1192 | 0 | { |
1193 | 0 | pViewSh->EnableAutoSpell(bDoAutoSpell); |
1194 | |
|
1195 | 0 | bRepaint = true; // Because HideAutoSpell might be invalid |
1196 | | //TODO: Paint all Views? |
1197 | 0 | } |
1198 | 0 | } |
1199 | |
|
1200 | 0 | if ( bOldAutoSpell != bDoAutoSpell ) |
1201 | 0 | SetAutoSpellProperty( bDoAutoSpell ); |
1202 | 0 | if ( pDocSh ) |
1203 | 0 | pDocSh->PostPaintGridAll(); // Due to marks |
1204 | 0 | ScInputHandler* pInputHandler = GetInputHdl(); |
1205 | 0 | if ( pInputHandler ) |
1206 | 0 | pInputHandler->UpdateSpellSettings(); // EditEngine flags |
1207 | 0 | if ( pViewSh ) |
1208 | 0 | pViewSh->UpdateDrawTextOutliner(); // EditEngine flags |
1209 | |
|
1210 | 0 | if (pBindings) |
1211 | 0 | pBindings->Invalidate( SID_AUTOSPELL_CHECK ); |
1212 | 0 | } |
1213 | | |
1214 | | // InputOptions |
1215 | 0 | ScInputOptions aInputOptions = m_pInputCfg->GetOptions(); |
1216 | 0 | if ( const SfxUInt16Item* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_SELECTIONPOS) ) |
1217 | 0 | { |
1218 | 0 | aInputOptions.SetMoveDir( pItem->GetValue() ); |
1219 | 0 | bSaveInputOptions = true; |
1220 | 0 | } |
1221 | 0 | if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_SELECTION) ) |
1222 | 0 | { |
1223 | 0 | aInputOptions.SetMoveSelection( pItem->GetValue() ); |
1224 | 0 | bSaveInputOptions = true; |
1225 | 0 | } |
1226 | 0 | if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_EDITMODE) ) |
1227 | 0 | { |
1228 | 0 | aInputOptions.SetEnterEdit( pItem->GetValue() ); |
1229 | 0 | bSaveInputOptions = true; |
1230 | 0 | } |
1231 | 0 | if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_FMT_EXPAND) ) |
1232 | 0 | { |
1233 | 0 | aInputOptions.SetExtendFormat( pItem->GetValue() ); |
1234 | 0 | bSaveInputOptions = true; |
1235 | 0 | } |
1236 | 0 | if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_RANGEFINDER) ) |
1237 | 0 | { |
1238 | 0 | aInputOptions.SetRangeFinder( pItem->GetValue() ); |
1239 | 0 | bSaveInputOptions = true; |
1240 | 0 | } |
1241 | 0 | if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_REF_EXPAND) ) |
1242 | 0 | { |
1243 | 0 | aInputOptions.SetExpandRefs( pItem->GetValue() ); |
1244 | 0 | bSaveInputOptions = true; |
1245 | 0 | } |
1246 | 0 | if (const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_OPT_SORT_REF_UPDATE)) |
1247 | 0 | { |
1248 | 0 | aInputOptions.SetSortRefUpdate( pItem->GetValue()); |
1249 | 0 | bSaveInputOptions = true; |
1250 | 0 | } |
1251 | |
|
1252 | 0 | if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_MARK_HEADER) ) |
1253 | 0 | { |
1254 | 0 | aInputOptions.SetMarkHeader( pItem->GetValue() ); |
1255 | 0 | bSaveInputOptions = true; |
1256 | 0 | bUpdateMarks = true; |
1257 | 0 | } |
1258 | 0 | if ( const SfxBoolItem* pItem = rOptSet.GetItemIfSet(SID_SC_INPUT_TEXTWYSIWYG) ) |
1259 | 0 | { |
1260 | 0 | bool bNew = pItem->GetValue(); |
1261 | 0 | if ( bNew != aInputOptions.GetTextWysiwyg() ) |
1262 | 0 | { |
1263 | 0 | aInputOptions.SetTextWysiwyg( bNew ); |
1264 | 0 | bSaveInputOptions = true; |
1265 | 0 | bUpdateRefDev = true; |
1266 | 0 | } |
1267 | 0 | } |
1268 | 0 | if( const SfxBoolItem* pItem = rOptSet.GetItemIfSet( SID_SC_INPUT_REPLCELLSWARN ) ) |
1269 | 0 | { |
1270 | 0 | aInputOptions.SetReplaceCellsWarn( pItem->GetValue() ); |
1271 | 0 | bSaveInputOptions = true; |
1272 | 0 | } |
1273 | |
|
1274 | 0 | if( const SfxBoolItem* pItem = rOptSet.GetItemIfSet( SID_SC_INPUT_LEGACY_CELL_SELECTION ) ) |
1275 | 0 | { |
1276 | 0 | aInputOptions.SetLegacyCellSelection( pItem->GetValue() ); |
1277 | 0 | bSaveInputOptions = true; |
1278 | 0 | } |
1279 | |
|
1280 | 0 | if( const SfxBoolItem* pItem = rOptSet.GetItemIfSet( SID_SC_INPUT_ENTER_PASTE_MODE ) ) |
1281 | 0 | { |
1282 | 0 | aInputOptions.SetEnterPasteMode( pItem->GetValue() ); |
1283 | 0 | bSaveInputOptions = true; |
1284 | 0 | } |
1285 | |
|
1286 | 0 | if( const SfxBoolItem* pItem = rOptSet.GetItemIfSet( SID_SC_INPUT_WARNACTIVESHEET ) ) |
1287 | 0 | { |
1288 | 0 | aInputOptions.SetWarnActiveSheet( pItem->GetValue() ); |
1289 | 0 | bSaveInputOptions = true; |
1290 | 0 | } |
1291 | | |
1292 | | // PrintOptions |
1293 | 0 | if ( const ScTpPrintItem* pItem = rOptSet.GetItemIfSet(SID_SCPRINTOPTIONS) ) |
1294 | 0 | { |
1295 | 0 | const ScPrintOptions& rNewOpt = pItem->GetPrintOptions(); |
1296 | 0 | SetPrintOptions( rNewOpt ); |
1297 | | |
1298 | | // broadcast causes all previews to recalc page numbers |
1299 | 0 | SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScPrintOptions ) ); |
1300 | 0 | } |
1301 | |
|
1302 | 0 | if ( bSaveAppOptions ) |
1303 | 0 | m_pAppCfg->SetOptions(aAppOptions); |
1304 | |
|
1305 | 0 | if ( bSaveInputOptions ) |
1306 | 0 | m_pInputCfg->SetOptions(aInputOptions); |
1307 | | |
1308 | | // Kick off recalculation? |
1309 | 0 | if (pDoc && bCompileErrorCells) |
1310 | 0 | { |
1311 | | // Re-compile cells with name error, and recalc if at least one cell |
1312 | | // has been re-compiled. In the future we may want to find a way to |
1313 | | // recalc only those that are affected. |
1314 | 0 | if (pDoc->CompileErrorCells(FormulaError::NoName)) |
1315 | 0 | bCalcAll = true; |
1316 | 0 | } |
1317 | |
|
1318 | 0 | if ( pDoc && bCalcAll ) |
1319 | 0 | { |
1320 | 0 | weld::WaitObject aWait( ScDocShell::GetActiveDialogParent() ); |
1321 | 0 | pDoc->CalcAll(); |
1322 | 0 | if ( pViewSh ) |
1323 | 0 | pViewSh->UpdateCharts( true ); |
1324 | 0 | else |
1325 | 0 | ScDBFunc::DoUpdateCharts( ScAddress(), *pDoc, true ); |
1326 | 0 | if (pBindings) |
1327 | 0 | pBindings->Invalidate( SID_ATTR_SIZE ); //SvxPosSize StatusControl Update |
1328 | 0 | } |
1329 | |
|
1330 | 0 | if ( pViewSh && bUpdateMarks ) |
1331 | 0 | pViewSh->UpdateAutoFillMark(); |
1332 | | |
1333 | | // Repaint View? |
1334 | 0 | if ( pViewSh && bRepaint ) |
1335 | 0 | { |
1336 | 0 | pViewSh->UpdateFixPos(); |
1337 | 0 | pViewSh->PaintGrid(); |
1338 | 0 | pViewSh->PaintTop(); |
1339 | 0 | pViewSh->PaintLeft(); |
1340 | 0 | pViewSh->PaintExtras(); |
1341 | 0 | pViewSh->InvalidateBorder(); |
1342 | 0 | if (pBindings) |
1343 | 0 | { |
1344 | 0 | pBindings->Invalidate( FID_TOGGLEHEADERS ); // -> Checks in menu |
1345 | 0 | pBindings->Invalidate( FID_TOGGLESYNTAX ); |
1346 | 0 | } |
1347 | 0 | } |
1348 | | |
1349 | | // update ref device (for all documents) |
1350 | 0 | if ( !bUpdateRefDev ) |
1351 | 0 | return; |
1352 | | |
1353 | | // for all documents: recalc output factor, update row heights |
1354 | 0 | SfxObjectShell* pObjSh = SfxObjectShell::GetFirst(); |
1355 | 0 | while ( pObjSh ) |
1356 | 0 | { |
1357 | 0 | if ( auto pOneDocSh = dynamic_cast<ScDocShell *>(pObjSh) ) |
1358 | 0 | { |
1359 | 0 | pOneDocSh->CalcOutputFactor(); |
1360 | 0 | SCTAB nTabCount = pOneDocSh->GetDocument().GetTableCount(); |
1361 | 0 | for (SCTAB nTab=0; nTab<nTabCount; nTab++) |
1362 | 0 | pOneDocSh->AdjustRowHeight( 0, pDocSh->GetDocument().MaxRow(), nTab ); |
1363 | 0 | } |
1364 | 0 | pObjSh = SfxObjectShell::GetNext( *pObjSh ); |
1365 | 0 | } |
1366 | | |
1367 | | // for all (tab-) views: |
1368 | 0 | SfxViewShell* pSh = SfxViewShell::GetFirst( true, checkSfxViewShell<ScTabViewShell> ); |
1369 | 0 | while ( pSh ) |
1370 | 0 | { |
1371 | 0 | ScTabViewShell* pOneViewSh = static_cast<ScTabViewShell*>(pSh); |
1372 | | |
1373 | | // set ref-device for EditEngine |
1374 | 0 | ScInputHandler* pHdl = GetInputHdl(pOneViewSh); |
1375 | 0 | if (pHdl) |
1376 | 0 | pHdl->UpdateRefDevice(); |
1377 | | |
1378 | | // update view scale |
1379 | 0 | ScViewData& rViewData = pOneViewSh->GetViewData(); |
1380 | 0 | pOneViewSh->SetZoom( rViewData.GetZoomX(), rViewData.GetZoomY(), false ); |
1381 | | |
1382 | | // repaint |
1383 | 0 | pOneViewSh->PaintGrid(); |
1384 | 0 | pOneViewSh->PaintTop(); |
1385 | 0 | pOneViewSh->PaintLeft(); |
1386 | |
|
1387 | 0 | pSh = SfxViewShell::GetNext( *pSh, true, checkSfxViewShell<ScTabViewShell> ); |
1388 | 0 | } |
1389 | 0 | } |
1390 | | |
1391 | | /** |
1392 | | * Input-Handler |
1393 | | */ |
1394 | | ScInputHandler* ScModule::GetInputHdl( ScTabViewShell* pViewSh, bool bUseRef ) |
1395 | 0 | { |
1396 | 0 | if ( !comphelper::LibreOfficeKit::isActive() && m_pRefInputHandler && bUseRef ) |
1397 | 0 | return m_pRefInputHandler; |
1398 | | |
1399 | 0 | ScInputHandler* pHdl = nullptr; |
1400 | 0 | if ( !pViewSh ) |
1401 | 0 | { |
1402 | | // in case a UIActive embedded object has no ViewShell (UNO component) |
1403 | | // the own calc view shell will be set as current, but no handling should happen |
1404 | 0 | ScTabViewShell* pCurViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); |
1405 | 0 | if ( pCurViewSh && !pCurViewSh->GetUIActiveClient() ) |
1406 | 0 | pViewSh = pCurViewSh; |
1407 | 0 | } |
1408 | |
|
1409 | 0 | if ( pViewSh ) |
1410 | 0 | pHdl = pViewSh->GetInputHandler(); // Viewshell always has one, from now on |
1411 | | |
1412 | | // If no ViewShell passed or active, we can get NULL |
1413 | 0 | OSL_ENSURE( pHdl || !pViewSh, "GetInputHdl: no InputHandler found!" ); |
1414 | 0 | return pHdl; |
1415 | 0 | } |
1416 | | |
1417 | | void ScModule::ViewShellChanged(bool bStopEditing /*=true*/) |
1418 | 0 | { |
1419 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1420 | 0 | ScTabViewShell* pShell = ScTabViewShell::GetActiveViewShell(); |
1421 | 0 | if ( pShell && pHdl ) |
1422 | 0 | pShell->UpdateInputHandler(false, bStopEditing); |
1423 | 0 | } |
1424 | | |
1425 | | void ScModule::SetInputMode( ScInputMode eMode, const OUString* pInitText ) |
1426 | 0 | { |
1427 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1428 | 0 | if (pHdl) |
1429 | 0 | pHdl->SetMode(eMode, pInitText); |
1430 | 0 | } |
1431 | | |
1432 | | bool ScModule::IsEditMode() |
1433 | 0 | { |
1434 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1435 | 0 | return pHdl && pHdl->IsEditMode(); |
1436 | 0 | } |
1437 | | |
1438 | | bool ScModule::IsInputMode() |
1439 | 0 | { |
1440 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1441 | 0 | return pHdl && pHdl->IsInputMode(); |
1442 | 0 | } |
1443 | | |
1444 | | bool ScModule::InputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit ) |
1445 | 0 | { |
1446 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1447 | 0 | return pHdl && pHdl->KeyInput( rKEvt, bStartEdit ); |
1448 | 0 | } |
1449 | | |
1450 | | void ScModule::InputEnterHandler( ScEnterMode nBlockMode, bool bBeforeSavingInLOK ) |
1451 | 0 | { |
1452 | 0 | if ( !SfxGetpApp()->IsDowning() ) // Not when quitting the program |
1453 | 0 | { |
1454 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1455 | 0 | if (pHdl) |
1456 | 0 | pHdl->EnterHandler( nBlockMode, bBeforeSavingInLOK ); |
1457 | 0 | } |
1458 | 0 | } |
1459 | | |
1460 | | void ScModule::InputCancelHandler() |
1461 | 0 | { |
1462 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1463 | 0 | if (pHdl) |
1464 | 0 | pHdl->CancelHandler(); |
1465 | 0 | } |
1466 | | |
1467 | | void ScModule::InputSelection( const EditView* pView ) |
1468 | 0 | { |
1469 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1470 | 0 | if (pHdl) |
1471 | 0 | pHdl->InputSelection( pView ); |
1472 | 0 | } |
1473 | | |
1474 | | void ScModule::InputChanged( const EditView* pView ) |
1475 | 0 | { |
1476 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1477 | 0 | if (pHdl) |
1478 | 0 | pHdl->InputChanged( pView, false ); |
1479 | 0 | } |
1480 | | |
1481 | | void ScModule::ViewShellGone( const ScTabViewShell* pViewSh ) |
1482 | 0 | { |
1483 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1484 | 0 | if (pHdl) |
1485 | 0 | pHdl->ViewShellGone( pViewSh ); |
1486 | 0 | } |
1487 | | |
1488 | | void ScModule::SetRefInputHdl( ScInputHandler* pNew ) |
1489 | 0 | { |
1490 | 0 | m_pRefInputHandler = pNew; |
1491 | 0 | } |
1492 | | |
1493 | | void ScModule::InputGetSelection( sal_Int32& rStart, sal_Int32& rEnd ) |
1494 | 0 | { |
1495 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1496 | 0 | if (pHdl) |
1497 | 0 | pHdl->InputGetSelection( rStart, rEnd ); |
1498 | 0 | } |
1499 | | |
1500 | | void ScModule::InputSetSelection( sal_Int32 nStart, sal_Int32 nEnd ) |
1501 | 0 | { |
1502 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1503 | 0 | if (pHdl) |
1504 | 0 | pHdl->InputSetSelection( nStart, nEnd ); |
1505 | 0 | } |
1506 | | |
1507 | | void ScModule::InputReplaceSelection( std::u16string_view aStr ) |
1508 | 0 | { |
1509 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1510 | 0 | if (pHdl) |
1511 | 0 | pHdl->InputReplaceSelection( aStr ); |
1512 | 0 | } |
1513 | | |
1514 | | void ScModule::InputTurnOffWinEngine() |
1515 | 0 | { |
1516 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1517 | 0 | if (pHdl) |
1518 | 0 | pHdl->InputTurnOffWinEngine(); |
1519 | 0 | } |
1520 | | |
1521 | | void ScModule::ActivateInputWindow( const OUString* pStrFormula, bool bMatrix ) |
1522 | 0 | { |
1523 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1524 | 0 | if ( !pHdl ) |
1525 | 0 | return; |
1526 | | |
1527 | 0 | ScInputWindow* pWin = pHdl->GetInputWindow(); |
1528 | 0 | if ( pStrFormula ) |
1529 | 0 | { |
1530 | | // Take over formula |
1531 | 0 | if ( pWin ) |
1532 | 0 | { |
1533 | 0 | pWin->SetFuncString( *pStrFormula, false ); |
1534 | | // SetSumAssignMode due to sal_False not necessary |
1535 | 0 | } |
1536 | 0 | ScEnterMode nMode = bMatrix ? ScEnterMode::MATRIX : ScEnterMode::NORMAL; |
1537 | 0 | pHdl->EnterHandler( nMode ); |
1538 | | |
1539 | | // Without Invalidate the selection remains active, if the formula has not changed |
1540 | 0 | if (pWin) |
1541 | 0 | pWin->TextInvalidate(); |
1542 | 0 | } |
1543 | 0 | else |
1544 | 0 | { |
1545 | | // Cancel |
1546 | 0 | if ( pWin ) |
1547 | 0 | { |
1548 | 0 | pWin->SetFuncString( OUString(), false ); |
1549 | | // SetSumAssignMode due to sal_False no necessary |
1550 | 0 | } |
1551 | 0 | pHdl->CancelHandler(); |
1552 | 0 | } |
1553 | 0 | } |
1554 | | |
1555 | | /** |
1556 | | * Reference dialogs |
1557 | | */ |
1558 | | void ScModule::SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm ) |
1559 | 0 | { |
1560 | | //TODO: Move reference dialog handling to view |
1561 | | // Just keep function autopilot here for references to other documents |
1562 | 0 | if ( !(m_nCurRefDlgId == 0 || ( nId == m_nCurRefDlgId && !bVis ) |
1563 | 0 | || ( comphelper::LibreOfficeKit::isActive() )) ) |
1564 | 0 | return; |
1565 | | |
1566 | 0 | if ( !pViewFrm ) |
1567 | 0 | pViewFrm = SfxViewFrame::Current(); |
1568 | | |
1569 | | // bindings update causes problems with update of stylist if |
1570 | | // current style family has changed |
1571 | | //if ( pViewFrm ) |
1572 | | // pViewFrm->GetBindings().Update(); // to avoid trouble in LockDispatcher |
1573 | | |
1574 | | // before SetChildWindow |
1575 | 0 | if ( comphelper::LibreOfficeKit::isActive() ) |
1576 | 0 | { |
1577 | 0 | if ( bVis ) |
1578 | 0 | m_nCurRefDlgId = nId; |
1579 | 0 | } |
1580 | 0 | else |
1581 | 0 | { |
1582 | 0 | m_nCurRefDlgId = bVis ? nId : 0; |
1583 | 0 | } |
1584 | |
|
1585 | 0 | if ( pViewFrm ) |
1586 | 0 | { |
1587 | | // store the dialog id also in the view shell |
1588 | 0 | SfxViewShell* pViewSh = pViewFrm->GetViewShell(); |
1589 | 0 | if (ScTabViewShell* pTabViewSh = dynamic_cast<ScTabViewShell*>(pViewSh)) |
1590 | 0 | pTabViewSh->SetCurRefDlgId(m_nCurRefDlgId); |
1591 | 0 | else |
1592 | 0 | { |
1593 | | // no ScTabViewShell - possible for example from a Basic macro |
1594 | 0 | bVis = false; |
1595 | 0 | m_nCurRefDlgId = 0; // don't set nCurRefDlgId if no dialog is created |
1596 | 0 | } |
1597 | |
|
1598 | 0 | pViewFrm->SetChildWindow( nId, bVis ); |
1599 | 0 | } |
1600 | |
|
1601 | 0 | SfxApplication* pSfxApp = SfxGetpApp(); |
1602 | 0 | pSfxApp->Broadcast( SfxHint( SfxHintId::ScRefModeChanged ) ); |
1603 | 0 | } |
1604 | | |
1605 | | static SfxChildWindow* lcl_GetChildWinFromCurrentView( sal_uInt16 nId ) |
1606 | 0 | { |
1607 | 0 | SfxViewFrame* pViewFrm = SfxViewFrame::Current(); |
1608 | | |
1609 | | // #i46999# current view frame can be null (for example, when closing help) |
1610 | 0 | return pViewFrm ? pViewFrm->GetChildWindow( nId ) : nullptr; |
1611 | 0 | } |
1612 | | |
1613 | | static SfxChildWindow* lcl_GetChildWinFromAnyView( sal_uInt16 nId ) |
1614 | 0 | { |
1615 | | // First, try the current view |
1616 | 0 | SfxChildWindow* pChildWnd = lcl_GetChildWinFromCurrentView( nId ); |
1617 | 0 | if ( pChildWnd ) |
1618 | 0 | return pChildWnd; // found in the current view |
1619 | | |
1620 | | // if not found there, get the child window from any open view |
1621 | | // it can be open only in one view because nCurRefDlgId is global |
1622 | | |
1623 | 0 | SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst(); |
1624 | 0 | while ( pViewFrm ) |
1625 | 0 | { |
1626 | 0 | pChildWnd = pViewFrm->GetChildWindow( nId ); |
1627 | 0 | if ( pChildWnd ) |
1628 | 0 | return pChildWnd; // found in any view |
1629 | | |
1630 | 0 | pViewFrm = SfxViewFrame::GetNext( *pViewFrm ); |
1631 | 0 | } |
1632 | | |
1633 | 0 | return nullptr; // none found |
1634 | 0 | } |
1635 | | |
1636 | | bool ScModule::IsModalMode(SfxObjectShell* pDocSh) |
1637 | 0 | { |
1638 | | //TODO: Move reference dialog handling to view |
1639 | | // Just keep function autopilot here for references to other documents |
1640 | 0 | bool bIsModal = false; |
1641 | |
|
1642 | 0 | if ( m_nCurRefDlgId ) |
1643 | 0 | { |
1644 | 0 | SfxChildWindow* pChildWnd = lcl_GetChildWinFromCurrentView( m_nCurRefDlgId ); |
1645 | 0 | if ( pChildWnd ) |
1646 | 0 | { |
1647 | 0 | if (pChildWnd->GetController()) |
1648 | 0 | { |
1649 | 0 | IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); |
1650 | 0 | assert(pRefDlg); |
1651 | 0 | bIsModal = pChildWnd->IsVisible() && pRefDlg && |
1652 | 0 | !( pRefDlg->IsRefInputMode() && pRefDlg->IsDocAllowed(pDocSh) ); |
1653 | 0 | } |
1654 | 0 | } |
1655 | 0 | else if ( pDocSh && comphelper::LibreOfficeKit::isActive() ) |
1656 | 0 | { |
1657 | | // m_nCurRefDlgId is not deglobalized so it can be set by other view |
1658 | | // in LOK case when no ChildWindow for this view was detected -> fallback |
1659 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1660 | 0 | if ( pHdl ) |
1661 | 0 | bIsModal = pHdl->IsModalMode(*pDocSh); |
1662 | 0 | } |
1663 | 0 | } |
1664 | 0 | else if (pDocSh) |
1665 | 0 | { |
1666 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1667 | 0 | if ( pHdl ) |
1668 | 0 | bIsModal = pHdl->IsModalMode(*pDocSh); |
1669 | 0 | } |
1670 | |
|
1671 | 0 | return bIsModal; |
1672 | 0 | } |
1673 | | |
1674 | | bool ScModule::IsTableLocked() |
1675 | 0 | { |
1676 | | //TODO: Move reference dialog handling to view |
1677 | | // Just keep function autopilot here for references to other documents |
1678 | 0 | bool bLocked = false; |
1679 | | |
1680 | | // Up until now just for ScAnyRefDlg |
1681 | 0 | if ( m_nCurRefDlgId ) |
1682 | 0 | { |
1683 | 0 | SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( m_nCurRefDlgId ); |
1684 | 0 | if ( pChildWnd ) |
1685 | 0 | { |
1686 | 0 | if (pChildWnd->GetController()) |
1687 | 0 | { |
1688 | 0 | IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); |
1689 | 0 | assert(pRefDlg); |
1690 | 0 | if (pRefDlg) |
1691 | 0 | bLocked = pRefDlg->IsTableLocked(); |
1692 | 0 | } |
1693 | 0 | } |
1694 | 0 | else if (!comphelper::LibreOfficeKit::isActive()) |
1695 | 0 | bLocked = true; // for other views, see IsModalMode |
1696 | 0 | } |
1697 | | |
1698 | | // We can't stop LOK clients from switching part, and getting out of sync. |
1699 | 0 | assert(!bLocked || !comphelper::LibreOfficeKit::isActive()); |
1700 | |
|
1701 | 0 | return bLocked; |
1702 | 0 | } |
1703 | | |
1704 | | bool ScModule::IsRefDialogOpen() |
1705 | 0 | { |
1706 | | //TODO: Move reference dialog handling to view |
1707 | | // Just keep function autopilot here for references to other documents |
1708 | 0 | bool bIsOpen = false; |
1709 | |
|
1710 | 0 | if ( m_nCurRefDlgId ) |
1711 | 0 | { |
1712 | 0 | SfxChildWindow* pChildWnd = lcl_GetChildWinFromCurrentView( m_nCurRefDlgId ); |
1713 | 0 | if ( pChildWnd ) |
1714 | 0 | bIsOpen = pChildWnd->IsVisible(); |
1715 | 0 | } |
1716 | |
|
1717 | 0 | return bIsOpen; |
1718 | 0 | } |
1719 | | |
1720 | | bool ScModule::IsFormulaMode() |
1721 | 0 | { |
1722 | | //TODO: Move reference dialog handling to view |
1723 | | // Just keep function autopilot here for references to other documents |
1724 | 0 | bool bIsFormula = false; |
1725 | |
|
1726 | 0 | if ( m_nCurRefDlgId ) |
1727 | 0 | { |
1728 | 0 | SfxChildWindow* pChildWnd = nullptr; |
1729 | |
|
1730 | 0 | if ( comphelper::LibreOfficeKit::isActive() ) |
1731 | 0 | pChildWnd = lcl_GetChildWinFromCurrentView( m_nCurRefDlgId ); |
1732 | 0 | else |
1733 | 0 | pChildWnd = lcl_GetChildWinFromAnyView( m_nCurRefDlgId ); |
1734 | |
|
1735 | 0 | if ( pChildWnd ) |
1736 | 0 | { |
1737 | 0 | if (pChildWnd->GetController()) |
1738 | 0 | { |
1739 | 0 | IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); |
1740 | 0 | assert(pRefDlg); |
1741 | 0 | bIsFormula = pChildWnd->IsVisible() && pRefDlg && pRefDlg->IsRefInputMode(); |
1742 | 0 | } |
1743 | 0 | } |
1744 | 0 | else if ( comphelper::LibreOfficeKit::isActive() ) |
1745 | 0 | { |
1746 | | // m_nCurRefDlgId is not deglobalized so it can be set by other view |
1747 | | // in LOK case when no ChildWindow for this view was detected -> fallback |
1748 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1749 | 0 | if ( pHdl ) |
1750 | 0 | bIsFormula = pHdl->IsFormulaMode(); |
1751 | 0 | } |
1752 | 0 | } |
1753 | 0 | else |
1754 | 0 | { |
1755 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1756 | 0 | if ( pHdl ) |
1757 | 0 | bIsFormula = pHdl->IsFormulaMode(); |
1758 | 0 | } |
1759 | |
|
1760 | 0 | if (m_bIsInEditCommand) |
1761 | 0 | bIsFormula = true; |
1762 | |
|
1763 | 0 | return bIsFormula; |
1764 | 0 | } |
1765 | | |
1766 | | static void lcl_MarkedTabs( const ScMarkData& rMark, SCTAB& rStartTab, SCTAB& rEndTab ) |
1767 | 0 | { |
1768 | 0 | if (rMark.GetSelectCount() > 1) |
1769 | 0 | { |
1770 | 0 | rEndTab = rMark.GetLastSelected(); |
1771 | 0 | rStartTab = rMark.GetFirstSelected(); |
1772 | 0 | } |
1773 | 0 | } |
1774 | | |
1775 | | void ScModule::SetReference( const ScRange& rRef, ScDocument& rDoc, |
1776 | | const ScMarkData* pMarkData ) |
1777 | 0 | { |
1778 | | //TODO: Move reference dialog handling to view |
1779 | | // Just keep function autopilot here for references to other documents |
1780 | | |
1781 | | // In RefDialogs we also trigger the ZoomIn, if the Ref's Start and End are different |
1782 | 0 | ScRange aNew = rRef; |
1783 | 0 | aNew.PutInOrder(); // Always in the right direction |
1784 | |
|
1785 | 0 | if( m_nCurRefDlgId ) |
1786 | 0 | { |
1787 | 0 | SfxChildWindow* pChildWnd = nullptr; |
1788 | |
|
1789 | 0 | if ( comphelper::LibreOfficeKit::isActive() ) |
1790 | 0 | pChildWnd = lcl_GetChildWinFromCurrentView( m_nCurRefDlgId ); |
1791 | 0 | else |
1792 | 0 | pChildWnd = lcl_GetChildWinFromAnyView( m_nCurRefDlgId ); |
1793 | |
|
1794 | 0 | OSL_ENSURE( pChildWnd, "NoChildWin" ); |
1795 | 0 | if ( pChildWnd ) |
1796 | 0 | { |
1797 | 0 | if ( m_nCurRefDlgId == SID_OPENDLG_CONSOLIDATE && pMarkData ) |
1798 | 0 | { |
1799 | 0 | SCTAB nStartTab = aNew.aStart.Tab(); |
1800 | 0 | SCTAB nEndTab = aNew.aEnd.Tab(); |
1801 | 0 | lcl_MarkedTabs( *pMarkData, nStartTab, nEndTab ); |
1802 | 0 | aNew.aStart.SetTab(nStartTab); |
1803 | 0 | aNew.aEnd.SetTab(nEndTab); |
1804 | 0 | } |
1805 | |
|
1806 | 0 | if (pChildWnd->GetController()) |
1807 | 0 | { |
1808 | 0 | IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); |
1809 | 0 | assert(pRefDlg); |
1810 | 0 | if(pRefDlg) |
1811 | 0 | { |
1812 | | // hide the (color) selection now instead of later from LoseFocus, |
1813 | | // don't abort the ref input that causes this call (bDoneRefMode = sal_False) |
1814 | 0 | pRefDlg->HideReference( false ); |
1815 | 0 | pRefDlg->SetReference( aNew, rDoc ); |
1816 | 0 | } |
1817 | 0 | } |
1818 | 0 | } |
1819 | 0 | else if ( comphelper::LibreOfficeKit::isActive() ) |
1820 | 0 | { |
1821 | | // m_nCurRefDlgId is not deglobalized so it can be set by other view |
1822 | | // in LOK case when no ChildWindow for this view was detected -> fallback |
1823 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1824 | 0 | if (pHdl) |
1825 | 0 | pHdl->SetReference( aNew, rDoc ); |
1826 | 0 | } |
1827 | 0 | } |
1828 | 0 | else |
1829 | 0 | { |
1830 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1831 | 0 | if (pHdl) |
1832 | 0 | pHdl->SetReference( aNew, rDoc ); |
1833 | 0 | else |
1834 | 0 | { |
1835 | 0 | OSL_FAIL("SetReference without receiver"); |
1836 | 0 | } |
1837 | 0 | } |
1838 | 0 | } |
1839 | | |
1840 | | /** |
1841 | | * Multiple selection |
1842 | | */ |
1843 | | void ScModule::AddRefEntry() |
1844 | 0 | { |
1845 | | //TODO: Move reference dialog handling to view |
1846 | | // Just keep function autopilot here for references to other documents |
1847 | 0 | if ( m_nCurRefDlgId ) |
1848 | 0 | { |
1849 | 0 | SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( m_nCurRefDlgId ); |
1850 | 0 | OSL_ENSURE( pChildWnd, "NoChildWin" ); |
1851 | 0 | if ( pChildWnd ) |
1852 | 0 | { |
1853 | 0 | if (pChildWnd->GetController()) |
1854 | 0 | { |
1855 | 0 | IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); |
1856 | 0 | assert(pRefDlg); |
1857 | 0 | if (pRefDlg) |
1858 | 0 | { |
1859 | 0 | pRefDlg->AddRefEntry(); |
1860 | 0 | } |
1861 | 0 | } |
1862 | 0 | } |
1863 | 0 | } |
1864 | 0 | else |
1865 | 0 | { |
1866 | 0 | ScInputHandler* pHdl = GetInputHdl(); |
1867 | 0 | if (pHdl) |
1868 | 0 | pHdl->AddRefEntry(); |
1869 | 0 | } |
1870 | 0 | } |
1871 | | |
1872 | | void ScModule::EndReference() |
1873 | 0 | { |
1874 | | //TODO: Move reference dialog handling to view |
1875 | | // Just keep function autopilot here for references to other documents |
1876 | | |
1877 | | // We also annul the ZoomIn again in RefDialogs |
1878 | | |
1879 | | //FIXME: ShowRefFrame at InputHdl, if the Function AutoPilot is open? |
1880 | 0 | if ( !m_nCurRefDlgId ) |
1881 | 0 | return; |
1882 | | |
1883 | 0 | SfxChildWindow* pChildWnd = nullptr; |
1884 | |
|
1885 | 0 | if ( comphelper::LibreOfficeKit::isActive() ) |
1886 | 0 | pChildWnd = lcl_GetChildWinFromCurrentView( m_nCurRefDlgId ); |
1887 | 0 | else |
1888 | 0 | pChildWnd = lcl_GetChildWinFromAnyView( m_nCurRefDlgId ); |
1889 | |
|
1890 | 0 | OSL_ENSURE( pChildWnd, "NoChildWin" ); |
1891 | 0 | if ( pChildWnd ) |
1892 | 0 | { |
1893 | 0 | if (pChildWnd->GetController()) |
1894 | 0 | { |
1895 | 0 | IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetController().get()); |
1896 | 0 | assert(pRefDlg); |
1897 | 0 | if(pRefDlg) |
1898 | 0 | { |
1899 | 0 | pRefDlg->SetActive(); |
1900 | 0 | } |
1901 | 0 | } |
1902 | 0 | } |
1903 | 0 | } |
1904 | | |
1905 | | /** |
1906 | | * Idle/OnlineSpelling |
1907 | | */ |
1908 | | void ScModule::EnsureIdleUpdate() |
1909 | 1.04M | { |
1910 | 1.04M | if (!m_aIdleTimer.IsActive()) |
1911 | 1.27k | m_aIdleTimer.Start(); // Restart the timer. |
1912 | 1.04M | } |
1913 | | |
1914 | | static void lcl_CheckNeedsRepaint( const ScDocShell* pDocShell ) |
1915 | 0 | { |
1916 | 0 | SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell ); |
1917 | 0 | while ( pFrame ) |
1918 | 0 | { |
1919 | 0 | SfxViewShell* p = pFrame->GetViewShell(); |
1920 | 0 | ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( p ); |
1921 | 0 | if ( pViewSh ) |
1922 | 0 | pViewSh->CheckNeedsRepaint(); |
1923 | 0 | pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell ); |
1924 | 0 | } |
1925 | 0 | } |
1926 | | |
1927 | | IMPL_LINK_NOARG(ScModule, IdleHandler, Timer *, void) |
1928 | 1.27k | { |
1929 | 1.27k | if ( Application::AnyInput( VclInputFlags::MOUSE | VclInputFlags::KEYBOARD ) ) |
1930 | 0 | { |
1931 | 0 | m_aIdleTimer.Start(); |
1932 | 0 | return; |
1933 | 0 | } |
1934 | | |
1935 | 1.27k | bool bMore = false; |
1936 | 1.27k | ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(SfxObjectShell::Current()); |
1937 | | |
1938 | 1.27k | if ( pDocSh ) |
1939 | 0 | { |
1940 | 0 | ScDocument& rDoc = pDocSh->GetDocument(); |
1941 | 0 | sc::DocumentLinkManager& rLinkMgr = rDoc.GetDocLinkManager(); |
1942 | 0 | bool bLinks = rLinkMgr.idleCheckLinks(); |
1943 | 0 | bool bWidth = rDoc.IdleCalcTextWidth(); |
1944 | |
|
1945 | 0 | bMore = bLinks || bWidth; // Still something at all? |
1946 | | |
1947 | | // While calculating a Basic formula, a paint event may have occurred, |
1948 | | // so check the bNeedsRepaint flags for this document's views |
1949 | 0 | if (bWidth) |
1950 | 0 | lcl_CheckNeedsRepaint( pDocSh ); |
1951 | 0 | } |
1952 | | |
1953 | 1.27k | if ( bMore ) |
1954 | 0 | { |
1955 | 0 | m_aIdleTimer.Start(); |
1956 | 0 | } |
1957 | 1.27k | else |
1958 | 1.27k | { |
1959 | 1.27k | m_aIdleTimer.Stop(); |
1960 | 1.27k | } |
1961 | 1.27k | } |
1962 | | |
1963 | | /** |
1964 | | * Virtual methods for the OptionsDialog |
1965 | | */ |
1966 | | std::optional<SfxItemSet> ScModule::CreateItemSet( sal_uInt16 nId ) |
1967 | 0 | { |
1968 | 0 | std::optional<SfxItemSet> pRet; |
1969 | 0 | if(SID_SC_EDITOPTIONS == nId) |
1970 | 0 | { |
1971 | 0 | pRet.emplace( |
1972 | 0 | GetPool(), |
1973 | 0 | svl::Items< |
1974 | | // TP_USERLISTS: |
1975 | 0 | SCITEM_USERLIST, SCITEM_USERLIST, |
1976 | | // TP_GRID: |
1977 | 0 | SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS, |
1978 | 0 | SID_ATTR_METRIC, SID_ATTR_METRIC, |
1979 | 0 | SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP, |
1980 | | // TP_INPUT: |
1981 | 0 | SID_SC_INPUT_LEGACY_CELL_SELECTION, SID_SC_OPT_SORT_REF_UPDATE, |
1982 | | // TP_FORMULA, TP_DEFAULTS: |
1983 | 0 | SID_SCFORMULAOPTIONS, SID_SCDEFAULTSOPTIONS, |
1984 | | // TP_VIEW, TP_CALC: |
1985 | 0 | SID_SCVIEWOPTIONS, SID_SCDOCOPTIONS, |
1986 | | // TP_INPUT: |
1987 | 0 | SID_SC_INPUT_WARNACTIVESHEET, SID_SC_INPUT_ENTER_PASTE_MODE, |
1988 | | // TP_PRINT: |
1989 | 0 | SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS, |
1990 | | // TP_INPUT: |
1991 | 0 | SID_SC_INPUT_SELECTION, SID_SC_INPUT_MARK_HEADER, |
1992 | 0 | SID_SC_INPUT_TEXTWYSIWYG, SID_SC_INPUT_TEXTWYSIWYG, |
1993 | 0 | SID_SC_INPUT_REPLCELLSWARN, SID_SC_INPUT_REPLCELLSWARN, |
1994 | | // TP_VIEW: |
1995 | 0 | SID_SC_OPT_SYNCZOOM, SID_SC_OPT_KEY_BINDING_COMPAT, |
1996 | 0 | SID_SC_OPT_LINKS, SID_SC_OPT_LINKS>); |
1997 | |
|
1998 | 0 | const ScAppOptions& rAppOpt = GetAppOptions(); |
1999 | |
|
2000 | 0 | ScDocShell* pDocSh = dynamic_cast< ScDocShell *>( SfxObjectShell::Current() ); |
2001 | 0 | ScDocOptions aCalcOpt = pDocSh |
2002 | 0 | ? pDocSh->GetDocument().GetDocOptions() |
2003 | 0 | : GetDocOptions(); |
2004 | |
|
2005 | 0 | ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( SfxViewShell::Current() ); |
2006 | 0 | ScViewOptions aViewOpt = pViewSh |
2007 | 0 | ? pViewSh->GetViewData().GetOptions() |
2008 | 0 | : GetViewOptions(); |
2009 | |
|
2010 | 0 | ScUserListItem aULItem( SCITEM_USERLIST ); |
2011 | 0 | const ScUserList& rUL = ScGlobal::GetUserList(); |
2012 | | |
2013 | | // SfxGetpApp()->GetOptions( aSet ); |
2014 | |
|
2015 | 0 | pRet->Put( SfxUInt16Item( SID_ATTR_METRIC, |
2016 | 0 | sal::static_int_cast<sal_uInt16>(rAppOpt.GetAppMetric()) ) ); |
2017 | | |
2018 | | // TP_CALC |
2019 | 0 | pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, |
2020 | 0 | aCalcOpt.GetTabDistance())); |
2021 | 0 | pRet->Put( ScTpCalcItem( SID_SCDOCOPTIONS, aCalcOpt ) ); |
2022 | | |
2023 | | // TP_VIEW |
2024 | 0 | pRet->Put( ScTpViewItem( aViewOpt ) ); |
2025 | 0 | pRet->Put( SfxBoolItem( SID_SC_OPT_SYNCZOOM, rAppOpt.GetSynchronizeZoom() ) ); |
2026 | | |
2027 | | // TP_INPUT |
2028 | 0 | const ScInputOptions& rInpOpt = GetInputOptions(); |
2029 | 0 | pRet->Put( SfxUInt16Item( SID_SC_INPUT_SELECTIONPOS, |
2030 | 0 | rInpOpt.GetMoveDir() ) ); |
2031 | 0 | pRet->Put( SfxBoolItem( SID_SC_INPUT_SELECTION, |
2032 | 0 | rInpOpt.GetMoveSelection() ) ); |
2033 | 0 | pRet->Put( SfxBoolItem( SID_SC_INPUT_EDITMODE, |
2034 | 0 | rInpOpt.GetEnterEdit() ) ); |
2035 | 0 | pRet->Put( SfxBoolItem( SID_SC_INPUT_FMT_EXPAND, |
2036 | 0 | rInpOpt.GetExtendFormat() ) ); |
2037 | 0 | pRet->Put( SfxBoolItem( SID_SC_INPUT_RANGEFINDER, |
2038 | 0 | rInpOpt.GetRangeFinder() ) ); |
2039 | 0 | pRet->Put( SfxBoolItem( SID_SC_INPUT_REF_EXPAND, |
2040 | 0 | rInpOpt.GetExpandRefs() ) ); |
2041 | 0 | pRet->Put( SfxBoolItem(SID_SC_OPT_SORT_REF_UPDATE, rInpOpt.GetSortRefUpdate())); |
2042 | 0 | pRet->Put( SfxBoolItem( SID_SC_INPUT_MARK_HEADER, |
2043 | 0 | rInpOpt.GetMarkHeader() ) ); |
2044 | 0 | pRet->Put( SfxBoolItem( SID_SC_INPUT_TEXTWYSIWYG, |
2045 | 0 | rInpOpt.GetTextWysiwyg() ) ); |
2046 | 0 | pRet->Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN, |
2047 | 0 | rInpOpt.GetReplaceCellsWarn() ) ); |
2048 | 0 | pRet->Put( SfxBoolItem( SID_SC_INPUT_LEGACY_CELL_SELECTION, |
2049 | 0 | rInpOpt.GetLegacyCellSelection() ) ); |
2050 | 0 | pRet->Put( SfxBoolItem( SID_SC_INPUT_ENTER_PASTE_MODE, |
2051 | 0 | rInpOpt.GetEnterPasteMode() ) ); |
2052 | 0 | pRet->Put( SfxBoolItem( SID_SC_INPUT_WARNACTIVESHEET, |
2053 | 0 | rInpOpt.GetWarnActiveSheet() ) ); |
2054 | | |
2055 | | // RID_SC_TP_PRINT |
2056 | 0 | pRet->Put( ScTpPrintItem( GetPrintOptions() ) ); |
2057 | | |
2058 | | // TP_GRID |
2059 | 0 | pRet->Put( aViewOpt.CreateGridItem() ); |
2060 | | |
2061 | | // TP_USERLISTS |
2062 | 0 | aULItem.SetUserList(rUL); |
2063 | 0 | pRet->Put(aULItem); |
2064 | | |
2065 | | // TP_COMPATIBILITY |
2066 | 0 | pRet->Put( SfxUInt16Item( SID_SC_OPT_KEY_BINDING_COMPAT, |
2067 | 0 | rAppOpt.GetKeyBindingType() ) ); |
2068 | 0 | pRet->Put( SfxBoolItem( SID_SC_OPT_LINKS, rAppOpt.GetLinksInsertedLikeMSExcel())); |
2069 | | |
2070 | | // TP_DEFAULTS |
2071 | 0 | pRet->Put( ScTpDefaultsItem( GetDefaultsOptions() ) ); |
2072 | | |
2073 | | // TP_FORMULA |
2074 | 0 | ScFormulaOptions aOptions = GetFormulaOptions(); |
2075 | 0 | if (pDocSh) |
2076 | 0 | { |
2077 | 0 | ScCalcConfig aConfig( aOptions.GetCalcConfig()); |
2078 | 0 | aConfig.MergeDocumentSpecific( pDocSh->GetDocument().GetCalcConfig()); |
2079 | 0 | aOptions.SetCalcConfig( aConfig); |
2080 | 0 | } |
2081 | 0 | pRet->Put( ScTpFormulaItem( std::move(aOptions) ) ); |
2082 | 0 | } |
2083 | 0 | return pRet; |
2084 | 0 | } |
2085 | | |
2086 | | void ScModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) |
2087 | 0 | { |
2088 | 0 | if(SID_SC_EDITOPTIONS == nId) |
2089 | 0 | { |
2090 | 0 | ModifyOptions( rSet ); |
2091 | 0 | } |
2092 | 0 | } |
2093 | | |
2094 | | std::unique_ptr<SfxTabPage> ScModule::CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) |
2095 | 0 | { |
2096 | 0 | std::unique_ptr<SfxTabPage> xRet; |
2097 | 0 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); |
2098 | 0 | switch(nId) |
2099 | 0 | { |
2100 | 0 | case SID_SC_TP_LAYOUT: |
2101 | 0 | { |
2102 | 0 | ::CreateTabPage ScTpLayoutOptionsCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_LAYOUT); |
2103 | 0 | if (ScTpLayoutOptionsCreate) |
2104 | 0 | xRet = (*ScTpLayoutOptionsCreate)(pPage, pController, &rSet); |
2105 | 0 | break; |
2106 | 0 | } |
2107 | 0 | case SID_SC_TP_CONTENT: |
2108 | 0 | { |
2109 | 0 | ::CreateTabPage ScTpContentOptionsCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_CONTENT); |
2110 | 0 | if (ScTpContentOptionsCreate) |
2111 | 0 | xRet = (*ScTpContentOptionsCreate)(pPage, pController, &rSet); |
2112 | 0 | break; |
2113 | 0 | } |
2114 | 0 | case SID_SC_TP_GRID: |
2115 | 0 | xRet = SvxGridTabPage::Create(pPage, pController, rSet); |
2116 | 0 | break; |
2117 | 0 | case SID_SC_TP_USERLISTS: |
2118 | 0 | { |
2119 | 0 | ::CreateTabPage ScTpUserListsCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_USERLISTS); |
2120 | 0 | if (ScTpUserListsCreate) |
2121 | 0 | xRet = (*ScTpUserListsCreate)(pPage, pController, &rSet); |
2122 | 0 | break; |
2123 | 0 | } |
2124 | 0 | case SID_SC_TP_CALC: |
2125 | 0 | { |
2126 | 0 | ::CreateTabPage ScTpCalcOptionsCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_CALC); |
2127 | 0 | if (ScTpCalcOptionsCreate) |
2128 | 0 | xRet = (*ScTpCalcOptionsCreate)(pPage, pController, &rSet); |
2129 | 0 | break; |
2130 | 0 | } |
2131 | 0 | case SID_SC_TP_FORMULA: |
2132 | 0 | { |
2133 | 0 | ::CreateTabPage ScTpFormulaOptionsCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_FORMULA); |
2134 | 0 | if (ScTpFormulaOptionsCreate) |
2135 | 0 | xRet = (*ScTpFormulaOptionsCreate)(pPage, pController, &rSet); |
2136 | 0 | break; |
2137 | 0 | } |
2138 | 0 | case SID_SC_TP_COMPATIBILITY: |
2139 | 0 | { |
2140 | 0 | ::CreateTabPage ScTpCompatOptionsCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_COMPATIBILITY); |
2141 | 0 | if (ScTpCompatOptionsCreate) |
2142 | 0 | xRet = (*ScTpCompatOptionsCreate)(pPage, pController, &rSet); |
2143 | 0 | break; |
2144 | 0 | } |
2145 | 0 | case SID_SC_TP_CHANGES: |
2146 | 0 | { |
2147 | 0 | ::CreateTabPage ScRedlineOptionsTabPageCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_CHANGES); |
2148 | 0 | if (ScRedlineOptionsTabPageCreate) |
2149 | 0 | xRet =(*ScRedlineOptionsTabPageCreate)(pPage, pController, &rSet); |
2150 | 0 | break; |
2151 | 0 | } |
2152 | 0 | case RID_SC_TP_PRINT: |
2153 | 0 | { |
2154 | 0 | ::CreateTabPage ScTpPrintOptionsCreate = pFact->GetTabPageCreatorFunc(RID_SC_TP_PRINT); |
2155 | 0 | if (ScTpPrintOptionsCreate) |
2156 | 0 | xRet = (*ScTpPrintOptionsCreate)(pPage, pController, &rSet); |
2157 | 0 | break; |
2158 | 0 | } |
2159 | 0 | case RID_SC_TP_DEFAULTS: |
2160 | 0 | { |
2161 | 0 | ::CreateTabPage ScTpDefaultsOptionsCreate = pFact->GetTabPageCreatorFunc(RID_SC_TP_DEFAULTS); |
2162 | 0 | if (ScTpDefaultsOptionsCreate) |
2163 | 0 | xRet = (*ScTpDefaultsOptionsCreate)(pPage, pController, &rSet); |
2164 | 0 | break; |
2165 | 0 | } |
2166 | 0 | } |
2167 | | |
2168 | 0 | OSL_ENSURE( xRet, "ScModule::CreateTabPage(): no valid ID for TabPage!" ); |
2169 | |
|
2170 | 0 | return xRet; |
2171 | 0 | } |
2172 | | |
2173 | | IMPL_LINK( ScModule, CalcFieldValueHdl, EditFieldInfo*, pInfo, void ) |
2174 | 241 | { |
2175 | | //TODO: Merge with ScFieldEditEngine! |
2176 | 241 | if (!pInfo) |
2177 | 0 | return; |
2178 | | |
2179 | 241 | const SvxFieldItem& rField = pInfo->GetField(); |
2180 | 241 | const SvxFieldData* pField = rField.GetField(); |
2181 | | |
2182 | 241 | if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField)) |
2183 | 241 | { |
2184 | | // URLField |
2185 | 241 | const OUString& aURL = pURLField->GetURL(); |
2186 | | |
2187 | 241 | switch ( pURLField->GetFormat() ) |
2188 | 241 | { |
2189 | 0 | case SvxURLFormat::AppDefault: //TODO: Settable in the App? |
2190 | 241 | case SvxURLFormat::Repr: |
2191 | 241 | { |
2192 | 241 | pInfo->SetRepresentation( pURLField->GetRepresentation() ); |
2193 | 241 | } |
2194 | 241 | break; |
2195 | | |
2196 | 0 | case SvxURLFormat::Url: |
2197 | 0 | { |
2198 | 0 | pInfo->SetRepresentation( aURL ); |
2199 | 0 | } |
2200 | 0 | break; |
2201 | 241 | } |
2202 | | |
2203 | 241 | svtools::ColorConfigEntry eEntry = |
2204 | 241 | INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS; |
2205 | 241 | pInfo->SetTextColor( GetColorConfig().GetColorValue(eEntry).nColor ); |
2206 | 241 | } |
2207 | 0 | else |
2208 | 0 | { |
2209 | 0 | OSL_FAIL("Unknown Field"); |
2210 | 0 | pInfo->SetRepresentation(OUString('?')); |
2211 | 0 | } |
2212 | 241 | } |
2213 | | |
2214 | | void ScModule::RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd, weld::Window* pWndAncestor) |
2215 | 0 | { |
2216 | 0 | std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>> & rlRefWindow = m_mapRefController[nSlotId]; |
2217 | |
|
2218 | 0 | if (std::none_of(rlRefWindow.begin(), rlRefWindow.end(), |
2219 | 0 | [rWnd](const std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>& rCandidate) |
2220 | 0 | { |
2221 | 0 | return rCandidate.first.get() == rWnd.get(); |
2222 | 0 | })) |
2223 | 0 | { |
2224 | 0 | rlRefWindow.emplace_back(rWnd, pWndAncestor); |
2225 | 0 | } |
2226 | 0 | } |
2227 | | |
2228 | | void ScModule::UnregisterRefController(sal_uInt16 nSlotId, const std::shared_ptr<SfxDialogController>& rWnd) |
2229 | 0 | { |
2230 | 0 | auto iSlot = m_mapRefController.find( nSlotId ); |
2231 | |
|
2232 | 0 | if( iSlot == m_mapRefController.end() ) |
2233 | 0 | return; |
2234 | | |
2235 | 0 | std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>> & rlRefWindow = iSlot->second; |
2236 | |
|
2237 | 0 | auto i = std::find_if(rlRefWindow.begin(), rlRefWindow.end(), |
2238 | 0 | [rWnd](const std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>& rCandidate) |
2239 | 0 | { |
2240 | 0 | return rCandidate.first.get() == rWnd.get(); |
2241 | 0 | }); |
2242 | |
|
2243 | 0 | if( i == rlRefWindow.end() ) |
2244 | 0 | return; |
2245 | | |
2246 | 0 | rlRefWindow.erase( i ); |
2247 | |
|
2248 | 0 | if( rlRefWindow.empty() ) |
2249 | 0 | m_mapRefController.erase( nSlotId ); |
2250 | 0 | } |
2251 | | |
2252 | | std::shared_ptr<SfxDialogController> ScModule::Find1RefWindow(sal_uInt16 nSlotId, const weld::Window *pWndAncestor) |
2253 | 0 | { |
2254 | 0 | if (!pWndAncestor) |
2255 | 0 | return nullptr; |
2256 | | |
2257 | 0 | auto iSlot = m_mapRefController.find( nSlotId ); |
2258 | |
|
2259 | 0 | if( iSlot == m_mapRefController.end() ) |
2260 | 0 | return nullptr; |
2261 | | |
2262 | 0 | std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>> & rlRefWindow = iSlot->second; |
2263 | |
|
2264 | 0 | for (auto const& refWindow : rlRefWindow) |
2265 | 0 | if ( refWindow.second == pWndAncestor ) |
2266 | 0 | return refWindow.first; |
2267 | | |
2268 | 0 | return nullptr; |
2269 | 0 | } |
2270 | | |
2271 | | using namespace com::sun::star; |
2272 | | |
2273 | | constexpr OUStringLiteral LINGUPROP_AUTOSPELL = u"IsSpellAuto"; |
2274 | | |
2275 | | void ScModule::GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, LanguageType& rCtlLang ) |
2276 | 69.1k | { |
2277 | | // use SvtLinguConfig instead of service LinguProperties to avoid |
2278 | | // loading the linguistic component |
2279 | 69.1k | SvtLinguConfig aConfig; |
2280 | | |
2281 | 69.1k | SvtLinguOptions aOptions; |
2282 | 69.1k | aConfig.GetOptions( aOptions ); |
2283 | | |
2284 | 69.1k | rDefLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage, css::i18n::ScriptType::LATIN); |
2285 | 69.1k | rCjkLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK, css::i18n::ScriptType::ASIAN); |
2286 | 69.1k | rCtlLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, css::i18n::ScriptType::COMPLEX); |
2287 | 69.1k | } |
2288 | | |
2289 | | void ScModule::SetAutoSpellProperty( bool bSet ) |
2290 | 0 | { |
2291 | | // use SvtLinguConfig instead of service LinguProperties to avoid |
2292 | | // loading the linguistic component |
2293 | 0 | SvtLinguConfig aConfig; |
2294 | |
|
2295 | 0 | aConfig.SetProperty( LINGUPROP_AUTOSPELL, uno::Any(bSet) ); |
2296 | 0 | } |
2297 | | |
2298 | | bool ScModule::GetAutoSpellProperty() |
2299 | 0 | { |
2300 | | // use SvtLinguConfig instead of service LinguProperties to avoid |
2301 | | // loading the linguistic component |
2302 | 0 | SvtLinguConfig aConfig; |
2303 | |
|
2304 | 0 | SvtLinguOptions aOptions; |
2305 | 0 | aConfig.GetOptions( aOptions ); |
2306 | |
|
2307 | 0 | return aOptions.bIsSpellAuto; |
2308 | 0 | } |
2309 | | |
2310 | | bool ScModule::HasThesaurusLanguage( LanguageType nLang ) |
2311 | 0 | { |
2312 | 0 | if ( nLang == LANGUAGE_NONE ) |
2313 | 0 | return false; |
2314 | | |
2315 | 0 | bool bHasLang = false; |
2316 | 0 | try |
2317 | 0 | { |
2318 | 0 | uno::Reference< linguistic2::XThesaurus > xThes(LinguMgr::GetThesaurus()); |
2319 | 0 | if ( xThes.is() ) |
2320 | 0 | bHasLang = xThes->hasLocale( LanguageTag::convertToLocale( nLang ) ); |
2321 | 0 | } |
2322 | 0 | catch( uno::Exception& ) |
2323 | 0 | { |
2324 | 0 | OSL_FAIL("Error in Thesaurus"); |
2325 | 0 | } |
2326 | |
|
2327 | 0 | return bHasLang; |
2328 | 0 | } |
2329 | | |
2330 | | SfxStyleFamilies ScModule::CreateStyleFamilies() |
2331 | 0 | { |
2332 | 0 | SfxStyleFamilies aStyleFamilies; |
2333 | 0 | std::locale resLocale = ScModule::get()->GetResLocale(); |
2334 | |
|
2335 | 0 | aStyleFamilies.emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para, |
2336 | 0 | ScResId(STR_STYLE_FAMILY_CELL), |
2337 | 0 | BMP_STYLES_FAMILY_CELL, |
2338 | 0 | RID_CELLSTYLEFAMILY, resLocale)); |
2339 | |
|
2340 | 0 | aStyleFamilies.emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Page, |
2341 | 0 | ScResId(STR_STYLE_FAMILY_PAGE), |
2342 | 0 | BMP_STYLES_FAMILY_PAGE, |
2343 | 0 | RID_PAGESTYLEFAMILY, resLocale)); |
2344 | |
|
2345 | 0 | aStyleFamilies.emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Frame, |
2346 | 0 | ScResId(STR_STYLE_FAMILY_GRAPHICS), |
2347 | 0 | BMP_STYLES_FAMILY_GRAPHICS, |
2348 | 0 | RID_GRAPHICSTYLEFAMILY, resLocale)); |
2349 | |
|
2350 | 0 | return aStyleFamilies; |
2351 | 0 | } |
2352 | | |
2353 | | void ScModule::RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller) |
2354 | 0 | { |
2355 | 0 | mxAutomationApplicationEventsCaller = xCaller; |
2356 | 0 | } |
2357 | | |
2358 | | void ScModule::CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments) |
2359 | 0 | { |
2360 | 0 | if (mxAutomationApplicationEventsCaller.is()) |
2361 | 0 | mxAutomationApplicationEventsCaller->CallSinks(Method, Arguments); |
2362 | 0 | } |
2363 | | |
2364 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |