Branch libreoffice-5-0-4
[LibreOffice.git] / package / source / xstor / ohierarchyholder.hxx
blobd680b434dd6a392a1af8f7663ab1f77fcbdd97e5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_PACKAGE_SOURCE_XSTOR_OHIERARCHYHOLDER_HXX
21 #define INCLUDED_PACKAGE_SOURCE_XSTOR_OHIERARCHYHOLDER_HXX
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>
28 #include <comphelper/sequenceashashmap.hxx>
30 #include <rtl/ref.hxx>
32 #include <list>
33 #include <unordered_map>
34 #include <vector>
36 struct OHierarchyElement_Impl;
38 struct eqFunc
40 bool operator()( const OUString &r1,
41 const OUString &r2) const
43 return r1 == r2;
46 typedef std::unordered_map< OUString,
47 ::rtl::Reference< OHierarchyElement_Impl >,
48 OUStringHash,
49 eqFunc > OHierarchyElementList_Impl;
51 typedef ::std::vector< OUString > OStringList_Impl;
52 typedef ::std::list< ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XExtendedStorageStream > >
53 OWeakStorRefList_Impl;
55 struct OHierarchyElement_Impl : public cppu::WeakImplHelper1< ::com::sun::star::embed::XTransactionListener >
57 ::osl::Mutex m_aMutex;
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;
63 OHierarchyElementList_Impl m_aChildren;
65 OWeakStorRefList_Impl m_aOpenStreams;
67 public:
68 OHierarchyElement_Impl( OHierarchyElement_Impl* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage )
69 : m_rParent( pParent )
70 , m_xOwnStorage( xStorage )
73 OHierarchyElement_Impl( const ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage >& xWeakStorage )
74 : m_rParent( NULL )
75 , m_xWeakOwnStorage( xWeakStorage )
78 void Commit();
80 void SetParent( const ::rtl::Reference< OHierarchyElement_Impl >& rParent ) { m_rParent = rParent; }
82 void TestForClosing();
84 void RemoveElement( const ::rtl::Reference< OHierarchyElement_Impl >& aRef );
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() );
92 void RemoveStreamHierarchically( OStringList_Impl& aListPath );
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;
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;
110 class OHierarchyHolder_Impl : public ::cppu::OWeakObject
112 ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage > m_xWeakOwnStorage;
113 ::rtl::Reference< OHierarchyElement_Impl > m_xChild;
114 public:
115 OHierarchyHolder_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xOwnStorage )
116 : m_xWeakOwnStorage( xOwnStorage )
117 , m_xChild( new OHierarchyElement_Impl( ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage >( xOwnStorage ) ) )
120 static OStringList_Impl GetListPathFromString( const OUString& aPath );
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() );
128 void RemoveStreamHierarchically( OStringList_Impl& aListPath );
131 #endif // _OHIERARCHYHOLDER
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */