LCOV - code coverage report
Current view: top level - libreoffice/forms/source/misc - componenttools.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 35 82.9 %
Date: 2012-12-17 Functions: 6 8 75.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             : #include "componenttools.hxx"
      21             : 
      22             : #include <com/sun/star/container/XChild.hpp>
      23             : 
      24             : #include <algorithm>
      25             : #include <iterator>
      26             : 
      27             : //........................................................................
      28             : namespace frm
      29             : {
      30             : //........................................................................
      31             : 
      32             :     /** === begin UNO using === **/
      33             :     using ::com::sun::star::frame::XModel;
      34             :     using ::com::sun::star::uno::XInterface;
      35             :     using ::com::sun::star::uno::Reference;
      36             :     using ::com::sun::star::uno::UNO_QUERY;
      37             :     using ::com::sun::star::container::XChild;
      38             :     /** === end UNO using === **/
      39             : 
      40             :     //====================================================================
      41             :     //= TypeBag
      42             :     //====================================================================
      43             :     //--------------------------------------------------------------------
      44          24 :     TypeBag::TypeBag( const TypeSequence& _rTypes1 )
      45             :     {
      46          24 :         addTypes( _rTypes1 );
      47          24 :     }
      48             : 
      49             :     //--------------------------------------------------------------------
      50           1 :     TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2 )
      51             :     {
      52           1 :         addTypes( _rTypes1 );
      53           1 :         addTypes( _rTypes2 );
      54           1 :     }
      55             : 
      56             :     //--------------------------------------------------------------------
      57           8 :     TypeBag::TypeBag( const TypeSequence& _rTypes1, const TypeSequence& _rTypes2, const TypeSequence& _rTypes3 )
      58             :     {
      59           8 :         addTypes( _rTypes1 );
      60           8 :         addTypes( _rTypes2 );
      61           8 :         addTypes( _rTypes3 );
      62           8 :     }
      63             : 
      64             :     //--------------------------------------------------------------------
      65          74 :     void TypeBag::addTypes( const TypeSequence& _rTypes )
      66             :     {
      67             :         ::std::copy(
      68             :             _rTypes.getConstArray(),
      69          74 :             _rTypes.getConstArray() + _rTypes.getLength(),
      70             :             ::std::insert_iterator< TypeSet >( m_aTypes, m_aTypes.begin() )
      71         148 :         );
      72          74 :     }
      73             : 
      74             :     //--------------------------------------------------------------------
      75           0 :     void TypeBag::addType( const Type& i_rType )
      76             :     {
      77           0 :         m_aTypes.insert( i_rType );
      78           0 :     }
      79             : 
      80             :     //--------------------------------------------------------------------
      81           0 :     void TypeBag::removeType( const TypeBag::Type& i_rType )
      82             :     {
      83           0 :         m_aTypes.erase( i_rType );
      84           0 :     }
      85             : 
      86             :     //--------------------------------------------------------------------
      87          33 :     TypeBag::TypeSequence TypeBag::getTypes() const
      88             :     {
      89          33 :         TypeSequence aTypes( m_aTypes.size() );
      90          33 :         ::std::copy( m_aTypes.begin(), m_aTypes.end(), aTypes.getArray() );
      91          33 :         return aTypes;
      92             :     }
      93             : 
      94             :     //====================================================================
      95          14 :     Reference< XModel >  getXModel( const Reference< XInterface >& _rxComponent )
      96             :     {
      97          14 :         Reference< XInterface > xParent = _rxComponent;
      98          14 :         Reference< XModel > xModel( xParent, UNO_QUERY );
      99          56 :         while ( xParent.is() && !xModel.is() )
     100             :         {
     101          28 :             Reference< XChild > xChild( xParent, UNO_QUERY );
     102          28 :             xParent.set( xChild.is() ? xChild->getParent() : Reference< XInterface >(), UNO_QUERY );
     103          28 :             xModel.set( xParent, UNO_QUERY );
     104          28 :         }
     105          14 :         return xModel;
     106             :     }
     107             : 
     108             : //........................................................................
     109             : } // namespace frm
     110             : //........................................................................
     111             : 
     112             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10