1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: singledoccontroller.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef DBAUI_SINGLEDOCCONTROLLER_HXX
32 #define DBAUI_SINGLEDOCCONTROLLER_HXX
34 #include "documentcontroller.hxx"
35 #include "genericcontroller.hxx"
36 #include "IEnvironment.hxx"
38 /** === begin UNO includes === **/
39 #include <com/sun/star/document/XScriptInvocationContext.hpp>
40 #include <com/sun/star/sdbc/XConnection.hpp>
41 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
42 #include <com/sun/star/sdbc/XDataSource.hpp>
43 #include <com/sun/star/util/XNumberFormatter.hpp>
44 /** === end UNO includes === **/
46 #include <comphelper/broadcasthelper.hxx>
47 #include <comphelper/proparrhlp.hxx>
48 #include <comphelper/propertycontainer.hxx>
49 #include <connectivity/dbmetadata.hxx>
50 #include <cppuhelper/implbase1.hxx>
51 #include <svtools/undo.hxx>
55 //........................................................................
58 //........................................................................
60 //====================================================================
61 //= OSingleDocumentController
62 //====================================================================
63 class OSingleDocumentController
;
65 typedef ::cppu::ImplInheritanceHelper1
< OGenericUnoController
66 , ::com::sun::star::document::XScriptInvocationContext
67 > OSingleDocumentController_Base
;
69 struct OSingleDocumentControllerImpl
;
70 class DBACCESS_DLLPUBLIC OSingleDocumentController
71 :public OSingleDocumentController_Base
75 ::std::auto_ptr
<OSingleDocumentControllerImpl
> m_pImpl
;
78 SfxUndoManager m_aUndoManager
;
81 /** forces usage of a connection which we do not own
82 <p>To be used from within XInitialization::initialize, resp. impl_initialize, only.</p>
84 void initializeConnection( const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxForeignConn
);
87 // OGenericUnoController - initialization
88 virtual void impl_initialize();
90 // state of a feature. 'feature' may be the handle of a ::com::sun::star::util::URL somebody requested a dispatch interface for OR a toolbar slot.
91 virtual FeatureState
GetState(sal_uInt16 nId
) const;
93 virtual void Execute(sal_uInt16 nId
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArgs
);
95 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> getPrivateModel() const;
99 sal_Bool
isReadOnly() const;
100 sal_Bool
isEditable() const;
101 void setEditable(sal_Bool _bEditable
);
102 sal_Bool
isModified() const;
104 virtual void setModified(sal_Bool _bModified
=sal_True
);
107 // need for undo's and redo's
108 SfxUndoManager
* getUndoMgr();
110 /** addUndoActionAndInvalidate adds an undo action to the undoManager,
111 additionally invalidates the UNDO and REDO slot
112 @param pAction the undo action to add
114 void addUndoActionAndInvalidate(SfxUndoAction
*pAction
);
115 // ----------------------------------------------------------------
116 // asking for connection-related stuff
118 sal_Bool
isConnected() const;
120 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
>
121 getMetaData( ) const;
123 // ----------------------------------------------------------------
124 // access to the data source / document
125 ::rtl::OUString
getDataSourceName() const;
126 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>&
127 getDataSource() const;
128 sal_Bool
haveDataSource() const;
130 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>
131 getDatabaseDocument() const;
133 /** provides access to the SDB-level database meta data of the current connection
135 const ::dbtools::DatabaseMetaData
& getSdbMetaData() const;
138 /** appends an error in the current environment.
140 virtual void appendError(
141 const ::rtl::OUString
& _rErrorMessage
,
142 const ::dbtools::StandardSQLState _eSQLState
= ::dbtools::SQL_GENERAL_ERROR
,
143 const sal_Int32 _nErrorCode
= 1000
146 /** clears the error state.
148 virtual void clearError();
151 <TRUE/> when an error was set otherwise <FALSE/>
153 virtual sal_Bool
hasError() const;
155 /** returns the current error
157 virtual const ::dbtools::SQLExceptionInfo
& getError() const;
159 /** displays the current error, or does nothing if there is no current error
161 virtual void displayError();
163 /** shows an info box with the string conntection lost.
165 void connectionLostMessage() const;
167 /** gives access to the currently used connection
169 the currently used connection.
171 virtual const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>&
172 getConnection() const;
174 /** returns the number formatter
176 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatter
> getNumberFormatter() const;
178 // ::com::sun::star::frame::XController
179 virtual sal_Bool SAL_CALL
suspend(sal_Bool bSuspend
) throw( ::com::sun::star::uno::RuntimeException
);
180 virtual sal_Bool SAL_CALL
attachModel(const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> & xModel
) throw( ::com::sun::star::uno::RuntimeException
);
182 // XScriptInvocationContext
183 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::document::XEmbeddedScripts
> SAL_CALL
getScriptContainer() throw (::com::sun::star::uno::RuntimeException
);
186 virtual ::rtl::OUString SAL_CALL
getTitle( ) throw (::com::sun::star::uno::RuntimeException
);
189 OSingleDocumentController(const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& _rxORB
);
190 virtual ~OSingleDocumentController();
192 virtual void disconnect();
193 virtual void reconnect( sal_Bool _bUI
);
194 sal_Bool
ensureConnected( sal_Bool _bUI
) { if ( !isConnected() ) reconnect( _bUI
); return isConnected(); }
196 /** called when our connection is beeing disposed
197 <p>The default implementation does a reconnect</p>
199 virtual void losingConnection( );
202 virtual sal_Bool
Construct(Window
* pParent
);
206 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& Source
) throw( ::com::sun::star::uno::RuntimeException
);
209 virtual void SAL_CALL
disposing();
212 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface(const ::com::sun::star::uno::Type
& _rType
) throw (::com::sun::star::uno::RuntimeException
);
215 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw (::com::sun::star::uno::RuntimeException
);
218 sal_Int32
getCurrentStartNumber() const;
221 OSingleDocumentController(); // never implemented
224 //........................................................................
226 //........................................................................
228 #endif // DBAUI_SINGLEDOCCONTROLLER_HXX