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