merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / app / AppDetailView.hxx
blob4467f3bb9961ef6021476cec09f3cb3a73aabd67
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AppDetailView.hxx,v $
10 * $Revision: 1.20 $
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 ************************************************************************/
30 #ifndef DBAUI_APPDETAILVIEW_HXX
31 #define DBAUI_APPDETAILVIEW_HXX
33 #ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_
34 #include <com/sun/star/frame/XController.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
37 #include <com/sun/star/container/XNameAccess.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
40 #include <com/sun/star/sdbc/XConnection.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
43 #include <com/sun/star/ucb/XContent.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_
46 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
47 #endif
48 #ifndef _SV_SPLIT_HXX
49 #include <vcl/split.hxx>
50 #endif
51 #ifndef _SV_FIXED_HXX
52 #include <vcl/fixed.hxx>
53 #endif
54 #ifndef _SV_MNEMONIC_HXX
55 #include <vcl/mnemonic.hxx>
56 #endif
57 #ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
58 #include "IClipBoardTest.hxx"
59 #endif
60 #ifndef DBAUI_TITLE_WINDOW_HXX
61 #include "AppTitleWindow.hxx"
62 #endif
63 #ifndef DBAUI_APPELEMENTTYPE_HXX
64 #include "AppElementType.hxx"
65 #endif
66 #ifndef _SVTREEBOX_HXX
67 #include <svtools/svtreebx.hxx>
68 #endif
69 #ifndef DBAUI_VERTSPLITVIEW_HXX
70 #include "VertSplitView.hxx"
71 #endif
73 #include <vector>
75 class SvLBoxEntry;
77 namespace dbaui
79 class OAppBorderWindow;
80 class OApplicationDetailView;
81 class OAppDetailPageHelper;
82 class OTasksWindow;
84 class OCreationList : public SvTreeListBox
86 OTasksWindow& m_rTaskWindow;
88 // members related to drawing the currently hovered/selected entry
89 SvLBoxEntry* m_pMouseDownEntry;
90 SvLBoxEntry* m_pLastActiveEntry;
91 Color m_aOriginalBackgroundColor;
92 Font m_aOriginalFont;
94 public:
95 OCreationList( OTasksWindow& _rParent );
96 // window overloads
97 virtual void MouseMove( const MouseEvent& rMEvt );
98 virtual void MouseButtonDown( const MouseEvent& rMEvt );
99 virtual void MouseButtonUp( const MouseEvent& rMEvt );
100 virtual void KeyInput( const KeyEvent& rKEvt );
101 virtual void Paint( const Rectangle& rRect );
102 virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel );
103 virtual void GetFocus();
104 virtual void LoseFocus();
106 inline void resetLastActive() { m_pLastActiveEntry = NULL;}
108 void updateHelpText();
110 protected:
111 virtual void PreparePaint( SvLBoxEntry* _pEntry );
112 virtual Rectangle GetFocusRect( SvLBoxEntry* _pEntry, long _nLine );
113 virtual void ModelHasCleared();
115 // IMnemonicEntryList
116 virtual void SelectSearchEntry( const void* _pEntry );
117 virtual void ExecuteSearchEntry( const void* _pEntry );
119 private:
120 void onSelected( SvLBoxEntry* _pEntry ) const;
121 /** sets a new current entry, and invalidates the old and the new one, if necessary
122 @return <TRUE/> if and only if the "current entry" changed
124 bool setCurrentEntryInvalidate( SvLBoxEntry* _pEntry );
127 struct TaskEntry
129 ::rtl::OUString sUNOCommand;
130 USHORT nHelpID;
131 String sTitle;
132 bool bHideWhenDisabled;
133 // TODO: we should be consistent in the task pane and the menus/toolbars:
134 // If an entry is disabled in the latter, it should also be disabled in the former.
135 // If an entry is *hidden* in the former, it should also be hidden in the latter.
137 TaskEntry( const sal_Char* _pAsciiUNOCommand, USHORT _nHelpID, USHORT _nTitleResourceID, bool _bHideWhenDisabled = false );
139 typedef ::std::vector< TaskEntry > TaskEntryList;
141 struct TaskPaneData
143 /// the tasks available in the pane
144 TaskEntryList aTasks;
145 /// the resource ID for the title of the pane
146 USHORT nTitleId;
149 class OTasksWindow : public Window
151 OCreationList m_aCreation;
152 FixedText m_aDescription;
153 FixedText m_aHelpText;
154 FixedLine m_aFL;
155 OApplicationDetailView* m_pDetailView;
157 DECL_LINK( OnEntrySelectHdl, SvTreeListBox* );
158 void ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );
159 protected:
160 virtual void DataChanged(const DataChangedEvent& rDCEvt);
161 public:
162 OTasksWindow(Window* _pParent,OApplicationDetailView* _pDetailView);
163 virtual ~OTasksWindow();
165 // window overloads
166 virtual void Resize();
168 OApplicationDetailView* getDetailView() const { return m_pDetailView; }
170 /// fills the Creation listbox with the necessary strings and images
171 void fillTaskEntryList( const TaskEntryList& _rList );
173 inline bool HandleKeyInput( const KeyEvent& _rKEvt )
175 return m_aCreation.HandleKeyInput( _rKEvt );
178 void Clear();
179 void setHelpText(USHORT _nId);
181 //==================================================================
182 class OApplicationDetailView : public OSplitterView
183 , public IClipboardTest
185 Splitter m_aHorzSplitter;
186 OTitleWindow m_aTasks;
187 OTitleWindow m_aContainer;
188 OAppBorderWindow& m_rBorderWin; // my parent
189 OAppDetailPageHelper* m_pControlHelper;
190 ::std::vector< TaskPaneData > m_aTaskPaneData;
191 MnemonicGenerator m_aExternalMnemonics;
193 void ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );
195 protected:
196 virtual void DataChanged(const DataChangedEvent& rDCEvt);
198 public:
199 OApplicationDetailView(OAppBorderWindow& _rParent,PreviewMode _ePreviewMode);
200 virtual ~OApplicationDetailView();
201 // window overloads
202 // virtual void Resize();
203 virtual void GetFocus();
205 /** creates the tables page
206 @param _xConnection
207 The connection to get the table names
209 void createTablesPage(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
211 /** creates the page for the specific type.
212 @param _eType
213 The type which should be created. E_TABLE isn't allowed.
214 @param _xContainer
215 The container of the elements to be inserted.
217 void createPage(ElementType _eType,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer);
219 void setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics );
221 /** called to give the window the chance to intercept key events, while it has not
222 the focus
224 @return <TRUE/> if and only if the event has been handled, and should not
225 not be further processed
227 bool interceptKeyInput( const KeyEvent& _rEvent );
229 inline OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
230 inline OTasksWindow& getTasksWindow() const { return *static_cast< OTasksWindow* >( m_aTasks.getChildWindow() ); }
232 sal_Bool isCutAllowed() ;
233 sal_Bool isCopyAllowed() ;
234 sal_Bool isPasteAllowed();
235 virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
236 void copy();
237 void cut();
238 void paste();
240 /** return the qualified name.
241 @param _pEntry
242 The entry of a table, or query, form, report to get the qualified name.
243 If the entry is <NULL/>, the first selected is chosen.
244 @return
245 the qualified name
247 ::rtl::OUString getQualifiedName( SvLBoxEntry* _pEntry ) const;
249 /** returns if an entry is a leaf
250 @param _pEntry
251 The entry to check
252 @return
253 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
255 sal_Bool isLeaf(SvLBoxEntry* _pEntry) const;
257 /** returns if one of the selected entries is a leaf
258 @return
259 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
261 sal_Bool isALeafSelected() const;
263 /** select all entries in the detail page
265 void selectAll();
267 /// returns <TRUE/> if it sorts ascending
268 sal_Bool isSortUp() const;
270 /// sort the entries in the detail page down
271 void sortDown();
273 /// sort the entries in the detail page up
274 void sortUp();
276 /// returns <TRUE/> when a detail page was filled
277 sal_Bool isFilled() const;
279 /// return the element of currently select entry
280 ElementType getElementType() const;
282 /** clears the detail pages.
283 @param _bTaskAlso
284 If <TRUE/> the task window will also be cleared.
286 void clearPages(sal_Bool _bTaskAlso = sal_True);
288 /// returns the count of entries
289 sal_Int32 getElementCount();
291 /// returns the count of selected entries
292 sal_Int32 getSelectionCount();
294 /** returns the element names which are selected
295 @param _rNames
296 The list will be filled.
298 void getSelectionElementNames(::std::vector< ::rtl::OUString>& _rNames ) const;
300 /** describes the current selection for the given control
302 void describeCurrentSelectionForControl(
303 const Control& _rControl,
304 ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
307 /** describes the current selection for the given ElementType
309 void describeCurrentSelectionForType(
310 const ElementType _eType,
311 ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
314 /** select all names on the currently selected container. Non existence names where ignored.
316 * \param _aNames the element names
318 void selectElements(const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aNames);
320 /** adds a new object to the detail page.
321 @param _eType
322 The type where the entry shold be appended.
323 @param _rName
324 The name of the object to be inserted
325 @param _rObject
326 The object to add.
327 @param _rxConn
328 If we insert a table, the connection must be set.
330 SvLBoxEntry* elementAdded(ElementType eType
331 ,const ::rtl::OUString& _rName
332 ,const ::com::sun::star::uno::Any& _rObject );
334 /** replaces a objects name with a new one
335 @param _eType
336 The type where the entry shold be appended.
337 @param _rOldName
338 The old name of the object to be replaced
339 @param _rNewName
340 The new name of the object to be replaced
341 @param _rxConn
342 If we insert a table, the connection must be set.
343 @param _xObject
344 The object which was replaced
346 void elementReplaced(ElementType eType
347 ,const ::rtl::OUString& _rOldName
348 ,const ::rtl::OUString& _rNewName );
350 /** removes an element from the detail page.
351 @param _eType
352 The type where the entry shold be appended.
353 @param _rName
354 The name of the element to be removed.
355 @param _rxConn
356 If we remove a table, the connection must be set.
358 void elementRemoved(ElementType _eType
359 ,const ::rtl::OUString& _rName );
361 /// returns the preview mode
362 PreviewMode getPreviewMode();
364 /// <TRUE/> if the preview is enabled
365 sal_Bool isPreviewEnabled();
368 /** switches to the given preview mode
369 @param _eMode
370 the mode to set for the preview
372 void switchPreview(PreviewMode _eMode);
374 /** shows the Preview of the content when it is enabled.
375 @param _xContent
376 The content which must support the "preview" command.
378 void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
380 /** shows the Preview of a table or query
381 @param _sDataSourceName
382 the name of the data source
383 @param _sName
384 the name of table or query
385 @param _bTable
386 <TRUE/> if it is a table, otherwise <FALSE/>
387 @return void
389 void showPreview( const ::rtl::OUString& _sDataSourceName,
390 const ::rtl::OUString& _sName,
391 sal_Bool _bTable);
393 SvLBoxEntry* getEntry( const Point& _aPoint ) const;
395 Window* getTreeWindow() const;
396 private:
397 void impl_createPage(
398 ElementType _eType,
399 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
400 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxNonTableElements
403 const TaskPaneData& impl_getTaskPaneData( ElementType _eType );
404 void impl_fillTaskPaneData( ElementType _eType, TaskPaneData& _rData ) const;
407 #endif // DBAUI_APPDETAILVIEW_HXX