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