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 INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CCONNECTION_HXX
21 : #define INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CCONNECTION_HXX
22 :
23 : #include "file/FConnection.hxx"
24 : #include <com/sun/star/uno/DeploymentException.hpp>
25 :
26 : namespace com { namespace sun { namespace star {
27 : namespace sheet { class XSpreadsheetDocument; }
28 : } } }
29 :
30 : namespace utl { class CloseVeto; }
31 :
32 :
33 : namespace connectivity
34 : {
35 : namespace calc
36 : {
37 : class ODriver;
38 : class OCalcConnection : public file::OConnection
39 : {
40 : // the spreadsheet document:
41 : ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > m_xDoc;
42 : /// close listener that vetoes so nobody disposes m_xDoc
43 : ::std::unique_ptr< ::utl::CloseVeto> m_pCloseListener;
44 : OUString m_sPassword;
45 : OUString m_aFileName;
46 : oslInterlockedCount m_nDocCount;
47 :
48 : public:
49 : OCalcConnection(ODriver* _pDriver);
50 : virtual ~OCalcConnection();
51 :
52 : virtual void construct(const OUString& _rUrl,
53 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo )
54 : throw( css::sdbc::SQLException,
55 : css::uno::RuntimeException,
56 : css::uno::DeploymentException) SAL_OVERRIDE;
57 :
58 : // XServiceInfo
59 : DECLARE_SERVICE_INFO();
60 :
61 : // OComponentHelper
62 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
63 :
64 : // XConnection
65 : 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, std::exception) SAL_OVERRIDE;
66 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog() SAL_OVERRIDE;
67 : 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, std::exception) SAL_OVERRIDE;
68 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
69 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
70 :
71 : // no interface methods
72 : ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> acquireDoc();
73 : void releaseDoc();
74 :
75 : class ODocHolder
76 : {
77 : OCalcConnection* m_pConnection;
78 : ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> m_xDoc;
79 : public:
80 27 : ODocHolder(OCalcConnection* _pConnection) : m_pConnection(_pConnection)
81 : {
82 27 : m_xDoc = m_pConnection->acquireDoc();
83 27 : }
84 27 : ~ODocHolder()
85 27 : {
86 27 : m_xDoc.clear();
87 27 : m_pConnection->releaseDoc();
88 27 : }
89 9 : ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument> getDoc() const { return m_xDoc; }
90 : };
91 : };
92 : }
93 : }
94 :
95 : #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CCONNECTION_HXX
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|