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