1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef CONNECTIVI_HSQLDB_HSTORAGEMAP_HXX 24 #define CONNECTIVI_HSQLDB_HSTORAGEMAP_HXX 25 26 #include <com/sun/star/embed/XStorage.hpp> 27 #include <com/sun/star/embed/XTransactionListener.hpp> 28 #include <com/sun/star/io/XStream.hpp> 29 #include <com/sun/star/io/XOutputStream.hpp> 30 #include <com/sun/star/io/XInputStream.hpp> 31 #include <com/sun/star/io/XSeekable.hpp> 32 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED 33 #include <boost/shared_ptr.hpp> 34 #endif 35 #include <comphelper/stl_types.hxx> 36 #include <jni.h> 37 //........................................................................ 38 namespace connectivity 39 { 40 //........................................................................ 41 namespace hsqldb 42 { 43 class StreamHelper 44 { 45 ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream> m_xStream; 46 ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable> m_xSeek; 47 ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream> m_xOutputStream; 48 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> m_xInputStream; 49 public: 50 StreamHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream>& _xStream); 51 ~StreamHelper(); 52 53 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> getInputStream(); 54 ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream> getOutputStream(); 55 ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable> getSeek(); 56 }; 57 58 59 DECLARE_STL_USTRINGACCESS_MAP(::boost::shared_ptr<StreamHelper>,TStreamMap); 60 typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >, ::rtl::OUString > TStorageURLPair; 61 typedef ::std::pair< TStorageURLPair, TStreamMap> TStoragePair; 62 DECLARE_STL_USTRINGACCESS_MAP(TStoragePair,TStorages); 63 /** contains all storages so far accessed. 64 */ 65 class StorageContainer 66 { 67 public: 68 static ::rtl::OUString registerStorage(const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage>& _xStorage,const ::rtl::OUString& _sURL); 69 static TStorages::mapped_type getRegisteredStorage(const ::rtl::OUString& _sKey); 70 static ::rtl::OUString getRegisteredKey(const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage>& _xStorage); 71 static void revokeStorage(const ::rtl::OUString& _sKey,const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XTransactionListener>& _xListener); 72 73 static TStreamMap::mapped_type registerStream(JNIEnv * env,jstring name, jstring key,sal_Int32 _nMode); 74 static void revokeStream(JNIEnv * env,jstring name, jstring key); 75 static TStreamMap::mapped_type getRegisteredStream( JNIEnv * env, jstring name, jstring key); 76 77 static ::rtl::OUString jstring2ustring(JNIEnv * env, jstring jstr); 78 static ::rtl::OUString removeURLPrefix(const ::rtl::OUString& _sURL,const ::rtl::OUString& _sFileURL); 79 static ::rtl::OUString removeOldURLPrefix(const ::rtl::OUString& _sURL); 80 static void throwJavaException(const ::com::sun::star::uno::Exception& _aException,JNIEnv * env); 81 }; 82 //........................................................................ 83 } // namespace hsqldb 84 //........................................................................ 85 //........................................................................ 86 } // namespace connectivity 87 88 //........................................................................ 89 #endif // CONNECTIVI_HSQLDB_HSTORAGEMAP_HXX 90 91