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 126 : ScXMLImportWrapper::ScXMLImportWrapper(ScDocument& rD, SfxMedium* pM, const uno::Reference < embed::XStorage >& xStor ) :
78 : rDoc(rD),
79 : pMedium(pM),
80 126 : xStorage(xStor)
81 : {
82 : OSL_ENSURE( pMedium || xStorage.is(), "ScXMLImportWrapper: Medium or Storage must be set" );
83 126 : }
84 :
85 126 : uno::Reference <task::XStatusIndicator> ScXMLImportWrapper::GetStatusIndicator()
86 : {
87 126 : uno::Reference<task::XStatusIndicator> xStatusIndicator;
88 126 : if (pMedium)
89 : {
90 126 : SfxItemSet* pSet = pMedium->GetItemSet();
91 126 : if (pSet)
92 : {
93 126 : const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL));
94 126 : if (pItem)
95 34 : xStatusIndicator.set(pItem->GetValue(), uno::UNO_QUERY);
96 : }
97 : }
98 126 : return xStatusIndicator;
99 : }
100 :
101 432 : 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 432 : uno::Reference < io::XStream > xDocStream;
109 432 : if ( !xStorage.is() && pMedium )
110 0 : xStorage = pMedium->GetStorage();
111 :
112 432 : sal_Bool bEncrypted = false;
113 864 : OUString sStream(sDocName);
114 432 : if( xStorage.is() )
115 : {
116 : try
117 : {
118 432 : uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY );
119 432 : if ( xAccess->hasByName(sDocName) && xStorage->isStreamElement( sDocName) )
120 420 : xDocStream = xStorage->openStreamElement( sDocName, embed::ElementModes::READ );
121 12 : 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 12 : return SCERR_NONE;
128 :
129 420 : aParserInput.aInputStream = xDocStream->getInputStream();
130 840 : uno::Reference < beans::XPropertySet > xSet( xDocStream, uno::UNO_QUERY );
131 :
132 840 : uno::Any aAny = xSet->getPropertyValue("Encrypted");
133 840 : 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 840 : uno::Reference< beans::XPropertySet > xInfoSet;
153 420 : if( aArgs.getLength() > 0 )
154 420 : aArgs.getConstArray()[0] >>= xInfoSet;
155 : OSL_ENSURE( xInfoSet.is(), "missing property set" );
156 420 : if( xInfoSet.is() )
157 : {
158 420 : OUString sPropName("StreamName");
159 420 : xInfoSet->setPropertyValue( sPropName, uno::makeAny( sStream ) );
160 : }
161 :
162 420 : sal_uInt32 nReturn = SCERR_NONE;
163 420 : rDoc.SetRangeOverflowType(0); // is modified by the importer if limits are exceeded
164 :
165 : uno::Reference<xml::sax::XDocumentHandler> xDocHandler(
166 840 : xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
167 420 : sComponentName, aArgs, xContext ),
168 840 : uno::UNO_QUERY );
169 : OSL_ENSURE( xDocHandler.is(), "can't get Calc importer" );
170 840 : uno::Reference<document::XImporter> xImporter( xDocHandler, uno::UNO_QUERY );
171 840 : uno::Reference<lang::XComponent> xComponent( xModel, uno::UNO_QUERY );
172 420 : if (xImporter.is())
173 416 : xImporter->setTargetDocument( xComponent );
174 :
175 420 : ScXMLImport* pImporterImpl = dynamic_cast<ScXMLImport*>(xImporter.get());
176 420 : if (pImporterImpl)
177 396 : pImporterImpl->SetPostProcessData(&maPostProcessData);
178 :
179 : // connect parser and filter
180 420 : xParser->setDocumentHandler( xDocHandler );
181 :
182 : try
183 : {
184 420 : 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 420 : if (rDoc.HasRangeOverflow() && !nReturn)
300 0 : nReturn = rDoc.GetRangeOverflowType();
301 :
302 : // free the component
303 420 : xParser->setDocumentHandler( NULL );
304 :
305 : // success!
306 852 : return nReturn;
307 : }
308 :
309 108 : bool ScXMLImportWrapper::Import(bool bStylesOnly, ErrCode& nError)
310 : {
311 108 : uno::Reference<uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
312 :
313 216 : xml::sax::InputSource aParserInput;
314 108 : if (pMedium)
315 108 : aParserInput.sSystemId = pMedium->GetName();
316 :
317 108 : if ( !xStorage.is() && pMedium )
318 108 : xStorage = pMedium->GetStorage();
319 :
320 : // get parser
321 216 : uno::Reference<xml::sax::XParser> xXMLParser = xml::sax::Parser::create(xContext);
322 :
323 : // get filter
324 108 : SfxObjectShell* pObjSh = rDoc.GetDocumentShell();
325 108 : if ( pObjSh )
326 : {
327 108 : OUString sEmpty;
328 216 : uno::Reference<frame::XModel> xModel(pObjSh->GetModel());
329 :
330 : /** property map for export info set */
331 : comphelper::PropertyMapEntry const aImportInfoMap[] =
332 : {
333 108 : { OUString("ProgressRange"), 0, ::getCppuType((sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
334 108 : { OUString("ProgressMax"), 0, ::getCppuType((sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
335 108 : { OUString("ProgressCurrent"), 0, ::getCppuType((sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
336 108 : { OUString("NumberStyles"), 0, ::getCppuType((uno::Reference<container::XNameAccess> *)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
337 108 : { OUString("PrivateData"), 0, ::getCppuType( (uno::Reference<uno::XInterface> *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
338 108 : { OUString("BaseURI"), 0, ::getCppuType( (OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
339 108 : { OUString("StreamRelPath"), 0, ::getCppuType( (OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
340 108 : { OUString("StreamName"), 0, ::getCppuType( (OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
341 108 : { OUString("BuildId"), 0, ::getCppuType( (OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
342 108 : { OUString("VBACompatibilityMode"), 0, ::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
343 108 : { OUString("ScriptConfiguration"), 0, ::getCppuType((uno::Reference<container::XNameAccess> *)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
344 108 : { OUString("OrganizerMode"), 0, ::getBooleanCppuType(),
345 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
346 108 : { OUString("SourceStorage"), 0, cppu::UnoType<embed::XStorage>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
347 : { OUString(), 0, css::uno::Type(), 0, 0 }
348 1620 : };
349 216 : uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aImportInfoMap ) ) );
350 :
351 : // ---- get BuildId from parent container if available
352 :
353 216 : uno::Reference< container::XChild > xChild( xModel, uno::UNO_QUERY );
354 108 : if( xChild.is() )
355 : {
356 108 : uno::Reference< beans::XPropertySet > xParentSet( xChild->getParent(), uno::UNO_QUERY );
357 108 : 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 108 : }
366 : }
367 :
368 216 : uno::Reference<task::XStatusIndicator> xStatusIndicator(GetStatusIndicator());
369 108 : if (xStatusIndicator.is())
370 : {
371 34 : sal_Int32 nProgressRange(1000000);
372 34 : xStatusIndicator->start(ScGlobal::GetRscString(STR_LOAD_DOC), nProgressRange);
373 34 : 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 216 : OUString aBaseURL = pMedium ? pMedium->GetBaseURL() : OUString();
379 216 : OUString sPropName("BaseURI");
380 108 : xInfoSet->setPropertyValue( sPropName, uno::makeAny( aBaseURL ) );
381 :
382 : // TODO/LATER: do not do it for embedded links
383 216 : OUString aName;
384 108 : if( SFX_CREATE_MODE_EMBEDDED == pObjSh->GetCreateMode() )
385 : {
386 74 : if ( pMedium && pMedium->GetItemSet() )
387 : {
388 : const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
389 74 : pMedium->GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
390 74 : if ( pDocHierarchItem )
391 0 : aName = pDocHierarchItem->GetValue();
392 : }
393 : else
394 0 : aName = "dummyObjectName";
395 :
396 74 : if( !aName.isEmpty() )
397 : {
398 0 : sPropName = "StreamRelPath";
399 0 : xInfoSet->setPropertyValue( sPropName, uno::makeAny( aName ) );
400 : }
401 : }
402 :
403 108 : if (bStylesOnly)
404 : {
405 : OUString const sOrganizerMode(
406 0 : "OrganizerMode");
407 0 : xInfoSet->setPropertyValue(sOrganizerMode, uno::makeAny(sal_True));
408 : }
409 :
410 108 : xInfoSet->setPropertyValue( "SourceStorage", uno::Any( xStorage ) );
411 :
412 108 : sal_Bool bOasis = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 );
413 :
414 108 : if (!bStylesOnly && bOasis)
415 : {
416 : // RDF metadata: ODF >= 1.2
417 : try
418 : {
419 : const uno::Reference< rdf::XDocumentMetadataAccess > xDMA(
420 102 : xModel, uno::UNO_QUERY_THROW );
421 : const uno::Reference< rdf::XURI > xBaseURI(
422 204 : ::sfx2::createBaseURI( xContext, xStorage, aBaseURL, aName ) );
423 : const uno::Reference< task::XInteractionHandler > xHandler(
424 204 : pObjSh->GetMedium()->GetInteractionHandler() );
425 204 : 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 108 : sal_uInt32 nMetaRetval(0);
447 216 : uno::Sequence<uno::Any> aMetaArgs(1);
448 108 : uno::Any* pMetaArgs = aMetaArgs.getArray();
449 108 : 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 108 : "meta.xml", "Meta.xml", aMetaArgs, false);
458 :
459 : SAL_INFO( "sc.filter", "meta import end" );
460 :
461 108 : SvXMLGraphicHelper* pGraphicHelper = NULL;
462 216 : uno::Reference< document::XGraphicObjectResolver > xGrfContainer;
463 :
464 216 : uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
465 108 : SvXMLEmbeddedObjectHelper *pObjectHelper = NULL;
466 :
467 108 : if( xStorage.is() )
468 : {
469 108 : pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_READ );
470 108 : xGrfContainer = pGraphicHelper;
471 :
472 108 : if( pObjSh )
473 : {
474 108 : pObjectHelper = SvXMLEmbeddedObjectHelper::Create(xStorage, *pObjSh, EMBEDDEDOBJECTHELPER_MODE_READ, false );
475 108 : xObjectResolver = pObjectHelper;
476 : }
477 : }
478 216 : uno::Sequence<uno::Any> aStylesArgs(4);
479 108 : uno::Any* pStylesArgs = aStylesArgs.getArray();
480 108 : pStylesArgs[0] <<= xInfoSet;
481 108 : pStylesArgs[1] <<= xGrfContainer;
482 108 : pStylesArgs[2] <<= xStatusIndicator;
483 108 : pStylesArgs[3] <<= xObjectResolver;
484 :
485 108 : sal_uInt32 nSettingsRetval(0);
486 108 : 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 108 : uno::Sequence<uno::Any> aSettingsArgs(1);
492 108 : uno::Any* pSettingsArgs = aSettingsArgs.getArray();
493 108 : 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 108 : "settings.xml", sEmpty, aSettingsArgs, false);
502 :
503 108 : SAL_INFO( "sc.filter", "settings import end" );
504 : }
505 :
506 108 : 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 108 : sEmpty, aStylesArgs, true);
515 :
516 : SAL_INFO( "sc.filter", "styles import end" );
517 : }
518 :
519 108 : sal_uInt32 nDocRetval(0);
520 108 : if (!bStylesOnly)
521 : {
522 108 : uno::Sequence<uno::Any> aDocArgs(4);
523 108 : uno::Any* pDocArgs = aDocArgs.getArray();
524 108 : pDocArgs[0] <<= xInfoSet;
525 108 : pDocArgs[1] <<= xGrfContainer;
526 108 : pDocArgs[2] <<= xStatusIndicator;
527 108 : 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 108 : true);
537 :
538 108 : SAL_INFO( "sc.filter", "content import end" );
539 : }
540 108 : if( pGraphicHelper )
541 108 : SvXMLGraphicHelper::Destroy( pGraphicHelper );
542 :
543 108 : if( pObjectHelper )
544 108 : SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
545 :
546 108 : if (xStatusIndicator.is())
547 34 : xStatusIndicator->end();
548 :
549 108 : bool bRet(false);
550 108 : if (bStylesOnly)
551 : {
552 0 : if (nStylesRetval)
553 0 : nError = nStylesRetval;
554 : else
555 0 : bRet = true;
556 : }
557 : else
558 : {
559 108 : 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 108 : else if (nStylesRetval)
569 0 : nError = nStylesRetval;
570 108 : else if (nMetaRetval)
571 0 : nError = nMetaRetval;
572 108 : else if (nSettingsRetval)
573 0 : nError = nSettingsRetval;
574 : else
575 108 : bRet = true;
576 : }
577 :
578 : // set BuildId on XModel for later OLE object loading
579 108 : if( xInfoSet.is() )
580 : {
581 108 : uno::Reference< beans::XPropertySet > xModelSet( xModel, uno::UNO_QUERY );
582 108 : if( xModelSet.is() )
583 : {
584 108 : uno::Reference< beans::XPropertySetInfo > xModelSetInfo( xModelSet->getPropertySetInfo() );
585 216 : OUString sBuildPropName("BuildId" );
586 108 : if( xModelSetInfo.is() && xModelSetInfo->hasPropertyByName(sBuildPropName) )
587 : {
588 108 : xModelSet->setPropertyValue( sBuildPropName, xInfoSet->getPropertyValue(sBuildPropName) );
589 108 : }
590 : }
591 :
592 : // Set Code Names
593 216 : uno::Any aAny = xInfoSet->getPropertyValue("ScriptConfiguration");
594 216 : uno::Reference <container::XNameAccess> xCodeNameAccess;
595 108 : if( aAny >>= xCodeNameAccess )
596 0 : XMLCodeNameProvider::set( xCodeNameAccess, &rDoc );
597 :
598 : // VBA compatibility
599 108 : bool bVBACompat = false;
600 108 : 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 108 : }
615 : }
616 :
617 : // Don't test bStylesRetval and bMetaRetval, because it could be an older file which not contain such streams
618 216 : return bRet;//!bStylesOnly ? bDocRetval : bStylesRetval;
619 : }
620 108 : return false;
621 : }
622 :
623 18 : static bool lcl_HasValidStream(ScDocument& rDoc)
624 : {
625 18 : SfxObjectShell* pObjSh = rDoc.GetDocumentShell();
626 18 : 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 18 : SfxMedium* pSrcMed = rDoc.GetDocumentShell()->GetMedium();
632 18 : if ( !pSrcMed || pSrcMed->IsRemote() )
633 0 : return false;
634 :
635 18 : SCTAB nTabCount = rDoc.GetTableCount();
636 40 : for (SCTAB nTab=0; nTab<nTabCount; ++nTab)
637 22 : if (rDoc.IsStreamValid(nTab))
638 0 : return true;
639 18 : return false;
640 : }
641 :
642 60 : 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 60 : bool bRet(false);
649 60 : uno::Reference<io::XOutputStream> xOut;
650 120 : uno::Reference<io::XStream> xStream;
651 :
652 60 : if ( !xStorage.is() && pMedium )
653 0 : xStorage = pMedium->GetOutputStorage();
654 :
655 60 : 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 60 : xStream = xStorage->openStreamElement( sName, embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
662 60 : uno::Reference < beans::XPropertySet > xSet( xStream, uno::UNO_QUERY );
663 60 : if (xSet.is())
664 : {
665 60 : xSet->setPropertyValue("MediaType", uno::makeAny(sMediaType));
666 60 : OUString aUseCommonPassPropName("UseCommonStoragePasswordEncryption");
667 :
668 : // advise storage impl to use common encryption
669 60 : xSet->setPropertyValue( aUseCommonPassPropName, uno::makeAny(sal_True) );
670 : }
671 :
672 60 : xOut = xStream->getOutputStream();
673 : }
674 :
675 : // set Base URL
676 120 : uno::Reference< beans::XPropertySet > xInfoSet;
677 60 : if( aArgs.getLength() > 0 )
678 60 : aArgs.getConstArray()[0] >>= xInfoSet;
679 : OSL_ENSURE( xInfoSet.is(), "missing property set" );
680 60 : if( xInfoSet.is() )
681 : {
682 60 : OUString sPropName("StreamName");
683 60 : xInfoSet->setPropertyValue( sPropName, uno::makeAny( sName ) );
684 : }
685 :
686 60 : xWriter->setOutputStream( xOut );
687 :
688 : uno::Reference<document::XFilter> xFilter(
689 120 : xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
690 60 : sComponentName , aArgs, xContext ),
691 120 : uno::UNO_QUERY );
692 : OSL_ENSURE( xFilter.is(), "can't get exporter" );
693 120 : uno::Reference<document::XExporter> xExporter( xFilter, uno::UNO_QUERY );
694 120 : uno::Reference<lang::XComponent> xComponent( xModel, uno::UNO_QUERY );
695 60 : if (xExporter.is())
696 60 : xExporter->setSourceDocument( xComponent );
697 :
698 60 : if ( xFilter.is() )
699 : {
700 60 : ScXMLExport* pExport = static_cast<ScXMLExport*>(SvXMLExport::getImplementation(xFilter));
701 60 : pExport->SetSharedData(pSharedData);
702 :
703 : // if there are sheets to copy, get the source stream
704 60 : 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 60 : bRet = xFilter->filter( aDescriptor );
749 :
750 60 : pSharedData = pExport->GetSharedData();
751 : }
752 :
753 120 : return bRet;
754 : }
755 :
756 18 : bool ScXMLImportWrapper::Export(bool bStylesOnly)
757 : {
758 18 : rDoc.CreateAllNoteCaptions();
759 :
760 18 : uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
761 :
762 36 : uno::Reference<xml::sax::XWriter> xWriter = xml::sax::Writer::create(xContext);
763 :
764 18 : if ( !xStorage.is() && pMedium )
765 18 : xStorage = pMedium->GetOutputStorage();
766 :
767 36 : OUString sFileName;
768 36 : OUString sTextMediaType("text/xml");
769 18 : if (pMedium)
770 18 : sFileName = pMedium->GetName();
771 18 : SfxObjectShell* pObjSh = rDoc.GetDocumentShell();
772 36 : uno::Sequence<beans::PropertyValue> aDescriptor(1);
773 18 : beans::PropertyValue* pProps = aDescriptor.getArray();
774 18 : pProps[0].Name = "FileName";
775 18 : pProps[0].Value <<= sFileName;
776 :
777 : /** property map for export info set */
778 : comphelper::PropertyMapEntry const aExportInfoMap[] =
779 : {
780 18 : { OUString("ProgressRange"), 0, ::getCppuType((sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
781 18 : { OUString("ProgressMax"), 0, ::getCppuType((sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
782 18 : { OUString("ProgressCurrent"), 0, ::getCppuType((sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
783 18 : { OUString("WrittenNumberStyles"), 0, ::getCppuType((uno::Sequence<sal_Int32>*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
784 18 : { OUString("UsePrettyPrinting"), 0, ::getCppuType((sal_Bool*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
785 18 : { OUString("BaseURI"), 0, ::getCppuType( (OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
786 18 : { OUString("StreamRelPath"), 0, ::getCppuType( (OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
787 18 : { OUString("StreamName"), 0, ::getCppuType( (OUString *)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
788 18 : { OUString("StyleNames"), 0, ::getCppuType( (uno::Sequence<OUString>*)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
789 18 : { OUString("StyleFamilies"), 0, ::getCppuType( (uno::Sequence<sal_Int32>*)0 ), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
790 18 : { OUString("TargetStorage"), 0, cppu::UnoType<embed::XStorage>::get(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
791 : { OUString(), 0, css::uno::Type(), 0, 0 }
792 234 : };
793 36 : uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) ) );
794 :
795 18 : if ( pObjSh && xStorage.is() )
796 : {
797 18 : pObjSh->UpdateDocInfoForSave(); // update information
798 :
799 18 : uno::Reference<frame::XModel> xModel(pObjSh->GetModel());
800 36 : uno::Reference<task::XStatusIndicator> xStatusIndicator(GetStatusIndicator());
801 18 : sal_Int32 nProgressRange(1000000);
802 18 : if(xStatusIndicator.is())
803 0 : xStatusIndicator->start(ScGlobal::GetRscString(STR_SAVE_DOC), nProgressRange);
804 18 : xInfoSet->setPropertyValue("ProgressRange", uno::makeAny(nProgressRange));
805 :
806 36 : SvtSaveOptions aSaveOpt;
807 18 : sal_Bool bUsePrettyPrinting(aSaveOpt.IsPrettyPrinting());
808 18 : xInfoSet->setPropertyValue("UsePrettyPrinting", uno::makeAny(bUsePrettyPrinting));
809 :
810 36 : const OUString sTargetStorage("TargetStorage");
811 18 : xInfoSet->setPropertyValue( sTargetStorage, uno::Any( xStorage ) );
812 :
813 : OSL_ENSURE( pMedium, "There is no medium to get MediaDescriptor from!\n" );
814 36 : OUString aBaseURL = pMedium ? pMedium->GetBaseURL( true ) : OUString();
815 36 : OUString sPropName("BaseURI");
816 18 : xInfoSet->setPropertyValue( sPropName, uno::makeAny( aBaseURL ) );
817 :
818 : // TODO/LATER: do not do it for embedded links
819 18 : if( SFX_CREATE_MODE_EMBEDDED == pObjSh->GetCreateMode() )
820 : {
821 12 : OUString aName("dummyObjectName");
822 12 : if ( pMedium && pMedium->GetItemSet() )
823 : {
824 : const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
825 12 : pMedium->GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
826 12 : if ( pDocHierarchItem )
827 0 : aName = pDocHierarchItem->GetValue();
828 : }
829 :
830 12 : if( !aName.isEmpty() )
831 : {
832 12 : sPropName = "StreamRelPath";
833 12 : xInfoSet->setPropertyValue( sPropName, uno::makeAny( aName ) );
834 12 : }
835 : }
836 :
837 18 : bool bMetaRet(pObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED);
838 18 : bool bStylesRet (false);
839 18 : bool bDocRet(false);
840 18 : bool bSettingsRet(false);
841 18 : ScMySharedData* pSharedData = NULL;
842 :
843 18 : sal_Bool bOasis = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 );
844 :
845 : // RDF metadata: ODF >= 1.2
846 18 : if ( !bStylesOnly && bOasis )
847 : {
848 18 : const uno::Reference< beans::XPropertySet > xPropSet( xStorage, uno::UNO_QUERY_THROW );
849 : try
850 : {
851 18 : OUString aVersion;
852 54 : if (( xPropSet->getPropertyValue(
853 72 : OUString("Version")) >>= aVersion )
854 36 : && !aVersion.equals(ODFVER_010_TEXT)
855 90 : && !aVersion.equals(ODFVER_011_TEXT) )
856 : {
857 : const uno::Reference< rdf::XDocumentMetadataAccess > xDMA(
858 18 : xModel, uno::UNO_QUERY_THROW );
859 18 : xDMA->storeMetadataToStorage( xStorage );
860 18 : }
861 : }
862 0 : catch ( const beans::UnknownPropertyException &)
863 : {
864 : }
865 0 : catch ( const uno::Exception &)
866 : {
867 18 : }
868 : }
869 :
870 : // meta export
871 18 : if (!bStylesOnly && !bMetaRet)
872 : {
873 6 : uno::Sequence<uno::Any> aMetaArgs(3);
874 6 : uno::Any* pMetaArgs = aMetaArgs.getArray();
875 6 : pMetaArgs[0] <<= xInfoSet;
876 6 : pMetaArgs[1] <<= xWriter;
877 6 : 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 6 : aMetaArgs, pSharedData);
887 :
888 6 : SAL_INFO( "sc.filter", "meta export end" );
889 : }
890 :
891 36 : uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
892 18 : SvXMLEmbeddedObjectHelper *pObjectHelper = 0;
893 :
894 36 : uno::Reference< document::XGraphicObjectResolver > xGrfContainer;
895 18 : SvXMLGraphicHelper* pGraphicHelper = 0;
896 :
897 18 : if( xStorage.is() )
898 : {
899 18 : pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_WRITE, false );
900 18 : xGrfContainer = pGraphicHelper;
901 : }
902 :
903 18 : if( pObjSh )
904 : {
905 18 : pObjectHelper = SvXMLEmbeddedObjectHelper::Create( xStorage, *pObjSh, EMBEDDEDOBJECTHELPER_MODE_WRITE, false );
906 18 : xObjectResolver = pObjectHelper;
907 : }
908 :
909 : // styles export
910 :
911 : {
912 18 : uno::Sequence<uno::Any> aStylesArgs(5);
913 18 : uno::Any* pStylesArgs = aStylesArgs.getArray();
914 18 : pStylesArgs[0] <<= xInfoSet;
915 18 : pStylesArgs[1] <<= xGrfContainer;
916 18 : pStylesArgs[2] <<= xStatusIndicator;
917 18 : pStylesArgs[3] <<= xWriter;
918 18 : 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 18 : aStylesArgs, pSharedData);
928 :
929 18 : SAL_INFO( "sc.filter", "styles export end" );
930 : }
931 :
932 : // content export
933 :
934 18 : if (!bStylesOnly)
935 : {
936 18 : uno::Sequence<uno::Any> aDocArgs(5);
937 18 : uno::Any* pDocArgs = aDocArgs.getArray();
938 18 : pDocArgs[0] <<= xInfoSet;
939 18 : pDocArgs[1] <<= xGrfContainer;
940 18 : pDocArgs[2] <<= xStatusIndicator;
941 18 : pDocArgs[3] <<= xWriter;
942 18 : 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 18 : aDocArgs, pSharedData);
952 :
953 18 : SAL_INFO( "sc.filter", "content export end" );
954 : }
955 :
956 18 : if( pGraphicHelper )
957 18 : SvXMLGraphicHelper::Destroy( pGraphicHelper );
958 :
959 18 : if( pObjectHelper )
960 18 : SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
961 :
962 : // settings export
963 :
964 18 : if (!bStylesOnly)
965 : {
966 18 : uno::Sequence<uno::Any> aSettingsArgs(3);
967 18 : uno::Any* pSettingsArgs = aSettingsArgs.getArray();
968 18 : pSettingsArgs[0] <<= xInfoSet;
969 18 : pSettingsArgs[1] <<= xWriter;
970 18 : 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 18 : aSettingsArgs, pSharedData);
980 :
981 18 : SAL_INFO( "sc.filter", "settings export end" );
982 : }
983 :
984 18 : if (pSharedData)
985 18 : delete pSharedData;
986 :
987 18 : if (xStatusIndicator.is())
988 0 : xStatusIndicator->end();
989 36 : return bStylesRet && ((!bStylesOnly && bDocRet && bMetaRet && bSettingsRet) || bStylesOnly);
990 : }
991 :
992 : // later: give string descriptor as parameter for doc type
993 :
994 18 : return false;
995 : }
996 :
997 108 : const sc::ImportPostProcessData& ScXMLImportWrapper::GetImportPostProcessData() const
998 : {
999 108 : return maPostProcessData;
1000 : }
1001 :
1002 :
1003 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|