1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DBACCESS_DBSUBCOMPONENTCONTROLLER_HXX
21 #define INCLUDED_DBACCESS_DBSUBCOMPONENTCONTROLLER_HXX
25 #include <com/sun/star/document/XScriptInvocationContext.hpp>
26 #include <com/sun/star/lang/EventObject.hpp>
27 #include <com/sun/star/uno/Any.hxx>
28 #include <com/sun/star/uno/Reference.hxx>
29 #include <com/sun/star/uno/Sequence.hxx>
30 #include <com/sun/star/uno/Type.hxx>
31 #include <com/sun/star/util/XModifiable.hpp>
32 #include <cppuhelper/implbase.hxx>
33 #include <dbaccess/dbaccessdllapi.h>
34 #include <dbaccess/genericcontroller.hxx>
35 #include <rtl/ustring.hxx>
36 #include <sal/types.h>
38 namespace com::sun::star
{
39 namespace beans
{ class XPropertySet
; }
40 namespace frame
{ class XModel
; }
41 namespace sdbc
{ class XConnection
; }
42 namespace sdbc
{ class XDatabaseMetaData
; }
43 namespace uno
{ class XComponentContext
; }
44 namespace util
{ class XNumberFormatter
; }
48 class DatabaseMetaData
;
49 class SQLExceptionInfo
;
54 //= DBSubComponentController
56 typedef ::cppu::ImplInheritanceHelper
< OGenericUnoController
57 , css::document::XScriptInvocationContext
58 , css::util::XModifiable
59 > DBSubComponentController_Base
;
61 struct DBSubComponentController_Impl
;
62 class UNLESS_MERGELIBS_MORE(DBACCESS_DLLPUBLIC
) DBSubComponentController
: public DBSubComponentController_Base
65 ::std::unique_ptr
<DBSubComponentController_Impl
> m_pImpl
;
68 /** forces usage of a connection which we do not own
69 <p>To be used from within XInitialization::initialize, resp. impl_initialize, only.</p>
71 void initializeConnection( const css::uno::Reference
< css::sdbc::XConnection
>& _rxForeignConn
);
74 // OGenericUnoController - initialization
75 virtual void impl_initialize(const ::comphelper::NamedValueCollection
& rArguments
) override
;
77 // OGenericUnoController
78 virtual void Execute(sal_uInt16 nId
, const css::uno::Sequence
< css::beans::PropertyValue
>& aArgs
) override
;
80 virtual css::uno::Reference
< css::frame::XModel
> getPrivateModel() const override
;
82 bool impl_isModified() const;
83 virtual void impl_onModifyChanged();
86 bool isReadOnly() const;
87 bool isEditable() const;
88 void setEditable(bool _bEditable
);
91 // asking for connection-related stuff
93 bool isConnected() const;
95 css::uno::Reference
< css::sdbc::XDatabaseMetaData
>
99 // access to the data source / document
100 OUString
getDataSourceName() const;
101 const css::uno::Reference
< css::beans::XPropertySet
>&
102 getDataSource() const;
103 bool haveDataSource() const;
105 css::uno::Reference
< css::frame::XModel
>
106 getDatabaseDocument() const;
108 /** provides access to the SDB-level database meta data of the current connection
110 const ::dbtools::DatabaseMetaData
& getSdbMetaData() const;
112 /** appends an error in the current environment.
114 void appendError( const OUString
& _rErrorMessage
);
116 /** clears the error state.
121 <TRUE/> when an error was set otherwise <FALSE/>
123 bool hasError() const;
125 /** returns the current error
127 const ::dbtools::SQLExceptionInfo
& getError() const;
129 /** displays the current error, or does nothing if there is no current error
133 /** shows an info box with the string connection lost.
135 void connectionLostMessage() const;
137 /** gives access to the currently used connection
139 the currently used connection.
141 const css::uno::Reference
< css::sdbc::XConnection
>&
142 getConnection() const;
144 /** returns the number formatter
146 css::uno::Reference
< css::util::XNumberFormatter
> const & getNumberFormatter() const;
148 // css::frame::XController
149 virtual sal_Bool SAL_CALL
suspend(sal_Bool bSuspend
) override
;
150 virtual sal_Bool SAL_CALL
attachModel(const css::uno::Reference
< css::frame::XModel
> & xModel
) override
;
152 // XScriptInvocationContext
153 virtual css::uno::Reference
< css::document::XEmbeddedScripts
> SAL_CALL
getScriptContainer() override
;
156 virtual sal_Bool SAL_CALL
isModified( ) override
;
157 virtual void SAL_CALL
setModified( sal_Bool bModified
) override
;
159 // XModifyBroadcaster
160 virtual void SAL_CALL
addModifyListener( const css::uno::Reference
< css::util::XModifyListener
>& aListener
) override
;
161 virtual void SAL_CALL
removeModifyListener( const css::uno::Reference
< css::util::XModifyListener
>& aListener
) override
;
164 virtual OUString SAL_CALL
getTitle( ) override
;
167 DBSubComponentController(const css::uno::Reference
< css::uno::XComponentContext
>& _rxORB
);
168 virtual ~DBSubComponentController() override
;
171 virtual void reconnect( bool _bUI
);
172 bool ensureConnected() {
173 if ( !isConnected() ) reconnect( false );
174 return isConnected();
177 /** called when our connection is being disposed
178 <p>The default implementation does a reconnect</p>
180 virtual void losingConnection( );
184 virtual void SAL_CALL
disposing(const css::lang::EventObject
& Source
) override
;
187 virtual void SAL_CALL
disposing() override
;
190 virtual css::uno::Any SAL_CALL
queryInterface(const css::uno::Type
& _rType
) override
;
193 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
196 sal_Int32
getCurrentStartNumber() const;
203 #endif // INCLUDED_DBACCESS_DBSUBCOMPONENTCONTROLLER_HXX
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */