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 54 // XServiceInfo 55 DECLARE_SERVICE_INFO(); 56 57 // OComponentHelper 58 virtual void SAL_CALL disposing(void); 59 60 // XConnection 61 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ); 62 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog(); 63 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ); 64 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ); 65 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ); 66 67 // no interface methods 68 ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> acquireDoc(); 69 void releaseDoc(); 70 71 class ODocHolder 72 { 73 OCalcConnection* m_pConnection; 74 ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> m_xDoc; 75 public: 76 ODocHolder(OCalcConnection* _pConnection) : m_pConnection(_pConnection) 77 { 78 m_xDoc = m_pConnection->acquireDoc(); 79 } 80 ~ODocHolder() 81 { 82 m_xDoc.clear(); 83 m_pConnection->releaseDoc(); 84 } 85 ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> getDoc() const { return m_xDoc; } 86 }; 87 }; 88 } 89 } 90 91 #endif // _CONNECTIVITY_CALC_CONNECTION_HXX_ 92