LCOV - code coverage report
Current view: top level - xmloff/source/style - FillStyleContext.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 116 134 86.6 %
Date: 2014-04-11 Functions: 31 61 50.8 %
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 <com/sun/star/container/XNameContainer.hpp>
      21             : #include "FillStyleContext.hxx"
      22             : #include <xmloff/xmlimp.hxx>
      23             : #include <xmloff/GradientStyle.hxx>
      24             : #include <xmloff/HatchStyle.hxx>
      25             : #include <xmloff/ImageStyle.hxx>
      26             : #include "TransGradientStyle.hxx"
      27             : #include <xmloff/MarkerStyle.hxx>
      28             : #include <xmloff/DashStyle.hxx>
      29             : #include <xmloff/families.hxx>
      30             : #include <xmloff/nmspmap.hxx>
      31             : #include <xmloff/xmlnmspe.hxx>
      32             : #include <xmloff/XMLBase64ImportContext.hxx>
      33             : 
      34             : using namespace ::com::sun::star;
      35             : 
      36           0 : TYPEINIT1( XMLGradientStyleContext, SvXMLStyleContext );
      37             : 
      38          31 : XMLGradientStyleContext::XMLGradientStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
      39             :                                               const OUString& rLName,
      40             :                                               const uno::Reference< xml::sax::XAttributeList >& xAttrList)
      41          31 : :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList)
      42             : {
      43             : 
      44             :     // start import
      45          31 :     XMLGradientStyleImport aGradientStyle( GetImport() );
      46          31 :     aGradientStyle.importXML( xAttrList, maAny, maStrName );
      47          31 : }
      48             : 
      49          62 : XMLGradientStyleContext::~XMLGradientStyleContext()
      50             : {
      51          62 : }
      52             : 
      53          31 : void XMLGradientStyleContext::EndElement()
      54             : {
      55          31 :     uno::Reference< container::XNameContainer > xGradient( GetImport().GetGradientHelper() );
      56             : 
      57             :     try
      58             :     {
      59          31 :         if(xGradient.is())
      60             :         {
      61          31 :             if( xGradient->hasByName( maStrName ) )
      62             :             {
      63           0 :                 xGradient->replaceByName( maStrName, maAny );
      64             :             }
      65             :             else
      66             :             {
      67          31 :                 xGradient->insertByName( maStrName, maAny );
      68             :             }
      69             :         }
      70             :     }
      71           0 :     catch( container::ElementExistException& )
      72          31 :     {}
      73          31 : }
      74             : 
      75          31 : bool XMLGradientStyleContext::IsTransient() const
      76             : {
      77          31 :     return true;
      78             : }
      79             : 
      80           0 : TYPEINIT1( XMLHatchStyleContext, SvXMLStyleContext );
      81             : 
      82          21 : XMLHatchStyleContext::XMLHatchStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
      83             :                                               const OUString& rLName,
      84             :                                               const uno::Reference< xml::sax::XAttributeList >& xAttrList)
      85          21 : :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList)
      86             : {
      87             :     // start import
      88          21 :     XMLHatchStyleImport aHatchStyle( GetImport() );
      89          21 :     aHatchStyle.importXML( xAttrList, maAny, maStrName );
      90          21 : }
      91             : 
      92          42 : XMLHatchStyleContext::~XMLHatchStyleContext()
      93             : {
      94          42 : }
      95             : 
      96          21 : void XMLHatchStyleContext::EndElement()
      97             : {
      98          21 :     uno::Reference< container::XNameContainer > xHatch( GetImport().GetHatchHelper() );
      99             : 
     100             :     try
     101             :     {
     102          21 :         if(xHatch.is())
     103             :         {
     104          21 :             if( xHatch->hasByName( maStrName ) )
     105             :             {
     106           0 :                 xHatch->replaceByName( maStrName, maAny );
     107             :             }
     108             :             else
     109             :             {
     110          21 :                 xHatch->insertByName( maStrName, maAny );
     111             :             }
     112             :         }
     113             :     }
     114           0 :     catch( container::ElementExistException& )
     115          21 :     {}
     116          21 : }
     117             : 
     118          21 : bool XMLHatchStyleContext::IsTransient() const
     119             : {
     120          21 :     return true;
     121             : }
     122             : 
     123           0 : TYPEINIT1( XMLBitmapStyleContext, SvXMLStyleContext );
     124             : 
     125          13 : XMLBitmapStyleContext::XMLBitmapStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     126             :                                               const OUString& rLName,
     127             :                                               const uno::Reference< xml::sax::XAttributeList >& xAttrList)
     128          13 : :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList)
     129             : {
     130             :     // start import
     131          13 :     XMLImageStyle aBitmapStyle;
     132          13 :     aBitmapStyle.importXML( xAttrList, maAny, maStrName, rImport );
     133          13 : }
     134             : 
     135          26 : XMLBitmapStyleContext::~XMLBitmapStyleContext()
     136             : {
     137          26 : }
     138             : 
     139           1 : SvXMLImportContext* XMLBitmapStyleContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList )
     140             : {
     141           1 :     SvXMLImportContext *pContext = 0;
     142           1 :     if( (XML_NAMESPACE_OFFICE == nPrefix) && xmloff::token::IsXMLToken( rLocalName, xmloff::token::XML_BINARY_DATA ) )
     143             :     {
     144           1 :         OUString sURL;
     145           1 :         maAny >>= sURL;
     146           1 :         if( sURL.isEmpty() && !mxBase64Stream.is() )
     147             :         {
     148           1 :             mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
     149           1 :             if( mxBase64Stream.is() )
     150           1 :                 pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
     151             :                                                     rLocalName, xAttrList,
     152           1 :                                                     mxBase64Stream );
     153           1 :         }
     154             :     }
     155           1 :     if( !pContext )
     156             :     {
     157           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     158             :     }
     159             : 
     160           1 :     return pContext;
     161             : }
     162             : 
     163          13 : void XMLBitmapStyleContext::EndElement()
     164             : {
     165          13 :     OUString sURL;
     166          13 :     maAny >>= sURL;
     167             : 
     168          13 :     if( sURL.isEmpty() && mxBase64Stream.is() )
     169             :     {
     170           1 :         sURL = GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream );
     171           1 :         mxBase64Stream = 0;
     172           1 :         maAny <<= sURL;
     173             :     }
     174             : 
     175          26 :     uno::Reference< container::XNameContainer > xBitmap( GetImport().GetBitmapHelper() );
     176             : 
     177             :     try
     178             :     {
     179          13 :         if(xBitmap.is())
     180             :         {
     181          13 :             if( xBitmap->hasByName( maStrName ) )
     182             :             {
     183           0 :                 xBitmap->replaceByName( maStrName, maAny );
     184             :             }
     185             :             else
     186             :             {
     187          13 :                 xBitmap->insertByName( maStrName, maAny );
     188             :             }
     189             :         }
     190             :     }
     191           0 :     catch( container::ElementExistException& )
     192          13 :     {}
     193          13 : }
     194             : 
     195          13 : bool XMLBitmapStyleContext::IsTransient() const
     196             : {
     197          13 :     return true;
     198             : }
     199             : 
     200           0 : TYPEINIT1( XMLTransGradientStyleContext, SvXMLStyleContext );
     201             : 
     202           6 : XMLTransGradientStyleContext::XMLTransGradientStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     203             :                                               const OUString& rLName,
     204             :                                               const uno::Reference< xml::sax::XAttributeList >& xAttrList)
     205           6 : :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList)
     206             : {
     207             :     // start import
     208           6 :     XMLTransGradientStyleImport aTransGradientStyle( GetImport() );
     209           6 :     aTransGradientStyle.importXML( xAttrList, maAny, maStrName );
     210           6 : }
     211             : 
     212          12 : XMLTransGradientStyleContext::~XMLTransGradientStyleContext()
     213             : {
     214          12 : }
     215             : 
     216           6 : void XMLTransGradientStyleContext::EndElement()
     217             : {
     218           6 :     uno::Reference< container::XNameContainer > xTransGradient( GetImport().GetTransGradientHelper() );
     219             : 
     220             :     try
     221             :     {
     222           6 :         if(xTransGradient.is())
     223             :         {
     224           6 :             if( xTransGradient->hasByName( maStrName ) )
     225             :             {
     226           0 :                 xTransGradient->replaceByName( maStrName, maAny );
     227             :             }
     228             :             else
     229             :             {
     230           6 :                 xTransGradient->insertByName( maStrName, maAny );
     231             :             }
     232             :         }
     233             :     }
     234           0 :     catch( container::ElementExistException& )
     235           6 :     {}
     236           6 : }
     237             : 
     238           6 : bool XMLTransGradientStyleContext::IsTransient() const
     239             : {
     240           6 :     return true;
     241             : }
     242             : 
     243           0 : TYPEINIT1( XMLMarkerStyleContext, SvXMLStyleContext );
     244             : 
     245          35 : XMLMarkerStyleContext::XMLMarkerStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     246             :                                               const OUString& rLName,
     247             :                                               const uno::Reference< xml::sax::XAttributeList >& xAttrList)
     248          35 : :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList)
     249             : {
     250             :     // start import
     251          35 :     XMLMarkerStyleImport aMarkerStyle( GetImport() );
     252          35 :     aMarkerStyle.importXML( xAttrList, maAny, maStrName );
     253          35 : }
     254             : 
     255          70 : XMLMarkerStyleContext::~XMLMarkerStyleContext()
     256             : {
     257          70 : }
     258             : 
     259          35 : void XMLMarkerStyleContext::EndElement()
     260             : {
     261          35 :     uno::Reference< container::XNameContainer > xMarker( GetImport().GetMarkerHelper() );
     262             : 
     263             :     try
     264             :     {
     265          35 :         if(xMarker.is())
     266             :         {
     267          35 :             if( xMarker->hasByName( maStrName ) )
     268             :             {
     269          14 :                 xMarker->replaceByName( maStrName, maAny );
     270             :             }
     271             :             else
     272             :             {
     273          21 :                 xMarker->insertByName( maStrName, maAny );
     274             :             }
     275             :         }
     276             :     }
     277           0 :     catch( container::ElementExistException& )
     278          35 :     {}
     279          35 : }
     280             : 
     281          35 : bool XMLMarkerStyleContext::IsTransient() const
     282             : {
     283          35 :     return true;
     284             : }
     285             : 
     286           0 : TYPEINIT1( XMLDashStyleContext, SvXMLStyleContext );
     287             : 
     288          14 : XMLDashStyleContext::XMLDashStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     289             :                                           const OUString& rLName,
     290             :                                           const uno::Reference< xml::sax::XAttributeList >& xAttrList)
     291          14 : :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList)
     292             : {
     293             :     // start import
     294          14 :     XMLDashStyleImport aDashStyle( GetImport() );
     295          14 :     aDashStyle.importXML( xAttrList, maAny, maStrName );
     296          14 : }
     297             : 
     298          28 : XMLDashStyleContext::~XMLDashStyleContext()
     299             : {
     300          28 : }
     301             : 
     302          14 : void XMLDashStyleContext::EndElement()
     303             : {
     304          14 :     uno::Reference< container::XNameContainer > xDashes( GetImport().GetDashHelper() );
     305             : 
     306             :     try
     307             :     {
     308          14 :         if(xDashes.is())
     309             :         {
     310          14 :             if( xDashes->hasByName( maStrName ) )
     311             :             {
     312           0 :                 xDashes->replaceByName( maStrName, maAny );
     313             :             }
     314             :             else
     315             :             {
     316          14 :                 xDashes->insertByName( maStrName, maAny );
     317             :             }
     318             :         }
     319             :     }
     320           0 :     catch( container::ElementExistException& )
     321          14 :     {}
     322          14 : }
     323             : 
     324          14 : bool XMLDashStyleContext::IsTransient() const
     325             : {
     326          14 :     return true;
     327             : }
     328             : 
     329             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10