xref: /AOO41X/main/dbaccess/source/ui/inc/JoinController.hxx (revision 2e2212a7c22e96cf6f6fab0dd042c34a45a64bd6)
1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir #ifndef DBAUI_JOINCONTROLLER_HXX
24cdf0e10cSrcweir #define DBAUI_JOINCONTROLLER_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "singledoccontroller.hxx"
27cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
28cdf0e10cSrcweir #include "moduledbu.hxx"
29cdf0e10cSrcweir #include "JoinTableView.hxx"
30cdf0e10cSrcweir #include "JoinDesignView.hxx"
31cdf0e10cSrcweir #include "TableConnectionData.hxx"
32cdf0e10cSrcweir #include "TableWindowData.hxx"
33cdf0e10cSrcweir #include <memory>
34cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace comphelper
37cdf0e10cSrcweir {
38cdf0e10cSrcweir     class NamedValueCollection;
39cdf0e10cSrcweir }
40cdf0e10cSrcweir 
41cdf0e10cSrcweir class VCLXWindow;
42cdf0e10cSrcweir namespace dbaui
43cdf0e10cSrcweir {
44cdf0e10cSrcweir 	class OAddTableDlg;
45cdf0e10cSrcweir     class AddTableDialogContext;
46cdf0e10cSrcweir 	class OTableConnectionData;
47cdf0e10cSrcweir 	class OTableWindowData;
48cdf0e10cSrcweir 	class OTableWindow;
49cdf0e10cSrcweir 	typedef OSingleDocumentController OJoinController_BASE;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     class OJoinController : public OJoinController_BASE
52cdf0e10cSrcweir 	{
53cdf0e10cSrcweir         OModuleClient                    m_aModuleClient;
54cdf0e10cSrcweir 	protected:
55cdf0e10cSrcweir         TTableConnectionData m_vTableConnectionData;
56cdf0e10cSrcweir 		TTableWindowData     m_vTableData;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 		Fraction								m_aZoom;
59cdf0e10cSrcweir 		::dbtools::SQLExceptionInfo				m_aExceptionInfo;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 		OAddTableDlg*	                            m_pAddTableDialog;
62cdf0e10cSrcweir         ::std::auto_ptr< AddTableDialogContext >    m_pDialogContext;
63cdf0e10cSrcweir         Point                                   m_aMinimumTableViewSize;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 		// 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.
66cdf0e10cSrcweir 		virtual FeatureState	GetState(sal_uInt16 nId) const;
67cdf0e10cSrcweir 		// execute a feature
68cdf0e10cSrcweir 		virtual void			Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 		/** loads the information for the windows.
71cdf0e10cSrcweir 			@param	i_rViewSettings
72cdf0e10cSrcweir 				The properties which comes from the layout information.
73cdf0e10cSrcweir 		*/
74cdf0e10cSrcweir         void loadTableWindows( const ::comphelper::NamedValueCollection& i_rViewSettings );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 		/** loads the information for one window.
77cdf0e10cSrcweir 			@param	_rTable
78cdf0e10cSrcweir 				The properties which comes from the layout information.
79cdf0e10cSrcweir 		*/
80cdf0e10cSrcweir 		void loadTableWindow( const ::comphelper::NamedValueCollection& i_rTableWindowSettings );
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 		/** saves the TableWindows structure in a sequence of property values
83cdf0e10cSrcweir 			@param	_rViewProps
84cdf0e10cSrcweir 				Contains the new sequence.
85cdf0e10cSrcweir 		*/
86cdf0e10cSrcweir         void saveTableWindows( ::comphelper::NamedValueCollection& o_rViewSettings ) const;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 		virtual ~OJoinController();
89cdf0e10cSrcweir 	public:
90cdf0e10cSrcweir 		OJoinController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir         // ---------------------------------------------------------------
93cdf0e10cSrcweir         // attribute access
getTableWindowData()94cdf0e10cSrcweir 		inline TTableWindowData*		getTableWindowData()     { return &m_vTableData; }
getTableConnectionData()95cdf0e10cSrcweir 		inline TTableConnectionData*	getTableConnectionData() { return &m_vTableConnectionData;}
getAddTableDialog() const96cdf0e10cSrcweir         inline OAddTableDlg*            getAddTableDialog()const { return m_pAddTableDialog; }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         // ---------------------------------------------------------------
99cdf0e10cSrcweir         // OSingleDocumentController overridables
100cdf0e10cSrcweir 		virtual void        reconnect( sal_Bool _bUI );
101cdf0e10cSrcweir 		virtual void        impl_onModifyChanged();
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         // ---------------------------------------------------------------
104cdf0e10cSrcweir         // own overridables
105cdf0e10cSrcweir         /** determines whether or not it's allowed for database views to participate in the game
106cdf0e10cSrcweir         */
107cdf0e10cSrcweir         virtual bool allowViews() const = 0;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir         /** determines whether or not it's allowed for queries to participate in the game
110cdf0e10cSrcweir         */
111cdf0e10cSrcweir         virtual bool allowQueries() const = 0;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir         /** provides access to the OJoinDesignView belonging to the controller, which might
114cdf0e10cSrcweir             or might not be the direct view (getView)
115cdf0e10cSrcweir         */
116cdf0e10cSrcweir 		virtual OJoinDesignView*	getJoinView();
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 
119cdf0e10cSrcweir         // ---------------------------------------------------------------
120cdf0e10cSrcweir         /** erase the data in the data vector
121cdf0e10cSrcweir 			@param	_pData
122cdf0e10cSrcweir 					the data whioch should be erased
123cdf0e10cSrcweir 		*/
124cdf0e10cSrcweir 		void    removeConnectionData(const TTableConnectionData::value_type& _pData);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		void    SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabWinList, long nOffsetX, long nOffsetY );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir         void	SaveTabWinPosSize(OTableWindow* pTabWin, long nOffsetX, long nOffsetY);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         // ---------------------------------------------------------------
131cdf0e10cSrcweir         // UNO interface overridables
132cdf0e10cSrcweir 		// XEventListener
133cdf0e10cSrcweir 		virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 		// ::com::sun::star::lang::XComponent
136cdf0e10cSrcweir 		virtual void	SAL_CALL disposing();
137cdf0e10cSrcweir 		// ::com::sun::star::frame::XController
138cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) throw( ::com::sun::star::uno::RuntimeException );
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         // ---------------------------------------------------------------
142cdf0e10cSrcweir         // misc
143cdf0e10cSrcweir 		/** only defines a method to save a SQLException in d&d methods to show the error at a later state
144cdf0e10cSrcweir 			set the internal member m_aExceptionInfo to _rInfo
145cdf0e10cSrcweir 		*/
setErrorOccured(const::dbtools::SQLExceptionInfo & _rInfo)146cdf0e10cSrcweir 		void setErrorOccured(const ::dbtools::SQLExceptionInfo& _rInfo)
147cdf0e10cSrcweir 		{
148cdf0e10cSrcweir 			m_aExceptionInfo = _rInfo;
149cdf0e10cSrcweir 		}
150cdf0e10cSrcweir 		/**
151cdf0e10cSrcweir 			just returns the internal member and clears it
152cdf0e10cSrcweir 		*/
clearOccuredError()153cdf0e10cSrcweir 		::dbtools::SQLExceptionInfo clearOccuredError()
154cdf0e10cSrcweir 		{
155cdf0e10cSrcweir 			::dbtools::SQLExceptionInfo aInfo = m_aExceptionInfo;
156cdf0e10cSrcweir 			m_aExceptionInfo = ::dbtools::SQLExceptionInfo();
157cdf0e10cSrcweir 			return aInfo;
158cdf0e10cSrcweir 		}
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     protected:
161cdf0e10cSrcweir 		TTableWindowData::value_type createTableWindowData(const ::rtl::OUString& _sComposedName,const ::rtl::OUString& _sTableName,const ::rtl::OUString& _sWindowName);
162cdf0e10cSrcweir 		// ask the user if the design should be saved when it is modified
163cdf0e10cSrcweir 		virtual short saveModified() = 0;
164cdf0e10cSrcweir 		// called when the orignal state should be reseted (first time load)
165cdf0e10cSrcweir 		virtual void reset()		 = 0;
166cdf0e10cSrcweir 		virtual void describeSupportedFeatures();
167cdf0e10cSrcweir 
168cdf0e10cSrcweir         AddTableDialogContext&  impl_getDialogContext() const;
169cdf0e10cSrcweir 	};
170cdf0e10cSrcweir }
171cdf0e10cSrcweir #endif // DBAUI_JOINCONTROLLER_HXX
172cdf0e10cSrcweir 
173