LibreOffice Module sc (master)  1
excel.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 <sfx2/docfile.hxx>
21 #include <sfx2/frame.hxx>
22 #include <sfx2/sfxsids.hrc>
23 #include <sot/storage.hxx>
24 #include <sot/exchange.hxx>
26 #include <tools/globname.hxx>
27 #include <com/sun/star/packages/XPackageEncryption.hpp>
28 #include <com/sun/star/ucb/ContentCreationException.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <unotools/streamwrap.hxx>
32 #include <unotools/wincodepage.hxx>
33 #include <osl/diagnose.h>
34 #include <filter.hxx>
35 #include <document.hxx>
36 #include <xistream.hxx>
37 #include <xltools.hxx>
38 #include <docoptio.hxx>
41 
42 #include <docsh.hxx>
43 #include <scerrors.hxx>
44 #include <imp_op.hxx>
45 #include <excimp8.hxx>
46 #include <exp_op.hxx>
47 #include <scdll.hxx>
48 
49 #include <memory>
50 
51 using namespace css;
52 
53 static void lcl_getListOfStreams(SotStorage * pStorage, comphelper::SequenceAsHashMap& aStreamsData, const OUString& sPrefix)
54 {
55  SvStorageInfoList aElements;
56  pStorage->FillInfoList(&aElements);
57  for (const auto & aElement : aElements)
58  {
59  OUString sStreamFullName = sPrefix.getLength() ? sPrefix + "/" + aElement.GetName() : aElement.GetName();
60  if (aElement.IsStorage())
61  {
62  tools::SvRef<SotStorage> xSubStorage = pStorage->OpenSotStorage(aElement.GetName(), StreamMode::STD_READ | StreamMode::SHARE_DENYALL);
63  lcl_getListOfStreams(xSubStorage.get(), aStreamsData, sStreamFullName);
64  }
65  else
66  {
67  // Read stream
68  tools::SvRef<SotStorageStream> rStream = pStorage->OpenSotStream(aElement.GetName(), StreamMode::READ | StreamMode::SHARE_DENYALL);
69  if (rStream.is())
70  {
71  sal_Int32 nStreamSize = rStream->GetSize();
72  uno::Sequence< sal_Int8 > oData;
73  oData.realloc(nStreamSize);
74  sal_Int32 nReadBytes = rStream->ReadBytes(oData.getArray(), nStreamSize);
75  if (nStreamSize == nReadBytes)
76  aStreamsData[sStreamFullName] <<= oData;
77  }
78  }
79  }
80 }
81 
82 static tools::SvRef<SotStorage> lcl_DRMDecrypt(SfxMedium& rMedium, tools::SvRef<SotStorage>& rStorage, std::shared_ptr<SvStream>& rNewStorageStrm)
83 {
84  tools::SvRef<SotStorage> aNewStorage;
85 
86  // We have DRM encrypted storage. We should try to decrypt it first, if we can
87  uno::Sequence< uno::Any > aArguments;
88  uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
89  uno::Reference< packages::XPackageEncryption > xPackageEncryption(
90  xComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext(
91  "com.sun.star.comp.oox.crypto.DRMDataSpace", aArguments, xComponentContext), uno::UNO_QUERY);
92 
93  if (!xPackageEncryption.is())
94  {
95  // We do not know how to decrypt this
96  return aNewStorage;
97  }
98 
99  comphelper::SequenceAsHashMap aStreamsData;
100  lcl_getListOfStreams(rStorage.get(), aStreamsData, "");
101 
102  try {
103  uno::Sequence<beans::NamedValue> aStreams = aStreamsData.getAsConstNamedValueList();
104  if (!xPackageEncryption->readEncryptionInfo(aStreams))
105  {
106  // We failed with decryption
107  return aNewStorage;
108  }
109 
110  tools::SvRef<SotStorageStream> rContentStream = rStorage->OpenSotStream("\011DRMContent", StreamMode::READ | StreamMode::SHARE_DENYALL);
111  if (!rContentStream.is())
112  {
113  return aNewStorage;
114  }
115 
116  rNewStorageStrm = std::make_shared<SvMemoryStream>();
117 
118  uno::Reference<io::XInputStream > xInputStream(new utl::OSeekableInputStreamWrapper(rContentStream.get(), false));
119  uno::Reference<io::XOutputStream > xDecryptedStream(new utl::OSeekableOutputStreamWrapper(*rNewStorageStrm));
120 
121  if (!xPackageEncryption->decrypt(xInputStream, xDecryptedStream))
122  {
123  // We failed with decryption
124  return aNewStorage;
125  }
126 
127  rNewStorageStrm->Seek(0);
128 
129  // Further reading is done from new document
130  aNewStorage = new SotStorage(*rNewStorageStrm);
131 
132  // Set the media descriptor data
133  uno::Sequence<beans::NamedValue> aEncryptionData = xPackageEncryption->createEncryptionData("");
134  rMedium.GetItemSet()->Put(SfxUnoAnyItem(SID_ENCRYPTIONDATA, uno::makeAny(aEncryptionData)));
135  }
136  catch (const std::exception&)
137  {
138  return aNewStorage;
139  }
140 
141  return aNewStorage;
142 }
143 
145 {
146  // check the passed Calc document
147  OSL_ENSURE( pDocument, "::ScImportExcel - no document" );
148  if( !pDocument ) return SCERR_IMPORT_INTERNAL; // should not happen
149 
150  /* Import all BIFF versions regardless on eFormat, needed for import of
151  external cells (file type detection returns Excel4.0). */
152  if( (eFormat != EIF_AUTO) && (eFormat != EIF_BIFF_LE4) && (eFormat != EIF_BIFF5) && (eFormat != EIF_BIFF8) )
153  {
154  OSL_FAIL( "::ScImportExcel - wrong file format specification" );
155  return SCERR_IMPORT_FORMAT;
156  }
157 
158  // check the input stream from medium
159  SvStream* pMedStrm = rMedium.GetInStream();
160  OSL_ENSURE( pMedStrm, "::ScImportExcel - medium without input stream" );
161  if( !pMedStrm ) return SCERR_IMPORT_OPEN; // should not happen
162 
163  SvStream* pBookStrm = nullptr; // The "Book"/"Workbook" stream containing main data.
164  XclBiff eBiff = EXC_BIFF_UNKNOWN; // The BIFF version of the main stream.
165 
166  // try to open an OLE storage
167  tools::SvRef<SotStorage> xRootStrg;
169  std::shared_ptr<SvStream> aNewStorageStrm;
170  if( SotStorage::IsStorageFile( pMedStrm ) )
171  {
172  xRootStrg = new SotStorage( pMedStrm, false );
173  if( xRootStrg->GetError() )
174  xRootStrg = nullptr;
175  }
176 
177  // try to open "Book" or "Workbook" stream in OLE storage
178  if( xRootStrg.is() )
179  {
180  // Check if there is DRM encryption in storage
181  tools::SvRef<SotStorageStream> xDRMStrm = ScfTools::OpenStorageStreamRead(xRootStrg, "\011DRMContent");
182  if (xDRMStrm.is())
183  {
184  xRootStrg = lcl_DRMDecrypt(rMedium, xRootStrg, aNewStorageStrm);
185  }
186 
187  // try to open the "Book" stream
189  XclBiff eBookBiff = xBookStrm.is() ? XclImpStream::DetectBiffVersion( *xBookStrm ) : EXC_BIFF_UNKNOWN;
190 
191  // try to open the "Workbook" stream
193  XclBiff eWorkbookBiff = xWorkbookStrm.is() ? XclImpStream::DetectBiffVersion( *xWorkbookStrm ) : EXC_BIFF_UNKNOWN;
194 
195  // decide which stream to use
196  if( (eWorkbookBiff != EXC_BIFF_UNKNOWN) && ((eBookBiff == EXC_BIFF_UNKNOWN) || (eWorkbookBiff > eBookBiff)) )
197  {
198  /* Only "Workbook" stream exists; or both streams exist,
199  and "Workbook" has higher BIFF version than "Book" stream. */
200  xStrgStrm = xWorkbookStrm;
201  eBiff = eWorkbookBiff;
202  }
203  else if( eBookBiff != EXC_BIFF_UNKNOWN )
204  {
205  /* Only "Book" stream exists; or both streams exist,
206  and "Book" has higher BIFF version than "Workbook" stream. */
207  xStrgStrm = xBookStrm;
208  eBiff = eBookBiff;
209  }
210 
211  pBookStrm = xStrgStrm.get();
212  }
213 
214  // no "Book" or "Workbook" stream found, try plain input stream from medium (even for BIFF5+)
215  if( !pBookStrm )
216  {
217  eBiff = XclImpStream::DetectBiffVersion( *pMedStrm );
218  if( eBiff != EXC_BIFF_UNKNOWN )
219  pBookStrm = pMedStrm;
220  }
221 
222  // try to import the file
224  if( pBookStrm )
225  {
226  pBookStrm->SetBufferSize( 0x8000 ); // still needed?
227 
228  XclImpRootData aImpData(
229  eBiff, rMedium, xRootStrg, *pDocument,
231  std::unique_ptr< ImportExcel > xFilter;
232  switch( eBiff )
233  {
234  case EXC_BIFF2:
235  case EXC_BIFF3:
236  case EXC_BIFF4:
237  case EXC_BIFF5:
238  xFilter.reset( new ImportExcel( aImpData, *pBookStrm ) );
239  break;
240  case EXC_BIFF8:
241  xFilter.reset( new ImportExcel8( aImpData, *pBookStrm ) );
242  break;
243  default: DBG_ERROR_BIFF();
244  }
245 
246  eRet = xFilter ? xFilter->Read() : SCERR_IMPORT_INTERNAL;
247  }
248 
249  return eRet;
250 }
251 
252 static ErrCode lcl_ExportExcelBiff( SfxMedium& rMedium, ScDocument *pDocument,
253  SvStream* pMedStrm, bool bBiff8, rtl_TextEncoding eNach )
254 {
255  uno::Reference< packages::XPackageEncryption > xPackageEncryption;
256  uno::Sequence< beans::NamedValue > aEncryptionData;
257  const SfxUnoAnyItem* pEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(rMedium.GetItemSet(), SID_ENCRYPTIONDATA, false);
258  SvStream* pOriginalMediaStrm = pMedStrm;
259  std::shared_ptr<SvStream> pMediaStrm;
260  if (pEncryptionDataItem && (pEncryptionDataItem->GetValue() >>= aEncryptionData))
261  {
262  ::comphelper::SequenceAsHashMap aHashData(aEncryptionData);
263  OUString sCryptoType = aHashData.getUnpackedValueOrDefault("CryptoType", OUString());
264 
265  if (sCryptoType.getLength())
266  {
267  uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
268  uno::Sequence<uno::Any> aArguments{
269  uno::makeAny(beans::NamedValue("Binary", uno::makeAny(true))) };
270  xPackageEncryption.set(
271  xComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext(
272  "com.sun.star.comp.oox.crypto." + sCryptoType, aArguments, xComponentContext), uno::UNO_QUERY);
273 
274  if (xPackageEncryption.is())
275  {
276  // We have an encryptor. Export document into memory stream and encrypt it later
277  pMediaStrm = std::make_shared<SvMemoryStream>();
278  pMedStrm = pMediaStrm.get();
279 
280  // Temp removal of EncryptionData to avoid password protection triggering
281  rMedium.GetItemSet()->ClearItem(SID_ENCRYPTIONDATA);
282  }
283  }
284  }
285 
286  // try to open an OLE storage
287  tools::SvRef<SotStorage> xRootStrg = new SotStorage( pMedStrm, false );
288  if( xRootStrg->GetError() ) return SCERR_IMPORT_OPEN;
289 
290  // create BIFF dependent strings
291  OUString aStrmName, aClipName, aClassName;
292  if( bBiff8 )
293  {
294  aStrmName = EXC_STREAM_WORKBOOK;
295  aClipName = "Biff8";
296  aClassName = "Microsoft Excel 97-Tabelle";
297  }
298  else
299  {
300  aStrmName = EXC_STREAM_BOOK;
301  aClipName = "Biff5";
302  aClassName = "Microsoft Excel 5.0-Tabelle";
303  }
304 
305  // open the "Book"/"Workbook" stream
306  tools::SvRef<SotStorageStream> xStrgStrm = ScfTools::OpenStorageStreamWrite( xRootStrg, aStrmName );
307  if( !xStrgStrm.is() || xStrgStrm->GetError() ) return SCERR_IMPORT_OPEN;
308 
309  xStrgStrm->SetBufferSize( 0x8000 ); // still needed?
310 
312  XclExpRootData aExpData( bBiff8 ? EXC_BIFF8 : EXC_BIFF5, rMedium, xRootStrg, *pDocument, eNach );
313  if ( bBiff8 )
314  {
315  ExportBiff8 aFilter( aExpData, *xStrgStrm );
316  eRet = aFilter.Write();
317  }
318  else
319  {
320  ExportBiff5 aFilter( aExpData, *xStrgStrm );
321  eRet = aFilter.Write();
322  }
323 
324  if( eRet == SCWARN_IMPORT_RANGE_OVERFLOW )
325  eRet = SCWARN_EXPORT_MAXROW;
326 
327  SvGlobalName aGlobName(MSO_EXCEL5_CLASSID);
329  xRootStrg->SetClass( aGlobName, nClip, aClassName );
330 
331  xStrgStrm->Commit();
332  xRootStrg->Commit();
333 
334  if (xPackageEncryption.is())
335  {
336  // Perform DRM encryption
337  pMedStrm->Seek(0);
338 
339  xPackageEncryption->setupEncryption(aEncryptionData);
340 
341  uno::Reference<io::XInputStream > xInputStream(new utl::OSeekableInputStreamWrapper(pMedStrm, false));
342  uno::Sequence<beans::NamedValue> aStreams = xPackageEncryption->encrypt(xInputStream);
343 
344  tools::SvRef<SotStorage> xEncryptedRootStrg = new SotStorage(pOriginalMediaStrm, false);
345  for (const beans::NamedValue & aStreamData : std::as_const(aStreams))
346  {
347  // To avoid long paths split and open substorages recursively
348  // Splitting paths manually, since comphelper::string::split is trimming special characters like \0x01, \0x09
349  tools::SvRef<SotStorage> pStorage = xEncryptedRootStrg.get();
350  OUString sFileName;
351  sal_Int32 idx = 0;
352  do
353  {
354  OUString sPathElem = aStreamData.Name.getToken(0, L'/', idx);
355  if (!sPathElem.isEmpty())
356  {
357  if (idx < 0)
358  {
359  sFileName = sPathElem;
360  }
361  else
362  {
363  pStorage = pStorage->OpenSotStorage(sPathElem);
364  }
365  }
366  } while (pStorage && idx >= 0);
367 
368  if (!pStorage)
369  {
370  eRet = ERRCODE_IO_GENERAL;
371  break;
372  }
373 
374  tools::SvRef<SotStorageStream> pStream = pStorage->OpenSotStream(sFileName);
375  if (!pStream)
376  {
377  eRet = ERRCODE_IO_GENERAL;
378  break;
379  }
380  uno::Sequence<sal_Int8> aStreamContent;
381  aStreamData.Value >>= aStreamContent;
382  size_t nBytesWritten = pStream->WriteBytes(aStreamContent.getArray(), aStreamContent.getLength());
383  if (nBytesWritten != static_cast<size_t>(aStreamContent.getLength()))
384  {
385  eRet = ERRCODE_IO_CANTWRITE;
386  break;
387  }
388  }
389  xEncryptedRootStrg->Commit();
390 
391  // Restore encryption data
392  rMedium.GetItemSet()->Put(SfxUnoAnyItem(SID_ENCRYPTIONDATA, uno::makeAny(aEncryptionData)));
393  }
394 
395  return eRet;
396 }
397 
399  ExportFormatExcel eFormat, rtl_TextEncoding eNach )
400 {
401  if( eFormat != ExpBiff5 && eFormat != ExpBiff8 )
402  return SCERR_IMPORT_NI;
403 
404  // check the passed Calc document
405  OSL_ENSURE( pDocument, "::ScExportExcel5 - no document" );
406  if( !pDocument ) return SCERR_IMPORT_INTERNAL; // should not happen
407 
408  // check the output stream from medium
409  SvStream* pMedStrm = rMedium.GetOutStream();
410  OSL_ENSURE( pMedStrm, "::ScExportExcel5 - medium without output stream" );
411  if( !pMedStrm ) return SCERR_IMPORT_OPEN; // should not happen
412 
413  ErrCode eRet = lcl_ExportExcelBiff(rMedium, pDocument, pMedStrm, eFormat == ExpBiff8, eNach);
414  return eRet;
415 }
416 
417 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportCalcRTF(SvStream &rStream)
418 {
419  ScDLL::Init();
421  ScDocOptions aDocOpt = aDocument.GetDocOptions();
422  aDocOpt.SetLookUpColRowNames(false);
423  aDocument.SetDocOptions(aDocOpt);
424  aDocument.MakeTable(0);
425  aDocument.EnableExecuteLink(false);
426  aDocument.SetInsertingFromOtherDoc(true);
427  ScRange aRange;
428  return ScFormatFilter::Get().ScImportRTF(rStream, OUString(), &aDocument, aRange) == ERRCODE_NONE;
429 }
430 
431 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportXLS(SvStream& rStream)
432 {
433  ScDLL::Init();
434  SfxMedium aMedium;
435  css::uno::Reference<css::io::XInputStream> xStm(new utl::OInputStreamWrapper(rStream));
436  aMedium.GetItemSet()->Put(SfxUnoAnyItem(SID_INPUTSTREAM, css::uno::makeAny(xStm)));
437 
438  ScDocShellRef xDocShell = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT |
439  SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS |
440  SfxModelFlags::DISABLE_DOCUMENT_RECOVERY);
441 
442  xDocShell->DoInitNew();
443 
444  ScDocument& rDoc = xDocShell->GetDocument();
445 
446  ScDocOptions aDocOpt = rDoc.GetDocOptions();
447  aDocOpt.SetLookUpColRowNames(false);
448  rDoc.SetDocOptions(aDocOpt);
449  rDoc.MakeTable(0);
450  rDoc.EnableExecuteLink(false);
451  rDoc.SetInsertingFromOtherDoc(true);
452  rDoc.InitDrawLayer(xDocShell.get());
453  bool bRet(false);
454  try
455  {
456  bRet = ScFormatFilter::Get().ScImportExcel(aMedium, &rDoc, EIF_AUTO) == ERRCODE_NONE;
457  }
458  catch (const css::ucb::ContentCreationException&)
459  {
460  }
461  catch (const std::out_of_range&)
462  {
463  }
464  xDocShell->DoClose();
465  xDocShell.clear();
466  return bRet;
467 }
468 
469 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDIF(SvStream &rStream)
470 {
471  ScDLL::Init();
473  ScDocOptions aDocOpt = aDocument.GetDocOptions();
474  aDocOpt.SetLookUpColRowNames(false);
475  aDocument.SetDocOptions(aDocOpt);
476  aDocument.MakeTable(0);
477  aDocument.EnableExecuteLink(false);
478  aDocument.SetInsertingFromOtherDoc(true);
479  return ScFormatFilter::Get().ScImportDif(rStream, &aDocument, ScAddress(0, 0, 0), RTL_TEXTENCODING_IBM_850) == ERRCODE_NONE;
480 }
481 
482 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool is() const
#define DBG_ERROR_BIFF()
Definition: xltools.hxx:31
std::vector< SvStorageInfo > SvStorageInfoList
static ErrCode lcl_ExportExcelBiff(SfxMedium &rMedium, ScDocument *pDocument, SvStream *pMedStrm, bool bBiff8, rtl_TextEncoding eNach)
Definition: excel.cxx:252
static SotClipboardFormatId RegisterFormatName(const OUString &rName)
XclBiff
An enumeration for all Excel file format types (BIFF types).
Definition: xlconst.hxx:30
Stores global buffers and data needed for Excel export filter.
Definition: xeroot.hxx:60
ScriptDocument aDocument
virtual ErrCode ScImportRTF(SvStream &, const OUString &rBaseURL, ScDocument *, ScRange &rRange)=0
Stores global buffers and data needed for Excel import filter.
Definition: xiroot.hxx:64
virtual ErrCode ScExportExcel5(SfxMedium &, ScDocument *, ExportFormatExcel eFormat, rtl_TextEncoding eDest) override
Definition: excel.cxx:398
void FillInfoList(SvStorageInfoList *) const
ErrCode GetError() const
virtual ErrCode ScImportExcel(SfxMedium &, ScDocument *, const EXCIMPFORMAT)=0
static tools::SvRef< SotStorageStream > OpenStorageStreamWrite(tools::SvRef< SotStorage > const &xStrg, const OUString &rStrmName)
Creates and opens a stream with the specified name in the passed storage (read/write).
Definition: ftools.cxx:185
#define SCWARN_IMPORT_RANGE_OVERFLOW
Definition: scerrors.hxx:62
sal_uInt32 GetSize() const
sal_uInt64 Seek(sal_uInt64 nPos)
static SC_DLLPUBLIC ScFormatFilterPlugin & Get()
Definition: impex.cxx:2347
css::uno::Sequence< css::beans::NamedValue > getAsConstNamedValueList() const
static bool IsStorageFile(OUString const &rFileName)
bool Commit()
#define EXC_STREAM_WORKBOOK
Definition: xlconst.hxx:84
SotStorage * OpenSotStorage(const OUString &rEleName, StreamMode=StreamMode::STD_READWRITE, bool transacted=true)
Sequence< PropertyValue > aArguments
MS Excel 4.0.
Definition: xlconst.hxx:35
MS Excel 8.0 (97), 9.0 (2000), 10.0 (XP), 11.0 (2003)
Definition: xlconst.hxx:37
rtl_TextEncoding utl_getWinTextEncodingFromLangStr(const OUString &sLanguage, bool bOEM)
#define SCERR_IMPORT_INTERNAL
Definition: scerrors.hxx:43
#define MSO_EXCEL5_CLASSID
void SetLookUpColRowNames(bool bVal)
Definition: docoptio.hxx:53
SvStream * GetOutStream()
const css::uno::Any & GetValue() const
#define ERRCODE_IO_CANTWRITE
SotClipboardFormatId
void SetInsertingFromOtherDoc(bool bVal)
Definition: document.hxx:2133
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1904
#define SCWARN_EXPORT_MAXROW
Definition: scerrors.hxx:73
#define SCERR_IMPORT_NI
Definition: scerrors.hxx:36
OUString sPrefix
T * get() const
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SC_DLLPUBLIC void InitDrawLayer(SfxObjectShell *pDocShell=nullptr)
Definition: documen9.cxx:96
MS Excel 5.0, MS Excel 7.0 (95)
Definition: xlconst.hxx:36
void EnableExecuteLink(bool bVal)
Definition: document.hxx:1539
#define ERRCODE_IO_GENERAL
SAL_DLLPUBLIC_EXPORT bool TestImportCalcRTF(SvStream &rStream)
Definition: excel.cxx:417
void SetClass(const SvGlobalName &rClass, SotClipboardFormatId bOriginalClipFormat, const OUString &rUserTypeName)
SotStorageStream * OpenSotStream(const OUString &rEleName, StreamMode=StreamMode::STD_READWRITE)
SAL_DLLPUBLIC_EXPORT bool TestImportXLS(SvStream &rStream)
Definition: excel.cxx:431
static SC_DLLPUBLIC void Init()
DLL-init/exit-code must be linked to the DLL only.
Definition: scdll.cxx:105
#define EXC_STREAM_BOOK
Definition: xlconst.hxx:83
static void lcl_getListOfStreams(SotStorage *pStorage, comphelper::SequenceAsHashMap &aStreamsData, const OUString &sPrefix)
Definition: excel.cxx:53
MS Excel 3.0.
Definition: xlconst.hxx:34
SfxItemSet * GetItemSet() const
void SetBufferSize(sal_uInt16 m_nBufSize)
SAL_DLLPUBLIC_EXPORT bool TestImportDIF(SvStream &rStream)
Definition: excel.cxx:469
static tools::SvRef< SotStorageStream > OpenStorageStreamRead(tools::SvRef< SotStorage > const &xStrg, const OUString &rStrmName)
Tries to open an existing stream with the specified name in the passed storage (read-only).
Definition: ftools.cxx:177
#define SCERR_IMPORT_OPEN
Definition: scerrors.hxx:27
const sal_uInt16 idx[]
#define SCERR_IMPORT_UNKNOWN_BIFF
Definition: scerrors.hxx:38
ExportFormatExcel
Definition: filter.hxx:43
static tools::SvRef< SotStorage > lcl_DRMDecrypt(SfxMedium &rMedium, tools::SvRef< SotStorage > &rStorage, std::shared_ptr< SvStream > &rNewStorageStrm)
Definition: excel.cxx:82
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SvStream * GetInStream()
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
Definition: documen3.cxx:1910
#define ERRCODE_NONE
EXCIMPFORMAT
Definition: filter.hxx:40
bool DoInitNew(SfxMedium *pMedium=nullptr)
Reference< XComponentContext > getProcessComponentContext()
#define SCERR_IMPORT_FORMAT
Definition: scerrors.hxx:34
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
virtual ErrCode ScImportDif(SvStream &, ScDocument *, const ScAddress &rInsPos, const rtl_TextEncoding eSrc)=0
SC_DLLPUBLIC void MakeTable(SCTAB nTab, bool _bNeedsNameCheck=true)
Definition: document.cxx:168
MS Excel 2.1.
Definition: xlconst.hxx:33
OUString utl_getLocaleForGlobalDefaultEncoding()
ErrCode Write() override
Definition: expop2.cxx:70
virtual ErrCode ScImportExcel(SfxMedium &, ScDocument *, const EXCIMPFORMAT) override
Definition: excel.cxx:144
static XclBiff DetectBiffVersion(SvStream &rStrm)
Detects the BIFF version of the passed workbook stream.
Definition: xistream.cxx:386