LibreOffice Module sc (master)  1
xmlwrap.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 <vcl/errinf.hxx>
21 #include <sfx2/docfile.hxx>
22 #include <sfx2/objsh.hxx>
23 #include <sot/storage.hxx>
24 #include <osl/diagnose.h>
25 #include <o3tl/unreachable.hxx>
26 #include <comphelper/fileformat.h>
29 #include <svx/dialmgr.hxx>
30 #include <svx/strings.hrc>
31 #include <svx/xmlgrhlp.hxx>
32 #include <svtools/sfxecode.hxx>
33 #include <sfx2/frame.hxx>
34 #include <svl/itemset.hxx>
35 #include <svl/stritem.hxx>
36 #include <sfx2/sfxsids.hrc>
37 #include <com/sun/star/container/XChild.hpp>
38 #include <com/sun/star/beans/XPropertySetInfo.hpp>
39 #include <com/sun/star/xml/sax/InputSource.hpp>
40 #include <com/sun/star/xml/sax/Parser.hpp>
41 #include <com/sun/star/xml/sax/XFastParser.hpp>
42 #include <com/sun/star/xml/sax/Writer.hpp>
43 #include <com/sun/star/xml/sax/SAXParseException.hpp>
44 #include <com/sun/star/frame/XModel.hpp>
45 #include <com/sun/star/beans/PropertyAttribute.hpp>
48 #include <com/sun/star/packages/WrongPasswordException.hpp>
49 #include <com/sun/star/packages/zip/ZipIOException.hpp>
50 #include <com/sun/star/embed/ElementModes.hpp>
51 #include <com/sun/star/script/vba/XVBACompatibility.hpp>
52 #include <com/sun/star/rdf/XDocumentMetadataAccess.hpp>
53 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
54 #include <com/sun/star/task/XStatusIndicator.hpp>
55 
58 #include <xmloff/shapeexport.hxx>
59 #include <svx/xmleohlp.hxx>
60 #include <sal/log.hxx>
61 #include <unotools/saveopt.hxx>
62 #include <tools/diagnose_ex.h>
63 
64 #include <document.hxx>
65 #include <xmlwrap.hxx>
66 #include "xmlimprt.hxx"
67 #include "xmlexprt.hxx"
68 #include <globstr.hrc>
69 #include <scresid.hxx>
70 #include <scerrors.hxx>
71 #include "XMLExportSharedData.hxx"
72 #include <docuno.hxx>
73 #include <drwlayer.hxx>
74 #include <sheetdata.hxx>
75 #include "XMLCodeNameProvider.hxx"
76 #include <docsh.hxx>
77 #include <unonames.hxx>
78 
79 using namespace com::sun::star;
80 using namespace css::uno;
81 
82 ScXMLImportWrapper::ScXMLImportWrapper( ScDocShell& rDocSh, SfxMedium* pM, const uno::Reference < embed::XStorage >& xStor ) :
83  mrDocShell(rDocSh),
84  rDoc(rDocSh.GetDocument()),
85  pMedium(pM),
86  xStorage(xStor)
87 {
88  OSL_ENSURE( pMedium || xStorage.is(), "ScXMLImportWrapper: Medium or Storage must be set" );
89 }
90 
91 uno::Reference <task::XStatusIndicator> ScXMLImportWrapper::GetStatusIndicator() const
92 {
93  uno::Reference<task::XStatusIndicator> xStatusIndicator;
94  if (pMedium)
95  {
96  SfxItemSet* pSet = pMedium->GetItemSet();
97  if (pSet)
98  {
99  const SfxUnoAnyItem* pItem = pSet->GetItem<SfxUnoAnyItem>(SID_PROGRESS_STATUSBAR_CONTROL);
100  if (pItem)
101  xStatusIndicator.set(pItem->GetValue(), uno::UNO_QUERY);
102  }
103  }
104  return xStatusIndicator;
105 }
106 
107 ErrCode ScXMLImportWrapper::ImportFromComponent(const uno::Reference<uno::XComponentContext>& xContext,
108  const uno::Reference<frame::XModel>& xModel,
109  xml::sax::InputSource& aParserInput,
110  const OUString& sComponentName, const OUString& sDocName,
111  const uno::Sequence<uno::Any>& aArgs,
112  bool bMustBeSuccessfull)
113 {
114  uno::Reference < io::XStream > xDocStream;
115  if ( !xStorage.is() && pMedium )
117 
118  bool bEncrypted = false;
119  OUString sStream(sDocName);
120  if( xStorage.is() )
121  {
122  try
123  {
124  if ( xStorage->hasByName(sDocName) && xStorage->isStreamElement( sDocName) )
125  xDocStream = xStorage->openStreamElement( sDocName, embed::ElementModes::READ );
126  else
127  return ERRCODE_NONE;
128 
129  aParserInput.aInputStream = xDocStream->getInputStream();
130  uno::Reference < beans::XPropertySet > xSet( xDocStream, uno::UNO_QUERY );
131 
132  uno::Any aAny = xSet->getPropertyValue("Encrypted");
133  aAny >>= bEncrypted;
134  }
135  catch( const packages::WrongPasswordException& )
136  {
138  }
139  catch( const packages::zip::ZipIOException& )
140  {
142  }
143  catch( const uno::Exception& )
144  {
145  return SCERR_IMPORT_UNKNOWN;
146  }
147  }
148  else
149  return SCERR_IMPORT_UNKNOWN;
150 
151  // set Base URL
152  uno::Reference< beans::XPropertySet > xInfoSet;
153  if( aArgs.hasElements() )
154  aArgs.getConstArray()[0] >>= xInfoSet;
155  OSL_ENSURE( xInfoSet.is(), "missing property set" );
156  if( xInfoSet.is() )
157  {
158  xInfoSet->setPropertyValue( "StreamName", uno::makeAny( sStream ) );
159  }
160 
161  ErrCode nReturn = ERRCODE_NONE;
162  rDoc.SetRangeOverflowType(ERRCODE_NONE); // is modified by the importer if limits are exceeded
163 
164  uno::Reference<XInterface> xImportInterface =
165  xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
166  sComponentName, aArgs, xContext );
167  SAL_WARN_IF( !xImportInterface, "sc", "can't get Calc importer " << sComponentName );
168  uno::Reference<document::XImporter> xImporter( xImportInterface, uno::UNO_QUERY );
169  if (xImporter.is())
170  xImporter->setTargetDocument( xModel );
171 
172  ScXMLImport* pImporterImpl = dynamic_cast<ScXMLImport*>(xImporter.get());
173  if (pImporterImpl)
174  pImporterImpl->SetPostProcessData(&maPostProcessData);
175 
176  // connect parser and filter
177  try
178  {
179  // xImportInterface is either ScXMLImport or an XMLTransformer subclass.
180  // ScXMLImport implements XFastParser, but XMLTransformer only implements XExtendedDocumentHandler
181 
182  uno::Reference< xml::sax::XFastParser > xFastParser(xImportInterface, uno::UNO_QUERY);
183  if (xFastParser)
184  xFastParser->parseStream( aParserInput );
185  else
186  {
187  uno::Reference<xml::sax::XParser> xParser = xml::sax::Parser::create(xContext);
188  uno::Reference<css::xml::sax::XDocumentHandler> xDocumentHandler(xImportInterface, uno::UNO_QUERY);
189  xParser->setDocumentHandler( xDocumentHandler );
190  xParser->parseStream( aParserInput );
191  }
192  }
193  catch( const xml::sax::SAXParseException& r )
194  {
195  css::uno::Any ex( cppu::getCaughtException() );
196  // sax parser sends wrapped exceptions,
197  // try to find the original one
198  xml::sax::SAXException aSaxEx = *static_cast<xml::sax::SAXException const *>(&r);
199  bool bTryChild = true;
200 
201  while( bTryChild )
202  {
203  xml::sax::SAXException aTmp;
204  if ( aSaxEx.WrappedException >>= aTmp )
205  aSaxEx = aTmp;
206  else
207  bTryChild = false;
208  }
209 
210  packages::zip::ZipIOException aBrokenPackage;
211  if ( aSaxEx.WrappedException >>= aBrokenPackage )
213  else if( bEncrypted )
214  nReturn = ERRCODE_SFX_WRONGPASSWORD;
215  else
216  {
217  SAL_WARN("sc.filter", "SAX parse exception caught while importing: " << exceptionToString(ex));
218 
219  OUString sErr = OUString::number( r.LineNumber ) +
220  "," +
221  OUString::number( r.ColumnNumber );
222 
223  if( !sDocName.isEmpty() )
224  {
225  nReturn = *new TwoStringErrorInfo(
226  (bMustBeSuccessfull ? SCERR_IMPORT_FILE_ROWCOL
228  sDocName, sErr,
229  DialogMask::ButtonsOk | DialogMask::MessageError );
230  }
231  else
232  {
233  OSL_ENSURE( bMustBeSuccessfull, "Warnings are not supported" );
234  nReturn = *new StringErrorInfo( SCERR_IMPORT_FORMAT_ROWCOL, sErr,
235  DialogMask::ButtonsOk | DialogMask::MessageError );
236  }
237  }
238  }
239  catch( const xml::sax::SAXException& r )
240  {
241  css::uno::Any ex( cppu::getCaughtException() );
242  packages::zip::ZipIOException aBrokenPackage;
243  if ( r.WrappedException >>= aBrokenPackage )
245  else if( bEncrypted )
246  nReturn = ERRCODE_SFX_WRONGPASSWORD;
247  else
248  {
249  SAL_WARN("sc.filter", "SAX exception caught while importing: " << exceptionToString(ex));
250 
251  nReturn = SCERR_IMPORT_FORMAT;
252  }
253  }
254  catch( const packages::zip::ZipIOException& )
255  {
256  TOOLS_WARN_EXCEPTION("sc.filter", "Zip exception caught while importing");
257 
258  nReturn = ERRCODE_IO_BROKENPACKAGE;
259  }
260  catch( const io::IOException& )
261  {
262  TOOLS_WARN_EXCEPTION("sc.filter", "IO exception caught while importing");
263 
264  nReturn = SCERR_IMPORT_OPEN;
265  }
266  catch( const uno::Exception& )
267  {
268  TOOLS_WARN_EXCEPTION("sc.filter", "uno exception caught while importing");
269 
270  nReturn = SCERR_IMPORT_UNKNOWN;
271  }
272 
273  // #i31130# Can't use getImplementation here to get the ScXMLImport from xDocHandler,
274  // because when OOo 1.x files are loaded, xDocHandler is the OOo2OasisTransformer.
275  // So the overflow warning ErrorCode is now stored in the document.
276  // Export works differently, there getImplementation still works.
277 
278  if (rDoc.HasRangeOverflow() && !nReturn)
279  nReturn = rDoc.GetRangeOverflowType();
280 
281  // success!
282  return nReturn;
283 }
284 
286 {
287  uno::Reference<uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
288 
289  xml::sax::InputSource aParserInput;
290  if (pMedium)
291  aParserInput.sSystemId = pMedium->GetName();
292 
293  if ( !xStorage.is() && pMedium )
295 
296  // get filter
297  uno::Reference<frame::XModel> xModel = mrDocShell.GetModel();
298 
300  comphelper::PropertyMapEntry const aImportInfoMap[] =
301  {
302  { OUString("ProgressRange"), 0, ::cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
303  { OUString("ProgressMax"), 0, ::cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
304  { OUString("ProgressCurrent"), 0, ::cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
305  { OUString("NumberStyles"), 0, cppu::UnoType<container::XNameAccess>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
306  { OUString("PrivateData"), 0, cppu::UnoType<uno::XInterface>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
307  { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
308  { OUString("StreamRelPath"), 0, ::cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
309  { OUString("StreamName"), 0, ::cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
310  { OUString("BuildId"), 0, ::cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
311  { OUString("VBACompatibilityMode"), 0, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
312  { OUString("ScriptConfiguration"), 0, cppu::UnoType<container::XNameAccess>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
313  { OUString("OrganizerMode"), 0, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
314  { OUString("SourceStorage"), 0, cppu::UnoType<embed::XStorage>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
315  { OUString(SC_UNO_ODS_LOCK_SOLAR_MUTEX), 0, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
316  { OUString(SC_UNO_ODS_IMPORT_STYLES), 0, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
317  { OUString(), 0, css::uno::Type(), 0, 0 }
318  };
319  uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aImportInfoMap ) ) );
320 
321  // No need to lock solar mutex when calling from the wrapper.
322  xInfoSet->setPropertyValue(SC_UNO_ODS_LOCK_SOLAR_MUTEX, uno::makeAny(false));
323 
324  // ---- get BuildId from parent container if available
325 
326  uno::Reference< container::XChild > xChild( xModel, uno::UNO_QUERY );
327  if( xChild.is() )
328  {
329  uno::Reference< beans::XPropertySet > xParentSet( xChild->getParent(), uno::UNO_QUERY );
330  if( xParentSet.is() )
331  {
332  uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xParentSet->getPropertySetInfo() );
333  OUString sPropName("BuildId" );
334  if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(sPropName) )
335  {
336  xInfoSet->setPropertyValue( sPropName, xParentSet->getPropertyValue(sPropName) );
337  }
338  }
339  }
340 
341  uno::Reference<task::XStatusIndicator> xStatusIndicator = GetStatusIndicator();
342  if (xStatusIndicator.is())
343  {
344  sal_Int32 nProgressRange(1000000);
345  xStatusIndicator->start(SvxResId(RID_SVXSTR_DOC_LOAD), nProgressRange);
346  xInfoSet->setPropertyValue("ProgressRange", uno::makeAny(nProgressRange));
347  }
348 
349  // Set base URI
350  OSL_ENSURE( pMedium, "There is no medium to get MediaDescriptor from!" );
351  OUString aBaseURL = pMedium ? pMedium->GetBaseURL() : OUString();
352  // needed for relative URLs, but in clipboard copy/paste there may be none
353  SAL_INFO_IF(aBaseURL.isEmpty(), "sc.filter", "ScXMLImportWrapper: no base URL");
354  OUString sPropName("BaseURI");
355  xInfoSet->setPropertyValue( sPropName, uno::makeAny( aBaseURL ) );
356 
357  // TODO/LATER: do not do it for embedded links
358  OUString aName;
359  if (SfxObjectCreateMode::EMBEDDED == mrDocShell.GetCreateMode())
360  {
361  if ( pMedium && pMedium->GetItemSet() )
362  {
363  const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
364  pMedium->GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
365  if ( pDocHierarchItem )
366  aName = pDocHierarchItem->GetValue();
367  }
368  else
369  aName = "dummyObjectName";
370 
371  if( !aName.isEmpty() )
372  {
373  sPropName = "StreamRelPath";
374  xInfoSet->setPropertyValue( sPropName, uno::makeAny( aName ) );
375  }
376  }
377 
378  if (mrDocShell.GetCreateMode() == SfxObjectCreateMode::ORGANIZER)
379  xInfoSet->setPropertyValue("OrganizerMode", uno::makeAny(true));
380 
381  xInfoSet->setPropertyValue( "SourceStorage", uno::Any( xStorage ) );
382 
384 
385  if ((nMode & ImportFlags::Metadata) && bOasis)
386  {
387  // RDF metadata: ODF >= 1.2
388  try
389  {
390  const uno::Reference< rdf::XDocumentMetadataAccess > xDMA(
391  xModel, uno::UNO_QUERY_THROW );
392  const uno::Reference< rdf::XURI > xBaseURI(
393  ::sfx2::createBaseURI( xContext, xModel, aBaseURL, aName ) );
394  uno::Reference<task::XInteractionHandler> xHandler =
396  xDMA->loadMetadataFromStorage( xStorage, xBaseURI, xHandler );
397  }
398  catch ( const lang::WrappedTargetException & e)
399  {
400  ucb::InteractiveAugmentedIOException iaioe;
401  if ( e.TargetException >>= iaioe )
402  {
403  rError = SCERR_IMPORT_UNKNOWN;
404  }
405  else
406  {
408  }
409  }
410  catch ( const uno::Exception &)
411  {
413  }
414  }
415 
416  // #i103539#: always read meta.xml for generator
417  ErrCode nMetaRetval(ERRCODE_NONE);
418  if (nMode & ImportFlags::Metadata)
419  {
420  uno::Sequence<uno::Any> aMetaArgs(1);
421  uno::Any* pMetaArgs = aMetaArgs.getArray();
422  pMetaArgs[0] <<= xInfoSet;
423 
424  SAL_INFO( "sc.filter", "meta import start" );
425 
426  nMetaRetval = ImportFromComponent(
427  xContext, xModel, aParserInput,
428  bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisMetaImporter")
429  : OUString("com.sun.star.comp.Calc.XMLMetaImporter"),
430  "meta.xml", aMetaArgs, false);
431 
432  SAL_INFO( "sc.filter", "meta import end" );
433  }
434 
435  rtl::Reference<SvXMLGraphicHelper> xGraphicHelper;
436  uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler;
437 
438  uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
440 
441  if( xStorage.is() )
442  {
443  xGraphicHelper = SvXMLGraphicHelper::Create( xStorage, SvXMLGraphicHelperMode::Read );
444  xGraphicStorageHandler = xGraphicHelper.get();
445 
446  xObjectHelper = SvXMLEmbeddedObjectHelper::Create(xStorage, mrDocShell, SvXMLEmbeddedObjectHelperMode::Read);
447  xObjectResolver = xObjectHelper.get();
448  }
449  uno::Sequence<uno::Any> aStylesArgs(4);
450  uno::Any* pStylesArgs = aStylesArgs.getArray();
451  pStylesArgs[0] <<= xInfoSet;
452  pStylesArgs[1] <<= xGraphicStorageHandler;
453  pStylesArgs[2] <<= xStatusIndicator;
454  pStylesArgs[3] <<= xObjectResolver;
455 
456  ErrCode nSettingsRetval(ERRCODE_NONE);
457  if (nMode & ImportFlags::Settings)
458  {
459  // Settings must be loaded first because of the printer setting,
460  // which is needed in the page styles (paper tray).
461 
462  uno::Sequence<uno::Any> aSettingsArgs(1);
463  uno::Any* pSettingsArgs = aSettingsArgs.getArray();
464  pSettingsArgs[0] <<= xInfoSet;
465 
466  SAL_INFO( "sc.filter", "settings import start" );
467 
468  nSettingsRetval = ImportFromComponent(
469  xContext, xModel, aParserInput,
470  bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisSettingsImporter")
471  : OUString("com.sun.star.comp.Calc.XMLSettingsImporter"),
472  "settings.xml", aSettingsArgs, false);
473 
474  SAL_INFO( "sc.filter", "settings import end" );
475  }
476 
477  ErrCode nStylesRetval(ERRCODE_NONE);
478  if (nMode & ImportFlags::Styles)
479  {
480  SAL_INFO( "sc.filter", "styles import start" );
481 
482  nStylesRetval = ImportFromComponent(xContext, xModel, aParserInput,
483  bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisStylesImporter")
484  : OUString("com.sun.star.comp.Calc.XMLStylesImporter"),
485  "styles.xml",
486  aStylesArgs, true);
487 
488  SAL_INFO( "sc.filter", "styles import end" );
489  }
490 
491  ErrCode nDocRetval(ERRCODE_NONE);
492  if (nMode & ImportFlags::Content)
493  {
494  if (mrDocShell.GetCreateMode() == SfxObjectCreateMode::INTERNAL)
495  // We only need to import content for external link cache document.
496  xInfoSet->setPropertyValue(SC_UNO_ODS_IMPORT_STYLES, uno::makeAny(false));
497 
498  uno::Sequence<uno::Any> aDocArgs(4);
499  uno::Any* pDocArgs = aDocArgs.getArray();
500  pDocArgs[0] <<= xInfoSet;
501  pDocArgs[1] <<= xGraphicStorageHandler;
502  pDocArgs[2] <<= xStatusIndicator;
503  pDocArgs[3] <<= xObjectResolver;
504 
505  SAL_INFO( "sc.filter", "content import start" );
506 
507  nDocRetval = ImportFromComponent(xContext, xModel, aParserInput,
508  bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisContentImporter")
509  : OUString("com.sun.star.comp.Calc.XMLContentImporter"),
510  "content.xml",
511  aDocArgs,
512  true);
513 
514  SAL_INFO( "sc.filter", "content import end" );
515  }
516  if( xGraphicHelper.is() )
517  xGraphicHelper->dispose();
518  xGraphicHelper.clear();
519 
520  if( xObjectHelper.is() )
521  xObjectHelper->dispose();
522  xObjectHelper.clear();
523 
524  if (xStatusIndicator.is())
525  xStatusIndicator->end();
526 
527  bool bRet = false;
528  if (nDocRetval)
529  {
530  rError = nDocRetval;
531  if (nDocRetval == SCWARN_IMPORT_RANGE_OVERFLOW ||
532  nDocRetval == SCWARN_IMPORT_ROW_OVERFLOW ||
533  nDocRetval == SCWARN_IMPORT_COLUMN_OVERFLOW ||
534  nDocRetval == SCWARN_IMPORT_SHEET_OVERFLOW)
535  bRet = true;
536  }
537  else if (nStylesRetval)
538  rError = nStylesRetval;
539  else if (nMetaRetval)
540  rError = nMetaRetval;
541  else if (nSettingsRetval)
542  rError = nSettingsRetval;
543  else
544  bRet = true;
545 
546  // set BuildId on XModel for later OLE object loading
547  if( xInfoSet.is() )
548  {
549  uno::Reference< beans::XPropertySet > xModelSet( xModel, uno::UNO_QUERY );
550  if( xModelSet.is() )
551  {
552  uno::Reference< beans::XPropertySetInfo > xModelSetInfo( xModelSet->getPropertySetInfo() );
553  OUString sBuildPropName("BuildId" );
554  if( xModelSetInfo.is() && xModelSetInfo->hasPropertyByName(sBuildPropName) )
555  {
556  xModelSet->setPropertyValue( sBuildPropName, xInfoSet->getPropertyValue(sBuildPropName) );
557  }
558  }
559 
560  // Set Code Names
561  uno::Any aAny = xInfoSet->getPropertyValue("ScriptConfiguration");
562  uno::Reference <container::XNameAccess> xCodeNameAccess;
563  if( aAny >>= xCodeNameAccess )
564  XMLCodeNameProvider::set( xCodeNameAccess, &rDoc );
565 
566  // VBA compatibility
567  bool bVBACompat = false;
568  if ( (xInfoSet->getPropertyValue("VBACompatibilityMode") >>= bVBACompat) && bVBACompat )
569  {
570  /* Set library container to VBA compatibility mode, this
571  forces loading the Basic project, which in turn creates the
572  VBA Globals object and does all related initialization. */
573  if ( xModelSet.is() ) try
574  {
575  uno::Reference< script::vba::XVBACompatibility > xVBACompat( xModelSet->getPropertyValue(
576  "BasicLibraries" ), uno::UNO_QUERY_THROW );
577  xVBACompat->setVBACompatibilityMode( true );
578  }
579  catch( const uno::Exception& )
580  {
581  }
582  }
583  }
584 
585  // Don't test bStylesRetval and bMetaRetval, because it could be an older file which not contain such streams
586  return bRet;
587 }
588 
589 static bool lcl_HasValidStream(const ScDocument& rDoc)
590 {
591  SfxObjectShell* pObjSh = rDoc.GetDocumentShell();
592  if ( pObjSh->IsDocShared() )
593  return false; // never copy stream from shared file
594 
595  // don't read remote file again
596  // (could instead re-use medium directly in that case)
597  SfxMedium* pSrcMed = rDoc.GetDocumentShell()->GetMedium();
598  if ( !pSrcMed || pSrcMed->IsRemote() )
599  return false;
600 
601  SCTAB nTabCount = rDoc.GetTableCount();
602  for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
603  if (rDoc.IsStreamValid(nTab))
604  return true;
605  return false;
606 }
607 
608 bool ScXMLImportWrapper::ExportToComponent(const uno::Reference<uno::XComponentContext>& xContext,
609  const uno::Reference<frame::XModel>& xModel, const uno::Reference<xml::sax::XWriter>& xWriter,
610  const uno::Sequence<beans::PropertyValue>& aDescriptor, const OUString& sName,
611  const OUString& sMediaType, const OUString& sComponentName,
612  const uno::Sequence<uno::Any>& aArgs, std::unique_ptr<ScMySharedData>& pSharedData)
613 {
614  bool bRet(false);
615  uno::Reference<io::XOutputStream> xOut;
616  uno::Reference<io::XStream> xStream;
617 
618  if ( !xStorage.is() && pMedium )
620 
621  if( xStorage.is() )
622  {
623  // #96807#; trunc stream before use, because it could be an existing stream
624  // and the new content could be shorter than the old content. In this case
625  // would not all be over written by the new content and the xml file
626  // would not be valid.
627  xStream = xStorage->openStreamElement( sName, embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
628  uno::Reference < beans::XPropertySet > xSet( xStream, uno::UNO_QUERY );
629  if (xSet.is())
630  {
631  xSet->setPropertyValue("MediaType", uno::makeAny(sMediaType));
632 
633  // advise storage impl to use common encryption
634  xSet->setPropertyValue( "UseCommonStoragePasswordEncryption", uno::makeAny(true) );
635  }
636 
637  xOut = xStream->getOutputStream();
638  }
639 
640  // set Base URL
641  uno::Reference< beans::XPropertySet > xInfoSet;
642  if( aArgs.hasElements() )
643  aArgs.getConstArray()[0] >>= xInfoSet;
644  OSL_ENSURE( xInfoSet.is(), "missing property set" );
645  if( xInfoSet.is() )
646  {
647  xInfoSet->setPropertyValue( "StreamName", uno::makeAny( sName ) );
648  }
649 
650  xWriter->setOutputStream( xOut );
651 
652  uno::Reference<document::XFilter> xFilter(
653  xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
654  sComponentName , aArgs, xContext ),
655  uno::UNO_QUERY );
656  OSL_ENSURE( xFilter.is(), "can't get exporter" );
657  uno::Reference<document::XExporter> xExporter( xFilter, uno::UNO_QUERY );
658  if (xExporter.is())
659  xExporter->setSourceDocument( xModel );
660 
661  if ( xFilter.is() )
662  {
663  ScXMLExport* pExport = static_cast<ScXMLExport*>(comphelper::getUnoTunnelImplementation<SvXMLExport>(xFilter));
664  pExport->SetSharedData(std::move(pSharedData));
665 
666  // if there are sheets to copy, get the source stream
667  if ( sName == "content.xml" && lcl_HasValidStream(rDoc) && ( pExport->getExportFlags() & SvXMLExportFlags::OASIS ) )
668  {
669  // old stream is still in this file's storage - open read-only
670 
671  // #i106854# use the document's storage directly, without a temporary SfxMedium
672  uno::Reference<embed::XStorage> xTmpStorage = rDoc.GetDocumentShell()->GetStorage();
673  uno::Reference<io::XStream> xSrcStream;
674  uno::Reference<io::XInputStream> xSrcInput;
675 
676  // #i108978# If an embedded object is saved and no events are notified, don't use the stream
677  // because without the ...DONE events, stream positions aren't updated.
678  ScSheetSaveData* pSheetData = comphelper::getUnoTunnelImplementation<ScModelObj>(xModel)->GetSheetSaveData();
679  if (pSheetData && pSheetData->IsInSupportedSave())
680  {
681  try
682  {
683  if (xTmpStorage.is())
684  xSrcStream = xTmpStorage->openStreamElement( sName, embed::ElementModes::READ );
685  if (xSrcStream.is())
686  xSrcInput = xSrcStream->getInputStream();
687  }
688  catch ( const uno::Exception&)
689  {
690  // stream not available (for example, password protected) - save normally (xSrcInput is null)
691  }
692  }
693 
694  pExport->SetSourceStream( xSrcInput );
695  bRet = xFilter->filter( aDescriptor );
696  pExport->SetSourceStream( uno::Reference<io::XInputStream>() );
697 
698  // If there was an error, reset all stream flags, so the next save attempt will use normal saving.
699  // #i110692# For embedded objects, the stream may be unavailable for one save operation (m_pAntiImpl)
700  // and become available again later. But after saving normally once, the stream positions aren't
701  // valid anymore, so the flags also have to be reset if the stream wasn't available.
702  if ( !bRet || !xSrcInput.is() )
703  {
704  SCTAB nTabCount = rDoc.GetTableCount();
705  for (SCTAB nTab=0; nTab<nTabCount; nTab++)
706  rDoc.SetStreamValid(nTab, false);
707  }
708  }
709  else
710  bRet = xFilter->filter( aDescriptor );
711 
712  pSharedData = pExport->ReleaseSharedData();
713  }
714 
715  return bRet;
716 }
717 
718 bool ScXMLImportWrapper::Export(bool bStylesOnly)
719 {
720  // Prevent all broadcasting and repaints and notification of accessibility
721  // during mass creation of captions, which is a major bottleneck and not
722  // needed during Save.
723  ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
724  bool bOldLock = bool();
725  if (pDrawLayer)
726  {
727  bOldLock = pDrawLayer->isLocked();
728  pDrawLayer->setLock(true);
729  }
730 
732 
733  if (pDrawLayer)
734  pDrawLayer->setLock(bOldLock);
735 
736  uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
737 
738  uno::Reference<xml::sax::XWriter> xWriter = xml::sax::Writer::create(xContext);
739 
740  if ( !xStorage.is() && pMedium )
742 
743  OUString sFileName;
744  if (pMedium)
745  sFileName = pMedium->GetName();
747  uno::Sequence<beans::PropertyValue> aDescriptor( comphelper::InitPropertySequence({
748  { "FileName", uno::Any(sFileName) }
749  }));
750 
752  comphelper::PropertyMapEntry const aExportInfoMap[] =
753  {
754  { OUString("ProgressRange"), 0, ::cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
755  { OUString("ProgressMax"), 0, ::cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
756  { OUString("ProgressCurrent"), 0, ::cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
757  { OUString("WrittenNumberStyles"), 0, cppu::UnoType<uno::Sequence<sal_Int32>>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
758  { OUString("UsePrettyPrinting"), 0, ::cppu::UnoType<sal_Bool>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
759  { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
760  { OUString("StreamRelPath"), 0, ::cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
761  { OUString("StreamName"), 0, ::cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
762  { OUString("StyleNames"), 0, cppu::UnoType<uno::Sequence<OUString>>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
763  { OUString("StyleFamilies"), 0, cppu::UnoType<uno::Sequence<sal_Int32>>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
764  { OUString("TargetStorage"), 0, cppu::UnoType<embed::XStorage>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
765  { OUString(), 0, css::uno::Type(), 0, 0 }
766  };
767  uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) );
768 
769  if ( pObjSh && xStorage.is() )
770  {
771  uno::Reference<frame::XModel> xModel(pObjSh->GetModel());
772  // sorting wants to create undo actions
773  assert(SfxObjectCreateMode::STANDARD != pObjSh->GetCreateMode() || rDoc.GetDrawLayer()->IsUndoEnabled());
774  uno::Reference<drawing::XDrawPagesSupplier> const xDPS(xModel, uno::UNO_QUERY);
775  uno::Reference<container::XIndexAccess> const xDPs(xDPS->getDrawPages());
776  assert(xDPs.is());
777  for (auto i = xDPs->getCount(); 0 < i; )
778  {
779  --i;
780  uno::Reference<drawing::XShapes> const xDP(xDPs->getByIndex(i), uno::UNO_QUERY);
781  assert(xDP.is());
782  xmloff::FixZOrder(xDP,
783  [](uno::Reference<beans::XPropertySet> const& xShape)
784  {
785  sal_Int16 nLayerID(0);
786  xShape->getPropertyValue("LayerID") >>= nLayerID;
787  switch (nLayerID)
788  {
790  return 1;
791  case sal_uInt8(SC_LAYER_BACK):
792  return 0;
794  return 2;
796  return 3;
798  return 1; // treat as equivalent to front
799  default:
801  }
802  });
803  }
804 
805  uno::Reference<task::XStatusIndicator> xStatusIndicator(GetStatusIndicator());
806  sal_Int32 nProgressRange(1000000);
807  if(xStatusIndicator.is())
808  xStatusIndicator->start(ScResId(STR_SAVE_DOC), nProgressRange);
809  xInfoSet->setPropertyValue("ProgressRange", uno::makeAny(nProgressRange));
810 
811  SvtSaveOptions aSaveOpt;
812  bool bUsePrettyPrinting(aSaveOpt.IsPrettyPrinting());
813  xInfoSet->setPropertyValue("UsePrettyPrinting", uno::makeAny(bUsePrettyPrinting));
814 
815  xInfoSet->setPropertyValue( "TargetStorage", uno::Any( xStorage ) );
816 
817  OSL_ENSURE( pMedium, "There is no medium to get MediaDescriptor from!" );
818  OUString aBaseURL = pMedium ? pMedium->GetBaseURL( true ) : OUString();
819  OUString sPropName("BaseURI");
820  xInfoSet->setPropertyValue( sPropName, uno::makeAny( aBaseURL ) );
821 
822  // TODO/LATER: do not do it for embedded links
823  if( SfxObjectCreateMode::EMBEDDED == pObjSh->GetCreateMode() )
824  {
825  OUString aName("dummyObjectName");
826  if ( pMedium && pMedium->GetItemSet() )
827  {
828  const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
829  pMedium->GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
830  if ( pDocHierarchItem )
831  aName = pDocHierarchItem->GetValue();
832  }
833 
834  if( !aName.isEmpty() )
835  {
836  sPropName = "StreamRelPath";
837  xInfoSet->setPropertyValue( sPropName, uno::makeAny( aName ) );
838  }
839  }
840 
841  OUString sTextMediaType("text/xml");
842  bool bMetaRet(pObjSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED);
843  bool bStylesRet (false);
844  bool bDocRet(false);
845  bool bSettingsRet(false);
846  std::unique_ptr<ScMySharedData> pSharedData;
847 
849 
850  // RDF metadata: ODF >= 1.2
851  if ( !bStylesOnly && bOasis )
852  {
853  const uno::Reference< beans::XPropertySet > xPropSet( xStorage, uno::UNO_QUERY_THROW );
854  try
855  {
856  OUString aVersion;
857  if (( xPropSet->getPropertyValue("Version") >>= aVersion )
858  && aVersion != ODFVER_010_TEXT
859  && aVersion != ODFVER_011_TEXT )
860  {
861  const uno::Reference< rdf::XDocumentMetadataAccess > xDMA(
862  xModel, uno::UNO_QUERY_THROW );
863  xDMA->storeMetadataToStorage( xStorage );
864  }
865  }
866  catch ( const beans::UnknownPropertyException &)
867  {
868  }
869  catch ( const uno::Exception &)
870  {
871  }
872  }
873 
874  // meta export
875  if (!bStylesOnly && !bMetaRet)
876  {
877  uno::Sequence<uno::Any> aMetaArgs(3);
878  uno::Any* pMetaArgs = aMetaArgs.getArray();
879  pMetaArgs[0] <<= xInfoSet;
880  pMetaArgs[1] <<= xWriter;
881  pMetaArgs[2] <<= xStatusIndicator;
882 
883  SAL_INFO( "sc.filter", "meta export start" );
884 
885  bMetaRet = ExportToComponent(xContext, xModel, xWriter, aDescriptor,
886  "meta.xml",
887  sTextMediaType,
888  bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisMetaExporter")
889  : OUString("com.sun.star.comp.Calc.XMLMetaExporter"),
890  aMetaArgs, pSharedData);
891 
892  SAL_INFO( "sc.filter", "meta export end" );
893  }
894 
895  uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler;
896  rtl::Reference<SvXMLGraphicHelper> xGraphicHelper;
897 
898  if( xStorage.is() )
899  {
900  xGraphicHelper = SvXMLGraphicHelper::Create( xStorage, SvXMLGraphicHelperMode::Write );
901  xGraphicStorageHandler = xGraphicHelper.get();
902  }
903 
904  auto xObjectHelper = SvXMLEmbeddedObjectHelper::Create(
905  xStorage, *pObjSh, SvXMLEmbeddedObjectHelperMode::Write);
906  uno::Reference<document::XEmbeddedObjectResolver> xObjectResolver(xObjectHelper);
907 
908  // styles export
909 
910  {
911  uno::Sequence<uno::Any> aStylesArgs(5);
912  uno::Any* pStylesArgs = aStylesArgs.getArray();
913  pStylesArgs[0] <<= xInfoSet;
914  pStylesArgs[1] <<= xGraphicStorageHandler;
915  pStylesArgs[2] <<= xStatusIndicator;
916  pStylesArgs[3] <<= xWriter;
917  pStylesArgs[4] <<= xObjectResolver;
918 
919  SAL_INFO( "sc.filter", "styles export start" );
920 
921  bStylesRet = ExportToComponent(xContext, xModel, xWriter, aDescriptor,
922  "styles.xml",
923  sTextMediaType,
924  bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisStylesExporter")
925  : OUString("com.sun.star.comp.Calc.XMLStylesExporter"),
926  aStylesArgs, pSharedData);
927 
928  SAL_INFO( "sc.filter", "styles export end" );
929  }
930 
931  // content export
932 
933  if (!bStylesOnly)
934  {
935  uno::Sequence<uno::Any> aDocArgs(5);
936  uno::Any* pDocArgs = aDocArgs.getArray();
937  pDocArgs[0] <<= xInfoSet;
938  pDocArgs[1] <<= xGraphicStorageHandler;
939  pDocArgs[2] <<= xStatusIndicator;
940  pDocArgs[3] <<= xWriter;
941  pDocArgs[4] <<= xObjectResolver;
942 
943  SAL_INFO( "sc.filter", "content export start" );
944 
945  bDocRet = ExportToComponent(xContext, xModel, xWriter, aDescriptor,
946  "content.xml",
947  sTextMediaType,
948  bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisContentExporter")
949  : OUString("com.sun.star.comp.Calc.XMLContentExporter"),
950  aDocArgs, pSharedData);
951 
952  SAL_INFO( "sc.filter", "content export end" );
953  }
954 
955  if( xGraphicHelper )
956  xGraphicHelper->dispose();
957  xGraphicHelper.clear();
958 
959  if( xObjectHelper )
960  xObjectHelper->dispose();
961  xObjectHelper.clear();
962 
963  // settings export
964 
965  if (!bStylesOnly)
966  {
967  uno::Sequence<uno::Any> aSettingsArgs(3);
968  uno::Any* pSettingsArgs = aSettingsArgs.getArray();
969  pSettingsArgs[0] <<= xInfoSet;
970  pSettingsArgs[1] <<= xWriter;
971  pSettingsArgs[2] <<= xStatusIndicator;
972 
973  SAL_INFO( "sc.filter", "settings export start" );
974 
975  bSettingsRet = ExportToComponent(xContext, xModel, xWriter, aDescriptor,
976  "settings.xml",
977  sTextMediaType,
978  bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisSettingsExporter")
979  : OUString("com.sun.star.comp.Calc.XMLSettingsExporter"),
980  aSettingsArgs, pSharedData);
981 
982  SAL_INFO( "sc.filter", "settings export end" );
983  }
984 
985  pSharedData.reset();
986 
987  if (xStatusIndicator.is())
988  xStatusIndicator->end();
989  return bStylesRet && ((!bStylesOnly && bDocRet && bMetaRet && bSettingsRet) || bStylesOnly);
990  }
991 
992  // later: give string descriptor as parameter for doc type
993 
994  return false;
995 }
996 
997 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< ScMySharedData > ReleaseSharedData()
Definition: xmlexprt.cxx:5464
static bool lcl_HasValidStream(const ScDocument &rDoc)
Definition: xmlwrap.cxx:589
#define ODFVER_011_TEXT
#define SCERR_IMPORT_FORMAT_ROWCOL
Definition: scerrors.hxx:48
#define SC_UNO_ODS_LOCK_SOLAR_MUTEX
Definition: unonames.hxx:699
bool Import(ImportFlags nMode, ErrCode &rError)
Definition: xmlwrap.cxx:285
sal_Int32 GetVersion() const
#define ERRCODE_SFX_WRONGPASSWORD
const OUString & GetName() const
#define SAL_INFO_IF(condition, area, stream)
css::uno::Reference< css::frame::XModel3 > GetModel() const
void SetSharedData(std::unique_ptr< ScMySharedData > pTemp)
Definition: xmlexprt.cxx:5462
#define SCWARN_IMPORT_RANGE_OVERFLOW
Definition: scerrors.hxx:61
constexpr SdrLayerID SC_LAYER_BACK(1)
ImportFlags
Definition: xmlwrap.hxx:44
css::uno::Reference< css::embed::XStorage > const & GetStorage()
Reference< XInputStream > xStream
OUString SvxResId(const char *pId)
Any SAL_CALL getCaughtException()
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:313
bool isLocked() const
static void set(const css::uno::Reference< css::container::XNameAccess > &xNameAccess, ScDocument *pDoc)
bool IsDocShared() const
void SetSourceStream(const css::uno::Reference< css::io::XInputStream > &xNewStream)
Definition: xmlexprt.cxx:433
ErrCode ImportFromComponent(const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel > &xModel, css::xml::sax::InputSource &aParserInput, const OUString &sComponentName, const OUString &sDocName, const css::uno::Sequence< css::uno::Any > &aArgs, bool bMustBeSuccessfull)
Definition: xmlwrap.cxx:107
const css::uno::Any & GetValue() const
sc::ImportPostProcessData maPostProcessData
Definition: xmlwrap.hxx:59
SfxObjectCreateMode GetCreateMode() const
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
css::uno::Reference< css::task::XInteractionHandler > GetInteractionHandler(bool bGetAlways=false)
bool IsStreamValid(SCTAB nTab) const
Definition: document.cxx:916
bool IsPrettyPrinting() const
ScDocument & rDoc
Definition: xmlwrap.hxx:62
#define SCWARN_IMPORT_FEATURES_LOST
Definition: scerrors.hxx:66
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1057
#define SOFFICE_FILEFORMAT_60
#define TOOLS_WARN_EXCEPTION(area, stream)
void SetPostProcessData(sc::ImportPostProcessData *p)
Definition: xmlimprt.cxx:308
int i
css::uno::Reference< css::embed::XStorage > xStorage
Definition: xmlwrap.hxx:64
#define O3TL_UNREACHABLE
bool IsUndoEnabled() const
static rtl::Reference< SvXMLEmbeddedObjectHelper > Create(const css::uno::Reference< css::embed::XStorage > &,::comphelper::IEmbeddedHelper &rDocPersist, SvXMLEmbeddedObjectHelperMode eCreateMode)
COMPHELPER_DLLPUBLIC css::uno::Reference< css::beans::XPropertySet > GenericPropertySet_CreateInstance(PropertySetInfo *pInfo)
const OUString & GetValue() const
bool HasRangeOverflow() const
Definition: document.hxx:2136
OUString ScResId(const char *pId)
Definition: scdll.cxx:89
#define SC_UNO_ODS_IMPORT_STYLES
Definition: unonames.hxx:700
OUString GetBaseURL(bool bForSaving=false)
SfxItemSet * GetItemSet() const
css::uno::Type const & get()
#define SCERR_IMPORT_UNKNOWN
Definition: scerrors.hxx:27
#define SCERR_IMPORT_OPEN
Definition: scerrors.hxx:26
OString exceptionToString(const css::uno::Any &caught)
#define ODFVER_010_TEXT
#define ERRCODE_IO_BROKENPACKAGE
void SetRangeOverflowType(ErrCode nType)
Definition: document.hxx:2135
void CreateAllNoteCaptions()
Ensure that all note objects have an associated sdr object.
Definition: document.cxx:6667
void setLock(bool bLock)
SfxMedium * pMedium
Definition: xmlwrap.hxx:63
void SetStreamValid(SCTAB nTab, bool bSet, bool bIgnoreLock=false)
Definition: document.cxx:924
constexpr SdrLayerID SC_LAYER_HIDDEN(4)
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
#define SAL_WARN_IF(condition, area, stream)
#define ERRCODE_NONE
unsigned char sal_uInt8
bool IsRemote() const
#define SCWARN_IMPORT_SHEET_OVERFLOW
Definition: scerrors.hxx:64
#define SCWARN_IMPORT_ROW_OVERFLOW
Definition: scerrors.hxx:62
constexpr SdrLayerID SC_LAYER_FRONT(0)
#define SAL_INFO(area, stream)
OUString aName
#define SCWARN_IMPORT_FILE_ROWCOL
Definition: scerrors.hxx:49
constexpr SdrLayerID SC_LAYER_INTERN(2)
SC_DLLPUBLIC const ErrCode & GetRangeOverflowType() const
Definition: document.hxx:2137
Reference< XComponentContext > getProcessComponentContext()
constexpr OUStringLiteral sStream
#define SCERR_IMPORT_FORMAT
Definition: scerrors.hxx:33
css::uno::Reference< css::embed::XStorage > GetOutputStorage()
#define SCWARN_IMPORT_COLUMN_OVERFLOW
Definition: scerrors.hxx:63
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1056
#define SAL_WARN(area, stream)
Reference< XModel > xModel
css::uno::Reference< css::task::XStatusIndicator > GetStatusIndicator() const
Definition: xmlwrap.cxx:91
static rtl::Reference< SvXMLGraphicHelper > Create(const css::uno::Reference< css::embed::XStorage > &rXMLStorage, SvXMLGraphicHelperMode eCreateMode)
void FixZOrder(uno::Reference< drawing::XShapes > const &xShapes, std::function< unsigned int(uno::Reference< beans::XPropertySet > const &)> const &rGetLayer)
bool ExportToComponent(const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel > &xModel, const css::uno::Reference< css::xml::sax::XWriter > &xWriter, const css::uno::Sequence< css::beans::PropertyValue > &aDescriptor, const OUString &sName, const OUString &sMediaType, const OUString &sComponentName, const css::uno::Sequence< css::uno::Any > &aArgs, std::unique_ptr< ScMySharedData > &pSharedData)
Definition: xmlwrap.cxx:608
bool IsInSupportedSave() const
Definition: sheetdata.hxx:170
ScXMLImportWrapper(ScDocShell &rDocSh, SfxMedium *pM, const css::uno::Reference< css::embed::XStorage > &xStor)
Definition: xmlwrap.cxx:82
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
bool Export(bool bStylesOnly)
Definition: xmlwrap.cxx:718
SvXMLExportFlags getExportFlags() const
constexpr SdrLayerID SC_LAYER_CONTROLS(3)
ScDocShell & mrDocShell
Definition: xmlwrap.hxx:61
uno::Reference< rdf::XURI > createBaseURI(uno::Reference< uno::XComponentContext > const &i_xContext, uno::Reference< frame::XModel > const &i_xModel, OUString const &i_rPkgURI, std::u16string_view i_rSubDocument)
sal_Int16 SCTAB
Definition: types.hxx:22
#define SCERR_IMPORT_FILE_ROWCOL
Definition: scerrors.hxx:47
SfxMedium * GetMedium() const