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