Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef DBAUI_APPDETAILVIEW_HXX
20 : #define DBAUI_APPDETAILVIEW_HXX
21 :
22 : #include <com/sun/star/frame/XController.hpp>
23 : #include <com/sun/star/container/XNameAccess.hpp>
24 : #include <com/sun/star/sdbc/XConnection.hpp>
25 : #include <com/sun/star/ucb/XContent.hpp>
26 : #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
27 : #include <vcl/split.hxx>
28 : #include <vcl/fixed.hxx>
29 : #include <vcl/mnemonic.hxx>
30 : #include "IClipBoardTest.hxx"
31 : #include "AppTitleWindow.hxx"
32 : #include "AppElementType.hxx"
33 : #include <svtools/treelistbox.hxx>
34 : #include "VertSplitView.hxx"
35 :
36 : #include <vector>
37 :
38 : class SvTreeListEntry;
39 :
40 : namespace dbaui
41 : {
42 : class OAppBorderWindow;
43 : class OApplicationDetailView;
44 : class OAppDetailPageHelper;
45 : class OTasksWindow;
46 :
47 0 : class OCreationList : public SvTreeListBox
48 : {
49 : OTasksWindow& m_rTaskWindow;
50 :
51 : // members related to drawing the currently hovered/selected entry
52 : SvTreeListEntry* m_pMouseDownEntry;
53 : SvTreeListEntry* m_pLastActiveEntry;
54 : Color m_aOriginalBackgroundColor;
55 : Font m_aOriginalFont;
56 :
57 : public:
58 : OCreationList( OTasksWindow& _rParent );
59 : // window overloads
60 : virtual void MouseMove( const MouseEvent& rMEvt );
61 : virtual void MouseButtonDown( const MouseEvent& rMEvt );
62 : virtual void MouseButtonUp( const MouseEvent& rMEvt );
63 : virtual void KeyInput( const KeyEvent& rKEvt );
64 : virtual void Paint( const Rectangle& rRect );
65 : virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel );
66 : virtual void GetFocus();
67 : virtual void LoseFocus();
68 :
69 0 : inline void resetLastActive() { m_pLastActiveEntry = NULL;}
70 :
71 : void updateHelpText();
72 :
73 : protected:
74 : virtual void PreparePaint( SvTreeListEntry* _pEntry );
75 : virtual Rectangle GetFocusRect( SvTreeListEntry* _pEntry, long _nLine );
76 : virtual void ModelHasCleared();
77 :
78 : // IMnemonicEntryList
79 : virtual void SelectSearchEntry( const void* _pEntry );
80 : virtual void ExecuteSearchEntry( const void* _pEntry ) const;
81 :
82 : private:
83 : void onSelected( SvTreeListEntry* _pEntry ) const;
84 : /** sets a new current entry, and invalidates the old and the new one, if necessary
85 : @return <TRUE/> if and only if the "current entry" changed
86 : */
87 : bool setCurrentEntryInvalidate( SvTreeListEntry* _pEntry );
88 : };
89 :
90 0 : struct TaskEntry
91 : {
92 : ::rtl::OUString sUNOCommand;
93 : sal_uInt16 nHelpID;
94 : String sTitle;
95 : bool bHideWhenDisabled;
96 : // TODO: we should be consistent in the task pane and the menus/toolbars:
97 : // If an entry is disabled in the latter, it should also be disabled in the former.
98 : // If an entry is *hidden* in the former, it should also be hidden in the latter.
99 :
100 : TaskEntry( const sal_Char* _pAsciiUNOCommand, sal_uInt16 _nHelpID, sal_uInt16 _nTitleResourceID, bool _bHideWhenDisabled = false );
101 : };
102 : typedef ::std::vector< TaskEntry > TaskEntryList;
103 :
104 0 : struct TaskPaneData
105 : {
106 : /// the tasks available in the pane
107 : TaskEntryList aTasks;
108 : /// the resource ID for the title of the pane
109 : sal_uInt16 nTitleId;
110 : };
111 :
112 : class OTasksWindow : public Window
113 : {
114 : OCreationList m_aCreation;
115 : FixedText m_aDescription;
116 : FixedText m_aHelpText;
117 : FixedLine m_aFL;
118 : OApplicationDetailView* m_pDetailView;
119 :
120 : DECL_LINK( OnEntrySelectHdl, SvTreeListBox* );
121 : void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
122 : protected:
123 : virtual void DataChanged(const DataChangedEvent& rDCEvt);
124 : public:
125 : OTasksWindow(Window* _pParent,OApplicationDetailView* _pDetailView);
126 : virtual ~OTasksWindow();
127 :
128 : // window overloads
129 : virtual void Resize();
130 :
131 0 : OApplicationDetailView* getDetailView() const { return m_pDetailView; }
132 :
133 : /// fills the Creation listbox with the necessary strings and images
134 : void fillTaskEntryList( const TaskEntryList& _rList );
135 :
136 0 : inline bool HandleKeyInput( const KeyEvent& _rKEvt )
137 : {
138 0 : return m_aCreation.HandleKeyInput( _rKEvt );
139 : }
140 :
141 : void Clear();
142 : void setHelpText(sal_uInt16 _nId);
143 : };
144 : //==================================================================
145 : class OApplicationDetailView : public OSplitterView
146 : , public IClipboardTest
147 : {
148 : Splitter m_aHorzSplitter;
149 : OTitleWindow m_aTasks;
150 : OTitleWindow m_aContainer;
151 : OAppBorderWindow& m_rBorderWin; // my parent
152 : OAppDetailPageHelper* m_pControlHelper;
153 : ::std::vector< TaskPaneData > m_aTaskPaneData;
154 : MnemonicGenerator m_aExternalMnemonics;
155 :
156 : void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
157 :
158 : protected:
159 : virtual void DataChanged(const DataChangedEvent& rDCEvt);
160 :
161 : public:
162 : OApplicationDetailView(OAppBorderWindow& _rParent,PreviewMode _ePreviewMode);
163 : virtual ~OApplicationDetailView();
164 : // window overloads
165 : virtual void GetFocus();
166 :
167 : /** creates the tables page
168 : @param _xConnection
169 : The connection to get the table names
170 : */
171 : void createTablesPage(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
172 :
173 : /** creates the page for the specific type.
174 : @param _eType
175 : The type which should be created. E_TABLE isn't allowed.
176 : @param _xContainer
177 : The container of the elements to be inserted.
178 : */
179 : void createPage(ElementType _eType,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer);
180 :
181 : void setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics );
182 :
183 : /** called to give the window the chance to intercept key events, while it has not
184 : the focus
185 :
186 : @return <TRUE/> if and only if the event has been handled, and should not
187 : not be further processed
188 : */
189 : bool interceptKeyInput( const KeyEvent& _rEvent );
190 :
191 0 : inline OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
192 0 : inline OTasksWindow& getTasksWindow() const { return *static_cast< OTasksWindow* >( m_aTasks.getChildWindow() ); }
193 :
194 : sal_Bool isCutAllowed() ;
195 : sal_Bool isCopyAllowed() ;
196 : sal_Bool isPasteAllowed();
197 0 : virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
198 : void copy();
199 : void cut();
200 : void paste();
201 :
202 : /** return the qualified name.
203 : @param _pEntry
204 : The entry of a table, or query, form, report to get the qualified name.
205 : If the entry is <NULL/>, the first selected is chosen.
206 : @return
207 : the qualified name
208 : */
209 : ::rtl::OUString getQualifiedName( SvTreeListEntry* _pEntry ) const;
210 :
211 : /** returns if an entry is a leaf
212 : @param _pEntry
213 : The entry to check
214 : @return
215 : <TRUE/> if the entry is a leaf, otherwise <FALSE/>
216 : */
217 : sal_Bool isLeaf(SvTreeListEntry* _pEntry) const;
218 :
219 : /** returns if one of the selected entries is a leaf
220 : @return
221 : <TRUE/> if the entry is a leaf, otherwise <FALSE/>
222 : */
223 : sal_Bool isALeafSelected() const;
224 :
225 : /** select all entries in the detail page
226 : */
227 : void selectAll();
228 :
229 : /// returns <TRUE/> if it sorts ascending
230 : sal_Bool isSortUp() const;
231 :
232 : /// sort the entries in the detail page down
233 : void sortDown();
234 :
235 : /// sort the entries in the detail page up
236 : void sortUp();
237 :
238 : /// returns <TRUE/> when a detail page was filled
239 : sal_Bool isFilled() const;
240 :
241 : /// return the element of currently select entry
242 : ElementType getElementType() const;
243 :
244 : /** clears the detail pages.
245 : @param _bTaskAlso
246 : If <TRUE/> the task window will also be cleared.
247 : */
248 : void clearPages(sal_Bool _bTaskAlso = sal_True);
249 :
250 : /// returns the count of entries
251 : sal_Int32 getElementCount();
252 :
253 : /// returns the count of selected entries
254 : sal_Int32 getSelectionCount();
255 :
256 : /** returns the element names which are selected
257 : @param _rNames
258 : The list will be filled.
259 : */
260 : void getSelectionElementNames(::std::vector< ::rtl::OUString>& _rNames ) const;
261 :
262 : /** describes the current selection for the given control
263 : */
264 : void describeCurrentSelectionForControl(
265 : const Control& _rControl,
266 : ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
267 : );
268 :
269 : /** describes the current selection for the given ElementType
270 : */
271 : void describeCurrentSelectionForType(
272 : const ElementType _eType,
273 : ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
274 : );
275 :
276 : /** select all names on the currently selected container. Non existence names where ignored.
277 : *
278 : * \param _aNames the element names
279 : */
280 : void selectElements(const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aNames);
281 :
282 : /** adds a new object to the detail page.
283 : @param _eType
284 : The type where the entry shold be appended.
285 : @param _rName
286 : The name of the object to be inserted
287 : @param _rObject
288 : The object to add.
289 : @param _rxConn
290 : If we insert a table, the connection must be set.
291 : */
292 : SvTreeListEntry* elementAdded(ElementType eType
293 : ,const ::rtl::OUString& _rName
294 : ,const ::com::sun::star::uno::Any& _rObject );
295 :
296 : /** replaces a objects name with a new one
297 : @param _eType
298 : The type where the entry shold be appended.
299 : @param _rOldName
300 : The old name of the object to be replaced
301 : @param _rNewName
302 : The new name of the object to be replaced
303 : @param _rxConn
304 : If we insert a table, the connection must be set.
305 : @param _xObject
306 : The object which was replaced
307 : */
308 : void elementReplaced(ElementType eType
309 : ,const ::rtl::OUString& _rOldName
310 : ,const ::rtl::OUString& _rNewName );
311 :
312 : /** removes an element from the detail page.
313 : @param _eType
314 : The type where the entry shold be appended.
315 : @param _rName
316 : The name of the element to be removed.
317 : @param _rxConn
318 : If we remove a table, the connection must be set.
319 : */
320 : void elementRemoved(ElementType _eType
321 : ,const ::rtl::OUString& _rName );
322 :
323 : /// returns the preview mode
324 : PreviewMode getPreviewMode();
325 :
326 : /// <TRUE/> if the preview is enabled
327 : sal_Bool isPreviewEnabled();
328 :
329 :
330 : /** switches to the given preview mode
331 : @param _eMode
332 : the mode to set for the preview
333 : */
334 : void switchPreview(PreviewMode _eMode);
335 :
336 : /** shows the Preview of the content when it is enabled.
337 : @param _xContent
338 : The content which must support the "preview" command.
339 : */
340 : void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
341 :
342 : /** shows the Preview of a table or query
343 : @param _sDataSourceName
344 : the name of the data source
345 : @param _sName
346 : the name of table or query
347 : @param _bTable
348 : <TRUE/> if it is a table, otherwise <FALSE/>
349 : @return void
350 : */
351 : void showPreview( const ::rtl::OUString& _sDataSourceName,
352 : const ::rtl::OUString& _sName,
353 : sal_Bool _bTable);
354 :
355 : SvTreeListEntry* getEntry( const Point& _aPoint ) const;
356 :
357 : Window* getTreeWindow() const;
358 : private:
359 : void impl_createPage(
360 : ElementType _eType,
361 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
362 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxNonTableElements
363 : );
364 :
365 : const TaskPaneData& impl_getTaskPaneData( ElementType _eType );
366 : void impl_fillTaskPaneData( ElementType _eType, TaskPaneData& _rData ) const;
367 : };
368 : }
369 : #endif // DBAUI_APPDETAILVIEW_HXX
370 :
371 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|