LCOV - code coverage report
Current view: top level - forms/source/xforms - unohelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 18 0.0 %
Date: 2012-08-25 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 46 0.0 %

           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 "unohelper.hxx"
      31                 :            : 
      32                 :            : #include <osl/diagnose.h>
      33                 :            : 
      34                 :            : #include <com/sun/star/uno/Reference.hxx>
      35                 :            : #include <com/sun/star/uno/Sequence.hxx>
      36                 :            : #include <com/sun/star/uno/XInterface.hpp>
      37                 :            : #include <com/sun/star/uno/Exception.hpp>
      38                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      39                 :            : #include <com/sun/star/beans/Property.hpp>
      40                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      41                 :            : #include <com/sun/star/beans/XPropertySetInfo.hpp>
      42                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      43                 :            : #include <comphelper/processfactory.hxx>
      44                 :            : 
      45                 :            : 
      46                 :            : using com::sun::star::uno::Reference;
      47                 :            : using com::sun::star::uno::Sequence;
      48                 :            : using com::sun::star::uno::Exception;
      49                 :            : using com::sun::star::uno::XInterface;
      50                 :            : using com::sun::star::lang::XMultiServiceFactory;
      51                 :            : using com::sun::star::beans::Property;
      52                 :            : using com::sun::star::beans::XPropertySet;
      53                 :            : using com::sun::star::beans::XPropertySetInfo;
      54                 :            : using com::sun::star::beans::PropertyAttribute::READONLY;
      55                 :            : using rtl::OUString;
      56                 :            : 
      57                 :            : 
      58                 :          0 : Reference<XInterface> xforms::createInstance( const OUString& sServiceName )
      59                 :            : {
      60         [ #  # ]:          0 :     Reference<XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory();
      61                 :            :     OSL_ENSURE( xFactory.is(), "can't get service factory" );
      62                 :            : 
      63 [ #  # ][ #  # ]:          0 :     Reference<XInterface> xInstance = xFactory->createInstance( sServiceName );
      64                 :            :     OSL_ENSURE( xInstance.is(), "failed to create instance" );
      65                 :            : 
      66                 :          0 :     return xInstance;
      67                 :            : }
      68                 :            : 
      69                 :          0 : void xforms::copy( const Reference<XPropertySet>& xFrom,
      70                 :            :                    Reference<XPropertySet>& xTo )
      71                 :            : {
      72                 :            :     OSL_ENSURE( xFrom.is(), "no source" );
      73                 :            :     OSL_ENSURE( xTo.is(), "no target" );
      74                 :            : 
      75                 :            :     // get property names & infos, and iterate over target properties
      76                 :            :     Sequence<Property> aProperties =
      77 [ #  # ][ #  # ]:          0 :         xTo->getPropertySetInfo()->getProperties();
         [ #  # ][ #  # ]
      78                 :          0 :     sal_Int32 nProperties = aProperties.getLength();
      79                 :          0 :     const Property* pProperties = aProperties.getConstArray();
      80 [ #  # ][ #  # ]:          0 :     Reference<XPropertySetInfo> xFromInfo = xFrom->getPropertySetInfo();
      81         [ #  # ]:          0 :     for( sal_Int32 n = 0; n < nProperties; n++ )
      82                 :            :     {
      83                 :          0 :         const OUString& rName = pProperties[n].Name;
      84                 :            : 
      85                 :            :         // if both set have the property, copy the value
      86                 :            :         // (catch and ignore exceptions, if any)
      87 [ #  # ][ #  # ]:          0 :         if( xFromInfo->hasPropertyByName( rName ) )
                 [ #  # ]
      88                 :            :         {
      89                 :            :             try
      90                 :            :             {
      91 [ #  # ][ #  # ]:          0 :                 Property aProperty = xFromInfo->getPropertyByName( rName );
      92         [ #  # ]:          0 :                 if ( ( aProperty.Attributes & READONLY ) == 0 )
      93 [ #  # ][ #  # ]:          0 :                     xTo->setPropertyValue(rName, xFrom->getPropertyValue( rName ));
         [ #  # ][ #  # ]
                 [ #  # ]
      94                 :            :             }
      95         [ #  # ]:          0 :             catch( const Exception& )
      96                 :            :             {
      97                 :            :                 // ignore any errors; we'll copy as good as we can
      98                 :            :             }
      99                 :            :         }
     100                 :            :         // else: no property? then ignore.
     101         [ #  # ]:          0 :     }
     102                 :          0 : }
     103                 :            : 
     104                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10