LCOV - code coverage report
Current view: top level - include/comphelper - enumhelper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1 100.0 %
Date: 2015-06-13 12:38:46 Functions: 2 2 100.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             : #ifndef INCLUDED_COMPHELPER_ENUMHELPER_HXX
      21             : #define INCLUDED_COMPHELPER_ENUMHELPER_HXX
      22             : 
      23             : #include <vector>
      24             : #include <com/sun/star/container/XNameAccess.hpp>
      25             : #include <com/sun/star/container/XEnumeration.hpp>
      26             : #include <com/sun/star/container/XIndexAccess.hpp>
      27             : #include <com/sun/star/lang/XEventListener.hpp>
      28             : #include <cppuhelper/implbase1.hxx>
      29             : #include <cppuhelper/implbase2.hxx>
      30             : #include <osl/mutex.hxx>
      31             : #include <comphelper/comphelperdllapi.h>
      32             : 
      33             : namespace comphelper
      34             : {
      35             : 
      36      102332 : struct OEnumerationLock
      37             : {
      38             :     public:
      39             :         ::osl::Mutex m_aLock;
      40             : };
      41             : 
      42             : /** provides an com.sun.star.container::XEnumeration access based
      43             :     on an object implementing the com.sun.star.container::XNameAccess interface
      44             : */
      45             : class COMPHELPER_DLLPUBLIC OEnumerationByName : private OEnumerationLock
      46             :                          , public ::cppu::WeakImplHelper2< css::container::XEnumeration ,
      47             :                                                            css::lang::XEventListener    >
      48             : {
      49             :     css::uno::Sequence< OUString >                m_aNames;
      50             :     sal_Int32                                           m_nPos;
      51             :     css::uno::Reference< css::container::XNameAccess >    m_xAccess;
      52             :     bool                                            m_bListening;
      53             : 
      54             : public:
      55             :     OEnumerationByName(const css::uno::Reference< css::container::XNameAccess >& _rxAccess);
      56             :     OEnumerationByName(const css::uno::Reference< css::container::XNameAccess >& _rxAccess,
      57             :                        const css::uno::Sequence< OUString >&             _aNames  );
      58             :     virtual ~OEnumerationByName();
      59             : 
      60             :     virtual sal_Bool SAL_CALL hasMoreElements(  ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      61             :     virtual css::uno::Any SAL_CALL nextElement(  )
      62             :         throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      63             : 
      64             :     virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      65             : 
      66             : private:
      67             :     COMPHELPER_DLLPRIVATE void impl_startDisposeListening();
      68             :     COMPHELPER_DLLPRIVATE void impl_stopDisposeListening();
      69             : };
      70             : 
      71             : /** provides an com.sun.star.container::XEnumeration access based
      72             :     on an object implementing the com.sun.star.container::XNameAccess interface
      73             : */
      74             : class COMPHELPER_DLLPUBLIC OEnumerationByIndex : private OEnumerationLock
      75             :                           , public ::cppu::WeakImplHelper2< css::container::XEnumeration ,
      76             :                                                             css::lang::XEventListener    >
      77             : {
      78             :     sal_Int32                                         m_nPos;
      79             :     css::uno::Reference< css::container::XIndexAccess > m_xAccess;
      80             :     bool                                          m_bListening;
      81             : 
      82             : public:
      83             :     OEnumerationByIndex(const css::uno::Reference< css::container::XIndexAccess >& _rxAccess);
      84             :     virtual ~OEnumerationByIndex();
      85             : 
      86             :     virtual sal_Bool SAL_CALL hasMoreElements(  ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      87             :     virtual css::uno::Any SAL_CALL nextElement(  )
      88             :         throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      89             : 
      90             :     virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      91             : 
      92             : private:
      93             :     COMPHELPER_DLLPRIVATE void impl_startDisposeListening();
      94             :     COMPHELPER_DLLPRIVATE void impl_stopDisposeListening();
      95             : };
      96             : 
      97             : /** provides an com.sun.star.container::XEnumeration
      98             :     for an outside set vector of Any's.
      99             : 
     100             : */
     101             : class COMPHELPER_DLLPUBLIC OAnyEnumeration : private OEnumerationLock
     102             :                                            , public  ::cppu::WeakImplHelper1< css::container::XEnumeration >
     103             : {
     104             :     sal_Int32                         m_nPos;
     105             :     css::uno::Sequence< css::uno::Any > m_lItems;
     106             : 
     107             : public:
     108             :     OAnyEnumeration(const css::uno::Sequence< css::uno::Any >& lItems);
     109             :     virtual ~OAnyEnumeration();
     110             : 
     111             :     virtual sal_Bool SAL_CALL hasMoreElements(  ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     112             :     virtual css::uno::Any SAL_CALL nextElement(  )
     113             :         throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     114             : 
     115             : };
     116             : 
     117             : }
     118             : 
     119             : #endif // INCLUDED_COMPHELPER_ENUMHELPER_HXX
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11