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 <sal/config.h>
21 :
22 : #include <boost/noncopyable.hpp>
23 : #include <com/sun/star/packages/zip/ZipIOException.hpp>
24 : #include <com/sun/star/embed/ElementModes.hpp>
25 : #include <com/sun/star/beans/NamedValue.hpp>
26 : #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
27 : #include <com/sun/star/util/MeasureUnit.hpp>
28 : #include <com/sun/star/xml/sax/Parser.hpp>
29 : #include "xmlfilter.hxx"
30 : #include "xmlGroup.hxx"
31 : #include "xmlReport.hxx"
32 : #include "xmlHelper.hxx"
33 : #include <vcl/svapp.hxx>
34 : #include <vcl/window.hxx>
35 : #include <connectivity/dbtools.hxx>
36 : #include <xmloff/xmlnmspe.hxx>
37 : #include <xmloff/xmltoken.hxx>
38 : #include <xmloff/txtimp.hxx>
39 : #include <xmloff/nmspmap.hxx>
40 : #include <xmloff/XMLFontStylesContext.hxx>
41 : #include <com/sun/star/xml/sax/InputSource.hpp>
42 : #include <com/sun/star/xml/sax/XParser.hpp>
43 : #include <com/sun/star/beans/PropertyAttribute.hpp>
44 :
45 : #include <comphelper/processfactory.hxx>
46 : #include <comphelper/genericpropertyset.hxx>
47 : #include <unotools/mediadescriptor.hxx>
48 : #include <xmloff/ProgressBarHelper.hxx>
49 : #include <sfx2/docfile.hxx>
50 : #include <com/sun/star/io/XInputStream.hpp>
51 : #include <com/sun/star/uno/XNamingService.hpp>
52 : #include <xmloff/DocumentSettingsContext.hxx>
53 : #include <xmloff/xmluconv.hxx>
54 : #include <xmloff/xmlmetai.hxx>
55 : #include <com/sun/star/util/XModifiable.hpp>
56 : #include <osl/mutex.hxx>
57 : #include <svtools/sfxecode.hxx>
58 : #include "xmlEnums.hxx"
59 : #include "xmlStyleImport.hxx"
60 : #include "xmlstrings.hrc"
61 : #include "xmlPropertyHandler.hxx"
62 : #include <xmloff/txtprmap.hxx>
63 : #include "ReportDefinition.hxx"
64 :
65 : namespace rptxml
66 : {
67 : using namespace ::com::sun::star::uno;
68 : using ::com::sun::star::uno::Reference;
69 : using namespace ::com::sun::star;
70 : using namespace ::com::sun::star::container;
71 : using namespace ::com::sun::star::lang;
72 : using namespace ::com::sun::star::beans;
73 : using namespace ::com::sun::star::document;
74 : using namespace ::com::sun::star::text;
75 : using namespace ::com::sun::star::io;
76 : using namespace ::com::sun::star::report;
77 : using namespace ::com::sun::star::xml::sax;
78 : using namespace xmloff;
79 : sal_Char const sXML_np__rpt[] = "_report";
80 : sal_Char const sXML_np___rpt[] = "__report";
81 :
82 : using namespace ::com::sun::star::util;
83 :
84 : class RptMLMasterStylesContext_Impl:
85 : public XMLTextMasterStylesContext, private boost::noncopyable
86 : {
87 : ORptFilter& m_rImport;
88 :
89 : public:
90 :
91 : TYPEINFO_OVERRIDE();
92 :
93 : RptMLMasterStylesContext_Impl(
94 : ORptFilter& rImport, sal_uInt16 nPrfx,
95 : const OUString& rLName ,
96 : const uno::Reference< xml::sax::XAttributeList > & xAttrList );
97 : virtual ~RptMLMasterStylesContext_Impl();
98 : virtual void EndElement() SAL_OVERRIDE;
99 : };
100 :
101 0 : TYPEINIT1( RptMLMasterStylesContext_Impl, XMLTextMasterStylesContext );
102 0 : RptMLMasterStylesContext_Impl::RptMLMasterStylesContext_Impl(
103 : ORptFilter& rImport, sal_uInt16 nPrfx,
104 : const OUString& rLName ,
105 : const uno::Reference< xml::sax::XAttributeList > & xAttrList ) :
106 : XMLTextMasterStylesContext( rImport, nPrfx, rLName, xAttrList )
107 0 : ,m_rImport(rImport)
108 : {
109 0 : }
110 :
111 0 : RptMLMasterStylesContext_Impl::~RptMLMasterStylesContext_Impl()
112 : {
113 0 : }
114 :
115 0 : void RptMLMasterStylesContext_Impl::EndElement()
116 : {
117 0 : FinishStyles( true );
118 0 : m_rImport.FinishStyles();
119 0 : }
120 :
121 : /// read a component (file + filter version)
122 0 : sal_Int32 ReadThroughComponent(
123 : const uno::Reference<XInputStream>& xInputStream,
124 : const uno::Reference<XComponent>& xModelComponent,
125 : const sal_Char* /*pStreamName*/,
126 : const uno::Reference<XComponentContext> & rContext,
127 : const uno::Reference< XDocumentHandler >& _xFilter,
128 : bool /*bEncrypted*/ )
129 : {
130 : OSL_ENSURE(xInputStream.is(), "input stream missing");
131 : OSL_ENSURE(xModelComponent.is(), "document missing");
132 : OSL_ENSURE(rContext.is(), "factory missing");
133 :
134 : // prepare ParserInputSrouce
135 0 : InputSource aParserInput;
136 0 : aParserInput.aInputStream = xInputStream;
137 :
138 : // get parser
139 0 : uno::Reference< XParser > xParser = xml::sax::Parser::create(rContext);
140 : SAL_INFO( "reportdesign", "parser created" );
141 : // get filter
142 : OSL_ENSURE( _xFilter.is(), "Can't instantiate filter component." );
143 0 : if( !_xFilter.is() )
144 0 : return 1;
145 :
146 : // connect parser and filter
147 0 : xParser->setDocumentHandler( _xFilter );
148 :
149 : // connect model and filter
150 0 : uno::Reference < XImporter > xImporter( _xFilter, UNO_QUERY );
151 0 : xImporter->setTargetDocument( xModelComponent );
152 :
153 : // finally, parser the stream
154 : try
155 : {
156 0 : xParser->parseStream( aParserInput );
157 : }
158 0 : catch (const SAXParseException& r)
159 : {
160 : #if OSL_DEBUG_LEVEL > 1
161 : OStringBuffer aError("SAX parse exception caught while importing:\n");
162 : aError.append(OUStringToOString(r.Message,
163 : RTL_TEXTENCODING_ASCII_US));
164 : aError.append(r.LineNumber);
165 : aError.append(',');
166 : aError.append(r.ColumnNumber);
167 : OSL_FAIL(aError.getStr());
168 : #else
169 : (void)r;
170 : #endif
171 0 : return 1;
172 : }
173 0 : catch (const SAXException&)
174 : {
175 0 : return 1;
176 : }
177 0 : catch (const packages::zip::ZipIOException&)
178 : {
179 0 : return ERRCODE_IO_BROKENPACKAGE;
180 : }
181 0 : catch (const IOException&)
182 : {
183 0 : return 1;
184 : }
185 0 : catch (const Exception&)
186 : {
187 0 : return 1;
188 : }
189 :
190 : // success!
191 0 : return 0;
192 : }
193 :
194 : /// read a component (storage version)
195 0 : sal_Int32 ReadThroughComponent(
196 : uno::Reference< embed::XStorage > xStorage,
197 : const uno::Reference<XComponent>& xModelComponent,
198 : const sal_Char* pStreamName,
199 : const sal_Char* pCompatibilityStreamName,
200 : const uno::Reference<XComponentContext> & rxContext,
201 : const Reference< document::XGraphicObjectResolver > & _xGraphicObjectResolver,
202 : const Reference<document::XEmbeddedObjectResolver>& _xEmbeddedObjectResolver,
203 : const OUString& _sFilterName
204 : ,const uno::Reference<beans::XPropertySet>& _xProp)
205 : {
206 : OSL_ENSURE( xStorage.is(), "Need storage!");
207 : OSL_ENSURE(NULL != pStreamName, "Please, please, give me a name!");
208 :
209 0 : if ( xStorage.is() )
210 : {
211 0 : uno::Reference< io::XStream > xDocStream;
212 0 : bool bEncrypted = false;
213 :
214 : try
215 : {
216 : // open stream (and set parser input)
217 0 : OUString sStreamName = OUString::createFromAscii(pStreamName);
218 0 : if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) )
219 : {
220 : // stream name not found! Then try the compatibility name.
221 : // if no stream can be opened, return immediately with OK signal
222 :
223 : // do we even have an alternative name?
224 0 : if ( NULL == pCompatibilityStreamName )
225 0 : return 0;
226 :
227 : // if so, does the stream exist?
228 0 : sStreamName = OUString::createFromAscii(pCompatibilityStreamName);
229 0 : if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) )
230 0 : return 0;
231 : }
232 :
233 : // get input stream
234 0 : xDocStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
235 :
236 0 : uno::Reference< beans::XPropertySet > xProps( xDocStream, uno::UNO_QUERY_THROW );
237 0 : xProps->getPropertyValue("Encrypted") >>= bEncrypted;
238 : }
239 0 : catch (const packages::WrongPasswordException&)
240 : {
241 0 : return ERRCODE_SFX_WRONGPASSWORD;
242 : }
243 0 : catch (const uno::Exception&)
244 : {
245 0 : return 1; // TODO/LATER: error handling
246 : }
247 :
248 0 : sal_Int32 nArgs = 0;
249 0 : if( _xGraphicObjectResolver.is())
250 0 : nArgs++;
251 0 : if( _xEmbeddedObjectResolver.is())
252 0 : nArgs++;
253 0 : if ( _xProp.is() )
254 0 : nArgs++;
255 :
256 0 : uno::Sequence< uno::Any > aFilterCompArgs( nArgs );
257 :
258 0 : nArgs = 0;
259 0 : if( _xGraphicObjectResolver.is())
260 0 : aFilterCompArgs[nArgs++] <<= _xGraphicObjectResolver;
261 0 : if( _xEmbeddedObjectResolver.is())
262 0 : aFilterCompArgs[ nArgs++ ] <<= _xEmbeddedObjectResolver;
263 0 : if ( _xProp.is() )
264 0 : aFilterCompArgs[ nArgs++ ] <<= _xProp;
265 :
266 : Reference< xml::sax::XDocumentHandler > xDocHandler(
267 0 : rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(_sFilterName, aFilterCompArgs, rxContext),
268 0 : uno::UNO_QUERY_THROW );
269 0 : uno::Reference< XInputStream > xInputStream = xDocStream->getInputStream();
270 : // read from the stream
271 : return ReadThroughComponent( xInputStream
272 : ,xModelComponent
273 : ,pStreamName
274 : ,rxContext
275 : ,xDocHandler
276 0 : ,bEncrypted );
277 : }
278 :
279 : // TODO/LATER: better error handling
280 0 : return 1;
281 : }
282 :
283 :
284 0 : uno::Reference< uno::XInterface > ORptImportHelper::create(uno::Reference< uno::XComponentContext > const & xContext)
285 : {
286 0 : return static_cast< XServiceInfo* >(new ORptFilter(xContext, IMPORT_SETTINGS ));
287 : }
288 :
289 0 : OUString ORptImportHelper::getImplementationName_Static( ) throw (RuntimeException)
290 : {
291 0 : return OUString(SERVICE_SETTINGSIMPORTER);
292 : }
293 :
294 0 : Sequence< OUString > ORptImportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
295 : {
296 0 : Sequence< OUString > aSupported(1);
297 0 : aSupported[0] = SERVICE_IMPORTFILTER;
298 0 : return aSupported;
299 : }
300 :
301 0 : Reference< XInterface > ORptContentImportHelper::create(const Reference< XComponentContext > & xContext)
302 : {
303 : return static_cast< XServiceInfo* >(new ORptFilter(xContext,IMPORT_AUTOSTYLES | IMPORT_CONTENT | IMPORT_SCRIPTS |
304 0 : IMPORT_FONTDECLS ));
305 : }
306 :
307 0 : OUString ORptContentImportHelper::getImplementationName_Static( ) throw (RuntimeException)
308 : {
309 0 : return OUString(SERVICE_CONTENTIMPORTER);
310 : }
311 :
312 0 : Sequence< OUString > ORptContentImportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
313 : {
314 0 : Sequence< OUString > aSupported(1);
315 0 : aSupported[0] = SERVICE_IMPORTFILTER;
316 0 : return aSupported;
317 : }
318 :
319 :
320 0 : Reference< XInterface > ORptStylesImportHelper::create(Reference< XComponentContext > const & xContext)
321 : {
322 : return static_cast< XServiceInfo* >(new ORptFilter(xContext,
323 : IMPORT_STYLES | IMPORT_MASTERSTYLES | IMPORT_AUTOSTYLES |
324 0 : IMPORT_FONTDECLS ));
325 : }
326 :
327 0 : OUString ORptStylesImportHelper::getImplementationName_Static( ) throw (RuntimeException)
328 : {
329 0 : return OUString(SERVICE_STYLESIMPORTER);
330 : }
331 :
332 0 : Sequence< OUString > ORptStylesImportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
333 : {
334 0 : Sequence< OUString > aSupported(1);
335 0 : aSupported[0] = SERVICE_IMPORTFILTER;
336 0 : return aSupported;
337 : }
338 :
339 :
340 0 : Reference< XInterface > ORptMetaImportHelper::create(Reference< XComponentContext > const & xContext)
341 : {
342 : return static_cast< XServiceInfo* >(new ORptFilter(xContext,
343 0 : IMPORT_META));
344 : }
345 :
346 0 : OUString ORptMetaImportHelper::getImplementationName_Static( ) throw (RuntimeException)
347 : {
348 0 : return OUString(SERVICE_METAIMPORTER);
349 : }
350 :
351 0 : Sequence< OUString > ORptMetaImportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
352 : {
353 0 : Sequence< OUString > aSupported(1);
354 0 : aSupported[0] = SERVICE_IMPORTFILTER;
355 0 : return aSupported;
356 : }
357 :
358 :
359 : // - ORptFilter -
360 :
361 0 : ORptFilter::ORptFilter( const uno::Reference< XComponentContext >& _rxContext,sal_uInt16 nImportFlags )
362 0 : :SvXMLImport(_rxContext, getImplementationName_Static(), nImportFlags)
363 : {
364 0 : GetMM100UnitConverter().SetCoreMeasureUnit(util::MeasureUnit::MM_100TH);
365 0 : GetMM100UnitConverter().SetXMLMeasureUnit(util::MeasureUnit::CM);
366 0 : GetNamespaceMap().Add( OUString( sXML_np__rpt ),
367 0 : GetXMLToken(XML_N_RPT),
368 0 : XML_NAMESPACE_REPORT );
369 :
370 0 : GetNamespaceMap().Add( OUString( sXML_np___rpt ),
371 0 : GetXMLToken(XML_N_RPT_OASIS),
372 0 : XML_NAMESPACE_REPORT );
373 :
374 0 : m_xPropHdlFactory = new OXMLRptPropHdlFactory;
375 0 : m_xCellStylesPropertySetMapper = OXMLHelper::GetCellStylePropertyMap(true, false);
376 0 : m_xColumnStylesPropertySetMapper = new XMLPropertySetMapper(OXMLHelper::GetColumnStyleProps(), m_xPropHdlFactory, false);
377 0 : m_xRowStylesPropertySetMapper = new XMLPropertySetMapper(OXMLHelper::GetRowStyleProps(), m_xPropHdlFactory, false);
378 0 : m_xTableStylesPropertySetMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TABLE_DEFAULTS, false );
379 0 : }
380 :
381 :
382 :
383 0 : ORptFilter::~ORptFilter() throw()
384 : {
385 0 : }
386 :
387 0 : uno::Reference< XInterface > ORptFilter::create(uno::Reference< XComponentContext > const & xContext)
388 : {
389 0 : return *(new ORptFilter(xContext));
390 : }
391 :
392 :
393 0 : OUString ORptFilter::getImplementationName_Static( ) throw(uno::RuntimeException)
394 : {
395 0 : return OUString("com.sun.star.comp.report.OReportFilter");
396 : }
397 :
398 0 : uno::Sequence< OUString > ORptFilter::getSupportedServiceNames_Static( ) throw(uno::RuntimeException)
399 : {
400 0 : uno::Sequence< OUString > aServices(1);
401 0 : aServices.getArray()[0] = SERVICE_IMPORTFILTER;
402 :
403 0 : return aServices;
404 : }
405 :
406 0 : sal_Bool SAL_CALL ORptFilter::filter( const Sequence< PropertyValue >& rDescriptor )
407 : throw (RuntimeException, std::exception)
408 : {
409 0 : vcl::Window* pFocusWindow = Application::GetFocusWindow();
410 0 : bool bRet = false;
411 :
412 0 : if( pFocusWindow )
413 0 : pFocusWindow->EnterWait();
414 :
415 0 : if ( GetModel().is() )
416 0 : bRet = implImport( rDescriptor );
417 :
418 0 : if ( pFocusWindow )
419 0 : pFocusWindow->LeaveWait();
420 :
421 0 : return bRet;
422 : }
423 :
424 0 : bool ORptFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
425 : throw (RuntimeException)
426 : {
427 0 : OUString sFileName;
428 0 : uno::Reference< embed::XStorage > xStorage;
429 0 : uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier;
430 :
431 0 : const PropertyValue* pIter = rDescriptor.getConstArray();
432 0 : const PropertyValue* pEnd = pIter + rDescriptor.getLength();
433 0 : for(;pIter != pEnd;++pIter)
434 : {
435 0 : if ( pIter->Name == "FileName" )
436 0 : pIter->Value >>= sFileName;
437 0 : else if ( pIter->Name == "Storage" )
438 0 : pIter->Value >>= xStorage;
439 0 : else if ( pIter->Name == "ComponentData" )
440 : {
441 0 : Sequence< PropertyValue > aComponent;
442 0 : pIter->Value >>= aComponent;
443 0 : const PropertyValue* pComponentIter = aComponent.getConstArray();
444 0 : const PropertyValue* pComponentEnd = pComponentIter + aComponent.getLength();
445 0 : for(;pComponentIter != pComponentEnd;++pComponentIter)
446 : {
447 0 : if ( pComponentIter->Name == "ActiveConnection" )
448 : {
449 0 : uno::Reference<sdbc::XConnection> xCon(pComponentIter->Value,uno::UNO_QUERY);
450 0 : xNumberFormatsSupplier = ::dbtools::getNumberFormats(xCon);
451 0 : break;
452 : }
453 0 : }
454 : }
455 : }
456 :
457 0 : if ( !sFileName.isEmpty() )
458 : {
459 0 : uno::Reference<XComponent> xCom(GetModel(),UNO_QUERY);
460 :
461 : SfxMediumRef pMedium = new SfxMedium(
462 0 : sFileName, ( STREAM_READ | STREAM_NOCREATE ) );
463 :
464 0 : if( pMedium )
465 : {
466 : try
467 : {
468 0 : xStorage = pMedium->GetStorage();
469 : }
470 0 : catch (const Exception&)
471 : {
472 : }
473 0 : }
474 : }
475 0 : bool bRet = xStorage.is();
476 0 : if ( bRet )
477 : {
478 0 : m_xReportDefinition.set(GetModel(),UNO_QUERY_THROW);
479 : OSL_ENSURE(m_xReportDefinition.is(),"ReportDefinition is NULL!");
480 0 : if ( !m_xReportDefinition.is() )
481 0 : return false;
482 :
483 : #if OSL_DEBUG_LEVEL > 1
484 : uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY );
485 : uno::Sequence< OUString> aSeq = xAccess->getElementNames();
486 : const OUString* pDebugIter = aSeq.getConstArray();
487 : const OUString* pDebugEnd = pDebugIter + aSeq.getLength();
488 : for(;pDebugIter != pDebugEnd;++pDebugIter)
489 : {
490 : (void)*pDebugIter;
491 : }
492 : #endif
493 :
494 0 : Reference< document::XGraphicObjectResolver > xGraphicObjectResolver;
495 0 : uno::Reference<document::XEmbeddedObjectResolver> xEmbeddedObjectResolver;
496 0 : uno::Reference< uno::XComponentContext > xContext = GetComponentContext();
497 :
498 0 : uno::Sequence< uno::Any > aArgs(1);
499 0 : aArgs[0] <<= xStorage;
500 : xGraphicObjectResolver.set(
501 0 : xContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.comp.Svx.GraphicImportHelper", aArgs, xContext),
502 0 : uno::UNO_QUERY );
503 :
504 0 : uno::Reference< lang::XMultiServiceFactory > xReportServiceFactory( m_xReportDefinition, uno::UNO_QUERY);
505 0 : aArgs[0] <<= beans::NamedValue(OUString("Storage"),uno::makeAny(xStorage));
506 0 : xEmbeddedObjectResolver.set( xReportServiceFactory->createInstanceWithArguments(OUString("com.sun.star.document.ImportEmbeddedObjectResolver"),aArgs) , uno::UNO_QUERY);
507 :
508 0 : static const OUString s_sOld("OldFormat");
509 : static comphelper::PropertyMapEntry const pMap[] =
510 : {
511 0 : { OUString("OldFormat") , 1, cppu::UnoType<sal_Bool>::get(), beans::PropertyAttribute::BOUND, 0 },
512 0 : { OUString("StreamName"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
513 0 : { OUString("PrivateData"),0, cppu::UnoType<XInterface>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
514 0 : { OUString("BaseURI"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
515 0 : { OUString("StreamRelPath"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
516 : { OUString(), 0, css::uno::Type(), 0, 0 }
517 0 : };
518 0 : utl::MediaDescriptor aDescriptor(rDescriptor);
519 0 : uno::Reference<beans::XPropertySet> xProp = comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(pMap));
520 0 : const OUString sVal( aDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_DOCUMENTBASEURL(),OUString()) );
521 0 : xProp->setPropertyValue("BaseURI", uno::makeAny(sVal));
522 0 : const OUString sHierarchicalDocumentName( aDescriptor.getUnpackedValueOrDefault("HierarchicalDocumentName",OUString()) );
523 0 : xProp->setPropertyValue("StreamRelPath", uno::makeAny(sHierarchicalDocumentName));
524 :
525 0 : uno::Reference<XComponent> xModel(GetModel(),UNO_QUERY);
526 0 : static const OUString s_sMeta("meta.xml");
527 0 : static const OUString s_sStreamName("StreamName");
528 0 : xProp->setPropertyValue(s_sStreamName, uno::makeAny(s_sMeta));
529 : sal_Int32 nRet = ReadThroughComponent( xStorage
530 : ,xModel
531 : ,"meta.xml"
532 : ,"Meta.xml"
533 : ,GetComponentContext()
534 : ,xGraphicObjectResolver
535 : ,xEmbeddedObjectResolver
536 : ,SERVICE_METAIMPORTER
537 : ,xProp
538 0 : );
539 :
540 :
541 : try
542 : {
543 0 : xProp->setPropertyValue(s_sOld,uno::makeAny(!(xStorage->hasByName(s_sMeta) || xStorage->isStreamElement( s_sMeta ))));
544 : }
545 0 : catch (const uno::Exception&)
546 : {
547 0 : xProp->setPropertyValue(s_sOld,uno::makeAny(sal_True));
548 : }
549 :
550 0 : if ( nRet == 0 )
551 : {
552 0 : xProp->setPropertyValue(s_sStreamName, uno::makeAny(OUString("settings.xml")));
553 : nRet = ReadThroughComponent( xStorage
554 : ,xModel
555 : ,"settings.xml"
556 : ,"Settings.xml"
557 : ,GetComponentContext()
558 : ,xGraphicObjectResolver
559 : ,xEmbeddedObjectResolver
560 : ,SERVICE_SETTINGSIMPORTER
561 : ,xProp
562 0 : );
563 : }
564 0 : if ( nRet == 0 )
565 : {
566 0 : xProp->setPropertyValue(s_sStreamName, uno::makeAny(OUString("styles.xml")));
567 : nRet = ReadThroughComponent(xStorage
568 : ,xModel
569 : ,"styles.xml"
570 : ,"Styles.xml"
571 : ,GetComponentContext()
572 : ,xGraphicObjectResolver
573 : ,xEmbeddedObjectResolver
574 : ,SERVICE_STYLESIMPORTER
575 0 : ,xProp);
576 : }
577 :
578 0 : if ( nRet == 0 )
579 : {
580 0 : xProp->setPropertyValue(s_sStreamName, uno::makeAny(OUString("content.xml")));
581 : nRet = ReadThroughComponent( xStorage
582 : ,xModel
583 : ,"content.xml"
584 : ,"Content.xml"
585 : ,GetComponentContext()
586 : ,xGraphicObjectResolver
587 : ,xEmbeddedObjectResolver
588 : ,SERVICE_CONTENTIMPORTER
589 : ,xProp
590 0 : );
591 : }
592 :
593 :
594 0 : bRet = nRet == 0;
595 :
596 0 : if ( bRet )
597 : {
598 0 : m_xReportDefinition->setModified(sal_False);
599 : }
600 : else
601 : {
602 0 : switch( nRet )
603 : {
604 : case ERRCODE_IO_BROKENPACKAGE:
605 0 : if( xStorage.is() )
606 : {
607 : // TODO/LATER: no way to transport the error outside from the filter!
608 0 : break;
609 : }
610 : // fall through intented
611 : default:
612 : {
613 : // TODO/LATER: this is completely wrong! Filter code should never call ErrorHandler directly! But for now this is the only way!
614 0 : ErrorHandler::HandleError( nRet );
615 0 : if( nRet & ERRCODE_WARNING_MASK )
616 0 : bRet = true;
617 : }
618 : }
619 0 : }
620 : }
621 :
622 0 : return bRet;
623 : }
624 :
625 0 : SvXMLImportContext* ORptFilter::CreateContext( sal_uInt16 nPrefix,
626 : const OUString& rLocalName,
627 : const uno::Reference< xml::sax::XAttributeList >& xAttrList )
628 : {
629 0 : SvXMLImportContext *pContext = 0;
630 :
631 0 : const SvXMLTokenMap& rTokenMap = GetDocElemTokenMap();
632 0 : switch( rTokenMap.Get( nPrefix, rLocalName ) )
633 : {
634 : case XML_TOK_DOC_SETTINGS:
635 0 : GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
636 0 : pContext = new XMLDocumentSettingsContext( *this, nPrefix, rLocalName,xAttrList );
637 0 : break;
638 : case XML_TOK_DOC_REPORT:
639 0 : GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
640 : {
641 0 : const SvXMLStylesContext* pAutoStyles = GetAutoStyles();
642 0 : if ( pAutoStyles )
643 : {
644 0 : XMLPropStyleContext* pAutoStyle = const_cast<XMLPropStyleContext*>(PTR_CAST(XMLPropStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_PAGE_MASTER,OUString("pm1"))));
645 0 : if ( pAutoStyle )
646 : {
647 0 : pAutoStyle->FillPropertySet(getReportDefinition().get());
648 : }
649 : }
650 0 : pContext = new OXMLReport( *this, nPrefix, rLocalName,xAttrList,getReportDefinition(),NULL );
651 : }
652 0 : break;
653 : case XML_TOK_DOC_STYLES:
654 0 : GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
655 0 : pContext = CreateStylesContext( rLocalName, xAttrList, false);
656 0 : break;
657 : case XML_TOK_DOC_AUTOSTYLES:
658 : // don't use the autostyles from the styles-document for the progress
659 0 : if ( ! IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) )
660 0 : GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
661 0 : pContext = CreateStylesContext( rLocalName, xAttrList, true);
662 0 : break;
663 : case XML_TOK_DOC_FONTDECLS:
664 0 : GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
665 0 : pContext = CreateFontDeclsContext( rLocalName,xAttrList );
666 0 : break;
667 : case XML_TOK_DOC_MASTERSTYLES:
668 : {
669 0 : SvXMLStylesContext* pStyleContext = new RptMLMasterStylesContext_Impl(*this, nPrefix, rLocalName,xAttrList);//CreateMasterStylesContext( rLocalName,xAttrList );
670 0 : pContext = pStyleContext;
671 0 : SetMasterStyles( pStyleContext );
672 : }
673 0 : break;
674 : case XML_TOK_DOC_META:
675 0 : GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
676 0 : pContext = CreateMetaContext( rLocalName,xAttrList );
677 0 : break;
678 : default:
679 0 : break;
680 : }
681 :
682 0 : if ( !pContext )
683 0 : pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
684 :
685 0 : return pContext;
686 : }
687 :
688 0 : const SvXMLTokenMap& ORptFilter::GetDocElemTokenMap() const
689 : {
690 0 : if ( !m_pDocElemTokenMap.get() )
691 : {
692 : static const SvXMLTokenMapEntry aElemTokenMap[]=
693 : {
694 : { XML_NAMESPACE_OFFICE, XML_SETTINGS, XML_TOK_DOC_SETTINGS },
695 : { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES },
696 : { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES },
697 : { XML_NAMESPACE_OFFICE, XML_REPORT, XML_TOK_DOC_REPORT },
698 : { XML_NAMESPACE_OOO, XML_REPORT, XML_TOK_DOC_REPORT },
699 : { XML_NAMESPACE_OFFICE, XML_FONT_FACE_DECLS, XML_TOK_DOC_FONTDECLS },
700 : { XML_NAMESPACE_OFFICE, XML_MASTER_STYLES, XML_TOK_DOC_MASTERSTYLES },
701 : { XML_NAMESPACE_OFFICE, XML_DOCUMENT_META, XML_TOK_DOC_META },
702 : XML_TOKEN_MAP_END
703 : };
704 0 : m_pDocElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
705 : }
706 0 : return *m_pDocElemTokenMap;
707 : }
708 :
709 0 : const SvXMLTokenMap& ORptFilter::GetReportElemTokenMap() const
710 : {
711 0 : if ( !m_pReportElemTokenMap.get() )
712 0 : m_pReportElemTokenMap.reset(OXMLHelper::GetReportElemTokenMap());
713 0 : return *m_pReportElemTokenMap;
714 : }
715 :
716 0 : const SvXMLTokenMap& ORptFilter::GetSubDocumentElemTokenMap() const
717 : {
718 0 : if ( !m_pSubDocumentElemTokenMap.get() )
719 0 : m_pSubDocumentElemTokenMap.reset(OXMLHelper::GetSubDocumentElemTokenMap());
720 0 : return *m_pSubDocumentElemTokenMap;
721 : }
722 :
723 0 : const SvXMLTokenMap& ORptFilter::GetFunctionElemTokenMap() const
724 : {
725 0 : if ( !m_pFunctionElemTokenMap.get() )
726 : {
727 : static const SvXMLTokenMapEntry aElemTokenMap[]=
728 : {
729 : { XML_NAMESPACE_REPORT, XML_NAME, XML_TOK_FUNCTION_NAME },
730 : { XML_NAMESPACE_REPORT, XML_FORMULA, XML_TOK_FUNCTION_FORMULA},
731 : { XML_NAMESPACE_REPORT, XML_PRE_EVALUATED, XML_TOK_PRE_EVALUATED },
732 : { XML_NAMESPACE_REPORT, XML_INITIAL_FORMULA,XML_TOK_INITIAL_FORMULA },
733 : { XML_NAMESPACE_REPORT, XML_DEEP_TRAVERSING,XML_TOK_DEEP_TRAVERSING },
734 : XML_TOKEN_MAP_END
735 : };
736 0 : m_pFunctionElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
737 : }
738 0 : return *m_pFunctionElemTokenMap;
739 : }
740 :
741 0 : const SvXMLTokenMap& ORptFilter::GetFormatElemTokenMap() const
742 : {
743 0 : if ( !m_pFormatElemTokenMap.get() )
744 : {
745 : static const SvXMLTokenMapEntry aElemTokenMap[]=
746 : {
747 : { XML_NAMESPACE_REPORT, XML_ENABLED , XML_TOK_ENABLED },
748 : { XML_NAMESPACE_REPORT, XML_FORMULA , XML_TOK_FORMULA },
749 : { XML_NAMESPACE_REPORT, XML_STYLE_NAME , XML_TOK_FORMAT_STYLE_NAME },
750 : XML_TOKEN_MAP_END
751 : };
752 0 : m_pFormatElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
753 : }
754 0 : return *m_pFormatElemTokenMap;
755 : }
756 :
757 0 : const SvXMLTokenMap& ORptFilter::GetGroupElemTokenMap() const
758 : {
759 0 : if ( !m_pGroupElemTokenMap.get() )
760 : {
761 : static const SvXMLTokenMapEntry aElemTokenMap[]=
762 : {
763 : { XML_NAMESPACE_REPORT, XML_START_NEW_COLUMN , XML_TOK_START_NEW_COLUMN },
764 : { XML_NAMESPACE_REPORT, XML_RESET_PAGE_NUMBER , XML_TOK_RESET_PAGE_NUMBER },
765 : { XML_NAMESPACE_REPORT, XML_PRINT_HEADER_ON_EACH_PAGE , XML_TOK_PRINT_HEADER_ON_EACH_PAGE },
766 : { XML_NAMESPACE_REPORT, XML_RESET_PAGE_NUMBER , XML_TOK_RESET_PAGE_NUMBER },
767 : { XML_NAMESPACE_REPORT, XML_SORT_EXPRESSION , XML_TOK_SORT_EXPRESSION },
768 : { XML_NAMESPACE_REPORT, XML_GROUP_EXPRESSION , XML_TOK_GROUP_EXPRESSION },
769 : { XML_NAMESPACE_REPORT, XML_GROUP_HEADER , XML_TOK_GROUP_HEADER },
770 : { XML_NAMESPACE_REPORT, XML_GROUP , XML_TOK_GROUP_GROUP },
771 : { XML_NAMESPACE_REPORT, XML_DETAIL , XML_TOK_GROUP_DETAIL },
772 : { XML_NAMESPACE_REPORT, XML_GROUP_FOOTER , XML_TOK_GROUP_FOOTER },
773 : { XML_NAMESPACE_REPORT, XML_SORT_ASCENDING , XML_TOK_SORT_ASCENDING },
774 : { XML_NAMESPACE_REPORT, XML_KEEP_TOGETHER , XML_TOK_GROUP_KEEP_TOGETHER },
775 : { XML_NAMESPACE_REPORT, XML_FUNCTION , XML_TOK_GROUP_FUNCTION },
776 : XML_TOKEN_MAP_END
777 : };
778 0 : m_pGroupElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
779 : }
780 0 : return *m_pGroupElemTokenMap;
781 : }
782 :
783 0 : const SvXMLTokenMap& ORptFilter::GetReportElementElemTokenMap() const
784 : {
785 0 : if ( !m_pElemTokenMap.get() )
786 : {
787 : static const SvXMLTokenMapEntry aElemTokenMap[]=
788 : {
789 : { XML_NAMESPACE_REPORT, XML_PRINT_REPEATED_VALUES ,XML_TOK_PRINT_REPEATED_VALUES },
790 : { XML_NAMESPACE_REPORT, XML_PRINT_WHEN_GROUP_CHANGE ,XML_TOK_PRINT_WHEN_GROUP_CHANGE },
791 : { XML_NAMESPACE_REPORT, XML_CONDITIONAL_PRINT_EXPRESSION,XML_TOK_REP_CONDITIONAL_PRINT_EXPRESSION },
792 : { XML_NAMESPACE_REPORT, XML_REPORT_COMPONENT ,XML_TOK_COMPONENT },
793 : { XML_NAMESPACE_REPORT, XML_FORMAT_CONDITION ,XML_TOK_FORMATCONDITION },
794 : XML_TOKEN_MAP_END
795 : };
796 0 : m_pElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
797 : }
798 0 : return *m_pElemTokenMap;
799 : }
800 :
801 0 : const SvXMLTokenMap& ORptFilter::GetControlElemTokenMap() const
802 : {
803 0 : if ( !m_pControlElemTokenMap.get() )
804 : {
805 : static const SvXMLTokenMapEntry aElemTokenMap[]=
806 : {
807 : { XML_NAMESPACE_FORM, XML_LABEL ,XML_TOK_LABEL },
808 : { XML_NAMESPACE_FORM, XML_PROPERTIES ,XML_TOK_PROPERTIES },
809 : { XML_NAMESPACE_FORM, XML_SIZE ,XML_TOK_SIZE },
810 : { XML_NAMESPACE_FORM, XML_IMAGE_DATA ,XML_TOK_IMAGE_DATA },
811 : { XML_NAMESPACE_REPORT, XML_SCALE ,XML_TOK_SCALE },
812 : { XML_NAMESPACE_REPORT, XML_REPORT_ELEMENT ,XML_TOK_REPORT_ELEMENT },
813 : { XML_NAMESPACE_REPORT, XML_FORMULA ,XML_TOK_DATA_FORMULA },
814 : { XML_NAMESPACE_REPORT, XML_PRESERVE_IRI ,XML_TOK_PRESERVE_IRI },
815 : { XML_NAMESPACE_REPORT, XML_SELECT_PAGE ,XML_TOK_SELECT_PAGE },
816 : XML_TOKEN_MAP_END
817 : };
818 0 : m_pControlElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
819 : }
820 0 : return *m_pControlElemTokenMap;
821 : }
822 :
823 0 : const SvXMLTokenMap& ORptFilter::GetControlPropertyElemTokenMap() const
824 : {
825 0 : if ( !m_pControlElemTokenMap.get() )
826 : {
827 : static const SvXMLTokenMapEntry aElemTokenMap[]=
828 : {
829 : { XML_NAMESPACE_FORM, XML_PROPERTY_NAME ,XML_TOK_PROPERTY_NAME },
830 : { XML_NAMESPACE_OOO, XML_VALUE_TYPE ,XML_TOK_VALUE_TYPE },
831 : { XML_NAMESPACE_FORM, XML_LIST_PROPERTY ,XML_TOK_LIST_PROPERTY },
832 : { XML_NAMESPACE_OOO, XML_VALUE ,XML_TOK_VALUE },
833 : { XML_NAMESPACE_OOO, XML_CURRENCY ,XML_TOK_CURRENCY },
834 : { XML_NAMESPACE_OOO, XML_DATE_VALUE ,XML_TOK_DATE_VALUE },
835 : { XML_NAMESPACE_OOO, XML_TIME_VALUE ,XML_TOK_TIME_VALUE },
836 : { XML_NAMESPACE_OOO, XML_STRING_VALUE ,XML_TOK_STRING_VALUE },
837 : { XML_NAMESPACE_OOO, XML_BOOLEAN_VALUE ,XML_TOK_BOOLEAN_VALUE },
838 : XML_TOKEN_MAP_END
839 : };
840 0 : m_pControlElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
841 : }
842 0 : return *m_pControlElemTokenMap;
843 : }
844 :
845 0 : const SvXMLTokenMap& ORptFilter::GetComponentElemTokenMap() const
846 : {
847 0 : if ( !m_pComponentElemTokenMap.get() )
848 : {
849 : static const SvXMLTokenMapEntry aElemTokenMap[]=
850 : {
851 : { XML_NAMESPACE_DRAW, XML_NAME , XML_TOK_NAME },
852 : { XML_NAMESPACE_DRAW, XML_TEXT_STYLE_NAME , XML_TOK_TEXT_STYLE_NAME },
853 : { XML_NAMESPACE_REPORT, XML_TRANSFORM , XML_TOK_TRANSFORM },
854 : XML_TOKEN_MAP_END
855 : };
856 0 : m_pComponentElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
857 : }
858 0 : return *m_pComponentElemTokenMap;
859 : }
860 :
861 0 : const SvXMLTokenMap& ORptFilter::GetColumnTokenMap() const
862 : {
863 0 : if ( !m_pColumnTokenMap.get() )
864 : {
865 : static const SvXMLTokenMapEntry aElemTokenMap[]=
866 : {
867 : { XML_NAMESPACE_TABLE, XML_NAME , XML_TOK_NAME },
868 : { XML_NAMESPACE_TABLE, XML_STYLE_NAME , XML_TOK_COLUMN_STYLE_NAME },
869 : { XML_NAMESPACE_TABLE, XML_TABLE_COLUMN , XML_TOK_COLUMN },
870 : { XML_NAMESPACE_TABLE, XML_TABLE_ROW , XML_TOK_ROW },
871 : { XML_NAMESPACE_TABLE, XML_TABLE_CELL , XML_TOK_CELL },
872 : { XML_NAMESPACE_TABLE, XML_TABLE_COLUMNS , XML_TOK_TABLE_COLUMNS },
873 : { XML_NAMESPACE_TABLE, XML_TABLE_ROWS , XML_TOK_TABLE_ROWS },
874 : { XML_NAMESPACE_TABLE, XML_COVERED_TABLE_CELL , XML_TOK_COV_CELL },
875 : { XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_SPANNED , XML_TOK_NUMBER_COLUMNS_SPANNED },
876 : { XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_SPANNED , XML_TOK_NUMBER_ROWS_SPANNED },
877 : { XML_NAMESPACE_REPORT, XML_CONDITIONAL_PRINT_EXPRESSION, XML_TOK_CONDITIONAL_PRINT_EXPRESSION},
878 : XML_TOKEN_MAP_END
879 : };
880 0 : m_pColumnTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
881 : }
882 0 : return *m_pColumnTokenMap;
883 : }
884 :
885 0 : const SvXMLTokenMap& ORptFilter::GetSectionElemTokenMap() const
886 : {
887 0 : if ( !m_pSectionElemTokenMap.get() )
888 : {
889 : static const SvXMLTokenMapEntry aElemTokenMap[]=
890 : {
891 : { XML_NAMESPACE_TABLE, XML_TABLE , XML_TOK_TABLE },
892 : { XML_NAMESPACE_TABLE, XML_NAME , XML_TOK_SECTION_NAME },
893 : { XML_NAMESPACE_REPORT, XML_VISIBLE , XML_TOK_VISIBLE },
894 : { XML_NAMESPACE_REPORT, XML_FORCE_NEW_PAGE , XML_TOK_FORCE_NEW_PAGE },
895 : { XML_NAMESPACE_REPORT, XML_FORCE_NEW_COLUMN , XML_TOK_FORCE_NEW_COLUMN },
896 : { XML_NAMESPACE_REPORT, XML_KEEP_TOGETHER , XML_TOK_KEEP_TOGETHER },
897 : { XML_NAMESPACE_REPORT, XML_REPEAT_SECTION , XML_TOK_REPEAT_SECTION },
898 : { XML_NAMESPACE_TABLE, XML_STYLE_NAME , XML_TOK_SECT_STYLE_NAME },
899 : { XML_NAMESPACE_REPORT, XML_PAGE_PRINT_OPTION , XML_TOK_PAGE_PRINT_OPTION },
900 :
901 : XML_TOKEN_MAP_END
902 : };
903 0 : m_pSectionElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
904 : }
905 0 : return *m_pSectionElemTokenMap;
906 : }
907 :
908 0 : const SvXMLTokenMap& ORptFilter::GetCellElemTokenMap() const
909 : {
910 0 : if ( !m_pCellElemTokenMap.get() )
911 : {
912 : static const SvXMLTokenMapEntry aElemTokenMap[]=
913 : {
914 : { XML_NAMESPACE_TEXT, XML_P , XML_TOK_P },
915 : { XML_NAMESPACE_REPORT, XML_FIXED_CONTENT , XML_TOK_FIXED_CONTENT },
916 : { XML_NAMESPACE_REPORT, XML_FORMATTED_TEXT , XML_TOK_FORMATTED_TEXT },
917 : { XML_NAMESPACE_REPORT, XML_IMAGE , XML_TOK_IMAGE },
918 : { XML_NAMESPACE_REPORT, XML_SUB_DOCUMENT , XML_TOK_SUB_DOCUMENT },
919 : { XML_NAMESPACE_DRAW, XML_CUSTOM_SHAPE , XML_TOK_CUSTOM_SHAPE },
920 : { XML_NAMESPACE_DRAW, XML_FRAME , XML_TOK_FRAME },
921 : { XML_NAMESPACE_TEXT, XML_PAGE_NUMBER , XML_TOK_PAGE_NUMBER },
922 : { XML_NAMESPACE_TEXT, XML_PAGE_COUNT , XML_TOK_PAGE_COUNT },
923 : { XML_NAMESPACE_TEXT, XML_TAB , XML_TOK_TEXT_TAB_STOP },
924 : { XML_NAMESPACE_TEXT, XML_LINE_BREAK , XML_TOK_TEXT_LINE_BREAK },
925 : { XML_NAMESPACE_TEXT, XML_S , XML_TOK_TEXT_S },
926 : XML_TOKEN_MAP_END
927 : };
928 0 : m_pCellElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
929 : }
930 0 : return *m_pCellElemTokenMap;
931 : }
932 :
933 0 : SvXMLImportContext* ORptFilter::CreateStylesContext(const OUString& rLocalName,
934 : const uno::Reference< XAttributeList>& xAttrList, bool bIsAutoStyle )
935 : {
936 0 : SvXMLImportContext* pContext = bIsAutoStyle ? GetAutoStyles() : GetStyles();
937 0 : if ( !pContext )
938 : {
939 0 : pContext = new OReportStylesContext(*this, XML_NAMESPACE_OFFICE, rLocalName, xAttrList, bIsAutoStyle);
940 0 : if (bIsAutoStyle)
941 0 : SetAutoStyles(static_cast<SvXMLStylesContext*>(pContext));
942 : else
943 0 : SetStyles(static_cast<SvXMLStylesContext*>(pContext));
944 : }
945 0 : return pContext;
946 : }
947 :
948 0 : SvXMLImport& ORptFilter::getGlobalContext()
949 : {
950 0 : return *this;
951 : }
952 :
953 0 : void ORptFilter::enterEventContext()
954 : {
955 0 : }
956 :
957 0 : void ORptFilter::leaveEventContext()
958 : {
959 0 : }
960 :
961 0 : SvXMLImportContext *ORptFilter::CreateFontDeclsContext(
962 : const OUString& rLocalName,
963 : const uno::Reference< xml::sax::XAttributeList > & xAttrList )
964 : {
965 : XMLFontStylesContext *pFSContext =
966 : new XMLFontStylesContext( *this, XML_NAMESPACE_OFFICE,
967 : rLocalName, xAttrList,
968 0 : osl_getThreadTextEncoding() );
969 0 : SetFontDecls( pFSContext );
970 0 : return pFSContext;
971 : }
972 :
973 0 : XMLShapeImportHelper* ORptFilter::CreateShapeImport()
974 : {
975 0 : return new XMLShapeImportHelper( *this,GetModel() );
976 : }
977 :
978 0 : void ORptFilter::FinishStyles()
979 : {
980 0 : if( GetStyles() )
981 0 : GetStyles()->FinishStyles( true );
982 0 : }
983 :
984 0 : OUString ORptFilter::convertFormula(const OUString& _sFormula)
985 : {
986 0 : return _sFormula;
987 : }
988 :
989 0 : void SAL_CALL ORptFilter::startDocument( void )
990 : throw( xml::sax::SAXException, uno::RuntimeException, std::exception )
991 : {
992 0 : m_xReportDefinition.set(GetModel(),UNO_QUERY_THROW);
993 : OSL_ENSURE(m_xReportDefinition.is(),"ReportDefinition is NULL!");
994 0 : if ( m_xReportDefinition.is() )
995 : {
996 0 : m_pReportModel = reportdesign::OReportDefinition::getSdrModel(m_xReportDefinition);
997 : OSL_ENSURE(m_pReportModel,"Report model is NULL!");
998 :
999 0 : SvXMLImport::startDocument();
1000 : }
1001 0 : }
1002 :
1003 0 : void ORptFilter::endDocument( void )
1004 : throw( xml::sax::SAXException, uno::RuntimeException, std::exception )
1005 : {
1006 : OSL_ENSURE( GetModel().is(), "model missing; maybe startDocument wasn't called?" );
1007 0 : if( !GetModel().is() )
1008 0 : return;
1009 :
1010 : // this method will modify the document directly -> lock SolarMutex
1011 0 : SolarMutexGuard aGuard;
1012 : // Clear the shape import to sort the shapes (and not in the
1013 : // destructor that might be called after the import has finished
1014 : // for Java filters.
1015 0 : if( HasShapeImport() )
1016 0 : ClearShapeImport();
1017 :
1018 : // delegate to parent: takes care of error handling
1019 0 : SvXMLImport::endDocument();
1020 : }
1021 :
1022 0 : void ORptFilter::removeFunction(const OUString& _sFunctionName)
1023 : {
1024 0 : m_aFunctions.erase(_sFunctionName);
1025 0 : }
1026 :
1027 0 : void ORptFilter::insertFunction(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction > & _xFunction)
1028 : {
1029 0 : m_aFunctions.insert(TGroupFunctionMap::value_type(_xFunction->getName(),_xFunction));
1030 0 : }
1031 :
1032 0 : SvXMLImportContext* ORptFilter::CreateMetaContext(const OUString& rLocalName,const uno::Reference<xml::sax::XAttributeList>&)
1033 : {
1034 0 : SvXMLImportContext* pContext = NULL;
1035 :
1036 0 : if ( (getImportFlags() & IMPORT_META) )
1037 : {
1038 0 : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(GetModel(), uno::UNO_QUERY_THROW);
1039 0 : pContext = new SvXMLMetaDocumentContext(*this,XML_NAMESPACE_OFFICE, rLocalName,xDPS->getDocumentProperties());
1040 : }
1041 0 : return pContext;
1042 : }
1043 :
1044 0 : bool ORptFilter::isOldFormat() const
1045 : {
1046 0 : bool bOldFormat = true;
1047 0 : uno::Reference<beans::XPropertySet> xProp = getImportInfo();
1048 0 : if ( xProp.is() )
1049 : {
1050 0 : const static OUString s_sOld("OldFormat");
1051 0 : if ( xProp->getPropertySetInfo()->hasPropertyByName(s_sOld))
1052 : {
1053 0 : xProp->getPropertyValue(s_sOld) >>= bOldFormat;
1054 : }
1055 : }
1056 0 : return bOldFormat;
1057 : }
1058 :
1059 :
1060 0 : }// rptxml
1061 :
1062 :
1063 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|