1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AppDetailView.hxx,v $
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>
36 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
37 #include <com/sun/star/container/XNameAccess.hpp>
39 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
40 #include <com/sun/star/sdbc/XConnection.hpp>
42 #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
43 #include <com/sun/star/ucb/XContent.hpp>
45 #ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_
46 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
49 #include <vcl/split.hxx>
52 #include <vcl/fixed.hxx>
54 #ifndef _SV_MNEMONIC_HXX
55 #include <vcl/mnemonic.hxx>
57 #ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
58 #include "IClipBoardTest.hxx"
60 #ifndef DBAUI_TITLE_WINDOW_HXX
61 #include "AppTitleWindow.hxx"
63 #ifndef DBAUI_APPELEMENTTYPE_HXX
64 #include "AppElementType.hxx"
66 #ifndef _SVTREEBOX_HXX
67 #include <svtools/svtreebx.hxx>
69 #ifndef DBAUI_VERTSPLITVIEW_HXX
70 #include "VertSplitView.hxx"
79 class OAppBorderWindow
;
80 class OApplicationDetailView
;
81 class OAppDetailPageHelper
;
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
;
95 OCreationList( OTasksWindow
& _rParent
);
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();
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
);
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
);
129 ::rtl::OUString sUNOCommand
;
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
;
143 /// the tasks available in the pane
144 TaskEntryList aTasks
;
145 /// the resource ID for the title of the pane
149 class OTasksWindow
: public Window
151 OCreationList m_aCreation
;
152 FixedText m_aDescription
;
153 FixedText m_aHelpText
;
155 OApplicationDetailView
* m_pDetailView
;
157 DECL_LINK( OnEntrySelectHdl
, SvTreeListBox
* );
158 void ImplInitSettings( BOOL bFont
, BOOL bForeground
, BOOL bBackground
);
160 virtual void DataChanged(const DataChangedEvent
& rDCEvt
);
162 OTasksWindow(Window
* _pParent
,OApplicationDetailView
* _pDetailView
);
163 virtual ~OTasksWindow();
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
);
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
);
196 virtual void DataChanged(const DataChangedEvent
& rDCEvt
);
199 OApplicationDetailView(OAppBorderWindow
& _rParent
,PreviewMode _ePreviewMode
);
200 virtual ~OApplicationDetailView();
202 // virtual void Resize();
203 virtual void GetFocus();
205 /** creates the tables page
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.
213 The type which should be created. E_TABLE isn't allowed.
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
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(); }
240 /** return the qualified name.
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.
247 ::rtl::OUString
getQualifiedName( SvLBoxEntry
* _pEntry
) const;
249 /** returns if an entry is a leaf
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
259 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
261 sal_Bool
isALeafSelected() const;
263 /** select all entries in the detail page
267 /// returns <TRUE/> if it sorts ascending
268 sal_Bool
isSortUp() const;
270 /// sort the entries in the detail page down
273 /// sort the entries in the detail page up
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.
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
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.
322 The type where the entry shold be appended.
324 The name of the object to be inserted
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
336 The type where the entry shold be appended.
338 The old name of the object to be replaced
340 The new name of the object to be replaced
342 If we insert a table, the connection must be set.
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.
352 The type where the entry shold be appended.
354 The name of the element to be removed.
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
370 the mode to set for the preview
372 void switchPreview(PreviewMode _eMode
);
374 /** shows the Preview of the content when it is enabled.
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
384 the name of table or query
386 <TRUE/> if it is a table, otherwise <FALSE/>
389 void showPreview( const ::rtl::OUString
& _sDataSourceName
,
390 const ::rtl::OUString
& _sName
,
393 SvLBoxEntry
* getEntry( const Point
& _aPoint
) const;
395 Window
* getTreeWindow() const;
397 void impl_createPage(
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