LCOV - code coverage report
Current view: top level - xmloff/source/style - FillStyleContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 100 134 74.6 %
Date: 2012-08-25 Functions: 30 61 49.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 71 242 29.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      30                 :            : #include "FillStyleContext.hxx"
      31                 :            : #include <xmloff/xmlimp.hxx>
      32                 :            : #include "xmloff/GradientStyle.hxx"
      33                 :            : #include "xmloff/HatchStyle.hxx"
      34                 :            : #include "xmloff/ImageStyle.hxx"
      35                 :            : #include "TransGradientStyle.hxx"
      36                 :            : #include "xmloff/MarkerStyle.hxx"
      37                 :            : #include "xmloff/DashStyle.hxx"
      38                 :            : #include <xmloff/families.hxx>
      39                 :            : #include <xmloff/nmspmap.hxx>
      40                 :            : #include "xmloff/xmlnmspe.hxx"
      41                 :            : #include <xmloff/XMLBase64ImportContext.hxx>
      42                 :            : 
      43                 :            : using namespace ::com::sun::star;
      44                 :            : using ::rtl::OUString;
      45                 :            : using ::rtl::OUStringBuffer;
      46                 :            : 
      47                 :            : 
      48                 :            : //////////////////////////////////////////////////////////////////////////////
      49                 :            : //////////////////////////////////////////////////////////////////////////////
      50                 :            : 
      51 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLGradientStyleContext, SvXMLStyleContext );
      52                 :            : 
      53                 :         33 : XMLGradientStyleContext::XMLGradientStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
      54                 :            :                                               const OUString& rLName,
      55                 :            :                                               const uno::Reference< xml::sax::XAttributeList >& xAttrList)
      56                 :         33 : :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList)
      57                 :            : {
      58                 :            : 
      59                 :            :     // start import
      60         [ +  - ]:         33 :     XMLGradientStyleImport aGradientStyle( GetImport() );
      61 [ +  - ][ +  - ]:         33 :     aGradientStyle.importXML( xAttrList, maAny, maStrName );
      62                 :         33 : }
      63                 :            : 
      64                 :         33 : XMLGradientStyleContext::~XMLGradientStyleContext()
      65                 :            : {
      66         [ -  + ]:         66 : }
      67                 :            : 
      68                 :         33 : void XMLGradientStyleContext::EndElement()
      69                 :            : {
      70         [ +  - ]:         33 :     uno::Reference< container::XNameContainer > xGradient( GetImport().GetGradientHelper() );
      71                 :            : 
      72                 :            :     try
      73                 :            :     {
      74         [ +  - ]:         33 :         if(xGradient.is())
      75                 :            :         {
      76 [ +  - ][ +  - ]:         33 :             if( xGradient->hasByName( maStrName ) )
                 [ -  + ]
      77                 :            :             {
      78 [ #  # ][ #  # ]:          0 :                 xGradient->replaceByName( maStrName, maAny );
      79                 :            :             }
      80                 :            :             else
      81                 :            :             {
      82 [ +  - ][ +  - ]:         33 :                 xGradient->insertByName( maStrName, maAny );
      83                 :            :             }
      84                 :            :         }
      85                 :            :     }
      86         [ #  # ]:          0 :     catch( container::ElementExistException& )
      87                 :         33 :     {}
      88         [ #  # ]:         33 : }
      89                 :            : 
      90                 :         33 : sal_Bool XMLGradientStyleContext::IsTransient() const
      91                 :            : {
      92                 :         33 :     return sal_True;
      93                 :            : }
      94                 :            : 
      95                 :            : //////////////////////////////////////////////////////////////////////////////
      96                 :            : //////////////////////////////////////////////////////////////////////////////
      97                 :            : 
      98 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLHatchStyleContext, SvXMLStyleContext );
      99                 :            : 
     100                 :         36 : XMLHatchStyleContext::XMLHatchStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     101                 :            :                                               const OUString& rLName,
     102                 :            :                                               const uno::Reference< xml::sax::XAttributeList >& xAttrList)
     103                 :         36 : :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList)
     104                 :            : {
     105                 :            :     // start import
     106         [ +  - ]:         36 :     XMLHatchStyleImport aHatchStyle( GetImport() );
     107 [ +  - ][ +  - ]:         36 :     aHatchStyle.importXML( xAttrList, maAny, maStrName );
     108                 :         36 : }
     109                 :            : 
     110                 :         36 : XMLHatchStyleContext::~XMLHatchStyleContext()
     111                 :            : {
     112         [ -  + ]:         72 : }
     113                 :            : 
     114                 :         36 : void XMLHatchStyleContext::EndElement()
     115                 :            : {
     116         [ +  - ]:         36 :     uno::Reference< container::XNameContainer > xHatch( GetImport().GetHatchHelper() );
     117                 :            : 
     118                 :            :     try
     119                 :            :     {
     120         [ +  - ]:         36 :         if(xHatch.is())
     121                 :            :         {
     122 [ +  - ][ +  - ]:         36 :             if( xHatch->hasByName( maStrName ) )
                 [ -  + ]
     123                 :            :             {
     124 [ #  # ][ #  # ]:          0 :                 xHatch->replaceByName( maStrName, maAny );
     125                 :            :             }
     126                 :            :             else
     127                 :            :             {
     128 [ +  - ][ +  - ]:         36 :                 xHatch->insertByName( maStrName, maAny );
     129                 :            :             }
     130                 :            :         }
     131                 :            :     }
     132         [ #  # ]:          0 :     catch( container::ElementExistException& )
     133                 :         36 :     {}
     134         [ #  # ]:         36 : }
     135                 :            : 
     136                 :         36 : sal_Bool XMLHatchStyleContext::IsTransient() const
     137                 :            : {
     138                 :         36 :     return sal_True;
     139                 :            : }
     140                 :            : 
     141                 :            : //////////////////////////////////////////////////////////////////////////////
     142                 :            : //////////////////////////////////////////////////////////////////////////////
     143                 :            : 
     144 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLBitmapStyleContext, SvXMLStyleContext );
     145                 :            : 
     146                 :         12 : XMLBitmapStyleContext::XMLBitmapStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     147                 :            :                                               const OUString& rLName,
     148                 :            :                                               const uno::Reference< xml::sax::XAttributeList >& xAttrList)
     149                 :         12 : :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList)
     150                 :            : {
     151                 :            :     // start import
     152         [ +  - ]:         12 :     XMLImageStyle aBitmapStyle;
     153 [ +  - ][ +  - ]:         12 :     aBitmapStyle.importXML( xAttrList, maAny, maStrName, rImport );
     154                 :         12 : }
     155                 :            : 
     156                 :         12 : XMLBitmapStyleContext::~XMLBitmapStyleContext()
     157                 :            : {
     158         [ -  + ]:         24 : }
     159                 :            : 
     160                 :          0 : SvXMLImportContext* XMLBitmapStyleContext::CreateChildContext( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList )
     161                 :            : {
     162                 :          0 :     SvXMLImportContext *pContext = 0;
     163 [ #  # ][ #  # ]:          0 :     if( (XML_NAMESPACE_OFFICE == nPrefix) && xmloff::token::IsXMLToken( rLocalName, xmloff::token::XML_BINARY_DATA ) )
                 [ #  # ]
     164                 :            :     {
     165                 :          0 :         OUString sURL;
     166                 :          0 :         maAny >>= sURL;
     167 [ #  # ][ #  # ]:          0 :         if( sURL.isEmpty() && !mxBase64Stream.is() )
                 [ #  # ]
     168                 :            :         {
     169 [ #  # ][ #  # ]:          0 :             mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
     170         [ #  # ]:          0 :             if( mxBase64Stream.is() )
     171                 :          0 :                 pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
     172                 :            :                                                     rLocalName, xAttrList,
     173 [ #  # ][ #  # ]:          0 :                                                     mxBase64Stream );
     174                 :          0 :         }
     175                 :            :     }
     176         [ #  # ]:          0 :     if( !pContext )
     177                 :            :     {
     178         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     179                 :            :     }
     180                 :            : 
     181                 :          0 :     return pContext;
     182                 :            : }
     183                 :            : 
     184                 :         12 : void XMLBitmapStyleContext::EndElement()
     185                 :            : {
     186                 :         12 :     OUString sURL;
     187                 :         12 :     maAny >>= sURL;
     188                 :            : 
     189 [ #  # ][ -  + ]:         12 :     if( sURL.isEmpty() && mxBase64Stream.is() )
                 [ -  + ]
     190                 :            :     {
     191         [ #  # ]:          0 :         sURL = GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream );
     192         [ #  # ]:          0 :         mxBase64Stream = 0;
     193         [ #  # ]:          0 :         maAny <<= sURL;
     194                 :            :     }
     195                 :            : 
     196         [ +  - ]:         12 :     uno::Reference< container::XNameContainer > xBitmap( GetImport().GetBitmapHelper() );
     197                 :            : 
     198                 :            :     try
     199                 :            :     {
     200         [ +  - ]:         12 :         if(xBitmap.is())
     201                 :            :         {
     202 [ +  - ][ +  - ]:         12 :             if( xBitmap->hasByName( maStrName ) )
                 [ -  + ]
     203                 :            :             {
     204 [ #  # ][ #  # ]:          0 :                 xBitmap->replaceByName( maStrName, maAny );
     205                 :            :             }
     206                 :            :             else
     207                 :            :             {
     208 [ +  - ][ +  - ]:         12 :                 xBitmap->insertByName( maStrName, maAny );
     209                 :            :             }
     210                 :            :         }
     211                 :            :     }
     212         [ #  # ]:          0 :     catch( container::ElementExistException& )
     213                 :         12 :     {}
     214         [ #  # ]:         12 : }
     215                 :            : 
     216                 :         12 : sal_Bool XMLBitmapStyleContext::IsTransient() const
     217                 :            : {
     218                 :         12 :     return sal_True;
     219                 :            : }
     220                 :            : 
     221                 :            : 
     222                 :            : //////////////////////////////////////////////////////////////////////////////
     223                 :            : //////////////////////////////////////////////////////////////////////////////
     224                 :            : 
     225 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLTransGradientStyleContext, SvXMLStyleContext );
     226                 :            : 
     227                 :         14 : XMLTransGradientStyleContext::XMLTransGradientStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     228                 :            :                                               const OUString& rLName,
     229                 :            :                                               const uno::Reference< xml::sax::XAttributeList >& xAttrList)
     230                 :         14 : :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList)
     231                 :            : {
     232                 :            :     // start import
     233         [ +  - ]:         14 :     XMLTransGradientStyleImport aTransGradientStyle( GetImport() );
     234 [ +  - ][ +  - ]:         14 :     aTransGradientStyle.importXML( xAttrList, maAny, maStrName );
     235                 :         14 : }
     236                 :            : 
     237                 :         14 : XMLTransGradientStyleContext::~XMLTransGradientStyleContext()
     238                 :            : {
     239         [ -  + ]:         28 : }
     240                 :            : 
     241                 :         14 : void XMLTransGradientStyleContext::EndElement()
     242                 :            : {
     243         [ +  - ]:         14 :     uno::Reference< container::XNameContainer > xTransGradient( GetImport().GetTransGradientHelper() );
     244                 :            : 
     245                 :            :     try
     246                 :            :     {
     247         [ +  - ]:         14 :         if(xTransGradient.is())
     248                 :            :         {
     249 [ +  - ][ +  - ]:         14 :             if( xTransGradient->hasByName( maStrName ) )
                 [ -  + ]
     250                 :            :             {
     251 [ #  # ][ #  # ]:          0 :                 xTransGradient->replaceByName( maStrName, maAny );
     252                 :            :             }
     253                 :            :             else
     254                 :            :             {
     255 [ +  - ][ +  - ]:         14 :                 xTransGradient->insertByName( maStrName, maAny );
     256                 :            :             }
     257                 :            :         }
     258                 :            :     }
     259         [ #  # ]:          0 :     catch( container::ElementExistException& )
     260                 :         14 :     {}
     261         [ #  # ]:         14 : }
     262                 :            : 
     263                 :         14 : sal_Bool XMLTransGradientStyleContext::IsTransient() const
     264                 :            : {
     265                 :         14 :     return sal_True;
     266                 :            : }
     267                 :            : 
     268                 :            : //////////////////////////////////////////////////////////////////////////////
     269                 :            : //////////////////////////////////////////////////////////////////////////////
     270                 :            : 
     271 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLMarkerStyleContext, SvXMLStyleContext );
     272                 :            : 
     273                 :         22 : XMLMarkerStyleContext::XMLMarkerStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     274                 :            :                                               const OUString& rLName,
     275                 :            :                                               const uno::Reference< xml::sax::XAttributeList >& xAttrList)
     276                 :         22 : :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList)
     277                 :            : {
     278                 :            :     // start import
     279         [ +  - ]:         22 :     XMLMarkerStyleImport aMarkerStyle( GetImport() );
     280 [ +  - ][ +  - ]:         22 :     aMarkerStyle.importXML( xAttrList, maAny, maStrName );
     281                 :         22 : }
     282                 :            : 
     283                 :         22 : XMLMarkerStyleContext::~XMLMarkerStyleContext()
     284                 :            : {
     285         [ -  + ]:         44 : }
     286                 :            : 
     287                 :         22 : void XMLMarkerStyleContext::EndElement()
     288                 :            : {
     289         [ +  - ]:         22 :     uno::Reference< container::XNameContainer > xMarker( GetImport().GetMarkerHelper() );
     290                 :            : 
     291                 :            :     try
     292                 :            :     {
     293         [ +  - ]:         22 :         if(xMarker.is())
     294                 :            :         {
     295 [ +  - ][ +  - ]:         22 :             if( xMarker->hasByName( maStrName ) )
                 [ +  + ]
     296                 :            :             {
     297 [ +  - ][ +  - ]:         11 :                 xMarker->replaceByName( maStrName, maAny );
     298                 :            :             }
     299                 :            :             else
     300                 :            :             {
     301 [ +  - ][ +  - ]:         11 :                 xMarker->insertByName( maStrName, maAny );
     302                 :            :             }
     303                 :            :         }
     304                 :            :     }
     305         [ #  # ]:          0 :     catch( container::ElementExistException& )
     306                 :         22 :     {}
     307         [ #  # ]:         22 : }
     308                 :            : 
     309                 :         22 : sal_Bool XMLMarkerStyleContext::IsTransient() const
     310                 :            : {
     311                 :         22 :     return sal_True;
     312                 :            : }
     313                 :            : 
     314                 :            : //////////////////////////////////////////////////////////////////////////////
     315                 :            : //////////////////////////////////////////////////////////////////////////////
     316                 :            : 
     317 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLDashStyleContext, SvXMLStyleContext );
     318                 :            : 
     319                 :          3 : XMLDashStyleContext::XMLDashStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     320                 :            :                                           const OUString& rLName,
     321                 :            :                                           const uno::Reference< xml::sax::XAttributeList >& xAttrList)
     322                 :          3 : :   SvXMLStyleContext(rImport, nPrfx, rLName, xAttrList)
     323                 :            : {
     324                 :            :     // start import
     325         [ +  - ]:          3 :     XMLDashStyleImport aDashStyle( GetImport() );
     326 [ +  - ][ +  - ]:          3 :     aDashStyle.importXML( xAttrList, maAny, maStrName );
     327                 :          3 : }
     328                 :            : 
     329                 :          3 : XMLDashStyleContext::~XMLDashStyleContext()
     330                 :            : {
     331         [ -  + ]:          6 : }
     332                 :            : 
     333                 :          3 : void XMLDashStyleContext::EndElement()
     334                 :            : {
     335         [ +  - ]:          3 :     uno::Reference< container::XNameContainer > xDashes( GetImport().GetDashHelper() );
     336                 :            : 
     337                 :            :     try
     338                 :            :     {
     339         [ +  - ]:          3 :         if(xDashes.is())
     340                 :            :         {
     341 [ +  - ][ +  - ]:          3 :             if( xDashes->hasByName( maStrName ) )
                 [ -  + ]
     342                 :            :             {
     343 [ #  # ][ #  # ]:          0 :                 xDashes->replaceByName( maStrName, maAny );
     344                 :            :             }
     345                 :            :             else
     346                 :            :             {
     347 [ +  - ][ +  - ]:          3 :                 xDashes->insertByName( maStrName, maAny );
     348                 :            :             }
     349                 :            :         }
     350                 :            :     }
     351         [ #  # ]:          0 :     catch( container::ElementExistException& )
     352                 :          3 :     {}
     353         [ #  # ]:          3 : }
     354                 :            : 
     355                 :          3 : sal_Bool XMLDashStyleContext::IsTransient() const
     356                 :            : {
     357                 :          3 :     return sal_True;
     358                 :            : }
     359                 :            : 
     360                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10