LibreOffice Module sc (master)  1
docsh4.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 <config_features.h>
21 
22 #include <boost/property_tree/json_parser.hpp>
23 
24 #include <com/sun/star/frame/Desktop.hpp>
25 
26 using namespace ::com::sun::star;
27 
28 #include <scitems.hxx>
29 #include <editeng/flstitem.hxx>
30 #include <sfx2/fcontnr.hxx>
31 #include <sfx2/infobar.hxx>
32 #include <sfx2/objface.hxx>
33 #include <sfx2/docfile.hxx>
34 #include <sfx2/docfilt.hxx>
35 #include <svtools/ehdl.hxx>
36 #include <svtools/langtab.hxx>
37 #include <basic/sbxcore.hxx>
38 #include <basic/sberrors.hxx>
39 #include <svtools/sfxecode.hxx>
40 #include <svx/ofaitem.hxx>
41 #include <svl/stritem.hxx>
42 #include <svl/whiter.hxx>
43 #include <vcl/button.hxx>
44 #include <vcl/svapp.hxx>
45 #include <vcl/weld.hxx>
47 #include <svx/drawitem.hxx>
48 #include <svx/fmshell.hxx>
49 #include <sfx2/passwd.hxx>
50 #include <sfx2/filedlghelper.hxx>
51 #include <sfx2/dispatch.hxx>
52 #include <sfx2/sfxdlg.hxx>
53 #include <svl/PasswordHelper.hxx>
54 #include <svl/documentlockfile.hxx>
55 #include <svl/sharecontrolfile.hxx>
57 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
58 #include <sal/log.hxx>
59 #include <unotools/charclass.hxx>
60 
61 #include <comphelper/lok.hxx>
63 #include <docuno.hxx>
64 
65 #include <docsh.hxx>
66 #include "docshimp.hxx"
67 #include <docfunc.hxx>
68 #include <scres.hrc>
69 #include <strings.hrc>
70 #include <stlsheet.hxx>
71 #include <stlpool.hxx>
72 #include <appoptio.hxx>
73 #include <globstr.hrc>
74 #include <global.hxx>
75 #include <dbdocfun.hxx>
76 #include <printfun.hxx>
77 #include <viewdata.hxx>
78 #include <tabvwsh.hxx>
79 #include <impex.hxx>
80 #include <undodat.hxx>
81 #include <undocell.hxx>
82 #include <inputhdl.hxx>
83 #include <dbdata.hxx>
84 #include <servobj.hxx>
85 #include <rangenam.hxx>
86 #include <scmod.hxx>
87 #include <chgviset.hxx>
88 #include <reffact.hxx>
89 #include <chartlis.hxx>
90 #include <chartpos.hxx>
91 #include <waitoff.hxx>
92 #include <tablink.hxx>
93 #include <drwlayer.hxx>
94 #include <docoptio.hxx>
95 #include <undostyl.hxx>
96 #include <rangeseq.hxx>
97 #include <chgtrack.hxx>
98 #include <com/sun/star/document/UpdateDocMode.hpp>
99 #include <scresid.hxx>
100 #include <scabstdlg.hxx>
101 #include <sharedocdlg.hxx>
102 #include <conditio.hxx>
103 #include <sheetevents.hxx>
104 #include <formulacell.hxx>
105 #include <documentlinkmgr.hxx>
106 #include <memory>
108 #include <helpids.h>
109 #include <editeng/eeitem.hxx>
110 #include <editeng/langitem.hxx>
111 
112 #include <svx/xdef.hxx>
113 
115 {
118 
119  ReloadTabLinks();
120  weld::Window *pDialogParent = GetActiveDialogParent();
121  m_aDocument.UpdateExternalRefLinks(pDialogParent);
122 
123  bool bAnyDde = m_aDocument.GetDocLinkManager().updateDdeOrOleOrWebServiceLinks(pDialogParent);
124 
125  if (bAnyDde)
126  {
127  // calculate formulas and paint like in the TrackTimeHdl
129  Broadcast(SfxHint(SfxHintId::ScDataChanged));
130 
131  // Should FID_DATACHANGED become asynchronous some time
132  // (e.g., with Invalidate at Window), an update needs to be forced here.
133  }
134 
136 }
137 
138 IMPL_LINK_NOARG( ScDocShell, ReloadAllLinksHdl, Button*, void )
139 {
140  ReloadAllLinks();
141 
142  ScTabViewShell* pViewSh = GetBestViewShell();
143  SfxViewFrame* pViewFrame = pViewSh ? pViewSh->GetFrame() : nullptr;
144  if (pViewFrame)
145  pViewFrame->RemoveInfoBar("enablecontent");
146  SAL_WARN_IF(!pViewFrame, "sc", "expected there to be a ViewFrame");
147 }
148 
150 {
151  const ScDocument& rDoc = GetDocument();
152 
153  ScLkUpdMode nSet = rDoc.GetLinkMode();
154 
155  if (nSet == LM_UNKNOWN)
156  {
157  ScAppOptions aAppOptions = SC_MOD()->GetAppOptions();
158  nSet = aAppOptions.GetLinkMode();
159  }
160 
161  if (m_nCanUpdate == css::document::UpdateDocMode::NO_UPDATE)
162  nSet = LM_NEVER;
163  else if (m_nCanUpdate == css::document::UpdateDocMode::FULL_UPDATE)
164  nSet = LM_ALWAYS;
165 
166  if (nSet == LM_ALWAYS
167  && !(SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
168  GetMedium() == nullptr ? OUString() : GetMedium()->GetName())
169  || (IsDocShared()
170  && SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
171  GetSharedFileURL()))))
172  {
173  nSet = LM_ON_DEMAND;
174  }
175  if (m_nCanUpdate == css::document::UpdateDocMode::QUIET_UPDATE
176  && nSet == LM_ON_DEMAND)
177  {
178  nSet = LM_NEVER;
179  }
180 
181  return nSet;
182 }
183 
185 {
186  const SfxItemSet* pReqArgs = rReq.GetArgs();
187  SfxBindings* pBindings = GetViewBindings();
188  bool bUndo (m_aDocument.IsUndoEnabled());
189 
190  sal_uInt16 nSlot = rReq.GetSlot();
191  switch ( nSlot )
192  {
193  case SID_SC_SETTEXT:
194  {
195  const SfxPoolItem* pColItem;
196  const SfxPoolItem* pRowItem;
197  const SfxPoolItem* pTabItem;
198  const SfxPoolItem* pTextItem;
199  if( pReqArgs && pReqArgs->HasItem( FN_PARAM_1, &pColItem ) &&
200  pReqArgs->HasItem( FN_PARAM_2, &pRowItem ) &&
201  pReqArgs->HasItem( FN_PARAM_3, &pTabItem ) &&
202  pReqArgs->HasItem( SID_SC_SETTEXT, &pTextItem ) )
203  {
204  // parameters are 1-based !!!
205  SCCOL nCol = static_cast<const SfxInt16Item*>(pColItem)->GetValue() - 1;
206  SCROW nRow = static_cast<const SfxInt32Item*>(pRowItem)->GetValue() - 1;
207  SCTAB nTab = static_cast<const SfxInt16Item*>(pTabItem)->GetValue() - 1;
208 
209  SCTAB nTabCount = m_aDocument.GetTableCount();
210  if ( m_aDocument.ValidCol(nCol) && m_aDocument.ValidRow(nRow) && ValidTab(nTab,nTabCount) )
211  {
212  if ( m_aDocument.IsBlockEditable( nTab, nCol,nRow, nCol, nRow ) )
213  {
214  OUString aVal = static_cast<const SfxStringItem*>(pTextItem)->GetValue();
215  m_aDocument.SetString( nCol, nRow, nTab, aVal );
216 
217  PostPaintCell( nCol, nRow, nTab );
219 
220  rReq.Done();
221  break;
222  }
223  else // protected cell
224  {
225 #if HAVE_FEATURE_SCRIPTING
227 #endif
228  break;
229  }
230  }
231  }
232 #if HAVE_FEATURE_SCRIPTING
234 #endif
235  }
236  break;
237 
238  case SID_SBA_IMPORT:
239  {
240  if (pReqArgs)
241  {
242  const SfxPoolItem* pItem;
244  if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
245  {
246  uno::Any aAny = static_cast<const SfxUnoAnyItem*>(pItem)->GetValue();
247  uno::Sequence<beans::PropertyValue> aProperties;
248  if ( aAny >>= aProperties )
249  aDesc.initializeFrom( aProperties );
250  }
251 
252  OUString sTarget;
253  if ( pReqArgs->GetItemState( FN_PARAM_1, true, &pItem ) == SfxItemState::SET )
254  sTarget = static_cast<const SfxStringItem*>(pItem)->GetValue();
255 
256  bool bIsNewArea = true; // Default sal_True (no inquiry)
257  if ( pReqArgs->GetItemState( FN_PARAM_2, true, &pItem ) == SfxItemState::SET )
258  bIsNewArea = static_cast<const SfxBoolItem*>(pItem)->GetValue();
259 
260  // if necessary, create new database area
261  bool bMakeArea = false;
262  if (bIsNewArea)
263  {
265  if ( !pDBColl || !pDBColl->getNamedDBs().findByUpperName(ScGlobal::getCharClassPtr()->uppercase(sTarget)) )
266  {
267  ScAddress aPos;
269  {
270  bMakeArea = true;
271  if (bUndo)
272  {
273  OUString aStrImport = ScResId( STR_UNDO_IMPORTDATA );
274  ViewShellId nViewShellId(-1);
276  nViewShellId = pViewSh->GetViewShellId();
277  GetUndoManager()->EnterListAction( aStrImport, aStrImport, 0, nViewShellId );
278  }
279 
281  OSL_ENSURE(pDBData, "Cannot create DB data");
282  sTarget = pDBData->GetName();
283  }
284  }
285  }
286 
287  // inquire, before old DB range gets overwritten
288  bool bDo = true;
289  if (!bIsNewArea)
290  {
291  OUString aTemplate = ScResId( STR_IMPORT_REPLACE );
292  OUString aMessage = aTemplate.getToken( 0, '#' )
293  + sTarget
294  + aTemplate.getToken( 1, '#' );
295 
296  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr,
297  VclMessageType::Question, VclButtonsType::YesNo,
298  aMessage));
299  xQueryBox->set_default_response(RET_YES);
300  bDo = xQueryBox->run() == RET_YES;
301  }
302 
303  if (bDo)
304  {
305  ScDBDocFunc(*this).UpdateImport( sTarget, aDesc );
306  rReq.Done();
307 
308  // UpdateImport also updates the internal operations
309  }
310  else
311  rReq.Ignore();
312 
313  if ( bMakeArea && bUndo)
315  }
316  else
317  {
318  OSL_FAIL( "arguments expected" );
319  }
320  }
321  break;
322 
323  case SID_CHART_SOURCE:
324  case SID_CHART_ADDSOURCE:
325  if (pReqArgs)
326  {
327  ScDocument& rDoc = GetDocument();
328  const SfxPoolItem* pItem;
329  OUString aChartName, aRangeName;
330 
331  ScRange aSingleRange;
332  ScRangeListRef aRangeListRef;
333  bool bMultiRange = false;
334 
335  bool bColHeaders = true;
336  bool bRowHeaders = true;
337  bool bColInit = false;
338  bool bRowInit = false;
339  bool bAddRange = (nSlot == SID_CHART_ADDSOURCE);
340 
341  if( pReqArgs->HasItem( SID_CHART_NAME, &pItem ) )
342  aChartName = static_cast<const SfxStringItem*>(pItem)->GetValue();
343 
344  if( pReqArgs->HasItem( SID_CHART_SOURCE, &pItem ) )
345  aRangeName = static_cast<const SfxStringItem*>(pItem)->GetValue();
346 
347  if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
348  {
349  bColHeaders = static_cast<const SfxBoolItem*>(pItem)->GetValue();
350  bColInit = true;
351  }
352  if( pReqArgs->HasItem( FN_PARAM_2, &pItem ) )
353  {
354  bRowHeaders = static_cast<const SfxBoolItem*>(pItem)->GetValue();
355  bRowInit = true;
356  }
357 
358  ScAddress::Details aDetails(rDoc.GetAddressConvention(), 0, 0);
359  bool bValid = (aSingleRange.ParseAny(aRangeName, &rDoc, aDetails) & ScRefFlags::VALID) == ScRefFlags::ZERO;
360  if (!bValid)
361  {
362  aRangeListRef = new ScRangeList;
363  aRangeListRef->Parse( aRangeName, &rDoc );
364  if ( !aRangeListRef->empty() )
365  {
366  bMultiRange = true;
367  aSingleRange = aRangeListRef->front(); // for header
368  bValid = true;
369  }
370  else
371  aRangeListRef.clear();
372  }
373 
375  if (pViewSh && bValid && !aChartName.isEmpty() )
376  {
377  weld::Window* pParent = pViewSh->GetFrameWeld();
378 
379  SCCOL nCol1 = aSingleRange.aStart.Col();
380  SCROW nRow1 = aSingleRange.aStart.Row();
381  SCCOL nCol2 = aSingleRange.aEnd.Col();
382  SCROW nRow2 = aSingleRange.aEnd.Row();
383  SCTAB nTab = aSingleRange.aStart.Tab();
384 
386  if (!bMultiRange)
387  m_aDocument.LimitChartArea( nTab, nCol1,nRow1, nCol2,nRow2 );
388 
389  // Dialog for column/row headers
390  bool bOk = true;
391  if ( !bAddRange && ( !bColInit || !bRowInit ) )
392  {
393  ScChartPositioner aChartPositioner( &m_aDocument, nTab, nCol1,nRow1, nCol2,nRow2 );
394  if (!bColInit)
395  bColHeaders = aChartPositioner.HasColHeaders();
396  if (!bRowInit)
397  bRowHeaders = aChartPositioner.HasRowHeaders();
398 
400 
401  ScopedVclPtr<AbstractScColRowLabelDlg> pDlg(pFact->CreateScColRowLabelDlg(pParent, bRowHeaders, bColHeaders));
402  if ( pDlg->Execute() == RET_OK )
403  {
404  bColHeaders = pDlg->IsRow();
405  bRowHeaders = pDlg->IsCol();
406 
407  rReq.AppendItem(SfxBoolItem(FN_PARAM_1, bColHeaders));
408  rReq.AppendItem(SfxBoolItem(FN_PARAM_2, bRowHeaders));
409  }
410  else
411  bOk = false;
412  }
413 
414  if (bOk) // execute
415  {
416  if (bMultiRange)
417  {
418  if (bUndo)
419  {
421  std::make_unique<ScUndoChartData>( this, aChartName, aRangeListRef,
422  bColHeaders, bRowHeaders, bAddRange ) );
423  }
424  m_aDocument.UpdateChartArea( aChartName, aRangeListRef,
425  bColHeaders, bRowHeaders, bAddRange );
426  }
427  else
428  {
429  ScRange aNewRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab );
430  if (bUndo)
431  {
433  std::make_unique<ScUndoChartData>( this, aChartName, aNewRange,
434  bColHeaders, bRowHeaders, bAddRange ) );
435  }
436  m_aDocument.UpdateChartArea( aChartName, aNewRange,
437  bColHeaders, bRowHeaders, bAddRange );
438  }
439  }
440  }
441  else
442  {
443  OSL_FAIL("UpdateChartArea: no ViewShell or wrong data");
444  }
445  rReq.Done();
446  }
447  else
448  {
449  OSL_FAIL("SID_CHART_SOURCE without arguments");
450  }
451  break;
452 
453  case FID_AUTO_CALC:
454  {
455  bool bNewVal;
456  const SfxPoolItem* pItem;
457  if ( pReqArgs && SfxItemState::SET == pReqArgs->GetItemState( nSlot, true, &pItem ) )
458  bNewVal = static_cast<const SfxBoolItem*>(pItem)->GetValue();
459  else
460  bNewVal = !m_aDocument.GetAutoCalc(); // Toggle for menu
461  m_aDocument.SetAutoCalc( bNewVal );
463  if (pBindings)
464  {
465  pBindings->Invalidate( FID_AUTO_CALC );
466  }
467  rReq.AppendItem( SfxBoolItem( FID_AUTO_CALC, bNewVal ) );
468  rReq.Done();
469  }
470  break;
471  case FID_RECALC:
472  DoRecalc( rReq.IsAPI() );
473  rReq.Done();
474  break;
475  case FID_HARD_RECALC:
476  DoHardRecalc();
477  rReq.Done();
478  break;
479  case SID_UPDATETABLINKS:
480  {
482 
483  if (nSet == LM_ALWAYS)
484  {
485  ReloadAllLinks();
486  rReq.Done();
487  }
488  else if (nSet == LM_NEVER)
489  {
491  rReq.Ignore();
492  }
493  else if (nSet == LM_ON_DEMAND)
494  {
495  ScTabViewShell* pViewSh = GetBestViewShell();
496  SfxViewFrame* pViewFrame = pViewSh ? pViewSh->GetFrame() : nullptr;
497  if (pViewFrame)
498  {
499  pViewFrame->RemoveInfoBar("enablecontent");
500  auto pInfoBar = pViewFrame->AppendInfoBar("enablecontent", "", ScResId(STR_RELOAD_TABLES), InfobarType::WARNING);
501  if (pInfoBar)
502  {
503  VclPtrInstance<PushButton> xBtn(&pViewFrame->GetWindow());
504  xBtn->SetText(ScResId(STR_ENABLE_CONTENT));
505  xBtn->SetSizePixel(xBtn->GetOptimalSize());
506  xBtn->SetClickHdl(LINK(this, ScDocShell, ReloadAllLinksHdl));
507  pInfoBar->addButton(xBtn);
508  }
509  }
510  rReq.Done();
511  }
512  }
513  break;
514 
515  case SID_REIMPORT_AFTER_LOAD:
516  {
517  // Is called after loading if there are DB areas with omitted data
518 
519  bool bDone = false;
521 
522  if ((m_nCanUpdate != css::document::UpdateDocMode::NO_UPDATE) &&
523  (m_nCanUpdate != css::document::UpdateDocMode::QUIET_UPDATE))
524  {
525  ScRange aRange;
526  ScTabViewShell* pViewSh = GetBestViewShell();
527  OSL_ENSURE(pViewSh,"SID_REIMPORT_AFTER_LOAD: no View");
528  if (pViewSh && pDBColl)
529  {
530  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetActiveDialogParent(),
531  VclMessageType::Question, VclButtonsType::YesNo,
532  ScResId(STR_REIMPORT_AFTER_LOAD)));
533  xQueryBox->set_default_response(RET_YES);
534  if (xQueryBox->run() == RET_YES)
535  {
536  ScDBCollection::NamedDBs& rDBs = pDBColl->getNamedDBs();
537  for (const auto& rxDB : rDBs)
538  {
539  ScDBData& rDBData = *rxDB;
540  if ( rDBData.IsStripData() &&
541  rDBData.HasImportParam() && !rDBData.HasImportSelection() )
542  {
543  rDBData.GetArea(aRange);
544  pViewSh->MarkRange(aRange);
545 
546  // Import and internal operations like SID_REFRESH_DBAREA
547  // (inquiry for import not needed here)
548 
549  ScImportParam aImportParam;
550  rDBData.GetImportParam( aImportParam );
551  bool bContinue = pViewSh->ImportData( aImportParam );
552  rDBData.SetImportParam( aImportParam );
553 
554  // mark (size may have changed)
555  rDBData.GetArea(aRange);
556  pViewSh->MarkRange(aRange);
557 
558  if ( bContinue ) // error at import -> abort
559  {
560  // internal operations, if some where saved
561 
562  if ( rDBData.HasQueryParam() || rDBData.HasSortParam() ||
563  rDBData.HasSubTotalParam() )
564  pViewSh->RepeatDB();
565 
566  // pivot tables, which have the range as source data
567 
568  RefreshPivotTables(aRange);
569  }
570  }
571  }
572  bDone = true;
573  }
574  }
575  }
576 
577  if ( !bDone && pDBColl )
578  {
579  // if not, but then update the dependent formulas
581 
582  m_aDocument.CalcAll();
583  PostDataChanged();
584  }
585 
586  if (bDone)
587  rReq.Done();
588  else
589  rReq.Ignore();
590  }
591  break;
592 
593  case SID_AUTO_STYLE:
594  OSL_FAIL("use ScAutoStyleHint instead of SID_AUTO_STYLE");
595  break;
596 
597  case SID_GET_COLORLIST:
598  {
599  const SvxColorListItem* pColItem = GetItem(SID_COLOR_TABLE);
600  const XColorListRef& pList = pColItem->GetColorList();
601  rReq.SetReturnValue(OfaRefItem<XColorList>(SID_GET_COLORLIST, pList));
602  }
603  break;
604 
605  case FID_CHG_RECORD:
606  {
607  ScDocument& rDoc = GetDocument();
608  // get argument (recorded macro)
609  const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(FID_CHG_RECORD);
610  bool bDo = true;
611 
612  // desired state
613  ScChangeTrack* pChangeTrack = rDoc.GetChangeTrack();
614  bool bActivateTracking = (pChangeTrack == nullptr); // toggle
615  if ( pItem )
616  bActivateTracking = pItem->GetValue(); // from argument
617 
618  if ( !bActivateTracking )
619  {
620  if ( !pItem )
621  {
622  // no dialog on playing the macro
623  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetActiveDialogParent(),
624  VclMessageType::Warning, VclButtonsType::YesNo,
625  ScResId(STR_END_REDLINING)));
626  xWarn->set_default_response(RET_NO);
627  bDo = (xWarn->run() == RET_YES );
628  }
629 
630  if ( bDo )
631  {
632  if (pChangeTrack)
633  {
634  if ( pChangeTrack->IsProtected() )
636  }
637  if ( bDo )
638  {
639  rDoc.EndChangeTracking();
641  }
642  }
643  }
644  else
645  {
646  rDoc.StartChangeTracking();
647  ScChangeViewSettings aChangeViewSet;
648  aChangeViewSet.SetShowChanges(true);
649  rDoc.SetChangeViewSettings(aChangeViewSet);
650  }
651 
652  if ( bDo )
653  {
655 
656  // invalidate slots
657  if (pBindings)
658  pBindings->InvalidateAll(false);
659  if ( !pItem )
660  rReq.AppendItem( SfxBoolItem( FID_CHG_RECORD, bActivateTracking ) );
661  rReq.Done();
662  }
663  else
664  rReq.Ignore();
665  }
666  break;
667 
668  case SID_CHG_PROTECT :
669  {
671  {
672  rReq.Done();
674  }
675  else
676  rReq.Ignore();
677  }
678  break;
679 
680  case SID_DOCUMENT_MERGE:
681  case SID_DOCUMENT_COMPARE:
682  {
683  bool bDo = true;
684  ScChangeTrack* pChangeTrack = m_aDocument.GetChangeTrack();
685  if ( pChangeTrack && !m_pImpl->bIgnoreLostRedliningWarning )
686  {
687  if ( nSlot == SID_DOCUMENT_COMPARE )
688  {
689  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetActiveDialogParent(),
690  VclMessageType::Warning, VclButtonsType::YesNo,
691  ScResId(STR_END_REDLINING)));
692  xWarn->set_default_response(RET_NO);
693  if (xWarn->run() == RET_YES)
694  bDo = ExecuteChangeProtectionDialog( true );
695  else
696  bDo = false;
697  }
698  else // merge might reject some actions
699  bDo = ExecuteChangeProtectionDialog( true );
700  }
701  if ( !bDo )
702  {
703  rReq.Ignore();
704  break;
705  }
706  SfxApplication* pApp = SfxGetpApp();
707  const SfxPoolItem* pItem;
708  const SfxStringItem* pStringItem(nullptr);
709  SfxMedium* pMed = nullptr;
710  if (pReqArgs && pReqArgs->GetItemState(SID_FILE_NAME, true, &pItem) == SfxItemState::SET)
711  {
712  pStringItem = dynamic_cast<const SfxStringItem*>(pItem);
713  }
714  if (pStringItem)
715  {
716  OUString aFileName = pStringItem->GetValue();
717 
718  OUString aFilterName;
719  pStringItem = nullptr;
720  if (pReqArgs->GetItemState(SID_FILTER_NAME, true, &pItem) == SfxItemState::SET)
721  pStringItem = dynamic_cast<const SfxStringItem*>(pItem);
722  if (pStringItem)
723  {
724  aFilterName = pStringItem->GetValue();
725  }
726  OUString aOptions;
727  pStringItem = nullptr;
728  if (pReqArgs->GetItemState(SID_FILE_FILTEROPTIONS, true, &pItem) == SfxItemState::SET)
729  pStringItem = dynamic_cast<const SfxStringItem*>(pItem);
730  if (pStringItem)
731  {
732  aOptions = pStringItem->GetValue();
733  }
734  short nVersion = 0;
735  const SfxInt16Item* pInt16Item(nullptr);
736  if (pReqArgs->GetItemState(SID_VERSION, true, &pItem) == SfxItemState::SET)
737  pInt16Item = dynamic_cast<const SfxInt16Item*>(pItem);
738  if (pInt16Item)
739  {
740  nVersion = pInt16Item->GetValue();
741  }
742 
743  // no filter specified -> detection
744  if (aFilterName.isEmpty())
745  ScDocumentLoader::GetFilterName( aFileName, aFilterName, aOptions, true, false );
746 
747  // filter name from dialog contains application prefix,
748  // GetFilter needs name without the prefix.
749  ScDocumentLoader::RemoveAppPrefix( aFilterName );
750 
751  std::shared_ptr<const SfxFilter> pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( aFilterName );
752  auto pSet = std::make_shared<SfxAllItemSet>( pApp->GetPool() );
753  if (!aOptions.isEmpty())
754  pSet->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, aOptions ) );
755  if ( nVersion != 0 )
756  pSet->Put( SfxInt16Item( SID_VERSION, nVersion ) );
757  pMed = new SfxMedium( aFileName, StreamMode::STD_READ, pFilter, std::move(pSet) );
758  }
759  else
760  {
761  const sfx2::DocumentInserter::Mode mode { nSlot==SID_DOCUMENT_COMPARE
764  // start file dialog asynchronous
765  m_pImpl->bIgnoreLostRedliningWarning = true;
766  m_pImpl->pRequest.reset(new SfxRequest( rReq ));
767  m_pImpl->pDocInserter.reset();
768 
770  weld::Window* pParent = pViewSh ? pViewSh->GetFrameWeld() : nullptr;
771  m_pImpl->pDocInserter.reset( new ::sfx2::DocumentInserter(pParent,
772  ScDocShell::Factory().GetFactoryName(), mode ) );
773  m_pImpl->pDocInserter->StartExecuteModal( LINK( this, ScDocShell, DialogClosedHdl ) );
774  return ;
775  }
776 
777  // now execute in earnest...
779 
780  // pOtherDocSh->DoClose() will be called explicitly later, but it is still more safe to use SfxObjectShellLock here
781  ScDocShell* pOtherDocSh = new ScDocShell;
782  SfxObjectShellLock aDocShTablesRef = pOtherDocSh;
783  pOtherDocSh->DoLoad( pMed );
784  ErrCode nErr = pOtherDocSh->GetErrorCode();
785  if (nErr)
786  ErrorHandler::HandleError( nErr ); // also warnings
787 
788  if ( !pOtherDocSh->GetError() ) // only errors
789  {
790  bool bHadTrack = ( m_aDocument.GetChangeTrack() != nullptr );
791 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
792  sal_uLong nStart = 0;
793  if ( nSlot == SID_DOCUMENT_MERGE && pChangeTrack )
794  {
795  nStart = pChangeTrack->GetActionMax() + 1;
796  }
797 #endif
798  if ( nSlot == SID_DOCUMENT_COMPARE )
799  CompareDocument( pOtherDocSh->GetDocument() );
800  else
801  MergeDocument( pOtherDocSh->GetDocument() );
802 
803  // show "accept changes" dialog
805  if ( !IsDocShared() )
806  {
807  SfxViewFrame* pViewFrm = SfxViewFrame::Current();
808  if ( pViewFrm )
809  {
810  pViewFrm->ShowChildWindow( ScAcceptChgDlgWrapper::GetChildWindowId() ); //@51669
811  }
812  if ( pBindings )
813  {
814  pBindings->Invalidate( FID_CHG_ACCEPT );
815  }
816  }
817 
818  rReq.SetReturnValue( SfxInt32Item( nSlot, 0 ) );
819  rReq.Done();
820 
821  if (!bHadTrack) // newly turned on -> show as well
822  {
824  if ( !pOldSet || !pOldSet->ShowChanges() )
825  {
826  ScChangeViewSettings aChangeViewSet;
827  aChangeViewSet.SetShowChanges(true);
828  m_aDocument.SetChangeViewSettings(aChangeViewSet);
829  }
830  }
831 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
832  else if ( nSlot == SID_DOCUMENT_MERGE && IsDocShared() && pChangeTrack )
833  {
834  sal_uLong nEnd = pChangeTrack->GetActionMax();
835  if ( nEnd >= nStart )
836  {
837  // only show changes from merged document
838  ScChangeViewSettings aChangeViewSet;
839  aChangeViewSet.SetShowChanges( true );
840  aChangeViewSet.SetShowAccepted( true );
841  aChangeViewSet.SetHasActionRange();
842  aChangeViewSet.SetTheActionRange( nStart, nEnd );
843  m_aDocument.SetChangeViewSettings( aChangeViewSet );
844 
845  // update view
846  PostPaintExtras();
848  }
849  }
850 #endif
851  }
852  pOtherDocSh->DoClose(); // delete happens with the Ref
853  }
854  break;
855 
856  case SID_DELETE_SCENARIO:
857  if (pReqArgs)
858  {
859  const SfxPoolItem* pItem;
860  if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
861  {
862  if (const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>(pItem))
863  {
864  const OUString& aName = pStringItem->GetValue();
865  SCTAB nTab;
866  if (m_aDocument.GetTable( aName, nTab ))
867  {
868  // move DeleteTable from viewfunc to docfunc!
869 
871  if ( pSh )
872  {
874  SCTAB nDispTab = pSh->GetViewData().GetTabNo();
875  pSh->DeleteTable( nTab );
876  pSh->SetTabNo(nDispTab);
877  rReq.Done();
878  }
879  }
880  }
881  }
882  }
883  break;
884 
885  case SID_EDIT_SCENARIO:
886  {
887  const SfxPoolItem* pItem;
888  if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
889  {
890  if (const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>(pItem))
891  {
892  OUString aName = pStringItem->GetValue();
893  SCTAB nTab;
894  if (m_aDocument.GetTable( aName, nTab ))
895  {
896  if (m_aDocument.IsScenario(nTab))
897  {
898  OUString aComment;
899  Color aColor;
900  ScScenarioFlags nFlags;
901  m_aDocument.GetScenarioData( nTab, aComment, aColor, nFlags );
902 
903  // Determine if the Sheet that the Scenario was created on
904  // is protected. But first we need to find that Sheet.
905  // Rewind back to the actual sheet.
906  SCTAB nActualTab = nTab;
907  do
908  {
909  nActualTab--;
910  }
911  while(m_aDocument.IsScenario(nActualTab));
912  bool bSheetProtected = m_aDocument.IsTabProtected(nActualTab);
913 
915 
916  ScopedVclPtr<AbstractScNewScenarioDlg> pNewDlg(pFact->CreateScNewScenarioDlg(GetActiveDialogParent(), aName, true, bSheetProtected));
917  pNewDlg->SetScenarioData( aName, aComment, aColor, nFlags );
918  if ( pNewDlg->Execute() == RET_OK )
919  {
920  pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags );
921  ModifyScenario( nTab, aName, aComment, aColor, nFlags );
922  rReq.Done();
923  }
924  }
925  }
926  }
927  }
928  }
929  break;
930 
931  case SID_ATTR_YEAR2000 :
932  {
933  const SfxPoolItem* pItem;
934  if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
935  {
936  if (const SfxUInt16Item* pInt16Item = dynamic_cast<const SfxUInt16Item*>(pItem))
937  {
938  sal_uInt16 nY2k = pInt16Item->GetValue();
939  // set always to DocOptions, so that it is also saved for S050
940  // (and all inquiries run up until now on it as well).
941  // SetDocOptions propagates that to the NumberFormatter
943  aDocOpt.SetYear2000( nY2k );
944  m_aDocument.SetDocOptions( aDocOpt );
945  // the FormShell shall notice it as well
947  if ( pSh )
948  {
949  FmFormShell* pFSh = pSh->GetFormShell();
950  if ( pFSh )
951  pFSh->SetY2KState( nY2k );
952  }
953  }
954  }
955  }
956  break;
957 
958 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
959  case SID_SHARE_DOC:
960  {
961  ScViewData* pViewData = GetViewData();
962  if ( !pViewData )
963  {
964  rReq.Ignore();
965  break;
966  }
967 
969  ScShareDocumentDlg aDlg(pWin, pViewData);
970  if (aDlg.run() == RET_OK)
971  {
972  bool bSetShared = aDlg.IsShareDocumentChecked();
973  if ( bSetShared != IsDocShared() )
974  {
975  if ( bSetShared )
976  {
977  bool bContinue = true;
978  if ( HasName() )
979  {
980  std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pWin,
981  VclMessageType::Question, VclButtonsType::YesNo,
982  ScResId(STR_DOC_WILLBESAVED)));
983  xQueryBox->set_default_response(RET_YES);
984  if (xQueryBox->run() == RET_NO)
985  {
986  bContinue = false;
987  }
988  }
989  if ( bContinue )
990  {
991  EnableSharedSettings( true );
992 
993  SC_MOD()->SetInSharedDocSaving( true );
994  if ( !SwitchToShared( true, true ) )
995  {
996  // TODO/LATER: what should be done in case the switch has failed?
997  // for example in case the user has cancelled the saveAs operation
998  }
999 
1000  SC_MOD()->SetInSharedDocSaving( false );
1001 
1002  InvalidateName();
1003  GetUndoManager()->Clear();
1004 
1005  ScTabView* pTabView = dynamic_cast< ScTabView* >( pViewData->GetView() );
1006  if ( pTabView )
1007  {
1008  pTabView->UpdateLayerLocks();
1009  }
1010  }
1011  }
1012  else
1013  {
1014  uno::Reference< frame::XModel > xModel;
1015  try
1016  {
1017  // load shared file
1018  xModel.set( LoadSharedDocument(), uno::UNO_SET_THROW );
1019  uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY_THROW );
1020 
1021  // check if shared flag is set in shared file
1022  bool bShared = false;
1023  ScModelObj* pDocObj = comphelper::getUnoTunnelImplementation<ScModelObj>( xModel );
1024  if ( pDocObj )
1025  {
1026  ScDocShell* pDocShell = dynamic_cast< ScDocShell* >( pDocObj->GetEmbeddedObject() );
1027  if ( pDocShell )
1028  {
1029  bShared = pDocShell->HasSharedXMLFlagSet();
1030  }
1031  }
1032 
1033  // #i87870# check if shared status was disabled and enabled again
1034  bool bOwnEntry = false;
1035  try
1036  {
1037  ::svt::ShareControlFile aControlFile( GetSharedFileURL() );
1038  bOwnEntry = aControlFile.HasOwnEntry();
1039  }
1040  catch ( uno::Exception& )
1041  {
1042  }
1043 
1044  if ( bShared && bOwnEntry )
1045  {
1046  uno::Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY_THROW );
1047  if ( xStorable->isReadonly() )
1048  {
1049  xCloseable->close( true );
1050 
1051  OUString aUserName( ScResId( STR_UNKNOWN_USER ) );
1052  try
1053  {
1055  LockFileEntry aData = aLockFile.GetLockData();
1056  if ( !aData[LockFileComponent::OOOUSERNAME].isEmpty() )
1057  {
1058  aUserName = aData[LockFileComponent::OOOUSERNAME];
1059  }
1060  else if ( !aData[LockFileComponent::SYSUSERNAME].isEmpty() )
1061  {
1062  aUserName = aData[LockFileComponent::SYSUSERNAME];
1063  }
1064  }
1065  catch ( uno::Exception& )
1066  {
1067  }
1068  OUString aMessage( ScResId( STR_FILE_LOCKED_TRY_LATER ) );
1069  aMessage = aMessage.replaceFirst( "%1", aUserName );
1070 
1071  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(pWin,
1072  VclMessageType::Warning, VclButtonsType::Ok,
1073  aMessage));
1074  xWarn->run();
1075  }
1076  else
1077  {
1078  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(pWin,
1079  VclMessageType::Warning, VclButtonsType::YesNo,
1080  ScResId(STR_DOC_DISABLESHARED)));
1081  xWarn->set_default_response(RET_YES);
1082 
1083  if (xWarn->run() == RET_YES)
1084  {
1085  xCloseable->close( true );
1086 
1087  if ( !SwitchToShared( false, true ) )
1088  {
1089  // TODO/LATER: what should be done in case the switch has failed?
1090  // for example in case the user has cancelled the saveAs operation
1091  }
1092 
1093  EnableSharedSettings( false );
1094 
1095  if ( pBindings )
1096  {
1097  pBindings->ExecuteSynchron( SID_SAVEDOC );
1098  }
1099 
1100  ScTabView* pTabView = dynamic_cast< ScTabView* >( pViewData->GetView() );
1101  if ( pTabView )
1102  {
1103  pTabView->UpdateLayerLocks();
1104  }
1105  }
1106  else
1107  {
1108  xCloseable->close( true );
1109  }
1110  }
1111  }
1112  else
1113  {
1114  xCloseable->close( true );
1115  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(pWin,
1116  VclMessageType::Warning, VclButtonsType::Ok,
1117  ScResId(STR_DOC_NOLONGERSHARED)));
1118  xWarn->run();
1119  }
1120  }
1121  catch ( uno::Exception& )
1122  {
1123  OSL_FAIL( "SID_SHARE_DOC: caught exception" );
1124  SC_MOD()->SetInSharedDocSaving( false );
1125 
1126  try
1127  {
1128  uno::Reference< util::XCloseable > xClose( xModel, uno::UNO_QUERY_THROW );
1129  xClose->close( true );
1130  }
1131  catch ( uno::Exception& )
1132  {
1133  }
1134  }
1135  }
1136  }
1137  }
1138  rReq.Done();
1139  }
1140  break;
1141 #endif
1142  case SID_OPEN_CALC:
1143  {
1144  SfxStringItem aApp(SID_DOC_SERVICE, "com.sun.star.sheet.SpreadsheetDocument");
1145  SfxStringItem aTarget(SID_TARGETNAME, "_blank");
1147  SID_OPENDOC, SfxCallMode::API|SfxCallMode::SYNCHRON,
1148  { &aApp, &aTarget });
1149  }
1150  break;
1151  case SID_NOTEBOOKBAR:
1152  {
1153  const SfxStringItem* pFile = rReq.GetArg<SfxStringItem>( SID_NOTEBOOKBAR );
1154 
1155  if ( pBindings && sfx2::SfxNotebookBar::IsActive() )
1156  sfx2::SfxNotebookBar::ExecMethod(*pBindings, pFile ? pFile->GetValue() : "");
1157  else if ( pBindings )
1159  }
1160  break;
1161  case SID_LANGUAGE_STATUS:
1162  {
1163  sal_Int32 nPos = 0;
1164  OUString aLangText;
1165  const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(nSlot);
1166  if ( pItem )
1167  aLangText = pItem->GetValue();
1168 
1169  if ( !aLangText.isEmpty() )
1170  {
1171  LanguageType eLang, eLatin, eCjk, eCtl;
1172  const OUString aSelectionLangPrefix("Current_");
1173  const OUString aParagraphLangPrefix("Paragraph_");
1174  const OUString aDocLangPrefix("Default_");
1175 
1176  bool bSelection = false;
1177  bool bParagraph = false;
1178 
1179  ScDocument& rDoc = GetDocument();
1180  rDoc.GetLanguage( eLatin, eCjk, eCtl );
1181 
1182  if ( aLangText == "*" )
1183  {
1186  ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateVclDialog(pSh ? pSh->GetDialogParent() : nullptr, SID_LANGUAGE_OPTIONS));
1187  pDlg->Execute();
1188 
1189  rDoc.GetLanguage( eLang, eCjk, eCtl );
1190  }
1191  else if ( (nPos = aLangText.indexOf(aDocLangPrefix)) != -1 )
1192  {
1193  aLangText = aLangText.replaceAt(nPos, aDocLangPrefix.getLength(), "");
1194 
1195  if ( aLangText == "LANGUAGE_NONE" )
1196  {
1197  eLang = LANGUAGE_NONE;
1198  rDoc.SetLanguage( eLang, eCjk, eCtl );
1199  }
1200  else if ( aLangText == "RESET_LANGUAGES" )
1201  {
1202  bool bAutoSpell;
1203 
1204  ScModule::GetSpellSettings(eLang, eCjk, eCtl, bAutoSpell);
1205  rDoc.SetLanguage(eLang, eCjk, eCtl);
1206  }
1207  else
1208  {
1209  eLang = SvtLanguageTable::GetLanguageType( aLangText );
1210  if ( eLang != LANGUAGE_DONTKNOW && SvtLanguageOptions::GetScriptTypeOfLanguage(eLang) == SvtScriptType::LATIN )
1211  {
1212  rDoc.SetLanguage( eLang, eCjk, eCtl );
1213  }
1214  else
1215  {
1216  eLang = eLatin;
1217  }
1218  }
1219  }
1220  else if (-1 != (nPos = aLangText.indexOf( aSelectionLangPrefix )))
1221  {
1222  bSelection = true;
1223  aLangText = aLangText.replaceAt( nPos, aSelectionLangPrefix.getLength(), "" );
1224  }
1225  else if (-1 != (nPos = aLangText.indexOf( aParagraphLangPrefix )))
1226  {
1227  bParagraph = true;
1228  aLangText = aLangText.replaceAt( nPos, aParagraphLangPrefix.getLength(), "" );
1229  }
1230 
1231  if (bSelection || bParagraph)
1232  {
1233  ScViewData* pViewData = GetViewData();
1234  if (!pViewData)
1235  return;
1236 
1237  EditView* pEditView = pViewData->GetEditView(pViewData->GetActivePart());
1238  if (!pEditView)
1239  return;
1240 
1241  const LanguageType nLangToUse = SvtLanguageTable::GetLanguageType( aLangText );
1242  SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse );
1243 
1244  SfxItemSet aAttrs = pEditView->GetEditEngine()->GetEmptyItemSet();
1245  if (nScriptType == SvtScriptType::LATIN)
1246  aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) );
1247  if (nScriptType == SvtScriptType::COMPLEX)
1248  aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CTL ) );
1249  if (nScriptType == SvtScriptType::ASIAN)
1250  aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CJK ) );
1251  ESelection aOldSel;
1252  if (bParagraph)
1253  {
1254  ESelection aSel = pEditView->GetSelection();
1255  aOldSel = aSel;
1256  aSel.nStartPos = 0;
1257  aSel.nEndPos = EE_TEXTPOS_ALL;
1258  pEditView->SetSelection( aSel );
1259  }
1260 
1261  pEditView->SetAttribs( aAttrs );
1262  if (bParagraph)
1263  pEditView->SetSelection( aOldSel );
1264  }
1265  else if ( eLang != eLatin )
1266  {
1268  {
1269  ScInputHandler* pInputHandler = SC_MOD()->GetInputHdl(pViewSh);
1270  if ( pInputHandler )
1271  pInputHandler->UpdateSpellSettings();
1272 
1273  pViewSh->UpdateDrawTextOutliner();
1274  }
1275 
1277  Broadcast(SfxHint(SfxHintId::LanguageChanged));
1278  PostPaintGridAll();
1279  }
1280  }
1281  }
1282  break;
1283  case SID_SPELLCHECK_IGNORE_ALL:
1284  {
1285  ScViewData* pViewData = GetViewData();
1286  if (!pViewData)
1287  return;
1288 
1289  EditView* pEditView = pViewData->GetEditView(pViewData->GetActivePart());
1290  if (!pEditView)
1291  return;
1292 
1293  OUString sIgnoreText;
1294  const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
1295  if (pItem2)
1296  sIgnoreText = pItem2->GetValue();
1297 
1298  if(sIgnoreText == "Spelling")
1299  {
1300  ESelection aOldSel = pEditView->GetSelection();
1301  pEditView->SpellIgnoreWord();
1302  pEditView->SetSelection( aOldSel );
1303  }
1304  }
1305  break;
1306  case SID_SPELLCHECK_APPLY_SUGGESTION:
1307  {
1308  ScViewData* pViewData = GetViewData();
1309  if (!pViewData)
1310  return;
1311 
1312  EditView* pEditView = pViewData->GetEditView(pViewData->GetActivePart());
1313  if (!pEditView)
1314  return;
1315 
1316  OUString sApplyText;
1317  const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
1318  if (pItem2)
1319  sApplyText = pItem2->GetValue();
1320 
1321  const OUString sSpellingRule("Spelling_");
1322  sal_Int32 nPos = 0;
1323  if(-1 != (nPos = sApplyText.indexOf( sSpellingRule )))
1324  {
1325  sApplyText = sApplyText.replaceAt(nPos, sSpellingRule.getLength(), "");
1326  pEditView->InsertText( sApplyText );
1327  }
1328  }
1329  break;
1330  default:
1331  {
1332  // small (?) hack -> forwarding of the slots to TabViewShell
1334  if ( pSh )
1335  pSh->Execute( rReq );
1336 #if HAVE_FEATURE_SCRIPTING
1337  else
1339 #endif
1340  }
1341  }
1342 }
1343 
1345 {
1346  // update "accept changes" dialog
1348  SfxViewFrame* pViewFrm = SfxViewFrame::Current();
1349  if ( pViewFrm && pViewFrm->HasChildWindow( FID_CHG_ACCEPT ) )
1350  {
1351  SfxChildWindow* pChild = pViewFrm->GetChildWindow( FID_CHG_ACCEPT );
1352  if ( pChild )
1353  static_cast<ScAcceptChgDlgWrapper*>(pChild)->ReInitDlg();
1354  }
1355 }
1356 
1357 bool ScDocShell::ExecuteChangeProtectionDialog( bool bJustQueryIfProtected )
1358 {
1359  bool bDone = false;
1360  ScChangeTrack* pChangeTrack = m_aDocument.GetChangeTrack();
1361  if ( pChangeTrack )
1362  {
1363  bool bProtected = pChangeTrack->IsProtected();
1364  if ( bJustQueryIfProtected && !bProtected )
1365  return true;
1366 
1367  OUString aTitle( ScResId( bProtected ? SCSTR_CHG_UNPROTECT : SCSTR_CHG_PROTECT ) );
1368  OUString aText( ScResId( SCSTR_PASSWORD ) );
1369  OUString aPassword;
1370 
1372  SfxPasswordDialog aDlg(pWin, &aText);
1373  aDlg.set_title(aTitle);
1374  aDlg.SetMinLen(1);
1375  aDlg.set_help_id(GetStaticInterface()->GetSlot(SID_CHG_PROTECT)->GetCommand());
1377  if ( !bProtected )
1378  aDlg.ShowExtras(SfxShowExtras::CONFIRM);
1379  if (aDlg.run() == RET_OK)
1380  aPassword = aDlg.GetPassword();
1381 
1382  if (!aPassword.isEmpty())
1383  {
1384  if ( bProtected )
1385  {
1386  if ( SvPasswordHelper::CompareHashPassword(pChangeTrack->GetProtection(), aPassword) )
1387  {
1388  if ( bJustQueryIfProtected )
1389  bDone = true;
1390  else
1391  pChangeTrack->SetProtection(
1392  css::uno::Sequence< sal_Int8 > (0) );
1393  }
1394  else
1395  {
1396  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin,
1397  VclMessageType::Info, VclButtonsType::Ok,
1398  ScResId(SCSTR_WRONGPASSWORD)));
1399  xInfoBox->run();
1400  }
1401  }
1402  else
1403  {
1404  css::uno::Sequence< sal_Int8 > aPass;
1405  SvPasswordHelper::GetHashPassword( aPass, aPassword );
1406  pChangeTrack->SetProtection( aPass );
1407  }
1408  if ( bProtected != pChangeTrack->IsProtected() )
1409  {
1411  bDone = true;
1412  }
1413  }
1414  }
1415  else if ( bJustQueryIfProtected )
1416  bDone = true;
1417  return bDone;
1418 }
1419 
1420 void ScDocShell::DoRecalc( bool bApi )
1421 {
1423  bool bDone = false;
1425  ScInputHandler* pHdl = ( pSh ? SC_MOD()->GetInputHdl( pSh ) : nullptr );
1426  if ( pSh )
1427  {
1428  if ( pHdl && pHdl->IsInputMode() && pHdl->IsFormulaMode() && !bApi )
1429  {
1430  pHdl->FormulaPreview(); // partial result as QuickHelp
1431  bDone = true;
1432  }
1433  else
1434  {
1435  ScTabView::UpdateInputLine(); // InputEnterHandler
1436  pSh->UpdateInputHandler();
1437  }
1438  }
1439  if (bDone) // otherwise re-calculate document
1440  return;
1441 
1443  if ( pHdl )
1444  {
1445  // tdf97897 set current cell to Dirty to force recalculation of cell
1447  if (pFC)
1448  pFC->SetDirty();
1449  }
1451  if ( pSh )
1452  pSh->UpdateCharts(true);
1453 
1454  m_aDocument.BroadcastUno( SfxHint( SfxHintId::DataChanged ) );
1455 
1456  // If there are charts, then paint everything, so that PostDataChanged
1457  // and the charts do not come one after the other and parts are painted twice.
1458 
1460  if ( pCharts && pCharts->hasListeners() )
1461  PostPaintGridAll();
1462  else
1463  PostDataChanged();
1464 }
1465 
1467 {
1468  auto start = std::chrono::steady_clock::now();
1472  if ( pSh )
1473  {
1474  ScTabView::UpdateInputLine(); // InputEnterHandler
1475  pSh->UpdateInputHandler();
1476  }
1477  m_aDocument.CalcAll();
1478  GetDocFunc().DetectiveRefresh(); // creates own Undo
1479  if ( pSh )
1480  pSh->UpdateCharts(true);
1481 
1482  // set notification flags for "calculate" event (used in SfxHintId::DataChanged broadcast)
1483  // (might check for the presence of any formulas on each sheet)
1484  SCTAB nTabCount = m_aDocument.GetTableCount();
1485  if (m_aDocument.HasAnySheetEventScript( ScSheetEventId::CALCULATE, true )) // search also for VBA handler
1486  for (SCTAB nTab=0; nTab<nTabCount; nTab++)
1488 
1489  // CalcAll doesn't broadcast value changes, so SfxHintId::ScCalcAll is broadcasted globally
1490  // in addition to SfxHintId::DataChanged.
1491  m_aDocument.BroadcastUno( SfxHint( SfxHintId::ScCalcAll ) );
1492  m_aDocument.BroadcastUno( SfxHint( SfxHintId::DataChanged ) );
1493 
1494  // use hard recalc also to disable stream-copying of all sheets
1495  // (somewhat consistent with charts)
1496  for (SCTAB nTab=0; nTab<nTabCount; nTab++)
1497  m_aDocument.SetStreamValid(nTab, false);
1498 
1499  PostPaintGridAll();
1500  auto end = std::chrono::steady_clock::now();
1501  SAL_INFO("sc.timing", "ScDocShell::DoHardRecalc(): took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms");
1502 }
1503 
1504 void ScDocShell::DoAutoStyle( const ScRange& rRange, const OUString& rStyle )
1505 {
1507  ScStyleSheet* pStyleSheet =
1508  pStylePool->FindCaseIns( rStyle, SfxStyleFamily::Para );
1509  if (!pStyleSheet)
1510  pStyleSheet = static_cast<ScStyleSheet*>(
1511  pStylePool->Find( ScResId(STR_STYLENAME_STANDARD_CELL), SfxStyleFamily::Para ));
1512  if (!pStyleSheet)
1513  return;
1514 
1515  OSL_ENSURE(rRange.aStart.Tab() == rRange.aEnd.Tab(),
1516  "DoAutoStyle with several tables");
1517  SCTAB nTab = rRange.aStart.Tab();
1518  SCCOL nStartCol = rRange.aStart.Col();
1519  SCROW nStartRow = rRange.aStart.Row();
1520  SCCOL nEndCol = rRange.aEnd.Col();
1521  SCROW nEndRow = rRange.aEnd.Row();
1522  m_aDocument.ApplyStyleAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, *pStyleSheet );
1523  m_aDocument.ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab );
1524  PostPaint( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab, PaintPartFlags::Grid );
1525 }
1526 
1528 {
1529  SfxHintId nId = rHint.GetId();
1530  const SfxStyleSheetBase* pStyle = rHint.GetStyleSheet();
1531  if (!pStyle)
1532  return;
1533 
1534  if ( pStyle->GetFamily() == SfxStyleFamily::Page )
1535  {
1536  if ( nId == SfxHintId::StyleSheetModified )
1537  {
1538  ScDocShellModificator aModificator( *this );
1539 
1540  const OUString& aNewName = pStyle->GetName();
1541  OUString aOldName = aNewName;
1542  const SfxStyleSheetModifiedHint* pExtendedHint = dynamic_cast<const SfxStyleSheetModifiedHint*>(&rHint); // name changed?
1543  if (pExtendedHint)
1544  aOldName = pExtendedHint->GetOldName();
1545 
1546  if ( aNewName != aOldName )
1547  m_aDocument.RenamePageStyleInUse( aOldName, aNewName );
1548 
1549  SCTAB nTabCount = m_aDocument.GetTableCount();
1550  for (SCTAB nTab=0; nTab<nTabCount; nTab++)
1551  if (m_aDocument.GetPageStyle(nTab) == aNewName) // already adjusted to new
1552  {
1553  m_aDocument.PageStyleModified( nTab, aNewName );
1554  ScPrintFunc aPrintFunc( this, GetPrinter(), nTab );
1555  aPrintFunc.UpdatePages();
1556  }
1557 
1558  aModificator.SetDocumentModified();
1559 
1560  if (pExtendedHint)
1561  {
1562  SfxBindings* pBindings = GetViewBindings();
1563  if (pBindings)
1564  {
1565  pBindings->Invalidate( SID_STATUS_PAGESTYLE );
1566  pBindings->Invalidate( SID_STYLE_FAMILY4 );
1567  pBindings->Invalidate( FID_RESET_PRINTZOOM );
1568  pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
1569  pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
1570  }
1571  }
1572  }
1573  }
1574  else if ( pStyle->GetFamily() == SfxStyleFamily::Para )
1575  {
1576  if ( nId == SfxHintId::StyleSheetModified)
1577  {
1578  const OUString& aNewName = pStyle->GetName();
1579  OUString aOldName = aNewName;
1580  const SfxStyleSheetModifiedHint* pExtendedHint = dynamic_cast<const SfxStyleSheetModifiedHint*>(&rHint);
1581  if (pExtendedHint)
1582  aOldName = pExtendedHint->GetOldName();
1583  if ( aNewName != aOldName )
1584  {
1585  for(SCTAB i = 0; i < m_aDocument.GetTableCount(); ++i)
1586  {
1588  if (pList)
1589  pList->RenameCellStyle( aOldName,aNewName );
1590  }
1591  }
1592  }
1593  }
1594 
1595  // everything else goes via slots...
1596 }
1597 
1598 // like in printfun.cxx
1599 #define ZOOM_MIN 10
1600 
1601 void ScDocShell::SetPrintZoom( SCTAB nTab, sal_uInt16 nScale, sal_uInt16 nPages )
1602 {
1603  OUString aStyleName = m_aDocument.GetPageStyle( nTab );
1605  SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SfxStyleFamily::Page );
1606  OSL_ENSURE( pStyleSheet, "PageStyle not found" );
1607  if ( !pStyleSheet )
1608  return;
1609 
1610  ScDocShellModificator aModificator( *this );
1611 
1612  SfxItemSet& rSet = pStyleSheet->GetItemSet();
1613  const bool bUndo(m_aDocument.IsUndoEnabled());
1614  if (bUndo)
1615  {
1616  sal_uInt16 nOldScale = rSet.Get(ATTR_PAGE_SCALE).GetValue();
1617  sal_uInt16 nOldPages = rSet.Get(ATTR_PAGE_SCALETOPAGES).GetValue();
1618  GetUndoManager()->AddUndoAction( std::make_unique<ScUndoPrintZoom>(
1619  this, nTab, nOldScale, nOldPages, nScale, nPages ) );
1620  }
1621 
1622  rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nScale ) );
1623  rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, nPages ) );
1624 
1625  ScPrintFunc aPrintFunc( this, GetPrinter(), nTab );
1626  aPrintFunc.UpdatePages();
1627  aModificator.SetDocumentModified();
1628 
1629  SfxBindings* pBindings = GetViewBindings();
1630  if (pBindings)
1631  pBindings->Invalidate( FID_RESET_PRINTZOOM );
1632 }
1633 
1635 {
1636  bool bChange = false;
1637  SCTAB nTab = rRange.aStart.Tab();
1638 
1639  OUString aStyleName = m_aDocument.GetPageStyle( nTab );
1641  SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SfxStyleFamily::Page );
1642  OSL_ENSURE( pStyleSheet, "PageStyle not found" );
1643  if ( pStyleSheet )
1644  {
1645  SfxItemSet& rSet = pStyleSheet->GetItemSet();
1646  bool bHeaders = rSet.Get(ATTR_PAGE_HEADERS).GetValue();
1647  sal_uInt16 nOldScale = rSet.Get(ATTR_PAGE_SCALE).GetValue();
1648  sal_uInt16 nOldPages = rSet.Get(ATTR_PAGE_SCALETOPAGES).GetValue();
1649  const ScRange* pRepeatCol = m_aDocument.GetRepeatColRange( nTab );
1650  const ScRange* pRepeatRow = m_aDocument.GetRepeatRowRange( nTab );
1651 
1652  // calculate needed scaling for selection
1653 
1654  sal_uInt16 nNewScale = nOldScale;
1655 
1656  long nBlkTwipsX = 0;
1657  if (bHeaders)
1658  nBlkTwipsX += long(PRINT_HEADER_WIDTH);
1659  SCCOL nStartCol = rRange.aStart.Col();
1660  SCCOL nEndCol = rRange.aEnd.Col();
1661  if ( pRepeatCol && nStartCol >= pRepeatCol->aStart.Col() )
1662  {
1663  for (SCCOL i=pRepeatCol->aStart.Col(); i<=pRepeatCol->aEnd.Col(); i++ )
1664  nBlkTwipsX += m_aDocument.GetColWidth( i, nTab );
1665  if ( nStartCol <= pRepeatCol->aEnd.Col() )
1666  nStartCol = pRepeatCol->aEnd.Col() + 1;
1667  }
1668  // legacy compilers' own scope for i
1669  {
1670  for ( SCCOL i=nStartCol; i<=nEndCol; i++ )
1671  nBlkTwipsX += m_aDocument.GetColWidth( i, nTab );
1672  }
1673 
1674  long nBlkTwipsY = 0;
1675  if (bHeaders)
1676  nBlkTwipsY += long(PRINT_HEADER_HEIGHT);
1677  SCROW nStartRow = rRange.aStart.Row();
1678  SCROW nEndRow = rRange.aEnd.Row();
1679  if ( pRepeatRow && nStartRow >= pRepeatRow->aStart.Row() )
1680  {
1681  nBlkTwipsY += m_aDocument.GetRowHeight( pRepeatRow->aStart.Row(),
1682  pRepeatRow->aEnd.Row(), nTab );
1683  if ( nStartRow <= pRepeatRow->aEnd.Row() )
1684  nStartRow = pRepeatRow->aEnd.Row() + 1;
1685  }
1686  nBlkTwipsY += m_aDocument.GetRowHeight( nStartRow, nEndRow, nTab );
1687 
1688  Size aPhysPage;
1689  long nHdr, nFtr;
1690  ScPrintFunc aOldPrFunc( this, GetPrinter(), nTab );
1691  aOldPrFunc.GetScaleData( aPhysPage, nHdr, nFtr );
1692  nBlkTwipsY += nHdr + nFtr;
1693 
1694  if ( nBlkTwipsX == 0 ) // hidden columns/rows may lead to 0
1695  nBlkTwipsX = 1;
1696  if ( nBlkTwipsY == 0 )
1697  nBlkTwipsY = 1;
1698 
1699  long nNeeded = std::min( aPhysPage.Width() * 100 / nBlkTwipsX,
1700  aPhysPage.Height() * 100 / nBlkTwipsY );
1701  if ( nNeeded < ZOOM_MIN )
1702  nNeeded = ZOOM_MIN; // boundary
1703  if ( nNeeded < static_cast<long>(nNewScale) )
1704  nNewScale = static_cast<sal_uInt16>(nNeeded);
1705 
1706  bChange = ( nNewScale != nOldScale || nOldPages != 0 );
1707  if ( bChange )
1708  SetPrintZoom( nTab, nNewScale, 0 );
1709  }
1710  return bChange;
1711 }
1712 
1713 void ScDocShell::PageStyleModified( const OUString& rStyleName, bool bApi )
1714 {
1715  ScDocShellModificator aModificator( *this );
1716 
1717  SCTAB nTabCount = m_aDocument.GetTableCount();
1718  SCTAB nUseTab = MAXTAB+1;
1719  for (SCTAB nTab=0; nTab<nTabCount && nUseTab>MAXTAB; nTab++)
1720  if ( m_aDocument.GetPageStyle(nTab) == rStyleName &&
1721  ( !bApi || m_aDocument.GetPageSize(nTab).Width() ) )
1722  nUseTab = nTab;
1723  // at bApi only if breaks already shown
1724 
1725  if (ValidTab(nUseTab)) // not used -> nothing to do
1726  {
1727  bool bWarn = false;
1728 
1729  ScPrintFunc aPrintFunc( this, GetPrinter(), nUseTab );
1730  if (!aPrintFunc.UpdatePages()) // sets breaks on all tabs
1731  bWarn = true;
1732 
1733  if (bWarn && !bApi)
1734  {
1736  weld::WaitObject aWaitOff(pWin);
1737  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pWin,
1738  VclMessageType::Info, VclButtonsType::Ok,
1739  ScResId(STR_PRINT_INVALID_AREA)));
1740  xInfoBox->run();
1741  }
1742  }
1743 
1744  aModificator.SetDocumentModified();
1745 
1746  SfxBindings* pBindings = GetViewBindings();
1747  if (pBindings)
1748  {
1749  pBindings->Invalidate( FID_RESET_PRINTZOOM );
1750  pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
1751  pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
1752  }
1753 }
1754 
1756  SfxRequest& rReq,
1757  SCTAB nCurTab )
1758 {
1759  const SfxItemSet* pReqArgs = rReq.GetArgs();
1760 
1761  switch ( rReq.GetSlot() )
1762  {
1763  case SID_STATUS_PAGESTYLE: // click on StatusBar control
1764  case SID_FORMATPAGE:
1765  {
1766  if ( pReqArgs == nullptr )
1767  {
1768  OUString aOldName = m_aDocument.GetPageStyle( nCurTab );
1770  SfxStyleSheetBase* pStyleSheet
1771  = pStylePool->Find( aOldName, SfxStyleFamily::Page );
1772 
1773  OSL_ENSURE( pStyleSheet, "PageStyle not found! :-/" );
1774 
1775  if ( pStyleSheet )
1776  {
1777  ScStyleSaveData aOldData;
1778  const bool bUndo(m_aDocument.IsUndoEnabled());
1779  if (bUndo)
1780  aOldData.InitFromStyle( pStyleSheet );
1781 
1782  SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
1784 
1786 
1787  VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateScStyleDlg(GetActiveDialogParent(), *pStyleSheet, true));
1788 
1789  auto pRequest = std::make_shared<SfxRequest>(rReq);
1790  rReq.Ignore(); // the 'old' request is not relevant any more
1791  pDlg->StartExecuteAsync([this, pDlg, pRequest, pStyleSheet, aOldData, aOldName, &rStyleSet, nCurTab, &rCaller, bUndo](sal_Int32 nResult){
1792  if ( nResult == RET_OK )
1793  {
1794  const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
1795 
1797 
1798  OUString aNewName = pStyleSheet->GetName();
1799  if ( aNewName != aOldName &&
1800  m_aDocument.RenamePageStyleInUse( aOldName, aNewName ) )
1801  {
1802  SfxBindings* pBindings = GetViewBindings();
1803  if (pBindings)
1804  {
1805  pBindings->Invalidate( SID_STATUS_PAGESTYLE );
1806  pBindings->Invalidate( FID_RESET_PRINTZOOM );
1807  }
1808  }
1809 
1810  if ( pOutSet )
1811  m_aDocument.ModifyStyleSheet( *pStyleSheet, *pOutSet );
1812 
1813  // memorizing for GetState():
1814  GetPageOnFromPageStyleSet( &rStyleSet, nCurTab, m_bHeaderOn, m_bFooterOn );
1815  rCaller.GetViewFrame()->GetBindings().Invalidate( SID_HFEDIT );
1816 
1817  ScStyleSaveData aNewData;
1818  aNewData.InitFromStyle( pStyleSheet );
1819  if (bUndo)
1820  {
1822  std::make_unique<ScUndoModifyStyle>( this, SfxStyleFamily::Page,
1823  aOldData, aNewData ) );
1824  }
1825 
1826  PageStyleModified( aNewName, false );
1827  pRequest->Done();
1828  }
1829  pDlg->disposeOnce();
1830  });
1831  }
1832  }
1833  }
1834  break;
1835 
1836  case SID_HFEDIT:
1837  {
1838  if ( pReqArgs == nullptr )
1839  {
1840  OUString aStr( m_aDocument.GetPageStyle( nCurTab ) );
1841 
1842  ScStyleSheetPool* pStylePool
1844 
1845  SfxStyleSheetBase* pStyleSheet
1846  = pStylePool->Find( aStr, SfxStyleFamily::Page );
1847 
1848  OSL_ENSURE( pStyleSheet, "PageStyle not found! :-/" );
1849 
1850  if ( pStyleSheet )
1851  {
1852  SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
1853 
1854  SvxPageUsage eUsage = rStyleSet.Get( ATTR_PAGE ).GetPageUsage();
1855  bool bShareHeader = rStyleSet
1857  .GetItemSet()
1858  .Get(ATTR_PAGE_SHARED)
1859  .GetValue();
1860  bool bShareFooter = rStyleSet
1862  .GetItemSet()
1863  .Get(ATTR_PAGE_SHARED)
1864  .GetValue();
1865  sal_uInt16 nResId = 0;
1866 
1867  switch ( eUsage )
1868  {
1869  case SvxPageUsage::Left:
1870  case SvxPageUsage::Right:
1871  {
1872  if ( m_bHeaderOn && m_bFooterOn )
1873  nResId = RID_SCDLG_HFEDIT;
1874  else if ( SvxPageUsage::Right == eUsage )
1875  {
1876  if ( !m_bHeaderOn && m_bFooterOn )
1877  nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER;
1878  else if ( m_bHeaderOn && !m_bFooterOn )
1879  nResId = RID_SCDLG_HFEDIT_RIGHTHEADER;
1880  }
1881  else
1882  {
1883  // #69193a# respect "shared" setting
1884  if ( !m_bHeaderOn && m_bFooterOn )
1885  nResId = bShareFooter ?
1886  RID_SCDLG_HFEDIT_RIGHTFOOTER :
1887  RID_SCDLG_HFEDIT_LEFTFOOTER;
1888  else if ( m_bHeaderOn && !m_bFooterOn )
1889  nResId = bShareHeader ?
1890  RID_SCDLG_HFEDIT_RIGHTHEADER :
1891  RID_SCDLG_HFEDIT_LEFTHEADER;
1892  }
1893  }
1894  break;
1895 
1896  case SvxPageUsage::Mirror:
1897  case SvxPageUsage::All:
1898  default:
1899  {
1900  if ( !bShareHeader && !bShareFooter )
1901  {
1902  if ( m_bHeaderOn && m_bFooterOn )
1903  nResId = RID_SCDLG_HFEDIT_ALL;
1904  else if ( !m_bHeaderOn && m_bFooterOn )
1905  nResId = RID_SCDLG_HFEDIT_FOOTER;
1906  else if ( m_bHeaderOn && !m_bFooterOn )
1907  nResId = RID_SCDLG_HFEDIT_HEADER;
1908  }
1909  else if ( bShareHeader && bShareFooter )
1910  {
1911  if ( m_bHeaderOn && m_bFooterOn )
1912  nResId = RID_SCDLG_HFEDIT;
1913  else
1914  {
1915  if ( !m_bHeaderOn && m_bFooterOn )
1916  nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER;
1917  else if ( m_bHeaderOn && !m_bFooterOn )
1918  nResId = RID_SCDLG_HFEDIT_RIGHTHEADER;
1919  }
1920  }
1921  else if ( !bShareHeader && bShareFooter )
1922  {
1923  if ( m_bHeaderOn && m_bFooterOn )
1924  nResId = RID_SCDLG_HFEDIT_SFTR;
1925  else if ( !m_bHeaderOn && m_bFooterOn )
1926  nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER;
1927  else if ( m_bHeaderOn && !m_bFooterOn )
1928  nResId = RID_SCDLG_HFEDIT_HEADER;
1929  }
1930  else if ( bShareHeader && !bShareFooter )
1931  {
1932  if ( m_bHeaderOn && m_bFooterOn )
1933  nResId = RID_SCDLG_HFEDIT_SHDR;
1934  else if ( !m_bHeaderOn && m_bFooterOn )
1935  nResId = RID_SCDLG_HFEDIT_FOOTER;
1936  else if ( m_bHeaderOn && !m_bFooterOn )
1937  nResId = RID_SCDLG_HFEDIT_RIGHTHEADER;
1938  }
1939  }
1940  }
1941 
1943 
1946  rStyleSet,
1947  aStr,
1948  nResId));
1949  auto xRequest = std::make_shared<SfxRequest>(rReq);
1950  rReq.Ignore(); // the 'old' request is not relevant any more
1951  pDlg->StartExecuteAsync([this, pDlg, pStyleSheet, xRequest](sal_Int32 nResult){
1952  if ( nResult == RET_OK )
1953  {
1954  const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
1955 
1956  if ( pOutSet )
1957  m_aDocument.ModifyStyleSheet( *pStyleSheet, *pOutSet );
1958 
1960  xRequest->Done();
1961  }
1962  pDlg->disposeOnce();
1963  });
1964  }
1965  }
1966  }
1967  break;
1968 
1969  default:
1970  break;
1971  }
1972 }
1973 
1975  SCTAB nCurTab )
1976 {
1977  SfxWhichIter aIter(rSet);
1978  sal_uInt16 nWhich = aIter.FirstWhich();
1979  while ( nWhich )
1980  {
1981  switch (nWhich)
1982  {
1983  case SID_STATUS_PAGESTYLE:
1984  rSet.Put( SfxStringItem( nWhich, m_aDocument.GetPageStyle( nCurTab ) ) );
1985  break;
1986 
1987  case SID_HFEDIT:
1988  {
1989  OUString aStr = m_aDocument.GetPageStyle( nCurTab );
1991  SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStr, SfxStyleFamily::Page );
1992 
1993  OSL_ENSURE( pStyleSheet, "PageStyle not found! :-/" );
1994 
1995  if ( pStyleSheet )
1996  {
1997  SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
1998  GetPageOnFromPageStyleSet( &rStyleSet, nCurTab, m_bHeaderOn, m_bFooterOn );
1999 
2000  if ( !m_bHeaderOn && !m_bFooterOn )
2001  rSet.DisableItem( nWhich );
2002  }
2003  }
2004  break;
2005  }
2006 
2007  nWhich = aIter.NextWhich();
2008  }
2009 }
2010 
2012 {
2013  bool bTabView = GetBestViewShell() != nullptr;
2014 
2015  SfxWhichIter aIter(rSet);
2016  for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich())
2017  {
2018  if (!bTabView)
2019  {
2020  rSet.DisableItem(nWhich);
2021  continue;
2022  }
2023 
2024  switch (nWhich)
2025  {
2026  case FID_AUTO_CALC:
2028  rSet.DisableItem( nWhich );
2029  else
2030  rSet.Put( SfxBoolItem( nWhich, m_aDocument.GetAutoCalc() ) );
2031  break;
2032 
2033  case FID_CHG_RECORD:
2034  if ( IsDocShared() )
2035  rSet.DisableItem( nWhich );
2036  else
2037  rSet.Put( SfxBoolItem( nWhich,
2038  m_aDocument.GetChangeTrack() != nullptr ) );
2039  break;
2040 
2041  case SID_CHG_PROTECT:
2042  {
2043  ScChangeTrack* pChangeTrack = m_aDocument.GetChangeTrack();
2044  if ( pChangeTrack && !IsDocShared() )
2045  rSet.Put( SfxBoolItem( nWhich,
2046  pChangeTrack->IsProtected() ) );
2047  else
2048  rSet.DisableItem( nWhich );
2049  }
2050  break;
2051 
2052  case SID_DOCUMENT_COMPARE:
2053  {
2054  if ( IsDocShared() )
2055  {
2056  rSet.DisableItem( nWhich );
2057  }
2058  }
2059  break;
2060 
2061  // When a formula is edited, FID_RECALC must be enabled in any case. Recalc for
2062  // the doc was disabled once because of a bug if AutoCalc was on, but is now
2063  // always enabled because of another bug.
2064 
2065  case SID_TABLES_COUNT:
2066  rSet.Put( SfxInt16Item( nWhich, m_aDocument.GetTableCount() ) );
2067  break;
2068 
2069  case SID_ATTR_YEAR2000 :
2070  rSet.Put( SfxUInt16Item( nWhich,
2072  break;
2073 
2074  case SID_SHARE_DOC:
2075  {
2076  if ( IsReadOnly() || GetObjectShell()->isExportLocked() )
2077  {
2078  rSet.DisableItem( nWhich );
2079  }
2080  }
2081  break;
2082 
2083  case SID_ATTR_CHAR_FONTLIST:
2084  rSet.Put( SvxFontListItem( m_pImpl->pFontList.get(), nWhich ) );
2085  break;
2086 
2087  case SID_NOTEBOOKBAR:
2088  {
2089  if (GetViewBindings())
2090  {
2092  "modules/scalc/ui/");
2093  rSet.Put( SfxBoolItem( SID_NOTEBOOKBAR, bVisible ) );
2094  }
2095  }
2096  break;
2097 
2098  case SID_LANGUAGE_STATUS:
2099  {
2100  LanguageType eLatin, eCjk, eCtl;
2101 
2102  GetDocument().GetLanguage( eLatin, eCjk, eCtl );
2103  OUString sLanguage = SvtLanguageTable::GetLanguageString(eLatin);
2105  if (eLatin == LANGUAGE_NONE)
2106  sLanguage += ";-";
2107  else
2108  sLanguage += ";" + LanguageTag(eLatin).getBcp47(false);
2109  }
2110  rSet.Put(SfxStringItem(nWhich, sLanguage));
2111  }
2112  break;
2113 
2114  default:
2115  {
2116  }
2117  break;
2118  }
2119  }
2120 }
2121 
2122 void ScDocShell::Draw( OutputDevice* pDev, const JobSetup & /* rSetup */, sal_uInt16 nAspect )
2123 {
2124 
2125  SCTAB nVisTab = m_aDocument.GetVisibleTab();
2126  if (!m_aDocument.HasTable(nVisTab))
2127  return;
2128 
2129  ComplexTextLayoutFlags nOldLayoutMode = pDev->GetLayoutMode();
2130  pDev->SetLayoutMode( ComplexTextLayoutFlags::Default ); // even if it's the same, to get the metafile action
2131 
2132  if ( nAspect == ASPECT_THUMBNAIL )
2133  {
2135  ScViewData aTmpData( this, nullptr );
2136  aTmpData.SetTabNo(nVisTab);
2137  SnapVisArea( aBoundRect );
2138  aTmpData.SetScreen( aBoundRect );
2139  ScPrintFunc::DrawToDev( &m_aDocument, pDev, 1.0, aBoundRect, &aTmpData, true );
2140  }
2141  else
2142  {
2144  tools::Rectangle aNewArea = aOldArea;
2145  ScViewData aTmpData( this, nullptr );
2146  aTmpData.SetTabNo(nVisTab);
2147  SnapVisArea( aNewArea );
2148  if ( aNewArea != aOldArea && (m_aDocument.GetPosLeft() > 0 || m_aDocument.GetPosTop() > 0) )
2149  SfxObjectShell::SetVisArea( aNewArea );
2150  aTmpData.SetScreen( aNewArea );
2151  ScPrintFunc::DrawToDev( &m_aDocument, pDev, 1.0, aNewArea, &aTmpData, true );
2152  }
2153 
2154  pDev->SetLayoutMode( nOldLayoutMode );
2155 }
2156 
2157 tools::Rectangle ScDocShell::GetVisArea( sal_uInt16 nAspect ) const
2158 {
2159  SfxObjectCreateMode eShellMode = GetCreateMode();
2160  if ( eShellMode == SfxObjectCreateMode::ORGANIZER )
2161  {
2162  // without contents we also don't know how large are the contents;
2163  // return empty rectangle, it will then be calculated after the loading
2164  return tools::Rectangle();
2165  }
2166 
2167  if( nAspect == ASPECT_THUMBNAIL )
2168  {
2169  SCTAB nVisTab = m_aDocument.GetVisibleTab();
2170  if (!m_aDocument.HasTable(nVisTab))
2171  {
2172  nVisTab = 0;
2173  const_cast<ScDocShell*>(this)->m_aDocument.SetVisibleTab(nVisTab);
2174  }
2175  Size aSize = m_aDocument.GetPageSize(nVisTab);
2176  const long SC_PREVIEW_SIZE_X = 10000;
2177  const long SC_PREVIEW_SIZE_Y = 12400;
2178  tools::Rectangle aArea( 0,0, SC_PREVIEW_SIZE_X, SC_PREVIEW_SIZE_Y);
2179  if (aSize.Width() > aSize.Height())
2180  {
2181  aArea.SetRight( SC_PREVIEW_SIZE_Y );
2182  aArea.SetBottom( SC_PREVIEW_SIZE_X );
2183  }
2184 
2185  bool bNegativePage = m_aDocument.IsNegativePage( m_aDocument.GetVisibleTab() );
2186  if ( bNegativePage )
2187  ScDrawLayer::MirrorRectRTL( aArea );
2188  SnapVisArea( aArea );
2189  return aArea;
2190  }
2191  else if( nAspect == ASPECT_CONTENT && eShellMode != SfxObjectCreateMode::EMBEDDED )
2192  {
2193  // fetch visarea like after loading
2194 
2195  SCTAB nVisTab = m_aDocument.GetVisibleTab();
2196  if (!m_aDocument.HasTable(nVisTab))
2197  {
2198  nVisTab = 0;
2199  const_cast<ScDocShell*>(this)->m_aDocument.SetVisibleTab(nVisTab);
2200  }
2201  SCCOL nStartCol;
2202  SCROW nStartRow;
2203  m_aDocument.GetDataStart( nVisTab, nStartCol, nStartRow );
2204  SCCOL nEndCol;
2205  SCROW nEndRow;
2206  m_aDocument.GetPrintArea( nVisTab, nEndCol, nEndRow );
2207  if (nStartCol>nEndCol)
2208  nStartCol = nEndCol;
2209  if (nStartRow>nEndRow)
2210  nStartRow = nEndRow;
2211  tools::Rectangle aNewArea = m_aDocument
2212  .GetMMRect( nStartCol,nStartRow, nEndCol,nEndRow, nVisTab );
2213  return aNewArea;
2214  }
2215  else
2216  return SfxObjectShell::GetVisArea( nAspect );
2217 }
2218 
2219 namespace {
2220 
2221 [[nodiscard]]
2222 long SnapHorizontal( const ScDocument& rDoc, SCTAB nTab, long nVal, SCCOL& rStartCol )
2223 {
2224  SCCOL nCol = 0;
2225  long nTwips = static_cast<long>(nVal / HMM_PER_TWIPS);
2226  long nSnap = 0;
2227  while ( nCol<rDoc.MaxCol() )
2228  {
2229  long nAdd = rDoc.GetColWidth(nCol, nTab);
2230  if ( nSnap + nAdd/2 < nTwips || nCol < rStartCol )
2231  {
2232  nSnap += nAdd;
2233  ++nCol;
2234  }
2235  else
2236  break;
2237  }
2238  nVal = static_cast<long>( nSnap * HMM_PER_TWIPS );
2239  rStartCol = nCol;
2240  return nVal;
2241 }
2242 
2243 [[nodiscard]]
2244 long SnapVertical( const ScDocument& rDoc, SCTAB nTab, long nVal, SCROW& rStartRow )
2245 {
2246  SCROW nRow = 0;
2247  long nTwips = static_cast<long>(nVal / HMM_PER_TWIPS);
2248  long nSnap = 0;
2249 
2250  bool bFound = false;
2251  for (SCROW i = nRow; i <= rDoc.MaxRow(); ++i)
2252  {
2253  SCROW nLastRow;
2254  if (rDoc.RowHidden(i, nTab, nullptr, &nLastRow))
2255  {
2256  i = nLastRow;
2257  continue;
2258  }
2259 
2260  nRow = i;
2261  long nAdd = rDoc.GetRowHeight(i, nTab);
2262  if ( nSnap + nAdd/2 < nTwips || nRow < rStartRow )
2263  {
2264  nSnap += nAdd;
2265  ++nRow;
2266  }
2267  else
2268  {
2269  bFound = true;
2270  break;
2271  }
2272  }
2273  if (!bFound)
2274  nRow = rDoc.MaxRow(); // all hidden down to the bottom
2275 
2276  nVal = static_cast<long>( nSnap * HMM_PER_TWIPS );
2277  rStartRow = nRow;
2278  return nVal;
2279 }
2280 
2281 }
2282 
2284 {
2285  SCTAB nTab = m_aDocument.GetVisibleTab();
2286  long nOrigTop = rRect.Top();
2287  long nOrigLeft = rRect.Left();
2288  bool bNegativePage = m_aDocument.IsNegativePage( nTab );
2289  if ( bNegativePage )
2290  ScDrawLayer::MirrorRectRTL( rRect ); // calculate with positive (LTR) values
2291 
2292  SCCOL nCol = m_aDocument.GetPosLeft();
2293  long nSetLeft = SnapHorizontal( m_aDocument, nTab, rRect.Left(), nCol );
2294  rRect.SetLeft( nSetLeft );
2295  ++nCol; // at least one column
2296  long nCorrectionLeft = (nOrigLeft == 0 && nCol > 0) ? nSetLeft : 0; // initial correction
2297  rRect.SetRight( SnapHorizontal( m_aDocument, nTab, rRect.Right() + nCorrectionLeft, nCol ));
2298 
2299  SCROW nRow = m_aDocument.GetPosTop();
2300  long nSetTop = SnapVertical( m_aDocument, nTab, rRect.Top(), nRow );
2301  rRect.SetTop( nSetTop );
2302  ++nRow; // at least one row
2303  long nCorrectionTop = (nOrigTop == 0 && nRow > 0) ? nSetTop : 0; // initial correction
2304  rRect.SetBottom( SnapVertical( m_aDocument, nTab, rRect.Bottom() + nCorrectionTop, nRow ));
2305 
2306  if ( bNegativePage )
2307  ScDrawLayer::MirrorRectRTL( rRect ); // back to real rectangle
2308 }
2309 
2311  SCTAB nCurTab,
2312  bool& rbHeader,
2313  bool& rbFooter )
2314 {
2315  if ( !pStyleSet )
2316  {
2318  SfxStyleSheetBase* pStyleSheet = pStylePool->
2319  Find( m_aDocument.GetPageStyle( nCurTab ),
2320  SfxStyleFamily::Page );
2321 
2322  OSL_ENSURE( pStyleSheet, "PageStyle not found! :-/" );
2323 
2324  if ( pStyleSheet )
2325  pStyleSet = &pStyleSheet->GetItemSet();
2326  else
2327  rbHeader = rbFooter = false;
2328  }
2329 
2330  OSL_ENSURE( pStyleSet, "PageStyle-Set not found! :-(" );
2331  if (!pStyleSet)
2332  return;
2333 
2334  const SvxSetItem* pSetItem = nullptr;
2335  const SfxItemSet* pSet = nullptr;
2336 
2337  pSetItem = &pStyleSet->Get( ATTR_PAGE_HEADERSET );
2338  pSet = &pSetItem->GetItemSet();
2339  rbHeader = pSet->Get(ATTR_PAGE_ON).GetValue();
2340 
2341  pSetItem = &pStyleSet->Get( ATTR_PAGE_FOOTERSET );
2342  pSet = &pSetItem->GetItemSet();
2343  rbFooter = pSet->Get(ATTR_PAGE_ON).GetValue();
2344 }
2345 
2346 #if defined(_WIN32)
2347 bool ScDocShell::DdeGetData( const OUString& rItem,
2348  const OUString& rMimeType,
2349  css::uno::Any & rValue )
2350 {
2352  if (SotClipboardFormatId::STRING == eFormatId || SotClipboardFormatId::STRING_TSVC == eFormatId)
2353  {
2354  if( rItem.equalsIgnoreAsciiCase( "Format" ) )
2355  {
2356  OString aFmtByte(OUStringToOString(m_aDdeTextFmt,
2357  osl_getThreadTextEncoding()));
2358  rValue <<= css::uno::Sequence< sal_Int8 >(
2359  reinterpret_cast<const sal_Int8*>(aFmtByte.getStr()),
2360  aFmtByte.getLength() + 1 );
2361  return true;
2362  }
2363  ScImportExport aObj( &m_aDocument, rItem );
2364  if ( !aObj.IsRef() )
2365  return false; // invalid range
2366 
2367  if( m_aDdeTextFmt[0] == 'F' )
2368  aObj.SetFormulas( true );
2369  if( m_aDdeTextFmt == "SYLK" ||
2370  m_aDdeTextFmt == "FSYLK" )
2371  {
2372  OString aData;
2373  if( aObj.ExportByteString( aData, osl_getThreadTextEncoding(),
2374  SotClipboardFormatId::SYLK ) )
2375  {
2376  rValue <<= css::uno::Sequence< sal_Int8 >(
2377  reinterpret_cast<const sal_Int8*>(aData.getStr()),
2378  aData.getLength() + 1 );
2379  return true;
2380  }
2381  else
2382  return false;
2383  }
2384  if( m_aDdeTextFmt == "CSV" ||
2385  m_aDdeTextFmt == "FCSV" )
2386  aObj.SetSeparator( ',' );
2387  aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, 0, false ) );
2388  return aObj.ExportData( rMimeType, rValue );
2389  }
2390 
2391  ScImportExport aObj( &m_aDocument, rItem );
2392  aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, 0, false ) );
2393  return aObj.IsRef() && aObj.ExportData( rMimeType, rValue );
2394 }
2395 
2396 bool ScDocShell::DdeSetData( const OUString& rItem,
2397  const OUString& rMimeType,
2398  const css::uno::Any & rValue )
2399 {
2401  if (SotClipboardFormatId::STRING == eFormatId || SotClipboardFormatId::STRING_TSVC == eFormatId)
2402  {
2403  if( rItem.equalsIgnoreAsciiCase( "Format" ) )
2404  {
2405  if ( ScByteSequenceToString::GetString( m_aDdeTextFmt, rValue, osl_getThreadTextEncoding() ) )
2406  {
2407  m_aDdeTextFmt = m_aDdeTextFmt.toAsciiUpperCase();
2408  return true;
2409  }
2410  return false;
2411  }
2412  ScImportExport aObj( &m_aDocument, rItem );
2413  if( m_aDdeTextFmt[0] == 'F' )
2414  aObj.SetFormulas( true );
2415  if( m_aDdeTextFmt == "SYLK" ||
2416  m_aDdeTextFmt == "FSYLK" )
2417  {
2418  OUString aData;
2419  if ( ScByteSequenceToString::GetString( aData, rValue, osl_getThreadTextEncoding() ) )
2420  {
2421  return aObj.ImportString( aData, SotClipboardFormatId::SYLK );
2422  }
2423  return false;
2424  }
2425  if( m_aDdeTextFmt == "CSV" ||
2426  m_aDdeTextFmt == "FCSV" )
2427  aObj.SetSeparator( ',' );
2428  OSL_ENSURE( false, "Implementation is missing" );
2429  return false;
2430  }
2431  /*ScImportExport aObj( &aDocument, rItem );
2432  return aObj.IsRef() && ScImportExport::ImportData( rMimeType, rValue );*/
2433  OSL_ENSURE( false, "Implementation is missing" );
2434  return false;
2435 }
2436 #endif
2437 
2439 {
2440  // only check for valid item string - range is parsed again in ScServerObject ctor
2441 
2442  // named range?
2443  OUString aPos = rItem;
2444  ScRangeName* pRange = m_aDocument.GetRangeName();
2445  if( pRange )
2446  {
2447  const ScRangeData* pData = pRange->findByUpperName(ScGlobal::getCharClassPtr()->uppercase(aPos));
2448  if (pData)
2449  {
2450  if( pData->HasType( ScRangeData::Type::RefArea )
2451  || pData->HasType( ScRangeData::Type::AbsArea )
2452  || pData->HasType( ScRangeData::Type::AbsPos ) )
2453  pData->GetSymbol( aPos ); // continue with the name's contents
2454  }
2455  }
2456 
2457  // Address in DDE function must be always parsed as CONV_OOO so that it
2458  // would always work regardless of current address conversion. We do this
2459  // because the address item in a DDE entry is *not* normalized when saved
2460  // into ODF.
2461  ScRange aRange;
2462  bool bValid = ( (aRange.Parse(aPos, &m_aDocument, formula::FormulaGrammar::CONV_OOO ) & ScRefFlags::VALID) ||
2464 
2465  ScServerObject* pObj = nullptr; // NULL = error
2466  if ( bValid )
2467  pObj = new ScServerObject( this, rItem );
2468 
2469  // GetLinkManager()->InsertServer() is in the ScServerObject ctor
2470 
2471  return pObj;
2472 }
2473 
2475 {
2476  if ( !pDocument->IsDocVisible() || // don't want callbacks until document load
2479  return;
2480 
2481  boost::property_tree::ptree aAnnotation;
2482  aAnnotation.put("action", (nType == LOKCommentNotificationType::Add ? "Add" :
2483  (nType == LOKCommentNotificationType::Remove ? "Remove" :
2484  (nType == LOKCommentNotificationType::Modify ? "Modify" : "???"))));
2485 
2486  assert(pNote);
2487  aAnnotation.put("id", pNote->GetId());
2488  aAnnotation.put("tab", rPos.Tab());
2489 
2491  {
2492  aAnnotation.put("author", pNote->GetAuthor());
2493  aAnnotation.put("dateTime", pNote->GetDate());
2494  aAnnotation.put("text", pNote->GetText());
2495 
2496  // Calculating the cell cursor position
2497  ScViewData* pViewData = GetViewData();
2498  if (pViewData && pViewData->GetActiveWin())
2499  {
2500  bool bInPrintTwips = comphelper::LibreOfficeKit::isCompatFlagSet(
2501  comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
2502  OString aRectString;
2503  if (bInPrintTwips)
2504  {
2505  Point aTopLeft = pViewData->GetPrintTwipsPos(rPos.Col(), rPos.Row());
2506  long nSizeX, nSizeY;
2507  pViewData->GetMergeSizePrintTwips(rPos.Col(), rPos.Row(), nSizeX, nSizeY);
2508  aRectString = tools::Rectangle(aTopLeft, Size(nSizeX - 1, nSizeY - 1)).toString();
2509  }
2510  else
2511  {
2512  Point aTopLeft = pViewData->GetScrPos(rPos.Col(), rPos.Row(),
2513  pViewData->GetActivePart(), true);
2514  long nSizeXPix, nSizeYPix;
2515  pViewData->GetMergeSizePixel(rPos.Col(), rPos.Row(), nSizeXPix, nSizeYPix);
2516  const double fPPTX = pViewData->GetPPTX();
2517  const double fPPTY = pViewData->GetPPTY();
2518  aRectString = tools::Rectangle(Point(aTopLeft.getX() / fPPTX, aTopLeft.getY() / fPPTY),
2519  Size(nSizeXPix / fPPTX, nSizeYPix / fPPTY)).toString();
2520  }
2521  aAnnotation.put("cellPos", aRectString);
2522  }
2523  }
2524 
2525  boost::property_tree::ptree aTree;
2526  aTree.add_child("comment", aAnnotation);
2527  std::stringstream aStream;
2528  boost::property_tree::write_json(aStream, aTree);
2529  std::string aPayload = aStream.str();
2530 
2531  ScViewData* pViewData = GetViewData();
2532  SfxViewShell* pThisViewShell = ( pViewData ? pViewData->GetViewShell() : nullptr );
2533  SfxViewShell* pViewShell = SfxViewShell::GetFirst();
2534  while (pViewShell)
2535  {
2536  if (pThisViewShell == nullptr || pViewShell->GetDocId() == pThisViewShell->GetDocId())
2537  pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str());
2538  pViewShell = SfxViewShell::GetNext(*pViewShell);
2539  }
2540 }
2541 
2543 {
2545  ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( pCur );
2546  return pViewSh ? &pViewSh->GetViewData() : nullptr;
2547 }
2548 
2550 {
2552 
2553  ScViewData* pViewData = GetViewData();
2554 
2555  return pViewData ? pViewData->GetTabNo() : static_cast<SCTAB>(0);
2556 }
2557 
2559 {
2561  // wrong Doc?
2562  if( pViewSh && pViewSh->GetViewData().GetDocShell() != this )
2563  pViewSh = nullptr;
2564  if( !pViewSh )
2565  {
2566  // 1. find ViewShell
2567  SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this, bOnlyVisible );
2568  if( pFrame )
2569  {
2570  SfxViewShell* p = pFrame->GetViewShell();
2571  pViewSh = dynamic_cast< ScTabViewShell *>( p );
2572  }
2573  }
2574  return pViewSh;
2575 }
2576 
2578 {
2579  // used to invalidate slots after changes to this document
2580 
2581  SfxViewShell* pViewSh = GetBestViewShell();
2582  if (pViewSh)
2583  return &pViewSh->GetViewFrame()->GetBindings();
2584  else
2585  return nullptr;
2586 }
2587 
2588 ScDocShell* ScDocShell::GetShellByNum( sal_uInt16 nDocNo ) // static
2589 {
2590  ScDocShell* pFound = nullptr;
2592  sal_uInt16 nShellCnt = 0;
2593 
2594  while ( pShell && !pFound )
2595  {
2596  if ( dynamic_cast<const ScDocShell*>(pShell) != nullptr )
2597  {
2598  if ( nShellCnt == nDocNo )
2599  pFound = static_cast<ScDocShell*>(pShell);
2600  else
2601  ++nShellCnt;
2602  }
2603  pShell = SfxObjectShell::GetNext( *pShell );
2604  }
2605 
2606  return pFound;
2607 }
2608 
2609 IMPL_LINK( ScDocShell, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, void )
2610 {
2611  OSL_ENSURE( _pFileDlg, "ScDocShell::DialogClosedHdl(): no file dialog" );
2612  OSL_ENSURE( m_pImpl->pDocInserter, "ScDocShell::DialogClosedHdl(): no document inserter" );
2613 
2614  if ( ERRCODE_NONE == _pFileDlg->GetError() )
2615  {
2616  sal_uInt16 nSlot = m_pImpl->pRequest->GetSlot();
2617  std::unique_ptr<SfxMedium> pMed = m_pImpl->pDocInserter->CreateMedium();
2618  // #i87094# If a .odt was selected pMed is NULL.
2619  if (pMed)
2620  {
2621  m_pImpl->pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) );
2622  if ( SID_DOCUMENT_COMPARE == nSlot )
2623  {
2624  if ( pMed->GetFilter() )
2625  m_pImpl->pRequest->AppendItem(
2626  SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) );
2627  OUString sOptions = ScDocumentLoader::GetOptions( *pMed );
2628  if ( !sOptions.isEmpty() )
2629  m_pImpl->pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
2630  }
2631  const SfxPoolItem* pItem = nullptr;
2632  const SfxInt16Item* pInt16Item(nullptr);
2633  SfxItemSet* pSet = pMed->GetItemSet();
2634  if (pSet && pSet->GetItemState(SID_VERSION, true, &pItem) == SfxItemState::SET)
2635  {
2636  pInt16Item = dynamic_cast<const SfxInt16Item*>(pItem);
2637  }
2638  if (pInt16Item)
2639  {
2640  m_pImpl->pRequest->AppendItem( *pItem );
2641  }
2642 
2643  Execute( *(m_pImpl->pRequest) );
2644  }
2645  }
2646 
2647  m_pImpl->bIgnoreLostRedliningWarning = false;
2648 }
2649 
2650 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
2651 
2652 void ScDocShell::EnableSharedSettings( bool bEnable )
2653 {
2655 
2656  if ( bEnable )
2657  {
2660 
2661  // hide accept or reject changes dialog
2662  sal_uInt16 nId = ScAcceptChgDlgWrapper::GetChildWindowId();
2663  SfxViewFrame* pViewFrame = SfxViewFrame::Current();
2664  if ( pViewFrame && pViewFrame->HasChildWindow( nId ) )
2665  {
2666  pViewFrame->ToggleChildWindow( nId );
2667  SfxBindings* pBindings = GetViewBindings();
2668  if ( pBindings )
2669  {
2670  pBindings->Invalidate( FID_CHG_ACCEPT );
2671  }
2672  }
2673  }
2674  else
2675  {
2677  }
2678 
2679  ScChangeViewSettings aChangeViewSet;
2680  aChangeViewSet.SetShowChanges( false );
2681  m_aDocument.SetChangeViewSettings( aChangeViewSet );
2682 }
2683 
2684 uno::Reference< frame::XModel > ScDocShell::LoadSharedDocument()
2685 {
2686  uno::Reference< frame::XModel > xModel;
2687  try
2688  {
2689  SC_MOD()->SetInSharedDocLoading( true );
2690  uno::Reference< frame::XDesktop2 > xLoader = frame::Desktop::create( ::comphelper::getProcessComponentContext() );
2691  uno::Sequence < beans::PropertyValue > aArgs( 1 );
2692  aArgs[0].Name = "Hidden";
2693  aArgs[0].Value <<= true;
2694 
2695  if ( GetMedium() )
2696  {
2697  const SfxStringItem* pPasswordItem = SfxItemSet::GetItem<SfxStringItem>(GetMedium()->GetItemSet(), SID_PASSWORD, false);
2698  if ( pPasswordItem && !pPasswordItem->GetValue().isEmpty() )
2699  {
2700  aArgs.realloc( 2 );
2701  aArgs[1].Name = "Password";
2702  aArgs[1].Value <<= pPasswordItem->GetValue();
2703  }
2704  const SfxUnoAnyItem* pEncryptionItem = SfxItemSet::GetItem<SfxUnoAnyItem>(GetMedium()->GetItemSet(), SID_ENCRYPTIONDATA, false);
2705  if (pEncryptionItem)
2706  {
2707  aArgs.realloc(aArgs.getLength() + 1);
2708  aArgs[aArgs.getLength() - 1].Name = "EncryptionData";
2709  aArgs[aArgs.getLength() - 1].Value = pEncryptionItem->GetValue();
2710  }
2711  }
2712 
2713  xModel.set(
2714  xLoader->loadComponentFromURL( GetSharedFileURL(), "_blank", 0, aArgs ),
2715  uno::UNO_QUERY_THROW );
2716  SC_MOD()->SetInSharedDocLoading( false );
2717  }
2718  catch ( uno::Exception& )
2719  {
2720  OSL_FAIL( "ScDocShell::LoadSharedDocument(): caught exception" );
2721  SC_MOD()->SetInSharedDocLoading( false );
2722  try
2723  {
2724  uno::Reference< util::XCloseable > xClose( xModel, uno::UNO_QUERY_THROW );
2725  xClose->close( true );
2726  return uno::Reference< frame::XModel >();
2727  }
2728  catch ( uno::Exception& )
2729  {
2730  return uno::Reference< frame::XModel >();
2731  }
2732  }
2733  return xModel;
2734 }
2735 
2736 #endif
2737 
2738 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SC_DLLPUBLIC bool GetPrintArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow, bool bNotes=true) const
Definition: documen2.cxx:573
void SetEditHelpId(const OString &rId)
SfxViewFrame * GetViewFrame() const
ScDBFunc * GetView() const
Definition: viewdata.hxx:356
bool GetValue() const
long Width() const
bool IsBlockEditable(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool *pOnlyNotBecauseOfMatrix=nullptr, bool bNoMatrixAtAll=false) const
Definition: document.cxx:5329
virtual void SetVisArea(const tools::Rectangle &rVisArea)
#define LANGUAGE_NONE
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
const size_t count(pCandidateA->getBorderLines().size())
SC_DLLPUBLIC ScRefFlags ParseAny(const OUString &, const ScDocument *, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
Definition: address.cxx:1770
SfxHintId
SC_DLLPUBLIC void ApplyStyleAreaTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, const ScStyleSheet &rStyle)
Definition: document.cxx:4853
SC_DLLPUBLIC const ScRange * GetRepeatColRange(SCTAB nTab)
Definition: document.cxx:6289
SC_DLLPUBLIC bool HasQueryParam() const
Definition: dbdata.cxx:510
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
Definition: document.hxx:819
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
ScAddress aStart
Definition: address.hxx:500
void EndChangeTracking()
Definition: documen2.cxx:267
bool bVisible
SC_DLLPUBLIC bool GetDataStart(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow) const
Definition: documen2.cxx:641
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1871
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
Definition: docsh3.cxx:450
SfxChildWindow * GetChildWindow(sal_uInt16)
SC_DLLPUBLIC ScLinkMode GetLinkMode(SCTAB nTab) const
Definition: documen3.cxx:485
static SfxInterface * GetStaticInterface()
void ExecutePageStyle(const SfxViewShell &rCaller, SfxRequest &rReq, SCTAB nCurTab)
Definition: docsh4.cxx:1755
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
Definition: document.cxx:1001
virtual const FmFormShell * GetFormShell() const override
Definition: tabvwsh.hxx:336
SfxViewFrame * GetFrame() const
VclPtr< SfxInfoBarWindow > AppendInfoBar(const OUString &sId, const OUString &sPrimaryMessage, const OUString &sSecondaryMessage, InfobarType aInfobarType, bool bShowCloseButton=true)
SCROW Row() const
Definition: address.hxx:262
static SfxAbstractDialogFactory * Create()
void PostPaintGridAll()
Definition: docsh3.cxx:181
const char aData[]
ScLkUpdMode GetLinkMode() const
Definition: appoptio.hxx:68
#define PRINT_HEADER_WIDTH
Definition: printfun.hxx:45
SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings &rNew)
Definition: documen2.cxx:1109
bool HasSharedXMLFlagSet() const
static void GetSpellSettings(LanguageType &rDefLang, LanguageType &rCjkLang, LanguageType &rCtlLang, bool &rAutoSpell)
Definition: scmod.cxx:2205
const SfxItemSet & GetEmptyItemSet() const
std::unique_ptr< ContentProperties > pData
std::string GetValue
static weld::Window * GetActiveDialogParent()
Definition: docsh.cxx:2949
SfxBindings * GetViewBindings()
Definition: docsh4.cxx:2577
virtual VclPtr< AbstractScColRowLabelDlg > CreateScColRowLabelDlg(weld::Window *pParent, bool bCol, bool bRow)=0
bool IsFormulaMode() const
Definition: inputhdl.hxx:259
long Height() const
signed char sal_Int8
void SetProtection(const css::uno::Sequence< sal_Int8 > &rPass)
Definition: chgtrack.hxx:1134
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1675
void PostPaintCell(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: docsh3.cxx:186
SC_DLLPUBLIC const ScFormulaCell * GetFormulaCell(const ScAddress &rPos) const
Definition: document.cxx:3725
ScScenarioFlags
Definition: global.hxx:236
bool IsInputMode() const
Definition: inputhdl.hxx:185
Point GetPrintTwipsPos(SCCOL nCol, SCROW nRow) const
returns the position (top-left corner) of the requested cell in print twips coordinates.
Definition: viewdata.cxx:2471
const OUString & GetAuthor() const
Returns the author date of this note.
Definition: postit.hxx:214
static void RemoveAppPrefix(OUString &rFilterName)
Definition: tablink.cxx:486
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALETOPAGES(175)
const OUString & GetName() const
sal_uIntPtr sal_uLong
void GetPageOnFromPageStyleSet(const SfxItemSet *pStyleSet, SCTAB nCurTab, bool &rbHeader, bool &rbFooter)
Definition: docsh4.cxx:2310
These options control how multi-line cells are converted during export in certain lossy formats (such...
Definition: impex.hxx:36
#define ZOOM_MIN
Definition: docsh4.cxx:1599
void PageStyleModified(const OUString &rStyleName, bool bApi)
Definition: docsh4.cxx:1713
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:168
SAL_DLLPRIVATE css::uno::Reference< css::frame::XModel > LoadSharedDocument()
bool updateDdeOrOleOrWebServiceLinks(weld::Window *pWin)
static void DrawToDev(ScDocument *pDoc, OutputDevice *pDev, double nPrintFactor, const tools::Rectangle &rBound, ScViewData *pViewData, bool bMetaFile)
Definition: printfun.cxx:443
void initializeFrom(const css::uno::Sequence< css::beans::PropertyValue > &_rValues)
const OUString & getBcp47(bool bResolveSystem=true) const
ViewShellDocId GetDocId() const override
ScDocShell(const ScDocShell &rDocShell)=delete
void RefreshPivotTables(const ScRange &rSource)
Definition: docsh5.cxx:473
void ModifyStyleSheet(SfxStyleSheetBase &rPageStyle, const SfxItemSet &rChanges)
Definition: documen8.cxx:209
void DeleteTable(SCTAB nTabNr, bool bRecord=true)
Definition: viewfun2.cxx:2388
static SVL_DLLPUBLIC void GetHashPassword(css::uno::Sequence< sal_Int8 > &rPassHash, const char *pPass, sal_uInt32 nLen)
void SetDocumentModified()
Definition: docsh.cxx:2819
sal_Int16 nId
sal_uInt16 FirstWhich()
void RenameCellStyle(const OUString &rOld, const OUString &rNew)
Definition: conditio.cxx:2159
double GetPPTX() const
Definition: viewdata.hxx:468
void PostPaintExtras()
Definition: docsh3.cxx:196
ComplexTextLayoutFlags GetLayoutMode() const
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
ScStyleSheet * FindCaseIns(const OUString &rName, SfxStyleFamily eFam)
Definition: stlpool.cxx:412
bool ImportData(const ScImportParam &rParam)
Definition: dbfunc.cxx:432
void MergeDocument(ScDocument &rOtherDoc, bool bShared=false, bool bCheckDuplicates=false, sal_uLong nOffset=0, ScChangeActionMergeMap *pMergeMap=nullptr, bool bInverseMap=false)
Definition: docsh3.cxx:769
void SetLayoutMode(ComplexTextLayoutFlags nTextLayoutMode)
ScAddress aEnd
Definition: address.hxx:501
ScSplitPos GetActivePart() const
Definition: viewdata.hxx:398
static void UpdateInputLine()
Definition: tabview3.cxx:2991
create "Importx" (if necessary)
Definition: global.hxx:394
void Done(bool bRemove=false)
virtual short run() override
ScRefFlags Parse(const OUString &, const ScDocument *, formula::FormulaGrammar::AddressConvention eConv=formula::FormulaGrammar::CONV_OOO, SCTAB nDefaultTab=0, sal_Unicode cDelimiter=0)
Definition: rangelst.cxx:106
virtual SfxItemSet & GetItemSet()
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CJK(EE_CHAR_START+15)
bool HasSubTotalParam() const
Definition: dbdata.cxx:528
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
ScDBData * GetDBData(const ScRange &rMarked, ScGetDBMode eMode, ScGetDBSelection eSel)
Definition: docsh5.cxx:115
sc::DocumentLinkManager & GetDocLinkManager()
Definition: documen2.cxx:225
bool ExecuteChangeProtectionDialog(bool bJustQueryIfProtected=false)
Protect/unprotect ChangeTrack and return if protection was successfully changed.
Definition: docsh4.cxx:1357
SfxStyleFamily GetFamily() const
virtual short Execute()=0
sal_uLong GetActionMax() const
Definition: chgtrack.hxx:966
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:475
void UpdateChartArea(const OUString &rChartName, const ScRange &rNewArea, bool bColHeaders, bool bRowHeaders, bool bAdd)
Definition: documen5.cxx:129
SfxHintId GetId() const
SC_DLLPUBLIC sal_uInt16 GetRowHeight(SCROW nRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4163
sal_uInt16 NextWhich()
virtual ::sfx2::SvLinkSource * DdeCreateLinkSource(const OUString &rItem) override
Definition: docsh4.cxx:2438
SfxApplication * SfxGetpApp()
OUString GetSharedFileURL() const
bool HasAnySheetEventScript(ScSheetEventId nEvent, bool bWithVbaEvents=false) const
Definition: documen3.cxx:677
void DoRecalc(bool bApi)
Definition: docsh4.cxx:1420
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2805
void ToggleChildWindow(sal_uInt16)
RET_NO
SfxStyleSheetBase * GetStyleSheet() const
Keep selection as is, expand to used data area if no selection.
bool AdjustPrintZoom(const ScRange &rRange)
Definition: docsh4.cxx:1634
vcl::Window & GetWindow() const
void MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo)
SC_DLLPUBLIC ScConditionalFormatList * GetCondFormList(SCTAB nTab) const
Definition: documen4.cxx:857
bool ShowChanges() const
Definition: chgviset.hxx:78
long Right() const
RET_YES
void ReloadAllLinks()
Definition: docsh4.cxx:114
void SetImportParam(const ScImportParam &rImportParam)
Definition: dbdata.cxx:476
const OUString & GetName() const
PropertiesInfo aProperties
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:876
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:313
Additional class containing cell annotation data.
Definition: postit.hxx:160
static void LOKCommentNotify(LOKCommentNotificationType nType, const ScDocument *pDocument, const ScAddress &rPos, const ScPostIt *pNote)
Definition: docsh4.cxx:2474
ScLkUpdMode
Definition: global.hxx:418
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static SfxViewShell * Current()
bool isCompatFlagSet(Compat flag)
void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
Definition: document.cxx:259
SC_DLLPUBLIC bool IsDocVisible() const
Definition: document.hxx:1555
void UpdateCharts(bool bAllCharts)
Definition: dbfunc2.cxx:24
bool IsDocShared() const
void RemoveInfoBar(const OUString &sId)
const SfxPoolItem * ExecuteSynchron(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr)
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
Definition: document.cxx:190
bool DetectiveRefresh(bool bAutomatic=false)
Definition: docfunc.cxx:459
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:632
#define HMM_PER_TWIPS
Definition: global.hxx:91
SCTAB Tab() const
Definition: address.hxx:271
bool RenamePageStyleInUse(const OUString &rOld, const OUString &rNew)
Definition: documen8.cxx:340
long Top() const
const css::uno::Any & GetValue() const
void Execute(SfxRequest &rReq)
Definition: docsh4.cxx:184
SotClipboardFormatId
void NotifyStyle(const SfxStyleSheetHint &rHint)
Definition: docsh4.cxx:1527
static SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
const OUString & GetName() const
static OUString GetOptions(const SfxMedium &rMedium)
Definition: tablink.cxx:422
sal_Int32 nEndPos
void SetTheActionRange(sal_uLong nFirst, sal_uLong nLast)
Definition: chgviset.hxx:127
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_HEADERS(169)
SfxObjectCreateMode GetCreateMode() const
void PageStyleModified(SCTAB nTab, const OUString &rNewName)
Definition: document.cxx:6176
bool HasRowHeaders() const
Definition: chartpos.hxx:134
void GetScaleData(Size &rPhysSize, long &rDocHdr, long &rDocFtr)
Definition: printfun.cxx:1098
ScViewData & GetViewData()
Definition: tabview.hxx:332
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2397
void UpdateSpellSettings(bool bFromStartTab=false)
Definition: inputhdl.cxx:907
void DoHardRecalc()
Definition: docsh4.cxx:1466
void SetDirty(bool bDirtyFlag=true)
static void SetError(ErrCode)
const css::uno::Sequence< sal_Int8 > & GetProtection() const
Definition: chgtrack.hxx:1136
SfxItemPool & GetPool() const
bool IsProtected() const
Definition: chgtrack.hxx:1138
bool empty() const
Definition: rangelst.hxx:89
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1904
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
void InitFromStyle(const SfxStyleSheetBase *pSource)
Definition: undostyl.cxx:59
void SetTabNo(SCTAB nNewTab)
Definition: viewdata.cxx:2260
SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab)
Definition: document.hxx:863
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
Definition: document.cxx:3365
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
Definition: rangenam.cxx:682
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:875
void RepeatDB(bool bRecord=true)
Definition: dbfunc3.cxx:2113
bool UpdatePages()
Definition: printfun.cxx:2397
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
SvtScriptType
void DoAutoStyle(const ScRange &rRange, const OUString &rStyle)
Definition: docsh4.cxx:1504
void SetTop(long v)
SC_DLLPUBLIC void CalcFormulaTree(bool bOnlyForced=false, bool bProgressBar=true, bool bSetAllDirty=true)
Calculate formula cells that are on the formula tree either partially, or in full.
Definition: documen7.cxx:326
virtual void Draw(OutputDevice *, const JobSetup &rSetup, sal_uInt16 nAspect) override
Definition: docsh4.cxx:2122
sal_Int16 GetValue() const
#define ERRCTX_SFX_OPENDOC
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
bool SwitchToShared(bool bShared, bool bSave)
SC_DLLPUBLIC void GetSymbol(OUString &rSymbol, const formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT) const
Definition: rangenam.cxx:246
int i
SfxObjectCreateMode
Point GetScrPos(SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, bool bAllowNeg=false, SCTAB nForTab=-1) const
Definition: viewdata.cxx:2319
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_FOOTERSET(182)
virtual SfxObjectShell * GetObjectShell() override
ComplexTextLayoutFlags
void SetAttribs(const SfxItemSet &rSet)
sal_Int16 SCCOL
Definition: types.hxx:22
bool ValidCol(SCCOL nCol) const
Definition: document.hxx:878
EditEngine * GetEditEngine() const
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
SC_DLLPUBLIC void SetAutoCalc(bool bNewAutoCalc)
Definition: documen7.cxx:602
#define SC_MOD()
Definition: scmod.hxx:253
bool HasSortParam() const
Definition: dbdata.cxx:521
void LimitChartArea(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow)
Definition: document.cxx:1114
SfxBindings & GetBindings()
SfxObjectShell * GetEmbeddedObject() const
Definition: docuno.cxx:454
#define ERRCODE_BASIC_NO_OBJECT
virtual void Clear()
const OUString & GetValue() const
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1786
void SetRight(long v)
const T * GetArg(sal_uInt16 nSlotId) const
void ShowExtras(SfxShowExtras nExtras)
constexpr sal_uInt16 XATTR_FILL_FIRST(XATTRSET_LINE+1)
void ModifyScenario(SCTAB nTab, const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
Definition: docsh5.cxx:755
void SetPrintZoom(SCTAB nTab, sal_uInt16 nScale, sal_uInt16 nPages)
Definition: docsh4.cxx:1601
void SetLinkFormulaNeedingCheck(bool bSet)
Definition: document.hxx:2127
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
void SetYear2000(sal_uInt16 nVal)
Definition: docoptio.hxx:85
long Bottom() const
const OUString & GetName() const
Definition: dbdata.hxx:122
OUString GetText() const
Returns the caption text of this note.
Definition: postit.cxx:913
void GetImportParam(ScImportParam &rImportParam) const
Definition: dbdata.cxx:466
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3069
#define LANGUAGE_DONTKNOW
HardRecalcState GetHardRecalcState() const
Definition: document.hxx:2305
#define HID_CHG_PROTECT
Definition: helpids.h:52
SC_DLLPUBLIC OUString GetPageStyle(SCTAB nTab) const
Definition: document.cxx:6188
void TrackFormulas(SfxHintId nHintId=SfxHintId::ScDataChanged)
Definition: documen7.cxx:527
SfxItemSet * GetItemSet() const
void BroadcastUno(const SfxHint &rHint)
Definition: documen3.cxx:930
virtual comphelper::EmbeddedObjectContainer & getEmbeddedObjectContainer() const override
static bool IsActive()
bool HasName() const
void InsertText(const OUString &rNew, bool bSelect=false)
static bool StateMethod(SfxBindings &rBindings, const OUString &rUIFile, bool bReloadNotebookbar=false)
SC_DLLPUBLIC tools::Rectangle GetMMRect(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: documen3.cxx:1953
const XColorListRef & GetColorList() const
sal_Int16 m_nCanUpdate
Definition: docsh.hxx:98
#define ERRCODE_BASIC_NO_ACTIVE_OBJECT
sal_Int16 nVersion
OUString SpellIgnoreWord()
const tools::Rectangle & GetVisArea() const
const SCTAB MAXTAB
Definition: address.hxx:71
static SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static ScViewData * GetViewData()
Definition: docsh4.cxx:2542
#define ASPECT_CONTENT
void ReloadTabLinks()
Definition: docsh6.cxx:389
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
Definition: docsh3.cxx:99
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:301
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument *=nullptr, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, ScAddress::ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, const OUString *pErrRef=nullptr)
Definition: address.cxx:1737
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
Definition: document.cxx:5570
bool HasType(Type nType) const
Definition: rangenam.hxx:177
bool IsStripData() const
Definition: dbdata.hxx:140
void GetStatePageStyle(SfxItemSet &rSet, SCTAB nCurTab)
Definition: docsh4.cxx:1974
void PostDataChanged()
Definition: docsh3.cxx:91
bool m_bFooterOn
Definition: docsh.hxx:89
SfxViewShell * GetViewShell() const
virtual VclPtr< AbstractScNewScenarioDlg > CreateScNewScenarioDlg(weld::Window *pParent, const OUString &rName, bool bEdit, bool bSheetProtected)=0
enumrange< T >::Iterator end(enumrange< T >)
SCCOL Col() const
Definition: address.hxx:267
bool IsReadOnly() const
bool IsShareDocumentChecked() const
Definition: sharedocdlg.cxx:90
size_t LeaveListAction()
ScDBData * findByUpperName(const OUString &rName)
Definition: dbdata.cxx:1145
void SetCalcNotification(SCTAB nTab)
Definition: documen3.cxx:702
SvxPageUsage
void SetMinLen(sal_uInt16 Len)
static ScDocShell * GetShellByNum(sal_uInt16 nDocNo)
Definition: docsh4.cxx:2588
ConversionMode mode
SC_DLLPUBLIC void GetScenarioData(SCTAB nTab, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const
Definition: documen3.cxx:449
OString OUStringToOString(const OUString &str, ConnectionSettings const *settings)
void SetReturnValue(const SfxPoolItem &)
#define ERRCODE_BASIC_BAD_PARAMETER
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CTL(EE_CHAR_START+16)
static bool GetString(OUString &rString, const css::uno::Any &rAny, sal_uInt16 nEncoding)
Definition: rangeseq.cxx:432
Stores global named database ranges.
Definition: dbdata.hxx:235
SCCOL GetPosLeft() const
Definition: document.hxx:864
void SetShowAccepted(bool bVal)
Definition: chgviset.hxx:114
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_Int32 SCROW
Definition: types.hxx:18
sal_uInt16 GetSlot() const
void UpdateExternalRefLinks(weld::Window *pWin)
Definition: documen8.cxx:787
double GetPPTY() const
Definition: viewdata.hxx:469
bool HasChildWindow(sal_uInt16)
virtual VclPtr< SfxAbstractTabDialog > CreateScStyleDlg(weld::Window *pParent, SfxStyleSheetBase &rStyleBase, bool bPage)=0
static SfxViewFrame * Current()
bool ValidRow(SCROW nRow) const
Definition: document.hxx:879
void SetStreamValid(SCTAB nTab, bool bSet, bool bIgnoreLock=false)
Definition: document.cxx:924
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
Definition: documen3.cxx:1910
static ScTabViewShell * GetActiveViewShell()
Definition: tabvwsh4.cxx:1023
void DisableItem(sal_uInt16 nWhich)
bool GetMergeSizePrintTwips(SCCOL nX, SCROW nY, long &rSizeXTwips, long &rSizeYTwips) const
Definition: viewdata.cxx:2684
weld::Window * GetFrameWeld() const
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
Definition: documen3.cxx:413
SC_DLLPUBLIC void CalcAll()
Definition: document.cxx:3935
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SC_DLLPUBLIC const ScRange * GetRepeatRowRange(SCTAB nTab)
Definition: document.cxx:6297
#define SAL_WARN_IF(condition, area, stream)
#define ERRCODE_NONE
const ScAddress & GetCursorPos() const
Definition: inputhdl.hxx:193
static SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
#define PRINT_HEADER_HEIGHT
Definition: printfun.hxx:46
IMPL_LINK(ScDocShell, DialogClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void)
Definition: docsh4.cxx:2609
static SotClipboardFormatId GetFormatIdFromMimeType(const OUString &rMimeType)
void CompareDocument(ScDocument &rOtherDoc)
Definition: docsh3.cxx:660
#define SAL_INFO(area, stream)
OUString aName
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
Definition: scabstdlg.cxx:38
virtual VclPtr< SfxAbstractTabDialog > CreateScHFEditDlg(weld::Window *pParent, const SfxItemSet &rCoreSet, const OUString &rPageStyle, sal_uInt16 nResId)=0
virtual LockFileEntry GetLockData() override
SfxDispatcher & GetDispatcher()
Definition: viewdata.cxx:3047
RET_OK
ScChangeViewSettings * GetChangeViewSettings() const
Definition: document.hxx:2156
static void MirrorRectRTL(tools::Rectangle &rRect)
Definition: drwlayer.cxx:1840
bool m_bHeaderOn
Definition: docsh.hxx:88
void UpdateAcceptChangesDialog()
Definition: docsh4.cxx:1344
sal_uInt32 GetId() const
Returns the note id.
Definition: postit.hxx:203
void SetBottom(long v)
static void ExecMethod(SfxBindings &rBindings, const OUString &rUIName)
void InvalidateName()
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
OUString GetPassword() const
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
virtual short run()
LOKCommentNotificationType
Definition: docsh.hxx:71
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
Definition: global.cxx:1018
std::unique_ptr< DocShell_Impl > m_pImpl
Definition: docsh.hxx:85
const OUString & GetDate() const
Returns the creation date of this note.
Definition: postit.hxx:209
void * p
Reference< XComponentContext > getProcessComponentContext()
SC_DLLPUBLIC ScChartListenerCollection * GetChartListenerCollection() const
Definition: document.hxx:2146
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:401
void SetLanguage(LanguageType eLatin, LanguageType eCjk, LanguageType eCtl)
Definition: documen3.cxx:1937
constexpr TypedWhichId< SvxPageItem > ATTR_PAGE(159)
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
sal_uInt16 GetYear2000() const
Definition: docoptio.hxx:86
bool HasImportSelection() const
Definition: dbdata.hxx:201
long Left() const
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6068
void ShowChildWindow(sal_uInt16, bool bVisible=true)
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:315
static OUString GetLanguageString(const LanguageType eType)
SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW *pFirstRow=nullptr, SCROW *pLastRow=nullptr) const
Definition: document.cxx:4431
void SetSelection(const ESelection &rNewSel)
void SetDocumentModified()
Definition: docsh.cxx:3158
ScDocument m_aDocument
Definition: docsh.hxx:80
void UpdateImport(const OUString &rTarget, const svx::ODataAccessDescriptor &rDescriptor)
Definition: dbdocfun.cxx:1669
static bool GetFilterName(const OUString &rFileName, OUString &rFilter, OUString &rOptions, bool bWithContent, bool bWithInteraction)
Returns the filter name and options from a file name.
Definition: tablink.cxx:432
static SVL_DLLPUBLIC bool CompareHashPassword(const css::uno::Sequence< sal_Int8 > &rOldPassHash, const OUString &sNewPass)
void Execute(SfxRequest &rReq)
Definition: tabvwsh3.cxx:149
bool hasListeners() const
Definition: chartlis.cxx:414
ScRange & front()
Definition: rangelst.hxx:93
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
void SetLeft(long v)
void InvalidateAll(bool bWithMsg)
bool HasColHeaders() const
Definition: chartpos.hxx:133
void AppendItem(const SfxPoolItem &)
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_HEADERSET(181)
OUString m_aDdeTextFmt
Definition: docsh.hxx:82
bool IsUndoEnabled() const
Definition: document.hxx:1534
Reference< XModel > xModel
static SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLBACKGROUND)
ESelection GetSelection() const
bool IsAPI() const
Size GetPageSize(SCTAB nTab) const
Definition: document.cxx:6202
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:218
ScTabViewShell * GetBestViewShell(bool bOnlyVisible=true)
Definition: docsh4.cxx:2558
void UpdateAreaLinks()
Definition: documen8.cxx:1047
void FormulaPreview()
Definition: inputhdl.cxx:1765
bool DoLoad(SfxMedium *pMedium)
void StartChangeTracking()
Definition: documen2.cxx:261
void SetScreen(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: viewdata.cxx:2940
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_ON(164)
SC_DLLPUBLIC void GetLanguage(LanguageType &rLatin, LanguageType &rCjk, LanguageType &rCtl) const
Definition: documen3.cxx:1930
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALE(174)
void UpdateLayerLocks()
Definition: tabview5.cxx:342
SCTAB GetVisibleTab() const
Definition: document.hxx:862
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4122
IMPL_LINK_NOARG(ScDocShell, ReloadAllLinksHdl, Button *, void)
Definition: docsh4.cxx:138
rtl::OString toString() const
SAL_DLLPRIVATE void EnableSharedSettings(bool bEnable)
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
void Ignore()
static SCTAB GetCurTab()
Definition: docsh4.cxx:2549
SC_DLLPUBLIC ScRefFlags Parse(const OUString &, const ScDocument *=nullptr, const Details &rDetails=detailsOOOa1, ExternalInfo *pExtInfo=nullptr, const css::uno::Sequence< css::sheet::ExternalLinkInfo > *pExternalLinks=nullptr, sal_Int32 *pSheetEndPos=nullptr, const OUString *pErrRef=nullptr)
Definition: address.cxx:1543
void SnapVisArea(tools::Rectangle &rRect) const
Definition: docsh4.cxx:2283
#define EE_TEXTPOS_ALL
SCROW GetPosTop() const
Definition: document.hxx:866
ScLkUpdMode GetLinkUpdateModeState() const
Definition: docsh4.cxx:149
void SetY2KState(sal_uInt16 n)
aStr
bool GetMergeSizePixel(SCCOL nX, SCROW nY, long &rSizeXPix, long &rSizeYPix) const
Definition: viewdata.cxx:2647
bool isExportLocked()
bool ValidTab(SCTAB nTab)
Definition: address.hxx:105
#define ASPECT_THUMBNAIL
weld::Window * GetDialogParent()
parent window for dialogs Problem: OLE Server!
Definition: tabvwshd.cxx:31
bool HasImportParam() const
Definition: dbdata.cxx:505
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
Create before modifications of the document and destroy thereafter.
Definition: docsh.hxx:450
void GetEditView(ScSplitPos eWhich, EditView *&rViewPtr, SCCOL &rCol, SCROW &rRow)
Definition: viewdata.cxx:2225
constexpr TypedWhichId< SfxBoolItem > ATTR_PAGE_SHARED(166)
sal_uInt16 nPos
static void CloseMethod(SfxBindings &rBindings)
sal_Int16 SCTAB
Definition: types.hxx:23
static LanguageType GetLanguageType(const OUString &rStr)
void GetState(SfxItemSet &rSet)
Definition: docsh4.cxx:2011
OUString toString(OptionInfo const *info)
SC_DLLPUBLIC bool GetAutoCalc() const
Definition: document.hxx:1363
sal_Int32 nStartPos
void SetShowChanges(bool bFlag)
Definition: chgviset.hxx:79
SfxMedium * GetMedium() const