1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef DBAUI_APPDETAILVIEW_HXX
29 #define DBAUI_APPDETAILVIEW_HXX
31 #include <com/sun/star/frame/XController.hpp>
32 #include <com/sun/star/container/XNameAccess.hpp>
33 #include <com/sun/star/sdbc/XConnection.hpp>
34 #include <com/sun/star/ucb/XContent.hpp>
35 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
36 #include <vcl/split.hxx>
37 #include <vcl/fixed.hxx>
38 #include <vcl/mnemonic.hxx>
39 #include "IClipBoardTest.hxx"
40 #include "AppTitleWindow.hxx"
41 #include "AppElementType.hxx"
42 #include <svtools/svtreebx.hxx>
43 #include "VertSplitView.hxx"
51 class OAppBorderWindow
;
52 class OApplicationDetailView
;
53 class OAppDetailPageHelper
;
56 class OCreationList
: public SvTreeListBox
58 OTasksWindow
& m_rTaskWindow
;
60 // members related to drawing the currently hovered/selected entry
61 SvLBoxEntry
* m_pMouseDownEntry
;
62 SvLBoxEntry
* m_pLastActiveEntry
;
63 Color m_aOriginalBackgroundColor
;
67 OCreationList( OTasksWindow
& _rParent
);
69 virtual void MouseMove( const MouseEvent
& rMEvt
);
70 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
71 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
72 virtual void KeyInput( const KeyEvent
& rKEvt
);
73 virtual void Paint( const Rectangle
& rRect
);
74 virtual void StartDrag( sal_Int8 _nAction
, const Point
& _rPosPixel
);
75 virtual void GetFocus();
76 virtual void LoseFocus();
78 inline void resetLastActive() { m_pLastActiveEntry
= NULL
;}
80 void updateHelpText();
83 virtual void PreparePaint( SvLBoxEntry
* _pEntry
);
84 virtual Rectangle
GetFocusRect( SvLBoxEntry
* _pEntry
, long _nLine
);
85 virtual void ModelHasCleared();
88 virtual void SelectSearchEntry( const void* _pEntry
);
89 virtual void ExecuteSearchEntry( const void* _pEntry
) const;
92 void onSelected( SvLBoxEntry
* _pEntry
) const;
93 /** sets a new current entry, and invalidates the old and the new one, if necessary
94 @return <TRUE/> if and only if the "current entry" changed
96 bool setCurrentEntryInvalidate( SvLBoxEntry
* _pEntry
);
101 ::rtl::OUString sUNOCommand
;
104 bool bHideWhenDisabled
;
105 // TODO: we should be consistent in the task pane and the menus/toolbars:
106 // If an entry is disabled in the latter, it should also be disabled in the former.
107 // If an entry is *hidden* in the former, it should also be hidden in the latter.
109 TaskEntry( const sal_Char
* _pAsciiUNOCommand
, sal_uInt16 _nHelpID
, sal_uInt16 _nTitleResourceID
, bool _bHideWhenDisabled
= false );
111 typedef ::std::vector
< TaskEntry
> TaskEntryList
;
115 /// the tasks available in the pane
116 TaskEntryList aTasks
;
117 /// the resource ID for the title of the pane
121 class OTasksWindow
: public Window
123 OCreationList m_aCreation
;
124 FixedText m_aDescription
;
125 FixedText m_aHelpText
;
127 OApplicationDetailView
* m_pDetailView
;
129 DECL_LINK( OnEntrySelectHdl
, SvTreeListBox
* );
130 void ImplInitSettings( sal_Bool bFont
, sal_Bool bForeground
, sal_Bool bBackground
);
132 virtual void DataChanged(const DataChangedEvent
& rDCEvt
);
134 OTasksWindow(Window
* _pParent
,OApplicationDetailView
* _pDetailView
);
135 virtual ~OTasksWindow();
138 virtual void Resize();
140 OApplicationDetailView
* getDetailView() const { return m_pDetailView
; }
142 /// fills the Creation listbox with the necessary strings and images
143 void fillTaskEntryList( const TaskEntryList
& _rList
);
145 inline bool HandleKeyInput( const KeyEvent
& _rKEvt
)
147 return m_aCreation
.HandleKeyInput( _rKEvt
);
151 void setHelpText(sal_uInt16 _nId
);
153 //==================================================================
154 class OApplicationDetailView
: public OSplitterView
155 , public IClipboardTest
157 Splitter m_aHorzSplitter
;
158 OTitleWindow m_aTasks
;
159 OTitleWindow m_aContainer
;
160 OAppBorderWindow
& m_rBorderWin
; // my parent
161 OAppDetailPageHelper
* m_pControlHelper
;
162 ::std::vector
< TaskPaneData
> m_aTaskPaneData
;
163 MnemonicGenerator m_aExternalMnemonics
;
165 void ImplInitSettings( sal_Bool bFont
, sal_Bool bForeground
, sal_Bool bBackground
);
168 virtual void DataChanged(const DataChangedEvent
& rDCEvt
);
171 OApplicationDetailView(OAppBorderWindow
& _rParent
,PreviewMode _ePreviewMode
);
172 virtual ~OApplicationDetailView();
174 virtual void GetFocus();
176 /** creates the tables page
178 The connection to get the table names
180 void createTablesPage(const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _xConnection
);
182 /** creates the page for the specific type.
184 The type which should be created. E_TABLE isn't allowed.
186 The container of the elements to be inserted.
188 void createPage(ElementType _eType
,const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>& _xContainer
);
190 void setTaskExternalMnemonics( MnemonicGenerator
& _rMnemonics
);
192 /** called to give the window the chance to intercept key events, while it has not
195 @return <TRUE/> if and only if the event has been handled, and should not
196 not be further processed
198 bool interceptKeyInput( const KeyEvent
& _rEvent
);
200 inline OAppBorderWindow
& getBorderWin() const { return m_rBorderWin
; }
201 inline OTasksWindow
& getTasksWindow() const { return *static_cast< OTasksWindow
* >( m_aTasks
.getChildWindow() ); }
203 sal_Bool
isCutAllowed() ;
204 sal_Bool
isCopyAllowed() ;
205 sal_Bool
isPasteAllowed();
206 virtual sal_Bool
hasChildPathFocus() { return HasChildPathFocus(); }
211 /** return the qualified name.
213 The entry of a table, or query, form, report to get the qualified name.
214 If the entry is <NULL/>, the first selected is chosen.
218 ::rtl::OUString
getQualifiedName( SvLBoxEntry
* _pEntry
) const;
220 /** returns if an entry is a leaf
224 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
226 sal_Bool
isLeaf(SvLBoxEntry
* _pEntry
) const;
228 /** returns if one of the selected entries is a leaf
230 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
232 sal_Bool
isALeafSelected() const;
234 /** select all entries in the detail page
238 /// returns <TRUE/> if it sorts ascending
239 sal_Bool
isSortUp() const;
241 /// sort the entries in the detail page down
244 /// sort the entries in the detail page up
247 /// returns <TRUE/> when a detail page was filled
248 sal_Bool
isFilled() const;
250 /// return the element of currently select entry
251 ElementType
getElementType() const;
253 /** clears the detail pages.
255 If <TRUE/> the task window will also be cleared.
257 void clearPages(sal_Bool _bTaskAlso
= sal_True
);
259 /// returns the count of entries
260 sal_Int32
getElementCount();
262 /// returns the count of selected entries
263 sal_Int32
getSelectionCount();
265 /** returns the element names which are selected
267 The list will be filled.
269 void getSelectionElementNames(::std::vector
< ::rtl::OUString
>& _rNames
) const;
271 /** describes the current selection for the given control
273 void describeCurrentSelectionForControl(
274 const Control
& _rControl
,
275 ::com::sun::star::uno::Sequence
< ::com::sun::star::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
278 /** describes the current selection for the given ElementType
280 void describeCurrentSelectionForType(
281 const ElementType _eType
,
282 ::com::sun::star::uno::Sequence
< ::com::sun::star::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
285 /** select all names on the currently selected container. Non existence names where ignored.
287 * \param _aNames the element names
289 void selectElements(const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& _aNames
);
291 /** adds a new object to the detail page.
293 The type where the entry shold be appended.
295 The name of the object to be inserted
299 If we insert a table, the connection must be set.
301 SvLBoxEntry
* elementAdded(ElementType eType
302 ,const ::rtl::OUString
& _rName
303 ,const ::com::sun::star::uno::Any
& _rObject
);
305 /** replaces a objects name with a new one
307 The type where the entry shold be appended.
309 The old name of the object to be replaced
311 The new name of the object to be replaced
313 If we insert a table, the connection must be set.
315 The object which was replaced
317 void elementReplaced(ElementType eType
318 ,const ::rtl::OUString
& _rOldName
319 ,const ::rtl::OUString
& _rNewName
);
321 /** removes an element from the detail page.
323 The type where the entry shold be appended.
325 The name of the element to be removed.
327 If we remove a table, the connection must be set.
329 void elementRemoved(ElementType _eType
330 ,const ::rtl::OUString
& _rName
);
332 /// returns the preview mode
333 PreviewMode
getPreviewMode();
335 /// <TRUE/> if the preview is enabled
336 sal_Bool
isPreviewEnabled();
339 /** switches to the given preview mode
341 the mode to set for the preview
343 void switchPreview(PreviewMode _eMode
);
345 /** shows the Preview of the content when it is enabled.
347 The content which must support the "preview" command.
349 void showPreview(const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XContent
>& _xContent
);
351 /** shows the Preview of a table or query
352 @param _sDataSourceName
353 the name of the data source
355 the name of table or query
357 <TRUE/> if it is a table, otherwise <FALSE/>
360 void showPreview( const ::rtl::OUString
& _sDataSourceName
,
361 const ::rtl::OUString
& _sName
,
364 SvLBoxEntry
* getEntry( const Point
& _aPoint
) const;
366 Window
* getTreeWindow() const;
368 void impl_createPage(
370 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
,
371 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>& _rxNonTableElements
374 const TaskPaneData
& impl_getTaskPaneData( ElementType _eType
);
375 void impl_fillTaskPaneData( ElementType _eType
, TaskPaneData
& _rData
) const;
378 #endif // DBAUI_APPDETAILVIEW_HXX
380 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */