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