1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef CONNECTIVI_HSQLDB_HSTORAGEMAP_HXX 28 #define CONNECTIVI_HSQLDB_HSTORAGEMAP_HXX 29 30 #include <com/sun/star/embed/XStorage.hpp> 31 #include <com/sun/star/embed/XTransactionListener.hpp> 32 #include <com/sun/star/io/XStream.hpp> 33 #include <com/sun/star/io/XOutputStream.hpp> 34 #include <com/sun/star/io/XInputStream.hpp> 35 #include <com/sun/star/io/XSeekable.hpp> 36 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED 37 #include <boost/shared_ptr.hpp> 38 #endif 39 #include <comphelper/stl_types.hxx> 40 #include <jni.h> 41 //........................................................................ 42 namespace connectivity 43 { 44 //........................................................................ 45 namespace hsqldb 46 { 47 class StreamHelper 48 { 49 ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream> m_xStream; 50 ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable> m_xSeek; 51 ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream> m_xOutputStream; 52 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> m_xInputStream; 53 public: 54 StreamHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream>& _xStream); 55 ~StreamHelper(); 56 57 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> getInputStream(); 58 ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream> getOutputStream(); 59 ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable> getSeek(); 60 }; 61 62 63 DECLARE_STL_USTRINGACCESS_MAP(::boost::shared_ptr<StreamHelper>,TStreamMap); 64 typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >, ::rtl::OUString > TStorageURLPair; 65 typedef ::std::pair< TStorageURLPair, TStreamMap> TStoragePair; 66 DECLARE_STL_USTRINGACCESS_MAP(TStoragePair,TStorages); 67 /** contains all storages so far accessed. 68 */ 69 class StorageContainer 70 { 71 public: 72 static ::rtl::OUString registerStorage(const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage>& _xStorage,const ::rtl::OUString& _sURL); 73 static TStorages::mapped_type getRegisteredStorage(const ::rtl::OUString& _sKey); 74 static ::rtl::OUString getRegisteredKey(const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage>& _xStorage); 75 static void revokeStorage(const ::rtl::OUString& _sKey,const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XTransactionListener>& _xListener); 76 77 static TStreamMap::mapped_type registerStream(JNIEnv * env,jstring name, jstring key,sal_Int32 _nMode); 78 static void revokeStream(JNIEnv * env,jstring name, jstring key); 79 static TStreamMap::mapped_type getRegisteredStream( JNIEnv * env, jstring name, jstring key); 80 81 static ::rtl::OUString jstring2ustring(JNIEnv * env, jstring jstr); 82 static ::rtl::OUString removeURLPrefix(const ::rtl::OUString& _sURL,const ::rtl::OUString& _sFileURL); 83 static ::rtl::OUString removeOldURLPrefix(const ::rtl::OUString& _sURL); 84 static void throwJavaException(const ::com::sun::star::uno::Exception& _aException,JNIEnv * env); 85 }; 86 //........................................................................ 87 } // namespace hsqldb 88 //........................................................................ 89 //........................................................................ 90 } // namespace connectivity 91 92 //........................................................................ 93 #endif // CONNECTIVI_HSQLDB_HSTORAGEMAP_HXX 94 95