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>
30 #include <formula/errorcodes.hxx>
31 #include <vcl/stdtext.hxx>
32 #include <vcl/svapp.hxx>
33 #include <vcl/virdev.hxx>
34 #include <vcl/weld.hxx>
35 #include <rtl/bootstrap.hxx>
36 #include <rtl/tencinfo.h>
37 #include <sal/log.hxx>
38 #include <svl/PasswordHelper.hxx>
39 #include <sfx2/app.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <sfx2/dinfdlg.hxx>
42 #include <sfx2/docfile.hxx>
43 #include <sfx2/event.hxx>
44 #include <sfx2/docfilt.hxx>
45 #include <sfx2/objface.hxx>
46 #include <sfx2/viewfrm.hxx>
47 #include <svl/documentlockfile.hxx>
48 #include <svl/fstathelper.hxx>
49 #include <svl/sharecontrolfile.hxx>
50 #include <svl/urihelper.hxx>
51 #include <osl/file.hxx>
52 #include <chgtrack.hxx>
53 #include <chgviset.hxx>
54 #include <com/sun/star/awt/Key.hpp>
55 #include <com/sun/star/awt/KeyModifier.hpp>
56 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
57 #include <com/sun/star/document/UpdateDocMode.hpp>
58 #include <com/sun/star/script/vba/VBAEventId.hpp>
59 #include <com/sun/star/script/vba/VBAScriptEventId.hpp>
60 #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
61 #include <com/sun/star/script/vba/XVBAScriptListener.hpp>
62 #include <com/sun/star/script/vba/XVBACompatibility.hpp>
63 #include <com/sun/star/sheet/XSpreadsheetView.hpp>
64 #include <com/sun/star/task/XJob.hpp>
65 #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
66 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
67 #include <com/sun/star/util/VetoException.hpp>
68 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
69 #include <ooo/vba/excel/XWorkbook.hpp>
70 #include <tools/diagnose_ex.h>
71 
72 #include <config_folders.h>
73 
74 #include <scabstdlg.hxx>
75 #include <sot/formats.hxx>
76 #include <svx/dialogs.hrc>
77 
78 #include <formulacell.hxx>
79 #include <global.hxx>
80 #include <filter.hxx>
81 #include <scmod.hxx>
82 #include <tabvwsh.hxx>
83 #include <docfunc.hxx>
84 #include <imoptdlg.hxx>
85 #include <impex.hxx>
86 #include <scresid.hxx>
87 #include <strings.hrc>
88 #include <globstr.hrc>
89 #include <scerrors.hxx>
90 #include <brdcst.hxx>
91 #include <stlpool.hxx>
92 #include <autostyl.hxx>
93 #include <attrib.hxx>
94 #include <asciiopt.hxx>
95 #include <progress.hxx>
96 #include <pntlock.hxx>
97 #include <docuno.hxx>
98 #include <appoptio.hxx>
99 #include <formulaopt.hxx>
100 #include <scdll.hxx>
101 #include <detdata.hxx>
102 #include <printfun.hxx>
103 #include <dociter.hxx>
104 #include <cellform.hxx>
105 #include <chartlis.hxx>
106 #include <hints.hxx>
107 #include <xmlwrap.hxx>
108 #include <drwlayer.hxx>
109 #include <dbdata.hxx>
110 #include <scextopt.hxx>
111 #include <compiler.hxx>
112 #include <warnpassword.hxx>
113 #include <optsolver.hxx>
114 #include <sheetdata.hxx>
115 #include <tabprotection.hxx>
116 #include <docparam.hxx>
117 #include "docshimp.hxx"
118 #include <sizedev.hxx>
119 #include <refreshtimerprotector.hxx>
120 
121 #include <officecfg/Office/Calc.hxx>
123 #include <comphelper/string.hxx>
124 #include <unotools/configmgr.hxx>
125 #include <unotools/tempfile.hxx>
127 #include <uiitems.hxx>
128 #include <dpobject.hxx>
129 #include <markdata.hxx>
130 #include <docoptio.hxx>
131 #include <orcusfilters.hxx>
132 #include <datastream.hxx>
133 #include <documentlinkmgr.hxx>
134 #include <refupdatecontext.hxx>
135 
136 #include <memory>
137 #include <vector>
138 
139 using namespace com::sun::star;
140 using ::com::sun::star::uno::Reference;
141 using ::com::sun::star::lang::XMultiServiceFactory;
142 using std::shared_ptr;
143 using ::std::vector;
144 
145 // Filter names (like in sclib.cxx)
146 
147 constexpr OUStringLiteral pFilterSc50 = u"StarCalc 5.0";
148 const char pFilterXML[] = "StarOffice XML (Calc)";
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{ uno::Any(pScHint->GetTab1()) };
652  xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_NEWSHEET, aArgs );
653  }
654  catch( uno::Exception& )
655  {
656  }
657  }
658  }
659 
660  if ( auto pStyleSheetHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint) ) // Template changed
661  NotifyStyle( *pStyleSheetHint );
662  else if ( auto pStlHint = dynamic_cast<const ScAutoStyleHint*>(&rHint) )
663  {
665 
666  // this is called synchronously from ScInterpreter::ScStyle,
667  // modifying the document must be asynchronous
668  // (handled by AddInitial)
669 
670  const ScRange& aRange = pStlHint->GetRange();
671  const OUString& aName1 = pStlHint->GetStyle1();
672  const OUString& aName2 = pStlHint->GetStyle2();
673  sal_uInt32 nTimeout = pStlHint->GetTimeout();
674 
675  if (!m_pAutoStyleList)
676  m_pAutoStyleList.reset( new ScAutoStyleList(this) );
677  m_pAutoStyleList->AddInitial( aRange, aName1, nTimeout, aName2 );
678  }
679  else if ( auto pEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
680  {
681  SfxEventHintId nEventId = pEventHint->GetEventId();
682 
683  switch ( nEventId )
684  {
685  case SfxEventHintId::LoadFinished:
686  {
687 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
688  // the readonly documents should not be opened in shared mode
689  if ( HasSharedXMLFlagSet() && !SC_MOD()->IsInSharedDocLoading() && !IsReadOnly() )
690  {
691  if ( SwitchToShared( true, false ) )
692  {
693  ScViewData* pViewData = GetViewData();
694  ScTabView* pTabView = ( pViewData ? pViewData->GetView() : nullptr );
695  if ( pTabView )
696  {
697  pTabView->UpdateLayerLocks();
698  }
699  }
700  else
701  {
702  // switching to shared mode has failed, the document should be opened readonly
703  // TODO/LATER: And error message should be shown here probably
704  SetReadOnlyUI();
705  }
706  }
707 #endif
708  }
709  break;
710  case SfxEventHintId::ViewCreated:
711  {
712  #if HAVE_FEATURE_SCRIPTING
713  uno::Reference<script::vba::XVBACompatibility> xVBACompat(GetBasicContainer(), uno::UNO_QUERY);
714  if ( !m_xVBAListener.is() && xVBACompat.is() )
715  {
716  m_xVBAListener.set(new VBAScriptListener(this));
717  xVBACompat->addVBAScriptListener(m_xVBAListener);
718  }
719 #endif
720 
721 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
722  if ( IsDocShared() && !SC_MOD()->IsInSharedDocLoading() )
723  {
724  ScAppOptions aAppOptions = SC_MOD()->GetAppOptions();
725  if ( aAppOptions.GetShowSharedDocumentWarning() )
726  {
727  MessageWithCheck aWarningBox(ScDocShell::GetActiveDialogParent(),
728  "modules/scalc/ui/sharedwarningdialog.ui", "SharedWarningDialog");
729  aWarningBox.run();
730 
731  bool bChecked = aWarningBox.get_active();
732  if (bChecked)
733  {
734  aAppOptions.SetShowSharedDocumentWarning(false);
735  SC_MOD()->SetAppOptions( aAppOptions );
736  }
737  }
738  }
739 #endif
740  try
741  {
742  uno::Reference< uno::XComponentContext > xContext(
744  uno::Reference< lang::XMultiServiceFactory > xServiceManager(
745  xContext->getServiceManager(),
746  uno::UNO_QUERY_THROW );
747  uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xServiceManager, uno::UNO_QUERY_THROW );
748  uno::Reference< container::XEnumeration> xEnum = xEnumAccess->createContentEnumeration(
749  "com.sun.star.sheet.SpreadsheetDocumentJob" );
750  if ( xEnum.is() )
751  {
752  while ( xEnum->hasMoreElements() )
753  {
754  uno::Any aAny = xEnum->nextElement();
755  uno::Reference< lang::XSingleComponentFactory > xFactory;
756  aAny >>= xFactory;
757  if ( xFactory.is() )
758  {
759  uno::Reference< task::XJob > xJob( xFactory->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
760  ScViewData* pViewData = GetViewData();
761  SfxViewShell* pViewShell = ( pViewData ? pViewData->GetViewShell() : nullptr );
762  SfxViewFrame* pViewFrame = ( pViewShell ? pViewShell->GetViewFrame() : nullptr );
763  SfxFrame* pFrame = ( pViewFrame ? &pViewFrame->GetFrame() : nullptr );
764  uno::Reference< frame::XController > xController = ( pFrame ? pFrame->GetController() : nullptr );
765  uno::Reference< sheet::XSpreadsheetView > xSpreadsheetView( xController, uno::UNO_QUERY_THROW );
766  uno::Sequence< beans::NamedValue > aArgsForJob { { "SpreadsheetView", uno::makeAny( xSpreadsheetView ) } };
767  xJob->execute( aArgsForJob );
768  }
769  }
770  }
771  }
772  catch ( uno::Exception & )
773  {
774  }
775  }
776  break;
777  case SfxEventHintId::SaveDoc:
778  {
779 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
780  if ( IsDocShared() && !SC_MOD()->IsInSharedDocSaving() )
781  {
782  bool bSuccess = false;
783  bool bRetry = true;
784  while ( bRetry )
785  {
786  bRetry = false;
787  uno::Reference< frame::XModel > xModel;
788  try
789  {
790  // load shared file
791  xModel.set( LoadSharedDocument(), uno::UNO_SET_THROW );
792  uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY_THROW );
793 
794  // check if shared flag is set in shared file
795  bool bShared = false;
796  ScModelObj* pDocObj = comphelper::getFromUnoTunnel<ScModelObj>( xModel );
797  ScDocShell* pSharedDocShell = ( pDocObj ? dynamic_cast< ScDocShell* >( pDocObj->GetObjectShell() ) : nullptr );
798  if ( pSharedDocShell )
799  {
800  bShared = pSharedDocShell->HasSharedXMLFlagSet();
801  }
802 
803  // #i87870# check if shared status was disabled and enabled again
804  bool bOwnEntry = false;
805  bool bEntriesNotAccessible = false;
806  try
807  {
808  ::svt::ShareControlFile aControlFile( GetSharedFileURL() );
809  bOwnEntry = aControlFile.HasOwnEntry();
810  }
811  catch ( uno::Exception& )
812  {
813  bEntriesNotAccessible = true;
814  }
815 
816  if ( bShared && bOwnEntry )
817  {
818  uno::Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY_THROW );
819 
820  if ( xStorable->isReadonly() )
821  {
822  xCloseable->close( true );
823 
824  OUString aUserName( ScResId( STR_UNKNOWN_USER ) );
825  bool bNoLockAccess = false;
826  try
827  {
828  ::svt::DocumentLockFile aLockFile( GetSharedFileURL() );
829  LockFileEntry aData = aLockFile.GetLockData();
830  if ( !aData[LockFileComponent::OOOUSERNAME].isEmpty() )
831  {
832  aUserName = aData[LockFileComponent::OOOUSERNAME];
833  }
834  else if ( !aData[LockFileComponent::SYSUSERNAME].isEmpty() )
835  {
836  aUserName = aData[LockFileComponent::SYSUSERNAME];
837  }
838  }
839  catch ( uno::Exception& )
840  {
841  bNoLockAccess = true;
842  }
843 
844  if ( bNoLockAccess )
845  {
846  // TODO/LATER: in future an error regarding impossibility to open file for writing could be shown
848  }
849  else
850  {
851  OUString aMessage( ScResId( STR_FILE_LOCKED_SAVE_LATER ) );
852  aMessage = aMessage.replaceFirst( "%1", aUserName );
853 
854  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetActiveDialogParent(),
855  VclMessageType::Warning, VclButtonsType::NONE,
856  aMessage));
857  xWarn->add_button(GetStandardText(StandardButtonType::Retry), RET_RETRY);
858  xWarn->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL);
859  xWarn->set_default_response(RET_RETRY);
860  if (xWarn->run() == RET_RETRY)
861  {
862  bRetry = true;
863  }
864  }
865  }
866  else
867  {
868  // merge changes from shared file into temp file
869  bool bSaveToShared = false;
870  if ( pSharedDocShell )
871  {
872  bSaveToShared = MergeSharedDocument( pSharedDocShell );
873  }
874 
875  // close shared file
876  xCloseable->close( true );
877 
878  // TODO: keep file lock on shared file
879 
880  // store to shared file
881  if ( bSaveToShared )
882  {
883  bool bChangedViewSettings = false;
884  ScChangeViewSettings* pChangeViewSet = m_aDocument.GetChangeViewSettings();
885  if ( pChangeViewSet && pChangeViewSet->ShowChanges() )
886  {
887  pChangeViewSet->SetShowChanges( false );
888  pChangeViewSet->SetShowAccepted( false );
889  m_aDocument.SetChangeViewSettings( *pChangeViewSet );
890  bChangedViewSettings = true;
891  }
892 
893  uno::Reference< frame::XStorable > xStor( GetModel(), uno::UNO_QUERY_THROW );
894  // TODO/LATER: More entries from the MediaDescriptor might be interesting for the merge
895  uno::Sequence< beans::PropertyValue > aValues{
897  "FilterName",
898  GetMedium()->GetFilter()->GetFilterName())
899  };
900 
901  const SfxStringItem* pPasswordItem = SfxItemSet::GetItem<SfxStringItem>(GetMedium()->GetItemSet(), SID_PASSWORD, false);
902  if ( pPasswordItem && !pPasswordItem->GetValue().isEmpty() )
903  {
904  aValues.realloc( 2 );
905  auto pValues = aValues.getArray();
906  pValues[1].Name = "Password";
907  pValues[1].Value <<= pPasswordItem->GetValue();
908  }
909 
910  SC_MOD()->SetInSharedDocSaving( true );
911  xStor->storeToURL( GetSharedFileURL(), aValues );
912  SC_MOD()->SetInSharedDocSaving( false );
913 
914  if ( bChangedViewSettings )
915  {
916  pChangeViewSet->SetShowChanges( true );
917  pChangeViewSet->SetShowAccepted( true );
918  m_aDocument.SetChangeViewSettings( *pChangeViewSet );
919  }
920  }
921 
922  bSuccess = true;
923  GetUndoManager()->Clear();
924  }
925  }
926  else
927  {
928  xCloseable->close( true );
929 
930  if ( bEntriesNotAccessible )
931  {
932  // TODO/LATER: in future an error regarding impossibility to write to share control file could be shown
934  }
935  else
936  {
937  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetActiveDialogParent(),
938  VclMessageType::Warning, VclButtonsType::Ok,
939  ScResId(STR_DOC_NOLONGERSHARED)));
940  xWarn->run();
941 
942  SfxBindings* pBindings = GetViewBindings();
943  if ( pBindings )
944  {
945  pBindings->ExecuteSynchron( SID_SAVEASDOC );
946  }
947  }
948  }
949  }
950  catch ( uno::Exception& )
951  {
952  TOOLS_WARN_EXCEPTION( "sc", "SfxEventHintId::SaveDoc" );
953  SC_MOD()->SetInSharedDocSaving( false );
954 
955  try
956  {
957  uno::Reference< util::XCloseable > xClose( xModel, uno::UNO_QUERY_THROW );
958  xClose->close( true );
959  }
960  catch ( uno::Exception& )
961  {
962  }
963  }
964  }
965 
966  if ( !bSuccess )
967  SetError(ERRCODE_IO_ABORT); // this error code will produce no error message, but will break the further saving process
968  }
969 #endif
970 
971  if (m_pSheetSaveData)
972  m_pSheetSaveData->SetInSupportedSave(true);
973  }
974  break;
975  case SfxEventHintId::SaveAsDoc:
976  {
977  if ( GetDocument().GetExternalRefManager()->containsUnsavedReferences() )
978  {
979  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetActiveDialogParent(),
980  VclMessageType::Warning, VclButtonsType::YesNo,
981  ScResId(STR_UNSAVED_EXT_REF)));
982  if (RET_NO == xWarn->run())
983  {
984  SetError(ERRCODE_IO_ABORT); // this error code will produce no error message, but will break the further saving process
985  }
986  }
987  [[fallthrough]];
988  }
989  case SfxEventHintId::SaveToDoc:
990  // #i108978# If no event is sent before saving, there will also be no "...DONE" event,
991  // and SAVE/SAVEAS can't be distinguished from SAVETO. So stream copying is only enabled
992  // if there is a SAVE/SAVEAS/SAVETO event first.
993  if (m_pSheetSaveData)
994  m_pSheetSaveData->SetInSupportedSave(true);
995  break;
996  case SfxEventHintId::SaveDocDone:
997  case SfxEventHintId::SaveAsDocDone:
998  {
999  // new positions are used after "save" and "save as", but not "save to"
1000  UseSheetSaveEntries(); // use positions from saved file for next saving
1001  [[fallthrough]];
1002  }
1003  case SfxEventHintId::SaveToDocDone:
1004  // only reset the flag, don't use the new positions
1005  if (m_pSheetSaveData)
1006  m_pSheetSaveData->SetInSupportedSave(false);
1007  break;
1008  default:
1009  {
1010  }
1011  break;
1012  }
1013  }
1014  else if (rHint.GetId() == SfxHintId::TitleChanged) // Without parameter
1015  {
1016  m_aDocument.SetName( SfxShell::GetName() );
1017  // RegisterNewTargetNames doesn't exist any longer
1018  SfxGetpApp()->Broadcast(SfxHint( SfxHintId::ScDocNameChanged )); // Navigator
1019  }
1020  else if (rHint.GetId() == SfxHintId::Deinitializing)
1021  {
1022 
1023 #if HAVE_FEATURE_SCRIPTING
1024  uno::Reference<script::vba::XVBACompatibility> xVBACompat(GetBasicContainer(), uno::UNO_QUERY);
1025  if (m_xVBAListener.is() && xVBACompat.is())
1026  {
1027  xVBACompat->removeVBAScriptListener(m_xVBAListener);
1028  }
1029 #endif
1030 
1031  if (m_aDocument.IsClipboardSource())
1032  {
1033  // Notes copied to the clipboard have a raw SdrCaptionObj pointer
1034  // copied from this document, forget it as it references this
1035  // document's drawing layer pages and what not, which otherwise when
1036  // pasting to another document after this document was destructed would
1037  // attempt to access non-existing data. Preserve the text data though.
1038  ScDocument* pClipDoc = ScModule::GetClipDoc();
1039  if (pClipDoc)
1040  pClipDoc->ClosingClipboardSource();
1041  }
1042  }
1043 
1044  const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
1045  if (!pSfxEventHint)
1046  return;
1047 
1048  switch( pSfxEventHint->GetEventId() )
1049  {
1050  case SfxEventHintId::CreateDoc:
1051  {
1052  uno::Any aWorkbook;
1053  aWorkbook <<= mxAutomationWorkbookObject;
1054  uno::Sequence< uno::Any > aArgs{ aWorkbook };
1055  SC_MOD()->CallAutomationApplicationEventSinks( "NewWorkbook", aArgs );
1056  }
1057  break;
1058  case SfxEventHintId::OpenDoc:
1059  {
1060  uno::Any aWorkbook;
1061  aWorkbook <<= mxAutomationWorkbookObject;
1062  uno::Sequence< uno::Any > aArgs{ 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 == SC_TEXT_CSV_FILTER_NAME)
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  aString = pCell->mpFormula->GetFormula();
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  aString = ScCellFormat::GetString(*pCell, nFormat, &pDummy, rFormatter, m_aDocument);
2121  bString = bSaveAsShown && rFormatter.IsTextFormat( nFormat);
2122  }
2123  else
2124  {
2125  aString = ScCellFormat::GetInputString(*pCell, nFormat, 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  aString = ScCellFormat::GetString(*pCell, nFormat, &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  aString = ScCellFormat::GetString(*pCell, nFormat, &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 = m_aDocument.GetNumberFormat( nCol, nRow, nTab );
2166  if ( bFixedWidth || bSaveAsShown )
2167  {
2168  const Color* pDummy;
2169  aString = ScCellFormat::GetString(*pCell, nFormat, &pDummy, rFormatter, m_aDocument);
2170  bString = bSaveAsShown && rFormatter.IsTextFormat( nFormat);
2171  }
2172  else
2173  {
2174  aString = ScCellFormat::GetInputString(*pCell, nFormat, rFormatter, m_aDocument);
2175  bString = bForceQuotes = !bSaveNumberAsSuch;
2176  }
2177  }
2178  break;
2179  default:
2180  OSL_FAIL( "ScDocShell::AsciiSave: unknown CellType" );
2181  aString.clear();
2182  bString = false;
2183  }
2184 
2185  if ( bFixedWidth )
2186  {
2187  SvxCellHorJustify eHorJust =
2188  m_aDocument.GetAttr( nCol, nRow, nTab, ATTR_HOR_JUSTIFY )->GetValue();
2189  lcl_ScDocShell_GetFixedWidthString( aString, m_aDocument, nTab, nCol,
2190  !bString, eHorJust );
2191  rStream.WriteUnicodeOrByteText( aString );
2192  }
2193  else
2194  {
2195  OUString aUniString = aString;// TODO: remove that later
2196  if (!bString && cStrDelim != 0 && !aUniString.isEmpty())
2197  {
2198  sal_Unicode c = aUniString[0];
2199  bString = (c == cStrDelim || c == ' ' ||
2200  aUniString.endsWith(" ") ||
2201  aUniString.indexOf(cStrDelim) >= 0);
2202  if (!bString && cDelim != 0)
2203  bString = (aUniString.indexOf(cDelim) >= 0);
2204  }
2205  if ( bString )
2206  {
2207  if ( cStrDelim != 0 ) //@ BugId 55355
2208  {
2209  if ( eCharSet == RTL_TEXTENCODING_UNICODE )
2210  {
2211  bool bNeedQuotes = false;
2212  sal_Int32 nPos = getTextSepPos(
2213  aUniString, rAsciiOpt, cStrDelim, cDelim, bNeedQuotes);
2214 
2215  escapeTextSep<OUString, OUStringBuffer>(
2216  nPos, OUString(cStrDelim), aUniString);
2217 
2218  if ( bNeedQuotes || bForceQuotes )
2219  rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
2220  write_uInt16s_FromOUString(rStream, aUniString);
2221  if ( bNeedQuotes || bForceQuotes )
2222  rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
2223  }
2224  else
2225  {
2226  // This is nasty. The Unicode to byte encoding
2227  // may convert typographical quotation marks to ASCII
2228  // quotation marks, which may interfere with the delimiter,
2229  // so we have to escape delimiters after the string has
2230  // been encoded. Since this may happen also with UTF-8
2231  // encoded typographical quotation marks if such was
2232  // specified as a delimiter we have to check for the full
2233  // encoded delimiter string, not just one character.
2234  // Now for RTL_TEXTENCODING_ISO_2022_... and similar brain
2235  // dead encodings where one code point (and especially a
2236  // low ASCII value) may represent different characters, we
2237  // have to convert forth and back and forth again. Same for
2238  // UTF-7 since it is a context sensitive encoding too.
2239 
2240  if ( bContextOrNotAsciiEncoding )
2241  {
2242  // to byte encoding
2243  OString aStrEnc = OUStringToOString(aUniString, eCharSet);
2244  // back to Unicode
2245  OUString aStrDec = OStringToOUString(aStrEnc, eCharSet);
2246 
2247  // search on re-decoded string
2248  bool bNeedQuotes = false;
2249  sal_Int32 nPos = getTextSepPos(
2250  aStrDec, rAsciiOpt, aStrDelimDecoded, aDelimDecoded, bNeedQuotes);
2251 
2252  escapeTextSep<OUString, OUStringBuffer>(
2253  nPos, aStrDelimDecoded, aStrDec);
2254 
2255  // write byte re-encoded
2256  if ( bNeedQuotes || bForceQuotes )
2257  rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
2258  rStream.WriteUnicodeOrByteText( aStrDec, eCharSet );
2259  if ( bNeedQuotes || bForceQuotes )
2260  rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
2261  }
2262  else
2263  {
2264  OString aStrEnc = OUStringToOString(aUniString, eCharSet);
2265 
2266  // search on encoded string
2267  bool bNeedQuotes = false;
2268  sal_Int32 nPos = getTextSepPos(
2269  aStrEnc, rAsciiOpt, aStrDelimEncoded, aDelimEncoded, bNeedQuotes);
2270 
2271  escapeTextSep<OString, OStringBuffer>(
2272  nPos, aStrDelimEncoded, aStrEnc);
2273 
2274  // write byte encoded
2275  if ( bNeedQuotes || bForceQuotes )
2276  rStream.WriteBytes(
2277  aStrDelimEncoded.getStr(), aStrDelimEncoded.getLength());
2278  rStream.WriteBytes(aStrEnc.getStr(), aStrEnc.getLength());
2279  if ( bNeedQuotes || bForceQuotes )
2280  rStream.WriteBytes(
2281  aStrDelimEncoded.getStr(), aStrDelimEncoded.getLength());
2282  }
2283  }
2284  }
2285  else
2286  rStream.WriteUnicodeOrByteText( aUniString );
2287  }
2288  else
2289  rStream.WriteUnicodeOrByteText( aUniString );
2290  }
2291 
2292  if( nCol < nEndCol )
2293  {
2294  if(cDelim!=0) //@ BugId 55355
2295  rStream.WriteUniOrByteChar( cDelim );
2296  }
2297  else
2298  endlub( rStream );
2299 
2300  if ( bProgress )
2301  aProgress.SetStateOnPercent( nRow );
2302  }
2303 
2304  // write out empty if requested
2305  if ( nNextRow <= nEndRow )
2306  {
2307  for ( nEmptyCol = nNextCol; nEmptyCol < nEndCol; nEmptyCol++ )
2308  { // remaining empty columns of last row
2309  if ( bFixedWidth )
2310  lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2311  m_aDocument, nTab, nEmptyCol );
2312  else if ( cDelim != 0 )
2313  rStream.WriteUniOrByteChar( cDelim );
2314  }
2315  endlub( rStream );
2316  nNextRow++;
2317  }
2318  for ( nEmptyRow = nNextRow; nEmptyRow <= nEndRow; nEmptyRow++ )
2319  { // entire empty rows
2320  for ( nEmptyCol = nStartCol; nEmptyCol < nEndCol; nEmptyCol++ )
2321  {
2322  if ( bFixedWidth )
2323  lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
2324  m_aDocument, nTab, nEmptyCol );
2325  else if ( cDelim != 0 )
2326  rStream.WriteUniOrByteChar( cDelim );
2327  }
2328  endlub( rStream );
2329  }
2330 
2331  rStream.SetStreamCharSet( eOldCharSet );
2332  rStream.SetEndian( nOldNumberFormatInt );
2333 }
2334 
2336 {
2338 
2339  // #i6500# don't call DoEnterHandler here (doesn't work with AutoSave),
2340  // it's already in ExecuteSave (as for Save and SaveAs)
2341 
2342  if (m_pAutoStyleList)
2343  m_pAutoStyleList->ExecuteAllNow(); // Execute template timeouts now
2344  if (GetCreateMode()== SfxObjectCreateMode::STANDARD)
2345  SfxObjectShell::SetVisArea( tools::Rectangle() ); // Edited normally -> no VisArea
2346 
2347  OSL_ENSURE( rMed.GetFilter(), "Filter == 0" );
2348 
2349  bool bRet = false;
2350  OUString aFltName = rMed.GetFilter()->GetFilterName();
2351 
2352  if (aFltName == pFilterXML)
2353  {
2354  //TODO/LATER: this shouldn't happen!
2355  OSL_FAIL("XML filter in ConvertFrom?!");
2356  bRet = SaveXML( &rMed, nullptr );
2357  }
2358  else if (aFltName == pFilterExcel5 || aFltName == pFilterExcel95 ||
2359  aFltName == pFilterExcel97 || aFltName == pFilterEx5Temp ||
2360  aFltName == pFilterEx95Temp || aFltName == pFilterEx97Temp)
2361  {
2363 
2364  bool bDoSave = true;
2365  if( ScTabViewShell* pViewShell = GetBestViewShell() )
2366  {
2368  if( !pExtDocOpt )
2369  {
2370  m_aDocument.SetExtDocOptions( std::make_unique<ScExtDocOptions>() );
2371  pExtDocOpt = m_aDocument.GetExtDocOptions();
2372  }
2373  pViewShell->GetViewData().WriteExtOptions( *pExtDocOpt );
2374 
2375  /* #i104990# If the imported document contains a medium
2376  password, determine if we can save it, otherwise ask the users
2377  whether they want to save without it. */
2378  if( (rMed.GetFilter()->GetFilterFlags() & SfxFilterFlags::ENCRYPTION) == SfxFilterFlags::NONE )
2379  {
2380  SfxItemSet* pItemSet = rMed.GetItemSet();
2381  const SfxPoolItem* pItem = nullptr;
2382  if( pItemSet && pItemSet->GetItemState( SID_PASSWORD, true, &pItem ) == SfxItemState::SET )
2383  {
2384  bDoSave = ScWarnPassword::WarningOnPassword( rMed );
2385  // #i42858# remove password from medium (warn only one time)
2386  if( bDoSave )
2387  pItemSet->ClearItem( SID_PASSWORD );
2388  }
2389  }
2390 
2391  if( bDoSave )
2392  {
2393  bool bNeedRetypePassDlg = ScPassHashHelper::needsPassHashRegen( m_aDocument, PASSHASH_XL );
2394  bDoSave = !bNeedRetypePassDlg || pViewShell->ExecuteRetypePassDlg( PASSHASH_XL );
2395  }
2396  }
2397 
2398  if( bDoSave )
2399  {
2400  ExportFormatExcel eFormat = ExpBiff5;
2401  if( aFltName == pFilterExcel97 || aFltName == pFilterEx97Temp )
2402  eFormat = ExpBiff8;
2403  ErrCode eError = ScFormatFilter::Get().ScExportExcel5( rMed, &m_aDocument, eFormat, RTL_TEXTENCODING_MS_1252 );
2404 
2405  if( eError && !GetError() )
2406  SetError(eError);
2407 
2408  // don't return false for warnings
2409  bRet = eError.IsWarning() || (eError == ERRCODE_NONE);
2410  }
2411  else
2412  {
2413  // export aborted, i.e. "Save without password" warning
2415  }
2416  }
2417  else if (aFltName == SC_TEXT_CSV_FILTER_NAME)
2418  {
2419  OUString sItStr;
2420  SfxItemSet* pSet = rMed.GetItemSet();
2421  const SfxPoolItem* pItem;
2422  if ( pSet && SfxItemState::SET ==
2423  pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
2424  {
2425  sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
2426  }
2427 
2428  if ( sItStr.isEmpty() )
2429  {
2430  // default for ascii export (from API without options):
2431  // ISO8859-1/MS_1252 encoding, comma, double quotes
2432 
2433  ScImportOptions aDefOptions( ',', '"', RTL_TEXTENCODING_MS_1252 );
2434  sItStr = aDefOptions.BuildString();
2435  }
2436 
2438  ScImportOptions aOptions( sItStr );
2439 
2440  if (aOptions.nSheetToExport)
2441  {
2442  // Only from command line --convert-to
2443  bRet = true;
2444 
2445  // Verbose only from command line, not UI (in case we actually
2446  // implement that) nor macro filter options.
2447  bool bVerbose = false;
2448  const css::uno::Sequence<css::beans::PropertyValue> & rArgs = rMed.GetArgs();
2449  const auto pProp = std::find_if( rArgs.begin(), rArgs.end(),
2450  [](const css::beans::PropertyValue& rProp) { return rProp.Name == "ConversionRequestOrigin"; });
2451  if (pProp != rArgs.end())
2452  {
2453  OUString aOrigin;
2454  pProp->Value >>= aOrigin;
2455  bVerbose = (aOrigin == "CommandLine");
2456  }
2457 
2458  SCTAB nStartTab;
2460  if (aOptions.nSheetToExport == -1)
2461  {
2462  // All sheets.
2463  nStartTab = 0;
2464  }
2465  else if (0 < aOptions.nSheetToExport && aOptions.nSheetToExport <= nCount)
2466  {
2467  // One sheet, 1-based.
2468  nCount = aOptions.nSheetToExport;
2469  nStartTab = nCount - 1;
2470  }
2471  else
2472  {
2473  // Usage error, no export but log.
2474  if (bVerbose)
2475  {
2476  if (aOptions.nSheetToExport < 0)
2477  std::cout << "Bad sheet number string given." << std::endl;
2478  else
2479  std::cout << "No sheet number " << aOptions.nSheetToExport
2480  << ", number of sheets is " << nCount << std::endl;
2481  }
2482  nStartTab = 0;
2483  nCount = 0;
2485  bRet = false;
2486  }
2487 
2488  INetURLObject aURLObject(rMed.GetURLObject());
2489  OUString sExt = aURLObject.CutExtension();
2490  OUString sBaseName = aURLObject.GetLastName();
2491  aURLObject.CutLastName();
2492 
2493  for (SCTAB i = nStartTab; i < nCount; ++i)
2494  {
2495  OUString sTabName;
2496  if (!m_aDocument.GetName(i, sTabName))
2497  sTabName = OUString::number(i);
2498  INetURLObject aSheetURLObject(aURLObject);
2499  OUString sFileName = sBaseName + "-" + sTabName;
2500  if (!sExt.isEmpty())
2501  sFileName = sFileName + "." + sExt;
2502  aSheetURLObject.Append(sFileName);
2503 
2504  // log similar to DispatchWatcher::executeDispatchRequests
2505  OUString aOutFile = aSheetURLObject.GetMainURL(INetURLObject::DecodeMechanism::NONE);
2506  if (bVerbose)
2507  {
2508  OUString aDisplayedName;
2509  if (osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(aOutFile, aDisplayedName))
2510  aDisplayedName = aOutFile;
2511  std::cout << "Writing sheet " << OUStringToOString(sTabName, osl_getThreadTextEncoding()) << " -> "
2512  << OUStringToOString(aDisplayedName, osl_getThreadTextEncoding())
2513  << std::endl;
2514 
2515  if (FStatHelper::IsDocument(aOutFile))
2516  std::cout << "Overwriting: " << OUStringToOString(aDisplayedName, osl_getThreadTextEncoding())
2517  << std::endl ;
2518  }
2519 
2520  std::unique_ptr<SvStream> xStm = ::utl::UcbStreamHelper::CreateStream(aOutFile, StreamMode::TRUNC | StreamMode::WRITE);
2521  if (!xStm)
2522  {
2524  bRet = false;
2525  break;
2526  }
2527  AsciiSave(*xStm, aOptions, i);
2528  }
2529  }
2530  else
2531  {
2532  SvStream* pStream = rMed.GetOutStream();
2533  if (pStream)
2534  {
2535  AsciiSave(*pStream, aOptions, GetSaveTab());
2536  bRet = true;
2537 
2538  if (m_aDocument.GetTableCount() > 1)
2539  if (!rMed.GetError())
2541  }
2542  }
2543  }
2544  else if (aFltName == pFilterDBase)
2545  {
2546  OUString sCharSet;
2547  SfxItemSet* pSet = rMed.GetItemSet();
2548  const SfxPoolItem* pItem;
2549  if ( pSet && SfxItemState::SET ==
2550  pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
2551  {
2552  sCharSet = static_cast<const SfxStringItem*>(pItem)->GetValue();
2553  }
2554 
2555  if (sCharSet.isEmpty())
2556  {
2557  // default for dBase export (from API without options):
2558  // IBM_850 encoding
2559 
2560  sCharSet = ScGlobal::GetCharsetString( RTL_TEXTENCODING_IBM_850 );
2561  }
2562 
2564  // Hack so that Sba can overwrite the opened TempFile.
2565  rMed.CloseOutStream();
2566  bool bHasMemo = false;
2567 
2568  ErrCode eError = DBaseExport(
2569  rMed.GetPhysicalName(), ScGlobal::GetCharsetValue(sCharSet), bHasMemo);
2570 
2571  INetURLObject aTmpFile( rMed.GetPhysicalName(), INetProtocol::File );
2572  if ( bHasMemo )
2573  aTmpFile.setExtension(u"dbt");
2574  if ( eError != ERRCODE_NONE && !eError.IsWarning() )
2575  {
2576  if (!GetError())
2577  SetError(eError);
2578  if ( bHasMemo && IsDocument( aTmpFile ) )
2579  KillFile( aTmpFile );
2580  }
2581  else
2582  {
2583  bRet = true;
2584  if ( bHasMemo )
2585  {
2586  const SfxStringItem* pNameItem = rMed.GetItemSet()->GetItem<SfxStringItem>( SID_FILE_NAME );
2587  INetURLObject aDbtFile( pNameItem->GetValue(), INetProtocol::File );
2588  aDbtFile.setExtension(u"dbt");
2589 
2590  // tdf#40713: don't lose dbt file
2591  // if aDbtFile corresponds exactly to aTmpFile, we just have to return
2592  if (aDbtFile.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ) ==
2593  aTmpFile.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ))
2594  {
2595  if (eError != ERRCODE_NONE && !GetError())
2596  SetError(eError);
2597  return bRet;
2598  }
2599 
2600  if ( IsDocument( aDbtFile ) && !KillFile( aDbtFile ) )
2601  bRet = false;
2602  if ( bRet && !MoveFile( aTmpFile, aDbtFile ) )
2603  bRet = false;
2604  if ( !bRet )
2605  {
2606  KillFile( aTmpFile );
2607  if (eError == ERRCODE_NONE || eError.IsWarning())
2608  eError = SCERR_EXPORT_DATA;
2609  }
2610  }
2611  if (eError != ERRCODE_NONE && !GetError())
2612  SetError(eError);
2613  }
2614  }
2615  else if (aFltName == pFilterDif)
2616  {
2617  SvStream* pStream = rMed.GetOutStream();
2618  if (pStream)
2619  {
2620  OUString sItStr;
2621  SfxItemSet* pSet = rMed.GetItemSet();
2622  const SfxPoolItem* pItem;
2623  if ( pSet && SfxItemState::SET ==
2624  pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) )
2625  {
2626  sItStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
2627  }
2628 
2629  if (sItStr.isEmpty())
2630  {
2631  // default for DIF export (from API without options):
2632  // ISO8859-1/MS_1252 encoding
2633 
2634  sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_MS_1252 );
2635  }
2636 
2638  ScFormatFilter::Get().ScExportDif( *pStream, &m_aDocument, ScAddress(0,0,0),
2639  ScGlobal::GetCharsetValue(sItStr) );
2640  bRet = true;
2641 
2642  if (m_aDocument.GetTableCount() > 1)
2643  if (!rMed.GetError())
2645  }
2646  }
2647  else if (aFltName == pFilterSylk)
2648  {
2649  SvStream* pStream = rMed.GetOutStream();
2650  if ( pStream )
2651  {
2653 
2654  SCCOL nEndCol;
2655  SCROW nEndRow;
2656  m_aDocument.GetCellArea( 0, nEndCol, nEndRow );
2657  ScRange aRange( 0,0,0, nEndCol,nEndRow,0 );
2658 
2659  ScImportExport aImExport( m_aDocument, aRange );
2660  aImExport.SetFormulas( true );
2661  bRet = aImExport.ExportStream( *pStream, rMed.GetBaseURL( true ), SotClipboardFormatId::SYLK );
2662  }
2663  }
2664  else if (aFltName == pFilterHtml)
2665  {
2666  SvStream* pStream = rMed.GetOutStream();
2667  if ( pStream )
2668  {
2669  SfxItemSet* pSet = rMed.GetItemSet();
2670  const SfxPoolItem* pItem;
2671  OUString sFilterOptions;
2672 
2673  if (pSet->GetItemState(SID_FILE_FILTEROPTIONS, true, &pItem) == SfxItemState::SET)
2674  sFilterOptions = static_cast<const SfxStringItem*>(pItem)->GetValue();
2675 
2677  ScImportExport aImExport(m_aDocument);
2678  aImExport.SetStreamPath(rMed.GetName());
2679  aImExport.SetFilterOptions(sFilterOptions);
2680  bRet = aImExport.ExportStream(*pStream, rMed.GetBaseURL(true), SotClipboardFormatId::HTML);
2681  if (bRet && !aImExport.GetNonConvertibleChars().isEmpty())
2682  {
2685  aImExport.GetNonConvertibleChars(),
2686  DialogMask::ButtonsOk | DialogMask::MessageInfo));
2687  }
2688  }
2689  }
2690  else
2691  {
2692  if (GetError())
2694  }
2695  return bRet;
2696 }
2697 
2698 bool ScDocShell::DoSaveCompleted( SfxMedium * pNewStor, bool bRegisterRecent )
2699 {
2700  bool bRet = SfxObjectShell::DoSaveCompleted( pNewStor, bRegisterRecent );
2701 
2702  // SfxHintId::ScDocSaved for change ReadOnly -> Read/Write
2703  Broadcast( SfxHint( SfxHintId::ScDocSaved ) );
2704  return bRet;
2705 }
2706 
2707 bool ScDocShell::QuerySlotExecutable( sal_uInt16 nSlotId )
2708 {
2709  // #i112634# ask VBA event handlers whether to save or print the document
2710 
2711  using namespace ::com::sun::star::script::vba;
2712 
2713  sal_Int32 nVbaEventId = VBAEventId::NO_EVENT;
2714  uno::Sequence< uno::Any > aArgs;
2715  switch( nSlotId )
2716  {
2717  case SID_SAVEDOC:
2718  case SID_SAVEASDOC:
2719  nVbaEventId = VBAEventId::WORKBOOK_BEFORESAVE;
2720  aArgs = { uno::Any(nSlotId == SID_SAVEASDOC) };
2721  break;
2722  case SID_PRINTDOC:
2723  case SID_PRINTDOCDIRECT:
2724  nVbaEventId = VBAEventId::WORKBOOK_BEFOREPRINT;
2725  break;
2726  }
2727 
2728  bool bSlotExecutable = true;
2729  if( nVbaEventId != VBAEventId::NO_EVENT ) try
2730  {
2731  uno::Reference< XVBAEventProcessor > xEventProcessor( m_aDocument.GetVbaEventProcessor(), uno::UNO_SET_THROW );
2732  xEventProcessor->processVbaEvent( nVbaEventId, aArgs );
2733  }
2734  catch( util::VetoException& )
2735  {
2736  bSlotExecutable = false;
2737  }
2738  catch( uno::Exception& )
2739  {
2740  }
2741  return bSlotExecutable;
2742 }
2743 
2745 {
2746  if(SC_MOD()->GetCurRefDlgId()>0)
2747  {
2748  SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
2749  if( pFrame )
2750  {
2751  SfxViewShell* p = pFrame->GetViewShell();
2752  ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell *>( p );
2753  if(pViewSh!=nullptr)
2754  {
2755  vcl::Window *pWin=pViewSh->GetWindow();
2756  if(pWin!=nullptr) pWin->GrabFocus();
2757  }
2758  }
2759 
2760  return false;
2761  }
2763  {
2764  ErrorMessage(STR_CLOSE_ERROR_LINK);
2765  return false;
2766  }
2767 
2768  DoEnterHandler();
2769 
2770  // start 'Workbook_BeforeClose' VBA event handler for possible veto
2771  if( !IsInPrepareClose() )
2772  {
2773  try
2774  {
2775  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( m_aDocument.GetVbaEventProcessor(), uno::UNO_SET_THROW );
2776  uno::Sequence< uno::Any > aArgs;
2777  xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_BEFORECLOSE, aArgs );
2778  }
2779  catch( util::VetoException& )
2780  {
2781  // if event processor throws VetoException, macro has vetoed close
2782  return false;
2783  }
2784  catch( uno::Exception& )
2785  {
2786  }
2787  }
2788  // end handler code
2789 
2790  bool bRet = SfxObjectShell::PrepareClose( bUI );
2791  if (bRet) // true == close
2792  m_aDocument.EnableIdle(false); // Do not mess around with it anymore!
2793 
2794  return bRet;
2795 }
2796 
2798 {
2799  return pFilterSc50;
2800 }
2801 
2803 {
2804  return pFilterHtml;
2805 }
2806 
2808 {
2809  return pFilterHtmlWebQ;
2810 }
2811 
2813 {
2814  return SC_TEXT_CSV_FILTER_NAME;
2815 }
2816 
2818 {
2819  return pFilterLotus;
2820 }
2821 
2823 {
2824  return pFilterDBase;
2825 }
2826 
2828 {
2829  return pFilterDif;
2830 }
2831 
2832 bool ScDocShell::HasAutomaticTableName( std::u16string_view rFilter )
2833 {
2834  // sal_True for those filters that keep the default table name
2835  // (which is language specific)
2836 
2837  return rFilter == SC_TEXT_CSV_FILTER_NAME
2838  || rFilter == pFilterLotus
2839  || rFilter == pFilterExcel4
2840  || rFilter == pFilterEx4Temp
2841  || rFilter == pFilterDBase
2842  || rFilter == pFilterDif
2843  || rFilter == pFilterSylk
2844  || rFilter == pFilterHtml
2845  || rFilter == pFilterRtf;
2846 }
2847 
2848 std::unique_ptr<ScDocFunc> ScDocShell::CreateDocFunc()
2849 {
2850  return std::make_unique<ScDocFuncDirect>( *this );
2851 }
2852 
2853 ScDocShell::ScDocShell( const SfxModelFlags i_nSfxCreationFlags ) :
2854  SfxObjectShell( i_nSfxCreationFlags ),
2855  m_aDocument ( SCDOCMODE_DOCUMENT, this ),
2856  m_aDdeTextFmt(OUString("TEXT")),
2857  m_nPrtToScreenFactor( 1.0 ),
2858  m_pImpl ( new DocShell_Impl ),
2859  m_bHeaderOn ( true ),
2860  m_bFooterOn ( true ),
2861  m_bIsEmpty ( true ),
2862  m_bIsInUndo ( false ),
2863  m_bDocumentModifiedPending( false ),
2864  m_bUpdateEnabled ( true ),
2865  m_bUcalcTest ( false ),
2867  m_nDocumentLock ( 0 ),
2868  m_nCanUpdate (css::document::UpdateDocMode::ACCORDING_TO_CONFIG)
2869 {
2870  SetPool( &SC_MOD()->GetPool() );
2871 
2872  m_bIsInplace = (GetCreateMode() == SfxObjectCreateMode::EMBEDDED);
2873  // Will be reset if not in place
2874 
2876 
2877  // SetBaseModel needs exception handling
2878  ScModelObj::CreateAndSet( this );
2879 
2880  StartListening(*this);
2882  if (pStlPool)
2883  StartListening(*pStlPool);
2884 
2886  LINK( this, ScDocShell, RefreshDBDataHdl ) );
2887 
2888  // InitItems and CalcOutputFactor are called now in Load/ConvertFrom/InitNew
2889 }
2890 
2892 {
2893  ResetDrawObjectShell(); // If the Drawing Layer still tries to access it, access it
2894 
2896  if (pStlPool)
2897  EndListening(*pStlPool);
2898  EndListening(*this);
2899 
2900  m_pAutoStyleList.reset();
2901 
2902  SfxApplication *pSfxApp = SfxGetpApp();
2903  if ( pSfxApp->GetDdeService() ) // Delete DDE for Document
2904  pSfxApp->RemoveDdeTopic( this );
2905 
2906  m_pDocFunc.reset();
2907  delete m_aDocument.mpUndoManager;
2908  m_aDocument.mpUndoManager = nullptr;
2909  m_pImpl.reset();
2910 
2911  m_pPaintLockData.reset();
2912 
2913  m_pSolverSaveData.reset();
2914  m_pSheetSaveData.reset();
2915  m_pFormatSaveData.reset();
2916  m_pOldAutoDBRange.reset();
2917 
2918  if (m_pModificator)
2919  {
2920  OSL_FAIL("The Modificator should not exist");
2921  m_pModificator.reset();
2922  }
2923 }
2924 
2926 {
2927  return m_aDocument.GetUndoManager();
2928 }
2929 
2930 void ScDocShell::SetModified( bool bModified )
2931 {
2933  {
2934  SfxObjectShell::SetModified( bModified );
2935  Broadcast( SfxHint( SfxHintId::DocChanged ) );
2936  }
2937 }
2938 
2940 {
2941  // BroadcastUno must also happen right away with pPaintLockData
2942  // FIXME: Also for SetDrawModified, if Drawing is connected
2943  // FIXME: Then own Hint?
2944 
2945  if ( m_pPaintLockData )
2946  {
2947  // #i115009# broadcast BCA_BRDCST_ALWAYS, so a component can read recalculated results
2948  // of RecalcModeAlways formulas (like OFFSET) after modifying cells
2949  m_aDocument.Broadcast(ScHint(SfxHintId::ScDataChanged, BCA_BRDCST_ALWAYS));
2950  m_aDocument.InvalidateTableArea(); // #i105279# needed here
2951  m_aDocument.BroadcastUno( SfxHint( SfxHintId::DataChanged ) );
2952 
2953  m_pPaintLockData->SetModified(); // Later on ...
2954  return;
2955  }
2956 
2957  SetDrawModified();
2958 
2961  else
2962  {
2963  SetDocumentModifiedPending( false );
2967  m_aDocument.Broadcast(ScHint(SfxHintId::ScDataChanged, BCA_BRDCST_ALWAYS));
2969  m_aDocument.CalcFormulaTree( true );
2971  PostDataChanged();
2972 
2973  // Detective AutoUpdate:
2974  // Update if formulas were modified (DetectiveDirty) or the list contains
2975  // "Trace Error" entries (Trace Error can look completely different
2976  // after changes to non-formula cells).
2977 
2979  if ( pList && ( m_aDocument.IsDetectiveDirty() || pList->HasAddError() ) &&
2980  pList->Count() && !IsInUndo() && SC_MOD()->GetAppOptions().GetDetectiveAuto() )
2981  {
2982  GetDocFunc().DetectiveRefresh(true); // sal_True = caused by automatic update
2983  }
2984  m_aDocument.SetDetectiveDirty(false); // always reset, also if not refreshed
2985  }
2986 
2988  {
2990  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreasChanged));
2991  }
2992 
2993  // notify UNO objects after BCA_BRDCST_ALWAYS etc.
2994  m_aDocument.BroadcastUno( SfxHint( SfxHintId::DataChanged ) );
2995 }
2996 
3004 {
3005  bool bUpdate = !IsModified();
3006 
3007  SetModified();
3008 
3009  SfxBindings* pBindings = GetViewBindings();
3010  if (bUpdate && pBindings)
3011  {
3012  pBindings->Invalidate( SID_SAVEDOC );
3013  pBindings->Invalidate( SID_DOC_MODIFIED );
3014  }
3015 
3016  if (pBindings)
3017  {
3018  // #i105960# Undo etc used to be volatile.
3019  // They always have to be invalidated, including drawing layer or row height changes
3020  // (but not while pPaintLockData is set).
3021  pBindings->Invalidate( SID_UNDO );
3022  pBindings->Invalidate( SID_REDO );
3023  pBindings->Invalidate( SID_REPEAT );
3024  }
3025 
3027  {
3029  SfxGetpApp()->Broadcast(SfxHint( SfxHintId::ScDrawChanged )); // Navigator
3030  }
3031  SC_MOD()->AnythingChanged();
3032 }
3033 
3034 void ScDocShell::SetInUndo(bool bSet)
3035 {
3036  m_bIsInUndo = bSet;
3037 }
3038 
3040 {
3041  SfxPrinter* pPrinter = GetPrinter();
3042 
3043  m_aDocument.GetDocStat( rDocStat );
3044  rDocStat.nPageCount = 0;
3045 
3046  if ( pPrinter )
3047  for ( SCTAB i=0; i<rDocStat.nTableCount; i++ )
3048  rDocStat.nPageCount = sal::static_int_cast<sal_uInt16>( rDocStat.nPageCount +
3049  static_cast<sal_uInt16>(ScPrintFunc( this, pPrinter, i ).GetTotalPages()) );
3050 }
3051 
3052 std::shared_ptr<SfxDocumentInfoDialog> ScDocShell::CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet)
3053 {
3054  std::shared_ptr<SfxDocumentInfoDialog> xDlg = std::make_shared<SfxDocumentInfoDialog>(pParent, rSet);
3055  ScDocShell* pDocSh = dynamic_cast< ScDocShell *>( SfxObjectShell::Current() );
3056 
3057  // Only for statistics, if this Doc is shown; not from the Doc Manager
3058  if( pDocSh == this )
3059  {
3061  ::CreateTabPage ScDocStatPageCreate = pFact->GetTabPageCreatorFunc(SID_SC_TP_STAT);
3062  OSL_ENSURE(ScDocStatPageCreate, "Tabpage create fail!");
3063  xDlg->AddFontTabPage();
3064  xDlg->AddTabPage("calcstats", ScResId(STR_DOC_STAT), ScDocStatPageCreate);
3065  }
3066  return xDlg;
3067 }
3068 
3070 {
3072  if ( pViewSh )
3073  return pViewSh->GetDialogParent();
3075 }
3076 
3077 void ScDocShell::SetSolverSaveData( std::unique_ptr<ScOptSolverSave> pData )
3078 {
3079  m_pSolverSaveData = std::move(pData);
3080 }
3081 
3083 {
3084  if (!m_pSheetSaveData)
3085  m_pSheetSaveData.reset( new ScSheetSaveData );
3086 
3087  return m_pSheetSaveData.get();
3088 }
3089 
3091 {
3092  if (!m_pFormatSaveData)
3093  m_pFormatSaveData.reset( new ScFormatSaveData );
3094 
3095  return m_pFormatSaveData.get();
3096 }
3097 
3098 namespace {
3099 
3100 void removeKeysIfExists(const Reference<ui::XAcceleratorConfiguration>& xScAccel, const vector<const awt::KeyEvent*>& rKeys)
3101 {
3102  for (const awt::KeyEvent* p : rKeys)
3103  {
3104  if (!p)
3105  continue;
3106 
3107  try
3108  {
3109  xScAccel->removeKeyEvent(*p);
3110  }
3111  catch (const container::NoSuchElementException&) {}
3112  }
3113 }
3114 
3115 }
3116 
3118 {
3119  using namespace ::com::sun::star::ui;
3120 
3121  Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
3122  if (!xContext.is())
3123  return;
3124 
3125  Reference<XModuleUIConfigurationManagerSupplier> xModuleCfgSupplier(
3126  theModuleUIConfigurationManagerSupplier::get(xContext) );
3127 
3128  // Grab the Calc configuration.
3129  Reference<XUIConfigurationManager> xConfigMgr =
3130  xModuleCfgSupplier->getUIConfigurationManager(
3131  "com.sun.star.sheet.SpreadsheetDocument");
3132 
3133  if (!xConfigMgr.is())
3134  return;
3135 
3136  // shortcut manager
3137  Reference<XAcceleratorConfiguration> xScAccel = xConfigMgr->getShortCutManager();
3138 
3139  if (!xScAccel.is())
3140  return;
3141 
3142  vector<const awt::KeyEvent*> aKeys;
3143  aKeys.reserve(9);
3144 
3145  // Backspace key
3146  awt::KeyEvent aBackspace;
3147  aBackspace.KeyCode = awt::Key::BACKSPACE;
3148  aBackspace.Modifiers = 0;
3149  aKeys.push_back(&aBackspace);
3150 
3151  // Delete key
3152  awt::KeyEvent aDelete;
3153  aDelete.KeyCode = awt::Key::DELETE;
3154  aDelete.Modifiers = 0;
3155  aKeys.push_back(&aDelete);
3156 
3157  // Ctrl-D
3158  awt::KeyEvent aCtrlD;
3159  aCtrlD.KeyCode = awt::Key::D;
3160  aCtrlD.Modifiers = awt::KeyModifier::MOD1;
3161  aKeys.push_back(&aCtrlD);
3162 
3163  // Alt-Down
3164  awt::KeyEvent aAltDown;
3165  aAltDown.KeyCode = awt::Key::DOWN;
3166  aAltDown.Modifiers = awt::KeyModifier::MOD2;
3167  aKeys.push_back(&aAltDown);
3168 
3169  // Ctrl-Space
3170  awt::KeyEvent aCtrlSpace;
3171  aCtrlSpace.KeyCode = awt::Key::SPACE;
3172  aCtrlSpace.Modifiers = awt::KeyModifier::MOD1;
3173  aKeys.push_back(&aCtrlSpace);
3174 
3175  // Ctrl-Shift-Space
3176  awt::KeyEvent aCtrlShiftSpace;
3177  aCtrlShiftSpace.KeyCode = awt::Key::SPACE;
3178  aCtrlShiftSpace.Modifiers = awt::KeyModifier::MOD1 | awt::KeyModifier::SHIFT;
3179  aKeys.push_back(&aCtrlShiftSpace);
3180 
3181  // F4
3182  awt::KeyEvent aF4;
3183  aF4.KeyCode = awt::Key::F4;
3184  aF4.Modifiers = 0;
3185  aKeys.push_back(&aF4);
3186 
3187  // CTRL+SHIFT+F4
3188  awt::KeyEvent aCtrlShiftF4;
3189  aCtrlShiftF4.KeyCode = awt::Key::F4;
3190  aCtrlShiftF4.Modifiers = awt::KeyModifier::MOD1 | awt::KeyModifier::SHIFT;
3191  aKeys.push_back(&aCtrlShiftF4);
3192 
3193  // SHIFT+F4
3194  awt::KeyEvent aShiftF4;
3195  aShiftF4.KeyCode = awt::Key::F4;
3196  aShiftF4.Modifiers = awt::KeyModifier::SHIFT;
3197  aKeys.push_back(&aShiftF4);
3198 
3199  // Remove all involved keys first, because swapping commands don't work
3200  // well without doing this.
3201  removeKeysIfExists(xScAccel, aKeys);
3202  xScAccel->store();
3203 
3204  switch (eType)
3205  {
3207  xScAccel->setKeyEvent(aDelete, ".uno:ClearContents");
3208  xScAccel->setKeyEvent(aBackspace, ".uno:Delete");
3209  xScAccel->setKeyEvent(aCtrlD, ".uno:FillDown");
3210  xScAccel->setKeyEvent(aAltDown, ".uno:DataSelect");
3211  xScAccel->setKeyEvent(aCtrlSpace, ".uno:SelectColumn");
3212  xScAccel->setKeyEvent(aCtrlShiftSpace, ".uno:SelectAll");
3213  xScAccel->setKeyEvent(aF4, ".uno:ToggleRelative");
3214  xScAccel->setKeyEvent(aCtrlShiftF4, ".uno:ViewDataSourceBrowser");
3215  break;
3217  xScAccel->setKeyEvent(aDelete, ".uno:Delete");
3218  xScAccel->setKeyEvent(aBackspace, ".uno:ClearContents");
3219  xScAccel->setKeyEvent(aCtrlD, ".uno:DataSelect");
3220  xScAccel->setKeyEvent(aCtrlShiftSpace, ".uno:SelectColumn");
3221  xScAccel->setKeyEvent(aF4, ".uno:ViewDataSourceBrowser");
3222  xScAccel->setKeyEvent(aShiftF4, ".uno:ToggleRelative");
3223  break;
3224  default:
3225  ;
3226  }
3227 
3228  xScAccel->store();
3229 }
3230 
3232 {
3233  if (!m_pSheetSaveData)
3234  return;
3235 
3236  m_pSheetSaveData->UseSaveEntries(); // use positions from saved file for next saving
3237 
3238  bool bHasEntries = false;
3239  SCTAB nTabCount = m_aDocument.GetTableCount();
3240  SCTAB nTab;
3241  for (nTab = 0; nTab < nTabCount; ++nTab)
3242  if (m_pSheetSaveData->HasStreamPos(nTab))
3243  bHasEntries = true;
3244 
3245  if (!bHasEntries)
3246  {
3247  // if no positions were set (for example, export to other format),
3248  // reset all "valid" flags
3249  for (nTab = 0; nTab < nTabCount; ++nTab)
3250  m_aDocument.SetStreamValid(nTab, false);
3251  }
3252 }
3253 
3254 // --- ScDocShellModificator ------------------------------------------
3255 
3257  :
3258  rDocShell( rDS ),
3259  mpProtector(new ScRefreshTimerProtector(rDS.GetDocument().GetRefreshTimerControlAddress()))
3260 {
3261  ScDocument& rDoc = rDocShell.GetDocument();
3263  bIdleEnabled = rDoc.IsIdleEnabled();
3264  rDoc.SetAutoCalcShellDisabled( true );
3265  rDoc.EnableIdle(false);
3266 }
3267 
3269 {
3270  ScDocument& rDoc = rDocShell.GetDocument();
3273  rDocShell.SetDocumentModified(); // last one shuts off the lights
3274  rDoc.EnableIdle(bIdleEnabled);
3275 }
3276 
3278 {
3279  ScDocument& rDoc = rDocShell.GetDocument();
3280  rDoc.PrepareFormulaCalc();
3281  if ( !rDoc.IsImportingXML() )
3282  {
3283  // temporarily restore AutoCalcShellDisabled
3284  bool bDisabled = rDoc.IsAutoCalcShellDisabled();
3287  rDoc.SetAutoCalcShellDisabled( bDisabled );
3288  }
3289  else
3290  {
3291  // uno broadcast is necessary for api to work
3292  // -> must also be done during xml import
3293  rDoc.BroadcastUno( SfxHint( SfxHintId::DataChanged ) );
3294  }
3295 }
3296 
3298 {
3299  ScChangeTrack* pChangeTrack = m_aDocument.GetChangeTrack();
3300  return pChangeTrack != nullptr;
3301 }
3302 
3304 {
3305  bool bRes = false;
3306  ScChangeTrack* pChangeTrack = m_aDocument.GetChangeTrack();
3307  if (pChangeTrack)
3308  bRes = pChangeTrack->IsProtected();
3309  return bRes;
3310 }
3311 
3312 void ScDocShell::SetChangeRecording( bool bActivate, bool /*bLockAllViews*/ )
3313 {
3314  bool bOldChangeRecording = IsChangeRecording();
3315 
3316  if (bActivate)
3317  {
3319  ScChangeViewSettings aChangeViewSet;
3320  aChangeViewSet.SetShowChanges(true);
3321  m_aDocument.SetChangeViewSettings(aChangeViewSet);
3322  }
3323  else
3324  {
3326  PostPaintGridAll();
3327  }
3328 
3329  if (bOldChangeRecording != IsChangeRecording())
3330  {
3332  // invalidate slots
3333  SfxBindings* pBindings = GetViewBindings();
3334  if (pBindings)
3335  pBindings->InvalidateAll(false);
3336  }
3337 }
3338 
3339 void ScDocShell::SetProtectionPassword( const OUString &rNewPassword )
3340 {
3341  ScChangeTrack* pChangeTrack = m_aDocument.GetChangeTrack();
3342  if (!pChangeTrack)
3343  return;
3344 
3345  bool bProtected = pChangeTrack->IsProtected();
3346 
3347  if (!rNewPassword.isEmpty())
3348  {
3349  // when password protection is applied change tracking must always be active
3350  SetChangeRecording( true );
3351 
3352  css::uno::Sequence< sal_Int8 > aProtectionHash;
3353  SvPasswordHelper::GetHashPassword( aProtectionHash, rNewPassword );
3354  pChangeTrack->SetProtection( aProtectionHash );
3355  }
3356  else
3357  {
3358  pChangeTrack->SetProtection( css::uno::Sequence< sal_Int8 >() );
3359  }
3360 
3361  if ( bProtected != pChangeTrack->IsProtected() )
3362  {
3365  }
3366 }
3367 
3368 bool ScDocShell::GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash )
3369 {
3370  bool bRes = false;
3371  ScChangeTrack* pChangeTrack = m_aDocument.GetChangeTrack();
3372  if (pChangeTrack && pChangeTrack->IsProtected())
3373  {
3374  rPasswordHash = pChangeTrack->GetProtection();
3375  bRes = true;
3376  }
3377  return bRes;
3378 }
3379 
3381 {
3382  m_bUcalcTest = true;
3383 }
3384 
3385 void ScDocShell::RegisterAutomationWorkbookObject(css::uno::Reference< ooo::vba::excel::XWorkbook > const& xWorkbook)
3386 {
3387  mxAutomationWorkbookObject = xWorkbook;
3388 }
3389 
3390 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportSLK(SvStream &rStream)
3391 {
3392  ScDLL::Init();
3394  ScDocOptions aDocOpt = aDocument.GetDocOptions();
3395  aDocOpt.SetLookUpColRowNames(false);
3396  aDocument.SetDocOptions(aDocOpt);
3397  aDocument.MakeTable(0);
3398  aDocument.EnableExecuteLink(false);
3399  aDocument.SetInsertingFromOtherDoc(true);
3400  aDocument.SetImportingXML(true);
3401 
3402  ScImportExport aImpEx(aDocument);
3403  return aImpEx.ImportStream(rStream, OUString(), SotClipboardFormatId::SYLK);
3404 }
3405 
3406 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDBF(SvStream &rStream)
3407 {
3408  ScDLL::Init();
3409 
3410  // we need a real file for this filter
3411 
3412  // put it in an empty dir
3413  utl::TempFile aTmpDir(nullptr, true);
3414  aTmpDir.EnableKillingFile();
3415  OUString sTmpDir = aTmpDir.GetURL();
3416 
3417  OUString sExtension(".dbf");
3418  utl::TempFile aTempInput(OUString(), true, &sExtension, &sTmpDir);
3419  aTempInput.EnableKillingFile();
3420 
3421  SvStream* pInputStream = aTempInput.GetStream(StreamMode::WRITE);
3422  sal_uInt8 aBuffer[8192];
3423  while (auto nRead = rStream.ReadBytes(aBuffer, SAL_N_ELEMENTS(aBuffer)))
3424  pInputStream->WriteBytes(aBuffer, nRead);
3425  aTempInput.CloseStream();
3426 
3427  SfxMedium aMedium(aTempInput.GetURL(), StreamMode::STD_READWRITE);
3428 
3429  ScDocShellRef xDocShell = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT |
3430  SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS |
3431  SfxModelFlags::DISABLE_DOCUMENT_RECOVERY);
3432 
3433  xDocShell->DoInitNew();
3434 
3435  ScDocument& rDoc = xDocShell->GetDocument();
3436 
3437  ScDocOptions aDocOpt = rDoc.GetDocOptions();
3438  aDocOpt.SetLookUpColRowNames(false);
3439  rDoc.SetDocOptions(aDocOpt);
3440  rDoc.MakeTable(0);
3441  rDoc.EnableExecuteLink(false);
3442  rDoc.SetInsertingFromOtherDoc(true);
3443 
3444  ScDocRowHeightUpdater::TabRanges aRecalcRanges(0, rDoc.MaxRow());
3445  std::map<SCCOL, ScColWidthParam> aColWidthParam;
3446  ErrCode eError = xDocShell->DBaseImport(aMedium.GetPhysicalName(), RTL_TEXTENCODING_IBM_850, aColWidthParam, aRecalcRanges.maRanges);
3447 
3448  xDocShell->DoClose();
3449  xDocShell.clear();
3450 
3451  return eError == ERRCODE_NONE;
3452 }
3453 
3454 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3109
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:2137
SvxCellHorJustify
OUString GetText(LineEnd eEnd=LINEEND_LF) const
bool HasExternalRefManager() const
Definition: document.hxx:1008
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:2797
sal_Int32 nIndex
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
Definition: document.hxx:820
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:271
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:204
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
Definition: docsh3.cxx:451
const sc::ImportPostProcessData & GetImportPostProcessData() const
Definition: xmlwrap.hxx:91
ScRefCellValue * GetNext(SCCOL &rCol, SCROW &rRow)
Definition: dociter.cxx:2133
#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:2329
SC_DLLPUBLIC size_t GetCount() const
Definition: dpobject.cxx:3678
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
OUString GetFormula(const formula::FormulaGrammar::Grammar=formula::FormulaGrammar::GRAM_DEFAULT, const ScInterpreterContext *pContext=nullptr) const
std::unique_ptr< ScRefreshTimerControl > const & GetRefreshTimerControlAddress() const
Definition: document.hxx:2437
SC_DLLPUBLIC void SetChangeViewSettings(const ScChangeViewSettings &rNew)
Definition: documen2.cxx:1115
virtual bool Load(SfxMedium &rMedium)
bool HasSharedXMLFlagSet() const
void RegisterAutomationWorkbookObject(css::uno::Reference< ooo::vba::excel::XWorkbook > const &xWorkbook)
Definition: docsh.cxx:3385
SfxObjectShell * GetObjectShell() const
bool HasAddError() const
Definition: detdata.hxx:78
ScFormatSaveData * GetFormatSaveData()
Definition: docsh.cxx:3090
std::string GetValue
const css::uno::Reference< css::script::vba::XVBAEventProcessor > & GetVbaEventProcessor() const
Definition: document.hxx:2454
static weld::Window * GetActiveDialogParent()
Definition: docsh.cxx:3069
SAL_DLLPUBLIC_EXPORT bool TestImportSLK(SvStream &rStream)
Definition: docsh.cxx:3390
int SetError()
SfxBindings * GetViewBindings()
Definition: docsh4.cxx:2614
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:1123
RET_RETRY
virtual void SetModified(bool bModified=true)
ScDetOpList * GetDetOpList() const
Definition: document.hxx:1782
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
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
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:2812
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:3052
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:2939
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:3077
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:2585
SAL_DLLPRIVATE void DoEnterHandler()
Definition: docsh.cxx:208
virtual bool SaveAs(SfxMedium &rMedium)
static OUString GetHtmlFilterName()
Definition: docsh.cxx:2802
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:148
static OUString GetCharsetString(rtl_TextEncoding eVal)
Definition: global.cxx:581
void Invalidate(sal_uInt16 nId)
sc::DocumentLinkManager & GetDocLinkManager()
Definition: documen2.cxx:229
SC_DLLPUBLIC SfxUndoManager * GetUndoManager()
Definition: document.cxx:6390
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:2807
RET_CANCEL
bool ImportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
Definition: impex.cxx:382
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:3268
virtual bool ConvertTo(SfxMedium &rMedium) override
Definition: docsh.cxx:2335
SfxApplication * SfxGetpApp()
virtual ScOrcusFilters * GetOrcusFilters()=0
virtual bool HasChangeRecordProtection() const override
Definition: docsh.cxx:3303
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:577
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2925
RET_NO
OUString CreateNewName() const
Create a new name that's not yet used by any existing data pilot objects.
Definition: dpobject.cxx:3704
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()
constexpr OUStringLiteral SC_TEXT_CSV_FILTER_NAME
Definition: global.hxx:62
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:3117
static weld::Window * GetDefDialogParent()
void SetText(const OUString &rStr)
void InvalidateStyleSheetUsage()
Definition: document.hxx:2448
virtual ~ScDocShell() override
Definition: docsh.cxx:2891
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:878
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:627
bool IsAutoCalcShellDisabled() const
Definition: document.hxx:1369
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:3231
static std::shared_ptr< ConfigurationChanges > create(css::uno::Reference< css::uno::XComponentContext > const &context=comphelper::getProcessComponentContext())
std::unique_ptr< DataStream > mpDataStream
static OUString GetString(const ScRefCellValue &rCell, sal_uInt32 nFormat, const Color **ppColor, SvNumberFormatter &rFormatter, const ScDocument &rDoc, bool bNullVals=true, bool bFormula=false, bool bUseStarFormat=false)
Definition: cellform.cxx:32
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:337
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:2469
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:366
void MarkUsedExternalReferences()
Definition: documen3.cxx:641
virtual bool importExcel2003XML(ScDocument &rDoc, SfxMedium &rMedium) const =0
ScViewData & GetViewData()
Definition: tabview.hxx:333
static ScDocument * GetClipDoc()
Definition: scmod.cxx:615
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2411
#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:4733
bool IsDocumentModifiedPending() const
Definition: docsh.hxx:381
const css::uno::Sequence< sal_Int8 > & GetProtection() const
Definition: chgtrack.hxx:1125
SfxItemPool & GetPool() const
void SetInsertingFromOtherDoc(bool bVal)
Definition: document.hxx:2152
#define SCWARN_IMPORT_CELL_OVERFLOW
Definition: scerrors.hxx:65
void SetError(ErrCode nError)
bool IsProtected() const
Definition: chgtrack.hxx:1127
OutputDevice * GetDevice() const
Definition: sizedev.hxx:40
void SetIsInUcalc()
Definition: docsh.cxx:3380
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:2698
#define SAL_N_ELEMENTS(arr)
void SetName(const OUString &rNew)
Definition: dpobject.cxx:490
DocumentType eType
ScSheetSaveData * GetSheetSaveData()
Definition: docsh.cxx:3082
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1947
static bool HasAutomaticTableName(std::u16string_view rFilter)
Definition: docsh.cxx:2832
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:442
#define SOFFICE_FILEFORMAT_60
std::unique_ptr< ScAutoStyleList > m_pAutoStyleList
Definition: docsh.hxx:104
bool IsChartListenerCollectionNeedsUpdate() const
Definition: document.hxx:2168
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:334
bool IsImportingXML() const
Definition: document.hxx:2156
void EnableExecuteLink(bool bVal)
Definition: document.hxx:1549
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:2817
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:569
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:1372
virtual bool LoadFrom(SfxMedium &rMedium)
const OUString & GetValue() const
void RemoveDdeTopic(SfxObjectShell const *)
::tools::Long nLastColWidthExtra
Definition: global.hxx:577
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:2744
bool hasExternalData() const
float u
bool IsDetectiveDirty() const
Definition: document.hxx:2139
virtual bool Save() override
Definition: docsh.cxx:1715
OUString GetBaseURL(bool bForSaving=false)
#define BCA_BRDCST_ALWAYS
Definition: address.hxx:958
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:952
SCTAB nTableCount
Definition: document.hxx:279
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:728
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:422
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:282
SAL_DLLPRIVATE std::unique_ptr< ScDocFunc > CreateDocFunc()
Definition: docsh.cxx:2848
virtual bool IsChangeRecording() const override
Definition: docsh.cxx:3297
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:3368
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:147
const PropertyValue * pValues
std::unique_ptr< ScOptSolverSave > m_pSolverSaveData
Definition: docsh.hxx:106
void SetInUndo(bool bSet)
Definition: docsh.cxx:3034
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)
static OUString GetInputString(const ScRefCellValue &rCell, sal_uInt32 nFormat, SvNumberFormatter &rFormatter, const ScDocument &rDoc, const svl::SharedString **pShared=nullptr, bool bFiltering=false)
Definition: cellform.cxx:130
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:323
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:268
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:637
bool m_bHeaderOn
Definition: docsh.hxx:90
void UpdateAcceptChangesDialog()
Definition: docsh4.cxx:1372
void SetDetectiveDirty(bool bSet)
Definition: document.hxx:2140
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:2370
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:2822
std::unique_ptr< DocShell_Impl > m_pImpl
Definition: docsh.hxx:87
void * p
Reference< XComponentContext > getProcessComponentContext()
SC_DLLPUBLIC ScChartListenerCollection * GetChartListenerCollection() const
Definition: document.hxx:2162
static SC_DLLPUBLIC double nScreenPPTX
Horizontal pixel per twips factor.
Definition: global.hxx:567
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:1368
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:6080
static rtl_TextEncoding GetCharsetValue(const OUString &rCharSet)
Definition: global.cxx:553
virtual void SetProtectionPassword(const OUString &rPassword) override
Definition: docsh.cxx:3339
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:320
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:640
bool IsEnableSetModified() const
void SetDocumentModified()
Definition: docsh.cxx:3277
SAL_DLLPUBLIC_EXPORT bool TestImportDBF(SvStream &rStream)
Definition: docsh.cxx:3406
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:370
#define ERRCODE_ABORT
virtual bool QuerySlotExecutable(sal_uInt16 nSlotId) override
Definition: docsh.cxx:2707
OUString BuildString() const
Definition: imoptdlg.cxx:99
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
virtual void SetModified(bool=true) override
Definition: docsh.cxx:2930
void GetDocStat(ScDocStat &rDocStat)
Definition: docsh.cxx:3039
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:3003
void setDataStream(DataStream *p)
ScDocFunc & GetDocFunc()
Definition: docsh.hxx:222
SC_DLLPUBLIC void MakeTable(SCTAB nTab, bool _bNeedsNameCheck=true)
Definition: document.cxx:168
ScTabViewShell * GetBestViewShell(bool bOnlyVisible=true)
Definition: docsh4.cxx:2595
bool m_bIsInplace
Definition: docsh.hxx:92
void StartChangeTracking()
Definition: documen2.cxx:265
void SetDocumentModifiedPending(bool bVal)
Definition: docsh.hxx:379
SC_DLLPUBLIC void SetExtDocOptions(std::unique_ptr< ScExtDocOptions > pNewOptions)
Definition: documen3.cxx:2026
void SetFilterOptions(const OUString &rFilterOptions)
Definition: impex.cxx:217
SvStream * GetStream(StreamMode eMode)
void UpdateLayerLocks()
Definition: tabview5.cxx:356
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: document.cxx:4139
virtual void SetChangeRecording(bool bActivate, bool bLockAllViews=false) override
Definition: docsh.cxx:3312
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:2136
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:6256
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:301
void EnableKillingFile(bool bEnable=true)
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
Definition: documen2.cxx:458
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:1366
std::size_t write_uInt16s_FromOUString(SvStream &rStrm, std::u16string_view rStr, std::size_t nUnits)
static OUString GetDifFilterName()
Definition: docsh.cxx:2827
SC_DLLPUBLIC sal_uInt32 GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3663
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