update dev300-m58
[ooovba.git] / sd / source / filter / xml / sdxmlwrp.cxx
blob256fe8573fb9d20c5571b91400bd80f31029e149
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdxmlwrp.cxx,v $
10 * $Revision: 1.70 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <rtl/logfile.hxx>
34 #include <com/sun/star/container/XChild.hpp>
35 #include <com/sun/star/beans/XPropertySetInfo.hpp>
36 #include <com/sun/star/embed/ElementModes.hpp>
37 #include <com/sun/star/xml/sax/SAXParseException.hdl>
38 #include <comphelper/processfactory.hxx>
39 #include <sfx2/docfile.hxx>
40 #include <sfx2/docfilt.hxx>
41 #include <tools/urlobj.hxx>
42 #include "drawdoc.hxx"
43 #include <unotools/streamwrap.hxx>
44 #include <svx/xmlgrhlp.hxx>
46 #include "../../ui/inc/DrawDocShell.hxx"
48 #include "sdxmlwrp.hxx"
49 #include "strmname.h"
50 #include <svx/xmleohlp.hxx>
51 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
52 #include <com/sun/star/document/XFilter.hpp>
53 #include <com/sun/star/document/XImporter.hpp>
54 #include <com/sun/star/document/XExporter.hpp>
55 #include <com/sun/star/lang/XServiceInfo.hpp>
56 #include <com/sun/star/document/XGraphicObjectResolver.hpp>
57 #include <com/sun/star/beans/PropertyAttribute.hpp>
58 #include <com/sun/star/container/XNameAccess.hpp>
59 #include <com/sun/star/packages/zip/ZipIOException.hpp>
61 #include <com/sun/star/xml/sax/XErrorHandler.hpp>
62 #include <com/sun/star/xml/sax/XEntityResolver.hpp>
63 #include <com/sun/star/xml/sax/InputSource.hpp>
64 #include <com/sun/star/xml/sax/XDTDHandler.hpp>
65 #include <com/sun/star/xml/sax/XParser.hpp>
66 #include <com/sun/star/io/XActiveDataSource.hpp>
67 #include <com/sun/star/io/XActiveDataControl.hpp>
68 #include <comphelper/genericpropertyset.hxx>
69 #include <comphelper/propertysetinfo.hxx>
70 #include <svtools/saveopt.hxx>
72 // #80365# include necessary for XML progress bar at load time
73 #include <svtools/itemset.hxx>
74 #include <svtools/stritem.hxx>
75 #include <svtools/sfxecode.hxx>
77 #include "sderror.hxx"
78 #include "sdresid.hxx"
79 #include "glob.hrc"
81 #include <sfx2/frame.hxx>
83 using rtl::OUString;
84 using namespace com::sun::star;
85 using namespace com::sun::star::uno;
86 using namespace com::sun::star::lang;
87 using namespace com::sun::star::document;
88 using namespace comphelper;
90 #define SD_XML_READERROR 1234
92 extern void TransformOOo2xDocument( SdDrawDocument* pDocument );
94 //////////////////////////////////////////////////////////////////////////////
96 #ifndef SEQTYPE
97 #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
98 #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
99 #else
100 #define SEQTYPE(x) &(x)
101 #endif
102 #endif
104 #define MAP_LEN(x) x, sizeof(x) - 1
106 #define XML_STRING(i, x) sal_Char __READONLY_DATA i[sizeof(x)] = x
108 XML_STRING( sXML_metaStreamName, "meta.xml");
109 XML_STRING( sXML_styleStreamName, "styles.xml" );
110 XML_STRING( sXML_contentStreamName, "content.xml" );
111 XML_STRING( sXML_oldContentStreamName, "Content.xml" );
112 XML_STRING( sXML_settingsStreamName, "settings.xml" );
114 XML_STRING( sXML_export_impress_oasis_service, "com.sun.star.comp.Impress.XMLOasisExporter" );
115 XML_STRING( sXML_export_impress_meta_oasis_service, "com.sun.star.comp.Impress.XMLOasisMetaExporter" );
116 XML_STRING( sXML_export_impress_styles_oasis_service, "com.sun.star.comp.Impress.XMLOasisStylesExporter" );
117 XML_STRING( sXML_export_impress_content_oasis_service, "com.sun.star.comp.Impress.XMLOasisContentExporter" );
118 XML_STRING( sXML_export_impress_settings_oasis_service, "com.sun.star.comp.Impress.XMLOasisSettingsExporter" );
120 XML_STRING( sXML_export_draw_oasis_service, "com.sun.star.comp.Draw.XMLOasisExporter" );
121 XML_STRING( sXML_export_draw_meta_oasis_service, "com.sun.star.comp.Draw.XMLOasisMetaExporter" );
122 XML_STRING( sXML_export_draw_styles_oasis_service, "com.sun.star.comp.Draw.XMLOasisStylesExporter" );
123 XML_STRING( sXML_export_draw_content_oasis_service, "com.sun.star.comp.Draw.XMLOasisContentExporter" );
124 XML_STRING( sXML_export_draw_settings_oasis_service, "com.sun.star.comp.Draw.XMLOasisSettingsExporter" );
126 XML_STRING( sXML_import_impress_oasis_service, "com.sun.star.comp.Impress.XMLOasisImporter" );
127 XML_STRING( sXML_import_impress_meta_oasis_service, "com.sun.star.comp.Impress.XMLOasisMetaImporter" );
128 XML_STRING( sXML_import_impress_styles_oasis_service, "com.sun.star.comp.Impress.XMLOasisStylesImporter" );
129 XML_STRING( sXML_import_impress_content_oasis_service, "com.sun.star.comp.Impress.XMLOasisContentImporter" );
130 XML_STRING( sXML_import_impress_settings_oasis_service, "com.sun.star.comp.Impress.XMLOasisSettingsImporter" );
132 XML_STRING( sXML_import_draw_oasis_service, "com.sun.star.comp.Draw.XMLOasisImporter" );
133 XML_STRING( sXML_import_draw_meta_oasis_service, "com.sun.star.comp.Draw.XMLOasisMetaImporter" );
134 XML_STRING( sXML_import_draw_styles_oasis_service, "com.sun.star.comp.Draw.XMLOasisStylesImporter" );
135 XML_STRING( sXML_import_draw_content_oasis_service, "com.sun.star.comp.Draw.XMLOasisContentImporter" );
136 XML_STRING( sXML_import_draw_settings_oasis_service, "com.sun.star.comp.Draw.XMLOasisSettingsImporter" );
138 // OOo
139 XML_STRING( sXML_export_impress_ooo_service, "com.sun.star.comp.Impress.XMLExporter" );
140 XML_STRING( sXML_export_impress_meta_ooo_service, "com.sun.star.comp.Impress.XMLMetaExporter" );
141 XML_STRING( sXML_export_impress_styles_ooo_service, "com.sun.star.comp.Impress.XMLStylesExporter" );
142 XML_STRING( sXML_export_impress_content_ooo_service, "com.sun.star.comp.Impress.XMLContentExporter" );
143 XML_STRING( sXML_export_impress_settings_ooo_service, "com.sun.star.comp.Impress.XMLSettingsExporter" );
145 XML_STRING( sXML_export_draw_ooo_service, "com.sun.star.comp.Draw.XMLExporter" );
146 XML_STRING( sXML_export_draw_meta_ooo_service, "com.sun.star.comp.Draw.XMLMetaExporter" );
147 XML_STRING( sXML_export_draw_styles_ooo_service, "com.sun.star.comp.Draw.XMLStylesExporter" );
148 XML_STRING( sXML_export_draw_content_ooo_service, "com.sun.star.comp.Draw.XMLContentExporter" );
149 XML_STRING( sXML_export_draw_settings_ooo_service, "com.sun.star.comp.Draw.XMLSettingsExporter" );
151 XML_STRING( sXML_import_impress_ooo_service, "com.sun.star.comp.Impress.XMLImporter" );
152 XML_STRING( sXML_import_impress_meta_ooo_service, "com.sun.star.comp.Impress.XMLMetaImporter" );
153 XML_STRING( sXML_import_impress_styles_ooo_service, "com.sun.star.comp.Impress.XMLStylesImporter" );
154 XML_STRING( sXML_import_impress_content_ooo_service, "com.sun.star.comp.Impress.XMLContentImporter" );
155 XML_STRING( sXML_import_impress_settings_ooo_service, "com.sun.star.comp.Impress.XMLSettingsImporter" );
157 XML_STRING( sXML_import_draw_ooo_service, "com.sun.star.comp.Draw.XMLImporter" );
158 XML_STRING( sXML_import_draw_meta_ooo_service, "com.sun.star.comp.Draw.XMLMetaImporter" );
159 XML_STRING( sXML_import_draw_styles_ooo_service, "com.sun.star.comp.Draw.XMLStylesImporter" );
160 XML_STRING( sXML_import_draw_content_ooo_service, "com.sun.star.comp.Draw.XMLContentImporter" );
161 XML_STRING( sXML_import_draw_settings_ooo_service, "com.sun.star.comp.Draw.XMLSettingsImporter" );
163 struct XML_SERVICEMAP
165 const sal_Char* mpService;
166 const sal_Char* mpStream;
167 sal_Bool mbPlain;
170 struct XML_SERVICES
172 const sal_Char* mpAll;
173 const sal_Char* mpMeta;
174 const sal_Char* mpStyles;
175 const sal_Char* mpContent;
176 const sal_Char* mpSettings;
179 XML_SERVICES* getServices( bool bImport, bool bDraw, ULONG nStoreVer )
181 static XML_SERVICES gServices[] =
183 { sXML_export_impress_oasis_service, sXML_export_impress_meta_oasis_service, sXML_export_impress_styles_oasis_service, sXML_export_impress_content_oasis_service, sXML_export_impress_settings_oasis_service },
184 { sXML_export_draw_oasis_service, sXML_export_draw_meta_oasis_service, sXML_export_draw_styles_oasis_service, sXML_export_draw_content_oasis_service, sXML_export_draw_settings_oasis_service },
185 { sXML_import_impress_oasis_service, sXML_import_impress_meta_oasis_service, sXML_import_impress_styles_oasis_service, sXML_import_impress_content_oasis_service, sXML_import_impress_settings_oasis_service },
186 { sXML_import_draw_oasis_service, sXML_import_draw_meta_oasis_service, sXML_import_draw_styles_oasis_service, sXML_import_draw_content_oasis_service, sXML_import_draw_settings_oasis_service },
188 { sXML_export_impress_ooo_service, sXML_export_impress_meta_ooo_service, sXML_export_impress_styles_ooo_service, sXML_export_impress_content_ooo_service, sXML_export_impress_settings_ooo_service },
189 { sXML_export_draw_ooo_service, sXML_export_draw_meta_ooo_service, sXML_export_draw_styles_ooo_service, sXML_export_draw_content_ooo_service, sXML_export_draw_settings_ooo_service },
190 { sXML_import_impress_ooo_service, sXML_import_impress_meta_ooo_service, sXML_import_impress_styles_ooo_service, sXML_import_impress_content_ooo_service, sXML_import_impress_settings_ooo_service },
191 { sXML_import_draw_ooo_service, sXML_import_draw_meta_ooo_service, sXML_import_draw_styles_ooo_service, sXML_import_draw_content_ooo_service, sXML_import_draw_settings_ooo_service },
194 return &gServices[ (bImport ? 2 : 0) + ((nStoreVer == SOFFICE_FILEFORMAT_60) ? 4 : 0) + (bDraw ? 1 : 0 ) ];
198 // ----------------
199 // - SdXMLWrapper -
200 // ----------------
202 SdXMLFilter::SdXMLFilter( SfxMedium& rMedium, ::sd::DrawDocShell& rDocShell, sal_Bool bShowProgress, SdXMLFilterMode eFilterMode, ULONG nStoreVer ) :
203 SdFilter( rMedium, rDocShell, bShowProgress ), meFilterMode( eFilterMode ), mnStoreVer( nStoreVer )
207 SdXMLFilter::~SdXMLFilter(void)
211 sal_Int32 ReadThroughComponent(
212 Reference<io::XInputStream> xInputStream,
213 Reference<XComponent> xModelComponent,
214 const String& rStreamName,
215 Reference<lang::XMultiServiceFactory> & rFactory,
216 const sal_Char* pFilterName,
217 Sequence<Any> rFilterArguments,
218 const OUString& rName,
219 sal_Bool bMustBeSuccessfull,
220 sal_Bool bEncrypted )
222 DBG_ASSERT(xInputStream.is(), "input stream missing");
223 DBG_ASSERT(xModelComponent.is(), "document missing");
224 DBG_ASSERT(rFactory.is(), "factory missing");
225 DBG_ASSERT(NULL != pFilterName,"I need a service name for the component!");
227 RTL_LOGFILE_CONTEXT( aLog, "ReadThroughComponent" );
229 // prepare ParserInputSrouce
230 xml::sax::InputSource aParserInput;
231 aParserInput.sSystemId = rName;
232 aParserInput.aInputStream = xInputStream;
234 // get parser
235 Reference< xml::sax::XParser > xParser(
236 rFactory->createInstance(
237 OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
238 UNO_QUERY );
239 DBG_ASSERT( xParser.is(), "Can't create parser" );
240 if( !xParser.is() )
241 return SD_XML_READERROR;
242 RTL_LOGFILE_CONTEXT_TRACE( aLog, "parser created" );
244 // get filter
245 Reference< xml::sax::XDocumentHandler > xFilter(
246 rFactory->createInstanceWithArguments(
247 OUString::createFromAscii(pFilterName), rFilterArguments),
248 UNO_QUERY );
249 DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." );
250 if( !xFilter.is() )
251 return SD_XML_READERROR;
252 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "%s created", pFilterName );
254 // connect parser and filter
255 xParser->setDocumentHandler( xFilter );
257 // connect model and filter
258 Reference < XImporter > xImporter( xFilter, UNO_QUERY );
259 xImporter->setTargetDocument( xModelComponent );
260 // finally, parser the stream
261 RTL_LOGFILE_CONTEXT_TRACE( aLog, "parsing stream" );
264 xParser->parseStream( aParserInput );
266 catch( xml::sax::SAXParseException& r )
268 if( bEncrypted )
269 return ERRCODE_SFX_WRONGPASSWORD;
271 #if OSL_DEBUG_LEVEL > 1
272 ByteString aError( "SAX parse exception catched while importing:\n" );
273 aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
274 DBG_ERROR( aError.GetBuffer() );
275 #endif
277 String sErr( String::CreateFromInt32( r.LineNumber ));
278 sErr += ',';
279 sErr += String::CreateFromInt32( r.ColumnNumber );
281 if( rStreamName.Len() )
283 return *new TwoStringErrorInfo(
284 (bMustBeSuccessfull ? ERR_FORMAT_FILE_ROWCOL
285 : WARN_FORMAT_FILE_ROWCOL),
286 rStreamName, sErr,
287 ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
289 else
291 DBG_ASSERT( bMustBeSuccessfull, "Warnings are not supported" );
292 return *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
293 ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
296 catch( xml::sax::SAXException& r )
298 (void)r;
299 if( bEncrypted )
300 return ERRCODE_SFX_WRONGPASSWORD;
302 #if OSL_DEBUG_LEVEL > 1
303 ByteString aError( "SAX exception catched while importing:\n" );
304 aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
305 DBG_ERROR( aError.GetBuffer() );
306 #endif
307 return SD_XML_READERROR;
309 catch( packages::zip::ZipIOException& r )
311 (void)r;
312 #if OSL_DEBUG_LEVEL > 1
313 ByteString aError( "Zip exception catched while importing:\n" );
314 aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
315 DBG_ERROR( aError.GetBuffer() );
316 #endif
317 return ERRCODE_IO_BROKENPACKAGE;
319 catch( io::IOException& r )
321 (void)r;
322 #if OSL_DEBUG_LEVEL > 1
323 ByteString aError( "IO exception catched while importing:\n" );
324 aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
325 DBG_ERROR( aError.GetBuffer() );
326 #endif
327 return SD_XML_READERROR;
329 catch( uno::Exception& r )
331 (void)r;
332 #if OSL_DEBUG_LEVEL > 1
333 ByteString aError( "uno exception catched while importing:\n" );
334 aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
335 DBG_ERROR( aError.GetBuffer() );
336 #endif
337 return SD_XML_READERROR;
340 // success!
341 return 0;
344 sal_Int32 ReadThroughComponent(
345 const uno::Reference < embed::XStorage >& xStorage,
346 Reference<XComponent> xModelComponent,
347 const sal_Char* pStreamName,
348 const sal_Char* pCompatibilityStreamName,
349 Reference<lang::XMultiServiceFactory> & rFactory,
350 const sal_Char* pFilterName,
351 Sequence<Any> rFilterArguments,
352 const OUString& rName,
353 sal_Bool bMustBeSuccessfull )
355 DBG_ASSERT(xStorage.is(), "Need storage!");
356 DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!");
358 // open stream (and set parser input)
359 OUString sStreamName = OUString::createFromAscii(pStreamName);
360 sal_Bool bContainsStream = sal_False;
363 bContainsStream = xStorage->isStreamElement(sStreamName);
365 catch( container::NoSuchElementException& )
369 if (!bContainsStream )
371 // stream name not found! Then try the compatibility name.
372 // if no stream can be opened, return immediatly with OK signal
374 // do we even have an alternative name?
375 if ( NULL == pCompatibilityStreamName )
376 return 0;
378 // if so, does the stream exist?
379 sStreamName = OUString::createFromAscii(pCompatibilityStreamName);
382 bContainsStream = xStorage->isStreamElement(sStreamName);
384 catch( container::NoSuchElementException& )
388 if (! bContainsStream )
389 return 0;
392 // set Base URL
393 uno::Reference< beans::XPropertySet > xInfoSet;
394 if( rFilterArguments.getLength() > 0 )
395 rFilterArguments.getConstArray()[0] >>= xInfoSet;
396 DBG_ASSERT( xInfoSet.is(), "missing property set" );
397 if( xInfoSet.is() )
399 OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("StreamName") );
400 xInfoSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
405 // get input stream
406 Reference <io::XStream> xStream =
407 xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
408 Reference <beans::XPropertySet > xProps( xStream, uno::UNO_QUERY );
409 if ( !xStream.is() || ! xProps.is() )
410 return SD_XML_READERROR;
412 Any aAny = xProps->getPropertyValue(
413 OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ) );
415 sal_Bool bEncrypted = aAny.getValueType() == ::getBooleanCppuType() &&
416 *(sal_Bool *)aAny.getValue();
418 Reference <io::XInputStream> xInputStream = xStream->getInputStream();
420 // read from the stream
421 return ReadThroughComponent(
422 xInputStream, xModelComponent, sStreamName, rFactory,
423 pFilterName, rFilterArguments,
424 rName, bMustBeSuccessfull, bEncrypted );
426 catch ( packages::WrongPasswordException& )
428 return ERRCODE_SFX_WRONGPASSWORD;
430 catch( packages::zip::ZipIOException& )
432 return ERRCODE_IO_BROKENPACKAGE;
434 catch ( uno::Exception& )
437 return SD_XML_READERROR;
440 // -----------------------------------------------------------------------------
442 sal_Bool SdXMLFilter::Import( ErrCode& nError )
444 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sd", "cl93746", "SdXMLFilter::Import" );
445 #ifdef TIMELOG
446 ByteString aFile( mrMedium.GetName(), RTL_TEXTENCODING_ASCII_US );
447 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "importing %s", aFile.GetBuffer() );
448 #endif
450 sal_uInt32 nRet = 0;
452 // Get service factory
453 Reference< lang::XMultiServiceFactory > xServiceFactory =
454 comphelper::getProcessServiceFactory();
455 DBG_ASSERT( xServiceFactory.is(),
456 "XMLReader::Read: got no service manager" );
457 if( !xServiceFactory.is() )
458 return sal_False;
460 // -------------------------------------
462 SdDrawDocument* pDoc = mrDocShell.GetDoc();
463 pDoc->EnableUndo(false);
464 pDoc->NewOrLoadCompleted( NEW_DOC );
465 pDoc->CreateFirstPages();
466 pDoc->StopWorkStartupDelay();
468 // -------------------------------------
470 mxModel->lockControllers();
472 // -------------------------------------
474 /** property map for export info set */
475 PropertyMapEntry aImportInfoMap[] =
477 // #80365# necessary properties for XML progress bar at load time
478 { MAP_LEN( "ProgressRange" ), 0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
479 { MAP_LEN( "ProgressMax" ), 0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
480 { MAP_LEN( "ProgressCurrent" ), 0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
481 { MAP_LEN( "Preview" ), 0, &::getCppuType((const sal_Bool*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
482 { MAP_LEN( "PageLayouts" ), 0, SEQTYPE(::getCppuType((const uno::Reference< container::XNameAccess >*)0)), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
483 { MAP_LEN( "PrivateData" ), 0,
484 &::getCppuType( (Reference<XInterface> *)0 ),
485 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
486 { MAP_LEN( "BaseURI" ), 0,
487 &::getCppuType( (OUString *)0 ),
488 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
489 { MAP_LEN( "StreamRelPath" ), 0,
490 &::getCppuType( (OUString *)0 ),
491 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
492 { MAP_LEN( "StreamName" ), 0,
493 &::getCppuType( (OUString *)0 ),
494 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
495 { MAP_LEN( "BuildId" ), 0,
496 &::getCppuType( (OUString *)0 ),
497 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
498 { NULL, 0, 0, NULL, 0, 0 }
501 uno::Reference< beans::XPropertySet > xInfoSet( GenericPropertySet_CreateInstance( new PropertySetInfo( aImportInfoMap ) ) );
502 xInfoSet->setPropertyValue( OUString::createFromAscii( "Preview" ), uno::makeAny( mrDocShell.GetDoc()->IsStarDrawPreviewMode() ) );
504 // ---- get BuildId from parent container if available
506 uno::Reference< container::XChild > xChild( mxModel, uno::UNO_QUERY );
507 if( xChild.is() )
509 uno::Reference< beans::XPropertySet > xParentSet( xChild->getParent(), uno::UNO_QUERY );
510 if( xParentSet.is() )
512 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xParentSet->getPropertySetInfo() );
513 OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("BuildId" ) );
514 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(sPropName) )
516 xInfoSet->setPropertyValue( sPropName, xParentSet->getPropertyValue(sPropName) );
521 // -------------------------------------
523 Reference< io::XActiveDataSource > xSource;
524 Reference< XInterface > xPipe;
525 Reference< document::XGraphicObjectResolver > xGraphicResolver;
526 SvXMLGraphicHelper *pGraphicHelper = 0;
527 Reference< document::XEmbeddedObjectResolver > xObjectResolver;
528 SvXMLEmbeddedObjectHelper *pObjectHelper = 0;
530 Reference< lang::XComponent > xModelComp( mxModel, uno::UNO_QUERY );
532 // -------------------------------------
534 // #80365# try to get an XStatusIndicator from the Medium
535 if( mbShowProgress )
537 SfxItemSet* pSet = mrMedium.GetItemSet();
538 if(pSet)
540 const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
541 pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
542 if (pItem)
544 pItem->GetValue() >>= mxStatusIndicator;
548 if(mxStatusIndicator.is())
550 sal_Int32 nProgressRange(1000000);
551 sal_Int32 nProgressCurrent(0);
552 OUString aMsg = String( SdResId( STR_LOAD_DOC ) );
553 mxStatusIndicator->start(aMsg, nProgressRange);
555 // set ProgressRange
556 uno::Any aProgRange;
557 aProgRange <<= nProgressRange;
558 xInfoSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ProgressRange")), aProgRange);
560 // set ProgressCurrent
561 uno::Any aProgCurrent;
562 aProgCurrent <<= nProgressCurrent;
563 xInfoSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ProgressCurrent")), aProgCurrent);
567 // -------------------------------------
568 // get the input stream (storage or stream)
569 // -------------------------------------
571 SvStorageStreamRef xDocStream;
572 Reference<io::XInputStream> xInputStream;
573 uno::Reference < embed::XStorage > xStorage = mrMedium.GetStorage();
575 if( !xStorage.is() )
576 nRet = SD_XML_READERROR;
578 if( 0 == nRet )
580 pGraphicHelper = SvXMLGraphicHelper::Create( xStorage,
581 GRAPHICHELPER_MODE_READ,
582 sal_False );
583 xGraphicResolver = pGraphicHelper;
584 pObjectHelper = SvXMLEmbeddedObjectHelper::Create(
585 xStorage, *pDoc->GetPersist(),
586 EMBEDDEDOBJECTHELPER_MODE_READ,
587 sal_False );
588 xObjectResolver = pObjectHelper;
591 // Set base URI
592 const OUString sBaseURI( RTL_CONSTASCII_USTRINGPARAM("BaseURI") );
593 xInfoSet->setPropertyValue( sBaseURI, makeAny( mrMedium.GetBaseURL() ) );
595 if( 0 == nRet && SFX_CREATE_MODE_EMBEDDED == mrDocShell.GetCreateMode() )
597 OUString aName;
598 if ( mrMedium.GetItemSet() )
600 const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
601 mrMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
602 if ( pDocHierarchItem )
603 aName = pDocHierarchItem->GetValue();
605 else
606 aName = ::rtl::OUString::createFromAscii( "dummyObjectName" );
608 if( aName.getLength() )
610 const OUString sStreamRelPath(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath"));
611 xInfoSet->setPropertyValue( sStreamRelPath, Any( aName ) );
615 // -------------------------------------
617 if( 0 == nRet )
620 // prepare filter arguments
621 Sequence<Any> aFilterArgs( 4 );
622 Any *pArgs = aFilterArgs.getArray();
623 *pArgs++ <<= xInfoSet;
624 *pArgs++ <<= xGraphicResolver;
625 *pArgs++ <<= xObjectResolver;
626 *pArgs++ <<= mxStatusIndicator;
628 Sequence<Any> aEmptyArgs( 2 );
629 pArgs = aEmptyArgs.getArray();
630 *pArgs++ <<= xInfoSet;
631 *pArgs++ <<= mxStatusIndicator;
633 const OUString aName( mrMedium.GetName() );
635 XML_SERVICES* pServices = getServices( true, IsDraw(), mnStoreVer );
637 sal_uInt32 nWarn = 0;
638 sal_uInt32 nWarn2 = 0;
639 // read storage streams
640 if( meFilterMode != SDXMLMODE_Organizer )
642 nWarn = ReadThroughComponent(
643 xStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory,
644 pServices->mpMeta,
645 aEmptyArgs, aName, sal_False );
647 nWarn2 = ReadThroughComponent(
648 xStorage, xModelComp, "settings.xml", NULL, xServiceFactory,
649 pServices->mpSettings,
650 aFilterArgs, aName, sal_False );
653 nRet = ReadThroughComponent(
654 xStorage, xModelComp, "styles.xml", NULL, xServiceFactory,
655 pServices->mpStyles,
656 aFilterArgs, aName, sal_True );
658 if( !nRet && (meFilterMode != SDXMLMODE_Organizer) )
659 nRet = ReadThroughComponent(
660 xStorage, xModelComp, "content.xml", "Content.xml", xServiceFactory,
661 pServices->mpContent,
662 aFilterArgs, aName, sal_True );
664 if( !nRet )
666 if( nWarn )
667 nRet = nWarn;
668 else if( nWarn2 )
669 nRet = nWarn2;
673 // -------------------------------------
674 if( pGraphicHelper )
675 SvXMLGraphicHelper::Destroy( pGraphicHelper );
676 xGraphicResolver = 0;
677 if( pObjectHelper )
678 SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
679 xObjectResolver = 0;
681 if( mxStatusIndicator.is() )
682 mxStatusIndicator->end();
684 if( mxModel.is() )
685 mxModel->unlockControllers();
687 if( nRet == 0 )
688 pDoc->UpdateAllLinks();
690 switch( nRet )
692 case 0: break;
693 // case ERRCODE_SFX_WRONGPASSWORD: break;
694 case SD_XML_READERROR: break;
695 case ERRCODE_IO_BROKENPACKAGE:
696 if( xStorage.is() )
698 nError = ERRCODE_IO_BROKENPACKAGE;
699 break;
701 // fall through intented
702 default:
704 // TODO/LATER: this is completely wrong! Filter code should never call ErrorHandler directly!
705 ErrorHandler::HandleError( nRet );
706 if( IsWarning( nRet ) )
707 nRet = 0;
712 // clear unused named items from item pool
714 uno::Reference< lang::XMultiServiceFactory> xModelFactory( mxModel, uno::UNO_QUERY );
715 if( xModelFactory.is() )
719 const OUString aName( RTL_CONSTASCII_USTRINGPARAM( "~clear~" ) );
720 uno::Reference< container::XNameContainer > xGradient( xModelFactory->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable") ) ), uno::UNO_QUERY );
721 if( xGradient.is() )
722 xGradient->removeByName( aName );
724 uno::Reference< container::XNameContainer > xHatch( xModelFactory->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable") ) ), uno::UNO_QUERY );
725 if( xHatch.is() )
726 xHatch->removeByName( aName );
728 uno::Reference< container::XNameContainer > xBitmap( xModelFactory->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable") ) ), uno::UNO_QUERY );
729 if( xBitmap.is() )
730 xBitmap->removeByName( aName );
732 uno::Reference< container::XNameContainer > xTransGradient( xModelFactory->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) ), uno::UNO_QUERY );
733 if( xTransGradient.is() )
734 xTransGradient->removeByName( aName );
736 uno::Reference< container::XNameContainer > xMarker( xModelFactory->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable") ) ), uno::UNO_QUERY );
737 if( xMarker.is() )
738 xMarker->removeByName( aName );
740 uno::Reference< container::XNameContainer > xDashes( xModelFactory->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable") ) ), uno::UNO_QUERY );
741 if( xDashes.is() )
742 xDashes->removeByName( aName );
744 catch( Exception& )
746 DBG_ERROR("sd::SdXMLFilter::Import(), exception during clearing of unused named items");
750 // set BuildId on XModel for later OLE object loading
751 if( xInfoSet.is() )
753 uno::Reference< beans::XPropertySet > xModelSet( mxModel, uno::UNO_QUERY );
754 if( xModelSet.is() )
756 uno::Reference< beans::XPropertySetInfo > xModelSetInfo( xModelSet->getPropertySetInfo() );
757 const OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("BuildId" ) );
759 OUString sBuildId;
760 xInfoSet->getPropertyValue(sPropName) >>= sBuildId;
762 if( xModelSetInfo.is() && xModelSetInfo->hasPropertyByName(sPropName) )
764 xModelSet->setPropertyValue( sPropName, Any( sBuildId ) );
767 bool bTransform = false;
769 if( (nRet == 0) )
771 if( sBuildId.getLength() )
773 sal_Int32 nIndex = sBuildId.indexOf('$');
774 if( nIndex != -1 )
776 sal_Int32 nUPD = sBuildId.copy( 0, nIndex ).toInt32();
778 if( nUPD == 300 )
780 sal_Int32 nBuildId = sBuildId.copy( nIndex+1 ).toInt32();
781 if( (nBuildId > 0) && (nBuildId < 9316) )
782 bTransform = true; // treat OOo 3.0 beta1 as OOo 2.x
784 else if( (nUPD == 680) || ( nUPD >= 640 && nUPD <= 645 ) )
785 bTransform = true;
788 else
790 // check for binary formats
791 const SfxFilter * pFilter = mrMedium.GetFilter();
792 if( pFilter )
794 const String& rTypeName = pFilter->GetRealTypeName();
796 if( (rTypeName.CompareToAscii( RTL_CONSTASCII_STRINGPARAM("impress_StarImpress" ) ) == 0) ||
797 (rTypeName.CompareToAscii( RTL_CONSTASCII_STRINGPARAM("draw_StarDraw" ) ) == 0) )
799 bTransform = true;
805 if( bTransform )
806 TransformOOo2xDocument( pDoc );
810 pDoc->EnableUndo(true);
811 mrDocShell.ClearUndoBuffer();
812 return nRet == 0;
815 // -----------------------------------------------------------------------------
817 sal_Bool SdXMLFilter::Export()
819 #ifdef TIMELOG
820 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sd", "cl93746", "SdXMLFilter::Export" );
821 ByteString aFile( mrMedium.GetName(), RTL_TEXTENCODING_ASCII_US );
822 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "exporting %s", aFile.GetBuffer() );
823 #endif
825 SvXMLEmbeddedObjectHelper* pObjectHelper = NULL;
826 SvXMLGraphicHelper* pGraphicHelper = NULL;
827 sal_Bool bDocRet = FALSE;
829 if( !mxModel.is() )
831 DBG_ERROR("Got NO Model in XMLExport");
832 return FALSE;
835 sal_Bool bLocked = mxModel->hasControllersLocked();
839 mxModel->lockControllers();
841 uno::Reference< lang::XServiceInfo > xServiceInfo( mxModel, uno::UNO_QUERY );
843 if( !xServiceInfo.is() || !xServiceInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GenericDrawingDocument" ) ) ) )
845 DBG_ERROR( "Model is no DrawingDocument in XMLExport" );
846 return FALSE;
849 uno::Reference< lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() );
851 if( !xServiceFactory.is() )
853 DBG_ERROR( "got no service manager" );
854 return FALSE;
857 uno::Reference< uno::XInterface > xWriter( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" ) ) ) );
859 if( !xWriter.is() )
861 DBG_ERROR( "com.sun.star.xml.sax.Writer service missing" );
862 return FALSE;
864 uno::Reference<xml::sax::XDocumentHandler> xHandler( xWriter, uno::UNO_QUERY );
866 /** property map for export info set */
867 PropertyMapEntry aExportInfoMap[] =
869 // #82003#
870 { MAP_LEN( "ProgressRange" ), 0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
871 { MAP_LEN( "ProgressMax" ), 0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
872 { MAP_LEN( "ProgressCurrent" ), 0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
873 { MAP_LEN( "UsePrettyPrinting"),0, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
874 { MAP_LEN( "GenerousListLevels"),0, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
876 { MAP_LEN( "PageLayoutNames" ), 0, SEQTYPE(::getCppuType((const OUString*)0)), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
877 { MAP_LEN( "BaseURI" ), 0,
878 &::getCppuType( (OUString *)0 ),
879 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
880 { MAP_LEN( "StreamRelPath" ), 0,
881 &::getCppuType( (OUString *)0 ),
882 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
883 { MAP_LEN( "StreamName" ), 0,
884 &::getCppuType( (OUString *)0 ),
885 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
886 { MAP_LEN( "StyleNames" ), 0,
887 &::getCppuType( (Sequence<OUString>*)0 ),
888 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
889 { MAP_LEN( "StyleFamilies" ), 0,
890 &::getCppuType( (Sequence<sal_Int32>*)0 ),
891 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
892 { MAP_LEN( "TargetStorage" ), 0, &embed::XStorage::static_type(),
893 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
895 { NULL, 0, 0, NULL, 0, 0 }
898 uno::Reference< beans::XPropertySet > xInfoSet( GenericPropertySet_CreateInstance( new PropertySetInfo( aExportInfoMap ) ) );
901 SvtSaveOptions aSaveOpt;
902 OUString sUsePrettyPrinting(RTL_CONSTASCII_USTRINGPARAM("UsePrettyPrinting"));
903 sal_Bool bUsePrettyPrinting( aSaveOpt.IsPrettyPrinting() );
904 xInfoSet->setPropertyValue( sUsePrettyPrinting, makeAny( bUsePrettyPrinting ) );
906 OUString sGenerousListLevels(RTL_CONSTASCII_USTRINGPARAM("GenerousListLevels"));
907 xInfoSet->setPropertyValue( sGenerousListLevels, makeAny( true ) );
909 const uno::Reference < embed::XStorage >& xStorage = mrMedium.GetOutputStorage();
911 // Set base URI
912 OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("BaseURI") );
913 xInfoSet->setPropertyValue( sPropName, makeAny( mrMedium.GetBaseURL( true ) ) );
915 OUString sTargetStorage( RTL_CONSTASCII_USTRINGPARAM("TargetStorage") );
916 xInfoSet->setPropertyValue( sTargetStorage, Any( xStorage ) );
918 if( SFX_CREATE_MODE_EMBEDDED == mrDocShell.GetCreateMode() )
920 OUString aName;
921 if ( mrMedium.GetItemSet() )
923 const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
924 mrMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
925 if ( pDocHierarchItem )
926 aName = pDocHierarchItem->GetValue();
929 if( aName.getLength() )
931 sPropName = OUString(RTL_CONSTASCII_USTRINGPARAM("StreamRelPath"));
932 xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
936 // initialize descriptor
937 uno::Sequence< beans::PropertyValue > aDescriptor( 1 );
938 beans::PropertyValue* pProps = aDescriptor.getArray();
940 pProps[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "FileName" ) );
941 pProps[0].Value <<= OUString( mrMedium.GetName() );
944 uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
945 uno::Reference< document::XGraphicObjectResolver > xGrfResolver;
947 // create helper for graphic and ole export if we have a storage
948 if( xStorage.is() )
950 pObjectHelper = SvXMLEmbeddedObjectHelper::Create( xStorage, *mrDocShell.GetDoc()->GetPersist(), EMBEDDEDOBJECTHELPER_MODE_WRITE, sal_False );
951 xObjectResolver = pObjectHelper;
953 pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_WRITE, FALSE );
954 xGrfResolver = pGraphicHelper;
957 // #82003#
958 if(mbShowProgress)
960 CreateStatusIndicator();
961 if(mxStatusIndicator.is())
963 sal_Int32 nProgressRange(1000000);
964 sal_Int32 nProgressCurrent(0);
965 OUString aMsg = String( SdResId( STR_SAVE_DOC ) );
966 mxStatusIndicator->start(aMsg, nProgressRange);
968 // set ProgressRange
969 uno::Any aProgRange;
970 aProgRange <<= nProgressRange;
971 xInfoSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ProgressRange")), aProgRange);
973 // set ProgressCurrent
974 uno::Any aProgCurrent;
975 aProgCurrent <<= nProgressCurrent;
976 xInfoSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ProgressCurrent")), aProgCurrent);
980 uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY );
982 XML_SERVICES* pServiceNames = getServices( false, IsDraw(), mnStoreVer );
984 XML_SERVICEMAP aServices[5]; sal_uInt16 i = 0;
985 aServices[i ].mpService = pServiceNames->mpStyles;
986 aServices[i ].mpStream = sXML_styleStreamName;
987 aServices[i++].mbPlain = sal_False;
989 aServices[i ].mpService = pServiceNames->mpContent;
990 aServices[i ].mpStream = sXML_contentStreamName;
991 aServices[i++].mbPlain = sal_False;
993 aServices[i ].mpService = pServiceNames->mpSettings;
994 aServices[i ].mpStream = sXML_settingsStreamName;
995 aServices[i++].mbPlain = sal_False;
997 if( mrDocShell.GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
999 aServices[i ].mpService = pServiceNames->mpMeta;
1000 aServices[i ].mpStream = sXML_metaStreamName;
1001 aServices[i++].mbPlain = sal_True;
1004 aServices[i].mpService = NULL;
1005 aServices[i].mpStream = NULL;
1007 XML_SERVICEMAP* pServices = aServices;
1009 // doc export
1012 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "exporting substream %s", pServices->mpStream );
1014 uno::Reference<io::XOutputStream> xDocOut;
1015 if( xStorage.is() )
1017 const OUString sDocName( OUString::createFromAscii( pServices->mpStream ) );
1018 uno::Reference<io::XStream> xStream =
1019 xStorage->openStreamElement( sDocName,
1020 embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
1022 DBG_ASSERT(xStream.is(), "Can't create output stream in package!");
1023 if( !xStream.is() )
1024 return sal_False;
1026 xDocOut = xStream->getOutputStream();
1027 Reference <beans::XPropertySet > xProps( xStream, uno::UNO_QUERY );
1028 if( !xDocOut.is() || !xProps.is() )
1029 return sal_False;
1031 uno::Any aAny; aAny <<= OUString( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
1032 xProps->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MediaType")), aAny);
1034 OUString aUseCommonPassPropName( RTL_CONSTASCII_USTRINGPARAM("UseCommonStoragePasswordEncryption") );
1035 if( pServices->mbPlain )
1036 xProps->setPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Compressed") ), uno::makeAny( (sal_Bool) sal_False ) );
1037 // if the document is encrypted even the plain streams should be encrypted
1038 xProps->setPropertyValue( aUseCommonPassPropName, uno::makeAny( (sal_Bool)sal_True ) );
1040 const OUString sStreamName( RTL_CONSTASCII_USTRINGPARAM("StreamName") );
1041 xInfoSet->setPropertyValue( sStreamName, Any( sDocName ) );
1044 uno::Reference< io::XActiveDataSource > xDocSrc( xWriter, uno::UNO_QUERY );
1045 xDocSrc->setOutputStream( xDocOut );
1047 uno::Sequence< uno::Any > aArgs( 2 + ( mxStatusIndicator.is() ? 1 : 0 ) + ( xGrfResolver.is() ? 1 : 0 ) + ( xObjectResolver.is() ? 1 : 0 ) );
1048 uno::Any* pArgs = aArgs.getArray();
1049 *pArgs++ <<= xInfoSet;
1050 if( xGrfResolver.is() ) *pArgs++ <<= xGrfResolver;
1051 if( xObjectResolver.is() ) *pArgs++ <<= xObjectResolver;
1052 if( mxStatusIndicator.is() ) *pArgs++ <<= mxStatusIndicator;
1054 *pArgs <<= xHandler;
1056 uno::Reference< document::XFilter > xFilter( xServiceFactory->createInstanceWithArguments( OUString::createFromAscii( pServices->mpService ), aArgs ), uno::UNO_QUERY );
1057 if( xFilter.is() )
1059 uno::Reference< document::XExporter > xExporter( xFilter, uno::UNO_QUERY );
1060 if( xExporter.is() )
1062 xExporter->setSourceDocument( xComponent );
1063 // outputstream will be closed by SAX parser
1064 bDocRet = xFilter->filter( aDescriptor );
1068 pServices++;
1070 while( bDocRet && pServices->mpService );
1072 // #82003#
1073 if(mbShowProgress)
1075 if(mxStatusIndicator.is())
1076 mxStatusIndicator->end();
1080 catch(uno::Exception e)
1082 #if OSL_DEBUG_LEVEL > 1
1083 ByteString aError( "uno Exception caught while exporting:\n" );
1084 aError += ByteString( String( e.Message), RTL_TEXTENCODING_ASCII_US );
1085 DBG_ERROR( aError.GetBuffer() );
1086 #endif
1087 bDocRet = sal_False;
1089 if ( !bLocked )
1090 mxModel->unlockControllers();
1092 if( pGraphicHelper )
1093 SvXMLGraphicHelper::Destroy( pGraphicHelper );
1095 if( pObjectHelper )
1096 SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
1098 return bDocRet;