LCOV - code coverage report
Current view: top level - sd/source/ui/unoidl - unowcntr.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 42 0.0 %
Date: 2014-04-14 Functions: 0 5 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             : #include <com/sun/star/lang/XComponent.hpp>
      21             : 
      22             : #include <unowcntr.hxx>
      23             : 
      24             : using namespace ::rtl;
      25             : using namespace ::com::sun::star;
      26             : 
      27           0 : SvUnoWeakContainer::SvUnoWeakContainer() throw()
      28             : {
      29           0 : }
      30             : 
      31           0 : SvUnoWeakContainer::~SvUnoWeakContainer() throw()
      32             : {
      33           0 :     for ( WeakRefList::iterator it = maList.begin(); it != maList.end(); ++it )
      34           0 :             delete *it;
      35           0 :     maList.clear();
      36           0 : }
      37             : 
      38             : /** inserts the given ref into this container */
      39           0 : void SvUnoWeakContainer::insert( uno::WeakReference< uno::XInterface > xRef ) throw()
      40             : {
      41           0 :     for ( WeakRefList::iterator it = maList.begin(); it != maList.end(); )
      42             :     {
      43           0 :         uno::WeakReference< uno::XInterface >* pRef = *it;
      44           0 :         uno::Reference< uno::XInterface > xTestRef( *pRef );
      45           0 :         if ( !xTestRef.is() )
      46             :         {
      47           0 :             delete pRef;
      48           0 :             it = maList.erase( it );
      49             :         }
      50             :         else
      51             :         {
      52           0 :             if ( *pRef == xRef )
      53           0 :                 return;
      54           0 :             ++it;
      55             :         }
      56           0 :     }
      57           0 :     maList.push_back( new uno::WeakReference< uno::XInterface >( xRef ) );
      58             : }
      59             : 
      60             : /** searches the container for a ref that returns true on the given
      61             :     search function
      62             : */
      63           0 : sal_Bool SvUnoWeakContainer::findRef(
      64             :     uno::WeakReference< uno::XInterface >& rRef,
      65             :     void* pSearchData,
      66             :     weakref_searchfunc pSearchFunc
      67             : )
      68             : {
      69           0 :     for ( WeakRefList::iterator it = maList.begin(); it != maList.end(); )
      70             :     {
      71           0 :         uno::WeakReference< uno::XInterface >* pRef = *it;
      72           0 :         uno::Reference< uno::XInterface > xTestRef( *pRef );
      73           0 :         if ( !xTestRef.is() )
      74             :         {
      75           0 :             delete pRef;
      76           0 :             it = maList.erase( it );
      77             :         }
      78             :         else
      79             :         {
      80           0 :             if( (*pSearchFunc)( *pRef, pSearchData ) )
      81             :             {
      82           0 :                 rRef = *pRef;
      83           0 :                 return sal_True;
      84             :             }
      85           0 :             ++it;
      86             :         }
      87           0 :     }
      88           0 :     return sal_False;
      89             : }
      90             : 
      91           0 : void SvUnoWeakContainer::dispose()
      92             : {
      93           0 :     for ( WeakRefList::iterator it = maList.begin(); it != maList.end(); ++it )
      94             :     {
      95           0 :         uno::WeakReference< uno::XInterface >* pRef = *it;
      96           0 :         uno::Reference< uno::XInterface > xTestRef( *pRef );
      97           0 :         if ( xTestRef.is() )
      98             :         {
      99           0 :             uno::Reference< lang::XComponent > xComp( xTestRef, uno::UNO_QUERY );
     100           0 :             if( xComp.is() )
     101           0 :                 xComp->dispose();
     102             :         }
     103           0 :     }
     104           0 : }
     105             : 
     106             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10