Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _CONNECTIVITY_CALC_CONNECTION_HXX_
21 : #define _CONNECTIVITY_CALC_CONNECTION_HXX_
22 :
23 : #include "file/FConnection.hxx"
24 :
25 : namespace com { namespace sun { namespace star { namespace sheet {
26 : class XSpreadsheetDocument;
27 : } } } }
28 :
29 :
30 : namespace connectivity
31 : {
32 : namespace calc
33 : {
34 : class ODriver;
35 : class OCalcConnection : public file::OConnection
36 : {
37 : // the spreadsheet document:
38 : ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > m_xDoc;
39 : ::rtl::OUString m_sPassword;
40 : String m_aFileName;
41 : oslInterlockedCount m_nDocCount;
42 :
43 : public:
44 : OCalcConnection(ODriver* _pDriver);
45 : virtual ~OCalcConnection();
46 :
47 : virtual void construct(const ::rtl::OUString& _rUrl,
48 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo )
49 : throw( ::com::sun::star::sdbc::SQLException);
50 :
51 : // XServiceInfo
52 : DECLARE_SERVICE_INFO();
53 :
54 : // OComponentHelper
55 : virtual void SAL_CALL disposing(void);
56 :
57 : // XConnection
58 : 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);
59 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog();
60 : 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);
61 : 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);
62 : 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);
63 :
64 : // no interface methods
65 : ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> acquireDoc();
66 : void releaseDoc();
67 :
68 : class ODocHolder
69 : {
70 : OCalcConnection* m_pConnection;
71 : ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> m_xDoc;
72 : public:
73 0 : ODocHolder(OCalcConnection* _pConnection) : m_pConnection(_pConnection)
74 : {
75 0 : m_xDoc = m_pConnection->acquireDoc();
76 0 : }
77 0 : ~ODocHolder()
78 0 : {
79 0 : m_xDoc.clear();
80 0 : m_pConnection->releaseDoc();
81 0 : }
82 0 : ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> getDoc() const { return m_xDoc; }
83 : };
84 : };
85 : }
86 : }
87 :
88 : #endif // _CONNECTIVITY_CALC_CONNECTION_HXX_
89 :
90 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|