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