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 _OHIERARCHYHOLDER_HXX_
21 : #define _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 <boost/unordered_map.hpp>
33 : #include <list>
34 : #include <vector>
35 :
36 : struct OHierarchyElement_Impl;
37 :
38 : struct eqFunc
39 : {
40 462 : sal_Bool operator()( const rtl::OUString &r1,
41 : const rtl::OUString &r2) const
42 : {
43 462 : return r1 == r2;
44 : }
45 : };
46 : typedef ::boost::unordered_map< ::rtl::OUString,
47 : ::rtl::Reference< OHierarchyElement_Impl >,
48 : ::rtl::OUStringHash,
49 : eqFunc > OHierarchyElementList_Impl;
50 :
51 : typedef ::std::vector< ::rtl::OUString > OStringList_Impl;
52 : typedef ::std::list< ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XExtendedStorageStream > >
53 : OWeakStorRefList_Impl;
54 :
55 898 : 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 250 : OHierarchyElement_Impl( OHierarchyElement_Impl* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage )
69 : : m_rParent( pParent )
70 250 : , m_xOwnStorage( xStorage )
71 250 : {}
72 :
73 199 : OHierarchyElement_Impl( const ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage >& xWeakStorage )
74 : : m_rParent( NULL )
75 199 : , m_xWeakOwnStorage( xWeakStorage )
76 199 : {}
77 :
78 : void Commit();
79 :
80 250 : 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);
97 :
98 :
99 : // XTransactionListener
100 : virtual void SAL_CALL preCommit( const ::com::sun::star::lang::EventObject& aEvent )
101 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
102 : virtual void SAL_CALL commited( const ::com::sun::star::lang::EventObject& aEvent )
103 : throw (::com::sun::star::uno::RuntimeException);
104 : virtual void SAL_CALL preRevert( const ::com::sun::star::lang::EventObject& aEvent )
105 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
106 : virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& aEvent )
107 : throw (::com::sun::star::uno::RuntimeException);
108 :
109 : };
110 :
111 398 : class OHierarchyHolder_Impl : public ::cppu::OWeakObject
112 : {
113 : ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage > m_xWeakOwnStorage;
114 : ::rtl::Reference< OHierarchyElement_Impl > m_xChild;
115 : public:
116 199 : OHierarchyHolder_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xOwnStorage )
117 : : m_xWeakOwnStorage( xOwnStorage )
118 199 : , m_xChild( new OHierarchyElement_Impl( ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage >( xOwnStorage ) ) )
119 199 : {}
120 :
121 : static OStringList_Impl GetListPathFromString( const ::rtl::OUString& aPath );
122 :
123 : ::com::sun::star::uno::Reference< ::com::sun::star::embed::XExtendedStorageStream >
124 : GetStreamHierarchically( sal_Int32 nStorageMode,
125 : OStringList_Impl& aListPath,
126 : sal_Int32 nStreamMode,
127 : const ::comphelper::SequenceAsHashMap& aEncryptionData = ::comphelper::SequenceAsHashMap() );
128 :
129 : void RemoveStreamHierarchically( OStringList_Impl& aListPath );
130 : };
131 :
132 : #endif // _OHIERARCHYHOLDER
133 :
134 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|