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 <rtl/strbuf.hxx>
21 : #include <com/sun/star/container/XChild.hpp>
22 : #include <com/sun/star/beans/XPropertySetInfo.hpp>
23 : #include <com/sun/star/embed/ElementModes.hpp>
24 : #include <com/sun/star/xml/sax/SAXParseException.hpp>
25 : #include <comphelper/processfactory.hxx>
26 : #include <sfx2/docfile.hxx>
27 : #include <sfx2/docfilt.hxx>
28 : #include "drawdoc.hxx"
29 : #include <unotools/streamwrap.hxx>
30 : #include <svx/xmlgrhlp.hxx>
31 :
32 : #include "../../ui/inc/DrawDocShell.hxx"
33 :
34 : #include "sdxmlwrp.hxx"
35 : #include "strmname.h"
36 : #include <svx/xmleohlp.hxx>
37 : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
38 : #include <com/sun/star/document/XFilter.hpp>
39 : #include <com/sun/star/document/XImporter.hpp>
40 : #include <com/sun/star/document/XExporter.hpp>
41 : #include <com/sun/star/lang/XServiceInfo.hpp>
42 : #include <com/sun/star/document/XGraphicObjectResolver.hpp>
43 : #include <com/sun/star/beans/PropertyAttribute.hpp>
44 : #include <com/sun/star/container/XNameAccess.hpp>
45 : #include <com/sun/star/packages/zip/ZipIOException.hpp>
46 :
47 : #include <com/sun/star/xml/sax/XErrorHandler.hpp>
48 : #include <com/sun/star/xml/sax/XEntityResolver.hpp>
49 : #include <com/sun/star/xml/sax/InputSource.hpp>
50 : #include <com/sun/star/xml/sax/XDTDHandler.hpp>
51 : #include <com/sun/star/xml/sax/Parser.hpp>
52 : #include <com/sun/star/xml/sax/Writer.hpp>
53 : #include <com/sun/star/io/XActiveDataSource.hpp>
54 : #include <com/sun/star/io/XActiveDataControl.hpp>
55 : #include <comphelper/genericpropertyset.hxx>
56 : #include <comphelper/propertysetinfo.hxx>
57 : #include <unotools/saveopt.hxx>
58 :
59 : // include necessary for XML progress bar at load time
60 : #include <svl/itemset.hxx>
61 : #include <svl/stritem.hxx>
62 : #include <svtools/sfxecode.hxx>
63 :
64 : #include "sderror.hxx"
65 : #include "sdresid.hxx"
66 : #include "glob.hrc"
67 :
68 : #include <sfx2/frame.hxx>
69 :
70 : using namespace com::sun::star;
71 : using namespace com::sun::star::uno;
72 : using namespace com::sun::star::lang;
73 : using namespace com::sun::star::document;
74 : using namespace comphelper;
75 :
76 : #define SD_XML_READERROR 1234
77 :
78 : extern void TransformOOo2xDocument( SdDrawDocument* pDocument );
79 :
80 : char const sXML_metaStreamName[] = "meta.xml";
81 : char const sXML_styleStreamName[] = "styles.xml";
82 : char const sXML_contentStreamName[] = "content.xml";
83 : char const sXML_settingsStreamName[] = "settings.xml";
84 :
85 : char const sXML_export_impress_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisExporter";
86 : char const sXML_export_impress_meta_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisMetaExporter";
87 : char const sXML_export_impress_styles_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisStylesExporter";
88 : char const sXML_export_impress_content_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisContentExporter";
89 : char const sXML_export_impress_settings_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisSettingsExporter";
90 :
91 : char const sXML_export_draw_oasis_service[] = "com.sun.star.comp.Draw.XMLOasisExporter";
92 : char const sXML_export_draw_meta_oasis_service[] = "com.sun.star.comp.Draw.XMLOasisMetaExporter";
93 : char const sXML_export_draw_styles_oasis_service[] = "com.sun.star.comp.Draw.XMLOasisStylesExporter";
94 : char const sXML_export_draw_content_oasis_service[] = "com.sun.star.comp.Draw.XMLOasisContentExporter";
95 : char const sXML_export_draw_settings_oasis_service[] = "com.sun.star.comp.Draw.XMLOasisSettingsExporter";
96 :
97 : char const sXML_import_impress_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisImporter";
98 : char const sXML_import_impress_meta_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisMetaImporter";
99 : char const sXML_import_impress_styles_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisStylesImporter";
100 : char const sXML_import_impress_content_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisContentImporter";
101 : char const sXML_import_impress_settings_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisSettingsImporter";
102 :
103 : char const sXML_import_draw_oasis_service[] = "com.sun.star.comp.Draw.XMLOasisImporter";
104 : char const sXML_import_draw_meta_oasis_service[] = "com.sun.star.comp.Draw.XMLOasisMetaImporter";
105 : char const sXML_import_draw_styles_oasis_service[] = "com.sun.star.comp.Draw.XMLOasisStylesImporter";
106 : char const sXML_import_draw_content_oasis_service[] = "com.sun.star.comp.Draw.XMLOasisContentImporter";
107 : char const sXML_import_draw_settings_oasis_service[] = "com.sun.star.comp.Draw.XMLOasisSettingsImporter";
108 :
109 : // OOo
110 : char const sXML_export_impress_ooo_service[] = "com.sun.star.comp.Impress.XMLExporter";
111 : char const sXML_export_impress_meta_ooo_service[] = "com.sun.star.comp.Impress.XMLMetaExporter";
112 : char const sXML_export_impress_styles_ooo_service[] = "com.sun.star.comp.Impress.XMLStylesExporter";
113 : char const sXML_export_impress_content_ooo_service[] = "com.sun.star.comp.Impress.XMLContentExporter";
114 : char const sXML_export_impress_settings_ooo_service[] = "com.sun.star.comp.Impress.XMLSettingsExporter";
115 :
116 : char const sXML_export_draw_ooo_service[] = "com.sun.star.comp.Draw.XMLExporter";
117 : char const sXML_export_draw_meta_ooo_service[] = "com.sun.star.comp.Draw.XMLMetaExporter";
118 : char const sXML_export_draw_styles_ooo_service[] = "com.sun.star.comp.Draw.XMLStylesExporter";
119 : char const sXML_export_draw_content_ooo_service[] = "com.sun.star.comp.Draw.XMLContentExporter";
120 : char const sXML_export_draw_settings_ooo_service[] = "com.sun.star.comp.Draw.XMLSettingsExporter";
121 :
122 : char const sXML_import_impress_ooo_service[] = "com.sun.star.comp.Impress.XMLImporter";
123 : char const sXML_import_impress_meta_ooo_service[] = "com.sun.star.comp.Impress.XMLMetaImporter";
124 : char const sXML_import_impress_styles_ooo_service[] = "com.sun.star.comp.Impress.XMLStylesImporter";
125 : char const sXML_import_impress_content_ooo_service[] = "com.sun.star.comp.Impress.XMLContentImporter";
126 : char const sXML_import_impress_settings_ooo_service[] = "com.sun.star.comp.Impress.XMLSettingsImporter";
127 :
128 : char const sXML_import_draw_ooo_service[] = "com.sun.star.comp.Draw.XMLImporter";
129 : char const sXML_import_draw_meta_ooo_service[] = "com.sun.star.comp.Draw.XMLMetaImporter";
130 : char const sXML_import_draw_styles_ooo_service[] = "com.sun.star.comp.Draw.XMLStylesImporter";
131 : char const sXML_import_draw_content_ooo_service[] = "com.sun.star.comp.Draw.XMLContentImporter";
132 : char const sXML_import_draw_settings_ooo_service[] = "com.sun.star.comp.Draw.XMLSettingsImporter";
133 :
134 : struct XML_SERVICEMAP
135 : {
136 : const sal_Char* mpService;
137 : const sal_Char* mpStream;
138 : };
139 :
140 : struct XML_SERVICES
141 : {
142 : const sal_Char* mpAll;
143 : const sal_Char* mpMeta;
144 : const sal_Char* mpStyles;
145 : const sal_Char* mpContent;
146 : const sal_Char* mpSettings;
147 : };
148 :
149 0 : XML_SERVICES* getServices( bool bImport, bool bDraw, sal_uLong nStoreVer )
150 : {
151 : static XML_SERVICES gServices[] =
152 : {
153 : { 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 },
154 : { 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 },
155 : { 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 },
156 : { 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 },
157 :
158 : { 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 },
159 : { 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 },
160 : { 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 },
161 : { 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 },
162 : };
163 :
164 0 : return &gServices[ (bImport ? 2 : 0) + ((nStoreVer == SOFFICE_FILEFORMAT_60) ? 4 : 0) + (bDraw ? 1 : 0 ) ];
165 : }
166 :
167 :
168 :
169 : // - SdXMLWrapper -
170 :
171 :
172 0 : SdXMLFilter::SdXMLFilter( SfxMedium& rMedium, ::sd::DrawDocShell& rDocShell, sal_Bool bShowProgress, SdXMLFilterMode eFilterMode, sal_uLong nStoreVer ) :
173 0 : SdFilter( rMedium, rDocShell, bShowProgress ), meFilterMode( eFilterMode ), mnStoreVer( nStoreVer )
174 : {
175 0 : }
176 :
177 0 : SdXMLFilter::~SdXMLFilter(void)
178 : {
179 0 : }
180 :
181 0 : sal_Int32 ReadThroughComponent(
182 : Reference<io::XInputStream> xInputStream,
183 : Reference<XComponent> xModelComponent,
184 : const OUString& rStreamName,
185 : Reference<uno::XComponentContext> & rxContext,
186 : const sal_Char* pFilterName,
187 : Sequence<Any> rFilterArguments,
188 : const OUString& rName,
189 : sal_Bool bMustBeSuccessfull,
190 : sal_Bool bEncrypted )
191 : {
192 : DBG_ASSERT(xInputStream.is(), "input stream missing");
193 : DBG_ASSERT(xModelComponent.is(), "document missing");
194 : DBG_ASSERT(rxContext.is(), "factory missing");
195 : DBG_ASSERT(NULL != pFilterName,"I need a service name for the component!");
196 :
197 : SAL_INFO( "sd.filter", "ReadThroughComponent" );
198 :
199 : // prepare ParserInputSrouce
200 0 : xml::sax::InputSource aParserInput;
201 0 : aParserInput.sSystemId = rName;
202 0 : aParserInput.aInputStream = xInputStream;
203 :
204 : // get parser
205 0 : Reference< xml::sax::XParser > xParser = xml::sax::Parser::create(rxContext);
206 : SAL_INFO( "sd.filter", "parser created" );
207 :
208 : // get filter
209 0 : OUString aFilterName(OUString::createFromAscii(pFilterName));
210 : Reference< xml::sax::XDocumentHandler > xFilter(
211 0 : rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(aFilterName, rFilterArguments, rxContext),
212 0 : UNO_QUERY );
213 : SAL_WARN_IF(!xFilter.is(), "sd.filter", "Can't instantiate filter component: " << aFilterName);
214 0 : if( !xFilter.is() )
215 0 : return SD_XML_READERROR;
216 : SAL_INFO( "sd.filter", "" << pFilterName << " created" );
217 :
218 : // connect parser and filter
219 0 : xParser->setDocumentHandler( xFilter );
220 :
221 : // connect model and filter
222 0 : Reference < XImporter > xImporter( xFilter, UNO_QUERY );
223 0 : xImporter->setTargetDocument( xModelComponent );
224 : // finally, parser the stream
225 : SAL_INFO( "sd.filter", "parsing stream" );
226 : try
227 : {
228 0 : xParser->parseStream( aParserInput );
229 : }
230 0 : catch (const xml::sax::SAXParseException& r)
231 : {
232 : // sax parser sends wrapped exceptions,
233 : // try to find the original one
234 0 : xml::sax::SAXException aSaxEx = *(xml::sax::SAXException*)(&r);
235 0 : sal_Bool bTryChild = sal_True;
236 :
237 0 : while( bTryChild )
238 : {
239 0 : xml::sax::SAXException aTmp;
240 0 : if ( aSaxEx.WrappedException >>= aTmp )
241 0 : aSaxEx = aTmp;
242 : else
243 0 : bTryChild = sal_False;
244 0 : }
245 :
246 0 : packages::zip::ZipIOException aBrokenPackage;
247 0 : if ( aSaxEx.WrappedException >>= aBrokenPackage )
248 0 : return ERRCODE_IO_BROKENPACKAGE;
249 :
250 0 : if( bEncrypted )
251 0 : return ERRCODE_SFX_WRONGPASSWORD;
252 :
253 : #if OSL_DEBUG_LEVEL > 1
254 : SAL_WARN( "sd.filter", "SAX parse exception caught while importing:" << r.Message);
255 : #endif
256 :
257 0 : OUString sErr( OUString::number( r.LineNumber ));
258 0 : sErr += ",";
259 0 : sErr += OUString::number( r.ColumnNumber );
260 :
261 0 : if (!rStreamName.isEmpty())
262 : {
263 : return *new TwoStringErrorInfo(
264 : (bMustBeSuccessfull ? ERR_FORMAT_FILE_ROWCOL
265 : : WARN_FORMAT_FILE_ROWCOL),
266 : rStreamName, sErr,
267 0 : ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
268 : }
269 : else
270 : {
271 : DBG_ASSERT( bMustBeSuccessfull, "Warnings are not supported" );
272 : return *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
273 0 : ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
274 0 : }
275 : }
276 0 : catch (const xml::sax::SAXException& r)
277 : {
278 0 : packages::zip::ZipIOException aBrokenPackage;
279 0 : if ( r.WrappedException >>= aBrokenPackage )
280 0 : return ERRCODE_IO_BROKENPACKAGE;
281 :
282 0 : if( bEncrypted )
283 0 : return ERRCODE_SFX_WRONGPASSWORD;
284 :
285 : #if OSL_DEBUG_LEVEL > 1
286 : SAL_WARN( "sd.filter", "SAX exception caught while importing:" << r.Message);
287 : #endif
288 0 : return SD_XML_READERROR;
289 : }
290 0 : catch (const packages::zip::ZipIOException& r)
291 : {
292 : #if OSL_DEBUG_LEVEL > 1
293 : SAL_WARN( "sd.filter", "Zip exception caught while importing:" << r.Message);
294 : #else
295 : (void)r;
296 : #endif
297 0 : return ERRCODE_IO_BROKENPACKAGE;
298 : }
299 0 : catch (const io::IOException& r)
300 : {
301 : #if OSL_DEBUG_LEVEL > 1
302 : SAL_WARN( "sd.filter", "IO exception caught while importing:" << r.Message);
303 : #else
304 : (void)r;
305 : #endif
306 0 : return SD_XML_READERROR;
307 : }
308 0 : catch (const uno::Exception& r)
309 : {
310 : #if OSL_DEBUG_LEVEL > 1
311 : SAL_WARN( "sd.filter", "uno exception caught while importing:" << r.Message);
312 : #else
313 : (void)r;
314 : #endif
315 0 : return SD_XML_READERROR;
316 : }
317 :
318 : // success!
319 0 : return 0;
320 : }
321 :
322 0 : sal_Int32 ReadThroughComponent(
323 : const uno::Reference < embed::XStorage >& xStorage,
324 : Reference<XComponent> xModelComponent,
325 : const sal_Char* pStreamName,
326 : const sal_Char* pCompatibilityStreamName,
327 : Reference<uno::XComponentContext> & rxContext,
328 : const sal_Char* pFilterName,
329 : Sequence<Any> rFilterArguments,
330 : const OUString& rName,
331 : sal_Bool bMustBeSuccessfull )
332 : {
333 : DBG_ASSERT(xStorage.is(), "Need storage!");
334 : DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!");
335 :
336 : // open stream (and set parser input)
337 0 : OUString sStreamName = OUString::createFromAscii(pStreamName);
338 0 : sal_Bool bContainsStream = sal_False;
339 : try
340 : {
341 0 : bContainsStream = xStorage->isStreamElement(sStreamName);
342 : }
343 0 : catch (const container::NoSuchElementException&)
344 : {
345 : }
346 :
347 0 : if (!bContainsStream )
348 : {
349 : // stream name not found! Then try the compatibility name.
350 : // if no stream can be opened, return immediately with OK signal
351 :
352 : // do we even have an alternative name?
353 0 : if ( NULL == pCompatibilityStreamName )
354 0 : return 0;
355 :
356 : // if so, does the stream exist?
357 0 : sStreamName = OUString::createFromAscii(pCompatibilityStreamName);
358 : try
359 : {
360 0 : bContainsStream = xStorage->isStreamElement(sStreamName);
361 : }
362 0 : catch (const container::NoSuchElementException&)
363 : {
364 : }
365 :
366 0 : if (! bContainsStream )
367 0 : return 0;
368 : }
369 :
370 : // set Base URL
371 0 : uno::Reference< beans::XPropertySet > xInfoSet;
372 0 : if( rFilterArguments.getLength() > 0 )
373 0 : rFilterArguments.getConstArray()[0] >>= xInfoSet;
374 : DBG_ASSERT( xInfoSet.is(), "missing property set" );
375 0 : if( xInfoSet.is() )
376 : {
377 0 : OUString sPropName( "StreamName" );
378 0 : xInfoSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
379 : }
380 :
381 : try
382 : {
383 : // get input stream
384 : Reference <io::XStream> xStream =
385 0 : xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
386 0 : Reference <beans::XPropertySet > xProps( xStream, uno::UNO_QUERY );
387 0 : if ( !xStream.is() || ! xProps.is() )
388 0 : return SD_XML_READERROR;
389 :
390 0 : Any aAny = xProps->getPropertyValue( "Encrypted" );
391 :
392 0 : sal_Bool bEncrypted = aAny.getValueType() == ::getBooleanCppuType() &&
393 0 : *(sal_Bool *)aAny.getValue();
394 :
395 0 : Reference <io::XInputStream> xInputStream = xStream->getInputStream();
396 :
397 : // read from the stream
398 : return ReadThroughComponent(
399 : xInputStream, xModelComponent, sStreamName, rxContext,
400 : pFilterName, rFilterArguments,
401 0 : rName, bMustBeSuccessfull, bEncrypted );
402 : }
403 0 : catch (const packages::WrongPasswordException&)
404 : {
405 0 : return ERRCODE_SFX_WRONGPASSWORD;
406 : }
407 0 : catch (const packages::zip::ZipIOException&)
408 : {
409 0 : return ERRCODE_IO_BROKENPACKAGE;
410 : }
411 0 : catch (const uno::Exception&)
412 : {}
413 :
414 0 : return SD_XML_READERROR;
415 : }
416 :
417 :
418 :
419 0 : sal_Bool SdXMLFilter::Import( ErrCode& nError )
420 : {
421 0 : sal_uInt32 nRet = 0;
422 :
423 : // Get service factory
424 : Reference< uno::XComponentContext > rxContext =
425 0 : comphelper::getProcessComponentContext();
426 :
427 :
428 :
429 0 : SdDrawDocument* pDoc = mrDocShell.GetDoc();
430 0 : pDoc->EnableUndo(false);
431 0 : pDoc->NewOrLoadCompleted( NEW_DOC );
432 0 : pDoc->CreateFirstPages();
433 0 : pDoc->StopWorkStartupDelay();
434 :
435 :
436 :
437 0 : mxModel->lockControllers();
438 :
439 :
440 :
441 : /** property map for import info set */
442 : PropertyMapEntry const aImportInfoMap[] =
443 : {
444 : // necessary properties for XML progress bar at load time
445 0 : { OUString("ProgressRange"), 0, ::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
446 0 : { OUString("ProgressMax"), 0, ::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
447 0 : { OUString("ProgressCurrent"), 0, ::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
448 0 : { OUString("Preview"), 0, ::getCppuType((const sal_Bool*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
449 0 : { OUString("PageLayouts"), 0, ::getCppuType((const uno::Reference< container::XNameAccess >*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
450 : { OUString("PrivateData"), 0,
451 0 : ::getCppuType( (Reference<XInterface> *)0 ),
452 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
453 : { OUString("BaseURI"), 0,
454 0 : ::getCppuType( (OUString *)0 ),
455 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
456 : { OUString("StreamRelPath"), 0,
457 0 : ::getCppuType( (OUString *)0 ),
458 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
459 : { OUString("StreamName"), 0,
460 0 : ::getCppuType( (OUString *)0 ),
461 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
462 : { OUString("BuildId"), 0,
463 0 : ::getCppuType( (OUString *)0 ),
464 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
465 : { OUString("OrganizerMode"), 0,
466 0 : ::getBooleanCppuType(),
467 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
468 0 : { OUString("SourceStorage"), 0, cppu::UnoType<embed::XStorage>::get(),
469 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
470 : { OUString(), 0, css::uno::Type(), 0, 0 }
471 0 : };
472 :
473 0 : uno::Reference< beans::XPropertySet > xInfoSet( GenericPropertySet_CreateInstance( new PropertySetInfo( aImportInfoMap ) ) );
474 0 : xInfoSet->setPropertyValue( "Preview" , uno::makeAny( mrDocShell.GetDoc()->IsStarDrawPreviewMode() ) );
475 :
476 : // ---- get BuildId from parent container if available
477 :
478 0 : uno::Reference< container::XChild > xChild( mxModel, uno::UNO_QUERY );
479 0 : if( xChild.is() )
480 : {
481 0 : uno::Reference< beans::XPropertySet > xParentSet( xChild->getParent(), uno::UNO_QUERY );
482 0 : if( xParentSet.is() )
483 : {
484 0 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xParentSet->getPropertySetInfo() );
485 0 : OUString sPropName( "BuildId" );
486 0 : if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(sPropName) )
487 : {
488 0 : xInfoSet->setPropertyValue( sPropName, xParentSet->getPropertyValue(sPropName) );
489 0 : }
490 0 : }
491 : }
492 :
493 :
494 :
495 0 : Reference< io::XActiveDataSource > xSource;
496 0 : Reference< XInterface > xPipe;
497 0 : Reference< document::XGraphicObjectResolver > xGraphicResolver;
498 0 : SvXMLGraphicHelper *pGraphicHelper = 0;
499 0 : Reference< document::XEmbeddedObjectResolver > xObjectResolver;
500 0 : SvXMLEmbeddedObjectHelper *pObjectHelper = 0;
501 :
502 0 : Reference< lang::XComponent > xModelComp( mxModel, uno::UNO_QUERY );
503 :
504 :
505 :
506 : // try to get an XStatusIndicator from the Medium
507 0 : if( mbShowProgress )
508 : {
509 0 : SfxItemSet* pSet = mrMedium.GetItemSet();
510 0 : if(pSet)
511 : {
512 : const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
513 0 : pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
514 0 : if (pItem)
515 : {
516 0 : pItem->GetValue() >>= mxStatusIndicator;
517 : }
518 : }
519 :
520 0 : if(mxStatusIndicator.is())
521 : {
522 0 : sal_Int32 nProgressRange(1000000);
523 0 : sal_Int32 nProgressCurrent(0);
524 0 : OUString aMsg(SD_RESSTR(STR_LOAD_DOC));
525 0 : mxStatusIndicator->start(aMsg, nProgressRange);
526 :
527 : // set ProgressRange
528 0 : uno::Any aProgRange;
529 0 : aProgRange <<= nProgressRange;
530 0 : xInfoSet->setPropertyValue( "ProgressRange" , aProgRange);
531 :
532 : // set ProgressCurrent
533 0 : uno::Any aProgCurrent;
534 0 : aProgCurrent <<= nProgressCurrent;
535 0 : xInfoSet->setPropertyValue( "ProgressCurrent" , aProgCurrent);
536 : }
537 : }
538 :
539 :
540 : // get the input stream (storage or stream)
541 :
542 :
543 0 : SvStorageStreamRef xDocStream;
544 0 : Reference<io::XInputStream> xInputStream;
545 0 : uno::Reference < embed::XStorage > xStorage = mrMedium.GetStorage();
546 :
547 0 : OUString sSourceStorage( "SourceStorage");
548 0 : xInfoSet->setPropertyValue( sSourceStorage, Any( xStorage ) );
549 :
550 0 : if( !xStorage.is() )
551 0 : nRet = SD_XML_READERROR;
552 :
553 0 : if( 0 == nRet )
554 : {
555 : pGraphicHelper = SvXMLGraphicHelper::Create( xStorage,
556 : GRAPHICHELPER_MODE_READ,
557 0 : false );
558 0 : xGraphicResolver = pGraphicHelper;
559 : pObjectHelper = SvXMLEmbeddedObjectHelper::Create(
560 0 : xStorage, *pDoc->GetPersist(),
561 : EMBEDDEDOBJECTHELPER_MODE_READ,
562 0 : false );
563 0 : xObjectResolver = pObjectHelper;
564 : }
565 :
566 : // Set base URI
567 0 : xInfoSet->setPropertyValue( "BaseURI" , makeAny( mrMedium.GetBaseURL() ) );
568 :
569 0 : if( 0 == nRet && SFX_CREATE_MODE_EMBEDDED == mrDocShell.GetCreateMode() )
570 : {
571 0 : OUString aName;
572 0 : if ( mrMedium.GetItemSet() )
573 : {
574 : const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
575 0 : mrMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
576 0 : if ( pDocHierarchItem )
577 0 : aName = pDocHierarchItem->GetValue();
578 : }
579 : else
580 0 : aName = "dummyObjectName" ;
581 :
582 0 : if( !aName.isEmpty() )
583 0 : xInfoSet->setPropertyValue( "StreamRelPath", Any( aName ) );
584 : }
585 :
586 0 : if (SDXMLMODE_Organizer == meFilterMode)
587 0 : xInfoSet->setPropertyValue("OrganizerMode", uno::makeAny(sal_True));
588 :
589 :
590 :
591 0 : if( 0 == nRet )
592 : {
593 :
594 : // prepare filter arguments
595 0 : Sequence<Any> aFilterArgs( 4 );
596 0 : Any *pArgs = aFilterArgs.getArray();
597 0 : *pArgs++ <<= xInfoSet;
598 0 : *pArgs++ <<= xGraphicResolver;
599 0 : *pArgs++ <<= xObjectResolver;
600 0 : *pArgs++ <<= mxStatusIndicator;
601 :
602 0 : Sequence<Any> aEmptyArgs( 2 );
603 0 : pArgs = aEmptyArgs.getArray();
604 0 : *pArgs++ <<= xInfoSet;
605 0 : *pArgs++ <<= mxStatusIndicator;
606 :
607 0 : const OUString aName( mrMedium.GetName() );
608 :
609 0 : XML_SERVICES* pServices = getServices( true, IsDraw(), mnStoreVer );
610 :
611 0 : sal_uInt32 nWarn = 0;
612 0 : sal_uInt32 nWarn2 = 0;
613 : // read storage streams
614 : // #i103539#: always read meta.xml for generator
615 : nWarn = ReadThroughComponent(
616 : xStorage, xModelComp, "meta.xml", "Meta.xml", rxContext,
617 : pServices->mpMeta,
618 0 : aEmptyArgs, aName, sal_False );
619 :
620 0 : if( meFilterMode != SDXMLMODE_Organizer )
621 : {
622 : nWarn2 = ReadThroughComponent(
623 : xStorage, xModelComp, "settings.xml", NULL, rxContext,
624 : pServices->mpSettings,
625 0 : aFilterArgs, aName, sal_False );
626 : }
627 :
628 : nRet = ReadThroughComponent(
629 : xStorage, xModelComp, "styles.xml", NULL, rxContext,
630 : pServices->mpStyles,
631 0 : aFilterArgs, aName, sal_True );
632 :
633 0 : if( !nRet && (meFilterMode != SDXMLMODE_Organizer) )
634 : nRet = ReadThroughComponent(
635 : xStorage, xModelComp, "content.xml", "Content.xml", rxContext,
636 : pServices->mpContent,
637 0 : aFilterArgs, aName, sal_True );
638 :
639 0 : if( !nRet )
640 : {
641 0 : if( nWarn )
642 0 : nRet = nWarn;
643 0 : else if( nWarn2 )
644 0 : nRet = nWarn2;
645 0 : }
646 : }
647 :
648 :
649 0 : if( pGraphicHelper )
650 0 : SvXMLGraphicHelper::Destroy( pGraphicHelper );
651 0 : xGraphicResolver = 0;
652 0 : if( pObjectHelper )
653 0 : SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
654 0 : xObjectResolver = 0;
655 :
656 0 : if( mxStatusIndicator.is() )
657 0 : mxStatusIndicator->end();
658 :
659 0 : if( mxModel.is() )
660 0 : mxModel->unlockControllers();
661 :
662 0 : if( nRet == 0 )
663 0 : pDoc->UpdateAllLinks();
664 :
665 0 : switch( nRet )
666 : {
667 0 : case 0: break;
668 0 : case SD_XML_READERROR: break;
669 : case ERRCODE_IO_BROKENPACKAGE:
670 0 : if( xStorage.is() )
671 : {
672 0 : nError = ERRCODE_IO_BROKENPACKAGE;
673 0 : break;
674 : }
675 : // fall through intented
676 : default:
677 : {
678 : // TODO/LATER: this is completely wrong! Filter code should never call ErrorHandler directly!
679 0 : ErrorHandler::HandleError( nRet );
680 0 : if( IsWarning( nRet ) )
681 0 : nRet = 0;
682 : }
683 : }
684 :
685 :
686 : // clear unused named items from item pool
687 :
688 0 : uno::Reference< lang::XMultiServiceFactory> xModelFactory( mxModel, uno::UNO_QUERY );
689 0 : if( xModelFactory.is() )
690 : {
691 : try
692 : {
693 0 : const OUString aName("~clear~" );
694 0 : uno::Reference< container::XNameContainer > xGradient( xModelFactory->createInstance( "com.sun.star.drawing.GradientTable" ), uno::UNO_QUERY );
695 0 : if( xGradient.is() )
696 0 : xGradient->removeByName( aName );
697 :
698 0 : uno::Reference< container::XNameContainer > xHatch( xModelFactory->createInstance( "com.sun.star.drawing.HatchTable" ), uno::UNO_QUERY );
699 0 : if( xHatch.is() )
700 0 : xHatch->removeByName( aName );
701 :
702 0 : uno::Reference< container::XNameContainer > xBitmap( xModelFactory->createInstance( "com.sun.star.drawing.BitmapTable" ), uno::UNO_QUERY );
703 0 : if( xBitmap.is() )
704 0 : xBitmap->removeByName( aName );
705 :
706 0 : uno::Reference< container::XNameContainer > xTransGradient( xModelFactory->createInstance( "com.sun.star.drawing.TransparencyGradientTable" ), uno::UNO_QUERY );
707 0 : if( xTransGradient.is() )
708 0 : xTransGradient->removeByName( aName );
709 :
710 0 : uno::Reference< container::XNameContainer > xMarker( xModelFactory->createInstance( "com.sun.star.drawing.MarkerTable" ), uno::UNO_QUERY );
711 0 : if( xMarker.is() )
712 0 : xMarker->removeByName( aName );
713 :
714 0 : uno::Reference< container::XNameContainer > xDashes( xModelFactory->createInstance( "com.sun.star.drawing.DashTable" ), uno::UNO_QUERY );
715 0 : if( xDashes.is() )
716 0 : xDashes->removeByName( aName );
717 : }
718 0 : catch (const Exception&)
719 : {
720 : SAL_WARN( "sd.filter","sd::SdXMLFilter::Import(), exception during clearing of unused named items");
721 : }
722 : }
723 :
724 : // set BuildId on XModel for later OLE object loading
725 0 : if( xInfoSet.is() )
726 : {
727 0 : uno::Reference< beans::XPropertySet > xModelSet( mxModel, uno::UNO_QUERY );
728 0 : if( xModelSet.is() )
729 : {
730 0 : uno::Reference< beans::XPropertySetInfo > xModelSetInfo( xModelSet->getPropertySetInfo() );
731 0 : const OUString sPropName( "BuildId" );
732 :
733 0 : OUString sBuildId;
734 0 : xInfoSet->getPropertyValue(sPropName) >>= sBuildId;
735 :
736 0 : if( xModelSetInfo.is() && xModelSetInfo->hasPropertyByName(sPropName) )
737 : {
738 0 : xModelSet->setPropertyValue( sPropName, Any( sBuildId ) );
739 : }
740 :
741 0 : bool bTransform = false;
742 :
743 0 : if( nRet == 0 )
744 : {
745 0 : if( !sBuildId.isEmpty() )
746 : {
747 0 : sal_Int32 nIndex = sBuildId.indexOf('$');
748 0 : if( nIndex != -1 )
749 : {
750 0 : sal_Int32 nUPD = sBuildId.copy( 0, nIndex ).toInt32();
751 :
752 0 : if( nUPD == 300 )
753 : {
754 0 : sal_Int32 nBuildId = sBuildId.copy( nIndex+1 ).toInt32();
755 0 : if( (nBuildId > 0) && (nBuildId < 9316) )
756 0 : bTransform = true; // treat OOo 3.0 beta1 as OOo 2.x
757 : }
758 0 : else if( (nUPD == 680) || ( nUPD >= 640 && nUPD <= 645 ) )
759 0 : bTransform = true;
760 : }
761 : }
762 : else
763 : {
764 : // check for binary formats
765 0 : const SfxFilter * pFilter = mrMedium.GetFilter();
766 0 : if( pFilter )
767 : {
768 0 : OUString typeName(pFilter->GetRealTypeName());
769 0 : if( typeName.startsWith( "impress_StarImpress" ) ||
770 0 : typeName.startsWith( "draw_StarDraw" ) )
771 : {
772 0 : bTransform = true;
773 0 : }
774 : }
775 : }
776 : }
777 :
778 0 : if( bTransform )
779 0 : TransformOOo2xDocument( pDoc );
780 0 : }
781 : }
782 :
783 0 : pDoc->EnableUndo(true);
784 0 : mrDocShell.ClearUndoBuffer();
785 0 : return nRet == 0;
786 : }
787 :
788 :
789 :
790 0 : sal_Bool SdXMLFilter::Export()
791 : {
792 0 : SvXMLEmbeddedObjectHelper* pObjectHelper = NULL;
793 0 : SvXMLGraphicHelper* pGraphicHelper = NULL;
794 0 : sal_Bool bDocRet = sal_False;
795 :
796 0 : if( !mxModel.is() )
797 : {
798 : SAL_WARN( "sd.filter","Got NO Model in XMLExport");
799 0 : return sal_False;
800 : }
801 :
802 0 : sal_Bool bLocked = mxModel->hasControllersLocked();
803 :
804 : try
805 : {
806 0 : mxModel->lockControllers();
807 :
808 0 : uno::Reference< lang::XServiceInfo > xServiceInfo( mxModel, uno::UNO_QUERY );
809 :
810 0 : if( !xServiceInfo.is() || !xServiceInfo->supportsService( "com.sun.star.drawing.GenericDrawingDocument" ) )
811 : {
812 : SAL_WARN( "sd.filter", "Model is no DrawingDocument in XMLExport" );
813 0 : return sal_False;
814 : }
815 :
816 0 : uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
817 :
818 0 : uno::Reference< xml::sax::XWriter > xWriter = xml::sax::Writer::create( xContext );
819 :
820 : /** property map for export info set */
821 : PropertyMapEntry const aExportInfoMap[] =
822 : {
823 0 : { OUString("ProgressRange"), 0, ::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
824 0 : { OUString("ProgressMax"), 0, ::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
825 0 : { OUString("ProgressCurrent"), 0, ::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
826 0 : { OUString("UsePrettyPrinting"),0, ::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
827 :
828 0 : { OUString("PageLayoutNames"), 0, ::getCppuType((const OUString*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
829 : { OUString("BaseURI"), 0,
830 0 : ::getCppuType( (OUString *)0 ),
831 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
832 : { OUString("StreamRelPath"), 0,
833 0 : ::getCppuType( (OUString *)0 ),
834 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
835 : { OUString("StreamName"), 0,
836 0 : ::getCppuType( (OUString *)0 ),
837 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
838 : { OUString("StyleNames"), 0,
839 0 : ::getCppuType( (Sequence<OUString>*)0 ),
840 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
841 : { OUString("StyleFamilies"), 0,
842 0 : ::getCppuType( (Sequence<sal_Int32>*)0 ),
843 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
844 0 : { OUString("TargetStorage"), 0, cppu::UnoType<embed::XStorage>::get(),
845 : ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
846 : { OUString(), 0, css::uno::Type(), 0, 0 }
847 0 : };
848 :
849 0 : uno::Reference< beans::XPropertySet > xInfoSet( GenericPropertySet_CreateInstance( new PropertySetInfo( aExportInfoMap ) ) );
850 :
851 :
852 0 : SvtSaveOptions aSaveOpt;
853 0 : OUString sUsePrettyPrinting("UsePrettyPrinting");
854 0 : sal_Bool bUsePrettyPrinting( aSaveOpt.IsPrettyPrinting() );
855 0 : xInfoSet->setPropertyValue( sUsePrettyPrinting, makeAny( bUsePrettyPrinting ) );
856 :
857 0 : const uno::Reference < embed::XStorage >& xStorage = mrMedium.GetOutputStorage();
858 :
859 : // Set base URI
860 0 : OUString sPropName( "BaseURI" );
861 0 : xInfoSet->setPropertyValue( sPropName, makeAny( mrMedium.GetBaseURL( true ) ) );
862 :
863 0 : OUString sTargetStorage( "TargetStorage" );
864 0 : xInfoSet->setPropertyValue( sTargetStorage, Any( xStorage ) );
865 :
866 0 : if( SFX_CREATE_MODE_EMBEDDED == mrDocShell.GetCreateMode() )
867 : {
868 0 : OUString aName;
869 0 : if ( mrMedium.GetItemSet() )
870 : {
871 : const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
872 0 : mrMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
873 0 : if ( pDocHierarchItem )
874 0 : aName = pDocHierarchItem->GetValue();
875 : }
876 :
877 0 : if( !aName.isEmpty() )
878 : {
879 0 : sPropName = "StreamRelPath";
880 0 : xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
881 0 : }
882 : }
883 :
884 : // initialize descriptor
885 0 : uno::Sequence< beans::PropertyValue > aDescriptor( 1 );
886 0 : beans::PropertyValue* pProps = aDescriptor.getArray();
887 :
888 0 : pProps[0].Name = "FileName";
889 0 : pProps[0].Value <<= OUString( mrMedium.GetName() );
890 :
891 : {
892 0 : uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
893 0 : uno::Reference< document::XGraphicObjectResolver > xGrfResolver;
894 :
895 : // create helper for graphic and ole export if we have a storage
896 0 : if( xStorage.is() )
897 : {
898 0 : pObjectHelper = SvXMLEmbeddedObjectHelper::Create( xStorage, *mrDocShell.GetDoc()->GetPersist(), EMBEDDEDOBJECTHELPER_MODE_WRITE, false );
899 0 : xObjectResolver = pObjectHelper;
900 :
901 0 : pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_WRITE, false );
902 0 : xGrfResolver = pGraphicHelper;
903 : }
904 :
905 0 : if(mbShowProgress)
906 : {
907 0 : CreateStatusIndicator();
908 0 : if(mxStatusIndicator.is())
909 : {
910 0 : sal_Int32 nProgressRange(1000000);
911 0 : sal_Int32 nProgressCurrent(0);
912 0 : OUString aMsg(SD_RESSTR(STR_SAVE_DOC));
913 0 : mxStatusIndicator->start(aMsg, nProgressRange);
914 :
915 : // set ProgressRange
916 0 : uno::Any aProgRange;
917 0 : aProgRange <<= nProgressRange;
918 0 : xInfoSet->setPropertyValue( "ProgressRange" , aProgRange);
919 :
920 : // set ProgressCurrent
921 0 : uno::Any aProgCurrent;
922 0 : aProgCurrent <<= nProgressCurrent;
923 0 : xInfoSet->setPropertyValue( "ProgressCurrent" , aProgCurrent);
924 : }
925 : }
926 :
927 0 : uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY );
928 :
929 0 : XML_SERVICES* pServiceNames = getServices( false, IsDraw(), mnStoreVer );
930 :
931 0 : XML_SERVICEMAP aServices[5]; sal_uInt16 i = 0;
932 0 : aServices[i ].mpService = pServiceNames->mpStyles;
933 0 : aServices[i++].mpStream = sXML_styleStreamName;
934 :
935 0 : aServices[i ].mpService = pServiceNames->mpContent;
936 0 : aServices[i++].mpStream = sXML_contentStreamName;
937 :
938 0 : aServices[i ].mpService = pServiceNames->mpSettings;
939 0 : aServices[i++].mpStream = sXML_settingsStreamName;
940 :
941 0 : if( mrDocShell.GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
942 : {
943 0 : aServices[i ].mpService = pServiceNames->mpMeta;
944 0 : aServices[i++].mpStream = sXML_metaStreamName;
945 : };
946 :
947 0 : aServices[i].mpService = NULL;
948 0 : aServices[i].mpStream = NULL;
949 :
950 0 : XML_SERVICEMAP* pServices = aServices;
951 :
952 : // doc export
953 0 : do
954 : {
955 : SAL_INFO( "sd.filter", "exporting substream " << pServices->mpStream );
956 :
957 0 : uno::Reference<io::XOutputStream> xDocOut;
958 0 : if( xStorage.is() )
959 : {
960 0 : const OUString sDocName( OUString::createFromAscii( pServices->mpStream ) );
961 : uno::Reference<io::XStream> xStream =
962 0 : xStorage->openStreamElement( sDocName,
963 0 : embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
964 :
965 : DBG_ASSERT(xStream.is(), "Can't create output stream in package!");
966 0 : if( !xStream.is() )
967 0 : return sal_False;
968 :
969 0 : xDocOut = xStream->getOutputStream();
970 0 : Reference <beans::XPropertySet > xProps( xStream, uno::UNO_QUERY );
971 0 : if( !xDocOut.is() || !xProps.is() )
972 0 : return sal_False;
973 :
974 0 : uno::Any aAny;
975 0 : aAny <<= OUString( "text/xml");
976 0 : xProps->setPropertyValue( "MediaType" , aAny);
977 :
978 : // encrypt all streams
979 0 : xProps->setPropertyValue( "UseCommonStoragePasswordEncryption",
980 0 : uno::makeAny( (sal_Bool)sal_True ) );
981 :
982 0 : const OUString sStreamName( "StreamName");
983 0 : xInfoSet->setPropertyValue( sStreamName, Any( sDocName ) );
984 : }
985 :
986 0 : uno::Reference< io::XActiveDataSource > xDocSrc( xWriter, uno::UNO_QUERY );
987 0 : xDocSrc->setOutputStream( xDocOut );
988 :
989 0 : uno::Sequence< uno::Any > aArgs( 2 + ( mxStatusIndicator.is() ? 1 : 0 ) + ( xGrfResolver.is() ? 1 : 0 ) + ( xObjectResolver.is() ? 1 : 0 ) );
990 0 : uno::Any* pArgs = aArgs.getArray();
991 0 : *pArgs++ <<= xInfoSet;
992 0 : if( xGrfResolver.is() ) *pArgs++ <<= xGrfResolver;
993 0 : if( xObjectResolver.is() ) *pArgs++ <<= xObjectResolver;
994 0 : if( mxStatusIndicator.is() ) *pArgs++ <<= mxStatusIndicator;
995 :
996 0 : *pArgs <<= xWriter;
997 :
998 0 : uno::Reference< document::XFilter > xFilter( xContext->getServiceManager()->createInstanceWithArgumentsAndContext( OUString::createFromAscii( pServices->mpService ), aArgs, xContext ), uno::UNO_QUERY );
999 0 : if( xFilter.is() )
1000 : {
1001 0 : uno::Reference< document::XExporter > xExporter( xFilter, uno::UNO_QUERY );
1002 0 : if( xExporter.is() )
1003 : {
1004 0 : xExporter->setSourceDocument( xComponent );
1005 : // outputstream will be closed by SAX parser
1006 0 : bDocRet = xFilter->filter( aDescriptor );
1007 0 : }
1008 : }
1009 :
1010 0 : pServices++;
1011 : }
1012 0 : while( bDocRet && pServices->mpService );
1013 :
1014 0 : if(mbShowProgress)
1015 : {
1016 0 : if(mxStatusIndicator.is())
1017 0 : mxStatusIndicator->end();
1018 0 : }
1019 0 : }
1020 : }
1021 0 : catch (const uno::Exception &e)
1022 : {
1023 : #if OSL_DEBUG_LEVEL > 1
1024 : SAL_WARN( "sd.filter", "uno Exception caught while exporting:" << e.Message);
1025 : #else
1026 : (void)e;
1027 : #endif
1028 0 : bDocRet = sal_False;
1029 : }
1030 0 : if ( !bLocked )
1031 0 : mxModel->unlockControllers();
1032 :
1033 0 : if( pGraphicHelper )
1034 0 : SvXMLGraphicHelper::Destroy( pGraphicHelper );
1035 :
1036 0 : if( pObjectHelper )
1037 0 : SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
1038 :
1039 0 : return bDocRet;
1040 0 : }
1041 :
1042 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|