1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ohierarchyholder.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _OHIERARCHYHOLDER_HXX_
32 #define _OHIERARCHYHOLDER_HXX_
34 #include <com/sun/star/embed/XStorage.hpp>
35 #include <com/sun/star/embed/XTransactionListener.hpp>
36 #include <com/sun/star/embed/XExtendedStorageStream.hpp>
37 #include <cppuhelper/implbase1.hxx>
39 #include <rtl/ref.hxx>
45 struct OHierarchyElement_Impl
;
49 sal_Bool
operator()( const rtl::OUString
&r1
,
50 const rtl::OUString
&r2
) const
55 typedef ::std::hash_map
< ::rtl::OUString
,
56 ::rtl::Reference
< OHierarchyElement_Impl
>,
58 eqFunc
> OHierarchyElementList_Impl
;
60 typedef ::std::vector
< ::rtl::OUString
> OStringList_Impl
;
61 typedef ::std::list
< ::com::sun::star::uno::WeakReference
< ::com::sun::star::embed::XExtendedStorageStream
> >
62 OWeakStorRefList_Impl
;
64 struct OHierarchyElement_Impl
: public cppu::WeakImplHelper1
< ::com::sun::star::embed::XTransactionListener
>
66 ::osl::Mutex m_aMutex
;
68 ::rtl::Reference
< OHierarchyElement_Impl
> m_rParent
;
69 ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
> m_xOwnStorage
;
70 ::com::sun::star::uno::WeakReference
< ::com::sun::star::embed::XStorage
> m_xWeakOwnStorage
;
72 OHierarchyElementList_Impl m_aChildren
;
74 OWeakStorRefList_Impl m_aOpenStreams
;
77 OHierarchyElement_Impl( OHierarchyElement_Impl
* pParent
, const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
)
78 : m_rParent( pParent
)
79 , m_xOwnStorage( xStorage
)
82 OHierarchyElement_Impl( const ::com::sun::star::uno::WeakReference
< ::com::sun::star::embed::XStorage
>& xWeakStorage
)
84 , m_xWeakOwnStorage( xWeakStorage
)
89 void SetParent( const ::rtl::Reference
< OHierarchyElement_Impl
>& rParent
) { m_rParent
= rParent
; }
91 void TestForClosing();
93 void RemoveElement( const ::rtl::Reference
< OHierarchyElement_Impl
>& aRef
);
95 ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XExtendedStorageStream
>
96 GetStreamHierarchically( sal_Int32 nStorageMode
,
97 OStringList_Impl
& aPath
,
98 sal_Int32 nStreamMode
,
99 const ::rtl::OUString
& aPassword
= ::rtl::OUString() );
101 void RemoveStreamHierarchically( OStringList_Impl
& aListPath
);
104 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
)
105 throw (::com::sun::star::uno::RuntimeException
);
108 // XTransactionListener
109 virtual void SAL_CALL
preCommit( const ::com::sun::star::lang::EventObject
& aEvent
)
110 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
111 virtual void SAL_CALL
commited( const ::com::sun::star::lang::EventObject
& aEvent
)
112 throw (::com::sun::star::uno::RuntimeException
);
113 virtual void SAL_CALL
preRevert( const ::com::sun::star::lang::EventObject
& aEvent
)
114 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
115 virtual void SAL_CALL
reverted( const ::com::sun::star::lang::EventObject
& aEvent
)
116 throw (::com::sun::star::uno::RuntimeException
);
120 class OHierarchyHolder_Impl
: public ::cppu::OWeakObject
122 ::com::sun::star::uno::WeakReference
< ::com::sun::star::embed::XStorage
> m_xWeakOwnStorage
;
123 ::rtl::Reference
< OHierarchyElement_Impl
> m_xChild
;
125 OHierarchyHolder_Impl( const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xOwnStorage
)
126 : m_xWeakOwnStorage( xOwnStorage
)
127 , m_xChild( new OHierarchyElement_Impl( ::com::sun::star::uno::WeakReference
< ::com::sun::star::embed::XStorage
>( xOwnStorage
) ) )
130 static OStringList_Impl
GetListPathFromString( const ::rtl::OUString
& aPath
);
132 ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XExtendedStorageStream
>
133 GetStreamHierarchically( sal_Int32 nStorageMode
,
134 OStringList_Impl
& aListPath
,
135 sal_Int32 nStreamMode
,
136 const ::rtl::OUString
& aPassword
= ::rtl::OUString() );
138 void RemoveStreamHierarchically( OStringList_Impl
& aListPath
);
141 #endif // _OHIERARCHYHOLDER