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