LCOV - code coverage report
Current view: top level - forms/source/xforms - unohelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 14 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 1 0.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             : 
      21             : #include "unohelper.hxx"
      22             : 
      23             : #include <osl/diagnose.h>
      24             : 
      25             : #include <com/sun/star/uno/Reference.hxx>
      26             : #include <com/sun/star/uno/Sequence.hxx>
      27             : #include <com/sun/star/uno/XInterface.hpp>
      28             : #include <com/sun/star/uno/Exception.hpp>
      29             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      30             : #include <com/sun/star/beans/Property.hpp>
      31             : #include <com/sun/star/beans/XPropertySet.hpp>
      32             : #include <com/sun/star/beans/XPropertySetInfo.hpp>
      33             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      34             : #include <comphelper/processfactory.hxx>
      35             : 
      36             : 
      37             : using com::sun::star::uno::Reference;
      38             : using com::sun::star::uno::Sequence;
      39             : using com::sun::star::uno::Exception;
      40             : using com::sun::star::uno::XInterface;
      41             : using com::sun::star::lang::XMultiServiceFactory;
      42             : using com::sun::star::beans::Property;
      43             : using com::sun::star::beans::XPropertySet;
      44             : using com::sun::star::beans::XPropertySetInfo;
      45             : using com::sun::star::beans::PropertyAttribute::READONLY;
      46             : 
      47             : 
      48           0 : void xforms::copy( const Reference<XPropertySet>& xFrom,
      49             :                    Reference<XPropertySet>& xTo )
      50             : {
      51             :     OSL_ENSURE( xFrom.is(), "no source" );
      52             :     OSL_ENSURE( xTo.is(), "no target" );
      53             : 
      54             :     // get property names & infos, and iterate over target properties
      55             :     Sequence<Property> aProperties =
      56           0 :         xTo->getPropertySetInfo()->getProperties();
      57           0 :     sal_Int32 nProperties = aProperties.getLength();
      58           0 :     const Property* pProperties = aProperties.getConstArray();
      59           0 :     Reference<XPropertySetInfo> xFromInfo = xFrom->getPropertySetInfo();
      60           0 :     for( sal_Int32 n = 0; n < nProperties; n++ )
      61             :     {
      62           0 :         const OUString& rName = pProperties[n].Name;
      63             : 
      64             :         // if both set have the property, copy the value
      65             :         // (catch and ignore exceptions, if any)
      66           0 :         if( xFromInfo->hasPropertyByName( rName ) )
      67             :         {
      68             :             try
      69             :             {
      70           0 :                 Property aProperty = xFromInfo->getPropertyByName( rName );
      71           0 :                 if ( ( aProperty.Attributes & READONLY ) == 0 )
      72           0 :                     xTo->setPropertyValue(rName, xFrom->getPropertyValue( rName ));
      73             :             }
      74           0 :             catch( const Exception& )
      75             :             {
      76             :                 // ignore any errors; we'll copy as good as we can
      77             :             }
      78             :         }
      79             :         // else: no property? then ignore.
      80           0 :     }
      81           0 : }
      82             : 
      83             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11