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 24 #ifndef _CONNECTIVITY_CALC_CONNECTION_HXX_ 25 #define _CONNECTIVITY_CALC_CONNECTION_HXX_ 26 27 #include "file/FConnection.hxx" 28 29 namespace com { namespace sun { namespace star { namespace sheet { 30 class XSpreadsheetDocument; 31 } } } } 32 33 34 namespace connectivity 35 { 36 namespace calc 37 { 38 class ODriver; 39 class OCalcConnection : public file::OConnection 40 { 41 // the spreadsheet document: 42 ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > m_xDoc; 43 ::rtl::OUString m_sPassword; 44 String m_aFileName; 45 oslInterlockedCount m_nDocCount; 46 47 public: 48 OCalcConnection(ODriver* _pDriver); 49 virtual ~OCalcConnection(); 50 51 virtual void construct(const ::rtl::OUString& _rUrl, 52 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo ) 53 throw( ::com::sun::star::sdbc::SQLException); 54 55 // XServiceInfo 56 DECLARE_SERVICE_INFO(); 57 58 // OComponentHelper 59 virtual void SAL_CALL disposing(void); 60 61 // XConnection 62 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 63 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog(); 64 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 65 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 66 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 67 68 // no interface methods 69 ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> acquireDoc(); 70 void releaseDoc(); 71 72 class ODocHolder 73 { 74 OCalcConnection* m_pConnection; 75 ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> m_xDoc; 76 public: ODocHolder(OCalcConnection * _pConnection)77 ODocHolder(OCalcConnection* _pConnection) : m_pConnection(_pConnection) 78 { 79 m_xDoc = m_pConnection->acquireDoc(); 80 } ~ODocHolder()81 ~ODocHolder() 82 { 83 m_xDoc.clear(); 84 m_pConnection->releaseDoc(); 85 } getDoc() const86 ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> getDoc() const { return m_xDoc; } 87 }; 88 }; 89 } 90 } 91 92 #endif // _CONNECTIVITY_CALC_CONNECTION_HXX_ 93 94