xref: /AOO41X/main/dbaccess/source/ui/inc/JoinController.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef DBAUI_JOINCONTROLLER_HXX
28*cdf0e10cSrcweir #define DBAUI_JOINCONTROLLER_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "singledoccontroller.hxx"
31*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
32*cdf0e10cSrcweir #include "moduledbu.hxx"
33*cdf0e10cSrcweir #include "JoinTableView.hxx"
34*cdf0e10cSrcweir #include "JoinDesignView.hxx"
35*cdf0e10cSrcweir #include "TableConnectionData.hxx"
36*cdf0e10cSrcweir #include "TableWindowData.hxx"
37*cdf0e10cSrcweir #include <memory>
38*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir namespace comphelper
41*cdf0e10cSrcweir {
42*cdf0e10cSrcweir     class NamedValueCollection;
43*cdf0e10cSrcweir }
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir class VCLXWindow;
46*cdf0e10cSrcweir namespace dbaui
47*cdf0e10cSrcweir {
48*cdf0e10cSrcweir 	class OAddTableDlg;
49*cdf0e10cSrcweir     class AddTableDialogContext;
50*cdf0e10cSrcweir 	class OTableConnectionData;
51*cdf0e10cSrcweir 	class OTableWindowData;
52*cdf0e10cSrcweir 	class OTableWindow;
53*cdf0e10cSrcweir 	typedef OSingleDocumentController OJoinController_BASE;
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir     class OJoinController : public OJoinController_BASE
56*cdf0e10cSrcweir 	{
57*cdf0e10cSrcweir         OModuleClient                    m_aModuleClient;
58*cdf0e10cSrcweir 	protected:
59*cdf0e10cSrcweir         TTableConnectionData m_vTableConnectionData;
60*cdf0e10cSrcweir 		TTableWindowData     m_vTableData;
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir 		Fraction								m_aZoom;
63*cdf0e10cSrcweir 		::dbtools::SQLExceptionInfo				m_aExceptionInfo;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir 		OAddTableDlg*	                            m_pAddTableDialog;
66*cdf0e10cSrcweir         ::std::auto_ptr< AddTableDialogContext >    m_pDialogContext;
67*cdf0e10cSrcweir         Point                                   m_aMinimumTableViewSize;
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 		// 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.
70*cdf0e10cSrcweir 		virtual FeatureState	GetState(sal_uInt16 nId) const;
71*cdf0e10cSrcweir 		// execute a feature
72*cdf0e10cSrcweir 		virtual void			Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 		/** loads the information for the windows.
75*cdf0e10cSrcweir 			@param	i_rViewSettings
76*cdf0e10cSrcweir 				The properties which comes from the layout information.
77*cdf0e10cSrcweir 		*/
78*cdf0e10cSrcweir         void loadTableWindows( const ::comphelper::NamedValueCollection& i_rViewSettings );
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 		/** loads the information for one window.
81*cdf0e10cSrcweir 			@param	_rTable
82*cdf0e10cSrcweir 				The properties which comes from the layout information.
83*cdf0e10cSrcweir 		*/
84*cdf0e10cSrcweir 		void loadTableWindow( const ::comphelper::NamedValueCollection& i_rTableWindowSettings );
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 		/** saves the TableWindows structure in a sequence of property values
87*cdf0e10cSrcweir 			@param	_rViewProps
88*cdf0e10cSrcweir 				Contains the new sequence.
89*cdf0e10cSrcweir 		*/
90*cdf0e10cSrcweir         void saveTableWindows( ::comphelper::NamedValueCollection& o_rViewSettings ) const;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 		virtual ~OJoinController();
93*cdf0e10cSrcweir 	public:
94*cdf0e10cSrcweir 		OJoinController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir         // ---------------------------------------------------------------
97*cdf0e10cSrcweir         // attribute access
98*cdf0e10cSrcweir 		inline TTableWindowData*		getTableWindowData()     { return &m_vTableData; }
99*cdf0e10cSrcweir 		inline TTableConnectionData*	getTableConnectionData() { return &m_vTableConnectionData;}
100*cdf0e10cSrcweir         inline OAddTableDlg*            getAddTableDialog()const { return m_pAddTableDialog; }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir         // ---------------------------------------------------------------
103*cdf0e10cSrcweir         // OSingleDocumentController overridables
104*cdf0e10cSrcweir 		virtual void        reconnect( sal_Bool _bUI );
105*cdf0e10cSrcweir 		virtual void        impl_onModifyChanged();
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir         // ---------------------------------------------------------------
108*cdf0e10cSrcweir         // own overridables
109*cdf0e10cSrcweir         /** determines whether or not it's allowed for database views to participate in the game
110*cdf0e10cSrcweir         */
111*cdf0e10cSrcweir         virtual bool allowViews() const = 0;
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir         /** determines whether or not it's allowed for queries to participate in the game
114*cdf0e10cSrcweir         */
115*cdf0e10cSrcweir         virtual bool allowQueries() const = 0;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir         /** provides access to the OJoinDesignView belonging to the controller, which might
118*cdf0e10cSrcweir             or might not be the direct view (getView)
119*cdf0e10cSrcweir         */
120*cdf0e10cSrcweir 		virtual OJoinDesignView*	getJoinView();
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir         // ---------------------------------------------------------------
124*cdf0e10cSrcweir         /** erase the data in the data vector
125*cdf0e10cSrcweir 			@param	_pData
126*cdf0e10cSrcweir 					the data whioch should be erased
127*cdf0e10cSrcweir 		*/
128*cdf0e10cSrcweir 		void    removeConnectionData(const TTableConnectionData::value_type& _pData);
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 		void    SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabWinList, long nOffsetX, long nOffsetY );
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir         void	SaveTabWinPosSize(OTableWindow* pTabWin, long nOffsetX, long nOffsetY);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir         // ---------------------------------------------------------------
135*cdf0e10cSrcweir         // UNO interface overridables
136*cdf0e10cSrcweir 		// XEventListener
137*cdf0e10cSrcweir 		virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 		// ::com::sun::star::lang::XComponent
140*cdf0e10cSrcweir 		virtual void	SAL_CALL disposing();
141*cdf0e10cSrcweir 		// ::com::sun::star::frame::XController
142*cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) throw( ::com::sun::star::uno::RuntimeException );
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir         // ---------------------------------------------------------------
146*cdf0e10cSrcweir         // misc
147*cdf0e10cSrcweir 		/** only defines a method to save a SQLException in d&d methods to show the error at a later state
148*cdf0e10cSrcweir 			set the internal member m_aExceptionInfo to _rInfo
149*cdf0e10cSrcweir 		*/
150*cdf0e10cSrcweir 		void setErrorOccured(const ::dbtools::SQLExceptionInfo& _rInfo)
151*cdf0e10cSrcweir 		{
152*cdf0e10cSrcweir 			m_aExceptionInfo = _rInfo;
153*cdf0e10cSrcweir 		}
154*cdf0e10cSrcweir 		/**
155*cdf0e10cSrcweir 			just returns the internal member and clears it
156*cdf0e10cSrcweir 		*/
157*cdf0e10cSrcweir 		::dbtools::SQLExceptionInfo clearOccuredError()
158*cdf0e10cSrcweir 		{
159*cdf0e10cSrcweir 			::dbtools::SQLExceptionInfo aInfo = m_aExceptionInfo;
160*cdf0e10cSrcweir 			m_aExceptionInfo = ::dbtools::SQLExceptionInfo();
161*cdf0e10cSrcweir 			return aInfo;
162*cdf0e10cSrcweir 		}
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     protected:
165*cdf0e10cSrcweir 		TTableWindowData::value_type createTableWindowData(const ::rtl::OUString& _sComposedName,const ::rtl::OUString& _sTableName,const ::rtl::OUString& _sWindowName);
166*cdf0e10cSrcweir 		// ask the user if the design should be saved when it is modified
167*cdf0e10cSrcweir 		virtual short saveModified() = 0;
168*cdf0e10cSrcweir 		// called when the orignal state should be reseted (first time load)
169*cdf0e10cSrcweir 		virtual void reset()		 = 0;
170*cdf0e10cSrcweir 		virtual void describeSupportedFeatures();
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir         AddTableDialogContext&  impl_getDialogContext() const;
173*cdf0e10cSrcweir 	};
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir #endif // DBAUI_JOINCONTROLLER_HXX
176*cdf0e10cSrcweir 
177