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