android: Update app-specific/MIME type icons
[LibreOffice.git] / include / dbaccess / dbsubcomponentcontroller.hxx
bloba1bc687ce5120415cd10746a00da94f90dae0689
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
23 #include <memory>
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 beans { struct PropertyValue; }
41 namespace document { class XEmbeddedScripts; }
42 namespace frame { class XModel; }
43 namespace sdbc { class XConnection; }
44 namespace sdbc { class XDatabaseMetaData; }
45 namespace uno { class XComponentContext; }
46 namespace util { class XModifyListener; }
47 namespace util { class XNumberFormatter; }
50 namespace dbtools {
51 class DatabaseMetaData;
52 class SQLExceptionInfo;
55 namespace dbaui
57 //= DBSubComponentController
59 typedef ::cppu::ImplInheritanceHelper< OGenericUnoController
60 , css::document::XScriptInvocationContext
61 , css::util::XModifiable
62 > DBSubComponentController_Base;
64 struct DBSubComponentController_Impl;
65 class DBACCESS_DLLPUBLIC DBSubComponentController : public DBSubComponentController_Base
67 private:
68 ::std::unique_ptr<DBSubComponentController_Impl> m_pImpl;
70 private:
71 /** forces usage of a connection which we do not own
72 <p>To be used from within XInitialization::initialize, resp. impl_initialize, only.</p>
74 void initializeConnection( const css::uno::Reference< css::sdbc::XConnection >& _rxForeignConn );
76 protected:
77 // OGenericUnoController - initialization
78 virtual void impl_initialize() override;
80 // OGenericUnoController
81 virtual void Execute(sal_uInt16 nId, const css::uno::Sequence< css::beans::PropertyValue>& aArgs) override;
83 virtual css::uno::Reference< css::frame::XModel > getPrivateModel() const override;
85 bool impl_isModified() const;
86 virtual void impl_onModifyChanged();
88 public:
89 bool isReadOnly() const;
90 bool isEditable() const;
91 void setEditable(bool _bEditable);
94 // asking for connection-related stuff
96 bool isConnected() const;
98 css::uno::Reference< css::sdbc::XDatabaseMetaData >
99 getMetaData( ) const;
102 // access to the data source / document
103 OUString getDataSourceName() const;
104 const css::uno::Reference< css::beans::XPropertySet >&
105 getDataSource() const;
106 bool haveDataSource() const;
108 css::uno::Reference< css::frame::XModel >
109 getDatabaseDocument() const;
111 /** provides access to the SDB-level database meta data of the current connection
113 const ::dbtools::DatabaseMetaData& getSdbMetaData() const;
115 /** appends an error in the current environment.
117 void appendError( const OUString& _rErrorMessage );
119 /** clears the error state.
121 void clearError();
123 /** @return
124 <TRUE/> when an error was set otherwise <FALSE/>
126 bool hasError() const;
128 /** returns the current error
130 const ::dbtools::SQLExceptionInfo& getError() const;
132 /** displays the current error, or does nothing if there is no current error
134 void displayError();
136 /** shows an info box with the string conntection lost.
138 void connectionLostMessage() const;
140 /** gives access to the currently used connection
141 @return
142 the currently used connection.
144 const css::uno::Reference< css::sdbc::XConnection >&
145 getConnection() const;
147 /** returns the number formatter
149 css::uno::Reference< css::util::XNumberFormatter > const & getNumberFormatter() const;
151 // css::frame::XController
152 virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) override;
153 virtual sal_Bool SAL_CALL attachModel(const css::uno::Reference< css::frame::XModel > & xModel) override;
155 // XScriptInvocationContext
156 virtual css::uno::Reference< css::document::XEmbeddedScripts > SAL_CALL getScriptContainer() override;
158 // XModifiable
159 virtual sal_Bool SAL_CALL isModified( ) override;
160 virtual void SAL_CALL setModified( sal_Bool bModified ) override;
162 // XModifyBroadcaster
163 virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
164 virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
166 // XTitle
167 virtual OUString SAL_CALL getTitle( ) override;
169 protected:
170 DBSubComponentController(const css::uno::Reference< css::uno::XComponentContext>& _rxORB);
171 virtual ~DBSubComponentController() override;
173 void disconnect();
174 virtual void reconnect( bool _bUI );
175 bool ensureConnected() {
176 if ( !isConnected() ) reconnect( false );
177 return isConnected();
180 /** called when our connection is being disposed
181 <p>The default implementation does a reconnect</p>
183 virtual void losingConnection( );
185 protected:
186 // XEventListener
187 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
189 // OComponentHelper
190 virtual void SAL_CALL disposing() override;
192 // XInterface
193 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
195 // XTypeProvider
196 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
198 protected:
199 sal_Int32 getCurrentStartNumber() const;
203 } // namespace dbaui
206 #endif // INCLUDED_DBACCESS_DBSUBCOMPONENTCONTROLLER_HXX
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */