LCOV - code coverage report
Current view: top level - libreoffice/svx/source/xml - xmlxtimp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 43 194 22.2 %
Date: 2012-12-27 Functions: 4 16 25.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             : 
      20             : #include <tools/urlobj.hxx>
      21             : #include <com/sun/star/document/XGraphicObjectResolver.hpp>
      22             : #include <com/sun/star/embed/ElementModes.hpp>
      23             : #include <com/sun/star/io/XActiveDataControl.hpp>
      24             : #include <com/sun/star/io/XActiveDataSource.hpp>
      25             : #include <com/sun/star/xml/sax/Parser.hpp>
      26             : #include <com/sun/star/container/XNameContainer.hpp>
      27             : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
      28             : #include <com/sun/star/uno/Sequence.hxx>
      29             : #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
      30             : #include <com/sun/star/drawing/LineDash.hpp>
      31             : #include <com/sun/star/awt/Gradient.hpp>
      32             : #include <com/sun/star/drawing/Hatch.hpp>
      33             : #include <com/sun/star/io/XOutputStream.hpp>
      34             : #include <com/sun/star/io/XSeekable.hpp>
      35             : #include <comphelper/processfactory.hxx>
      36             : #include <comphelper/storagehelper.hxx>
      37             : #include <unotools/streamwrap.hxx>
      38             : #include <rtl/ustrbuf.hxx>
      39             : #include <sax/tools/converter.hxx>
      40             : #include <sfx2/docfile.hxx>
      41             : #include "xmloff/xmlnmspe.hxx"
      42             : #include "xmloff/nmspmap.hxx"
      43             : 
      44             : #include "xmloff/xmltoken.hxx"
      45             : #include "xmloff/xmlmetae.hxx"
      46             : #include "xmloff/DashStyle.hxx"
      47             : #include "xmloff/GradientStyle.hxx"
      48             : #include "xmloff/HatchStyle.hxx"
      49             : #include "xmloff/ImageStyle.hxx"
      50             : #include "xmloff/MarkerStyle.hxx"
      51             : #include <xmloff/xmlictxt.hxx>
      52             : #include "svx/xmlgrhlp.hxx"
      53             : #include "xmloff/attrlist.hxx"
      54             : 
      55             : #include "xmlxtimp.hxx"
      56             : 
      57             : #include <cstdio>
      58             : 
      59             : using namespace com::sun::star;
      60             : using namespace com::sun::star::container;
      61             : using namespace com::sun::star::document;
      62             : using namespace com::sun::star::uno;
      63             : using namespace com::sun::star::awt;
      64             : using namespace com::sun::star::lang;
      65             : using namespace com::sun::star::xml::sax;
      66             : using namespace ::rtl;
      67             : using namespace ::xmloff::token;
      68             : using namespace cppu;
      69             : 
      70             : sal_Char const sXML_np__office[] = "__office";
      71             : sal_Char const sXML_np__office_ooo[] = "___office";
      72             : sal_Char const sXML_np__draw[] = "__draw";
      73             : sal_Char const sXML_np__draw_ooo[] = "___draw";
      74             : sal_Char const sXML_np__ooo[] = "__ooo";
      75             : sal_Char const sXML_np__xlink[] = "__xlink";
      76             : 
      77             : ///////////////////////////////////////////////////////////////////////
      78             : 
      79             : enum SvxXMLTableImportContextEnum { stice_unknown, stice_color, stice_marker, stice_dash, stice_hatch, stice_gradient, stice_bitmap };
      80             : 
      81             : ///////////////////////////////////////////////////////////////////////
      82             : 
      83             : class SvxXMLTableImportContext : public SvXMLImportContext
      84             : {
      85             : public:
      86             :     SvxXMLTableImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const uno::Reference< XAttributeList >& xAttrList, SvxXMLTableImportContextEnum eContext, const uno::Reference< XNameContainer >& xTable,
      87             :         sal_Bool bOOoFormat );
      88             :     virtual ~SvxXMLTableImportContext();
      89             : 
      90             :     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList );
      91             : 
      92             :     SvxXMLXTableImport& getImport() const { return *(SvxXMLXTableImport*)&GetImport(); }
      93             : 
      94             : protected:
      95             :     void importColor( sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName );
      96             :     void importMarker( sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName );
      97             :     void importDash( sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName );
      98             :     void importHatch( sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName );
      99             :     void importGradient( sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName );
     100             :     void importBitmap( sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName );
     101             : 
     102             : private:
     103             :     uno::Reference< XNameContainer > mxTable;
     104             :     SvxXMLTableImportContextEnum meContext;
     105             :     sal_Bool mbOOoFormat;
     106             : };
     107             : 
     108             : ///////////////////////////////////////////////////////////////////////
     109             : 
     110           0 : SvxXMLTableImportContext::SvxXMLTableImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, const uno::Reference< XAttributeList >&, SvxXMLTableImportContextEnum eContext, const uno::Reference< XNameContainer >& xTable, sal_Bool bOOoFormat )
     111             : : SvXMLImportContext( rImport, nPrfx, rLName ), mxTable( xTable ), meContext( eContext ),
     112           0 :     mbOOoFormat( bOOoFormat )
     113             : {
     114           0 : }
     115             : 
     116           0 : SvxXMLTableImportContext::~SvxXMLTableImportContext()
     117             : {
     118           0 : }
     119             : 
     120           0 : SvXMLImportContext *SvxXMLTableImportContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< XAttributeList >& rAttrList )
     121             : {
     122           0 :     if( XML_NAMESPACE_DRAW == nPrefix )
     123             :     {
     124           0 :         uno::Reference< XAttributeList > xAttrList( rAttrList );
     125           0 :         if( mbOOoFormat &&
     126             :              (stice_dash == meContext || stice_hatch == meContext ||
     127             :              stice_bitmap == meContext) )
     128             :         {
     129           0 :             SvXMLAttributeList *pAttrList = new SvXMLAttributeList( rAttrList );
     130           0 :             xAttrList = pAttrList;
     131           0 :             sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     132           0 :             for( sal_Int16 i=0; i < nAttrCount; i++ )
     133             :             {
     134           0 :                 const OUString& rAttrName = xAttrList->getNameByIndex( i );
     135           0 :                 OUString aLocalName;
     136             :                 sal_uInt16 nPrefix_ =
     137           0 :                     GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
     138           0 :                                                                 &aLocalName );
     139           0 :                 if( XML_NAMESPACE_XLINK == nPrefix_ &&
     140             :                     stice_bitmap == meContext &&
     141           0 :                     IsXMLToken( aLocalName, XML_HREF ) )
     142             :                 {
     143           0 :                     const OUString rValue = xAttrList->getValueByIndex( i );
     144           0 :                     if( !rValue.isEmpty() && '#' == rValue[0] )
     145           0 :                         pAttrList->SetValueByIndex( i, rValue.copy( 1 ) );
     146             :                 }
     147           0 :                 else if( XML_NAMESPACE_DRAW == nPrefix_ &&
     148             :                           ( ( stice_dash == meContext &&
     149           0 :                               (IsXMLToken( aLocalName, XML_DOTS1_LENGTH ) ||
     150           0 :                                IsXMLToken( aLocalName, XML_DOTS2_LENGTH ) ||
     151           0 :                                IsXMLToken( aLocalName, XML_DISTANCE )) ) ||
     152             :                             ( stice_hatch == meContext &&
     153           0 :                               IsXMLToken( aLocalName, XML_HATCH_DISTANCE ) ) ) )
     154             :                 {
     155           0 :                     const OUString rValue = xAttrList->getValueByIndex( i );
     156           0 :                     sal_Int32 nPos = rValue.getLength();
     157           0 :                     while( nPos && rValue[nPos-1] <= ' ' )
     158           0 :                         --nPos;
     159           0 :                     if( nPos > 2 &&
     160           0 :                         ('c'==rValue[nPos-2] || 'C'==rValue[nPos-2]) &&
     161           0 :                         ('h'==rValue[nPos-1] || 'H'==rValue[nPos-1]) )
     162             :                     {
     163           0 :                         pAttrList->SetValueByIndex( i, rValue.copy( 0, nPos-2 ) );
     164           0 :                     }
     165             :                 }
     166           0 :             }
     167             :         }
     168             :         try
     169             :         {
     170           0 :             Any aAny;
     171           0 :             OUString aName;
     172             : 
     173           0 :             switch( meContext )
     174             :             {
     175             :             case stice_color:
     176           0 :                 importColor( nPrefix, rLocalName, xAttrList, aAny, aName );
     177           0 :                 break;
     178             :             case stice_marker:
     179           0 :                 importMarker( nPrefix, rLocalName, xAttrList, aAny, aName  );
     180           0 :                 break;
     181             :             case stice_dash:
     182           0 :                 importDash( nPrefix, rLocalName, xAttrList, aAny, aName  );
     183           0 :                 break;
     184             :             case stice_hatch:
     185           0 :                 importHatch( nPrefix, rLocalName, xAttrList, aAny, aName  );
     186           0 :                 break;
     187             :             case stice_gradient:
     188           0 :                 importGradient( nPrefix, rLocalName, xAttrList, aAny, aName  );
     189           0 :                 break;
     190             :             case stice_bitmap:
     191           0 :                 importBitmap( nPrefix, rLocalName, xAttrList, aAny, aName  );
     192           0 :                 break;
     193             :             case stice_unknown:
     194           0 :                 break;
     195             :             }
     196             : 
     197           0 :             if( !aName.isEmpty() && aAny.hasValue() )
     198             :             {
     199           0 :                 if( mxTable->hasByName( aName ) )
     200             :                 {
     201           0 :                     mxTable->replaceByName( aName, aAny );
     202             :                 }
     203             :                 else
     204             :                 {
     205           0 :                     mxTable->insertByName( aName, aAny );
     206             :                 }
     207           0 :             }
     208             :         }
     209           0 :         catch (const uno::Exception&)
     210             :         {
     211           0 :         }
     212             :     }
     213             : 
     214           0 :     return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     215             : }
     216             : 
     217           0 : void SvxXMLTableImportContext::importColor( sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName )
     218             : {
     219             :     (void)nPrfx;
     220             :     (void)rLocalName;
     221             : 
     222           0 :     const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     223           0 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
     224             :     {
     225           0 :         const OUString& rFullAttrName = xAttrList->getNameByIndex( i );
     226           0 :         OUString aLocalName;
     227           0 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rFullAttrName, &aLocalName );
     228             : 
     229             : 
     230           0 :         if( XML_NAMESPACE_DRAW == nPrefix )
     231             :         {
     232           0 :             if( aLocalName == GetXMLToken(XML_NAME) )
     233             :             {
     234           0 :                 rName = xAttrList->getValueByIndex( i );
     235             :             }
     236           0 :             else if( aLocalName == GetXMLToken(XML_COLOR) )
     237             :             {
     238           0 :                 sal_Int32 nColor(0);
     239             :                 ::sax::Converter::convertColor(nColor,
     240           0 :                         xAttrList->getValueByIndex( i ));
     241           0 :                 rAny <<= nColor;
     242             :             }
     243             :         }
     244           0 :     }
     245           0 : }
     246             : 
     247           0 : void SvxXMLTableImportContext::importMarker( sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName )
     248             : {
     249             :     (void)nPrfx;
     250             :     (void)rLocalName;
     251             : 
     252             :     try
     253             :     {
     254           0 :         XMLMarkerStyleImport aMarkerStyle( GetImport() );
     255           0 :         aMarkerStyle.importXML( xAttrList, rAny, rName );
     256             :     }
     257           0 :     catch (const Exception&)
     258             :     {
     259             :         OSL_FAIL("SvxXMLTableImportContext::importMarker(), exception caught!");
     260             :     }
     261           0 : }
     262             : 
     263           0 : void SvxXMLTableImportContext::importDash( sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName )
     264             : {
     265             :     (void)nPrfx;
     266             :     (void)rLocalName;
     267             : 
     268             :     try
     269             :     {
     270           0 :         XMLDashStyleImport aDashStyle( GetImport() );
     271           0 :         aDashStyle.importXML( xAttrList, rAny, rName );
     272             :     }
     273           0 :     catch (const Exception&)
     274             :     {
     275             :         OSL_FAIL("SvxXMLTableImportContext::importDash(), exception caught!");
     276             :     }
     277           0 : }
     278             : 
     279           0 : void SvxXMLTableImportContext::importHatch( sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName )
     280             : {
     281             :     (void)nPrfx;
     282             :     (void)rLocalName;
     283             : 
     284             :     try
     285             :     {
     286           0 :         XMLHatchStyleImport aHatchStyle( GetImport() );
     287           0 :         aHatchStyle.importXML( xAttrList, rAny, rName );
     288             :     }
     289           0 :     catch (const Exception&)
     290             :     {
     291             :         OSL_FAIL("SvxXMLTableImportContext::importHatch(), exception caught!");
     292             :     }
     293           0 : }
     294             : 
     295           0 : void SvxXMLTableImportContext::importGradient( sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName )
     296             : {
     297             :     (void)nPrfx;
     298             :     (void)rLocalName;
     299             : 
     300             :     try
     301             :     {
     302           0 :         XMLGradientStyleImport aGradientStyle( GetImport() );
     303           0 :         aGradientStyle.importXML( xAttrList, rAny, rName );
     304             :     }
     305           0 :     catch (const Exception&)
     306             :     {
     307             :         OSL_FAIL("SvxXMLTableImportContext::importGradient(), exception caught!");
     308             :     }
     309           0 : }
     310             : 
     311           0 : void SvxXMLTableImportContext::importBitmap( sal_uInt16 nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName )
     312             : {
     313             :     (void)nPrfx;
     314             :     (void)rLocalName;
     315             : 
     316             :     try
     317             :     {
     318           0 :         XMLImageStyle aImageStyle;
     319           0 :         aImageStyle.importXML( xAttrList, rAny, rName, GetImport() );
     320             :     }
     321           0 :     catch (const Exception&)
     322             :     {
     323             :         OSL_FAIL("SvxXMLTableImportContext::importBitmap(), exception caught!");
     324             :     }
     325           0 : }
     326             : 
     327             : ///////////////////////////////////////////////////////////////////////
     328             : 
     329             : // #110680#
     330          14 : SvxXMLXTableImport::SvxXMLXTableImport(
     331             :     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
     332             :     const uno::Reference< XNameContainer > & rTable,
     333             :     uno::Reference< XGraphicObjectResolver >& xGrfResolver )
     334             : :   SvXMLImport(xServiceFactory, 0),
     335          14 :     mrTable( rTable )
     336             : {
     337          14 :     SetGraphicResolver( xGrfResolver );
     338             : 
     339          14 :     GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__ooo ) ), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
     340          14 :     GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office ) ), GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE );
     341          14 :     GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__draw ) ), GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW );
     342          14 :     GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xlink ) ), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
     343             : 
     344             :     // OOo namespaces for reading OOo 1.1 files
     345          14 :     GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office_ooo ) ),
     346          14 :                         GetXMLToken(XML_N_OFFICE_OOO),
     347          28 :                         XML_NAMESPACE_OFFICE );
     348          14 :     GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__draw_ooo ) ),
     349          14 :                         GetXMLToken(XML_N_DRAW_OOO),
     350          28 :                         XML_NAMESPACE_DRAW );
     351          14 : }
     352             : 
     353          28 : SvxXMLXTableImport::~SvxXMLXTableImport() throw ()
     354             : {
     355          28 : }
     356             : 
     357           0 : static void openStorageStream( xml::sax::InputSource *pParserInput,
     358             :                                SvXMLGraphicHelper   **ppGraphicHelper,
     359             :                                uno::Reference < embed::XStorage > xStorage )
     360             : {
     361           0 :     uno::Reference < io::XStream > xIStm;
     362           0 :     const String aContentStmName( RTL_CONSTASCII_USTRINGPARAM( "Content.xml" ) );
     363           0 :     xIStm.set( xStorage->openStreamElement( aContentStmName, embed::ElementModes::READ ), uno::UNO_QUERY_THROW );
     364           0 :     if( !xIStm.is() )
     365             :     {
     366             :         OSL_FAIL( "could not open Content stream" );
     367           0 :         return;
     368             :     }
     369           0 :     pParserInput->aInputStream = xIStm->getInputStream();
     370           0 :     *ppGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_READ );
     371             : }
     372             : 
     373          14 : bool SvxXMLXTableImport::load( const rtl::OUString &rPath,
     374             :                                const uno::Reference < embed::XStorage > &xStorage,
     375             :                                const uno::Reference< XNameContainer >& xTable,
     376             :                                bool *bOptLoadedFromStorage ) throw()
     377             : {
     378          14 :     bool bRet = true;
     379          14 :     SvXMLGraphicHelper* pGraphicHelper = 0;
     380             : 
     381          14 :     INetURLObject aURLObj( rPath );
     382          14 :     bool bUseStorage = aURLObj.GetProtocol() == INET_PROT_NOT_VALID; // a relative path
     383             : 
     384             :     try
     385             :     {
     386          14 :         uno::Reference<lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() );
     387          14 :         uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
     388          14 :         if( !xServiceFactory.is() )
     389             :         {
     390             :             OSL_FAIL( "SvxXMLXTableImport::load: got no service manager" );
     391           0 :             return false;
     392             :         }
     393             : 
     394          14 :         uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create( xContext );
     395             : 
     396          14 :         xml::sax::InputSource aParserInput;
     397          14 :         comphelper::LifecycleProxy aNasty;
     398             : 
     399          14 :         if( !bUseStorage || !xStorage.is() )
     400             :         {
     401          14 :             SfxMedium aMedium( rPath, STREAM_READ | STREAM_NOCREATE );
     402          14 :             aParserInput.sSystemId = aMedium.GetName();
     403             : 
     404          14 :             if( aMedium.IsStorage() )
     405             :             {
     406           0 :                 uno::Reference < embed::XStorage > xMediumStorage( aMedium.GetStorage( sal_False ), uno::UNO_QUERY_THROW );
     407           0 :                 openStorageStream( &aParserInput, &pGraphicHelper, xMediumStorage );
     408             :             }
     409             :             else
     410          14 :                 aParserInput.aInputStream = aMedium.GetInputStream();
     411             :         }
     412             :         else // relative URL into a storage
     413             :         {
     414           0 :             uno::Reference< embed::XStorage > xSubStorage;
     415             :             try
     416             :             {
     417             :                 xSubStorage = comphelper::OStorageHelper::GetStorageAtPath(
     418           0 :                         xStorage, rPath, embed::ElementModes::READ, aNasty );
     419             :             }
     420           0 :             catch (const uno::Exception&)
     421             :             {
     422             :             }
     423           0 :             if( xSubStorage.is() )
     424           0 :                 openStorageStream( &aParserInput, &pGraphicHelper, xSubStorage );
     425             :             else
     426             :             {
     427           0 :                 ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > xStream;
     428             :                 xStream = comphelper::OStorageHelper::GetStreamAtPath(
     429           0 :                         xStorage, rPath, embed::ElementModes::READ, aNasty );
     430           0 :                 if( !xStream.is() )
     431           0 :                     return false;
     432           0 :                 aParserInput.aInputStream = xStream->getInputStream();
     433             :             }
     434           0 :             if( bOptLoadedFromStorage )
     435           0 :                 *bOptLoadedFromStorage = true;
     436             :         }
     437             : 
     438          14 :         uno::Reference< XGraphicObjectResolver > xGrfResolver;
     439          14 :         if (pGraphicHelper)
     440           0 :             xGrfResolver = pGraphicHelper;
     441             : 
     442             :         try
     443             :         {
     444          14 :             uno::Reference< io::XSeekable > xSeek( aParserInput.aInputStream, uno::UNO_QUERY_THROW );
     445           0 :             xSeek->seek( 0 );
     446             :         }
     447          14 :         catch (const uno::Exception&)
     448             :         {
     449             :         }
     450             : 
     451          14 :         uno::Reference< XDocumentHandler > xHandler( new SvxXMLXTableImport( xServiceFactory, xTable, xGrfResolver ) );
     452          14 :         xParser->setDocumentHandler( xHandler );
     453          14 :         xParser->parseStream( aParserInput );
     454             : 
     455           0 :         if( pGraphicHelper )
     456          14 :             SvXMLGraphicHelper::Destroy( pGraphicHelper );
     457             :     }
     458          28 :     catch (const uno::Exception&)
     459             :     {
     460             : //      thrown each time you load a document with property tables that are not
     461             : //      on the current machine. FIXME: would be better to check a file exists
     462             : //      before importing ...
     463             : //        fprintf (stderr, "parsing etc. exception '%s'\n",
     464             : //                 rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
     465          14 :         bRet = false;
     466             :     }
     467             : 
     468          14 :     return bRet;
     469             : }
     470             : 
     471           0 : SvXMLImportContext *SvxXMLXTableImport::CreateContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList )
     472             : {
     473           0 :     if( XML_NAMESPACE_OOO == nPrefix ||
     474             :         XML_NAMESPACE_OFFICE == nPrefix )
     475             :     {
     476           0 :         sal_Bool bOOoFormat = (XML_NAMESPACE_OFFICE == nPrefix);
     477           0 :         Type aType = mrTable->getElementType();
     478             : 
     479           0 :         if ( rLocalName == "color-table" )
     480             :         {
     481           0 :             if( aType == ::getCppuType((const sal_Int32*)0) )
     482           0 :                 return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, xAttrList, stice_color, mrTable, bOOoFormat );
     483             :         }
     484           0 :         else if ( rLocalName == "marker-table" )
     485             :         {
     486           0 :             if( aType == ::getCppuType((const drawing::PolyPolygonBezierCoords*)0) )
     487           0 :                 return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, xAttrList, stice_marker, mrTable, bOOoFormat );
     488             :         }
     489           0 :         else if ( rLocalName == "dash-table" )
     490             :         {
     491           0 :             if( aType == ::getCppuType((const drawing::LineDash*)0) )
     492           0 :                 return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, xAttrList, stice_dash, mrTable, bOOoFormat );
     493             :         }
     494           0 :         else if ( rLocalName == "hatch-table" )
     495             :         {
     496           0 :             if( aType == ::getCppuType((const drawing::Hatch*)0) )
     497           0 :                 return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, xAttrList, stice_hatch, mrTable, bOOoFormat );
     498             :         }
     499           0 :         else if ( rLocalName == "gradient-table" )
     500             :         {
     501           0 :             if( aType == ::getCppuType((const awt::Gradient*)0))
     502           0 :                 return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, xAttrList, stice_gradient, mrTable, bOOoFormat );
     503             :         }
     504           0 :         else if ( rLocalName == "bitmap-table" )
     505             :         {
     506           0 :             if( aType == ::getCppuType((const OUString*)0))
     507           0 :                 return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, xAttrList, stice_bitmap, mrTable, bOOoFormat );
     508           0 :         }
     509             :     }
     510             : 
     511           0 :     return new SvXMLImportContext( *this, nPrefix, rLocalName );
     512             : }
     513             : 
     514             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10