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