LCOV - code coverage report
Current view: top level - xmloff/source/draw - layerexp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 29 82.8 %
Date: 2012-08-25 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 33 80 41.2 %

           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                 :            : 
      30                 :            : #include <com/sun/star/drawing/XLayerSupplier.hpp>
      31                 :            : #include <com/sun/star/container/XIndexAccess.hpp>
      32                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      33                 :            : #include <xmloff/xmltoken.hxx>
      34                 :            : #include "xmloff/xmlnmspe.hxx"
      35                 :            : #include <xmloff/xmlexp.hxx>
      36                 :            : #include <xmloff/xmlement.hxx>
      37                 :            : #include <xmloff/nmspmap.hxx>
      38                 :            : #include "layerexp.hxx"
      39                 :            : 
      40                 :            : using ::rtl::OUString;
      41                 :            : using ::rtl::OUStringBuffer;
      42                 :            : using ::com::sun::star::uno::Reference;
      43                 :            : 
      44                 :            : using namespace ::cppu;
      45                 :            : using namespace ::com::sun::star;
      46                 :            : using namespace ::com::sun::star::uno;
      47                 :            : using namespace ::com::sun::star::drawing;
      48                 :            : using namespace ::com::sun::star::beans;
      49                 :            : using namespace ::com::sun::star::lang;
      50                 :            : using namespace ::com::sun::star::container;
      51                 :            : using namespace ::xmloff::token;
      52                 :            : 
      53                 :         12 : void SdXMLayerExporter::exportLayer( SvXMLExport& rExport )
      54                 :            : {
      55         [ +  - ]:         12 :     Reference< XLayerSupplier > xLayerSupplier( rExport.GetModel(), UNO_QUERY );
      56         [ -  + ]:         12 :     if( !xLayerSupplier.is() )
      57                 :            :         return;
      58                 :            : 
      59 [ +  - ][ +  - ]:         12 :     Reference< XIndexAccess > xLayerManager( xLayerSupplier->getLayerManager(), UNO_QUERY );
                 [ +  - ]
      60         [ -  + ]:         12 :     if( !xLayerManager.is() )
      61                 :            :         return;
      62                 :            : 
      63 [ +  - ][ +  - ]:         12 :     const sal_Int32 nCount = xLayerManager->getCount();
      64         [ -  + ]:         12 :     if( nCount == 0 )
      65                 :            :         return;
      66                 :            : 
      67         [ +  - ]:         12 :     const OUString strName( RTL_CONSTASCII_USTRINGPARAM( "Name" ) );
      68         [ +  - ]:         12 :     const OUString strTitle( RTL_CONSTASCII_USTRINGPARAM( "Title" ) );
      69         [ +  - ]:         12 :     const OUString strDescription( RTL_CONSTASCII_USTRINGPARAM( "Description" ) );
      70                 :            : 
      71                 :         12 :     OUString sTmp;
      72                 :            : 
      73         [ +  - ]:         12 :     SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, XML_LAYER_SET, sal_True, sal_True );
      74                 :            : 
      75         [ +  + ]:         72 :     for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
      76                 :            :     {
      77                 :            :         try
      78                 :            :         {
      79 [ +  - ][ +  - ]:         60 :             Reference< XPropertySet> xLayer( xLayerManager->getByIndex( nIndex ), UNO_QUERY_THROW );
                 [ +  - ]
      80 [ +  - ][ +  - ]:         60 :             xLayer->getPropertyValue( strName ) >>= sTmp;
      81         [ +  - ]:         60 :             if(!sTmp.isEmpty())
      82         [ +  - ]:         60 :                 rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, sTmp );
      83                 :            : 
      84         [ +  - ]:         60 :             SvXMLElementExport aEle( rExport, XML_NAMESPACE_DRAW, XML_LAYER, sal_True, sal_True );
      85                 :            : 
      86                 :            :             // title property (as <svg:title> element)
      87 [ +  - ][ +  - ]:         60 :             xLayer->getPropertyValue(strTitle) >>= sTmp;
      88         [ -  + ]:         60 :             if(!sTmp.isEmpty())
      89                 :            :             {
      90         [ #  # ]:          0 :                 SvXMLElementExport aEventElemt(rExport, XML_NAMESPACE_SVG, XML_TITLE, sal_True, sal_False);
      91 [ #  # ][ #  # ]:          0 :                 rExport.Characters(sTmp);
      92                 :            :             }
      93                 :            : 
      94                 :            :             // description property (as <svg:desc> element)
      95 [ +  - ][ +  - ]:         60 :             xLayer->getPropertyValue(strDescription) >>= sTmp;
      96         [ -  + ]:         60 :             if(!sTmp.isEmpty())
      97                 :            :             {
      98         [ #  # ]:          0 :                 SvXMLElementExport aDesc(rExport, XML_NAMESPACE_SVG, XML_DESC, sal_True, sal_False);
      99 [ #  # ][ #  # ]:          0 :                 rExport.Characters(sTmp);
     100 [ +  - ][ #  # ]:         60 :             }
     101                 :            :         }
     102         [ #  # ]:          0 :         catch( Exception& )
     103                 :            :         {
     104                 :            :             OSL_FAIL("SdXMLayerExporter::exportLayer(), exception caught during export of one layer!");
     105                 :            :         }
     106 [ +  - ][ -  + ]:         12 :     }
                 [ +  - ]
     107                 :            : }
     108                 :            : 
     109                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10