xref: /aoo41x/main/dbaccess/source/ui/app/AppView.hxx (revision 2e2212a7)
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
10*2e2212a7SAndrew Rist  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2e2212a7SAndrew Rist  *
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.
19*2e2212a7SAndrew Rist  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir #ifndef DBAUI_APPVIEW_HXX
24cdf0e10cSrcweir #define DBAUI_APPVIEW_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef DBAUI_DATAVIEW_HXX
27cdf0e10cSrcweir #include "dataview.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
30cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
33cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
36cdf0e10cSrcweir #include <com/sun/star/ucb/XContent.hpp>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_
39cdf0e10cSrcweir #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef _SV_FIXED_HXX
42cdf0e10cSrcweir #include <vcl/fixed.hxx>
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #ifndef _UNOTOOLS_EVENTLISTENERADAPTER_HXX_
45cdf0e10cSrcweir #include <unotools/eventlisteneradapter.hxx>
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
48cdf0e10cSrcweir #include "IClipBoardTest.hxx"
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #ifndef DBAUI_APPELEMENTTYPE_HXX
51cdf0e10cSrcweir #include "AppElementType.hxx"
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir 
54cdf0e10cSrcweir namespace com{ namespace sun { namespace star { namespace beans    { class XPropertySet; } } } }
55cdf0e10cSrcweir 
56cdf0e10cSrcweir class Control;
57cdf0e10cSrcweir class SvLBoxEntry;
58cdf0e10cSrcweir class MnemonicGenerator;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir namespace dbaui
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	class IControlActionListener;
63cdf0e10cSrcweir     class IApplicationController;
64cdf0e10cSrcweir 	class OApplicationView;
65cdf0e10cSrcweir 	class OApplicationDetailView;
66cdf0e10cSrcweir 	class OApplicationSwapWindow;
67cdf0e10cSrcweir 	class OTitleWindow;
68cdf0e10cSrcweir 	//==================================================================
69cdf0e10cSrcweir 	class OAppBorderWindow : public Window
70cdf0e10cSrcweir 	{
71cdf0e10cSrcweir 		OTitleWindow*						m_pPanel;
72cdf0e10cSrcweir 		OApplicationDetailView*				m_pDetailView;
73cdf0e10cSrcweir 		OApplicationView*					m_pView;
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 		void ImplInitSettings();
76cdf0e10cSrcweir 	protected:
77cdf0e10cSrcweir 		// Window
78cdf0e10cSrcweir 		virtual void DataChanged( const DataChangedEvent& rDCEvt );
79cdf0e10cSrcweir 	public:
80cdf0e10cSrcweir 		OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePreviewMode);
81cdf0e10cSrcweir 		virtual ~OAppBorderWindow();
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 		// window overloads
84cdf0e10cSrcweir 		virtual void GetFocus();
85cdf0e10cSrcweir 		virtual void Resize();
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 		OApplicationView*		getView() const;
88cdf0e10cSrcweir 		OApplicationSwapWindow*	getPanel() const;
89cdf0e10cSrcweir 		OApplicationDetailView*	getDetailView() const;
90cdf0e10cSrcweir 	};
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	//==================================================================
93cdf0e10cSrcweir 	class OApplicationView : public ODataView
94cdf0e10cSrcweir 							,public IClipboardTest
95cdf0e10cSrcweir 							,public ::utl::OEventListenerAdapter
96cdf0e10cSrcweir 	{
97cdf0e10cSrcweir 		enum ChildFocusState
98cdf0e10cSrcweir 		{
99cdf0e10cSrcweir 			PANELSWAP,
100cdf0e10cSrcweir 			DETAIL,
101cdf0e10cSrcweir 			NONE
102cdf0e10cSrcweir 		};
103cdf0e10cSrcweir 	private:
104cdf0e10cSrcweir 		::com::sun::star::lang::Locale		m_aLocale;
105cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
106cdf0e10cSrcweir 											m_xObject;
107cdf0e10cSrcweir 		OAppBorderWindow*					m_pWin;
108cdf0e10cSrcweir 		IApplicationController&             m_rAppController;
109cdf0e10cSrcweir         ChildFocusState						m_eChildFocus;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 		IClipboardTest* getActiveChild() const;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 		void ImplInitSettings();
114cdf0e10cSrcweir 	protected:
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 		// return the Rectangle where I can paint myself
118cdf0e10cSrcweir 		virtual void resizeDocumentView(Rectangle& rRect);
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 		// OEventListenerAdapter
121cdf0e10cSrcweir 		virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 		// Window
124cdf0e10cSrcweir 		virtual void DataChanged( const DataChangedEvent& rDCEvt );
125cdf0e10cSrcweir 	public:
126cdf0e10cSrcweir 		OApplicationView(	Window* pParent
127cdf0e10cSrcweir 							,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
128cdf0e10cSrcweir 							,IApplicationController&            _rAppController
129cdf0e10cSrcweir 							,PreviewMode _ePreviewMode
130cdf0e10cSrcweir 							);
131cdf0e10cSrcweir 		virtual ~OApplicationView();
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         /// automatically creates mnemonics for the icon/texts in our left hand side panel
134cdf0e10cSrcweir         void    createIconAutoMnemonics( MnemonicGenerator& _rMnemonics );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir         /// automatically creates mnemonics for the texts in our task pane
137cdf0e10cSrcweir         void    setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         // window overloads
140cdf0e10cSrcweir 		virtual long PreNotify( NotifyEvent& rNEvt );
141cdf0e10cSrcweir 		virtual void GetFocus();
142cdf0e10cSrcweir 
getAppController() const143cdf0e10cSrcweir         inline IApplicationController&                  getAppController() const { return m_rAppController; }
getLocale() const144cdf0e10cSrcweir 		inline const ::com::sun::star::lang::Locale&	getLocale() const { return m_aLocale;}
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 		// IClipboardTest
147cdf0e10cSrcweir 		virtual sal_Bool isCutAllowed();
148cdf0e10cSrcweir 		virtual sal_Bool isCopyAllowed();
149cdf0e10cSrcweir 		virtual sal_Bool isPasteAllowed();
hasChildPathFocus()150cdf0e10cSrcweir 		virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
151cdf0e10cSrcweir 		virtual void copy();
152cdf0e10cSrcweir 		virtual void cut();
153cdf0e10cSrcweir 		virtual void paste();
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 		/// get the left panel
getPanel() const156cdf0e10cSrcweir 		inline OApplicationSwapWindow*	getPanel()		const { return m_pWin->getPanel(); }
157cdf0e10cSrcweir 		/// get the detail page
getDetailView() const158cdf0e10cSrcweir 		inline OApplicationDetailView*	getDetailView() const { return m_pWin->getDetailView(); }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 		/** return the qualified name.
161cdf0e10cSrcweir 			@param	_pEntry
162cdf0e10cSrcweir 				The entry of a table, or query, form, report to get the qualified name.
163cdf0e10cSrcweir 				If the entry is <NULL/>, the first selected is chosen.
164cdf0e10cSrcweir 			@return
165cdf0e10cSrcweir 				the qualified name
166cdf0e10cSrcweir 		*/
167cdf0e10cSrcweir 		::rtl::OUString getQualifiedName( SvLBoxEntry* _pEntry ) const;
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 		/** returns if an entry is a leaf
170cdf0e10cSrcweir 			@param _pEntry
171cdf0e10cSrcweir 				The entry to check
172cdf0e10cSrcweir 			@return
173cdf0e10cSrcweir 				<TRUE/> if the entry is a leaf, otherwise <FALSE/>
174cdf0e10cSrcweir 		*/
175cdf0e10cSrcweir 		sal_Bool isLeaf(SvLBoxEntry* _pEntry) const;
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 		/** returns if one of the selected entries is a leaf
178cdf0e10cSrcweir 			@return
179cdf0e10cSrcweir 				<TRUE/> if the entry is a leaf, otherwise <FALSE/>
180cdf0e10cSrcweir 		*/
181cdf0e10cSrcweir 		sal_Bool isALeafSelected() const;
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 		/** select all entries in the detail page
184cdf0e10cSrcweir 		*/
185cdf0e10cSrcweir 		void selectAll();
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 		/// returns <TRUE/> if it sorts ascending
188cdf0e10cSrcweir 		sal_Bool isSortUp() const;
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 		/// sort the entries in the detail page down
191cdf0e10cSrcweir 		void sortDown();
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 		/// sort the entries in the detail page up
194cdf0e10cSrcweir 		void sortUp();
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 		/// returns <TRUE/> when a detail page was filled
197cdf0e10cSrcweir 		sal_Bool isFilled() const;
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 		/// return the element of currently select entry
200cdf0e10cSrcweir 		ElementType getElementType() const;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 		/// returns the count of entries
203cdf0e10cSrcweir 		sal_Int32 getElementCount();
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 		/// returns the count of selected entries
206cdf0e10cSrcweir 		sal_Int32 getSelectionCount();
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 		/** clears the detail page and the selection on the left side.
209cdf0e10cSrcweir 			@param	_bTaskAlso
210cdf0e10cSrcweir 				If <TRUE/> the task window will also be cleared.
211cdf0e10cSrcweir 		*/
212cdf0e10cSrcweir 		void clearPages(sal_Bool _bTaskAlso = sal_True);
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 		/** returns the element names which are selected
215cdf0e10cSrcweir 			@param	_rNames
216cdf0e10cSrcweir 				The list will be filled.
217cdf0e10cSrcweir 		*/
218cdf0e10cSrcweir 		void getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const;
219cdf0e10cSrcweir 
220cdf0e10cSrcweir         /** describes the current selection for the given control
221cdf0e10cSrcweir         */
222cdf0e10cSrcweir         void    describeCurrentSelectionForControl(
223cdf0e10cSrcweir                     const Control& _rControl,
224cdf0e10cSrcweir                     ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
225cdf0e10cSrcweir                 );
226cdf0e10cSrcweir 
227cdf0e10cSrcweir         /** describes the current selection for the given ElementType
228cdf0e10cSrcweir         */
229cdf0e10cSrcweir         void    describeCurrentSelectionForType(
230cdf0e10cSrcweir                     const ElementType _eType,
231cdf0e10cSrcweir                     ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
232cdf0e10cSrcweir                 );
233cdf0e10cSrcweir 
234cdf0e10cSrcweir         /** select all names on the currently selected container. Non existence names where ignored.
235cdf0e10cSrcweir         *
236cdf0e10cSrcweir         * \param _aNames the element names
237cdf0e10cSrcweir         */
238cdf0e10cSrcweir         void selectElements(const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aNames);
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 		/** adds a new object to the detail page.
241cdf0e10cSrcweir 			@param	_eType
242cdf0e10cSrcweir 				The type where the entry shold be appended.
243cdf0e10cSrcweir 			@param	_rName
244cdf0e10cSrcweir 				The name of the object to be inserted
245cdf0e10cSrcweir 			@param	_rObject
246cdf0e10cSrcweir 				The object to add.
247cdf0e10cSrcweir 			@param	_rxConn
248cdf0e10cSrcweir 				If we insert a table, the connection must be set.
249cdf0e10cSrcweir 		*/
250cdf0e10cSrcweir 		SvLBoxEntry* elementAdded(ElementType _eType
251cdf0e10cSrcweir 						,const ::rtl::OUString& _rName
252cdf0e10cSrcweir 						,const ::com::sun::star::uno::Any& _rObject );
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 		/** replaces a objects name with a new one
255cdf0e10cSrcweir 			@param	_eType
256cdf0e10cSrcweir 				The type where the entry shold be appended.
257cdf0e10cSrcweir 			@param	_rOldName
258cdf0e10cSrcweir 				The old name of the object to be replaced
259cdf0e10cSrcweir 			@param	_rNewName
260cdf0e10cSrcweir 				The new name of the object to be replaced
261cdf0e10cSrcweir 			@param	_rxConn
262cdf0e10cSrcweir 				If we insert a table, the connection must be set.
263cdf0e10cSrcweir             @param  _xObject
264cdf0e10cSrcweir                 The object which was replaced
265cdf0e10cSrcweir 		*/
266cdf0e10cSrcweir 		void elementReplaced(ElementType eType
267cdf0e10cSrcweir 						,const ::rtl::OUString& _rOldName
268cdf0e10cSrcweir 						,const ::rtl::OUString& _rNewName );
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 		/** removes an element from the detail page.
271cdf0e10cSrcweir 			@param	_eType
272cdf0e10cSrcweir 				The type where the entry shold be appended.
273cdf0e10cSrcweir 			@param	_rName
274cdf0e10cSrcweir 				The name of the element to be removed.
275cdf0e10cSrcweir 			@param	_rxConn
276cdf0e10cSrcweir 				If we remove a table, the connection must be set.
277cdf0e10cSrcweir 		*/
278cdf0e10cSrcweir 		void elementRemoved(ElementType _eType
279cdf0e10cSrcweir 							,const ::rtl::OUString& _rName );
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 		/** changes the container which should be displayed. The select handler will also be called.
283cdf0e10cSrcweir 			@param	_eType
284cdf0e10cSrcweir 				Which container to show.
285cdf0e10cSrcweir 		*/
286cdf0e10cSrcweir 		void selectContainer(ElementType _eType);
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 		/// returns the preview mode
289cdf0e10cSrcweir 		PreviewMode getPreviewMode();
290cdf0e10cSrcweir 
291cdf0e10cSrcweir 		/// <TRUE/> if the preview is enabled
292cdf0e10cSrcweir 		sal_Bool isPreviewEnabled();
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 		/** switches to the given preview mode
295cdf0e10cSrcweir 			@param	_eMode
296cdf0e10cSrcweir 				the mode to set for the preview
297cdf0e10cSrcweir 		*/
298cdf0e10cSrcweir 		void switchPreview(PreviewMode _eMode);
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 		/** shows the Preview of the content when it is enabled.
301cdf0e10cSrcweir 			@param	_xContent
302cdf0e10cSrcweir 				The content which must support the "preview" command.
303cdf0e10cSrcweir 		*/
304cdf0e10cSrcweir 		void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 		/** shows the Preview of a table or query
307cdf0e10cSrcweir 			@param	_sDataSourceName
308cdf0e10cSrcweir 				the name of the data source
309cdf0e10cSrcweir 			@param	_xConnection
310cdf0e10cSrcweir 				the connection which will be shared
311cdf0e10cSrcweir 			@param	_sName
312cdf0e10cSrcweir 				the name of table or query
313cdf0e10cSrcweir 			@param	_bTable
314cdf0e10cSrcweir 				<TRUE/> if it is a table, otherwise <FALSE/>
315cdf0e10cSrcweir 			@return	void
316cdf0e10cSrcweir 		*/
317cdf0e10cSrcweir 		void showPreview(	const ::rtl::OUString& _sDataSourceName,
318cdf0e10cSrcweir 							const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
319cdf0e10cSrcweir 							const ::rtl::OUString& _sName,
320cdf0e10cSrcweir 							sal_Bool _bTable);
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 		SvLBoxEntry* getEntry( const Point& _aPosPixel ) const;
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 		DECL_LINK( SwitchHdl, Accelerator* );
325cdf0e10cSrcweir 	};
326cdf0e10cSrcweir }
327cdf0e10cSrcweir #endif // DBAUI_APPVIEW_HXX
328cdf0e10cSrcweir 
329