LCOV - code coverage report
Current view: top level - reportdesign/source/filter/xml - xmlfilter.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 369 0.0 %
Date: 2014-04-11 Functions: 0 60 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10