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 <formdata.hxx>
85 #include <detfunc.hxx>
86 #include <preview.hxx>
87 #include <dragdata.hxx>
88 #include <markdata.hxx>
89 #include <transobj.hxx>
90 #include <funcdesc.hxx>
91 
92 #define ShellClass_ScModule
93 #include <scslots.hxx>
94 
95 #include <scabstdlg.hxx>
96 #include <formula/errorcodes.hxx>
97 #include <documentlinkmgr.hxx>
98 
99 #define SC_IDLE_MIN 150
100 #define SC_IDLE_MAX 3000
101 #define SC_IDLE_STEP 75
102 #define SC_IDLE_COUNT 50
103 
104 static sal_uInt16 nIdleCount = 0;
105 
107 
108 void ScModule::InitInterface_Impl()
109 {
110  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION,
111  SfxVisibilityFlags::Standard | SfxVisibilityFlags::Client | SfxVisibilityFlags::Viewer,
112  ToolbarId::Objectbar_App);
113 
114  GetStaticInterface()->RegisterStatusBar(StatusBarId::CalcStatusBar);
115 }
116 
118  SfxModule("sc", {pFact}),
119  m_aIdleTimer("sc ScModule IdleTimer"),
120  m_aSpellIdle("sc ScModule SpellIdle"),
121  m_pDragData(new ScDragData),
122  m_pSelTransfer( nullptr ),
123  m_pMessagePool( nullptr ),
124  m_pRefInputHandler( nullptr ),
125  m_nCurRefDlgId( 0 ),
126  m_bIsWaterCan( false ),
127  m_bIsInEditCommand( false ),
128  m_bIsInExecuteDrop( false ),
129  m_bIsInSharedDocLoading( false ),
130  m_bIsInSharedDocSaving( false )
131 {
132  // The ResManager (DLL data) is not yet initialized in the ctor!
133  SetName("StarCalc"); // for Basic
134 
135  ResetDragObject();
136 
137  // InputHandler does not need to be created
138 
139  // Create ErrorHandler - was in Init()
140  // Between OfficeApplication::Init and ScGlobal::Init
142  m_pErrorHdl.reset( new SfxErrorHandler(RID_ERRHDLSC,
143  ErrCodeArea::Sc,
144  ErrCodeArea::Sc,
145  GetResLocale()) );
146 
147  m_aSpellIdle.SetInvokeHandler( LINK( this, ScModule, SpellTimerHdl ) );
148 
149  m_aIdleTimer.SetTimeout(SC_IDLE_MIN);
150  m_aIdleTimer.SetInvokeHandler( LINK( this, ScModule, IdleHandler ) );
151  m_aIdleTimer.Start();
152 
153  m_pMessagePool = new ScMessagePool;
154  m_pMessagePool->FreezeIdRanges();
155  SetPool( m_pMessagePool );
156  ScGlobal::InitTextHeight( m_pMessagePool );
157 
158  StartListening( *SfxGetpApp() ); // for SfxHintId::Deinitializing
159 }
160 
162 {
163  OSL_ENSURE( !m_pSelTransfer, "Selection Transfer object not deleted" );
164 
165  // InputHandler does not need to be deleted (there's none in the App anymore)
166 
168 
169  m_pDragData.reset();
170  m_pErrorHdl.reset();
171 
172  ScGlobal::Clear(); // Also calls ScDocumentPool::DeleteVersionMaps();
173 
174  DeleteCfg(); // Called from Exit()
175 }
176 
178 {
179  if ( p == m_pColorConfig.get() || p == m_pAccessOptions.get() )
180  {
181  // Test if detective objects have to be updated with new colors
182  // (if the detective colors haven't been used yet, there's nothing to update)
184  {
185  const svtools::ColorConfig& rColors = GetColorConfig();
186  bool bArrows =
189  bool bComments =
191  if ( bArrows || bComments )
192  {
193  ScDetectiveFunc::InitializeColors(); // get the new colors
194 
195  // update detective objects in all open documents
197  while ( pObjSh )
198  {
199  if ( dynamic_cast<const ScDocShell * >(pObjSh) != nullptr )
200  {
201  ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
202  if ( bArrows )
203  ScDetectiveFunc( &pDocSh->GetDocument(), 0 ).UpdateAllArrowColors();
204  if ( bComments )
206  }
207  pObjSh = SfxObjectShell::GetNext( *pObjSh );
208  }
209  }
210  }
211 
212  // force all views to repaint, using the new options
213  SfxViewShell* pViewShell = SfxViewShell::GetFirst();
214  while(pViewShell)
215  {
216  if (ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(pViewShell))
217  {
218  pViewSh->PaintGrid();
219  pViewSh->PaintTop();
220  pViewSh->PaintLeft();
221  pViewSh->PaintExtras();
222 
223  ScInputHandler* pHdl = pViewSh->GetInputHandler();
224  if ( pHdl )
225  pHdl->ForgetLastPattern(); // EditEngine BackgroundColor may change
226  }
227  else if ( dynamic_cast<const ScPreviewShell*>( pViewShell) != nullptr )
228  {
229  vcl::Window* pWin = pViewShell->GetWindow();
230  if (pWin)
231  pWin->Invalidate();
232  }
233  pViewShell = SfxViewShell::GetNext( *pViewShell );
234  }
235  }
236  else if ( p == m_pCTLOptions.get() )
237  {
238  // for all documents: set digit language for printer, recalc output factor, update row heights
240  while ( pObjSh )
241  {
242  if ( dynamic_cast<const ScDocShell *>(pObjSh) != nullptr )
243  {
244  ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh);
245  OutputDevice* pPrinter = pDocSh->GetPrinter();
246  if ( pPrinter )
247  pPrinter->SetDigitLanguage( GetOptDigitLanguage() );
248 
249  pDocSh->CalcOutputFactor();
250 
251  SCTAB nTabCount = pDocSh->GetDocument().GetTableCount();
252  for (SCTAB nTab=0; nTab<nTabCount; nTab++)
253  pDocSh->AdjustRowHeight( 0, pDocSh->GetDocument().MaxRow(), nTab );
254  }
255  pObjSh = SfxObjectShell::GetNext( *pObjSh );
256  }
257 
258  // for all views (table and preview): update digit language
260  while ( pSh )
261  {
262  if (ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(pSh))
263  {
264  // set ref-device for EditEngine (re-evaluates digit settings)
265  ScInputHandler* pHdl = GetInputHdl(pViewSh);
266  if (pHdl)
267  pHdl->UpdateRefDevice();
268 
269  pViewSh->DigitLanguageChanged();
270  pViewSh->PaintGrid();
271  }
272  else if (ScPreviewShell* pPreviewSh = dynamic_cast<ScPreviewShell*>(pSh))
273  {
274  ScPreview* pPreview = pPreviewSh->GetPreview();
275 
276  pPreview->SetDigitLanguage( GetOptDigitLanguage() );
277  pPreview->Invalidate();
278  }
279 
280  pSh = SfxViewShell::GetNext( *pSh );
281  }
282  }
283 }
284 
286 {
287  if ( rHint.GetId() == SfxHintId::Deinitializing )
288  {
289  // ConfigItems must be removed before ConfigManager
290  DeleteCfg();
291  }
292 }
293 
295 {
296  m_pViewCfg.reset(); // Saving happens automatically before Exit()
297  m_pDocCfg.reset();
298  m_pAppCfg.reset();
299  m_pDefaultsCfg.reset();
300  m_pFormulaCfg.reset();
301  m_pInputCfg.reset();
302  m_pPrintCfg.reset();
303  m_pNavipiCfg.reset();
304  m_pAddInCfg.reset();
305 
306  if ( m_pColorConfig )
307  {
308  m_pColorConfig->RemoveListener(this);
309  m_pColorConfig.reset();
310  }
311  if ( m_pAccessOptions )
312  {
313  m_pAccessOptions->RemoveListener(this);
314  m_pAccessOptions.reset();
315  }
316  if ( m_pCTLOptions )
317  {
318  m_pCTLOptions->RemoveListener(this);
319  m_pCTLOptions.reset();
320  }
321  m_pUserOptions.reset();
322 }
323 
324 // Moved here from the App
325 
327 {
328  SfxViewFrame* pViewFrm = SfxViewFrame::Current();
329  SfxBindings* pBindings = pViewFrm ? &pViewFrm->GetBindings() : nullptr;
330 
331  const SfxItemSet* pReqArgs = rReq.GetArgs();
332  sal_uInt16 nSlot = rReq.GetSlot();
333 
334  switch ( nSlot )
335  {
336  case SID_CHOOSE_DESIGN:
337  SfxApplication::CallAppBasic( "Template.Samples.ShowStyles" );
338  break;
339  case SID_EURO_CONVERTER:
340  SfxApplication::CallAppBasic( "Euro.ConvertRun.Main" );
341  break;
342  case SID_AUTOSPELL_CHECK:
343  {
344  bool bSet;
345  const SfxPoolItem* pItem;
346  if ( pReqArgs && SfxItemState::SET == pReqArgs->GetItemState( nSlot, true, &pItem ) )
347  bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
348  else
349  { // Toggle
350  ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() );
351  if ( pDocSh )
352  bSet = !pDocSh->GetDocument().GetDocOptions().IsAutoSpell();
353  else
354  bSet = !GetDocOptions().IsAutoSpell();
355  }
356 
358  aSet.Put( SfxBoolItem( SID_AUTOSPELL_CHECK, bSet ) );
359  ModifyOptions( aSet );
360  rReq.Done();
361  }
362  break;
363 
364  case SID_ATTR_METRIC:
365  {
366  const SfxPoolItem* pItem;
367  if ( pReqArgs && SfxItemState::SET == pReqArgs->GetItemState( nSlot, true, &pItem ) )
368  {
369  FieldUnit eUnit = static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
370  switch( eUnit )
371  {
372  case FieldUnit::MM: // Just the units that are also in the dialog
373  case FieldUnit::CM:
374  case FieldUnit::INCH:
375  case FieldUnit::PICA:
376  case FieldUnit::POINT:
377  {
378  PutItem( *pItem );
379  ScAppOptions aNewOpts( GetAppOptions() );
380  aNewOpts.SetAppMetric( eUnit );
381  SetAppOptions( aNewOpts );
382  rReq.Done();
383  }
384  break;
385  default:
386  {
387  // added to avoid warnings
388  }
389  }
390  }
391  }
392  break;
393 
394  case FID_AUTOCOMPLETE:
395  {
396  ScAppOptions aNewOpts( GetAppOptions() );
397  bool bNew = !aNewOpts.GetAutoComplete();
398  aNewOpts.SetAutoComplete( bNew );
399  SetAppOptions( aNewOpts );
401  if (pBindings)
402  pBindings->Invalidate( FID_AUTOCOMPLETE );
403  rReq.Done();
404  }
405  break;
406 
407  case SID_DETECTIVE_AUTO:
408  {
409  ScAppOptions aNewOpts( GetAppOptions() );
410  bool bNew = !aNewOpts.GetDetectiveAuto();
411  const SfxBoolItem* pAuto = rReq.GetArg<SfxBoolItem>(SID_DETECTIVE_AUTO);
412  if ( pAuto )
413  bNew = pAuto->GetValue();
414 
415  aNewOpts.SetDetectiveAuto( bNew );
416  SetAppOptions( aNewOpts );
417  if (pBindings)
418  pBindings->Invalidate( SID_DETECTIVE_AUTO );
419  rReq.AppendItem( SfxBoolItem( SID_DETECTIVE_AUTO, bNew ) );
420  rReq.Done();
421  }
422  break;
423 
424  case SID_PSZ_FUNCTION:
425  if (pReqArgs)
426  {
427  auto const & p = pReqArgs->Get(SID_PSZ_FUNCTION);
428  OSL_ENSURE(dynamic_cast<const SfxUInt32Item*>(&p) != nullptr,"wrong Parameter");
429  const SfxUInt32Item& rItem = static_cast<const SfxUInt32Item&>(p);
430 
431  ScAppOptions aNewOpts( GetAppOptions() );
432  aNewOpts.SetStatusFunc( rItem.GetValue() );
433  SetAppOptions( aNewOpts );
434 
435  if (pBindings)
436  {
437  pBindings->Invalidate( SID_TABLE_CELL );
438  pBindings->Update( SID_TABLE_CELL ); // Immediately
439 
440  pBindings->Invalidate( SID_PSZ_FUNCTION );
441  pBindings->Update( SID_PSZ_FUNCTION );
442  // If the menu is opened again immediately
443  }
444  }
445  break;
446 
447  case SID_ATTR_LANGUAGE:
448  case SID_ATTR_CHAR_CJK_LANGUAGE:
449  case SID_ATTR_CHAR_CTL_LANGUAGE:
450  {
451  const SfxPoolItem* pItem;
452  if ( pReqArgs && SfxItemState::SET == pReqArgs->GetItemState( GetPool().GetWhich(nSlot), true, &pItem ) )
453  {
454  ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() );
455  if ( pDocSh )
456  {
457  ScDocument& rDoc = pDocSh->GetDocument();
458  LanguageType eNewLang = static_cast<const SvxLanguageItem*>(pItem)->GetLanguage();
459  LanguageType eLatin, eCjk, eCtl;
460  rDoc.GetLanguage( eLatin, eCjk, eCtl );
461  LanguageType eOld = ( nSlot == SID_ATTR_CHAR_CJK_LANGUAGE ) ? eCjk :
462  ( ( nSlot == SID_ATTR_CHAR_CTL_LANGUAGE ) ? eCtl : eLatin );
463  if ( eNewLang != eOld )
464  {
465  if ( nSlot == SID_ATTR_CHAR_CJK_LANGUAGE )
466  eCjk = eNewLang;
467  else if ( nSlot == SID_ATTR_CHAR_CTL_LANGUAGE )
468  eCtl = eNewLang;
469  else
470  eLatin = eNewLang;
471 
472  rDoc.SetLanguage( eLatin, eCjk, eCtl );
473 
474  ScInputHandler* pInputHandler = GetInputHdl();
475  if ( pInputHandler )
476  pInputHandler->UpdateSpellSettings(); // EditEngine flags
477  ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
478  if ( pViewSh )
479  pViewSh->UpdateDrawTextOutliner(); // EditEngine flags
480 
481  pDocSh->SetDocumentModified();
482  }
483  }
484  }
485  }
486  break;
487 
488  case FID_FOCUS_POSWND:
489  {
490  ScInputHandler* pHdl = GetInputHdl();
491  if (pHdl)
492  {
493  ScInputWindow* pWin = pHdl->GetInputWindow();
494  if (pWin)
495  pWin->PosGrabFocus();
496  }
497  rReq.Done();
498  }
499  break;
500 
501  case SID_OPEN_XML_FILTERSETTINGS:
502  {
503  try
504  {
505  css::uno::Reference < css::ui::dialogs::XExecutableDialog > xDialog = css::ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext());
506  xDialog->execute();
507  }
508  catch( css::uno::RuntimeException& )
509  {
510  DBG_UNHANDLED_EXCEPTION("sc.ui");
511  }
512  }
513  break;
514 
515  default:
516  OSL_FAIL( "ScApplication: Unknown Message." );
517  break;
518  }
519 }
520 
522 {
523  ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() );
524  bool bTabView = pDocSh && (pDocSh->GetBestViewShell() != nullptr);
525 
526  SfxWhichIter aIter(rSet);
527  for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich())
528  {
529  if (!bTabView)
530  {
531  // Not in the normal calc view shell (most likely in preview shell). Disable all actions.
532  rSet.DisableItem(nWhich);
533  continue;
534  }
535 
536  switch ( nWhich )
537  {
538  case FID_AUTOCOMPLETE:
539  rSet.Put( SfxBoolItem( nWhich, GetAppOptions().GetAutoComplete() ) );
540  break;
541  case SID_DETECTIVE_AUTO:
542  rSet.Put( SfxBoolItem( nWhich, GetAppOptions().GetDetectiveAuto() ) );
543  break;
544  case SID_PSZ_FUNCTION:
545  rSet.Put( SfxUInt32Item( nWhich, GetAppOptions().GetStatusFunc() ) );
546  break;
547  case SID_ATTR_METRIC:
548  rSet.Put( SfxUInt16Item( nWhich, sal::static_int_cast<sal_uInt16>(GetAppOptions().GetAppMetric()) ) );
549  break;
550  case SID_AUTOSPELL_CHECK:
551  rSet.Put( SfxBoolItem( nWhich, pDocSh->GetDocument().GetDocOptions().IsAutoSpell()) );
552  break;
553  case SID_ATTR_LANGUAGE:
554  case ATTR_CJK_FONT_LANGUAGE: // WID for SID_ATTR_CHAR_CJK_LANGUAGE
555  case ATTR_CTL_FONT_LANGUAGE: // WID for SID_ATTR_CHAR_CTL_LANGUAGE
556  {
557  LanguageType eLatin, eCjk, eCtl;
558  pDocSh->GetDocument().GetLanguage( eLatin, eCjk, eCtl );
559  LanguageType eLang = ( nWhich == ATTR_CJK_FONT_LANGUAGE ) ? eCjk :
560  ( ( nWhich == ATTR_CTL_FONT_LANGUAGE ) ? eCtl : eLatin );
561  rSet.Put( SvxLanguageItem( eLang, nWhich ) );
562  }
563  break;
564  }
565  }
566 }
567 
569 {
570  if( SfxViewFrame* pViewFrm = SfxViewFrame::Current() )
571  {
572  SfxBindings& rBindings = pViewFrm->GetBindings();
573  SfxWhichIter aIter( rSet );
574  for( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich != 0; nWhich = aIter.NextWhich() )
575  {
576  ScViewUtil::HideDisabledSlot( rSet, rBindings, nWhich );
577  // always disable the slots
578  rSet.DisableItem( nWhich );
579  }
580  }
581 }
582 
584 {
585  m_pDragData->pCellTransfer = nullptr;
586  m_pDragData->pDrawTransfer = nullptr;
587  m_pDragData->pJumpLocalDoc = nullptr;
588  m_pDragData->aLinkDoc.clear();
589  m_pDragData->aLinkTable.clear();
590  m_pDragData->aLinkArea.clear();
591  m_pDragData->aJumpTarget.clear();
592  m_pDragData->aJumpText.clear();
593 }
594 
596 {
597  ResetDragObject();
598  m_pDragData->pCellTransfer = pCellObj;
599  m_pDragData->pDrawTransfer = pDrawObj;
600 }
601 
603  const OUString& rDoc, const OUString& rTab, const OUString& rArea )
604 {
605  ResetDragObject();
606  m_pDragData->aLinkDoc = rDoc;
607  m_pDragData->aLinkTable = rTab;
608  m_pDragData->aLinkArea = rArea;
609 }
610 
612  ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText )
613 {
614  ResetDragObject();
615 
616  m_pDragData->pJumpLocalDoc = pLocalDoc;
617  m_pDragData->aJumpTarget = rTarget;
618  m_pDragData->aJumpText = rText;
619 }
620 
622 {
623  // called from document
624  SfxViewFrame* pViewFrame = nullptr;
625  ScTabViewShell* pViewShell = nullptr;
626  css::uno::Reference<css::datatransfer::XTransferable2> xTransferable;
627 
628  if ((pViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current())))
629  xTransferable.set(ScTabViewShell::GetClipData(pViewShell->GetViewData().GetActiveWin()));
630  else if ((pViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::GetFirst())))
631  xTransferable.set(ScTabViewShell::GetClipData(pViewShell->GetViewData().GetActiveWin()));
632  else if ((pViewFrame = SfxViewFrame::GetFirst()))
633  {
634  css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard =
635  pViewFrame->GetWindow().GetClipboard();
636  xTransferable.set(xClipboard.is() ? xClipboard->getContents() : nullptr, css::uno::UNO_QUERY);
637  }
638 
639  const ScTransferObj* pObj = ScTransferObj::GetOwnClipboard(xTransferable);
640  if (pObj)
641  {
642  ScDocument* pDoc = pObj->GetDocument();
643  assert((!pDoc || pDoc->IsClipboard()) && "Document is not clipboard, how can that be?");
644  return pDoc;
645  }
646 
647  return nullptr;
648 }
649 
651 {
652  m_pSelTransfer = pNew;
653 }
654 
656 {
657  if ( !m_pViewCfg )
658  m_pViewCfg.reset(new ScViewCfg);
659 
660  m_pViewCfg->SetOptions( rOpt );
661 }
662 
664 {
665  if ( !m_pViewCfg )
666  m_pViewCfg.reset( new ScViewCfg );
667 
668  return *m_pViewCfg;
669 }
670 
672 {
673  if ( !m_pDocCfg )
674  m_pDocCfg.reset( new ScDocCfg );
675 
676  m_pDocCfg->SetOptions( rOpt );
677 }
678 
680 {
681  if ( !m_pDocCfg )
682  m_pDocCfg.reset( new ScDocCfg );
683 
684  return *m_pDocCfg;
685 }
686 
687 void ScModule::InsertEntryToLRUList(sal_uInt16 nFIndex)
688 {
689  if(nFIndex == 0)
690  return;
691 
692  const ScAppOptions& rAppOpt = GetAppOptions();
693  sal_uInt16 nLRUFuncCount = std::min( rAppOpt.GetLRUFuncListCount(), sal_uInt16(LRU_MAX) );
694  sal_uInt16* pLRUListIds = rAppOpt.GetLRUFuncList();
695 
696  sal_uInt16 aIdxList[LRU_MAX];
697  sal_uInt16 n = 0;
698  bool bFound = false;
699 
700  while ((n < LRU_MAX) && n<nLRUFuncCount) // Iterate through old list
701  {
702  if (!bFound && (pLRUListIds[n]== nFIndex))
703  bFound = true; // First hit!
704  else if (bFound)
705  aIdxList[n ] = pLRUListIds[n]; // Copy after hit
706  else if ((n+1) < LRU_MAX)
707  aIdxList[n+1] = pLRUListIds[n]; // Move before hit
708  n++;
709  }
710  if (!bFound && (n < LRU_MAX)) // Entry not found?
711  n++; // One more
712  aIdxList[0] = nFIndex; // Current on Top
713 
714  ScAppOptions aNewOpts(rAppOpt); // Let App know
715  aNewOpts.SetLRUFuncList(aIdxList, n);
716  SetAppOptions(aNewOpts);
717 }
718 
720 {
721  if ( !m_pAppCfg )
722  m_pAppCfg.reset( new ScAppCfg );
723 
724  m_pAppCfg->SetOptions( rOpt );
725 }
726 
728 {
729  SC_MOD()->GetAppOptions();
730 }
731 
733 {
734  if ( !m_pAppCfg )
735  m_pAppCfg.reset( new ScAppCfg );
736 
737  return *m_pAppCfg;
738 }
739 
741 {
742  if ( !m_pDefaultsCfg )
743  m_pDefaultsCfg.reset( new ScDefaultsCfg );
744 
745  m_pDefaultsCfg->SetOptions( rOpt );
746 }
747 
749 {
750  if ( !m_pDefaultsCfg )
751  m_pDefaultsCfg.reset( new ScDefaultsCfg );
752 
753  return *m_pDefaultsCfg;
754 }
755 
757 {
758  if ( !m_pFormulaCfg )
759  m_pFormulaCfg.reset( new ScFormulaCfg );
760 
761  m_pFormulaCfg->SetOptions( rOpt );
762 }
763 
765 {
766  if ( !m_pFormulaCfg )
767  m_pFormulaCfg.reset( new ScFormulaCfg );
768 
769  return *m_pFormulaCfg;
770 }
771 
773 {
774  if ( !m_pInputCfg )
775  m_pInputCfg.reset( new ScInputCfg );
776 
777  m_pInputCfg->SetOptions( rOpt );
778 }
779 
781 {
782  if ( !m_pInputCfg )
783  m_pInputCfg.reset( new ScInputCfg );
784 
785  return *m_pInputCfg;
786 }
787 
789 {
790  if ( !m_pPrintCfg )
791  m_pPrintCfg.reset( new ScPrintCfg );
792 
793  m_pPrintCfg->SetOptions( rOpt );
794 }
795 
797 {
798  if ( !m_pPrintCfg )
799  m_pPrintCfg.reset( new ScPrintCfg );
800 
801  return *m_pPrintCfg;
802 }
803 
805 {
806  if ( !m_pNavipiCfg )
807  m_pNavipiCfg.reset( new ScNavipiCfg );
808 
809  return *m_pNavipiCfg;
810 }
811 
813 {
814  if ( !m_pAddInCfg )
815  m_pAddInCfg.reset( new ScAddInCfg );
816 
817  return *m_pAddInCfg;
818 }
819 
821 {
822  if ( !m_pColorConfig )
823  {
825  m_pColorConfig->AddListener(this);
826  }
827 
828  return *m_pColorConfig;
829 }
830 
832 {
833  if ( !m_pAccessOptions )
834  {
836  m_pAccessOptions->AddListener(this);
837  }
838 
839  return *m_pAccessOptions;
840 }
841 
843 {
844  if ( !m_pCTLOptions )
845  {
846  m_pCTLOptions.reset( new SvtCTLOptions );
847  m_pCTLOptions->AddListener(this);
848  }
849 
850  return *m_pCTLOptions;
851 }
852 
854 {
855  if( !m_pUserOptions )
856  {
857  m_pUserOptions.reset( new SvtUserOptions );
858  }
859  return *m_pUserOptions;
860 }
861 
863 {
865  return ( eNumerals == SvtCTLOptions::NUMERALS_ARABIC ) ? LANGUAGE_ENGLISH_US :
868 }
869 
875 void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
876 {
877  LanguageType nOldSpellLang, nOldCjkLang, nOldCtlLang;
878  bool bOldAutoSpell;
879  GetSpellSettings( nOldSpellLang, nOldCjkLang, nOldCtlLang, bOldAutoSpell );
880 
881  if (!m_pAppCfg)
882  GetAppOptions();
883  OSL_ENSURE( m_pAppCfg, "AppOptions not initialised :-(" );
884 
885  if (!m_pInputCfg)
886  GetInputOptions();
887  OSL_ENSURE( m_pInputCfg, "InputOptions not initialised :-(" );
888 
889  SfxViewFrame* pViewFrm = SfxViewFrame::Current();
890  SfxBindings* pBindings = pViewFrm ? &pViewFrm->GetBindings() : nullptr;
891 
892  ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() );
893  ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() );
894  ScDocument* pDoc = pDocSh ? &pDocSh->GetDocument() : nullptr;
895  const SfxPoolItem* pItem = nullptr;
896  bool bRepaint = false;
897  bool bUpdateMarks = false;
898  bool bUpdateRefDev = false;
899  bool bCalcAll = false;
900  bool bSaveAppOptions = false;
901  bool bSaveInputOptions = false;
902  bool bCompileErrorCells = false;
903 
904  // SfxGetpApp()->SetOptions( rOptSet );
905 
906  // No more linguistics
907  if (rOptSet.HasItem(SID_ATTR_METRIC, &pItem))
908  {
909  PutItem( *pItem );
910  m_pAppCfg->SetAppMetric( static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()) );
911  bSaveAppOptions = true;
912  }
913 
914  if (rOptSet.HasItem(SCITEM_USERLIST, &pItem))
915  {
916  ScGlobal::SetUserList( static_cast<const ScUserListItem*>(pItem)->GetUserList() );
917  bSaveAppOptions = true;
918  }
919 
920  if (rOptSet.HasItem(SID_SC_OPT_SYNCZOOM, &pItem))
921  {
922  m_pAppCfg->SetSynchronizeZoom( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
923  bSaveAppOptions = true;
924  }
925 
926  if (rOptSet.HasItem(SID_SC_OPT_KEY_BINDING_COMPAT, &pItem))
927  {
928  sal_uInt16 nVal = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
929  ScOptionsUtil::KeyBindingType eOld = m_pAppCfg->GetKeyBindingType();
931  if (eOld != eNew)
932  {
933  m_pAppCfg->SetKeyBindingType(eNew);
934  bSaveAppOptions = true;
936  }
937  }
938 
939  // DefaultsOptions
940  if (rOptSet.HasItem(SID_SCDEFAULTSOPTIONS, &pItem))
941  {
942  const ScDefaultsOptions& rOpt = static_cast<const ScTpDefaultsItem*>(pItem)->GetDefaultsOptions();
943  SetDefaultsOptions( rOpt );
944  }
945 
946  // FormulaOptions
947  if (rOptSet.HasItem(SID_SCFORMULAOPTIONS, &pItem))
948  {
949  const ScFormulaOptions& rOpt = static_cast<const ScTpFormulaItem*>(pItem)->GetFormulaOptions();
950 
951  if (!m_pFormulaCfg || (*m_pFormulaCfg != rOpt))
952  // Formula options have changed. Repaint the column headers.
953  bRepaint = true;
954 
955  if (m_pFormulaCfg && m_pFormulaCfg->GetUseEnglishFuncName() != rOpt.GetUseEnglishFuncName())
956  {
957  // Re-compile formula cells with error as the error may have been
958  // caused by unresolved function names.
959  bCompileErrorCells = true;
960  }
961 
962  // Recalc for interpreter options changes.
963  if (m_pFormulaCfg && m_pFormulaCfg->GetCalcConfig() != rOpt.GetCalcConfig())
964  bCalcAll = true;
965 
966  if ( pDocSh )
967  {
968  pDocSh->SetFormulaOptions( rOpt );
969  pDocSh->SetDocumentModified();
970  }
971 
972  // ScDocShell::SetFormulaOptions() may check for changed settings, so
973  // set the new options here after that has been called.
974  if (!bCalcAll || rOpt.GetWriteCalcConfig())
975  {
976  // CalcConfig is new, didn't change or is global, simply set all.
977  SetFormulaOptions( rOpt );
978  }
979  else
980  {
981  // If "only for current document" was checked, reset those affected
982  // by that setting to previous values.
983  ScFormulaOptions aNewOpt( rOpt);
984  aNewOpt.GetCalcConfig().MergeDocumentSpecific( m_pFormulaCfg->GetCalcConfig());
985  SetFormulaOptions( aNewOpt);
986  }
987  }
988 
989  // ViewOptions
990  if (rOptSet.HasItem(SID_SCVIEWOPTIONS, &pItem))
991  {
992  const ScViewOptions& rNewOpt = static_cast<const ScTpViewItem*>(pItem)->GetViewOptions();
993 
994  if ( pViewSh )
995  {
996  ScViewData& rViewData = pViewSh->GetViewData();
997  const ScViewOptions& rOldOpt = rViewData.GetOptions();
998 
999  bool bAnchorList = ( rOldOpt.GetOption( VOPT_ANCHOR ) !=
1000  rNewOpt.GetOption( VOPT_ANCHOR ) );
1001 
1002  if ( rOldOpt != rNewOpt )
1003  {
1004  rViewData.SetOptions( rNewOpt ); // Changes rOldOpt
1005  rViewData.GetDocument()->SetViewOptions( rNewOpt );
1006  if (pDocSh)
1007  pDocSh->SetDocumentModified();
1008  bRepaint = true;
1009  }
1010  if ( bAnchorList )
1011  pViewSh->UpdateAnchorHandles();
1012  }
1013  SetViewOptions( rNewOpt );
1014  if (pBindings)
1015  {
1016  pBindings->Invalidate(SID_HELPLINES_MOVE);
1017  }
1018  }
1019 
1020  // GridOptions
1021  // Evaluate after ViewOptions, as GridOptions is a member of ViewOptions
1022  if ( rOptSet.HasItem(SID_ATTR_GRID_OPTIONS,&pItem) )
1023  {
1024  ScGridOptions aNewGridOpt( static_cast<const SvxGridItem&>(*pItem ));
1025 
1026  if ( pViewSh )
1027  {
1028  ScViewData& rViewData = pViewSh->GetViewData();
1029  ScViewOptions aNewViewOpt( rViewData.GetOptions() );
1030  const ScGridOptions& rOldGridOpt = aNewViewOpt.GetGridOptions();
1031 
1032  if ( rOldGridOpt != aNewGridOpt )
1033  {
1034  aNewViewOpt.SetGridOptions( aNewGridOpt );
1035  rViewData.SetOptions( aNewViewOpt );
1036  rViewData.GetDocument()->SetViewOptions( aNewViewOpt );
1037  if (pDocSh)
1038  pDocSh->SetDocumentModified();
1039  bRepaint = true;
1040  }
1041  }
1042  ScViewOptions aNewViewOpt ( GetViewOptions() );
1043  aNewViewOpt.SetGridOptions( aNewGridOpt );
1044  SetViewOptions( aNewViewOpt );
1045  if (pBindings)
1046  {
1047  pBindings->Invalidate(SID_GRID_VISIBLE);
1048  pBindings->Invalidate(SID_GRID_USE);
1049  }
1050  }
1051 
1052  // DocOptions
1053  if ( rOptSet.HasItem(SID_SCDOCOPTIONS,&pItem) )
1054  {
1055  const ScDocOptions& rNewOpt = static_cast<const ScTpCalcItem*>(pItem)->GetDocOptions();
1056 
1057  if ( pDoc )
1058  {
1059  const ScDocOptions& rOldOpt = pDoc->GetDocOptions();
1060 
1061  bRepaint = ( bRepaint || ( rOldOpt != rNewOpt ) );
1062  bCalcAll = bRepaint &&
1063  ( rOldOpt.IsIter() != rNewOpt.IsIter()
1064  || rOldOpt.GetIterCount() != rNewOpt.GetIterCount()
1065  || rOldOpt.GetIterEps() != rNewOpt.GetIterEps()
1066  || rOldOpt.IsIgnoreCase() != rNewOpt.IsIgnoreCase()
1067  || rOldOpt.IsCalcAsShown() != rNewOpt.IsCalcAsShown()
1068  || (rNewOpt.IsCalcAsShown() &&
1069  rOldOpt.GetStdPrecision() != rNewOpt.GetStdPrecision())
1070  || rOldOpt.IsMatchWholeCell() != rNewOpt.IsMatchWholeCell()
1071  || rOldOpt.GetYear2000() != rNewOpt.GetYear2000()
1072  || rOldOpt.IsFormulaRegexEnabled() != rNewOpt.IsFormulaRegexEnabled()
1073  || rOldOpt.IsFormulaWildcardsEnabled() != rNewOpt.IsFormulaWildcardsEnabled()
1074  );
1075  pDoc->SetDocOptions( rNewOpt );
1076  pDocSh->SetDocumentModified();
1077  }
1078  SetDocOptions( rNewOpt );
1079  }
1080 
1081  // Set TabDistance after the actual DocOptions
1082  if ( rOptSet.HasItem(SID_ATTR_DEFTABSTOP,&pItem) )
1083  {
1084  sal_uInt16 nTabDist = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1085  ScDocOptions aOpt(GetDocOptions());
1086  aOpt.SetTabDistance(nTabDist);
1087  SetDocOptions( aOpt );
1088 
1089  if ( pDoc )
1090  {
1091  ScDocOptions aDocOpt(pDoc->GetDocOptions());
1092  aDocOpt.SetTabDistance(nTabDist);
1093  pDoc->SetDocOptions( aDocOpt );
1094  pDocSh->SetDocumentModified();
1095  if(pDoc->GetDrawLayer())
1096  pDoc->GetDrawLayer()->SetDefaultTabulator(nTabDist);
1097  }
1098  }
1099 
1100  // AutoSpell after the DocOptions (due to being a member)
1101  if ( rOptSet.HasItem(SID_AUTOSPELL_CHECK,&pItem) ) // At DocOptions
1102  {
1103  bool bDoAutoSpell = static_cast<const SfxBoolItem*>(pItem)->GetValue();
1104 
1105  if (pDoc)
1106  {
1107  ScDocOptions aNewOpt = pDoc->GetDocOptions();
1108  if ( aNewOpt.IsAutoSpell() != bDoAutoSpell )
1109  {
1110  aNewOpt.SetAutoSpell( bDoAutoSpell );
1111  pDoc->SetDocOptions( aNewOpt );
1112 
1113  if (pViewSh)
1114  pViewSh->EnableAutoSpell(bDoAutoSpell);
1115 
1116  bRepaint = true; // Because HideAutoSpell might be invalid
1117  //TODO: Paint all Views?
1118  }
1119  }
1120 
1121  if ( bOldAutoSpell != bDoAutoSpell )
1122  SetAutoSpellProperty( bDoAutoSpell );
1123  if ( pDocSh )
1124  pDocSh->PostPaintGridAll(); // Due to marks
1125  ScInputHandler* pInputHandler = GetInputHdl();
1126  if ( pInputHandler )
1127  pInputHandler->UpdateSpellSettings(); // EditEngine flags
1128  if ( pViewSh )
1129  pViewSh->UpdateDrawTextOutliner(); // EditEngine flags
1130 
1131  if (pBindings)
1132  pBindings->Invalidate( SID_AUTOSPELL_CHECK );
1133  }
1134 
1135  // InputOptions
1136  if ( rOptSet.HasItem(SID_SC_INPUT_SELECTIONPOS,&pItem) )
1137  {
1138  m_pInputCfg->SetMoveDir( static_cast<const SfxUInt16Item*>(pItem)->GetValue() );
1139  bSaveInputOptions = true;
1140  }
1141  if ( rOptSet.HasItem(SID_SC_INPUT_SELECTION,&pItem) )
1142  {
1143  m_pInputCfg->SetMoveSelection( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
1144  bSaveInputOptions = true;
1145  }
1146  if ( rOptSet.HasItem(SID_SC_INPUT_EDITMODE,&pItem) )
1147  {
1148  m_pInputCfg->SetEnterEdit( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
1149  bSaveInputOptions = true;
1150  }
1151  if ( rOptSet.HasItem(SID_SC_INPUT_FMT_EXPAND,&pItem) )
1152  {
1153  m_pInputCfg->SetExtendFormat( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
1154  bSaveInputOptions = true;
1155  }
1156  if ( rOptSet.HasItem(SID_SC_INPUT_RANGEFINDER,&pItem) )
1157  {
1158  m_pInputCfg->SetRangeFinder( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
1159  bSaveInputOptions = true;
1160  }
1161  if ( rOptSet.HasItem(SID_SC_INPUT_REF_EXPAND,&pItem) )
1162  {
1163  m_pInputCfg->SetExpandRefs( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
1164  bSaveInputOptions = true;
1165  }
1166  if (rOptSet.HasItem(SID_SC_OPT_SORT_REF_UPDATE, &pItem))
1167  {
1168  m_pInputCfg->SetSortRefUpdate(static_cast<const SfxBoolItem*>(pItem)->GetValue());
1169  bSaveInputOptions = true;
1170  }
1171 
1172  if ( rOptSet.HasItem(SID_SC_INPUT_MARK_HEADER,&pItem) )
1173  {
1174  m_pInputCfg->SetMarkHeader( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
1175  bSaveInputOptions = true;
1176  bUpdateMarks = true;
1177  }
1178  if ( rOptSet.HasItem(SID_SC_INPUT_TEXTWYSIWYG,&pItem) )
1179  {
1180  bool bNew = static_cast<const SfxBoolItem*>(pItem)->GetValue();
1181  if ( bNew != m_pInputCfg->GetTextWysiwyg() )
1182  {
1183  m_pInputCfg->SetTextWysiwyg( bNew );
1184  bSaveInputOptions = true;
1185  bUpdateRefDev = true;
1186  }
1187  }
1188  if( rOptSet.HasItem( SID_SC_INPUT_REPLCELLSWARN, &pItem ) )
1189  {
1190  m_pInputCfg->SetReplaceCellsWarn( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
1191  bSaveInputOptions = true;
1192  }
1193 
1194  if( rOptSet.HasItem( SID_SC_INPUT_LEGACY_CELL_SELECTION, &pItem ) )
1195  {
1196  m_pInputCfg->SetLegacyCellSelection( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
1197  bSaveInputOptions = true;
1198  }
1199 
1200  // PrintOptions
1201  if ( rOptSet.HasItem(SID_SCPRINTOPTIONS,&pItem) )
1202  {
1203  const ScPrintOptions& rNewOpt = static_cast<const ScTpPrintItem*>(pItem)->GetPrintOptions();
1204  SetPrintOptions( rNewOpt );
1205 
1206  // broadcast causes all previews to recalc page numbers
1207  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScPrintOptions ) );
1208  }
1209 
1210  if ( bSaveAppOptions )
1211  m_pAppCfg->OptionsChanged();
1212 
1213  if ( bSaveInputOptions )
1214  m_pInputCfg->OptionsChanged();
1215 
1216  // Kick off recalculation?
1217  if (pDoc && bCompileErrorCells)
1218  {
1219  // Re-compile cells with name error, and recalc if at least one cell
1220  // has been re-compiled. In the future we may want to find a way to
1221  // recalc only those that are affected.
1222  if (pDoc->CompileErrorCells(FormulaError::NoName))
1223  bCalcAll = true;
1224  }
1225 
1226  if ( pDoc && bCalcAll )
1227  {
1229  pDoc->CalcAll();
1230  if ( pViewSh )
1231  pViewSh->UpdateCharts( true );
1232  else
1233  ScDBFunc::DoUpdateCharts( ScAddress(), pDoc, true );
1234  if (pBindings)
1235  pBindings->Invalidate( SID_ATTR_SIZE ); //SvxPosSize StatusControl Update
1236  }
1237 
1238  if ( pViewSh && bUpdateMarks )
1239  pViewSh->UpdateAutoFillMark();
1240 
1241  // Repaint View?
1242  if ( pViewSh && bRepaint )
1243  {
1244  pViewSh->UpdateFixPos();
1245  pViewSh->PaintGrid();
1246  pViewSh->PaintTop();
1247  pViewSh->PaintLeft();
1248  pViewSh->PaintExtras();
1249  pViewSh->InvalidateBorder();
1250  if (pBindings)
1251  {
1252  pBindings->Invalidate( FID_TOGGLEHEADERS ); // -> Checks in menu
1253  pBindings->Invalidate( FID_TOGGLESYNTAX );
1254  }
1255  }
1256 
1257  // update ref device (for all documents)
1258  if ( !bUpdateRefDev )
1259  return;
1260 
1261  // for all documents: recalc output factor, update row heights
1263  while ( pObjSh )
1264  {
1265  if ( dynamic_cast<const ScDocShell *>(pObjSh) != nullptr )
1266  {
1267  ScDocShell* pOneDocSh = static_cast<ScDocShell*>(pObjSh);
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.
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 
1668 void ScModule::SetReference( const ScRange& rRef, ScDocument& rDoc,
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  bool bAutoSpell = false;
1819  ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(SfxObjectShell::Current());
1820 
1821  if ( pDocSh )
1822  {
1823  ScDocument& rDoc = pDocSh->GetDocument();
1824  bAutoSpell = rDoc.GetDocOptions().IsAutoSpell();
1825  if (pDocSh->IsReadOnly())
1826  bAutoSpell = false;
1827 
1828  sc::DocumentLinkManager& rLinkMgr = rDoc.GetDocLinkManager();
1829  bool bLinks = rLinkMgr.idleCheckLinks();
1830  bool bWidth = rDoc.IdleCalcTextWidth();
1831 
1832  bMore = bLinks || bWidth; // Still something at all?
1833 
1834  // While calculating a Basic formula, a paint event may have occurred,
1835  // so check the bNeedsRepaint flags for this document's views
1836  if (bWidth)
1837  lcl_CheckNeedsRepaint( pDocSh );
1838  }
1839 
1840  if (bAutoSpell)
1841  {
1842  ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
1843  if (pViewSh)
1844  {
1845  bool bSpell = pViewSh->ContinueOnlineSpelling();
1846  if (bSpell)
1847  {
1848  m_aSpellIdle.Start();
1849  bMore = true;
1850  }
1851  }
1852  }
1853 
1854  sal_uInt64 nOldTime = m_aIdleTimer.GetTimeout();
1855  sal_uInt64 nNewTime = nOldTime;
1856  if ( bMore )
1857  {
1858  nNewTime = SC_IDLE_MIN;
1859  nIdleCount = 0;
1860  }
1861  else
1862  {
1863  // Set SC_IDLE_COUNT to initial Timeout - increase afterwards
1864  if ( nIdleCount < SC_IDLE_COUNT )
1865  ++nIdleCount;
1866  else
1867  {
1868  nNewTime += SC_IDLE_STEP;
1869  if ( nNewTime > SC_IDLE_MAX )
1870  nNewTime = SC_IDLE_MAX;
1871  }
1872  }
1873  if ( nNewTime != nOldTime )
1874  m_aIdleTimer.SetTimeout( nNewTime );
1875 
1876 
1877  m_aIdleTimer.Start();
1878 }
1879 
1880 IMPL_LINK_NOARG(ScModule, SpellTimerHdl, Timer *, void)
1881 {
1882  if ( Application::AnyInput( VclInputFlags::KEYBOARD ) )
1883  {
1884  m_aSpellIdle.Start();
1885  return; // Later again ...
1886  }
1887 
1888  ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
1889  if (pViewSh)
1890  {
1891  if (pViewSh->ContinueOnlineSpelling())
1892  m_aSpellIdle.Start();
1893  }
1894 }
1895 
1899 std::unique_ptr<SfxItemSet> ScModule::CreateItemSet( sal_uInt16 nId )
1900 {
1901  std::unique_ptr<SfxItemSet> pRet;
1902  if(SID_SC_EDITOPTIONS == nId)
1903  {
1904  pRet = std::make_unique<SfxItemSet>(
1905  GetPool(),
1906  svl::Items<
1907  // TP_USERLISTS:
1909  // TP_GRID:
1910  SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS,
1911  SID_ATTR_METRIC, SID_ATTR_METRIC,
1912  SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
1913  // TP_INPUT:
1914  SID_SC_INPUT_LEGACY_CELL_SELECTION, SID_SC_OPT_SORT_REF_UPDATE,
1915  // TP_FORMULA, TP_DEFAULTS:
1916  SID_SCFORMULAOPTIONS, SID_SCDEFAULTSOPTIONS,
1917  // TP_VIEW, TP_CALC:
1918  SID_SCVIEWOPTIONS, SID_SCDOCOPTIONS,
1919  // TP_PRINT:
1920  SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS,
1921  // TP_INPUT:
1922  SID_SC_INPUT_SELECTION, SID_SC_INPUT_MARK_HEADER,
1923  SID_SC_INPUT_TEXTWYSIWYG, SID_SC_INPUT_TEXTWYSIWYG,
1924  SID_SC_INPUT_REPLCELLSWARN, SID_SC_INPUT_REPLCELLSWARN,
1925  // TP_VIEW:
1926  SID_SC_OPT_SYNCZOOM, SID_SC_OPT_KEY_BINDING_COMPAT>{});
1927 
1928  const ScAppOptions& rAppOpt = GetAppOptions();
1929 
1930  ScDocShell* pDocSh = dynamic_cast< ScDocShell *>( SfxObjectShell::Current() );
1931  ScDocOptions aCalcOpt = pDocSh
1932  ? pDocSh->GetDocument().GetDocOptions()
1933  : GetDocOptions();
1934 
1935  ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( SfxViewShell::Current() );
1936  ScViewOptions aViewOpt = pViewSh
1937  ? pViewSh->GetViewData().GetOptions()
1938  : GetViewOptions();
1939 
1940  ScUserListItem aULItem( SCITEM_USERLIST );
1942 
1943  // SfxGetpApp()->GetOptions( aSet );
1944 
1945  pRet->Put( SfxUInt16Item( SID_ATTR_METRIC,
1946  sal::static_int_cast<sal_uInt16>(rAppOpt.GetAppMetric()) ) );
1947 
1948  // TP_CALC
1949  pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP,
1950  aCalcOpt.GetTabDistance()));
1951  pRet->Put( ScTpCalcItem( SID_SCDOCOPTIONS, aCalcOpt ) );
1952 
1953  // TP_VIEW
1954  pRet->Put( ScTpViewItem( aViewOpt ) );
1955  pRet->Put( SfxBoolItem( SID_SC_OPT_SYNCZOOM, rAppOpt.GetSynchronizeZoom() ) );
1956 
1957  // TP_INPUT
1958  const ScInputOptions& rInpOpt = GetInputOptions();
1959  pRet->Put( SfxUInt16Item( SID_SC_INPUT_SELECTIONPOS,
1960  rInpOpt.GetMoveDir() ) );
1961  pRet->Put( SfxBoolItem( SID_SC_INPUT_SELECTION,
1962  rInpOpt.GetMoveSelection() ) );
1963  pRet->Put( SfxBoolItem( SID_SC_INPUT_EDITMODE,
1964  rInpOpt.GetEnterEdit() ) );
1965  pRet->Put( SfxBoolItem( SID_SC_INPUT_FMT_EXPAND,
1966  rInpOpt.GetExtendFormat() ) );
1967  pRet->Put( SfxBoolItem( SID_SC_INPUT_RANGEFINDER,
1968  rInpOpt.GetRangeFinder() ) );
1969  pRet->Put( SfxBoolItem( SID_SC_INPUT_REF_EXPAND,
1970  rInpOpt.GetExpandRefs() ) );
1971  pRet->Put( SfxBoolItem(SID_SC_OPT_SORT_REF_UPDATE, rInpOpt.GetSortRefUpdate()));
1972  pRet->Put( SfxBoolItem( SID_SC_INPUT_MARK_HEADER,
1973  rInpOpt.GetMarkHeader() ) );
1974  pRet->Put( SfxBoolItem( SID_SC_INPUT_TEXTWYSIWYG,
1975  rInpOpt.GetTextWysiwyg() ) );
1976  pRet->Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN,
1977  rInpOpt.GetReplaceCellsWarn() ) );
1978  pRet->Put( SfxBoolItem( SID_SC_INPUT_LEGACY_CELL_SELECTION,
1979  rInpOpt.GetLegacyCellSelection() ) );
1980 
1981  // RID_SC_TP_PRINT
1982  pRet->Put( ScTpPrintItem( GetPrintOptions() ) );
1983 
1984  // TP_GRID
1985  std::unique_ptr<SvxGridItem> pSvxGridItem = aViewOpt.CreateGridItem();
1986  pRet->Put( *pSvxGridItem );
1987  pSvxGridItem.reset();
1988 
1989  // TP_USERLISTS
1990  if ( pUL )
1991  {
1992  aULItem.SetUserList( *pUL );
1993  pRet->Put(aULItem);
1994  }
1995 
1996  // TP_COMPATIBILITY
1997  pRet->Put( SfxUInt16Item( SID_SC_OPT_KEY_BINDING_COMPAT,
1998  rAppOpt.GetKeyBindingType() ) );
1999 
2000  // TP_DEFAULTS
2001  pRet->Put( ScTpDefaultsItem( GetDefaultsOptions() ) );
2002 
2003  // TP_FORMULA
2004  ScFormulaOptions aOptions = GetFormulaOptions();
2005  if (pDocSh)
2006  {
2007  ScCalcConfig aConfig( aOptions.GetCalcConfig());
2008  aConfig.MergeDocumentSpecific( pDocSh->GetDocument().GetCalcConfig());
2009  aOptions.SetCalcConfig( aConfig);
2010  }
2011  pRet->Put( ScTpFormulaItem( aOptions ) );
2012  }
2013  return pRet;
2014 }
2015 
2016 void ScModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
2017 {
2018  if(SID_SC_EDITOPTIONS == nId)
2019  {
2020  ModifyOptions( rSet );
2021  }
2022 }
2023 
2024 std::unique_ptr<SfxTabPage> ScModule::CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet )
2025 {
2026  std::unique_ptr<SfxTabPage> xRet;
2028  switch(nId)
2029  {
2030  case SID_SC_TP_LAYOUT:
2031  {
2032  ::CreateTabPage ScTpLayoutOptionsCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_LAYOUT);
2033  if (ScTpLayoutOptionsCreate)
2034  xRet = (*ScTpLayoutOptionsCreate)(pPage, pController, &rSet);
2035  break;
2036  }
2037  case SID_SC_TP_CONTENT:
2038  {
2039  ::CreateTabPage ScTpContentOptionsCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_CONTENT);
2040  if (ScTpContentOptionsCreate)
2041  xRet = (*ScTpContentOptionsCreate)(pPage, pController, &rSet);
2042  break;
2043  }
2044  case SID_SC_TP_GRID:
2045  xRet = SvxGridTabPage::Create(pPage, pController, rSet);
2046  break;
2047  case SID_SC_TP_USERLISTS:
2048  {
2049  ::CreateTabPage ScTpUserListsCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_USERLISTS);
2050  if (ScTpUserListsCreate)
2051  xRet = (*ScTpUserListsCreate)(pPage, pController, &rSet);
2052  break;
2053  }
2054  case SID_SC_TP_CALC:
2055  {
2056  ::CreateTabPage ScTpCalcOptionsCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_CALC);
2057  if (ScTpCalcOptionsCreate)
2058  xRet = (*ScTpCalcOptionsCreate)(pPage, pController, &rSet);
2059  break;
2060  }
2061  case SID_SC_TP_FORMULA:
2062  {
2063  ::CreateTabPage ScTpFormulaOptionsCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_FORMULA);
2064  if (ScTpFormulaOptionsCreate)
2065  xRet = (*ScTpFormulaOptionsCreate)(pPage, pController, &rSet);
2066  break;
2067  }
2068  case SID_SC_TP_COMPATIBILITY:
2069  {
2070  ::CreateTabPage ScTpCompatOptionsCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_COMPATIBILITY);
2071  if (ScTpCompatOptionsCreate)
2072  xRet = (*ScTpCompatOptionsCreate)(pPage, pController, &rSet);
2073  break;
2074  }
2075  case SID_SC_TP_CHANGES:
2076  {
2077  ::CreateTabPage ScRedlineOptionsTabPageCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_CHANGES);
2078  if (ScRedlineOptionsTabPageCreate)
2079  xRet =(*ScRedlineOptionsTabPageCreate)(pPage, pController, &rSet);
2080  break;
2081  }
2082  case RID_SC_TP_PRINT:
2083  {
2084  ::CreateTabPage ScTpPrintOptionsCreate = pFact->GetTabPageCreatorFunc(RID_SC_TP_PRINT);
2085  if (ScTpPrintOptionsCreate)
2086  xRet = (*ScTpPrintOptionsCreate)(pPage, pController, &rSet);
2087  break;
2088  }
2089  case RID_SC_TP_DEFAULTS:
2090  {
2091  ::CreateTabPage ScTpDefaultsOptionsCreate = pFact->GetTabPageCreatorFunc(RID_SC_TP_DEFAULTS);
2092  if (ScTpDefaultsOptionsCreate)
2093  xRet = (*ScTpDefaultsOptionsCreate)(pPage, pController, &rSet);
2094  break;
2095  }
2096  }
2097 
2098  OSL_ENSURE( xRet, "ScModule::CreateTabPage(): no valid ID for TabPage!" );
2099 
2100  return xRet;
2101 }
2102 
2103 IMPL_LINK( ScModule, CalcFieldValueHdl, EditFieldInfo*, pInfo, void )
2104 {
2105  //TODO: Merge with ScFieldEditEngine!
2106  if (!pInfo)
2107  return;
2108 
2109  const SvxFieldItem& rField = pInfo->GetField();
2110  const SvxFieldData* pField = rField.GetField();
2111 
2112  if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
2113  {
2114  // URLField
2115  const OUString& aURL = pURLField->GetURL();
2116 
2117  switch ( pURLField->GetFormat() )
2118  {
2119  case SvxURLFormat::AppDefault: //TODO: Settable in the App?
2120  case SvxURLFormat::Repr:
2121  {
2122  pInfo->SetRepresentation( pURLField->GetRepresentation() );
2123  }
2124  break;
2125 
2126  case SvxURLFormat::Url:
2127  {
2128  pInfo->SetRepresentation( aURL );
2129  }
2130  break;
2131  }
2132 
2133  svtools::ColorConfigEntry eEntry =
2135  pInfo->SetTextColor( GetColorConfig().GetColorValue(eEntry).nColor );
2136  }
2137  else
2138  {
2139  OSL_FAIL("Unknown Field");
2140  pInfo->SetRepresentation(OUString('?'));
2141  }
2142 }
2143 
2144 void ScModule::RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr<SfxDialogController>& rWnd, weld::Window* pWndAncestor)
2145 {
2146  std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>> & rlRefWindow = m_mapRefController[nSlotId];
2147 
2148  if (std::find_if(rlRefWindow.begin(), rlRefWindow.end(),
2149  [rWnd](const std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>& rCandidate)
2150  {
2151  return rCandidate.first.get() == rWnd.get();
2152  }) == rlRefWindow.end())
2153  {
2154  rlRefWindow.emplace_back(rWnd, pWndAncestor);
2155  }
2156 }
2157 
2158 void ScModule::UnregisterRefController(sal_uInt16 nSlotId, const std::shared_ptr<SfxDialogController>& rWnd)
2159 {
2160  auto iSlot = m_mapRefController.find( nSlotId );
2161 
2162  if( iSlot == m_mapRefController.end() )
2163  return;
2164 
2165  std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>> & rlRefWindow = iSlot->second;
2166 
2167  auto i = std::find_if(rlRefWindow.begin(), rlRefWindow.end(),
2168  [rWnd](const std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>& rCandidate)
2169  {
2170  return rCandidate.first.get() == rWnd.get();
2171  });
2172 
2173  if( i == rlRefWindow.end() )
2174  return;
2175 
2176  rlRefWindow.erase( i );
2177 
2178  if( rlRefWindow.empty() )
2179  m_mapRefController.erase( nSlotId );
2180 }
2181 
2182 std::shared_ptr<SfxDialogController> ScModule::Find1RefWindow(sal_uInt16 nSlotId, const weld::Window *pWndAncestor)
2183 {
2184  if (!pWndAncestor)
2185  return nullptr;
2186 
2187  auto iSlot = m_mapRefController.find( nSlotId );
2188 
2189  if( iSlot == m_mapRefController.end() )
2190  return nullptr;
2191 
2192  std::vector<std::pair<std::shared_ptr<SfxDialogController>, weld::Window*>> & rlRefWindow = iSlot->second;
2193 
2194  for (auto const& refWindow : rlRefWindow)
2195  if ( refWindow.second == pWndAncestor )
2196  return refWindow.first;
2197 
2198  return nullptr;
2199 }
2200 
2201 using namespace com::sun::star;
2202 
2203 #define LINGUPROP_AUTOSPELL "IsSpellAuto"
2204 
2206  bool& rAutoSpell )
2207 {
2208  // use SvtLinguConfig instead of service LinguProperties to avoid
2209  // loading the linguistic component
2210  SvtLinguConfig aConfig;
2211 
2212  SvtLinguOptions aOptions;
2213  aConfig.GetOptions( aOptions );
2214 
2215  rDefLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage, css::i18n::ScriptType::LATIN);
2216  rCjkLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK, css::i18n::ScriptType::ASIAN);
2217  rCtlLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, css::i18n::ScriptType::COMPLEX);
2218  rAutoSpell = aOptions.bIsSpellAuto;
2219 }
2220 
2222 {
2223  // use SvtLinguConfig instead of service LinguProperties to avoid
2224  // loading the linguistic component
2225  SvtLinguConfig aConfig;
2226 
2227  aConfig.SetProperty( LINGUPROP_AUTOSPELL, uno::Any(bSet) );
2228 }
2229 
2231 {
2232  if ( nLang == LANGUAGE_NONE )
2233  return false;
2234 
2235  bool bHasLang = false;
2236  try
2237  {
2238  uno::Reference< linguistic2::XThesaurus > xThes(LinguMgr::GetThesaurus());
2239  if ( xThes.is() )
2240  bHasLang = xThes->hasLocale( LanguageTag::convertToLocale( nLang ) );
2241  }
2242  catch( uno::Exception& )
2243  {
2244  OSL_FAIL("Error in Thesaurus");
2245  }
2246 
2247  return bHasLang;
2248 }
2249 
2250 std::unique_ptr<SfxStyleFamilies> ScModule::CreateStyleFamilies()
2251 {
2252  std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
2253 
2254  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
2255  ScResId(STR_STYLE_FAMILY_CELL),
2256  BMP_STYLES_FAMILY_CELL,
2257  RID_CELLSTYLEFAMILY, SC_MOD()->GetResLocale()));
2258 
2259  pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Page,
2260  ScResId(STR_STYLE_FAMILY_PAGE),
2261  BMP_STYLES_FAMILY_PAGE,
2262  RID_PAGESTYLEFAMILY, SC_MOD()->GetResLocale()));
2263 
2264  return pStyleFamilies;
2265 }
2266 
2267 void ScModule::RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller)
2268 {
2269  mxAutomationApplicationEventsCaller = xCaller;
2270 }
2271 
2272 void ScModule::CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments)
2273 {
2274  if (mxAutomationApplicationEventsCaller.is())
2275  mxAutomationApplicationEventsCaller->CallSinks(Method, Arguments);
2276 }
2277 
2278 /* 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:102
IMPL_LINK_NOARG(ScModule, IdleHandler, Timer *, void)
Definition: scmod.cxx:1809
ConfigurationHints
void SetAutoComplete(bool bNew)
Definition: appoptio.hxx:54
#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:286
bool GetMoveSelection() const
Definition: inputopt.hxx:50
void CancelHandler()
Definition: inputhdl.cxx:3278
ScAddress aStart
Definition: address.hxx:500
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
Definition: docsh3.cxx:450
bool GetAutoComplete() const
Definition: appoptio.hxx:55
std::vector< SfxStyleFamilyItem > SfxStyleFamilies
SfxChildWindow * GetChildWindow(sal_uInt16)
std::unique_ptr< ScFormulaCfg > m_pFormulaCfg
Definition: scmod.hxx:94
bool IsEditMode()
Definition: scmod.cxx:1341
#define SFX_IMPL_INTERFACE(Class, SuperClass)
#define EMPTY_OUSTRING
Definition: global.hxx:214
#define LANGUAGE_ARABIC_SAUDI_ARABIA
std::map< sal_uInt16, std::vector< std::pair< std::shared_ptr< SfxDialogController >, weld::Window * > > > m_mapRefController
Definition: scmod.hxx:112
void PostPaintGridAll()
Definition: docsh3.cxx:181
#define LANGUAGE_ENGLISH_US
SC_DLLPUBLIC void RegisterRefController(sal_uInt16 nSlotId, std::shared_ptr< SfxDialogController > &rWnd, weld::Window *pWndAncestor)
Definition: scmod.cxx:2144
std::unique_ptr< ScNavipiCfg > m_pNavipiCfg
Definition: scmod.hxx:97
bool AdjustRowHeight(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
merge with docfunc
Definition: docsh5.cxx:405
#define LINGUPROP_AUTOSPELL
Definition: scmod.cxx:2203
constexpr TypedWhichId< SvxLanguageItem > ATTR_CJK_FONT_LANGUAGE(115)
SC_DLLPUBLIC void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const &xCaller)
Definition: scmod.cxx:2267
static void GetSpellSettings(LanguageType &rDefLang, LanguageType &rCjkLang, LanguageType &rCtlLang, bool &rAutoSpell)
Definition: scmod.cxx:2205
std::string GetValue
static weld::Window * GetActiveDialogParent()
Definition: docsh.cxx:2949
const Fraction & GetZoomX() const
Definition: viewdata.hxx:459
void DeleteCfg()
Definition: scmod.cxx:294
bool IsFormulaMode() const
Definition: inputhdl.hxx:259
#define SC_IDLE_MIN
Definition: scmod.cxx:99
bool PaintExtras()
Definition: tabview3.cxx:2741
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard()
std::unique_ptr< SvtCTLOptions > m_pCTLOptions
Definition: scmod.hxx:101
virtual void HideReference(bool bDoneRefMode=true)=0
bool IsInputMode() const
Definition: inputhdl.hxx:185
void EndReference()
Definition: scmod.cxx:1751
sal_uInt16 GetLRUFuncListCount() const
Definition: appoptio.hxx:48
void SetLRUFuncList(const sal_uInt16 *pList, const sal_uInt16 nCount)
Definition: appoptio.cxx:111
void InputGetSelection(sal_Int32 &rStart, sal_Int32 &rEnd)
Definition: scmod.cxx:1402
ScModule(SfxObjectFactory *pFact)
Definition: scmod.cxx:117
svtools::ColorConfig & GetColorConfig()
Definition: scmod.cxx:820
void AddRefEntry()
Multiple selection.
Definition: scmod.cxx:1722
sal_Int64 n
CALCNOTESBACKGROUND
bool GetUseEnglishFuncName() const
Definition: formulaopt.hxx:48
std::unique_ptr< ScDefaultsCfg > m_pDefaultsCfg
Definition: scmod.hxx:93
static void SetUserList(const ScUserList *pNewList)
Definition: global.cxx:288
void SetDocumentModified()
Definition: docsh.cxx:2819
LanguageType nDefaultLanguage_CJK
void SetStatusFunc(sal_uInt32 nNew)
Definition: appoptio.hxx:52
sal_uInt16 FirstWhich()
LanguageType GetOptDigitLanguage()
Definition: scmod.cxx:862
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:595
SvtCTLOptions & GetCTLOptions()
Definition: scmod.cxx:842
static Color GetErrorColor()
Definition: detfunc.cxx:1663
void SetTabDistance(sal_uInt16 nTabDist)
Definition: docoptio.hxx:72
void PaintGrid()
Definition: tabview3.cxx:2614
ScAddress aEnd
Definition: address.hxx:501
bool IsIter() const
Definition: docoptio.hxx:60
void Done(bool bRemove=false)
static css::uno::Reference< css::datatransfer::XTransferable2 > GetClipData(vcl::Window *pWin)
Definition: tabvwshc.cxx:483
std::unique_ptr< ScInputCfg > m_pInputCfg
Definition: scmod.hxx:95
static bool HasThesaurusLanguage(LanguageType nLang)
Definition: scmod.cxx:2230
static SfxObjectShell * Current()
bool GetSortRefUpdate() const
Definition: inputopt.hxx:60
void InputSelection(const EditView *pView)
Definition: inputhdl.cxx:4179
bool m_bIsInEditCommand
Definition: scmod.hxx:106
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
sc::DocumentLinkManager & GetDocLinkManager()
Definition: documen2.cxx:225
void ViewShellChanged(bool bStopEditing)
Definition: scmod.cxx:1326
std::unique_ptr< ScAppCfg, o3tl::default_delete< ScAppCfg > > m_pAppCfg
Definition: scmod.hxx:92
CALCDETECTIVEERROR
void PutItem(const SfxPoolItem &rItem)
void FreezeIdRanges()
void ViewShellGone(const ScTabViewShell *pViewSh)
Definition: inputhdl.cxx:2116
sal_uInt16 GetIterCount() const
Definition: docoptio.hxx:62
SfxHintId GetId() const
ScNavipiCfg & GetNavipiCfg()
Definition: scmod.cxx:804
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()
ScMessagePool * m_pMessagePool
Definition: scmod.hxx:87
SfxApplication * SfxGetpApp()
SC_DLLPUBLIC void UnregisterRefController(sal_uInt16 nSlotId, const std::shared_ptr< SfxDialogController > &rWnd)
Definition: scmod.cxx:2158
SfxInPlaceClient * GetUIActiveClient() const
void SetFormulaOptions(const ScFormulaOptions &rOpt, bool bForLoading=false)
Definition: docsh6.cxx:422
bool IsInputMode()
Definition: scmod.cxx:1347
void UpdateAutoFillMark(bool bFromPaste=false)
Definition: tabview3.cxx:183
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:285
void UpdateFixPos()
Definition: tabview.cxx:755
void PaintLeft()
Definition: tabview3.cxx:2690
void InvalidateBorder()
void InputReplaceSelection(const OUString &rStr)
Definition: inputhdl.cxx:4326
sal_uInt16 m_nCurRefDlgId
Definition: scmod.hxx:104
static void ResetKeyBindings(ScOptionsUtil::KeyBindingType eType)
Definition: docsh.cxx:2998
bool IsFormulaMode()
Definition: scmod.cxx:1621
bool GetMarkHeader() const
Definition: inputopt.hxx:62
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:876
static Color GetArrowColor()
Definition: detfunc.cxx:1656
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:313
virtual void ConfigurationChanged(utl::ConfigurationBroadcaster *, ConfigurationHints) override
Definition: scmod.cxx:177
SCTAB GetSelectCount() const
Definition: markdata.cxx:195
void SetViewOptions(const ScViewOptions &rOpt)
Definition: scmod.cxx:655
void InsertEntryToLRUList(sal_uInt16 nFIndex)
Definition: scmod.cxx:687
void AddRefEntry()
Definition: inputhdl.cxx:3344
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
sal_uInt16 * GetLRUFuncList() const
Definition: appoptio.hxx:49
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:260
static SfxViewShell * Current()
void SetOptions(const ScViewOptions &rOpt)
Definition: viewdata.cxx:3886
SC_DLLPUBLIC std::shared_ptr< SfxDialogController > Find1RefWindow(sal_uInt16 nSlotId, const weld::Window *pWndAncestor)
Definition: scmod.cxx:2182
void UpdateCharts(bool bAllCharts)
Definition: dbfunc2.cxx:24
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
Definition: scmod.cxx:671
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:632
SCTAB Tab() const
Definition: address.hxx:271
SC_DLLPUBLIC const ScDocOptions & GetDocOptions()
Definition: scmod.cxx:679
std::unique_ptr< ScDocCfg, o3tl::default_delete< ScDocCfg > > m_pDocCfg
Definition: scmod.hxx:91
ScDocument * GetDocument() const
Definition: viewdata.cxx:859
static ErrCode CallAppBasic(const OUString &i_macroName)
void InputSetSelection(sal_Int32 nStart, sal_Int32 nEnd)
Definition: inputhdl.cxx:4306
ScDocument * GetDocument() const
Definition: transobj.hxx:81
const Fraction & GetZoomY() const
Definition: viewdata.hxx:460
SC_DLLPUBLIC void SetInputOptions(const ScInputOptions &rOpt)
Definition: scmod.cxx:772
ScViewData & GetViewData()
Definition: tabview.hxx:332
static ScDocument * GetClipDoc()
Definition: scmod.cxx:621
void PaintTop()
Definition: tabview3.cxx:2625
void UpdateSpellSettings(bool bFromStartTab=false)
Definition: inputhdl.cxx:907
void CheckNeedsRepaint()
Definition: tabview3.cxx:3043
static sal_uInt16 DoUpdateCharts(const ScAddress &rPos, ScDocument *pDoc, bool bAllCharts)
Definition: dbfunc4.cxx:30
bool GetTextWysiwyg() const
Definition: inputopt.hxx:66
SfxItemPool & GetPool() const
bool IsClipboard() const
Definition: document.hxx:1533
static bool IsColorsInitialized()
Definition: detfunc.cxx:1689
bool IsMatchWholeCell() const
Definition: docoptio.hxx:56
bool InputKeyEvent(const KeyEvent &rKEvt, bool bStartEdit=false)
Definition: scmod.cxx:1353
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1904
static SfxChildWindow * lcl_GetChildWinFromCurrentView(sal_uInt16 nId)
Definition: scmod.cxx:1514
void MergeDocumentSpecific(const ScCalcConfig &r)
Definition: calcconfig.cxx:160
ScSelectionTransferObj * m_pSelTransfer
Definition: scmod.hxx:86
SC_DLLPUBLIC void SetAppOptions(const ScAppOptions &rOpt)
Definition: scmod.cxx:719
bool ContinueOnlineSpelling()
Definition: tabview.cxx:2239
void SetTab(SCTAB nTabP)
Definition: address.hxx:283
void SetZoom(const Fraction &rNewX, const Fraction &rNewY, bool bAll)
Definition: tabview5.cxx:414
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1062
#define DBG_UNHANDLED_EXCEPTION(...)
bool IsModalMode(const SfxObjectShell *pDocSh)
Definition: inputhdl.cxx:3336
void CalcOutputFactor()
Definition: docsh3.cxx:353
ScCalcConfig & GetCalcConfig()
Definition: formulaopt.hxx:43
void GetState(SfxItemSet &rSet)
Definition: scmod.cxx:521
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:71
sal_uInt64 GetTimeout() const
int i
bool GetReplaceCellsWarn() const
Definition: inputopt.hxx:68
bool GetEnterEdit() const
Definition: inputopt.hxx:52
void Execute(SfxRequest &rReq)
Definition: scmod.cxx:326
bool GetDetectiveAuto() const
Definition: appoptio.hxx:57
static bool AnyInput(VclInputFlags nType=VCL_INPUT_ANY)
void GetOptions(SvtLinguOptions &rOptions) const
SC_DLLPUBLIC const ScPrintOptions & GetPrintOptions()
Definition: scmod.cxx:796
virtual void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet) override
Definition: scmod.cxx:2016
#define LANGUAGE_SYSTEM
void SetDetectiveAuto(bool bNew)
Definition: appoptio.hxx:56
static void Clear()
Definition: global.cxx:528
LanguageType GetLanguage(SwWrtShell &rSh, sal_uInt16 nLangWhichId)
bool GetLegacyCellSelection() const
Definition: inputopt.hxx:70
SC_DLLPUBLIC const ScFormulaOptions & GetFormulaOptions()
Definition: scmod.cxx:764
#define SC_MOD()
Definition: scmod.hxx:253
void SetPrintOptions(const ScPrintOptions &rOpt)
Definition: scmod.cxx:788
virtual void AddRefEntry()=0
SfxBindings & GetBindings()
void EnterHandler(ScEnterMode nBlockMode=ScEnterMode::NORMAL)
Definition: inputhdl.cxx:2901
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
Definition: documen3.cxx:1924
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
SC_DLLPUBLIC const ScAppOptions & GetAppOptions()
Definition: scmod.cxx:732
const T * GetArg(sal_uInt16 nSlotId) const
#define SC_IDLE_COUNT
Definition: scmod.cxx:102
SvtAccessibilityOptions & GetAccessOptions()
Definition: scmod.cxx:831
std::unique_ptr< SvtAccessibilityOptions > m_pAccessOptions
Definition: scmod.hxx:100
std::unique_ptr< ScDragData > m_pDragData
Definition: scmod.hxx:85
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:568
virtual std::unique_ptr< SfxTabPage > CreateTabPage(sal_uInt16 nId, weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet) override
Definition: scmod.cxx:2024
static void UpdateAllComments(ScDocument &rDoc)
on all tables
Definition: detfunc.cxx:1413
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
bool GetOption(ScViewOption eOpt) const
Definition: viewopti.hxx:88
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3069
static SC_DLLPUBLIC ScUserList * GetUserList()
Definition: global.cxx:277
void SetGridOptions(const ScGridOptions &rNew)
Definition: viewopti.hxx:97
#define LRU_MAX
Definition: funcdesc.hxx:35
Timer m_aIdleTimer
Definition: scmod.hxx:83
void InputChanged(const EditView *pView, bool bFromNotify)
Definition: inputhdl.cxx:4189
std::unique_ptr< svtools::ColorConfig > m_pColorConfig
Definition: scmod.hxx:99
std::unique_ptr< SvxGridItem > CreateGridItem() const
Definition: viewopti.cxx:158
void global_InitAppOptions()
Definition: scmod.cxx:727
static sal_uInt16 nIdleCount
Definition: scmod.cxx:104
bool CompileErrorCells(FormulaError nErrCode)
Re-compile formula cells with error.
Definition: document.cxx:4012
virtual std::unique_ptr< SfxItemSet > CreateItemSet(sal_uInt16 nId) override
Virtual methods for the OptionsDialog.
Definition: scmod.cxx:1899
void EnableAutoSpell(bool bEnable)
Definition: tabview.cxx:2254
void SetDragJump(ScDocument *pLocalDoc, const OUString &rTarget, const OUString &rText)
Definition: scmod.cxx:611
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:3377
std::unique_ptr< ScViewCfg, o3tl::default_delete< ScViewCfg > > m_pViewCfg
Definition: scmod.hxx:90
bool IsReadOnly() const
void SetFuncString(const OUString &rString, bool bDoEdit=true)
Definition: inputwin.cxx:546
static SfxChildWindow * lcl_GetChildWinFromAnyView(sal_uInt16 nId)
Definition: scmod.cxx:1522
void SetInputMode(ScInputMode eMode, const OUString *pInitText=nullptr)
Definition: scmod.cxx:1334
Configuration options for formula interpreter.
Definition: calcconfig.hxx:43
bool QueryUrl(const INetURLObject &rUrl)
bool IdleCalcTextWidth()
Definition: documen8.cxx:530
bool GetExtendFormat() const
Definition: inputopt.hxx:54
void Update(sal_uInt16 nId)
SC_DLLPUBLIC void SetFormulaOptions(const ScFormulaOptions &rOpt)
Definition: scmod.cxx:756
void SetCalcConfig(const ScCalcConfig &rConfig)
Definition: formulaopt.hxx:45
ScAddInCfg & GetAddInCfg()
Definition: scmod.cxx:812
constexpr TypedWhichId< SvxLanguageItem > ATTR_CTL_FONT_LANGUAGE(120)
bool GetExpandRefs() const
Definition: inputopt.hxx:58
static void InitTextHeight(const SfxItemPool *pPool)
Definition: global.cxx:497
static Color GetCommentColor()
Definition: detfunc.cxx:1670
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
SC_DLLPUBLIC void PutInOrder()
Definition: address.cxx:1577
bool IsFormulaWildcardsEnabled() const
Definition: docoptio.hxx:99
static void Free(SfxItemPool *pPool)
static SfxViewFrame * Current()
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
Definition: documen3.cxx:1910
static ScTabViewShell * GetActiveViewShell()
Definition: tabvwsh4.cxx:1023
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:875
virtual bool IsDocAllowed(SfxObjectShell *pDocSh) const =0
SC_DLLPUBLIC void CalcAll()
Definition: document.cxx:3935
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:4274
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:3554
const ScCalcConfig & GetCalcConfig() const
Definition: document.hxx:2528
bool IsCalcAsShown() const
Definition: docoptio.hxx:82
static void InitializeColors()
Definition: detfunc.cxx:1677
ScInputHandler * m_pRefInputHandler
Definition: scmod.hxx:89
SC_DLLPUBLIC SvtUserOptions & GetUserOptions()
Definition: scmod.cxx:853
virtual std::unique_ptr< SfxStyleFamilies > CreateStyleFamilies() override
Definition: scmod.cxx:2250
void TextInvalidate()
Definition: inputwin.cxx:669
SCTAB GetFirstSelected() const
Definition: markdata.cxx:200
LanguageType nDefaultLanguage
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
Definition: scabstdlg.cxx:38
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:748
static SC_DLLPUBLIC ScTransferObj * GetOwnClipboard(const css::uno::Reference< css::datatransfer::XTransferable2 > &)
Definition: transobj.cxx:196
bool IsEditMode() const
Definition: inputhdl.hxx:186
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:100
double GetIterEps() const
Definition: docoptio.hxx:64
const ScViewOptions & GetOptions() const
Definition: viewdata.hxx:537
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
sal_uInt16 GetMoveDir() const
Definition: inputopt.hxx:48
void * p
Reference< XComponentContext > getProcessComponentContext()
ScDocument * pDoc
Definition: lotfilter.hxx:45
void SetLanguage(LanguageType eLatin, LanguageType eCjk, LanguageType eCtl)
Definition: documen3.cxx:1937
SC_DLLPUBLIC const ScInputOptions & GetInputOptions()
Definition: scmod.cxx:780
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
bool IsAutoSpell() const
Definition: docoptio.hxx:54
sal_uInt16 GetYear2000() const
Definition: docoptio.hxx:86
std::unique_ptr< ScAddInCfg > m_pAddInCfg
Definition: scmod.hxx:98
void InputSetSelection(sal_Int32 nStart, sal_Int32 nEnd)
Definition: scmod.cxx:1409
vcl::Window * GetWindow() const
sal_uInt16 GetStdPrecision() const
Definition: docoptio.hxx:79
virtual ~ScModule() override
Definition: scmod.cxx:161
SC_DLLPUBLIC void CallAutomationApplicationEventSinks(const OUString &Method, css::uno::Sequence< css::uno::Any > &Arguments)
Definition: scmod.cxx:2272
static void ensure()
void InputCancelHandler()
Definition: scmod.cxx:1369
void UpdateAnchorHandles()
Definition: tabview5.cxx:479
void SetSelectionTransfer(ScSelectionTransferObj *pNew)
Definition: scmod.cxx:650
sal_uInt32 GetValue() const
ScEnterMode
Definition: global.hxx:229
bool GetRangeFinder() const
Definition: inputopt.hxx:56
bool IsFormulaRegexEnabled() const
Definition: docoptio.hxx:96
void InputTurnOffWinEngine()
Definition: inputhdl.cxx:4357
static css::uno::Reference< css::linguistic2::XThesaurus > GetThesaurus()
const ScViewOptions & GetViewOptions()
Definition: scmod.cxx:663
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
void AppendItem(const SfxPoolItem &)
void UpdateRefDevice()
Definition: inputhdl.cxx:839
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:518
ScInputHandler * GetInputHdl(ScTabViewShell *pViewSh=nullptr, bool bUseRef=true)
Input-Handler.
Definition: scmod.cxx:1303
virtual void SetActive()=0
bool GetWriteCalcConfig() const
Definition: formulaopt.hxx:51
ScTabViewShell * GetBestViewShell(bool bOnlyVisible=true)
Definition: docsh4.cxx:2558
std::unique_ptr< ScPrintCfg > m_pPrintCfg
Definition: scmod.hxx:96
void SetAutoSpell(bool bVal)
Definition: docoptio.hxx:55
bool IsIgnoreCase() const
Definition: docoptio.hxx:58
void SetMode(ScInputMode eNewMode, const OUString *pInitText=nullptr, ScEditEngineDefaulter *pTopEngine=nullptr)
Definition: inputhdl.cxx:2792
bool IsRefDialogOpen()
Definition: scmod.cxx:1605
IMPL_LINK(ScModule, CalcFieldValueHdl, EditFieldInfo *, pInfo, void)
Definition: scmod.cxx:2103
SC_DLLPUBLIC void GetLanguage(LanguageType &rLatin, LanguageType &rCjk, LanguageType &rCtl) const
Definition: documen3.cxx:1930
#define SC_IDLE_STEP
Definition: scmod.cxx:101
void ResetDragObject()
Definition: scmod.cxx:583
void SetUserList(const ScUserList &rUserList)
Definition: uiitems.cxx:323
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:233
ScInputMode
Definition: global.hxx:368
void SetDragLink(const OUString &rDoc, const OUString &rTab, const OUString &rArea)
Definition: scmod.cxx:602
static void SetAutoSpellProperty(bool bSet)
Definition: scmod.cxx:2221
std::unique_ptr< SfxErrorHandler > m_pErrorHdl
Definition: scmod.hxx:103
void ForgetLastPattern()
Definition: inputhdl.cxx:2218
sal_Int16 SCTAB
Definition: types.hxx:23
void PosGrabFocus()
Definition: inputwin.cxx:693
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
void SetDefaultsOptions(const ScDefaultsOptions &rOpt)
Definition: scmod.cxx:740
const SvxFieldData * GetField() const
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
void SetAppMetric(FieldUnit eUnit)
Definition: appoptio.hxx:40
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo