LibreOffice Module sc (master)  1
docsh.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 <docsh.hxx>
21 
22 #include <config_features.h>
23 #include <scitems.hxx>
24 #include <sc.hrc>
25 #include <vcl/errinf.hxx>
26 #include <editeng/justifyitem.hxx>
27 #include <comphelper/fileformat.h>
28 #include <comphelper/classids.hxx>
29 #include <formula/errorcodes.hxx>
30 #include <vcl/stdtext.hxx>
31 #include <vcl/svapp.hxx>
32 #include <vcl/virdev.hxx>
33 #include <vcl/weld.hxx>
34 #include <rtl/bootstrap.hxx>
35 #include <rtl/tencinfo.h>
36 #include <sal/log.hxx>
37 #include <svl/PasswordHelper.hxx>
38 #include <sfx2/app.hxx>
39 #include <sfx2/bindings.hxx>
40 #include <sfx2/dinfdlg.hxx>
41 #include <sfx2/docfile.hxx>
42 #include <sfx2/event.hxx>
43 #include <sfx2/docfilt.hxx>
44 #include <sfx2/objface.hxx>
45 #include <sfx2/viewfrm.hxx>
46 #include <svl/documentlockfile.hxx>
47 #include <svl/fstathelper.hxx>
48 #include <svl/sharecontrolfile.hxx>
49 #include <svl/urihelper.hxx>
50 #include <osl/file.hxx>
51 #include <chgtrack.hxx>
52 #include <chgviset.hxx>
53 #include <com/sun/star/awt/Key.hpp>
54 #include <com/sun/star/awt/KeyModifier.hpp>
55 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
56 #include <com/sun/star/document/UpdateDocMode.hpp>
57 #include <com/sun/star/script/vba/VBAEventId.hpp>
58 #include <com/sun/star/script/vba/VBAScriptEventId.hpp>
59 #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
60 #include <com/sun/star/script/vba/XVBAScriptListener.hpp>
61 #include <com/sun/star/script/vba/XVBACompatibility.hpp>
62 #include <com/sun/star/sheet/XSpreadsheetView.hpp>
63 #include <com/sun/star/task/XJob.hpp>
64 #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
65 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
66 #include <com/sun/star/util/VetoException.hpp>
67 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
68 #include <ooo/vba/excel/XWorkbook.hpp>
69 #include <tools/diagnose_ex.h>
70 
71 #include <config_folders.h>
72 
73 #include <scabstdlg.hxx>
74 #include <sot/formats.hxx>
75 #include <svx/dialogs.hrc>
76 
77 #include <formulacell.hxx>
78 #include <global.hxx>
79 #include <filter.hxx>
80 #include <scmod.hxx>
81 #include <tabvwsh.hxx>
82 #include <docfunc.hxx>
83 #include <imoptdlg.hxx>
84 #include <impex.hxx>
85 #include <scresid.hxx>
86 #include <strings.hrc>
87 #include <globstr.hrc>
88 #include <scerrors.hxx>
89 #include <brdcst.hxx>
90 #include <stlpool.hxx>
91 #include <autostyl.hxx>
92 #include <attrib.hxx>
93 #include <asciiopt.hxx>
94 #include <progress.hxx>
95 #include <pntlock.hxx>
96 #include <docuno.hxx>
97 #include <appoptio.hxx>
98 #include <formulaopt.hxx>
99 #include <scdll.hxx>
100 #include <detdata.hxx>
101 #include <printfun.hxx>
102 #include <dociter.hxx>
103 #include <cellform.hxx>
104 #include <chartlis.hxx>
105 #include <hints.hxx>
106 #include <xmlwrap.hxx>
107 #include <drwlayer.hxx>
108 #include <dbdata.hxx>
109 #include <scextopt.hxx>
110 #include <compiler.hxx>
111 #include <warnpassword.hxx>
112 #include <optsolver.hxx>
113 #include <sheetdata.hxx>
114 #include <tabprotection.hxx>
115 #include <docparam.hxx>
116 #include "docshimp.hxx"
117 #include <sizedev.hxx>
118 #include <refreshtimerprotector.hxx>
119 
120 #include <officecfg/Office/Calc.hxx>
122 #include <comphelper/string.hxx>
123 #include <unotools/configmgr.hxx>
124 #include <unotools/tempfile.hxx>
126 #include <uiitems.hxx>
127 #include <dpobject.hxx>
128 #include <markdata.hxx>
129 #include <docoptio.hxx>
130 #include <orcusfilters.hxx>
131 #include <datastream.hxx>
132 #include <documentlinkmgr.hxx>
133 #include <refupdatecontext.hxx>
134 
135 #include <memory>
136 #include <vector>
137 
138 using namespace com::sun::star;
139 using ::com::sun::star::uno::Reference;
140 using ::com::sun::star::lang::XMultiServiceFactory;
141 using std::shared_ptr;
142 using ::std::vector;
143 
144 // Filter names (like in sclib.cxx)
145 
146 constexpr OUStringLiteral pFilterSc50 = u"StarCalc 5.0";
147 const char pFilterXML[] = "StarOffice XML (Calc)";
148 constexpr OUStringLiteral pFilterAscii = u"" SC_TEXT_CSV_FILTER_NAME;
149 constexpr OUStringLiteral pFilterLotus = u"Lotus";
150 const char pFilterQPro6[] = "Quattro Pro 6.0";
151 const char16_t pFilterExcel4[] = u"MS Excel 4.0";
152 const char16_t pFilterEx4Temp[] = u"MS Excel 4.0 Vorlage/Template";
153 const char pFilterExcel5[] = "MS Excel 5.0/95";
154 const char pFilterEx5Temp[] = "MS Excel 5.0/95 Vorlage/Template";
155 const char pFilterExcel95[] = "MS Excel 95";
156 const char pFilterEx95Temp[] = "MS Excel 95 Vorlage/Template";
157 const char pFilterExcel97[] = "MS Excel 97";
158 const char pFilterEx97Temp[] = "MS Excel 97 Vorlage/Template";
159 constexpr OUStringLiteral pFilterDBase = u"dBase";
160 constexpr OUStringLiteral pFilterDif = u"DIF";
161 const char16_t pFilterSylk[] = u"SYLK";
162 constexpr OUStringLiteral pFilterHtml = u"HTML (StarCalc)";
163 constexpr OUStringLiteral pFilterHtmlWebQ = u"calc_HTML_WebQuery";
164 const char16_t pFilterRtf[] = u"Rich Text Format (StarCalc)";
165 
166 #define ShellClass_ScDocShell
167 #include <scslots.hxx>
168 
170 
171 void ScDocShell::InitInterface_Impl()
172 {
173 }
174 
175 // GlobalName of the current version:
176 SFX_IMPL_OBJECTFACTORY( ScDocShell, SvGlobalName(SO3_SC_CLASSID), "scalc" )
177 
178 
179 void ScDocShell::FillClass( SvGlobalName* pClassName,
180  SotClipboardFormatId* pFormat,
181  OUString* pFullTypeName,
182  sal_Int32 nFileFormat,
183  bool bTemplate /* = false */) const
184 {
185  if ( nFileFormat == SOFFICE_FILEFORMAT_60 )
186  {
187  *pClassName = SvGlobalName( SO3_SC_CLASSID_60 );
188  *pFormat = SotClipboardFormatId::STARCALC_60;
189  *pFullTypeName = ScResId( SCSTR_LONG_SCDOC_NAME_60 );
190  }
191  else if ( nFileFormat == SOFFICE_FILEFORMAT_8 )
192  {
193  *pClassName = SvGlobalName( SO3_SC_CLASSID_60 );
194  *pFormat = bTemplate ? SotClipboardFormatId::STARCALC_8_TEMPLATE : SotClipboardFormatId::STARCALC_8;
195  *pFullTypeName = ScResId( SCSTR_LONG_SCDOC_NAME_80 );
196  }
197  else
198  {
199  OSL_FAIL("Which version?");
200  }
201 }
202 
203 std::set<Color> ScDocShell::GetDocColors()
204 {
205  return m_aDocument.GetDocColors();
206 }
207 
209 {
211  if (pViewSh && pViewSh->GetViewData().GetDocShell() == this)
212  SC_MOD()->InputEnterHandler();
213 }
214 
216 {
217  SCTAB nTab = 0;
218  ScTabViewShell* pSh = GetBestViewShell();
219  if (pSh)
220  {
221  const ScMarkData& rMark = pSh->GetViewData().GetMarkData();
222  nTab = rMark.GetFirstSelected();
223  }
224  return nTab;
225 }
226 
228 {
229  // get global state like HiddenInformation::DOCUMENTVERSIONS
231 
232  if ( nStates & HiddenInformation::RECORDEDCHANGES )
233  {
234  if ( m_aDocument.GetChangeTrack() && m_aDocument.GetChangeTrack()->GetFirst() )
235  nState |= HiddenInformation::RECORDEDCHANGES;
236  }
237  if ( nStates & HiddenInformation::NOTES )
238  {
239  SCTAB nTableCount = m_aDocument.GetTableCount();
240  bool bFound = false;
241  for (SCTAB nTab = 0; nTab < nTableCount && !bFound; ++nTab)
242  {
243  if (m_aDocument.HasTabNotes(nTab)) //TODO:
244  bFound = true;
245  }
246 
247  if (bFound)
248  nState |= HiddenInformation::NOTES;
249  }
250 
251  return nState;
252 }
253 
255 {
256  m_aDocument.EnableIdle(false);
257 
258  // prevent unnecessary broadcasts and updates
259  OSL_ENSURE(m_pModificator == nullptr, "The Modificator should not exist");
260  m_pModificator.reset( new ScDocShellModificator( *this ) );
261 
262  m_aDocument.SetImportingXML( true );
263  m_aDocument.EnableExecuteLink( false ); // #i101304# to be safe, prevent nested loading from external references
264  m_aDocument.EnableUndo( false );
265  // prevent unnecessary broadcasts and "half way listeners"
266  m_aDocument.SetInsertingFromOtherDoc( true );
267 }
268 
270 {
271  if (GetCreateMode() != SfxObjectCreateMode::ORGANIZER)
272  {
273  UpdateLinks();
274  // don't prevent establishing of listeners anymore
275  m_aDocument.SetInsertingFromOtherDoc( false );
276  if ( bRet )
277  {
278  ScChartListenerCollection* pChartListener = m_aDocument.GetChartListenerCollection();
279  if (pChartListener)
280  pChartListener->UpdateDirtyCharts();
281 
282  // #95582#; set the table names of linked tables to the new path
283  SCTAB nTabCount = m_aDocument.GetTableCount();
284  for (SCTAB i = 0; i < nTabCount; ++i)
285  {
286  if (m_aDocument.IsLinked( i ))
287  {
288  OUString aName;
289  m_aDocument.GetName(i, aName);
290  OUString aLinkTabName = m_aDocument.GetLinkTab(i);
291  sal_Int32 nLinkTabNameLength = aLinkTabName.getLength();
292  sal_Int32 nNameLength = aName.getLength();
293  if (nLinkTabNameLength < nNameLength)
294  {
295 
296  // remove the quotes on begin and end of the docname and restore the escaped quotes
297  const sal_Unicode* pNameBuffer = aName.getStr();
298  if ( *pNameBuffer == '\'' && // all docnames have to have a ' character on the first pos
300  {
301  OUStringBuffer aDocURLBuffer;
302  bool bQuote = true; // Document name is always quoted
303  ++pNameBuffer;
304  while ( bQuote && *pNameBuffer )
305  {
306  if ( *pNameBuffer == '\'' && *(pNameBuffer-1) != '\\' )
307  bQuote = false;
308  else if( *pNameBuffer != '\\' || *(pNameBuffer+1) != '\'' )
309  aDocURLBuffer.append(*pNameBuffer); // If escaped quote: only quote in the name
310  ++pNameBuffer;
311  }
312 
313  if( *pNameBuffer == SC_COMPILER_FILE_TAB_SEP ) // after the last quote of the docname should be the # char
314  {
315  sal_Int32 nIndex = nNameLength - nLinkTabNameLength;
316  INetURLObject aINetURLObject(aDocURLBuffer.makeStringAndClear());
317  if(aName.match( aLinkTabName, nIndex) &&
318  (aName[nIndex - 1] == '#') && // before the table name should be the # char
319  !aINetURLObject.HasError()) // the docname should be a valid URL
320  {
321  aName = ScGlobal::GetDocTabName( m_aDocument.GetLinkDoc( i ), m_aDocument.GetLinkTab( i ) );
322  m_aDocument.RenameTab(i, aName, true/*bExternalDocument*/);
323  }
324  // else; nothing has to happen, because it is a user given name
325  }
326  // else; nothing has to happen, because it is a user given name
327  }
328  // else; nothing has to happen, because it is a user given name
329  }
330  // else; nothing has to happen, because it is a user given name
331  }
332  }
333 
334  // #i94570# DataPilot table names have to be unique, or the tables can't be accessed by API.
335  // If no name (or an invalid name, skipped in ScXMLDataPilotTableContext::EndElement) was set, create a new name.
336  ScDPCollection* pDPCollection = m_aDocument.GetDPCollection();
337  if ( pDPCollection )
338  {
339  size_t nDPCount = pDPCollection->GetCount();
340  for (size_t nDP=0; nDP<nDPCount; ++nDP)
341  {
342  ScDPObject& rDPObj = (*pDPCollection)[nDP];
343  if (rDPObj.GetName().isEmpty())
344  rDPObj.SetName( pDPCollection->CreateNewName() );
345  }
346  }
347  }
348  }
349  else
350  m_aDocument.SetInsertingFromOtherDoc( false );
351 
352  m_aDocument.SetImportingXML( false );
353  m_aDocument.EnableExecuteLink( true );
354  m_aDocument.EnableUndo( true );
355  m_bIsEmpty = false;
356 
357  if (m_pModificator)
358  {
359  ScDocument::HardRecalcState eRecalcState = m_aDocument.GetHardRecalcState();
360  // Temporarily set hard-recalc to prevent calling
361  // ScFormulaCell::Notify() during destruction of the Modificator which
362  // will set the cells dirty.
363  if (eRecalcState == ScDocument::HardRecalcState::OFF)
364  m_aDocument.SetHardRecalcState(ScDocument::HardRecalcState::TEMPORARY);
365  m_pModificator.reset();
366  m_aDocument.SetHardRecalcState(eRecalcState);
367  }
368  else
369  {
370  OSL_FAIL("The Modificator should exist");
371  }
372 
373  m_aDocument.EnableIdle(true);
374 }
375 
376 namespace {
377 
378 class LoadMediumGuard
379 {
380 public:
381  explicit LoadMediumGuard(ScDocument* pDoc) :
382  mpDoc(pDoc)
383  {
384  mpDoc->SetLoadingMedium(true);
385  }
386 
387  ~LoadMediumGuard()
388  {
389  mpDoc->SetLoadingMedium(false);
390  }
391 private:
392  ScDocument* mpDoc;
393 };
394 
395 void processDataStream( ScDocShell& rShell, const sc::ImportPostProcessData& rData )
396 {
397  if (!rData.mpDataStream)
398  return;
399 
401  if (!r.maRange.IsValid())
402  return;
403 
404  // Break the streamed range into the top range and the height limit. A
405  // height limit of 0 means unlimited i.e. the streamed data will go all
406  // the way to the last row.
407 
408  ScRange aTopRange = r.maRange;
409  aTopRange.aEnd.SetRow(aTopRange.aStart.Row());
410  sal_Int32 nLimit = r.maRange.aEnd.Row() - r.maRange.aStart.Row() + 1;
411  if (r.maRange.aEnd.Row() == rShell.GetDocument().MaxRow())
412  // Unlimited range.
413  nLimit = 0;
414 
418 
419  sc::DataStream* pStrm = new sc::DataStream(&rShell, r.maURL, aTopRange, nLimit, eMove, 0);
422  rMgr.setDataStream(pStrm);
423 }
424 
425 class MessageWithCheck : public weld::MessageDialogController
426 {
427 private:
428  std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
429 public:
430  MessageWithCheck(weld::Window *pParent, const OUString& rUIFile, const OString& rDialogId)
431  : MessageDialogController(pParent, rUIFile, rDialogId, "ask")
432  , m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
433  {
434  }
435  bool get_active() const { return m_xWarningOnBox->get_active(); }
436  void hide_ask() const { m_xWarningOnBox->set_visible(false); };
437 };
438 
439 #if HAVE_FEATURE_SCRIPTING
440 class VBAScriptListener : public ::cppu::WeakImplHelper< css::script::vba::XVBAScriptListener >
441 {
442 private:
443  ScDocShell* m_pDocSh;
444 public:
445  VBAScriptListener(ScDocShell* pDocSh) : m_pDocSh(pDocSh)
446  {
447  }
448 
449  // XVBAScriptListener
450  virtual void SAL_CALL notifyVBAScriptEvent( const ::css::script::vba::VBAScriptEvent& aEvent ) override
451  {
452  if (aEvent.Identifier == script::vba::VBAScriptEventId::SCRIPT_STOPPED &&
453  m_pDocSh->GetClipData().is())
454  {
455  m_pDocSh->SetClipData(uno::Reference<datatransfer::XTransferable2>());
456  }
457  }
458 
459  // XEventListener
460  virtual void SAL_CALL disposing( const ::css::lang::EventObject& /*Source*/ ) override
461  {
462  }
463 };
464 #endif
465 
466 }
467 
468 bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css::embed::XStorage >& xStor )
469 {
470  LoadMediumGuard aLoadGuard(&m_aDocument);
471 
472  // MacroCallMode is no longer needed, state is kept in SfxObjectShell now
473 
474  // no Seek(0) here - always loading from storage, GetInStream must not be called
475 
476  BeforeXMLLoading();
477 
478  ScXMLImportWrapper aImport(*this, pLoadMedium, xStor);
479 
480  bool bRet = false;
481  ErrCode nError = ERRCODE_NONE;
482  m_aDocument.LockAdjustHeight();
483  if (GetCreateMode() == SfxObjectCreateMode::ORGANIZER)
484  bRet = aImport.Import(ImportFlags::Styles, nError);
485  else
486  bRet = aImport.Import(ImportFlags::All, nError);
487 
488  if ( nError )
489  pLoadMedium->SetError(nError);
490 
491  processDataStream(*this, aImport.GetImportPostProcessData());
492 
493  //if the document was not generated by LibreOffice, do hard recalc in case some other document
494  //generator saved cached formula results that differ from LibreOffice's calculated results or
495  //did not use cached formula results.
496  uno::Reference<document::XDocumentPropertiesSupplier> xDPS(GetModel(), uno::UNO_QUERY_THROW);
497  uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
498 
500  ScRecalcOptions nRecalcMode =
501  static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::ODFRecalcMode::get(xContext));
502 
503  bool bHardRecalc = false;
504  if (nRecalcMode == RECALC_ASK)
505  {
506  OUString sProductName(utl::ConfigManager::getProductName());
507  if (m_aDocument.IsUserInteractionEnabled() && xDocProps->getGenerator().indexOf(sProductName) == -1)
508  {
509  // Generator is not LibreOffice. Ask if the user wants to perform
510  // full re-calculation.
511  MessageWithCheck aQueryBox(GetActiveDialogParent(),
512  "modules/scalc/ui/recalcquerydialog.ui", "RecalcQueryDialog");
513  aQueryBox.set_primary_text(ScResId(STR_QUERY_FORMULA_RECALC_ONLOAD_ODS));
514  aQueryBox.set_default_response(RET_YES);
515 
516  if ( officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::isReadOnly() )
517  aQueryBox.hide_ask();
518 
519  bHardRecalc = aQueryBox.run() == RET_YES;
520 
521  if (aQueryBox.get_active())
522  {
523  // Always perform selected action in the future.
524  std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
525  officecfg::Office::Calc::Formula::Load::ODFRecalcMode::set(sal_Int32(0), batch);
526  ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
527  aOpt.SetODFRecalcOptions(bHardRecalc ? RECALC_ALWAYS : RECALC_NEVER);
528  /* XXX is this really supposed to set the ScModule options?
529  * Not the ScDocShell options? */
530  SC_MOD()->SetFormulaOptions(aOpt);
531 
532  batch->commit();
533  }
534  }
535  }
536  else if (nRecalcMode == RECALC_ALWAYS)
537  bHardRecalc = true;
538 
539  if (bHardRecalc)
540  DoHardRecalc();
541  else
542  {
543  // still need to recalc volatile formula cells.
544  m_aDocument.Broadcast(ScHint(SfxHintId::ScDataChanged, BCA_BRDCST_ALWAYS));
545  }
546 
547  AfterXMLLoading(bRet);
548 
549  m_aDocument.UnlockAdjustHeight();
550  return bRet;
551 }
552 
553 bool ScDocShell::SaveXML( SfxMedium* pSaveMedium, const css::uno::Reference< css::embed::XStorage >& xStor )
554 {
555  m_aDocument.EnableIdle(false);
556 
557  ScXMLImportWrapper aImport(*this, pSaveMedium, xStor);
558  bool bRet(false);
559  if (GetCreateMode() != SfxObjectCreateMode::ORGANIZER)
560  bRet = aImport.Export(false);
561  else
562  bRet = aImport.Export(true);
563 
564  m_aDocument.EnableIdle(true);
565 
566  return bRet;
567 }
568 
569 bool ScDocShell::Load( SfxMedium& rMedium )
570 {
571  LoadMediumGuard aLoadGuard(&m_aDocument);
572  ScRefreshTimerProtector aProt( m_aDocument.GetRefreshTimerControlAddress() );
573 
574  // only the latin script language is loaded
575  // -> initialize the others from options (before loading)
576  InitOptions(true);
577 
578  // If this is an ODF file being loaded, then by default, use legacy processing
579  // for tdf#99729 (if required, it will be overridden in *::ReadUserDataSequence())
580  if (IsOwnStorageFormat(rMedium))
581  {
582  if (m_aDocument.GetDrawLayer())
583  m_aDocument.GetDrawLayer()->SetAnchoredTextOverflowLegacy(true);
584  }
585 
586  GetUndoManager()->Clear();
587 
588  bool bRet = SfxObjectShell::Load(rMedium);
589  if (bRet)
590  {
591  SetInitialLinkUpdate(&rMedium);
592 
593  {
594  // prepare a valid document for XML filter
595  // (for ConvertFrom, InitNew is called before)
596  m_aDocument.MakeTable(0);
597  m_aDocument.GetStyleSheetPool()->CreateStandardStyles();
598  m_aDocument.UpdStlShtPtrsFrmNms();
599 
600  if (!m_bUcalcTest)
601  {
602  /* Create styles that are imported through Orcus */
603 
604  OUString aURL("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/calc/styles.xml");
605  rtl::Bootstrap::expandMacros(aURL);
606 
607  OUString aPath;
608  osl::FileBase::getSystemPathFromFileURL(aURL, aPath);
609 
611 
612  if (pOrcus)
613  {
614  pOrcus->importODS_Styles(m_aDocument, aPath);
615  m_aDocument.GetStyleSheetPool()->setAllParaStandard();
616  }
617  }
618 
619  bRet = LoadXML( &rMedium, nullptr );
620  }
621  }
622 
623  if (!bRet && !rMedium.GetError())
625 
626  if (rMedium.GetError())
627  SetError(rMedium.GetError());
628 
629  InitItems();
630  CalcOutputFactor();
631 
632  // invalidate eventually temporary table areas
633  if ( bRet )
634  m_aDocument.InvalidateTableArea();
635 
636  m_bIsEmpty = false;
637  FinishedLoading();
638  return bRet;
639 }
640 
642 {
643  const ScTablesHint* pScHint = dynamic_cast< const ScTablesHint* >( &rHint );
644  if (pScHint)
645  {
646  if (pScHint->GetTablesHintId() == SC_TAB_INSERTED)
647  {
648  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = m_aDocument.GetVbaEventProcessor();
649  if ( xVbaEvents.is() ) try
650  {
651  uno::Sequence< uno::Any > aArgs( 1 );
652  aArgs[0] <<= pScHint->GetTab1();
653  xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_NEWSHEET, aArgs );
654  }
655  catch( uno::Exception& )
656  {
657  }
658  }
659  }
660 
661  if ( auto pStyleSheetHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint) ) // Template changed
662  NotifyStyle( *pStyleSheetHint );
663  else if ( auto pStlHint = dynamic_cast<const ScAutoStyleHint*>(&rHint) )
664  {
666 
667  // this is called synchronously from ScInterpreter::ScStyle,
668  // modifying the document must be asynchronous
669  // (handled by AddInitial)
670 
671  const ScRange& aRange = pStlHint->GetRange();
672  const OUString& aName1 = pStlHint->GetStyle1();
673  const OUString& aName2 = pStlHint->GetStyle2();
674  sal_uInt32 nTimeout = pStlHint->GetTimeout();
675 
676  if (!m_pAutoStyleList)
677  m_pAutoStyleList.reset( new ScAutoStyleList(this) );
678  m_pAutoStyleList->AddInitial( aRange, aName1, nTimeout, aName2 );
679  }
680  else if ( auto pEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
681  {
682  SfxEventHintId nEventId = pEventHint->GetEventId();
683 
684  switch ( nEventId )
685  {
686  case SfxEventHintId::LoadFinished:
687  {
688 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
689  // the readonly documents should not be opened in shared mode
690  if ( HasSharedXMLFlagSet() && !SC_MOD()->IsInSharedDocLoading() && !IsReadOnly() )
691  {
692  if ( SwitchToShared( true, false ) )
693  {
694  ScViewData* pViewData = GetViewData();
695  ScTabView* pTabView = ( pViewData ? pViewData->GetView() : nullptr );
696  if ( pTabView )
697  {
698  pTabView->UpdateLayerLocks();
699  }
700  }
701  else
702  {
703  // switching to shared mode has failed, the document should be opened readonly
704  // TODO/LATER: And error message should be shown here probably
705  SetReadOnlyUI();
706  }
707  }
708 #endif
709  }
710  break;
711  case SfxEventHintId::ViewCreated:
712  {
713  #if HAVE_FEATURE_SCRIPTING
714  uno::Reference<script::vba::XVBACompatibility> xVBACompat(GetBasicContainer(), uno::UNO_QUERY);
715  if ( !m_xVBAListener.is() && xVBACompat.is() )
716  {
717  m_xVBAListener.set(new VBAScriptListener(this));
718  xVBACompat->addVBAScriptListener(m_xVBAListener);
719  }
720 #endif
721 
722 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
723  if ( IsDocShared() && !SC_MOD()->IsInSharedDocLoading() )
724  {
725  ScAppOptions aAppOptions = SC_MOD()->GetAppOptions();
726  if ( aAppOptions.GetShowSharedDocumentWarning() )
727  {
728  MessageWithCheck aWarningBox(ScDocShell::GetActiveDialogParent(),
729  "modules/scalc/ui/sharedwarningdialog.ui", "SharedWarningDialog");
730  aWarningBox.run();
731 
732  bool bChecked = aWarningBox.get_active();
733  if (bChecked)
734  {
735  aAppOptions.SetShowSharedDocumentWarning(false);
736  SC_MOD()->SetAppOptions( aAppOptions );
737  }
738  }
739  }
740 #endif
741  try
742  {
743  uno::Reference< uno::XComponentContext > xContext(
745  uno::Reference< lang::XMultiServiceFactory > xServiceManager(
746  xContext->getServiceManager(),
747  uno::UNO_QUERY_THROW );
748  uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xServiceManager, uno::UNO_QUERY_THROW );
749  uno::Reference< container::XEnumeration> xEnum = xEnumAccess->createContentEnumeration(
750  "com.sun.star.sheet.SpreadsheetDocumentJob" );
751  if ( xEnum.is() )
752  {
753  while ( xEnum->hasMoreElements() )
754  {
755  uno::Any aAny = xEnum->nextElement();
756  uno::Reference< lang::XSingleComponentFactory > xFactory;
757  aAny >>= xFactory;
758  if ( xFactory.is() )
759  {
760  uno::Reference< task::XJob > xJob( xFactory->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
761  ScViewData* pViewData = GetViewData();
762  SfxViewShell* pViewShell = ( pViewData ? pViewData->GetViewShell() : nullptr );
763  SfxViewFrame* pViewFrame = ( pViewShell ? pViewShell->GetViewFrame() : nullptr );
764  SfxFrame* pFrame = ( pViewFrame ? &pViewFrame->GetFrame() : nullptr );
765  uno::Reference< frame::XController > xController = ( pFrame ? pFrame->GetController() : nullptr );
766  uno::Reference< sheet::XSpreadsheetView > xSpreadsheetView( xController, uno::UNO_QUERY_THROW );
767  uno::Sequence< beans::NamedValue > aArgsForJob { { "SpreadsheetView", uno::makeAny( xSpreadsheetView ) } };
768  xJob->execute( aArgsForJob );
769  }
770  }
771  }
772  }
773  catch ( uno::Exception & )
774  {
775  }
776  }
777  break;
778  case SfxEventHintId::SaveDoc:
779  {
780 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
781  if ( IsDocShared() && !SC_MOD()->IsInSharedDocSaving() )
782  {
783  bool bSuccess = false;
784  bool bRetry = true;
785  while ( bRetry )
786  {
787  bRetry = false;
788  uno::Reference< frame::XModel > xModel;
789  try
790  {
791  // load shared file
792  xModel.set( LoadSharedDocument(), uno::UNO_SET_THROW );
793  uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY_THROW );
794 
795  // check if shared flag is set in shared file
796  bool bShared = false;
797  ScModelObj* pDocObj = comphelper::getFromUnoTunnel<ScModelObj>( xModel );
798  ScDocShell* pSharedDocShell = ( pDocObj ? dynamic_cast< ScDocShell* >( pDocObj->GetObjectShell() ) : nullptr );
799  if ( pSharedDocShell )
800  {
801  bShared = pSharedDocShell->HasSharedXMLFlagSet();
802  }
803 
804  // #i87870# check if shared status was disabled and enabled again
805  bool bOwnEntry = false;
806  bool bEntriesNotAccessible = false;
807  try
808  {
809  ::svt::ShareControlFile aControlFile( GetSharedFileURL() );
810  bOwnEntry = aControlFile.HasOwnEntry();
811  }
812  catch ( uno::Exception& )
813  {
814  bEntriesNotAccessible = true;
815  }
816 
817  if ( bShared && bOwnEntry )
818  {
819  uno::Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY_THROW );
820 
821  if ( xStorable->isReadonly() )
822  {
823  xCloseable->close( true );
824 
825  OUString aUserName( ScResId( STR_UNKNOWN_USER ) );
826  bool bNoLockAccess = false;
827  try
828  {
829  ::svt::DocumentLockFile aLockFile( GetSharedFileURL() );
830  LockFileEntry aData = aLockFile.GetLockData();
831  if ( !aData[LockFileComponent::OOOUSERNAME].isEmpty() )
832  {
833  aUserName = aData[LockFileComponent::OOOUSERNAME];
834  }
835  else if ( !aData[LockFileComponent::SYSUSERNAME].isEmpty() )
836  {
837  aUserName = aData[LockFileComponent::SYSUSERNAME];
838  }
839  }
840  catch ( uno::Exception& )
841  {
842  bNoLockAccess = true;
843  }
844 
845  if ( bNoLockAccess )
846  {
847  // TODO/LATER: in future an error regarding impossibility to open file for writing could be shown
849  }
850  else
851  {
852  OUString aMessage( ScResId( STR_FILE_LOCKED_SAVE_LATER ) );
853  aMessage = aMessage.replaceFirst( "%1", aUserName );
854 
855  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetActiveDialogParent(),
856  VclMessageType::Warning, VclButtonsType::NONE,
857  aMessage));
858  xWarn->add_button(GetStandardText(StandardButtonType::Retry), RET_RETRY);
859  xWarn->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL);
860  xWarn->set_default_response(RET_RETRY);
861  if (xWarn->run() == RET_RETRY)
862  {
863  bRetry = true;
864  }
865  }
866  }
867  else
868  {
869  // merge changes from shared file into temp file
870  bool bSaveToShared = false;
871  if ( pSharedDocShell )
872  {
873  bSaveToShared = MergeSharedDocument( pSharedDocShell );
874  }
875 
876  // close shared file
877  xCloseable->close( true );
878 
879  // TODO: keep file lock on shared file
880 
881  // store to shared file
882  if ( bSaveToShared )
883  {
884  bool bChangedViewSettings = false;
885  ScChangeViewSettings* pChangeViewSet = m_aDocument.GetChangeViewSettings();
886  if ( pChangeViewSet && pChangeViewSet->ShowChanges() )
887  {
888  pChangeViewSet->SetShowChanges( false );
889  pChangeViewSet->SetShowAccepted( false );
890  m_aDocument.SetChangeViewSettings( *pChangeViewSet );
891  bChangedViewSettings = true;
892  }
893 
894  uno::Reference< frame::XStorable > xStor( GetModel(), uno::UNO_QUERY_THROW );
895  // TODO/LATER: More entries from the MediaDescriptor might be interesting for the merge
896  uno::Sequence< beans::PropertyValue > aValues(1);
897  aValues[0].Name = "FilterName";
898  aValues[0].Value <<= GetMedium()->GetFilter()->GetFilterName();
899 
900  const SfxStringItem* pPasswordItem = SfxItemSet::GetItem<SfxStringItem>(GetMedium()->GetItemSet(), SID_PASSWORD, false);
901  if ( pPasswordItem && !pPasswordItem->GetValue().isEmpty() )
902  {
903  aValues.realloc( 2 );
904  aValues[1].Name = "Password";
905  aValues[1].Value <<= pPasswordItem->GetValue();
906  }
907 
908  SC_MOD()->SetInSharedDocSaving( true );
909  xStor->storeToURL( GetSharedFileURL(), aValues );
910  SC_MOD()->SetInSharedDocSaving( false );
911 
912  if ( bChangedViewSettings )
913  {
914  pChangeViewSet->SetShowChanges( true );
915  pChangeViewSet->SetShowAccepted( true );
916  m_aDocument.SetChangeViewSettings( *pChangeViewSet );
917  }
918  }
919 
920  bSuccess = true;
921  GetUndoManager()->Clear();
922  }
923  }
924  else
925  {
926  xCloseable->close( true );
927 
928  if ( bEntriesNotAccessible )
929  {
930  // TODO/LATER: in future an error regarding impossibility to write to share control file could be shown
932  }
933  else
934  {
935  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetActiveDialogParent(),
936  VclMessageType::Warning, VclButtonsType::Ok,
937  ScResId(STR_DOC_NOLONGERSHARED)));
938  xWarn->run();
939 
940  SfxBindings* pBindings = GetViewBindings();
941  if ( pBindings )
942  {
943  pBindings->ExecuteSynchron( SID_SAVEASDOC );
944  }
945  }
946  }
947  }
948  catch ( uno::Exception& )
949  {
950  TOOLS_WARN_EXCEPTION( "sc", "SfxEventHintId::SaveDoc" );
951  SC_MOD()->SetInSharedDocSaving( false );
952 
953  try
954  {
955  uno::Reference< util::XCloseable > xClose( xModel, uno::UNO_QUERY_THROW );
956  xClose->close( true );
957  }
958  catch ( uno::Exception& )
959  {
960  }
961  }
962  }
963 
964  if ( !bSuccess )
965  SetError(ERRCODE_IO_ABORT); // this error code will produce no error message, but will break the further saving process
966  }
967 #endif
968 
969  if (m_pSheetSaveData)
970  m_pSheetSaveData->SetInSupportedSave(true);
971  }
972  break;
973  case SfxEventHintId::SaveAsDoc:
974  {
975  if ( GetDocument().GetExternalRefManager()->containsUnsavedReferences() )
976  {
977  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetActiveDialogParent(),
978  VclMessageType::Warning, VclButtonsType::YesNo,
979  ScResId(STR_UNSAVED_EXT_REF)));
980  if (RET_NO == xWarn->run())
981  {
982  SetError(ERRCODE_IO_ABORT); // this error code will produce no error message, but will break the further saving process
983  }
984  }
985  [[fallthrough]];
986  }
987  case SfxEventHintId::SaveToDoc:
988  // #i108978# If no event is sent before saving, there will also be no "...DONE" event,
989  // and SAVE/SAVEAS can't be distinguished from SAVETO. So stream copying is only enabled
990  // if there is a SAVE/SAVEAS/SAVETO event first.
991  if (m_pSheetSaveData)
992  m_pSheetSaveData->SetInSupportedSave(true);
993  break;
994  case SfxEventHintId::SaveDocDone:
995  case SfxEventHintId::SaveAsDocDone:
996  {
997  // new positions are used after "save" and "save as", but not "save to"
998  UseSheetSaveEntries(); // use positions from saved file for next saving
999  [[fallthrough]];
1000  }
1001  case SfxEventHintId::SaveToDocDone:
1002  // only reset the flag, don't use the new positions
1003  if (m_pSheetSaveData)
1004  m_pSheetSaveData->SetInSupportedSave(false);
1005  break;
1006  default:
1007  {
1008  }
1009  break;
1010  }
1011  }
1012  else if (rHint.GetId() == SfxHintId::TitleChanged) // Without parameter
1013  {
1014  m_aDocument.SetName( SfxShell::GetName() );
1015  // RegisterNewTargetNames doesn't exist any longer
1016  SfxGetpApp()->Broadcast(SfxHint( SfxHintId::ScDocNameChanged )); // Navigator
1017  }
1018  else if (rHint.GetId() == SfxHintId::Deinitializing)
1019  {
1020 
1021 #if HAVE_FEATURE_SCRIPTING
1022  uno::Reference<script::vba::XVBACompatibility> xVBACompat(GetBasicContainer(), uno::UNO_QUERY);
1023  if (m_xVBAListener.is() && xVBACompat.is())
1024  {
1025  xVBACompat->removeVBAScriptListener(m_xVBAListener);
1026  }
1027 #endif
1028 
1029  if (m_aDocument.IsClipboardSource())
1030  {
1031  // Notes copied to the clipboard have a raw SdrCaptionObj pointer
1032  // copied from this document, forget it as it references this
1033  // document's drawing layer pages and what not, which otherwise when
1034  // pasting to another document after this document was destructed would
1035  // attempt to access non-existing data. Preserve the text data though.
1036  ScDocument* pClipDoc = ScModule::GetClipDoc();
1037  if (pClipDoc)
1038  pClipDoc->ClosingClipboardSource();
1039  }
1040  }
1041 
1042  const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
1043  if (!pSfxEventHint)
1044  return;
1045 
1046  switch( pSfxEventHint->GetEventId() )
1047  {
1048  case SfxEventHintId::CreateDoc:
1049  {
1050  uno::Any aWorkbook;
1051  aWorkbook <<= mxAutomationWorkbookObject;
1052  uno::Sequence< uno::Any > aArgs(1);
1053  aArgs[0] = aWorkbook;
1054  SC_MOD()->CallAutomationApplicationEventSinks( "NewWorkbook", aArgs );
1055  }
1056  break;
1057  case SfxEventHintId::OpenDoc:
1058  {
1059  uno::Any aWorkbook;
1060  aWorkbook <<= mxAutomationWorkbookObject;
1061  uno::Sequence< uno::Any > aArgs(1);
1062  aArgs[0] = aWorkbook;
1063  SC_MOD()->CallAutomationApplicationEventSinks( "WorkbookOpen", aArgs );
1064  }
1065  break;
1066  default:
1067  break;
1068  }
1069 }
1070 
1071 // Load contents for organizer
1073 {
1074  LoadMediumGuard aLoadGuard(&m_aDocument);
1075  ScRefreshTimerProtector aProt( m_aDocument.GetRefreshTimerControlAddress() );
1076 
1077  weld::WaitObject aWait( GetActiveDialogParent() );
1078 
1079  bool bRet = false;
1080 
1081  SetInitialLinkUpdate(&rMedium);
1082 
1083  // until loading/saving only the styles in XML is implemented,
1084  // load the whole file
1085  bRet = LoadXML( &rMedium, nullptr );
1086  InitItems();
1087 
1088  SfxObjectShell::LoadFrom( rMedium );
1089 
1090  return bRet;
1091 }
1092 
1093 static void lcl_parseHtmlFilterOption(const OUString& rOption, LanguageType& rLang, bool& rDateConvert)
1094 {
1095  OUStringBuffer aBuf;
1096  std::vector< OUString > aTokens;
1097  sal_Int32 n = rOption.getLength();
1098  const sal_Unicode* p = rOption.getStr();
1099  for (sal_Int32 i = 0; i < n; ++i)
1100  {
1101  const sal_Unicode c = p[i];
1102  if (c == ' ')
1103  {
1104  if (!aBuf.isEmpty())
1105  aTokens.push_back( aBuf.makeStringAndClear() );
1106  }
1107  else
1108  aBuf.append(c);
1109  }
1110 
1111  if (!aBuf.isEmpty())
1112  aTokens.push_back( aBuf.makeStringAndClear() );
1113 
1114  rLang = LanguageType( 0 );
1115  rDateConvert = false;
1116 
1117  if (!aTokens.empty())
1118  rLang = static_cast<LanguageType>(aTokens[0].toInt32());
1119  if (aTokens.size() > 1)
1120  rDateConvert = static_cast<bool>(aTokens[1].toInt32());
1121 }
1122 
1124 {
1125  LoadMediumGuard aLoadGuard(&m_aDocument);
1126 
1127  bool bRet = false; // sal_False means user quit!
1128  // On error: Set error at stream
1129 
1130  ScRefreshTimerProtector aProt( m_aDocument.GetRefreshTimerControlAddress() );
1131 
1132  GetUndoManager()->Clear();
1133 
1134  // Set optimal col width after import?
1135  bool bSetColWidths = false;
1136  bool bSetSimpleTextColWidths = false;
1137  std::map<SCCOL, ScColWidthParam> aColWidthParam;
1138  ScRange aColWidthRange;
1139  // Set optimal row height after import?
1140  bool bSetRowHeights = false;
1141 
1142  vector<ScDocRowHeightUpdater::TabRanges> aRecalcRowRangesArray;
1143 
1144  // All filters need the complete file in one piece (not asynchronously)
1145  // So make sure that we transfer the whole file with CreateFileStream
1146  rMedium.GetPhysicalName();
1147 
1148  SetInitialLinkUpdate(&rMedium);
1149 
1150  std::shared_ptr<const SfxFilter> pFilter = rMedium.GetFilter();
1151  if (pFilter)
1152  {
1153  OUString aFltName = pFilter->GetFilterName();
1154 
1155  bool bCalc3 = aFltName == "StarCalc 3.0";
1156  bool bCalc4 = aFltName == "StarCalc 4.0";
1157  if (!bCalc3 && !bCalc4)
1158  m_aDocument.SetInsertingFromOtherDoc( true );
1159 
1160  if (aFltName == pFilterXML)
1161  bRet = LoadXML( &rMedium, nullptr );
1162  else if (aFltName == pFilterLotus)
1163  {
1164  OUString sItStr;
1165  SfxItemSet* pSet = rMedium.GetItemSet();
1166  const SfxPoolItem* pItem;
1167  if ( pSet && SfxItemState::SET ==
1168  pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
1169  {
1170  sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
1171  }
1172 
1173  if (sItStr.isEmpty())
1174  {
1175  // default for lotus import (from API without options):
1176  // IBM_437 encoding
1177  sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_IBM_437 );
1178  }
1179 
1180  ErrCode eError = ScFormatFilter::Get().ScImportLotus123( rMedium, m_aDocument,
1181  ScGlobal::GetCharsetValue(sItStr));
1182  if (eError != ERRCODE_NONE)
1183  {
1184  if (!GetError())
1185  SetError(eError);
1186 
1187  if( eError.IsWarning() )
1188  bRet = true;
1189  }
1190  else
1191  bRet = true;
1192  bSetColWidths = true;
1193  bSetRowHeights = true;
1194  }
1195  else if ( aFltName == pFilterExcel4 || aFltName == pFilterExcel5 ||
1196  aFltName == pFilterExcel95 || aFltName == pFilterExcel97 ||
1197  aFltName == pFilterEx4Temp || aFltName == pFilterEx5Temp ||
1198  aFltName == pFilterEx95Temp || aFltName == pFilterEx97Temp )
1199  {
1200  EXCIMPFORMAT eFormat = EIF_AUTO;
1201  if ( aFltName == pFilterExcel4 || aFltName == pFilterEx4Temp )
1202  eFormat = EIF_BIFF_LE4;
1203  else if ( aFltName == pFilterExcel5 || aFltName == pFilterExcel95 ||
1204  aFltName == pFilterEx5Temp || aFltName == pFilterEx95Temp )
1205  eFormat = EIF_BIFF5;
1206  else if ( aFltName == pFilterExcel97 || aFltName == pFilterEx97Temp )
1207  eFormat = EIF_BIFF8;
1208 
1209  MakeDrawLayer();
1210  CalcOutputFactor(); // prepare update of row height
1211  ErrCode eError = ScFormatFilter::Get().ScImportExcel( rMedium, &m_aDocument, eFormat );
1212  m_aDocument.UpdateFontCharSet();
1213  if ( m_aDocument.IsChartListenerCollectionNeedsUpdate() )
1214  m_aDocument.UpdateChartListenerCollection();
1215 
1216  // all graphics objects must have names
1217  m_aDocument.EnsureGraphicNames();
1218 
1219  if (eError == SCWARN_IMPORT_RANGE_OVERFLOW)
1220  {
1221  if (!GetError())
1222  SetError(eError);
1223  bRet = true;
1224  }
1225  else if (eError != ERRCODE_NONE)
1226  {
1227  if (!GetError())
1228  SetError(eError);
1229  }
1230  else
1231  bRet = true;
1232  }
1233  else if (aFltName == "Gnumeric Spreadsheet")
1234  {
1236  if (!pOrcus)
1237  return false;
1238 
1239  bRet = pOrcus->importGnumeric(m_aDocument, rMedium);
1240  }
1241  else if (aFltName == "MS Excel 2003 XML Orcus")
1242  {
1244  if (!pOrcus)
1245  return false;
1246 
1247  bRet = pOrcus->importExcel2003XML(m_aDocument, rMedium);
1248  }
1249  else if (aFltName == pFilterAscii)
1250  {
1251  SfxItemSet* pSet = rMedium.GetItemSet();
1252  const SfxPoolItem* pItem;
1253  ScAsciiOptions aOptions;
1254  bool bOptInit = false;
1255 
1256  if ( pSet && SfxItemState::SET ==
1257  pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
1258  {
1259  aOptions.ReadFromString( static_cast<const SfxStringItem*>(pItem)->GetValue() );
1260  bOptInit = true;
1261  }
1262 
1263  if ( !bOptInit )
1264  {
1265  // default for ascii import (from API without options):
1266  // ISO8859-1/MS_1252 encoding, comma, double quotes
1267 
1268  aOptions.SetCharSet( RTL_TEXTENCODING_MS_1252 );
1269  aOptions.SetFieldSeps( OUString(',') );
1270  aOptions.SetTextSep( '"' );
1271  }
1272 
1273  ErrCode eError = ERRCODE_NONE;
1274  bool bOverflowRow, bOverflowCol, bOverflowCell;
1275  bOverflowRow = bOverflowCol = bOverflowCell = false;
1276 
1277  if( ! rMedium.IsStorage() )
1278  {
1279  ScImportExport aImpEx( m_aDocument );
1280  aImpEx.SetExtOptions( aOptions );
1281 
1282  SvStream* pInStream = rMedium.GetInStream();
1283  if (pInStream)
1284  {
1285  pInStream->SetStreamCharSet( aOptions.GetCharSet() );
1286  pInStream->Seek( 0 );
1287  bRet = aImpEx.ImportStream( *pInStream, rMedium.GetBaseURL(), SotClipboardFormatId::STRING );
1288  eError = bRet ? ERRCODE_NONE : SCERR_IMPORT_CONNECT;
1289  m_aDocument.StartAllListeners();
1291  m_aDocument.SetAllFormulasDirty(aCxt);
1292 
1293  // The same resulting name has to be handled in
1294  // ScExternalRefCache::initializeDoc() and related, hence
1295  // pass 'true' for RenameTab()'s bExternalDocument for a
1296  // composed name so ValidTabName() will not be checked,
1297  // which could veto the rename in case it contained
1298  // characters that Excel does not handle. If we wanted to
1299  // change that then it needed to be handled in all
1300  // corresponding places of the external references
1301  // manager/cache. Likely then we'd also need a method to
1302  // compose a name excluding such characters.
1303  m_aDocument.RenameTab( 0, INetURLObject( rMedium.GetName()).GetBase(), true/*bExternalDocument*/);
1304 
1305  bOverflowRow = aImpEx.IsOverflowRow();
1306  bOverflowCol = aImpEx.IsOverflowCol();
1307  bOverflowCell = aImpEx.IsOverflowCell();
1308  }
1309  else
1310  {
1311  OSL_FAIL( "No Stream" );
1312  }
1313  }
1314 
1315  if (eError != ERRCODE_NONE)
1316  {
1317  if (!GetError())
1318  SetError(eError);
1319  }
1320  else if (!GetError() && (bOverflowRow || bOverflowCol || bOverflowCell))
1321  {
1322  // precedence: row, column, cell
1323  ErrCode nWarn = (bOverflowRow ? SCWARN_IMPORT_ROW_OVERFLOW :
1324  (bOverflowCol ? SCWARN_IMPORT_COLUMN_OVERFLOW :
1326  SetError(nWarn);
1327  }
1328  bSetColWidths = true;
1329  bSetSimpleTextColWidths = true;
1330  }
1331  else if (aFltName == pFilterDBase)
1332  {
1333  OUString sItStr;
1334  SfxItemSet* pSet = rMedium.GetItemSet();
1335  const SfxPoolItem* pItem;
1336  if ( pSet && SfxItemState::SET ==
1337  pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
1338  {
1339  sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
1340  }
1341 
1342  if (sItStr.isEmpty())
1343  {
1344  // default for dBase import (from API without options):
1345  // IBM_850 encoding
1346 
1347  sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_IBM_850 );
1348  }
1349 
1350  ScDocRowHeightUpdater::TabRanges aRecalcRanges(0, m_aDocument.MaxRow());
1351  ErrCode eError = DBaseImport( rMedium.GetPhysicalName(),
1352  ScGlobal::GetCharsetValue(sItStr), aColWidthParam, aRecalcRanges.maRanges );
1353  aRecalcRowRangesArray.push_back(aRecalcRanges);
1354 
1355  if (eError != ERRCODE_NONE)
1356  {
1357  if (!GetError())
1358  SetError(eError);
1359  bRet = ( eError == SCWARN_IMPORT_RANGE_OVERFLOW );
1360  }
1361  else
1362  bRet = true;
1363 
1364  aColWidthRange.aStart.SetRow( 1 ); // Except for the column header
1365  bSetColWidths = true;
1366  bSetSimpleTextColWidths = true;
1367  }
1368  else if (aFltName == pFilterDif)
1369  {
1370  SvStream* pStream = rMedium.GetInStream();
1371  if (pStream)
1372  {
1373  ErrCode eError;
1374  OUString sItStr;
1375  SfxItemSet* pSet = rMedium.GetItemSet();
1376  const SfxPoolItem* pItem;
1377  if ( pSet && SfxItemState::SET ==
1378  pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
1379  {
1380  sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
1381  }
1382 
1383  if (sItStr.isEmpty())
1384  {
1385  // default for DIF import (from API without options):
1386  // ISO8859-1/MS_1252 encoding
1387 
1388  sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_MS_1252 );
1389  }
1390 
1391  eError = ScFormatFilter::Get().ScImportDif( *pStream, &m_aDocument, ScAddress(0,0,0),
1392  ScGlobal::GetCharsetValue(sItStr));
1393  if (eError != ERRCODE_NONE)
1394  {
1395  if (!GetError())
1396  SetError(eError);
1397 
1398  if( eError.IsWarning() )
1399  bRet = true;
1400  }
1401  else
1402  bRet = true;
1403  }
1404  bSetColWidths = true;
1405  bSetSimpleTextColWidths = true;
1406  bSetRowHeights = true;
1407  }
1408  else if (aFltName == pFilterSylk)
1409  {
1410  ErrCode eError = SCERR_IMPORT_UNKNOWN;
1411  bool bOverflowRow, bOverflowCol, bOverflowCell;
1412  bOverflowRow = bOverflowCol = bOverflowCell = false;
1413  if( !rMedium.IsStorage() )
1414  {
1415  ScImportExport aImpEx( m_aDocument );
1416 
1417  SvStream* pInStream = rMedium.GetInStream();
1418  if (pInStream)
1419  {
1420  pInStream->Seek( 0 );
1421  bRet = aImpEx.ImportStream( *pInStream, rMedium.GetBaseURL(), SotClipboardFormatId::SYLK );
1422  eError = bRet ? ERRCODE_NONE : SCERR_IMPORT_UNKNOWN;
1423  m_aDocument.StartAllListeners();
1425  m_aDocument.SetAllFormulasDirty(aCxt);
1426 
1427  bOverflowRow = aImpEx.IsOverflowRow();
1428  bOverflowCol = aImpEx.IsOverflowCol();
1429  bOverflowCell = aImpEx.IsOverflowCell();
1430  }
1431  else
1432  {
1433  OSL_FAIL( "No Stream" );
1434  }
1435  }
1436 
1437  if ( eError != ERRCODE_NONE && !GetError() )
1438  SetError(eError);
1439  else if (!GetError() && (bOverflowRow || bOverflowCol || bOverflowCell))
1440  {
1441  // precedence: row, column, cell
1442  ErrCode nWarn = (bOverflowRow ? SCWARN_IMPORT_ROW_OVERFLOW :
1443  (bOverflowCol ? SCWARN_IMPORT_COLUMN_OVERFLOW :
1445  SetError(nWarn);
1446  }
1447  bSetColWidths = true;
1448  bSetSimpleTextColWidths = true;
1449  bSetRowHeights = true;
1450  }
1451  else if (aFltName == pFilterQPro6)
1452  {
1453  ErrCode eError = ScFormatFilter::Get().ScImportQuattroPro(rMedium.GetInStream(), m_aDocument);
1454  if (eError != ERRCODE_NONE)
1455  {
1456  if (!GetError())
1457  SetError(eError);
1458  if( eError.IsWarning() )
1459  bRet = true;
1460  }
1461  else
1462  bRet = true;
1463  // TODO: Filter should set column widths. Not doing it here, it may
1464  // result in very narrow or wide columns, depending on content.
1465  // Setting row heights makes cells with font size attribution or
1466  // wrapping enabled look nicer...
1467  bSetRowHeights = true;
1468  }
1469  else if (aFltName == pFilterRtf)
1470  {
1471  ErrCode eError = SCERR_IMPORT_UNKNOWN;
1472  if( !rMedium.IsStorage() )
1473  {
1474  SvStream* pInStream = rMedium.GetInStream();
1475  if (pInStream)
1476  {
1477  pInStream->Seek( 0 );
1478  ScRange aRange;
1479  eError = ScFormatFilter::Get().ScImportRTF( *pInStream, rMedium.GetBaseURL(), &m_aDocument, aRange );
1480  if (eError != ERRCODE_NONE)
1481  {
1482  if (!GetError())
1483  SetError(eError);
1484 
1485  if( eError.IsWarning() )
1486  bRet = true;
1487  }
1488  else
1489  bRet = true;
1490  m_aDocument.StartAllListeners();
1492  m_aDocument.SetAllFormulasDirty(aCxt);
1493  bSetColWidths = true;
1494  bSetRowHeights = true;
1495  }
1496  else
1497  {
1498  OSL_FAIL( "No Stream" );
1499  }
1500  }
1501 
1502  if ( eError != ERRCODE_NONE && !GetError() )
1503  SetError(eError);
1504  }
1505  else if (aFltName == pFilterHtml || aFltName == pFilterHtmlWebQ)
1506  {
1507  ErrCode eError = SCERR_IMPORT_UNKNOWN;
1508  bool bWebQuery = aFltName == pFilterHtmlWebQ;
1509  if( !rMedium.IsStorage() )
1510  {
1511  SvStream* pInStream = rMedium.GetInStream();
1512  if (pInStream)
1513  {
1514  LanguageType eLang = LANGUAGE_SYSTEM;
1515  bool bDateConvert = false;
1516  SfxItemSet* pSet = rMedium.GetItemSet();
1517  const SfxPoolItem* pItem;
1518  if ( pSet && SfxItemState::SET ==
1519  pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
1520  {
1521  OUString aFilterOption = static_cast<const SfxStringItem*>(pItem)->GetValue();
1522  lcl_parseHtmlFilterOption(aFilterOption, eLang, bDateConvert);
1523  }
1524 
1525  pInStream->Seek( 0 );
1526  ScRange aRange;
1527  // HTML does its own ColWidth/RowHeight
1528  CalcOutputFactor();
1530  eError = ScFormatFilter::Get().ScImportHTML( *pInStream, rMedium.GetBaseURL(), &m_aDocument, aRange,
1531  GetOutputFactor(), !bWebQuery, &aNumFormatter, bDateConvert );
1532  if (eError != ERRCODE_NONE)
1533  {
1534  if (!GetError())
1535  SetError(eError);
1536 
1537  if( eError.IsWarning() )
1538  bRet = true;
1539  }
1540  else
1541  bRet = true;
1542  m_aDocument.StartAllListeners();
1543 
1545  m_aDocument.SetAllFormulasDirty(aCxt);
1546  }
1547  else
1548  {
1549  OSL_FAIL( "No Stream" );
1550  }
1551  }
1552 
1553  if ( eError != ERRCODE_NONE && !GetError() )
1554  SetError(eError);
1555  }
1556  else
1557  {
1558  if (!GetError())
1559  {
1560  SAL_WARN("sc.filter", "No match for filter '" << aFltName << "' in ConvertFrom");
1562  }
1563  }
1564 
1565  if (!bCalc3)
1566  m_aDocument.SetInsertingFromOtherDoc( false );
1567  }
1568  else
1569  {
1570  OSL_FAIL("No Filter in ConvertFrom");
1571  }
1572 
1573  InitItems();
1574  CalcOutputFactor();
1575  if ( bRet && (bSetColWidths || bSetRowHeights) )
1576  { // Adjust column width/row height; base 100% zoom
1577  Fraction aZoom( 1, 1 );
1578  double nPPTX = ScGlobal::nScreenPPTX * static_cast<double>(aZoom) / GetOutputFactor(); // Factor is printer display ratio
1579  double nPPTY = ScGlobal::nScreenPPTY * static_cast<double>(aZoom);
1581  // all sheets (for Excel import)
1582  SCTAB nTabCount = m_aDocument.GetTableCount();
1583  for (SCTAB nTab=0; nTab<nTabCount; nTab++)
1584  {
1585  SCCOL nEndCol;
1586  SCROW nEndRow;
1587  m_aDocument.GetCellArea( nTab, nEndCol, nEndRow );
1588  aColWidthRange.aEnd.SetCol( nEndCol );
1589  aColWidthRange.aEnd.SetRow( nEndRow );
1590  ScMarkData aMark(m_aDocument.GetSheetLimits());
1591  aMark.SetMarkArea( aColWidthRange );
1592  aMark.MarkToMulti();
1593 
1594  // Order is important: First width, then height
1595  if ( bSetColWidths )
1596  {
1597  for ( SCCOL nCol=0; nCol <= nEndCol; nCol++ )
1598  {
1599  if (!bSetSimpleTextColWidths)
1600  aColWidthParam[nCol].mbSimpleText = false;
1601 
1602  sal_uInt16 nWidth = m_aDocument.GetOptimalColWidth(
1603  nCol, nTab, pVirtDev, nPPTX, nPPTY, aZoom, aZoom, false, &aMark,
1604  &aColWidthParam[nCol] );
1605  m_aDocument.SetColWidth( nCol, nTab,
1606  nWidth + static_cast<sal_uInt16>(ScGlobal::nLastColWidthExtra) );
1607  }
1608  }
1609  }
1610 
1611  if (bSetRowHeights)
1612  {
1613  // Update all rows in all tables.
1614  ScSizeDeviceProvider aProv(this);
1615  ScDocRowHeightUpdater aUpdater(m_aDocument, aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), nullptr);
1616  aUpdater.update();
1617  }
1618  else if (!aRecalcRowRangesArray.empty())
1619  {
1620  // Update only specified row ranges for better performance.
1621  ScSizeDeviceProvider aProv(this);
1622  ScDocRowHeightUpdater aUpdater(m_aDocument, aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), &aRecalcRowRangesArray);
1623  aUpdater.update();
1624  }
1625  }
1626  FinishedLoading();
1627 
1628  // invalidate eventually temporary table areas
1629  if ( bRet )
1630  m_aDocument.InvalidateTableArea();
1631 
1632  m_bIsEmpty = false;
1633 
1634  return bRet;
1635 }
1636 
1638 {
1639  std::shared_ptr<const SfxFilter> pFilter = rMed.GetFilter();
1640  if (!pFilter)
1641  return false;
1642 
1643  if (pFilter->GetProviderName() == "orcus")
1644  {
1646  if (!pOrcus)
1647  return false;
1648 
1649  const OUString& rFilterName = pFilter->GetName();
1650  if (rFilterName == "gnumeric")
1651  {
1652  if (!pOrcus->importGnumeric(m_aDocument, rMed))
1653  return false;
1654  }
1655  else if (rFilterName == "csv")
1656  {
1657  if (!pOrcus->importCSV(m_aDocument, rMed))
1658  return false;
1659  }
1660  else if (rFilterName == "xlsx")
1661  {
1662  if (!pOrcus->importXLSX(m_aDocument, rMed))
1663  return false;
1664  }
1665  else if (rFilterName == "ods")
1666  {
1667  if (!pOrcus->importODS(m_aDocument, rMed))
1668  return false;
1669  }
1670 
1671  FinishedLoading();
1672  return true;
1673  }
1674 
1675  return false;
1676 }
1677 
1679  : mrDocShell( rDocShell)
1680 {
1681  // DoEnterHandler not here (because of AutoSave), is in ExecuteSave.
1682 
1684  if (pCharts)
1685  pCharts->UpdateDirtyCharts(); // Charts to be updated.
1688  mrDocShell.m_pAutoStyleList->ExecuteAllNow(); // Execute template timeouts now.
1690  {
1692  if (pRefMgr && pRefMgr->hasExternalData())
1693  {
1694  pRefMgr->setAllCacheTableReferencedStati( false);
1695  mrDocShell.m_aDocument.MarkUsedExternalReferences(); // Mark tables of external references to be written.
1696  }
1697  }
1698  if (mrDocShell.GetCreateMode()== SfxObjectCreateMode::STANDARD)
1699  mrDocShell.SfxObjectShell::SetVisArea( tools::Rectangle() ); // "Normally" worked on => no VisArea.
1700 }
1701 
1703 {
1704  if (mrDocShell.m_aDocument.HasExternalRefManager())
1705  {
1706  ScExternalRefManager* pRefMgr = mrDocShell.m_aDocument.GetExternalRefManager();
1707  if (pRefMgr && pRefMgr->hasExternalData())
1708  {
1709  // Prevent accidental data loss due to lack of knowledge.
1710  pRefMgr->setAllCacheTableReferencedStati( true);
1711  }
1712  }
1713 }
1714 
1716 {
1718 
1719  PrepareSaveGuard aPrepareGuard( *this);
1720 
1721  if (const auto pFrame1 = SfxViewFrame::GetFirst(this))
1722  {
1723  if (auto pSysWin = pFrame1->GetWindow().GetSystemWindow())
1724  {
1725  pSysWin->SetAccessibleName(OUString());
1726  }
1727  }
1728  // wait cursor is handled with progress bar
1729  bool bRet = SfxObjectShell::Save();
1730  if( bRet )
1731  bRet = SaveXML( GetMedium(), nullptr );
1732  return bRet;
1733 }
1734 
1735 namespace {
1736 
1740 void popFileName(OUString& rPath)
1741 {
1742  if (!rPath.isEmpty())
1743  {
1744  INetURLObject aURLObj(rPath);
1745  aURLObj.removeSegment();
1746  rPath = aURLObj.GetMainURL(INetURLObject::DecodeMechanism::NONE);
1747  }
1748 }
1749 
1750 }
1751 
1753 {
1754  // Commit any cell changes before saving.
1755  SC_MOD()->InputEnterHandler();
1756 }
1757 
1759 {
1760  OUString aCurPath; // empty for new document that hasn't been saved.
1761  const SfxMedium* pCurMedium = GetMedium();
1762  if (pCurMedium)
1763  {
1764  aCurPath = pCurMedium->GetName();
1765  popFileName(aCurPath);
1766  }
1767 
1768  if (!aCurPath.isEmpty())
1769  {
1770  // current document has a path -> not a brand-new document.
1771  OUString aNewPath = rMedium.GetName();
1772  popFileName(aNewPath);
1773  OUString aRel = URIHelper::simpleNormalizedMakeRelative(aCurPath, aNewPath);
1774  if (!aRel.isEmpty())
1775  {
1776  // Directory path will change before and after the save.
1778  }
1779  }
1780 
1781  ScTabViewShell* pViewShell = GetBestViewShell();
1783  if (bNeedsRehash)
1784  // legacy xls hash double-hashed by SHA1 is also supported.
1786  if (bNeedsRehash)
1787  { // SHA256 explicitly supported in ODF 1.2, implicitly in ODF 1.1
1789  }
1790 
1791  if (pViewShell && bNeedsRehash)
1792  {
1793  if (!pViewShell->ExecuteRetypePassDlg(PASSHASH_SHA1))
1794  // password re-type cancelled. Don't save the document.
1795  return false;
1796  }
1797 
1799 
1800  PrepareSaveGuard aPrepareGuard( *this);
1801 
1802  // wait cursor is handled with progress bar
1803  bool bRet = SfxObjectShell::SaveAs( rMedium );
1804  if (bRet)
1805  bRet = SaveXML( &rMedium, nullptr );
1806 
1807  return bRet;
1808 }
1809 
1810 namespace {
1811 
1812 // Xcl-like column width measured in characters of standard font.
1813 sal_Int32 lcl_ScDocShell_GetColWidthInChars( sal_uInt16 nWidth )
1814 {
1815  double f = nWidth;
1816  f *= 1328.0 / 25.0;
1817  f += 90.0;
1818  f *= 1.0 / 23.0;
1819  f /= 256.0;
1820 
1821  return sal_Int32( f );
1822 }
1823 
1824 void lcl_ScDocShell_GetFixedWidthString( OUString& rStr, const ScDocument& rDoc,
1825  SCTAB nTab, SCCOL nCol, bool bValue, SvxCellHorJustify eHorJust )
1826 {
1827  OUString aString = rStr;
1828  sal_Int32 nLen = lcl_ScDocShell_GetColWidthInChars(
1829  rDoc.GetColWidth( nCol, nTab ) );
1830  //If the text won't fit in the column
1831  if ( nLen < aString.getLength() )
1832  {
1833  OUStringBuffer aReplacement;
1834  if (bValue)
1835  aReplacement.append("###");
1836  else
1837  aReplacement.append(aString);
1838  //truncate to the number of characters that should fit, even in the
1839  //bValue case nLen might be < len ###
1840  aString = comphelper::string::truncateToLength(aReplacement, nLen).makeStringAndClear();
1841  }
1842  if ( nLen > aString.getLength() )
1843  {
1844  if ( bValue && eHorJust == SvxCellHorJustify::Standard )
1845  eHorJust = SvxCellHorJustify::Right;
1846  sal_Int32 nBlanks = nLen - aString.getLength();
1847  switch ( eHorJust )
1848  {
1849  case SvxCellHorJustify::Right:
1850  {
1851  OUStringBuffer aTmp;
1852  comphelper::string::padToLength( aTmp, nBlanks, ' ' );
1853  aString = aTmp.append(aString).makeStringAndClear();
1854  }
1855  break;
1856  case SvxCellHorJustify::Center:
1857  {
1858  sal_Int32 nLeftPad = nBlanks / 2;
1859  OUStringBuffer aTmp;
1860  comphelper::string::padToLength( aTmp, nLeftPad, ' ' );
1861  aTmp.append(aString);
1862  comphelper::string::padToLength( aTmp, nLen, ' ' );
1863  aString = aTmp.makeStringAndClear();
1864  }
1865  break;
1866  default:
1867  {
1868  OUStringBuffer aTmp(aString);
1869  comphelper::string::padToLength( aTmp, nLen, ' ' );
1870  aString = aTmp.makeStringAndClear();
1871  }
1872  }
1873  }
1874  rStr = aString;
1875 }
1876 
1877 void lcl_ScDocShell_WriteEmptyFixedWidthString( SvStream& rStream,
1878  const ScDocument& rDoc, SCTAB nTab, SCCOL nCol )
1879 {
1880  OUString aString;
1881  lcl_ScDocShell_GetFixedWidthString( aString, rDoc, nTab, nCol, false,
1882  SvxCellHorJustify::Standard );
1883  rStream.WriteUnicodeOrByteText( aString );
1884 }
1885 
1886 template<typename StrT, typename SepCharT>
1887 sal_Int32 getTextSepPos(
1888  const StrT& rStr, const ScImportOptions& rAsciiOpt, const SepCharT& rTextSep, const SepCharT& rFieldSep, bool& rNeedQuotes)
1889 {
1890  // #i116636# quotes are needed if text delimiter (quote), field delimiter,
1891  // or LF or CR is in the cell text.
1892  sal_Int32 nPos = rStr.indexOf(rTextSep);
1893  rNeedQuotes = rAsciiOpt.bQuoteAllText || (nPos >= 0) ||
1894  (rStr.indexOf(rFieldSep) >= 0) ||
1895  (rStr.indexOf('\n') >= 0) ||
1896  (rStr.indexOf('\r') >= 0);
1897  return nPos;
1898 }
1899 
1900 template<typename StrT, typename StrBufT>
1901 void escapeTextSep(sal_Int32 nPos, const StrT& rStrDelim, StrT& rStr)
1902 {
1903  while (nPos >= 0)
1904  {
1905  StrBufT aBuf(rStr);
1906  aBuf.insert(nPos, rStrDelim);
1907  rStr = aBuf.makeStringAndClear();
1908  nPos = rStr.indexOf(rStrDelim, nPos+1+rStrDelim.getLength());
1909  }
1910 }
1911 
1912 }
1913 
1914 void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt, SCTAB nTab )
1915 {
1916  sal_Unicode cDelim = rAsciiOpt.nFieldSepCode;
1917  sal_Unicode cStrDelim = rAsciiOpt.nTextSepCode;
1918  rtl_TextEncoding eCharSet = rAsciiOpt.eCharSet;
1919  bool bFixedWidth = rAsciiOpt.bFixedWidth;
1920  bool bSaveNumberAsSuch = rAsciiOpt.bSaveNumberAsSuch;
1921  bool bSaveAsShown = rAsciiOpt.bSaveAsShown;
1922  bool bShowFormulas = rAsciiOpt.bSaveFormulas;
1923 
1924  rtl_TextEncoding eOldCharSet = rStream.GetStreamCharSet();
1925  rStream.SetStreamCharSet( eCharSet );
1926  SvStreamEndian nOldNumberFormatInt = rStream.GetEndian();
1927  OString aStrDelimEncoded; // only used if not Unicode
1928  OUString aStrDelimDecoded; // only used if context encoding
1929  OString aDelimEncoded;
1930  OUString aDelimDecoded;
1931  bool bContextOrNotAsciiEncoding;
1932  if ( eCharSet == RTL_TEXTENCODING_UNICODE )
1933  {
1934  rStream.StartWritingUnicodeText();
1935  bContextOrNotAsciiEncoding = false;
1936  }
1937  else
1938  {
1939  aStrDelimEncoded = OString(&cStrDelim, 1, eCharSet);
1940  aDelimEncoded = OString(&cDelim, 1, eCharSet);
1941  rtl_TextEncodingInfo aInfo;
1942  aInfo.StructSize = sizeof(aInfo);
1943  if ( rtl_getTextEncodingInfo( eCharSet, &aInfo ) )
1944  {
1945  bContextOrNotAsciiEncoding =
1946  (((aInfo.Flags & RTL_TEXTENCODING_INFO_CONTEXT) != 0) ||
1947  ((aInfo.Flags & RTL_TEXTENCODING_INFO_ASCII) == 0));
1948  if ( bContextOrNotAsciiEncoding )
1949  {
1950  aStrDelimDecoded = OStringToOUString(aStrDelimEncoded, eCharSet);
1951  aDelimDecoded = OStringToOUString(aDelimEncoded, eCharSet);
1952  }
1953  }
1954  else
1955  bContextOrNotAsciiEncoding = false;
1956  }
1957 
1958  SCCOL nStartCol = 0;
1959  SCROW nStartRow = 0;
1960  SCCOL nEndCol;
1961  SCROW nEndRow;
1962  m_aDocument.GetCellArea( nTab, nEndCol, nEndRow );
1963 
1964  ScProgress aProgress( this, ScResId( STR_SAVE_DOC ), nEndRow, true );
1965 
1966  OUString aString;
1967 
1968  bool bTabProtect = m_aDocument.IsTabProtected( nTab );
1969 
1970  SCCOL nCol;
1971  SCROW nRow;
1972 
1973  // Treat the top left cell separator "sep=" special.
1974  // Here nStartRow == 0 && nStartCol == 0
1975  if (!bFixedWidth && cDelim != 0)
1976  {
1977  // First row iterator.
1978  ScHorizontalCellIterator aIter( m_aDocument, nTab, nStartCol, nStartRow, nEndCol, nStartRow);
1979  ScRefCellValue* pCell;
1980  // Must be first column and all following cells on this row must be
1981  // empty to fiddle with "sep=".
1982  if ((pCell = aIter.GetNext( nCol, nRow)) != nullptr && nCol == nStartCol && !aIter.GetNext( nCol, nRow))
1983  {
1984  if (pCell->meType == CELLTYPE_STRING)
1985  {
1986  aString = pCell->mpString->getString();
1987  if (aString.getLength() <= 5 && aString.startsWithIgnoreAsciiCase("sep="))
1988  {
1989  // Cell content is /^sep=.?$/ so write current separator.
1990  // Force the quote character to '"' regardless what is set
1991  // for export because that is the only one recognized on
1992  // import.
1993  aString = "sep=" + OUStringChar(cDelim);
1994  if (cStrDelim != 0)
1995  rStream.WriteUniOrByteChar( '"', eCharSet);
1996  if (eCharSet == RTL_TEXTENCODING_UNICODE)
1997  {
1998  write_uInt16s_FromOUString( rStream, aString);
1999  }
2000  else
2001  {
2002  OString aStrEnc = OUStringToOString( aString, eCharSet);
2003  // write byte encoded
2004  rStream.WriteBytes( aStrEnc.getStr(), aStrEnc.getLength());
2005  }
2006  if (cStrDelim != 0)
2007  rStream.WriteUniOrByteChar( '"', eCharSet);
2008  endlub( rStream );
2009  ++nStartRow;
2010  }
2011  }
2012  }
2013  }
2014 
2015  SCCOL nNextCol = nStartCol;
2016  SCROW nNextRow = nStartRow;
2017  SCCOL nEmptyCol;
2018  SCROW nEmptyRow;
2019  SvNumberFormatter& rFormatter = *m_aDocument.GetFormatTable();
2020 
2021  ScHorizontalCellIterator aIter( m_aDocument, nTab, nStartCol, nStartRow,
2022  nEndCol, nEndRow );
2023  ScRefCellValue* pCell;
2024  while ( ( pCell = aIter.GetNext( nCol, nRow ) ) != nullptr )
2025  {
2026  bool bProgress = false; // only upon line change
2027  if ( nNextRow < nRow )
2028  { // empty rows or/and empty columns up to end of row
2029  bProgress = true;
2030  for ( nEmptyCol = nNextCol; nEmptyCol < nEndCol; nEmptyCol++ )
2031  { // remaining columns of last row
2032  if ( bFixedWidth )
2033  lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2034  m_aDocument, nTab, nEmptyCol );
2035  else if ( cDelim != 0 )
2036  rStream.WriteUniOrByteChar( cDelim );
2037  }
2038  endlub( rStream );
2039  nNextRow++;
2040  for ( nEmptyRow = nNextRow; nEmptyRow < nRow; nEmptyRow++ )
2041  { // completely empty rows
2042  for ( nEmptyCol = nStartCol; nEmptyCol < nEndCol; nEmptyCol++ )
2043  {
2044  if ( bFixedWidth )
2045  lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2046  m_aDocument, nTab, nEmptyCol );
2047  else if ( cDelim != 0 )
2048  rStream.WriteUniOrByteChar( cDelim );
2049  }
2050  endlub( rStream );
2051  }
2052  for ( nEmptyCol = nStartCol; nEmptyCol < nCol; nEmptyCol++ )
2053  { // empty columns at beginning of row
2054  if ( bFixedWidth )
2055  lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2056  m_aDocument, nTab, nEmptyCol );
2057  else if ( cDelim != 0 )
2058  rStream.WriteUniOrByteChar( cDelim );
2059  }
2060  nNextRow = nRow;
2061  }
2062  else if ( nNextCol < nCol )
2063  { // empty columns in same row
2064  for ( nEmptyCol = nNextCol; nEmptyCol < nCol; nEmptyCol++ )
2065  { // columns in between
2066  if ( bFixedWidth )
2067  lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2068  m_aDocument, nTab, nEmptyCol );
2069  else if ( cDelim != 0 )
2070  rStream.WriteUniOrByteChar( cDelim );
2071  }
2072  }
2073  if ( nCol == nEndCol )
2074  {
2075  bProgress = true;
2076  nNextCol = nStartCol;
2077  nNextRow = nRow + 1;
2078  }
2079  else
2080  nNextCol = nCol + 1;
2081 
2082  CellType eType = pCell->meType;
2083  ScAddress aPos(nCol, nRow, nTab);
2084  if ( bTabProtect )
2085  {
2086  const ScProtectionAttr* pProtAttr =
2087  m_aDocument.GetAttr( nCol, nRow, nTab, ATTR_PROTECTION );
2088  if ( pProtAttr->GetHideCell() ||
2089  ( eType == CELLTYPE_FORMULA && bShowFormulas &&
2090  pProtAttr->GetHideFormula() ) )
2091  eType = CELLTYPE_NONE; // hide
2092  }
2093  bool bForceQuotes = false;
2094  bool bString;
2095  switch ( eType )
2096  {
2097  case CELLTYPE_NONE:
2098  aString.clear();
2099  bString = false;
2100  break;
2101  case CELLTYPE_FORMULA :
2102  {
2103  FormulaError nErrCode;
2104  if ( bShowFormulas )
2105  {
2106  pCell->mpFormula->GetFormula(aString);
2107  bString = true;
2108  }
2109  else if ((nErrCode = pCell->mpFormula->GetErrCode()) != FormulaError::NONE)
2110  {
2111  aString = ScGlobal::GetErrorString( nErrCode );
2112  bString = true;
2113  }
2114  else if (pCell->mpFormula->IsValue())
2115  {
2116  sal_uInt32 nFormat = m_aDocument.GetNumberFormat(aPos);
2117  if ( bFixedWidth || bSaveAsShown )
2118  {
2119  const Color* pDummy;
2120  ScCellFormat::GetString(*pCell, nFormat, aString, &pDummy, rFormatter, m_aDocument);
2121  bString = bSaveAsShown && rFormatter.IsTextFormat( nFormat);
2122  }
2123  else
2124  {
2125  ScCellFormat::GetInputString(*pCell, nFormat, aString, rFormatter, m_aDocument);
2126  bString = bForceQuotes = !bSaveNumberAsSuch;
2127  }
2128  }
2129  else
2130  {
2131  if ( bSaveAsShown )
2132  {
2133  sal_uInt32 nFormat = m_aDocument.GetNumberFormat(aPos);
2134  const Color* pDummy;
2135  ScCellFormat::GetString(*pCell, nFormat, aString, &pDummy, rFormatter, m_aDocument);
2136  }
2137  else
2138  aString = pCell->mpFormula->GetString().getString();
2139  bString = true;
2140  }
2141  }
2142  break;
2143  case CELLTYPE_STRING :
2144  if ( bSaveAsShown )
2145  {
2146  sal_uInt32 nFormat = m_aDocument.GetNumberFormat(aPos);
2147  const Color* pDummy;
2148  ScCellFormat::GetString(*pCell, nFormat, aString, &pDummy, rFormatter, m_aDocument);
2149  }
2150  else
2151  aString = pCell->mpString->getString();
2152  bString = true;
2153  break;
2154  case CELLTYPE_EDIT :
2155  {
2156  const EditTextObject* pObj = pCell->mpEditText;
2157  EditEngine& rEngine = m_aDocument.GetEditEngine();
2158  rEngine.SetText( *pObj);
2159  aString = rEngine.GetText(); // including LF
2160  bString = true;
2161  }
2162  break;
2163  case CELLTYPE_VALUE :
2164  {
2165  sal_uInt32 nFormat;
2166  m_aDocument.GetNumberFormat( nCol, nRow, nTab, nFormat );
2167  if ( bFixedWidth || bSaveAsShown )
2168  {
2169  const Color* pDummy;
2170  ScCellFormat::GetString(*pCell, nFormat, aString, &pDummy, rFormatter, m_aDocument);
2171  bString = bSaveAsShown && rFormatter.IsTextFormat( nFormat);
2172  }
2173  else
2174  {
2175  ScCellFormat::GetInputString(*pCell, nFormat, aString, rFormatter, m_aDocument);
2176  bString = bForceQuotes = !bSaveNumberAsSuch;
2177  }
2178  }
2179  break;
2180  default:
2181  OSL_FAIL( "ScDocShell::AsciiSave: unknown CellType" );
2182  aString.clear();
2183  bString = false;
2184  }
2185 
2186  if ( bFixedWidth )
2187  {
2188  SvxCellHorJustify eHorJust =
2189  m_aDocument.GetAttr( nCol, nRow, nTab, ATTR_HOR_JUSTIFY )->GetValue();
2190  lcl_ScDocShell_GetFixedWidthString( aString, m_aDocument, nTab, nCol,
2191  !bString, eHorJust );
2192  rStream.WriteUnicodeOrByteText( aString );
2193  }
2194  else
2195  {
2196  OUString aUniString = aString;// TODO: remove that later
2197  if (!bString && cStrDelim != 0 && !aUniString.isEmpty())
2198  {
2199  sal_Unicode c = aUniString[0];
2200  bString = (c == cStrDelim || c == ' ' ||
2201  aUniString.endsWith(" ") ||
2202  aUniString.indexOf(cStrDelim) >= 0);
2203  if (!bString && cDelim != 0)
2204  bString = (aUniString.indexOf(cDelim) >= 0);
2205  }
2206  if ( bString )
2207  {
2208  if ( cStrDelim != 0 ) //@ BugId 55355
2209  {
2210  if ( eCharSet == RTL_TEXTENCODING_UNICODE )
2211  {
2212  bool bNeedQuotes = false;
2213  sal_Int32 nPos = getTextSepPos(
2214  aUniString, rAsciiOpt, cStrDelim, cDelim, bNeedQuotes);
2215 
2216  escapeTextSep<OUString, OUStringBuffer>(
2217  nPos, OUString(cStrDelim), aUniString);
2218 
2219  if ( bNeedQuotes || bForceQuotes )
2220  rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
2221  write_uInt16s_FromOUString(rStream, aUniString);
2222  if ( bNeedQuotes || bForceQuotes )
2223  rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
2224  }
2225  else
2226  {
2227  // This is nasty. The Unicode to byte encoding
2228  // may convert typographical quotation marks to ASCII
2229  // quotation marks, which may interfere with the delimiter,
2230  // so we have to escape delimiters after the string has
2231  // been encoded. Since this may happen also with UTF-8
2232  // encoded typographical quotation marks if such was
2233  // specified as a delimiter we have to check for the full
2234  // encoded delimiter string, not just one character.
2235  // Now for RTL_TEXTENCODING_ISO_2022_... and similar brain
2236  // dead encodings where one code point (and especially a
2237  // low ASCII value) may represent different characters, we
2238  // have to convert forth and back and forth again. Same for
2239  // UTF-7 since it is a context sensitive encoding too.
2240 
2241  if ( bContextOrNotAsciiEncoding )
2242  {
2243  // to byte encoding
2244  OString aStrEnc = OUStringToOString(aUniString, eCharSet);
2245  // back to Unicode
2246  OUString aStrDec = OStringToOUString(aStrEnc, eCharSet);
2247 
2248  // search on re-decoded string
2249  bool bNeedQuotes = false;
2250  sal_Int32 nPos = getTextSepPos(
2251  aStrDec, rAsciiOpt, aStrDelimDecoded, aDelimDecoded, bNeedQuotes);
2252 
2253  escapeTextSep<OUString, OUStringBuffer>(
2254  nPos, aStrDelimDecoded, aStrDec);
2255 
2256  // write byte re-encoded
2257  if ( bNeedQuotes || bForceQuotes )
2258  rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
2259  rStream.WriteUnicodeOrByteText( aStrDec, eCharSet );
2260  if ( bNeedQuotes || bForceQuotes )
2261  rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
2262  }
2263  else
2264  {
2265  OString aStrEnc = OUStringToOString(aUniString, eCharSet);
2266 
2267  // search on encoded string
2268  bool bNeedQuotes = false;
2269  sal_Int32 nPos = getTextSepPos(
2270  aStrEnc, rAsciiOpt, aStrDelimEncoded, aDelimEncoded, bNeedQuotes);
2271 
2272  escapeTextSep<OString, OStringBuffer>(
2273  nPos, aStrDelimEncoded, aStrEnc);
2274 
2275  // write byte encoded
2276  if ( bNeedQuotes || bForceQuotes )
2277  rStream.WriteBytes(
2278  aStrDelimEncoded.getStr(), aStrDelimEncoded.getLength());
2279  rStream.WriteBytes(aStrEnc.getStr(), aStrEnc.getLength());
2280  if ( bNeedQuotes || bForceQuotes )
2281  rStream.WriteBytes(
2282  aStrDelimEncoded.getStr(), aStrDelimEncoded.getLength());
2283  }
2284  }
2285  }
2286  else
2287  rStream.WriteUnicodeOrByteText( aUniString );
2288  }
2289  else
2290  rStream.WriteUnicodeOrByteText( aUniString );
2291  }
2292 
2293  if( nCol < nEndCol )
2294  {
2295  if(cDelim!=0) //@ BugId 55355
2296  rStream.WriteUniOrByteChar( cDelim );
2297  }
2298  else
2299  endlub( rStream );
2300 
2301  if ( bProgress )
2302  aProgress.SetStateOnPercent( nRow );
2303  }
2304 
2305  // write out empty if requested
2306  if ( nNextRow <= nEndRow )
2307  {
2308  for ( nEmptyCol = nNextCol; nEmptyCol < nEndCol; nEmptyCol++ )
2309  { // remaining empty columns of last row
2310  if ( bFixedWidth )
2311  lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2312  m_aDocument, nTab, nEmptyCol );
2313  else if ( cDelim != 0 )
2314  rStream.WriteUniOrByteChar( cDelim );
2315  }
2316  endlub( rStream );
2317  nNextRow++;
2318  }
2319  for ( nEmptyRow = nNextRow; nEmptyRow <= nEndRow; nEmptyRow++ )
2320  { // entire empty rows
2321  for ( nEmptyCol = nStartCol; nEmptyCol < nEndCol; nEmptyCol++ )
2322  {
2323  if ( bFixedWidth )
2324  lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2325  m_aDocument, nTab, nEmptyCol );
2326  else if ( cDelim != 0 )
2327  rStream.WriteUniOrByteChar( cDelim );
2328  }
2329  endlub( rStream );
2330  }
2331 
2332  rStream.SetStreamCharSet( eOldCharSet );
2333  rStream.SetEndian( nOldNumberFormatInt );
2334 }
2335 
2337 {
2339 
2340  // #i6500# don't call DoEnterHandler here (doesn't work with AutoSave),
2341  // it's already in ExecuteSave (as for Save and SaveAs)
2342 
2343  if (m_pAutoStyleList)
2344  m_pAutoStyleList->ExecuteAllNow(); // Execute template timeouts now
2345  if (GetCreateMode()== SfxObjectCreateMode::STANDARD)
2346  SfxObjectShell::SetVisArea( tools::Rectangle() ); // Edited normally -> no VisArea
2347 
2348  OSL_ENSURE( rMed.GetFilter(), "Filter == 0" );
2349 
2350  bool bRet = false;
2351  OUString aFltName = rMed.GetFilter()->GetFilterName();
2352 
2353  if (aFltName == pFilterXML)
2354  {
2355  //TODO/LATER: this shouldn't happen!
2356  OSL_FAIL("XML filter in ConvertFrom?!");
2357  bRet = SaveXML( &rMed, nullptr );
2358  }
2359  else if (aFltName == pFilterExcel5 || aFltName == pFilterExcel95 ||
2360  aFltName == pFilterExcel97 || aFltName == pFilterEx5Temp ||
2361  aFltName == pFilterEx95Temp || aFltName == pFilterEx97Temp)
2362  {
2364 
2365  bool bDoSave = true;
2366  if( ScTabViewShell* pViewShell = GetBestViewShell() )
2367  {
2369  if( !pExtDocOpt )
2370  {
2371  m_aDocument.SetExtDocOptions( std::make_unique<ScExtDocOptions>() );
2372  pExtDocOpt = m_aDocument.GetExtDocOptions();
2373  }
2374  pViewShell->GetViewData().WriteExtOptions( *pExtDocOpt );
2375 
2376  /* #i104990# If the imported document contains a medium
2377  password, determine if we can save it, otherwise ask the users
2378  whether they want to save without it. */
2379  if( (rMed.GetFilter()->GetFilterFlags() & SfxFilterFlags::ENCRYPTION) == SfxFilterFlags::NONE )
2380  {
2381  SfxItemSet* pItemSet = rMed.GetItemSet();
2382  const SfxPoolItem* pItem = nullptr;
2383  if( pItemSet && pItemSet->GetItemState( SID_PASSWORD, true, &pItem ) == SfxItemState::SET )
2384  {
2385  bDoSave = ScWarnPassword::WarningOnPassword( rMed );
2386  // #i42858# remove password from medium (warn only one time)
2387  if( bDoSave )
2388  pItemSet->ClearItem( SID_PASSWORD );
2389  }
2390  }
2391 
2392  if( bDoSave )
2393  {
2394  bool bNeedRetypePassDlg = ScPassHashHelper::needsPassHashRegen( m_aDocument, PASSHASH_XL );
2395  bDoSave = !bNeedRetypePassDlg || pViewShell->ExecuteRetypePassDlg( PASSHASH_XL );
2396  }
2397  }
2398 
2399  if( bDoSave )
2400  {
2401  ExportFormatExcel eFormat = ExpBiff5;
2402  if( aFltName == pFilterExcel97 || aFltName == pFilterEx97Temp )
2403  eFormat = ExpBiff8;
2404  ErrCode eError = ScFormatFilter::Get().ScExportExcel5( rMed, &m_aDocument, eFormat, RTL_TEXTENCODING_MS_1252 );
2405 
2406  if( eError && !GetError() )
2407  SetError(eError);
2408 
2409  // don't return false for warnings
2410  bRet = eError.IsWarning() || (eError == ERRCODE_NONE);
2411  }
2412  else
2413  {
2414  // export aborted, i.e. "Save without password" warning
2416  }
2417  }
2418  else if (aFltName == pFilterAscii)
2419  {
2420  OUString sItStr;
2421  SfxItemSet* pSet = rMed.GetItemSet();
2422  const SfxPoolItem* pItem;
2423  if ( pSet && SfxItemState::SET ==
2424  pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
2425  {
2426  sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
2427  }
2428 
2429  if ( sItStr.isEmpty() )
2430  {
2431  // default for ascii export (from API without options):
2432  // ISO8859-1/MS_1252 encoding, comma, double quotes
2433 
2434  ScImportOptions aDefOptions( ',', '"', RTL_TEXTENCODING_MS_1252 );
2435  sItStr = aDefOptions.BuildString();
2436  }
2437 
2439  ScImportOptions aOptions( sItStr );
2440 
2441  if (aOptions.nSheetToExport)
2442  {
2443  // Only from command line --convert-to
2444  bRet = true;
2445 
2446  // Verbose only from command line, not UI (in case we actually
2447  // implement that) nor macro filter options.
2448  bool bVerbose = false;
2449  const css::uno::Sequence<css::beans::PropertyValue> & rArgs = rMed.GetArgs();
2450  const auto pProp = std::find_if( rArgs.begin(), rArgs.end(),
2451  [](const css::beans::PropertyValue& rProp) { return rProp.Name == "ConversionRequestOrigin"; });
2452  if (pProp != rArgs.end())
2453  {
2454  OUString aOrigin;
2455  pProp->Value >>= aOrigin;
2456  bVerbose = (aOrigin == "CommandLine");
2457  }
2458 
2459  SCTAB nStartTab;
2461  if (aOptions.nSheetToExport == -1)
2462  {
2463  // All sheets.
2464  nStartTab = 0;
2465  }
2466  else if (0 < aOptions.nSheetToExport && aOptions.nSheetToExport <= nCount)
2467  {
2468  // One sheet, 1-based.
2469  nCount = aOptions.nSheetToExport;
2470  nStartTab = nCount - 1;
2471  }
2472  else
2473  {
2474  // Usage error, no export but log.
2475  if (bVerbose)
2476  {
2477  if (aOptions.nSheetToExport < 0)
2478  std::cout << "Bad sheet number string given." << std::endl;
2479  else
2480  std::cout << "No sheet number " << aOptions.nSheetToExport
2481  << ", number of sheets is " << nCount << std::endl;
2482  }
2483  nStartTab = 0;
2484  nCount = 0;
2486  bRet = false;
2487  }
2488 
2489  INetURLObject aURLObject(rMed.GetURLObject());
2490  OUString sExt = aURLObject.CutExtension();
2491  OUString sBaseName = aURLObject.GetLastName();
2492  aURLObject.CutLastName();
2493 
2494  for (SCTAB i = nStartTab; i < nCount; ++i)
2495  {
2496  OUString sTabName;
2497  if (!m_aDocument.GetName(i, sTabName))
2498  sTabName = OUString::number(i);
2499  INetURLObject aSheetURLObject(aURLObject);
2500  OUString sFileName = sBaseName + "-" + sTabName;
2501  if (!sExt.isEmpty())
2502  sFileName = sFileName + "." + sExt;
2503  aSheetURLObject.Append(sFileName);
2504 
2505  // log similar to DispatchWatcher::executeDispatchRequests
2506  OUString aOutFile = aSheetURLObject.GetMainURL(INetURLObject::DecodeMechanism::NONE);
2507  if (bVerbose)
2508  {
2509  OUString aDisplayedName;
2510  if (osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(aOutFile, aDisplayedName))
2511  aDisplayedName = aOutFile;
2512  std::cout << "Writing sheet " << OUStringToOString(sTabName, osl_getThreadTextEncoding()) << " -> "
2513  << OUStringToOString(aDisplayedName, osl_getThreadTextEncoding())
2514  << std::endl;
2515 
2516  if (FStatHelper::IsDocument(aOutFile))
2517  std::cout << "Overwriting: " << OUStringToOString(aDisplayedName, osl_getThreadTextEncoding())
2518  << std::endl ;
2519  }
2520 
2521  std::unique_ptr<SvStream> xStm = ::utl::UcbStreamHelper::CreateStream(aOutFile, StreamMode::TRUNC | StreamMode::WRITE);
2522  if (!xStm)
2523  {
2525  bRet = false;
2526  break;
2527  }
2528  AsciiSave(*xStm, aOptions, i);
2529  }
2530  }
2531  else
2532  {
2533  SvStream* pStream = rMed.GetOutStream();
2534  if (pStream)
2535  {
2536  AsciiSave(*pStream, aOptions, GetSaveTab());
2537  bRet = true;
2538 
2539  if (m_aDocument.GetTableCount() > 1)
2540  if (!rMed.GetError())
2542  }
2543  }
2544  }
2545  else if (aFltName == pFilterDBase)
2546  {
2547  OUString sCharSet;
2548  SfxItemSet* pSet = rMed.GetItemSet();
2549  const SfxPoolItem* pItem;
2550  if ( pSet && SfxItemState::SET ==
2551  pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
2552  {
2553  sCharSet = static_cast<const SfxStringItem*>(pItem)->GetValue();
2554  }
2555 
2556  if (sCharSet.isEmpty())
2557  {
2558  // default for dBase export (from API without options):
2559  // IBM_850 encoding
2560 
2561  sCharSet = ScGlobal::GetCharsetString( RTL_TEXTENCODING_IBM_850 );
2562  }
2563 
2565  // Hack so that Sba can overwrite the opened TempFile.
2566  rMed.CloseOutStream();
2567  bool bHasMemo = false;
2568 
2569  ErrCode eError = DBaseExport(
2570  rMed.GetPhysicalName(), ScGlobal::GetCharsetValue(sCharSet), bHasMemo);
2571 
2572  INetURLObject aTmpFile( rMed.GetPhysicalName(), INetProtocol::File );
2573  if ( bHasMemo )
2574  aTmpFile.setExtension(u"dbt");
2575  if ( eError != ERRCODE_NONE && !eError.IsWarning() )
2576  {
2577  if (!GetError())
2578  SetError(eError);
2579  if ( bHasMemo && IsDocument( aTmpFile ) )
2580  KillFile( aTmpFile );
2581  }
2582  else
2583  {
2584  bRet = true;
2585  if ( bHasMemo )
2586  {
2587  const SfxStringItem* pNameItem = rMed.GetItemSet()->GetItem<SfxStringItem>( SID_FILE_NAME );
2588  INetURLObject aDbtFile( pNameItem->GetValue(), INetProtocol::File );
2589  aDbtFile.setExtension(u"dbt");
2590 
2591  // tdf#40713: don't lose dbt file
2592  // if aDbtFile corresponds exactly to aTmpFile, we just have to return
2593  if (aDbtFile.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ) ==
2594  aTmpFile.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ))
2595  {
2596  if (eError != ERRCODE_NONE && !GetError())
2597  SetError(eError);
2598  return bRet;
2599  }
2600 
2601  if ( IsDocument( aDbtFile ) && !KillFile( aDbtFile ) )
2602  bRet = false;
2603  if ( bRet && !MoveFile( aTmpFile, aDbtFile ) )
2604  bRet = false;
2605  if ( !bRet )
2606  {
2607  KillFile( aTmpFile );
2608  if (eError == ERRCODE_NONE || eError.IsWarning())
2609  eError = SCERR_EXPORT_DATA;
2610  }
2611  }
2612  if (eError != ERRCODE_NONE && !GetError())
2613  SetError(eError);
2614  }
2615  }
2616  else if (aFltName == pFilterDif)
2617  {
2618  SvStream* pStream = rMed.GetOutStream();
2619  if (pStream)
2620  {
2621  OUString sItStr;
2622  SfxItemSet* pSet = rMed.GetItemSet();
2623  const SfxPoolItem* pItem;
2624  if ( pSet && SfxItemState::SET ==
2625  pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
2626  {
2627  sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
2628  }
2629 
2630  if (sItStr.isEmpty())
2631  {
2632  // default for DIF export (from API without options):
2633  // ISO8859-1/MS_1252 encoding
2634 
2635  sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_MS_1252 );
2636  }
2637 
2639  ScFormatFilter::Get().ScExportDif( *pStream, &m_aDocument, ScAddress(0,0,0),
2640  ScGlobal::GetCharsetValue(sItStr) );
2641  bRet = true;
2642 
2643  if (m_aDocument.GetTableCount() > 1)
2644  if (!rMed.GetError())
2646  }
2647  }
2648  else if (aFltName == pFilterSylk)
2649  {
2650  SvStream* pStream = rMed.GetOutStream();
2651  if ( pStream )
2652  {
2654 
2655  SCCOL nEndCol;
2656  SCROW nEndRow;
2657  m_aDocument.GetCellArea( 0, nEndCol, nEndRow );
2658  ScRange aRange( 0,0,0, nEndCol,nEndRow,0 );
2659 
2660  ScImportExport aImExport( m_aDocument, aRange );
2661  aImExport.SetFormulas( true );
2662  bRet = aImExport.ExportStream( *pStream, rMed.GetBaseURL( true ), SotClipboardFormatId::SYLK );
2663  }
2664  }
2665  else if (aFltName == pFilterHtml)
2666  {
2667  SvStream* pStream = rMed.GetOutStream();
2668  if ( pStream )
2669  {
2670  SfxItemSet* pSet = rMed.GetItemSet();
2671  const SfxPoolItem* pItem;
2672  OUString sFilterOptions;
2673 
2674  if (pSet->GetItemState(SID_FILE_FILTEROPTIONS, true, &pItem) == SfxItemState::SET)
2675  sFilterOptions = static_cast<const SfxStringItem*>(pItem)->GetValue();
2676 
2678  ScImportExport aImExport(m_aDocument);
2679  aImExport.SetStreamPath(rMed.GetName());
2680  aImExport.SetFilterOptions(sFilterOptions);
2681  bRet = aImExport.ExportStream(*pStream, rMed.GetBaseURL(true), SotClipboardFormatId::HTML);
2682  if (bRet && !aImExport.GetNonConvertibleChars().isEmpty())
2683  {
2686  aImExport.GetNonConvertibleChars(),
2687  DialogMask::ButtonsOk | DialogMask::MessageInfo));
2688  }
2689  }
2690  }
2691  else
2692  {
2693  if (GetError())
2695  }
2696  return bRet;
2697 }
2698 
2699 bool ScDocShell::DoSaveCompleted( SfxMedium * pNewStor, bool bRegisterRecent )
2700 {
2701  bool bRet = SfxObjectShell::DoSaveCompleted( pNewStor, bRegisterRecent );
2702 
2703  // SfxHintId::ScDocSaved for change ReadOnly -> Read/Write
2704  Broadcast( SfxHint( SfxHintId::ScDocSaved ) );
2705  return bRet;
2706 }
2707 
2708 bool ScDocShell::QuerySlotExecutable( sal_uInt16 nSlotId )
2709 {
2710  // #i112634# ask VBA event handlers whether to save or print the document
2711 
2712  using namespace ::com::sun::star::script::vba;
2713 
2714  sal_Int32 nVbaEventId = VBAEventId::NO_EVENT;
2715  uno::Sequence< uno::Any > aArgs;
2716  switch( nSlotId )
2717  {
2718  case SID_SAVEDOC:
2719  case SID_SAVEASDOC:
2720  nVbaEventId = VBAEventId::WORKBOOK_BEFORESAVE;
2721  aArgs.realloc( 1 );
2722  aArgs[ 0 ] <<= (nSlotId == SID_SAVEASDOC);
2723  break;
2724  case SID_PRINTDOC:
2725  case SID_PRINTDOCDIRECT:
2726  nVbaEventId = VBAEventId::WORKBOOK_BEFOREPRINT;
2727  break;
2728  }
2729 
2730  bool bSlotExecutable = true;
2731  if( nVbaEventId != VBAEventId::NO_EVENT ) try
2732  {
2733  uno::Reference< XVBAEventProcessor > xEventProcessor( m_aDocument.GetVbaEventProcessor(), uno::UNO_SET_THROW );
2734  xEventProcessor->processVbaEvent( nVbaEventId, aArgs );
2735  }
2736  catch( util::VetoException& )
2737  {
2738  bSlotExecutable = false;
2739  }
2740  catch( uno::Exception& )
2741  {
2742  }
2743  return bSlotExecutable;
2744 }
2745 
2747 {
2748  if(SC_MOD()->GetCurRefDlgId()>0)
2749  {
2750  SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
2751  if( pFrame )
2752  {
2753  SfxViewShell* p = pFrame->GetViewShell();
2754  ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( p );
2755  if(pViewSh!=nullptr)
2756  {
2757  vcl::Window *pWin=pViewSh->GetWindow();
2758  if(pWin!=nullptr) pWin->GrabFocus();
2759  }
2760  }
2761 
2762  return false;
2763  }
2765  {
2766  ErrorMessage(STR_CLOSE_ERROR_LINK);
2767  return false;
2768  }
2769 
2770  DoEnterHandler();
2771 
2772  // start 'Workbook_BeforeClose' VBA event handler for possible veto
2773  if( !IsInPrepareClose() )
2774  {
2775  try
2776  {
2777  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( m_aDocument.GetVbaEventProcessor(), uno::UNO_SET_THROW );
2778  uno::Sequence< uno::Any > aArgs;
2779  xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_BEFORECLOSE, aArgs );
2780  }
2781  catch( util::VetoException& )
2782  {
2783  // if event processor throws VetoException, macro has vetoed close
2784  return false;
2785  }
2786  catch( uno::Exception& )
2787  {
2788  }
2789  }
2790  // end handler code
2791 
2792  bool bRet = SfxObjectShell::PrepareClose( bUI );
2793  if (bRet) // true == close
2794  m_aDocument.EnableIdle(false); // Do not mess around with it anymore!
2795 
2796  return bRet;
2797 }
2798 
2800 {
2801  return pFilterSc50;
2802 }
2803 
2805 {
2806  return pFilterHtml;
2807 }
2808 
2810 {
2811  return pFilterHtmlWebQ;
2812 }
2813 
2815 {
2816  return pFilterAscii;
2817 }
2818 
2820 {
2821  return pFilterLotus;
2822 }
2823 
2825 {
2826  return pFilterDBase;
2827 }
2828 
2830 {
2831  return pFilterDif;
2832 }
2833 
2834 bool ScDocShell::HasAutomaticTableName( std::u16string_view rFilter )
2835 {
2836  // sal_True for those filters that keep the default table name
2837  // (which is language specific)
2838 
2839  return rFilter == pFilterAscii
2840  || rFilter == pFilterLotus
2841  || rFilter == pFilterExcel4
2842  || rFilter == pFilterEx4Temp
2843  || rFilter == pFilterDBase
2844  || rFilter == pFilterDif
2845  || rFilter == pFilterSylk
2846  || rFilter == pFilterHtml
2847  || rFilter == pFilterRtf;
2848 }
2849 
2850 std::unique_ptr<ScDocFunc> ScDocShell::CreateDocFunc()
2851 {
2852  return std::make_unique<ScDocFuncDirect>( *this );
2853 }
2854 
2855 ScDocShell::ScDocShell( const SfxModelFlags i_nSfxCreationFlags ) :
2856  SfxObjectShell( i_nSfxCreationFlags ),
2857  m_aDocument ( SCDOCMODE_DOCUMENT, this ),
2858  m_aDdeTextFmt(OUString("TEXT")),
2859  m_nPrtToScreenFactor( 1.0 ),
2860  m_pImpl ( new DocShell_Impl ),
2861  m_bHeaderOn ( true ),
2862  m_bFooterOn ( true ),
2863  m_bIsEmpty ( true ),
2864  m_bIsInUndo ( false ),
2865  m_bDocumentModifiedPending( false ),
2866  m_bUpdateEnabled ( true ),
2867  m_bUcalcTest ( false ),
2869  m_nDocumentLock ( 0 ),
2870  m_nCanUpdate (css::document::UpdateDocMode::ACCORDING_TO_CONFIG)
2871 {
2872  SetPool( &SC_MOD()->GetPool() );
2873 
2874  m_bIsInplace = (GetCreateMode() == SfxObjectCreateMode::EMBEDDED);
2875  // Will be reset if not in place
2876 
2878 
2879  // SetBaseModel needs exception handling
2880  ScModelObj::CreateAndSet( this );
2881 
2882  StartListening(*this);
2884  if (pStlPool)
2885  StartListening(*pStlPool);
2886 
2888  LINK( this, ScDocShell, RefreshDBDataHdl ) );
2889 
2890  // InitItems and CalcOutputFactor are called now in Load/ConvertFrom/InitNew
2891 }
2892 
2894 {
2895  ResetDrawObjectShell(); // If the Drawing Layer still tries to access it, access it
2896 
2898  if (pStlPool)
2899  EndListening(*pStlPool);
2900  EndListening(*this);
2901 
2902  m_pAutoStyleList.reset();
2903 
2904  SfxApplication *pSfxApp = SfxGetpApp();
2905  if ( pSfxApp->GetDdeService() ) // Delete DDE for Document
2906  pSfxApp->RemoveDdeTopic( this );
2907 
2908  m_pDocFunc.reset();
2909  delete m_aDocument.mpUndoManager;
2910  m_aDocument.mpUndoManager = nullptr;
2911  m_pImpl.reset();
2912 
2913  m_pPaintLockData.reset();
2914 
2915  m_pSolverSaveData.reset();
2916  m_pSheetSaveData.reset();
2917  m_pFormatSaveData.reset();
2918  m_pOldAutoDBRange.reset();
2919 
2920  if (m_pModificator)
2921  {
2922  OSL_FAIL("The Modificator should not exist");
2923  m_pModificator.reset();
2924  }
2925 }
2926 
2928 {
2929  return m_aDocument.GetUndoManager();
2930 }
2931 
2932 void ScDocShell::SetModified( bool bModified )
2933 {
2935  {
2936  SfxObjectShell::SetModified( bModified );
2937  Broadcast( SfxHint( SfxHintId::DocChanged ) );
2938  }
2939 }
2940 
2942 {
2943  // BroadcastUno must also happen right away with pPaintLockData
2944  // FIXME: Also for SetDrawModified, if Drawing is connected
2945  // FIXME: Then own Hint?
2946 
2947  if ( m_pPaintLockData )
2948  {
2949  // #i115009# broadcast BCA_BRDCST_ALWAYS, so a component can read recalculated results
2950  // of RecalcModeAlways formulas (like OFFSET) after modifying cells
2951  m_aDocument.Broadcast(ScHint(SfxHintId::ScDataChanged, BCA_BRDCST_ALWAYS));
2952  m_aDocument.InvalidateTableArea(); // #i105279# needed here
2953  m_aDocument.BroadcastUno( SfxHint( SfxHintId::DataChanged ) );
2954 
2955  m_pPaintLockData->SetModified(); // Later on ...
2956  return;
2957  }
2958 
2959  SetDrawModified();
2960 
2963  else
2964  {
2965  SetDocumentModifiedPending( false );
2969  m_aDocument.Broadcast(ScHint(SfxHintId::ScDataChanged, BCA_BRDCST_ALWAYS));
2971  m_aDocument.CalcFormulaTree( true );
2973  PostDataChanged();
2974 
2975  // Detective AutoUpdate:
2976  // Update if formulas were modified (DetectiveDirty) or the list contains
2977  // "Trace Error" entries (Trace Error can look completely different
2978  // after changes to non-formula cells).
2979 
2981  if ( pList && ( m_aDocument.IsDetectiveDirty() || pList->HasAddError() ) &&
2982  pList->Count() && !IsInUndo() && SC_MOD()->GetAppOptions().GetDetectiveAuto() )
2983  {
2984  GetDocFunc().DetectiveRefresh(true); // sal_True = caused by automatic update
2985  }
2986  m_aDocument.SetDetectiveDirty(false); // always reset, also if not refreshed
2987  }
2988 
2990  {
2992  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreasChanged));
2993  }
2994 
2995  // notify UNO objects after BCA_BRDCST_ALWAYS etc.
2996  m_aDocument.BroadcastUno( SfxHint( SfxHintId::DataChanged ) );
2997 }
2998 
3006 {
3007  bool bUpdate = !IsModified();
3008 
3009  SetModified();
3010 
3011  SfxBindings* pBindings = GetViewBindings();
3012  if (bUpdate && pBindings)
3013  {
3014  pBindings->Invalidate( SID_SAVEDOC );
3015  pBindings->Invalidate( SID_DOC_MODIFIED );
3016  }
3017 
3018  if (pBindings)
3019  {
3020  // #i105960# Undo etc used to be volatile.
3021  // They always have to be invalidated, including drawing layer or row height changes
3022  // (but not while pPaintLockData is set).
3023  pBindings->Invalidate( SID_UNDO );
3024  pBindings->Invalidate( SID_REDO );
3025  pBindings->Invalidate( SID_REPEAT );
3026  }
3027 
3029  {
3031  SfxGetpApp()->Broadcast(SfxHint( SfxHintId::ScDrawChanged )); // Navigator
3032  }
3033  SC_MOD()->AnythingChanged();
3034 }
3035 
3036 void ScDocShell::SetInUndo(bool bSet)
3037 {
3038  m_bIsInUndo = bSet;
3039 }
3040 
3042 {
3043  SfxPrinter* pPrinter = GetPrinter();
3044 
3045  m_aDocument.GetDocStat( rDocStat );
3046  rDocStat.nPageCount = 0;
3047 
3048  if ( pPrinter )
3049  for ( SCTAB i=0; i<rDocStat.nTableCount; i++ )
3050  rDocStat.nPageCount = sal::static_int_cast<sal_uInt16>( rDocStat.nPageCount +
3051  static_cast<sal_uInt16>(ScPrintFunc( this, pPrinter, i ).GetTotalPages()) );
3052 }
3053 
3054 std::shared_ptr<SfxDocumentInfoDialog> ScDocShell::CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet)
3055 {
3056  std::shared_ptr<SfxDocumentInfoDialog> xDlg = std::make_shared<SfxDocumentInfoDialog>(pParent, rSet);
3057  ScDocShell* pDocSh = dynamic_cast< ScDocShell *>( SfxObjectShell::Current() );
3058 
3059  // Only for statistics, if this Doc is shown; not from the Doc Manager
3060  if( pDocSh == this )
3061  {
3063  ::CreateTabPage ScDocStatPageCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_STAT);
3064  OSL_ENSURE(ScDocStatPageCreate, "Tabpage create fail!");
3065  xDlg->AddFontTabPage();
3066  xDlg->AddTabPage("calcstats", ScResId(STR_DOC_STAT), ScDocStatPageCreate);
3067  }
3068  return xDlg;
3069 }
3070 
3072 {
3074  if ( pViewSh )
3075  return pViewSh->GetDialogParent();
3077 }
3078 
3079 void ScDocShell::SetSolverSaveData( std::unique_ptr<ScOptSolverSave> pData )
3080 {
3081  m_pSolverSaveData = std::move(pData);
3082 }
3083 
3085 {
3086  if (!m_pSheetSaveData)
3087  m_pSheetSaveData.reset( new ScSheetSaveData );
3088 
3089  return m_pSheetSaveData.get();
3090 }
3091 
3093 {
3094  if (!m_pFormatSaveData)
3095  m_pFormatSaveData.reset( new ScFormatSaveData );
3096 
3097  return m_pFormatSaveData.get();
3098 }
3099 
3100 namespace {
3101 
3102 void removeKeysIfExists(const Reference<ui::XAcceleratorConfiguration>& xScAccel, const vector<const awt::KeyEvent*>& rKeys)
3103 {
3104  for (const awt::KeyEvent* p : rKeys)
3105  {
3106  if (!p)
3107  continue;
3108 
3109  try
3110  {
3111  xScAccel->removeKeyEvent(*p);
3112  }
3113  catch (const container::NoSuchElementException&) {}
3114  }
3115 }
3116 
3117 }
3118 
3120 {
3121  using namespace ::com::sun::star::ui;
3122 
3123  Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
3124  if (!xContext.is())
3125  return;
3126 
3127  Reference<XModuleUIConfigurationManagerSupplier> xModuleCfgSupplier(
3128  theModuleUIConfigurationManagerSupplier::get(xContext) );
3129 
3130  // Grab the Calc configuration.
3131  Reference<XUIConfigurationManager> xConfigMgr =
3132  xModuleCfgSupplier->getUIConfigurationManager(
3133  "com.sun.star.sheet.SpreadsheetDocument");
3134 
3135  if (!xConfigMgr.is())
3136  return;
3137 
3138  // shortcut manager
3139  Reference<XAcceleratorConfiguration> xScAccel = xConfigMgr->getShortCutManager();
3140 
3141  if (!xScAccel.is())
3142  return;
3143 
3144  vector<const awt::KeyEvent*> aKeys;
3145  aKeys.reserve(9);
3146 
3147  // Backspace key
3148  awt::KeyEvent aBackspace;
3149  aBackspace.KeyCode = awt::Key::BACKSPACE;
3150  aBackspace.Modifiers = 0;
3151  aKeys.push_back(&aBackspace);
3152 
3153  // Delete key
3154  awt::KeyEvent aDelete;
3155  aDelete.KeyCode = awt::Key::DELETE;
3156  aDelete.Modifiers = 0;
3157  aKeys.push_back(&aDelete);
3158 
3159  // Ctrl-D
3160  awt::KeyEvent aCtrlD;
3161  aCtrlD.KeyCode = awt::Key::D;
3162  aCtrlD.Modifiers = awt::KeyModifier::MOD1;
3163  aKeys.push_back(&aCtrlD);
3164 
3165  // Alt-Down
3166  awt::KeyEvent aAltDown;
3167  aAltDown.KeyCode = awt::Key::DOWN;
3168  aAltDown.Modifiers = awt::KeyModifier::MOD2;
3169  aKeys.push_back(&aAltDown);
3170 
3171  // Ctrl-Space
3172  awt::KeyEvent aCtrlSpace;
3173  aCtrlSpace.KeyCode = awt::Key::SPACE;
3174  aCtrlSpace.Modifiers = awt::KeyModifier::MOD1;
3175  aKeys.push_back(&aCtrlSpace);
3176 
3177  // Ctrl-Shift-Space
3178  awt::KeyEvent aCtrlShiftSpace;
3179  aCtrlShiftSpace.KeyCode = awt::Key::SPACE;
3180  aCtrlShiftSpace.Modifiers = awt::KeyModifier::MOD1 | awt::KeyModifier::SHIFT;
3181  aKeys.push_back(&aCtrlShiftSpace);
3182 
3183  // F4
3184  awt::KeyEvent aF4;
3185  aF4.KeyCode = awt::Key::F4;
3186  aF4.Modifiers = 0;
3187  aKeys.push_back(&aF4);
3188 
3189  // CTRL+SHIFT+F4
3190  awt::KeyEvent aCtrlShiftF4;
3191  aCtrlShiftF4.KeyCode = awt::Key::F4;
3192  aCtrlShiftF4.Modifiers = awt::KeyModifier::MOD1 | awt::KeyModifier::SHIFT;
3193  aKeys.push_back(&aCtrlShiftF4);
3194 
3195  // SHIFT+F4
3196  awt::KeyEvent aShiftF4;
3197  aShiftF4.KeyCode = awt::Key::F4;
3198  aShiftF4.Modifiers = awt::KeyModifier::SHIFT;
3199  aKeys.push_back(&aShiftF4);
3200 
3201  // Remove all involved keys first, because swapping commands don't work
3202  // well without doing this.
3203  removeKeysIfExists(xScAccel, aKeys);
3204  xScAccel->store();
3205 
3206  switch (eType)
3207  {
3209  xScAccel->setKeyEvent(aDelete, ".uno:ClearContents");
3210  xScAccel->setKeyEvent(aBackspace, ".uno:Delete");
3211  xScAccel->setKeyEvent(aCtrlD, ".uno:FillDown");
3212  xScAccel->setKeyEvent(aAltDown, ".uno:DataSelect");
3213  xScAccel->setKeyEvent(aCtrlSpace, ".uno:SelectColumn");
3214  xScAccel->setKeyEvent(aCtrlShiftSpace, ".uno:SelectAll");
3215  xScAccel->setKeyEvent(aF4, ".uno:ToggleRelative");
3216  xScAccel->setKeyEvent(aCtrlShiftF4, ".uno:ViewDataSourceBrowser");
3217  break;
3219  xScAccel->setKeyEvent(aDelete, ".uno:Delete");
3220  xScAccel->setKeyEvent(aBackspace, ".uno:ClearContents");
3221  xScAccel->setKeyEvent(aCtrlD, ".uno:DataSelect");
3222  xScAccel->setKeyEvent(aCtrlShiftSpace, ".uno:SelectColumn");
3223  xScAccel->setKeyEvent(aF4, ".uno:ViewDataSourceBrowser");
3224  xScAccel->setKeyEvent(aShiftF4, ".uno:ToggleRelative");
3225  break;
3226  default:
3227  ;
3228  }
3229 
3230  xScAccel->store();
3231 }
3232 
3234 {
3235  if (!m_pSheetSaveData)
3236  return;
3237 
3238  m_pSheetSaveData->UseSaveEntries(); // use positions from saved file for next saving
3239 
3240  bool bHasEntries = false;
3241  SCTAB nTabCount = m_aDocument.GetTableCount();
3242  SCTAB nTab;
3243  for (nTab = 0; nTab < nTabCount; ++nTab)
3244  if (m_pSheetSaveData->HasStreamPos(nTab))
3245  bHasEntries = true;
3246 
3247  if (!bHasEntries)
3248  {
3249  // if no positions were set (for example, export to other format),
3250  // reset all "valid" flags
3251  for (nTab = 0; nTab < nTabCount; ++nTab)
3252  m_aDocument.SetStreamValid(nTab, false);
3253  }
3254 }
3255 
3256 // --- ScDocShellModificator ------------------------------------------
3257 
3259  :
3260  rDocShell( rDS ),
3261  mpProtector(new ScRefreshTimerProtector(rDS.GetDocument().GetRefreshTimerControlAddress()))
3262 {
3263  ScDocument& rDoc = rDocShell.GetDocument();
3265  bIdleEnabled = rDoc.IsIdleEnabled();
3266  rDoc.SetAutoCalcShellDisabled( true );
3267  rDoc.EnableIdle(false);
3268 }
3269 
3271 {
3272  ScDocument& rDoc = rDocShell.GetDocument();
3275  rDocShell.SetDocumentModified(); // last one shuts off the lights
3276  rDoc.EnableIdle(bIdleEnabled);
3277 }
3278 
3280 {
3281  ScDocument& rDoc = rDocShell.GetDocument();
3282  rDoc.PrepareFormulaCalc();
3283  if ( !rDoc.IsImportingXML() )
3284  {
3285  // temporarily restore AutoCalcShellDisabled
3286  bool bDisabled = rDoc.IsAutoCalcShellDisabled();
3289  rDoc.SetAutoCalcShellDisabled( bDisabled );
3290  }
3291  else
3292  {
3293  // uno broadcast is necessary for api to work
3294  // -> must also be done during xml import
3295  rDoc.BroadcastUno( SfxHint( SfxHintId::DataChanged ) );
3296  }
3297 }
3298 
3300 {
3301  ScChangeTrack* pChangeTrack = m_aDocument.GetChangeTrack();
3302  return pChangeTrack != nullptr;
3303 }
3304 
3306 {
3307  bool bRes = false;
3308  ScChangeTrack* pChangeTrack = m_aDocument.GetChangeTrack();
3309  if (pChangeTrack)
3310  bRes = pChangeTrack->IsProtected();
3311  return bRes;
3312 }
3313 
3314 void ScDocShell::SetChangeRecording( bool bActivate, bool /*bLockAllViews*/ )
3315 {
3316  bool bOldChangeRecording = IsChangeRecording();
3317 
3318  if (bActivate)
3319  {
3321  ScChangeViewSettings aChangeViewSet;
3322  aChangeViewSet.SetShowChanges(true);
3323  m_aDocument.SetChangeViewSettings(aChangeViewSet);
3324  }
3325  else
3326  {
3328  PostPaintGridAll();
3329  }
3330 
3331  if (bOldChangeRecording != IsChangeRecording())
3332  {
3334  // invalidate slots
3335  SfxBindings* pBindings = GetViewBindings();
3336  if (pBindings)
3337  pBindings->InvalidateAll(false);
3338  }
3339 }
3340 
3341 void ScDocShell::SetProtectionPassword( const OUString &rNewPassword )
3342 {
3343  ScChangeTrack* pChangeTrack = m_aDocument.GetChangeTrack();
3344  if (!pChangeTrack)
3345  return;
3346 
3347  bool bProtected = pChangeTrack->IsProtected();
3348 
3349  if (!rNewPassword.isEmpty())
3350  {
3351  // when password protection is applied change tracking must always be active
3352  SetChangeRecording( true );
3353 
3354  css::uno::Sequence< sal_Int8 > aProtectionHash;
3355  SvPasswordHelper::GetHashPassword( aProtectionHash, rNewPassword );
3356  pChangeTrack->SetProtection( aProtectionHash );
3357  }
3358  else
3359  {
3360  pChangeTrack->SetProtection( css::uno::Sequence< sal_Int8 >() );
3361  }
3362 
3363  if ( bProtected != pChangeTrack->IsProtected() )
3364  {
3367  }
3368 }
3369 
3370 bool ScDocShell::GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash )
3371 {
3372  bool bRes = false;
3373  ScChangeTrack* pChangeTrack = m_aDocument.GetChangeTrack();
3374  if (pChangeTrack && pChangeTrack->IsProtected())
3375  {
3376  rPasswordHash = pChangeTrack->GetProtection();
3377  bRes = true;
3378  }
3379  return bRes;
3380 }
3381 
3383 {
3384  m_bUcalcTest = true;
3385 }
3386 
3387 void ScDocShell::RegisterAutomationWorkbookObject(css::uno::Reference< ooo::vba::excel::XWorkbook > const& xWorkbook)
3388 {
3389  mxAutomationWorkbookObject = xWorkbook;
3390 }
3391 
3392 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportSLK(SvStream &rStream)
3393 {
3394  ScDLL::Init();
3396  ScDocOptions aDocOpt = aDocument.GetDocOptions();
3397  aDocOpt.SetLookUpColRowNames(false);
3398  aDocument.SetDocOptions(aDocOpt);
3399  aDocument.MakeTable(0);
3400  aDocument.EnableExecuteLink(false);
3401  aDocument.SetInsertingFromOtherDoc(true);
3402  aDocument.SetImportingXML(true);
3403 
3404  ScImportExport aImpEx(aDocument);
3405  return aImpEx.ImportStream(rStream, OUString(), SotClipboardFormatId::SYLK);
3406 }
3407 
3408 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDBF(SvStream &rStream)
3409 {
3410  ScDLL::Init();
3411 
3412  // we need a real file for this filter
3413 
3414  // put it in an empty dir
3415  utl::TempFile aTmpDir(nullptr, true);
3416  aTmpDir.EnableKillingFile();
3417  OUString sTmpDir = aTmpDir.GetURL();
3418 
3419  OUString sExtension(".dbf");
3420  utl::TempFile aTempInput(OUString(), true, &sExtension, &sTmpDir);
3421  aTempInput.EnableKillingFile();
3422 
3423  SvStream* pInputStream = aTempInput.GetStream(StreamMode::WRITE);
3424  sal_uInt8 aBuffer[8192];
3425  while (auto nRead = rStream.ReadBytes(aBuffer, SAL_N_ELEMENTS(aBuffer)))
3426  pInputStream->WriteBytes(aBuffer, nRead);
3427  aTempInput.CloseStream();
3428 
3429  SfxMedium aMedium(aTempInput.GetURL(), StreamMode::STD_READWRITE);
3430 
3431  ScDocShellRef xDocShell = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT |
3432  SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS |
3433  SfxModelFlags::DISABLE_DOCUMENT_RECOVERY);
3434 
3435  xDocShell->DoInitNew();
3436 
3437  ScDocument& rDoc = xDocShell->GetDocument();
3438 
3439  ScDocOptions aDocOpt = rDoc.GetDocOptions();
3440  aDocOpt.SetLookUpColRowNames(false);
3441  rDoc.SetDocOptions(aDocOpt);
3442  rDoc.MakeTable(0);
3443  rDoc.EnableExecuteLink(false);
3444  rDoc.SetInsertingFromOtherDoc(true);
3445 
3446  ScDocRowHeightUpdater::TabRanges aRecalcRanges(0, rDoc.MaxRow());
3447  std::map<SCCOL, ScColWidthParam> aColWidthParam;
3448  ErrCode eError = xDocShell->DBaseImport(aMedium.GetPhysicalName(), RTL_TEXTENCODING_IBM_850, aColWidthParam, aRecalcRanges.maRanges);
3449 
3450  xDocShell->DoClose();
3451  xDocShell.clear();
3452 
3453  return eError == ERRCODE_NONE;
3454 }
3455 
3456 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3108
sal_Unicode nFieldSepCode
Definition: imoptdlg.hxx:44
Data stream data needs to be post-processed because it requires ScDocShell instance which is not avai...
SfxViewFrame * GetViewFrame() const
bool bSaveFormulas
Definition: imoptdlg.hxx:52
bool m_bUcalcTest
Definition: docsh.hxx:97
constexpr double nPPTY
virtual void SetVisArea(const tools::Rectangle &rVisArea)
void EnableIdle(bool bDo)
Definition: document.hxx:2131
SvxCellHorJustify
OUString GetText(LineEnd eEnd=LINEEND_LF) const
bool HasExternalRefManager() const
Definition: document.hxx:1002
SVL_DLLPUBLIC bool IsDocument(const OUString &rURL)
URL aURL
virtual HiddenInformation GetHiddenInformationState(HiddenInformation nStates) override
Definition: docsh.cxx:227
static OUString GetOwnFilterName()
Definition: docsh.cxx:2799
sal_Int32 nIndex
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
Definition: document.hxx:814
OUString getString() const
double GetPPTY() const
Definition: sizedev.hxx:42
ScAddress aStart
Definition: address.hxx:499
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:353
void EndChangeTracking()
Definition: documen2.cxx:270
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1914
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:42
void SetExtOptions(const ScAsciiOptions &rOpt)
Definition: impex.cxx:201
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
Definition: docsh3.cxx:451
const sc::ImportPostProcessData & GetImportPostProcessData() const
Definition: xmlwrap.hxx:91
static void GetInputString(const ScRefCellValue &rCell, sal_uInt32 nFormat, OUString &rString, SvNumberFormatter &rFormatter, const ScDocument &rDoc, bool bFiltering=false)
Definition: cellform.cxx:119
ScRefCellValue * GetNext(SCCOL &rCol, SCROW &rRow)
Definition: dociter.cxx:2132
#define SFX_IMPL_INTERFACE(Class, SuperClass)
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:89
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
bool IsInInterpreter() const
Definition: document.hxx:2323
SC_DLLPUBLIC size_t GetCount() const
Definition: dpobject.cxx:3675
Collection of orcus filter wrappers.
ScriptDocument aDocument
SCROW Row() const
Definition: address.hxx:261
#define SCWARN_EXPORT_NONCONVERTIBLE_CHARS
Definition: scerrors.hxx:69
std::unique_ptr< ScDBData > m_pOldAutoDBRange
Definition: docsh.hxx:102
virtual ErrCode ScImportRTF(SvStream &, const OUString &rBaseURL, ScDocument *, ScRange &rRange)=0
void PostPaintGridAll()
Definition: docsh3.cxx:183
#define ERRCODE_IO_ABORT
std::unique_ptr< ScRefreshTimerControl > const & GetRefreshTimerControlAddress() const
Definition: document.hxx:2431
SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings &rNew)
Definition: documen2.cxx:1114
virtual bool Load(SfxMedium &rMedium)
bool HasSharedXMLFlagSet() const
void RegisterAutomationWorkbookObject(css::uno::Reference< ooo::vba::excel::XWorkbook > const &xWorkbook)
Definition: docsh.cxx:3387
SfxObjectShell * GetObjectShell() const
bool HasAddError() const
Definition: detdata.hxx:78
ScFormatSaveData * GetFormatSaveData()
Definition: docsh.cxx:3092
std::string GetValue
const css::uno::Reference< css::script::vba::XVBAEventProcessor > & GetVbaEventProcessor() const
Definition: document.hxx:2448
static weld::Window * GetActiveDialogParent()
Definition: docsh.cxx:3071
SAL_DLLPUBLIC_EXPORT bool TestImportSLK(SvStream &rStream)
Definition: docsh.cxx:3392
int SetError()
SfxBindings * GetViewBindings()
Definition: docsh4.cxx:2613
OUString GetStandardText(StandardButtonType eButton)
double m_nPrtToScreenFactor
Definition: docsh.hxx:86
bool Import(ImportFlags nMode, ErrCode &rError)
Definition: xmlwrap.cxx:286
void SetProtection(const css::uno::Sequence< sal_Int8 > &rPass)
Definition: chgtrack.hxx:1128
RET_RETRY
virtual void SetModified(bool bModified=true)
void GetFormula(OUString &rFormula, const formula::FormulaGrammar::Grammar=formula::FormulaGrammar::GRAM_DEFAULT, const ScInterpreterContext *pContext=nullptr) const
ScDetOpList * GetDetOpList() const
Definition: document.hxx:1776
css::uno::Reference< css::datatransfer::XTransferable2 > const & GetClipData() const
Definition: docsh.hxx:224
virtual ErrCode ScImportExcel(SfxMedium &, ScDocument *, const EXCIMPFORMAT)=0
const OUString & GetName() const
Do things that need to be done before saving to our own format and necessary clean ups in dtor...
Definition: docsh.hxx:125
static OUString GetAsciiFilterName()
Definition: docsh.cxx:2814
sal_Int32 toInt32(OUString const &rStr)
sal_Int64 n
void CloseStream()
virtual std::shared_ptr< SfxDocumentInfoDialog > CreateDocumentInfoDialog(weld::Window *pParent, const SfxItemSet &rSet) override
Definition: docsh.cxx:3054
ScDocShell & rDocShell
Definition: docsh.hxx:458
void SetStateOnPercent(sal_uLong nVal)
Definition: progress.hxx:96
void setAllCacheTableReferencedStati(bool bReferenced)
ScDocShell(const ScDocShell &rDocShell)=delete
virtual bool importODS(ScDocument &rDoc, SfxMedium &rMedium) const =0
normal calculation of dependencies
aBuf
static SVL_DLLPUBLIC void GetHashPassword(css::uno::Sequence< sal_Int8 > &rPassHash, const char *pPass, sal_uInt32 nLen)
const char pFilterEx5Temp[]
Definition: docsh.cxx:154
void SetDocumentModified()
Definition: docsh.cxx:2941
Stores data imported from the file that need to be processed at the end of the import process...
constexpr OUStringLiteral pFilterDBase
Definition: docsh.cxx:159
#define SCWARN_IMPORT_RANGE_OVERFLOW
Definition: scerrors.hxx:61
void SetSolverSaveData(std::unique_ptr< ScOptSolverSave > pData)
Definition: docsh.cxx:3079
bool m_bUpdateEnabled
Definition: docsh.hxx:96
sal_uInt64 Seek(sal_uInt64 nPos)
bool ExecuteRetypePassDlg(ScPasswordHash eDesiredHash)
Definition: tabvwshh.cxx:247
static SC_DLLPUBLIC ScFormatFilterPlugin & Get()
Definition: impex.cxx:2455
SAL_DLLPRIVATE void DoEnterHandler()
Definition: docsh.cxx:208
SC_DLLPUBLIC void GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt32 &rFormat) const
Definition: document.cxx:3672
virtual bool SaveAs(SfxMedium &rMedium)
static OUString GetHtmlFilterName()
Definition: docsh.cxx:2804
ScAddress aEnd
Definition: address.hxx:500
Extended options held by an ScDocument containing additional settings for filters.
Definition: scextopt.hxx:76
virtual std::set< Color > GetDocColors() override
Definition: docsh.cxx:203
static SfxObjectShell * Current()
bool m_bAreasChangedNeedBroadcast
Definition: docsh.hxx:98
bool setExtension(std::u16string_view rTheExtension, sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:103
constexpr TypedWhichId< ScProtectionAttr > ATTR_PROTECTION(149)
#define SC_TAB_INSERTED
Definition: uiitems.hxx:75
const char pFilterQPro6[]
Definition: docsh.cxx:150
const char pFilterXML[]
Definition: docsh.cxx:147
static OUString GetCharsetString(rtl_TextEncoding eVal)
Definition: global.cxx:584
void Invalidate(sal_uInt16 nId)
sc::DocumentLinkManager & GetDocLinkManager()
Definition: documen2.cxx:228
SC_DLLPUBLIC SfxUndoManager * GetUndoManager()
Definition: document.cxx:6402
virtual bool importODS_Styles(ScDocument &rDoc, OUString &aFileName) const =0
Used to import just the styles from an xml file.
bool IsInPrepareClose() const
SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative(OUString const &baseUriReference, OUString const &uriReference)
static OUString GetWebQueryFilterName()
Definition: docsh.cxx:2809
RET_CANCEL
bool ImportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
Definition: impex.cxx:379
OUString CutExtension()
SfxHintId GetId() const
ErrCode GetError() const
bool bSaveNumberAsSuch
Definition: imoptdlg.hxx:51
~PrepareSaveGuard() COVERITY_NOEXCEPT_FALSE
Definition: docsh.cxx:1702
~ScDocShellModificator() COVERITY_NOEXCEPT_FALSE
Definition: docsh.cxx:3270
virtual bool ConvertTo(SfxMedium &rMedium) override
Definition: docsh.cxx:2336
SfxApplication * SfxGetpApp()
virtual ScOrcusFilters * GetOrcusFilters()=0
virtual bool HasChangeRecordProtection() const override
Definition: docsh.cxx:3305
const char pFilterEx95Temp[]
Definition: docsh.cxx:156
PrepareSaveGuard(ScDocShell &rDocShell)
Definition: docsh.cxx:1678
constexpr OUStringLiteral pFilterHtmlWebQ
Definition: docsh.cxx:163
size_t Count() const
Definition: detdata.hxx:79
void InvalidateTableArea()
Definition: documen4.cxx:578
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2927
RET_NO
OUString CreateNewName() const
Create a new name that's not yet used by any existing data pilot objects.
Definition: dpobject.cxx:3701
virtual bool PrepareClose(bool bUI=true)
void SetCharSet(rtl_TextEncoding eNew)
Definition: asciiopt.hxx:72
SC_DLLPUBLIC void SetImportingXML(bool bVal)
Definition: documen9.cxx:592
bool IsStorage()
sal_uInt16 sal_Unicode
constexpr OUStringLiteral pFilterHtml
Definition: docsh.cxx:162
bool ShowChanges() const
Definition: chgviset.hxx:77
void SetRefreshOnEmptyLine(bool bVal)
Definition: datastream.cxx:404
virtual void ScExportDif(SvStream &, ScDocument *, const ScAddress &rOutPos, const rtl_TextEncoding eDest)=0
Reference< XController > xController
RET_YES
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
const EditTextObject * mpEditText
Definition: cellvalue.hxx:109
static void ResetKeyBindings(ScOptionsUtil::KeyBindingType eType)
Definition: docsh.cxx:3119
static weld::Window * GetDefDialogParent()
void SetText(const OUString &rStr)
void InvalidateStyleSheetUsage()
Definition: document.hxx:2442
virtual ~ScDocShell() override
Definition: docsh.cxx:2893
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:872
virtual bool Save()
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:314
FormulaError GetErrCode()
SfxFrame & GetFrame() const
int nCount
virtual bool SaveAs(SfxMedium &rMedium) override
Definition: docsh.cxx:1758
std::unique_ptr< ScPaintLockData > m_pPaintLockData
Definition: docsh.hxx:105
virtual ErrCode ScImportLotus123(SfxMedium &, ScDocument &, rtl_TextEncoding eSrc)=0
bool IsOverflowCol() const
Definition: impex.hxx:149
void SetLookUpColRowNames(bool bVal)
Definition: docoptio.hxx:52
const OUString & GetPhysicalName() const
SC_DLLPUBLIC ScExternalRefManager * GetExternalRefManager() const
Definition: documen3.cxx:623
bool IsAutoCalcShellDisabled() const
Definition: document.hxx:1363
SvStream * GetOutStream()
UpdateLinks
std::unique_ptr< ScDocFunc > m_pDocFunc
Definition: docsh.hxx:88
const SfxPoolItem * ExecuteSynchron(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr)
const char16_t pFilterExcel4[]
Definition: docsh.cxx:151
bool DetectiveRefresh(bool bAutomatic=false)
Definition: docfunc.cxx:465
ScFormulaCell * mpFormula
Definition: cellvalue.hxx:110
void SetRow(SCROW nRowP)
Definition: address.hxx:274
SAL_DLLPRIVATE void UseSheetSaveEntries()
Definition: docsh.cxx:3233
static std::shared_ptr< ConfigurationChanges > create(css::uno::Reference< css::uno::XComponentContext > const &context=comphelper::getProcessComponentContext())
std::unique_ptr< DataStream > mpDataStream
static void lcl_parseHtmlFilterOption(const OUString &rOption, LanguageType &rLang, bool &rDateConvert)
Definition: docsh.cxx:1093
SotClipboardFormatId
virtual bool Load(SfxMedium &rMedium) override
Definition: docsh.cxx:569
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
const OUString & GetName() const
void SetRefreshHandler(const Link< Timer *, void > &rLink)
Definition: dbdata.hxx:336
SfxObjectCreateMode GetCreateMode() const
#define SO3_SC_CLASSID_60
void PrepareFormulaCalc()
Call this before any operations that might trigger one or more formula cells to get calculated...
Definition: document.cxx:2464
void SetClipData(const css::uno::Reference< css::datatransfer::XTransferable2 > &xTransferable)
Definition: docsh.hxx:225
sal_Int32 nSheetToExport
Definition: imoptdlg.hxx:57
const sal_Unicode cDelim
Definition: unitconv.cxx:29
void SetCol(SCCOL nColP)
Definition: address.hxx:278
virtual bool LoadFrom(SfxMedium &rMedium) override
Definition: docsh.cxx:1072
SfxUndoManager * mpUndoManager
Definition: document.hxx:365
void MarkUsedExternalReferences()
Definition: documen3.cxx:637
virtual bool importExcel2003XML(ScDocument &rDoc, SfxMedium &rMedium) const =0
ScViewData & GetViewData()
Definition: tabview.hxx:333
static ScDocument * GetClipDoc()
Definition: scmod.cxx:616
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2405
#define SCWARN_EXPORT_ASCII
Definition: scerrors.hxx:71
bool m_bIsInUndo
Definition: docsh.hxx:94
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4745
bool IsDocumentModifiedPending() const
Definition: docsh.hxx:381
const css::uno::Sequence< sal_Int8 > & GetProtection() const
Definition: chgtrack.hxx:1130
SfxItemPool & GetPool() const
void SetInsertingFromOtherDoc(bool bVal)
Definition: document.hxx:2146
#define SCWARN_IMPORT_CELL_OVERFLOW
Definition: scerrors.hxx:65
void SetError(ErrCode nError)
bool IsProtected() const
Definition: chgtrack.hxx:1132
OutputDevice * GetDevice() const
Definition: sizedev.hxx:40
void SetIsInUcalc()
Definition: docsh.cxx:3382
SC_DLLPUBLIC bool GetCellArea(SCTAB nTab, SCCOL &rEndCol, SCROW &rEndRow) const
Definition: document.cxx:1010
constexpr OUStringLiteral aData
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true) override
Definition: docsh.cxx:2699
#define SAL_N_ELEMENTS(arr)
void SetName(const OUString &rNew)
Definition: dpobject.cxx:490
DocumentType eType
ScSheetSaveData * GetSheetSaveData()
Definition: docsh.cxx:3084
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1947
static bool HasAutomaticTableName(std::u16string_view rFilter)
Definition: docsh.cxx:2834
constexpr double nPPTX
bool GetHideCell() const
Definition: attrib.hxx:147
bool IsModified() const
#define SCERR_IMPORT_NI
Definition: scerrors.hxx:35
void InvalidateStreamOnSave()
Definition: document.cxx:495
sal_Unicode nTextSepCode
Definition: imoptdlg.hxx:45
void SetMarkArea(const ScRange &rRange)
Definition: markdata.cxx:96
bool m_bIsEmpty
Definition: docsh.hxx:93
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:441
#define SOFFICE_FILEFORMAT_60
std::unique_ptr< ScAutoStyleList > m_pAutoStyleList
Definition: docsh.hxx:104
bool IsChartListenerCollectionNeedsUpdate() const
Definition: document.hxx:2162
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define ERRCODE_IO_CANTCREATE
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
bool IsImportingXML() const
Definition: document.hxx:2150
void EnableExecuteLink(bool bVal)
Definition: document.hxx:1543
void CloseOutStream()
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define ERRCODE_IO_GENERAL
static SAL_DLLPRIVATE bool MoveFile(const INetURLObject &rSource, const INetURLObject &rDest)
Definition: docsh8.cxx:141
virtual bool importGnumeric(ScDocument &rDoc, SfxMedium &rMedium) const =0
void SetFormulas(bool b)
Definition: impex.hxx:132
int i
static OUString getProductName()
OUStringBuffer & truncateToLength(OUStringBuffer &rBuffer, sal_Int32 nLength)
OUString const & GetURL() const
static SAL_DLLPRIVATE bool KillFile(const INetURLObject &rURL)
Definition: docsh8.cxx:185
#define LANGUAGE_SYSTEM
const svl::SharedString * mpString
Definition: cellvalue.hxx:108
static OUString GetLotusFilterName()
Definition: docsh.cxx:2819
std::unique_ptr< ScDocShellModificator, o3tl::default_delete< ScDocShellModificator > > m_pModificator
Definition: docsh.hxx:110
sal_Int16 SCCOL
Definition: types.hxx:21
SAL_DLLPRIVATE SCTAB GetSaveTab()
Definition: docsh.cxx:215
static SC_DLLPUBLIC void Init()
DLL-init/exit-code must be linked to the DLL only.
Definition: scdll.cxx:99
SAL_DLLPRIVATE void ResetDrawObjectShell()
Definition: docsh2.cxx:162
constexpr OUStringLiteral pFilterLotus
Definition: docsh.cxx:149
static SC_DLLPUBLIC double nScreenPPTY
Vertical pixel per twips factor.
Definition: global.hxx:584
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
sal_uInt16 m_nDocumentLock
Definition: docsh.hxx:99
#define SC_MOD()
Definition: scmod.hxx:250
bool IsTextFormat(sal_uInt32 nFIndex) const
bool GetHideFormula() const
Definition: attrib.hxx:145
bool IsForcedFormulaPending() const
Definition: document.hxx:1366
virtual bool LoadFrom(SfxMedium &rMedium)
const OUString & GetValue() const
void RemoveDdeTopic(SfxObjectShell const *)
::tools::Long nLastColWidthExtra
Definition: global.hxx:592
const OUString & GetName() const
Definition: dpobject.hxx:167
const char pFilterExcel95[]
Definition: docsh.cxx:155
#define SCERR_EXPORT_DATA
Definition: scerrors.hxx:53
void SetPool(SfxItemPool *pNewPool)
std::size_t WriteBytes(const void *pData, std::size_t nSize)
virtual bool PrepareClose(bool bUI=true) override
Definition: docsh.cxx:2746
bool hasExternalData() const
float u
bool IsDetectiveDirty() const
Definition: document.hxx:2133
virtual bool Save() override
Definition: docsh.cxx:1715
OUString GetBaseURL(bool bForSaving=false)
#define BCA_BRDCST_ALWAYS
Definition: address.hxx:950
std::unique_ptr< weld::CheckButton > m_xWarningOnBox
constexpr OUStringLiteral pFilterDif
Definition: docsh.cxx:160
void StartWritingUnicodeText()
virtual ErrCode ScExportExcel5(SfxMedium &, ScDocument *, ExportFormatExcel eFormat, rtl_TextEncoding eDest)=0
virtual ErrCode ScImportQuattroPro(SvStream *pStream, ScDocument &rDoc)=0
SfxItemSet * GetItemSet() const
void BroadcastUno(const SfxHint &rHint)
Definition: documen3.cxx:949
SCTAB nTableCount
Definition: document.hxx:278
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
virtual bool LoadExternal(SfxMedium &rMedium) override
Definition: docsh.cxx:1637
sal_Int16 m_nCanUpdate
Definition: docsh.hxx:100
SvStream & endlub(SvStream &rStrm)
SAL_DLLPRIVATE ErrCode DBaseExport(const OUString &rFullFileName, rtl_TextEncoding eCharSet, bool &bHasMemo)
Definition: docsh8.cxx:730
bool GetShowSharedDocumentWarning() const
Definition: appoptio.hxx:76
virtual ErrCode ScImportHTML(SvStream &, const OUString &rBaseURL, ScDocument *, ScRange &rRange, double nOutputFactor, bool bCalcWidthHeight, SvNumberFormatter *pFormatter, bool bConvertDate)=0
virtual HiddenInformation GetHiddenInformationState(HiddenInformation nStates)
const css::uno::Sequence< css::beans::PropertyValue > & GetArgs() const
bool ExportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
Definition: impex.cxx:419
const char pFilterEx97Temp[]
Definition: docsh.cxx:158
bool IsValid() const
Definition: address.hxx:546
void Broadcast(const ScHint &rHint)
Broadcast wrapper, calls rHint.GetCell()->Broadcast() and AreaBroadcast() and TrackFormulas() Preferr...
Definition: documen7.cxx:117
void SetShowSharedDocumentWarning(bool bNew)
Definition: appoptio.hxx:75
void GrabFocus()
void SetFieldSeps(const OUString &rStr)
Definition: asciiopt.hxx:75
const std::shared_ptr< const SfxFilter > & GetFilter() const
void PostDataChanged()
Definition: docsh3.cxx:93
bool m_bFooterOn
Definition: docsh.hxx:91
SfxViewShell * GetViewShell() const
#define SCERR_IMPORT_UNKNOWN
Definition: scerrors.hxx:27
sal_uInt16 nPageCount
Definition: document.hxx:281
SAL_DLLPRIVATE std::unique_ptr< ScDocFunc > CreateDocFunc()
Definition: docsh.cxx:2850
virtual bool IsChangeRecording() const override
Definition: docsh.cxx:3299
const svl::SharedString & GetString()
virtual void TerminateEditing() override
Definition: docsh.cxx:1752
FormulaError
ScDBFunc * GetView() const
Definition: viewdata.cxx:861
std::size_t ReadBytes(void *pData, std::size_t nSize)
virtual bool GetProtectionHash(css::uno::Sequence< sal_Int8 > &rPasswordHash) override
Definition: docsh.cxx:3370
ExportFormatExcel
Definition: filter.hxx:42
const char pFilterExcel5[]
Definition: docsh.cxx:153
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
const char16_t pFilterRtf[]
Definition: docsh.cxx:164
CellType meType
Definition: cellvalue.hxx:105
SvStreamEndian GetEndian() const
void SetShowAccepted(bool bVal)
Definition: chgviset.hxx:113
constexpr OUStringLiteral pFilterSc50
Definition: docsh.cxx:146
std::unique_ptr< ScOptSolverSave > m_pSolverSaveData
Definition: docsh.hxx:106
void SetInUndo(bool bSet)
Definition: docsh.cxx:3036
SvStream * GetInStream()
sal_Int32 SCROW
Definition: types.hxx:17
void StopTemporaryChartLock()
Definition: documen3.cxx:406
const OUString & GetNonConvertibleChars() const
Definition: impex.hxx:153
std::unique_ptr< ScSheetSaveData > m_pSheetSaveData
Definition: docsh.hxx:107
std::unique_ptr< char[]> aBuffer
void SetStreamValid(SCTAB nTab, bool bSet, bool bIgnoreLock=false)
Definition: document.cxx:925
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
Definition: documen3.cxx:1953
SFX_IMPL_OBJECTFACTORY(DrawDocShell, SvGlobalName(SO3_SIMPRESS_CLASSID),"simpress") void DrawDocShell
static ScTabViewShell * GetActiveViewShell()
Definition: tabvwsh4.cxx:1038
sal_uInt16 GetTablesHintId() const
Definition: uiitems.hxx:93
bool IsOverflowRow() const
Definition: impex.hxx:148
exports com.sun.star. document
virtual bool ConvertFrom(SfxMedium &rMedium) override
Definition: docsh.cxx:1123
Any makeAny(Color const &value)
SfxEventHintId GetEventId() const
std::unique_ptr< ScFormatSaveData > m_pFormatSaveData
Definition: docsh.hxx:108
static SC_DLLPUBLIC OUString GetDocTabName(std::u16string_view rFileName, std::u16string_view rTabName)
Definition: global2.cxx:322
static SAL_DLLPRIVATE bool IsDocument(const INetURLObject &rURL)
Definition: docsh8.cxx:204
#define ERRCODE_NONE
void ReadFromString(const OUString &rString)
Definition: asciiopt.cxx:86
unsigned char sal_uInt8
bool bQuoteAllText
Definition: imoptdlg.hxx:50
bool IsOverflowCell() const
Definition: impex.hxx:150
void SetStreamPath(const OUString &rPath)
Definition: impex.hxx:135
CellType
Definition: global.hxx:281
EXCIMPFORMAT
Definition: filter.hxx:39
#define SCERR_IMPORT_CONNECT
Definition: scerrors.hxx:25
void AfterXMLLoading(bool bRet)
Definition: docsh.cxx:269
#define SCWARN_IMPORT_ROW_OVERFLOW
Definition: scerrors.hxx:62
void SetEndian(SvStreamEndian SvStreamEndian)
css::uno::Reference< css::frame::XController > GetController() const
OUString aName
SCTAB GetFirstSelected() const
Definition: markdata.cxx:199
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
Definition: scabstdlg.cxx:37
SfxEventHintId
SfxModelFlags
virtual LockFileEntry GetLockData() override
int GetError()
ScExtDocOptions * GetExtDocOptions()
Definition: document.hxx:631
bool m_bHeaderOn
Definition: docsh.hxx:90
void UpdateAcceptChangesDialog()
Definition: docsh4.cxx:1371
#define SC_TEXT_CSV_FILTER_NAME
Definition: global.hxx:61
void SetDetectiveDirty(bool bSet)
Definition: document.hxx:2134
void SetStreamCharSet(rtl_TextEncoding eCharSet)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
#define SVSTREAM_FILEFORMAT_ERROR
SAL_DLLPRIVATE bool SaveXML(SfxMedium *pMedium, const css::uno::Reference< css::embed::XStorage > &)
Definition: docsh.cxx:553
void InvalidateLastTableOpParams()
Definition: document.hxx:2364
rtl_TextEncoding GetCharSet() const
Definition: asciiopt.hxx:56
rtl_TextEncoding GetStreamCharSet() const
const char16_t pFilterSylk[]
Definition: docsh.cxx:161
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
const INetURLObject & GetURLObject() const
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
bool IsWarning() const
static OUString GetDBaseFilterName()
Definition: docsh.cxx:2824
std::unique_ptr< DocShell_Impl > m_pImpl
Definition: docsh.hxx:87
void * p
Reference< XComponentContext > getProcessComponentContext()
SC_DLLPUBLIC ScChartListenerCollection * GetChartListenerCollection() const
Definition: document.hxx:2156
static SC_DLLPUBLIC double nScreenPPTX
Horizontal pixel per twips factor.
Definition: global.hxx:582
bool needsPassHashRegen(const ScDocument &rDoc, ScPasswordHash eHash1, ScPasswordHash eHash2=PASSHASH_UNSPECIFIED)
Check for the compatibility of all password hashes.
void SetAutoCalcShellDisabled(bool bNew)
Definition: document.hxx:1362
bool Append(std::u16string_view rTheSegment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
ScRecalcOptions
Definition: calcconfig.hxx:23
void ErrorMessage(TranslateId pGlobStrId)
Definition: docsh5.cxx:70
SC_DLLPUBLIC void UpdateChartListenerCollection()
Definition: documen5.cxx:570
css::uno::Reference< ooo::vba::excel::XWorkbook > mxAutomationWorkbookObject
Definition: docsh.hxx:112
vcl::Window * GetWindow() const
#define SCWARN_IMPORT_COLUMN_OVERFLOW
Definition: scerrors.hxx:63
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6092
static rtl_TextEncoding GetCharsetValue(const OUString &rCharSet)
Definition: global.cxx:556
virtual void SetProtectionPassword(const OUString &rPassword) override
Definition: docsh.cxx:3341
ScDocShellModificator(const ScDocShellModificator &)=delete
void ClosingClipboardSource()
To be called at the clipboard document when closing a document that is the current clipboard source t...
Definition: documen2.cxx:319
SAL_DLLPRIVATE bool LoadXML(SfxMedium *pMedium, const css::uno::Reference< css::embed::XStorage > &)
Definition: docsh.cxx:468
static const sal_Unicode * UnicodeStrChr(const sal_Unicode *pStr, sal_Unicode c)
strchr() functionality on unicode, as long as we need it for FormulaToken etc.
Definition: global.cxx:643
bool IsEnableSetModified() const
void SetDocumentModified()
Definition: docsh.cxx:3279
SAL_DLLPUBLIC_EXPORT bool TestImportDBF(SvStream &rStream)
Definition: docsh.cxx:3408
bool IsInUndo() const
Definition: docsh.hxx:354
virtual ErrCode ScImportDif(SvStream &, ScDocument *, const ScAddress &rInsPos, const rtl_TextEncoding eSrc)=0
ScDocument m_aDocument
Definition: docsh.hxx:82
#define SC_COMPILER_FILE_TAB_SEP
Definition: compiler.hxx:82
ErrCode GetError() const
bool IsInLinkUpdate() const
Definition: documen8.cxx:786
static void CreateAndSet(ScDocShell *pDocSh)
create ScModelObj and set at pDocSh (SetBaseModel)
Definition: docuno.cxx:373
#define ERRCODE_ABORT
virtual bool QuerySlotExecutable(sal_uInt16 nSlotId) override
Definition: docsh.cxx:2708
OUString BuildString() const
Definition: imoptdlg.cxx:98
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
virtual void SetModified(bool=true) override
Definition: docsh.cxx:2932
void GetDocStat(ScDocStat &rDocStat)
Definition: docsh.cxx:3041
void InvalidateAll(bool bWithMsg)
virtual bool importXLSX(ScDocument &rDoc, SfxMedium &rMedium) const =0
bool m_bDocumentModifiedPending
Definition: docsh.hxx:95
#define SAL_WARN(area, stream)
Reference< XSingleServiceFactory > xFactory
OUString m_aDdeTextFmt
Definition: docsh.hxx:84
rtl_TextEncoding eCharSet
Definition: imoptdlg.hxx:47
Reference< XModel > xModel
SvStreamEndian
void(* f)(TrueTypeTable *)
void SetDrawModified()
SetDrawModified - without Formula update.
Definition: docsh.cxx:3005
void setDataStream(DataStream *p)
static void GetString(const ScRefCellValue &rCell, sal_uInt32 nFormat, OUString &rString, const Color **ppColor, SvNumberFormatter &rFormatter, const ScDocument &rDoc, bool bNullVals=true, bool bFormula=false, bool bUseStarFormat=false)
Definition: cellform.cxx:32
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:222
constexpr OUStringLiteral pFilterAscii
Definition: docsh.cxx:148
SC_DLLPUBLIC void MakeTable(SCTAB nTab, bool _bNeedsNameCheck=true)
Definition: document.cxx:168
ScTabViewShell * GetBestViewShell(bool bOnlyVisible=true)
Definition: docsh4.cxx:2594
bool m_bIsInplace
Definition: docsh.hxx:92
void StartChangeTracking()
Definition: documen2.cxx:264
void SetDocumentModifiedPending(bool bVal)
Definition: docsh.hxx:379
SC_DLLPUBLIC void SetExtDocOptions(std::unique_ptr< ScExtDocOptions > pNewOptions)
Definition: documen3.cxx:2029
void SetFilterOptions(const OUString &rFilterOptions)
Definition: impex.cxx:214
SvStream * GetStream(StreamMode eMode)
void UpdateLayerLocks()
Definition: tabview5.cxx:357
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4151
virtual void SetChangeRecording(bool bActivate, bool bLockAllViews=false) override
Definition: docsh.cxx:3314
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
bool Export(bool bStylesOnly)
Definition: xmlwrap.cxx:721
HiddenInformation
const DdeService * GetDdeService() const
bool IsIdleEnabled() const
Definition: document.hxx:2130
bool WriteUniOrByteChar(sal_Unicode ch, rtl_TextEncoding eDestCharSet)
static bool WarningOnPassword(SfxMedium &rMedium)
Opens a query warning dialog.
const char16_t pFilterEx4Temp[]
Definition: docsh.cxx:152
bool WriteUnicodeOrByteText(std::u16string_view rStr, rtl_TextEncoding eDestCharSet)
sal_Int32 nState
void RefreshDirtyTableColumnNames()
Definition: documen3.cxx:354
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:213
double GetPPTX() const
Definition: sizedev.hxx:41
void GetDocStat(ScDocStat &rDocStat)
Definition: document.cxx:6268
virtual bool importCSV(ScDocument &rDoc, SfxMedium &rMedium) const =0
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: docsh.cxx:641
void SetTextSep(sal_Unicode c)
Definition: asciiopt.hxx:82
weld::Window * GetDialogParent()
parent window for dialogs Problem: OLE Server!
Definition: tabvwshd.cxx:31
void SetError(ErrCode rErr)
static OUString GetErrorString(FormulaError nErrNumber)
Definition: global.cxx:303
void EnableKillingFile(bool bEnable=true)
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
Definition: documen2.cxx:457
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:456
const char pFilterExcel97[]
Definition: docsh.cxx:157
#define SOFFICE_FILEFORMAT_8
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:22
void SetODFRecalcOptions(ScRecalcOptions eOpt)
Definition: formulaopt.hxx:64
bool bAutoCalcShellDisabled
Definition: docsh.hxx:460
SC_DLLPUBLIC bool GetAutoCalc() const
Definition: document.hxx:1360
std::size_t write_uInt16s_FromOUString(SvStream &rStrm, std::u16string_view rStr, std::size_t nUnits)
static OUString GetDifFilterName()
Definition: docsh.cxx:2829
SCTAB GetTab1() const
Definition: uiitems.hxx:94
void SetShowChanges(bool bFlag)
Definition: chgviset.hxx:78
OStringBuffer & padToLength(OStringBuffer &rBuffer, sal_Int32 nLength, char cFill= '\0')
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
SfxMedium * GetMedium() const
void AsciiSave(SvStream &rStream, const ScImportOptions &rOpt, SCTAB nTab)
Definition: docsh.cxx:1914
void BeforeXMLLoading()
Definition: docsh.cxx:254