LCOV - code coverage report
Current view: top level - package/source/xstor - ohierarchyholder.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 14 14 100.0 %
Date: 2015-06-13 12:38:46 Functions: 9 9 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_PACKAGE_SOURCE_XSTOR_OHIERARCHYHOLDER_HXX
      21             : #define INCLUDED_PACKAGE_SOURCE_XSTOR_OHIERARCHYHOLDER_HXX
      22             : 
      23             : #include <com/sun/star/embed/XStorage.hpp>
      24             : #include <com/sun/star/embed/XTransactionListener.hpp>
      25             : #include <com/sun/star/embed/XExtendedStorageStream.hpp>
      26             : #include <cppuhelper/implbase1.hxx>
      27             : 
      28             : #include <comphelper/sequenceashashmap.hxx>
      29             : 
      30             : #include <rtl/ref.hxx>
      31             : 
      32             : #include <list>
      33             : #include <unordered_map>
      34             : #include <vector>
      35             : 
      36             : struct OHierarchyElement_Impl;
      37             : 
      38             : struct eqFunc
      39             : {
      40       22363 :     bool operator()( const OUString &r1,
      41             :                          const OUString &r2) const
      42             :     {
      43       22363 :         return r1 == r2;
      44             :     }
      45             : };
      46             : typedef std::unordered_map< OUString,
      47             :                          ::rtl::Reference< OHierarchyElement_Impl >,
      48             :                          OUStringHash,
      49             :                          eqFunc > OHierarchyElementList_Impl;
      50             : 
      51             : typedef ::std::vector< OUString > OStringList_Impl;
      52             : typedef ::std::list< ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XExtendedStorageStream > >
      53             :                         OWeakStorRefList_Impl;
      54             : 
      55       21326 : struct OHierarchyElement_Impl : public cppu::WeakImplHelper1< ::com::sun::star::embed::XTransactionListener >
      56             : {
      57             :     ::osl::Mutex m_aMutex;
      58             : 
      59             :     ::rtl::Reference< OHierarchyElement_Impl > m_rParent;
      60             :     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > m_xOwnStorage;
      61             :     ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage > m_xWeakOwnStorage;
      62             : 
      63             :     OHierarchyElementList_Impl m_aChildren;
      64             : 
      65             :     OWeakStorRefList_Impl m_aOpenStreams;
      66             : 
      67             : public:
      68        7389 :     OHierarchyElement_Impl( OHierarchyElement_Impl* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage )
      69             :     : m_rParent( pParent )
      70        7389 :     , m_xOwnStorage( xStorage )
      71        7389 :     {}
      72             : 
      73        3274 :     OHierarchyElement_Impl( const ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage >& xWeakStorage )
      74             :     : m_rParent( NULL )
      75        3274 :     , m_xWeakOwnStorage( xWeakStorage )
      76        3274 :     {}
      77             : 
      78             :     void Commit();
      79             : 
      80        7389 :     void SetParent( const ::rtl::Reference< OHierarchyElement_Impl >& rParent ) { m_rParent = rParent; }
      81             : 
      82             :     void TestForClosing();
      83             : 
      84             :     void RemoveElement( const ::rtl::Reference< OHierarchyElement_Impl >& aRef );
      85             : 
      86             :     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XExtendedStorageStream >
      87             :         GetStreamHierarchically( sal_Int32 nStorageMode,
      88             :                                 OStringList_Impl& aPath,
      89             :                                 sal_Int32 nStreamMode,
      90             :                                 const ::comphelper::SequenceAsHashMap& aEncryptionData = ::comphelper::SequenceAsHashMap() );
      91             : 
      92             :     void RemoveStreamHierarchically( OStringList_Impl& aListPath );
      93             : 
      94             :     // XEventListener
      95             :     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
      96             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      97             : 
      98             :     // XTransactionListener
      99             :     virtual void SAL_CALL preCommit( const ::com::sun::star::lang::EventObject& aEvent )
     100             :         throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     101             :     virtual void SAL_CALL commited( const ::com::sun::star::lang::EventObject& aEvent )
     102             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     103             :     virtual void SAL_CALL preRevert( const ::com::sun::star::lang::EventObject& aEvent )
     104             :         throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     105             :     virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& aEvent )
     106             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     107             : 
     108             : };
     109             : 
     110        6548 : class OHierarchyHolder_Impl : public ::cppu::OWeakObject
     111             : {
     112             :     ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage > m_xWeakOwnStorage;
     113             :     ::rtl::Reference< OHierarchyElement_Impl > m_xChild;
     114             : public:
     115        3274 :     OHierarchyHolder_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xOwnStorage )
     116             :     : m_xWeakOwnStorage( xOwnStorage )
     117        3274 :     , m_xChild( new OHierarchyElement_Impl( ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage >( xOwnStorage ) ) )
     118        3274 :     {}
     119             : 
     120             :     static OStringList_Impl GetListPathFromString( const OUString& aPath );
     121             : 
     122             :     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XExtendedStorageStream >
     123             :         GetStreamHierarchically( sal_Int32 nStorageMode,
     124             :                                 OStringList_Impl& aListPath,
     125             :                                 sal_Int32 nStreamMode,
     126             :                                 const ::comphelper::SequenceAsHashMap& aEncryptionData = ::comphelper::SequenceAsHashMap() );
     127             : 
     128             :     void RemoveStreamHierarchically( OStringList_Impl& aListPath );
     129             : };
     130             : 
     131             : #endif // _OHIERARCHYHOLDER
     132             : 
     133             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11