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