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