1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef _OHIERARCHYHOLDER_HXX_ 25*b1cdbd2cSJim Jagielski #define _OHIERARCHYHOLDER_HXX_ 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/XStorage.hpp> 28*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/XTransactionListener.hpp> 29*b1cdbd2cSJim Jagielski #include <com/sun/star/embed/XExtendedStorageStream.hpp> 30*b1cdbd2cSJim Jagielski #include <cppuhelper/implbase1.hxx> 31*b1cdbd2cSJim Jagielski 32*b1cdbd2cSJim Jagielski #include <comphelper/sequenceashashmap.hxx> 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski #include <rtl/ref.hxx> 35*b1cdbd2cSJim Jagielski 36*b1cdbd2cSJim Jagielski #include <hash_map> 37*b1cdbd2cSJim Jagielski #include <list> 38*b1cdbd2cSJim Jagielski #include <vector> 39*b1cdbd2cSJim Jagielski 40*b1cdbd2cSJim Jagielski struct OHierarchyElement_Impl; 41*b1cdbd2cSJim Jagielski 42*b1cdbd2cSJim Jagielski struct eqFunc 43*b1cdbd2cSJim Jagielski { operator ()eqFunc44*b1cdbd2cSJim Jagielski sal_Bool operator()( const rtl::OUString &r1, 45*b1cdbd2cSJim Jagielski const rtl::OUString &r2) const 46*b1cdbd2cSJim Jagielski { 47*b1cdbd2cSJim Jagielski return r1 == r2; 48*b1cdbd2cSJim Jagielski } 49*b1cdbd2cSJim Jagielski }; 50*b1cdbd2cSJim Jagielski typedef ::std::hash_map< ::rtl::OUString, 51*b1cdbd2cSJim Jagielski ::rtl::Reference< OHierarchyElement_Impl >, 52*b1cdbd2cSJim Jagielski ::rtl::OUStringHash, 53*b1cdbd2cSJim Jagielski eqFunc > OHierarchyElementList_Impl; 54*b1cdbd2cSJim Jagielski 55*b1cdbd2cSJim Jagielski typedef ::std::vector< ::rtl::OUString > OStringList_Impl; 56*b1cdbd2cSJim Jagielski typedef ::std::list< ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XExtendedStorageStream > > 57*b1cdbd2cSJim Jagielski OWeakStorRefList_Impl; 58*b1cdbd2cSJim Jagielski 59*b1cdbd2cSJim Jagielski struct OHierarchyElement_Impl : public cppu::WeakImplHelper1< ::com::sun::star::embed::XTransactionListener > 60*b1cdbd2cSJim Jagielski { 61*b1cdbd2cSJim Jagielski ::osl::Mutex m_aMutex; 62*b1cdbd2cSJim Jagielski 63*b1cdbd2cSJim Jagielski ::rtl::Reference< OHierarchyElement_Impl > m_rParent; 64*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > m_xOwnStorage; 65*b1cdbd2cSJim Jagielski ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage > m_xWeakOwnStorage; 66*b1cdbd2cSJim Jagielski 67*b1cdbd2cSJim Jagielski OHierarchyElementList_Impl m_aChildren; 68*b1cdbd2cSJim Jagielski 69*b1cdbd2cSJim Jagielski OWeakStorRefList_Impl m_aOpenStreams; 70*b1cdbd2cSJim Jagielski 71*b1cdbd2cSJim Jagielski public: OHierarchyElement_ImplOHierarchyElement_Impl72*b1cdbd2cSJim Jagielski OHierarchyElement_Impl( OHierarchyElement_Impl* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) 73*b1cdbd2cSJim Jagielski : m_rParent( pParent ) 74*b1cdbd2cSJim Jagielski , m_xOwnStorage( xStorage ) 75*b1cdbd2cSJim Jagielski {} 76*b1cdbd2cSJim Jagielski OHierarchyElement_ImplOHierarchyElement_Impl77*b1cdbd2cSJim Jagielski OHierarchyElement_Impl( const ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage >& xWeakStorage ) 78*b1cdbd2cSJim Jagielski : m_rParent( NULL ) 79*b1cdbd2cSJim Jagielski , m_xWeakOwnStorage( xWeakStorage ) 80*b1cdbd2cSJim Jagielski {} 81*b1cdbd2cSJim Jagielski 82*b1cdbd2cSJim Jagielski void Commit(); 83*b1cdbd2cSJim Jagielski SetParentOHierarchyElement_Impl84*b1cdbd2cSJim Jagielski void SetParent( const ::rtl::Reference< OHierarchyElement_Impl >& rParent ) { m_rParent = rParent; } 85*b1cdbd2cSJim Jagielski 86*b1cdbd2cSJim Jagielski void TestForClosing(); 87*b1cdbd2cSJim Jagielski 88*b1cdbd2cSJim Jagielski void RemoveElement( const ::rtl::Reference< OHierarchyElement_Impl >& aRef ); 89*b1cdbd2cSJim Jagielski 90*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Reference< ::com::sun::star::embed::XExtendedStorageStream > 91*b1cdbd2cSJim Jagielski GetStreamHierarchically( sal_Int32 nStorageMode, 92*b1cdbd2cSJim Jagielski OStringList_Impl& aPath, 93*b1cdbd2cSJim Jagielski sal_Int32 nStreamMode, 94*b1cdbd2cSJim Jagielski const ::comphelper::SequenceAsHashMap& aEncryptionData = ::comphelper::SequenceAsHashMap() ); 95*b1cdbd2cSJim Jagielski 96*b1cdbd2cSJim Jagielski void RemoveStreamHierarchically( OStringList_Impl& aListPath ); 97*b1cdbd2cSJim Jagielski 98*b1cdbd2cSJim Jagielski // XEventListener 99*b1cdbd2cSJim Jagielski virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) 100*b1cdbd2cSJim Jagielski throw (::com::sun::star::uno::RuntimeException); 101*b1cdbd2cSJim Jagielski 102*b1cdbd2cSJim Jagielski 103*b1cdbd2cSJim Jagielski // XTransactionListener 104*b1cdbd2cSJim Jagielski virtual void SAL_CALL preCommit( const ::com::sun::star::lang::EventObject& aEvent ) 105*b1cdbd2cSJim Jagielski throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 106*b1cdbd2cSJim Jagielski virtual void SAL_CALL commited( const ::com::sun::star::lang::EventObject& aEvent ) 107*b1cdbd2cSJim Jagielski throw (::com::sun::star::uno::RuntimeException); 108*b1cdbd2cSJim Jagielski virtual void SAL_CALL preRevert( const ::com::sun::star::lang::EventObject& aEvent ) 109*b1cdbd2cSJim Jagielski throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 110*b1cdbd2cSJim Jagielski virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& aEvent ) 111*b1cdbd2cSJim Jagielski throw (::com::sun::star::uno::RuntimeException); 112*b1cdbd2cSJim Jagielski 113*b1cdbd2cSJim Jagielski }; 114*b1cdbd2cSJim Jagielski 115*b1cdbd2cSJim Jagielski class OHierarchyHolder_Impl : public ::cppu::OWeakObject 116*b1cdbd2cSJim Jagielski { 117*b1cdbd2cSJim Jagielski ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage > m_xWeakOwnStorage; 118*b1cdbd2cSJim Jagielski ::rtl::Reference< OHierarchyElement_Impl > m_xChild; 119*b1cdbd2cSJim Jagielski public: OHierarchyHolder_Impl(const::com::sun::star::uno::Reference<::com::sun::star::embed::XStorage> & xOwnStorage)120*b1cdbd2cSJim Jagielski OHierarchyHolder_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xOwnStorage ) 121*b1cdbd2cSJim Jagielski : m_xWeakOwnStorage( xOwnStorage ) 122*b1cdbd2cSJim Jagielski , m_xChild( new OHierarchyElement_Impl( ::com::sun::star::uno::WeakReference< ::com::sun::star::embed::XStorage >( xOwnStorage ) ) ) 123*b1cdbd2cSJim Jagielski {} 124*b1cdbd2cSJim Jagielski 125*b1cdbd2cSJim Jagielski static OStringList_Impl GetListPathFromString( const ::rtl::OUString& aPath ); 126*b1cdbd2cSJim Jagielski 127*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Reference< ::com::sun::star::embed::XExtendedStorageStream > 128*b1cdbd2cSJim Jagielski GetStreamHierarchically( sal_Int32 nStorageMode, 129*b1cdbd2cSJim Jagielski OStringList_Impl& aListPath, 130*b1cdbd2cSJim Jagielski sal_Int32 nStreamMode, 131*b1cdbd2cSJim Jagielski const ::comphelper::SequenceAsHashMap& aEncryptionData = ::comphelper::SequenceAsHashMap() ); 132*b1cdbd2cSJim Jagielski 133*b1cdbd2cSJim Jagielski void RemoveStreamHierarchically( OStringList_Impl& aListPath ); 134*b1cdbd2cSJim Jagielski }; 135*b1cdbd2cSJim Jagielski 136*b1cdbd2cSJim Jagielski #endif // _OHIERARCHYHOLDER 137*b1cdbd2cSJim Jagielski 138