fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / app / AppDetailView.hxx
blob3b4286abe7aca7bee0958a45d7a39914cbdae26d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_DBACCESS_SOURCE_UI_APP_APPDETAILVIEW_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_APP_APPDETAILVIEW_HXX
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"
36 #include <vector>
38 class SvTreeListEntry;
40 namespace dbaui
42 class OAppBorderWindow;
43 class OApplicationDetailView;
44 class OAppDetailPageHelper;
45 class OTasksWindow;
47 class OCreationList : public SvTreeListBox
49 OTasksWindow& m_rTaskWindow;
51 // members related to drawing the currently hovered/selected entry
52 SvTreeListEntry* m_pMouseDownEntry;
53 SvTreeListEntry* m_pLastActiveEntry;
54 Color m_aOriginalBackgroundColor;
55 vcl::Font m_aOriginalFont;
57 public:
58 OCreationList( OTasksWindow& _rParent );
59 // Window overrides
60 virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
61 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
62 virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
63 virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
64 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
65 virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) SAL_OVERRIDE;
66 virtual void GetFocus() SAL_OVERRIDE;
67 virtual void LoseFocus() SAL_OVERRIDE;
69 inline void resetLastActive() { m_pLastActiveEntry = NULL;}
71 void updateHelpText();
73 protected:
74 virtual void PreparePaint(vcl::RenderContext& rRenderContext, SvTreeListEntry* _pEntry) SAL_OVERRIDE;
75 virtual Rectangle GetFocusRect( SvTreeListEntry* _pEntry, long _nLine ) SAL_OVERRIDE;
76 virtual void ModelHasCleared() SAL_OVERRIDE;
78 // IMnemonicEntryList
79 virtual void SelectSearchEntry( const void* _pEntry ) SAL_OVERRIDE;
80 virtual void ExecuteSearchEntry( const void* _pEntry ) const SAL_OVERRIDE;
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
87 bool setCurrentEntryInvalidate( SvTreeListEntry* _pEntry );
90 struct TaskEntry
92 OUString sUNOCommand;
93 sal_uInt16 nHelpID;
94 OUString 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.
100 TaskEntry( const sal_Char* _pAsciiUNOCommand, sal_uInt16 _nHelpID, sal_uInt16 _nTitleResourceID, bool _bHideWhenDisabled = false );
102 typedef ::std::vector< TaskEntry > TaskEntryList;
104 struct TaskPaneData
106 /// the tasks available in the pane
107 TaskEntryList aTasks;
108 /// the resource ID for the title of the pane
109 sal_uInt16 nTitleId;
112 class OTasksWindow : public vcl::Window
114 VclPtr<OCreationList> m_aCreation;
115 VclPtr<FixedText> m_aDescription;
116 VclPtr<FixedText> m_aHelpText;
117 VclPtr<FixedLine> m_aFL;
118 VclPtr<OApplicationDetailView> m_pDetailView;
120 DECL_LINK( OnEntrySelectHdl, SvTreeListBox* );
121 void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
122 protected:
123 virtual void DataChanged(const DataChangedEvent& rDCEvt) SAL_OVERRIDE;
124 public:
125 OTasksWindow(vcl::Window* _pParent,OApplicationDetailView* _pDetailView);
126 virtual ~OTasksWindow();
127 virtual void dispose() SAL_OVERRIDE;
129 // Window overrides
130 virtual void Resize() SAL_OVERRIDE;
132 OApplicationDetailView* getDetailView() const { return m_pDetailView; }
134 /// fills the Creation listbox with the necessary strings and images
135 void fillTaskEntryList( const TaskEntryList& _rList );
137 inline bool HandleKeyInput( const KeyEvent& _rKEvt )
139 return m_aCreation->HandleKeyInput( _rKEvt );
142 void Clear();
143 void setHelpText(sal_uInt16 _nId);
145 class OApplicationDetailView : public OSplitterView
146 , public IClipboardTest
148 VclPtr<Splitter> m_aHorzSplitter;
149 VclPtr<OTitleWindow> m_aTasks;
150 VclPtr<OTitleWindow> m_aContainer;
151 OAppBorderWindow& m_rBorderWin; // my parent
152 VclPtr<OAppDetailPageHelper> m_pControlHelper;
153 ::std::vector< TaskPaneData > m_aTaskPaneData;
154 MnemonicGenerator m_aExternalMnemonics;
156 void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
158 protected:
159 virtual void DataChanged(const DataChangedEvent& rDCEvt) SAL_OVERRIDE;
161 public:
162 OApplicationDetailView(OAppBorderWindow& _rParent,PreviewMode _ePreviewMode);
163 virtual ~OApplicationDetailView();
164 // Window overrides
165 virtual void dispose() SAL_OVERRIDE;
166 virtual void GetFocus() SAL_OVERRIDE;
168 /** creates the tables page
169 @param _xConnection
170 The connection to get the table names
172 void createTablesPage(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
174 /** creates the page for the specific type.
175 @param _eType
176 The type which should be created. E_TABLE isn't allowed.
177 @param _xContainer
178 The container of the elements to be inserted.
180 void createPage(ElementType _eType,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer);
182 void setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics );
184 /** called to give the window the chance to intercept key events, while it has not
185 the focus
187 @return <TRUE/> if and only if the event has been handled, and should not
188 not be further processed
190 bool interceptKeyInput( const KeyEvent& _rEvent );
192 inline OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
193 inline OTasksWindow& getTasksWindow() const { return *static_cast< OTasksWindow* >( m_aTasks->getChildWindow() ); }
195 bool isCutAllowed() SAL_OVERRIDE ;
196 bool isCopyAllowed() SAL_OVERRIDE ;
197 bool isPasteAllowed() SAL_OVERRIDE;
198 virtual bool hasChildPathFocus() SAL_OVERRIDE { return HasChildPathFocus(); }
199 void copy() SAL_OVERRIDE;
200 void cut() SAL_OVERRIDE;
201 void paste() SAL_OVERRIDE;
203 /** return the qualified name.
204 @param _pEntry
205 The entry of a table, or query, form, report to get the qualified name.
206 If the entry is <NULL/>, the first selected is chosen.
207 @return
208 the qualified name
210 OUString getQualifiedName( SvTreeListEntry* _pEntry ) const;
212 /** returns if an entry is a leaf
213 @param _pEntry
214 The entry to check
215 @return
216 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
218 static bool isLeaf(SvTreeListEntry* _pEntry);
220 /** returns if one of the selected entries is a leaf
221 @return
222 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
224 bool isALeafSelected() const;
226 /** select all entries in the detail page
228 void selectAll();
230 /// returns <TRUE/> if it sorts ascending
231 bool isSortUp() const;
233 /// sort the entries in the detail page down
234 void sortDown();
236 /// sort the entries in the detail page up
237 void sortUp();
239 /// returns <TRUE/> when a detail page was filled
240 bool isFilled() const;
242 /// return the element of currently select entry
243 ElementType getElementType() const;
245 /** clears the detail pages.
246 @param _bTaskAlso
247 If <TRUE/> the task window will also be cleared.
249 void clearPages(bool _bTaskAlso = true);
251 /// returns the count of entries
252 sal_Int32 getElementCount();
254 /// returns the count of selected entries
255 sal_Int32 getSelectionCount();
257 /** returns the element names which are selected
258 @param _rNames
259 The list will be filled.
261 void getSelectionElementNames(::std::vector< OUString>& _rNames ) const;
263 /** describes the current selection for the given control
265 void describeCurrentSelectionForControl(
266 const Control& _rControl,
267 ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
270 /** describes the current selection for the given ElementType
272 void describeCurrentSelectionForType(
273 const ElementType _eType,
274 ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
277 /** select all names on the currently selected container. Non existence names where ignored.
279 * \param _aNames the element names
281 void selectElements(const ::com::sun::star::uno::Sequence< OUString>& _aNames);
283 /** adds a new object to the detail page.
284 @param _eType
285 The type where the entry shold be appended.
286 @param _rName
287 The name of the object to be inserted
288 @param _rObject
289 The object to add.
290 @param _rxConn
291 If we insert a table, the connection must be set.
293 SvTreeListEntry* elementAdded(ElementType eType
294 ,const OUString& _rName
295 ,const ::com::sun::star::uno::Any& _rObject );
297 /** replaces a objects name with a new one
298 @param _eType
299 The type where the entry shold be appended.
300 @param _rOldName
301 The old name of the object to be replaced
302 @param _rNewName
303 The new name of the object to be replaced
304 @param _rxConn
305 If we insert a table, the connection must be set.
306 @param _xObject
307 The object which was replaced
309 void elementReplaced(ElementType eType
310 ,const OUString& _rOldName
311 ,const OUString& _rNewName );
313 /** removes an element from the detail page.
314 @param _eType
315 The type where the entry shold be appended.
316 @param _rName
317 The name of the element to be removed.
318 @param _rxConn
319 If we remove a table, the connection must be set.
321 void elementRemoved(ElementType _eType
322 ,const OUString& _rName );
324 /// returns the preview mode
325 PreviewMode getPreviewMode();
327 /// <TRUE/> if the preview is enabled
328 bool isPreviewEnabled();
330 /** switches to the given preview mode
331 @param _eMode
332 the mode to set for the preview
334 void switchPreview(PreviewMode _eMode);
336 /** shows the Preview of the content when it is enabled.
337 @param _xContent
338 The content which must support the "preview" command.
340 void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
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
351 void showPreview( const OUString& _sDataSourceName,
352 const OUString& _sName,
353 bool _bTable);
355 SvTreeListEntry* getEntry( const Point& _aPoint ) const;
357 vcl::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
365 const TaskPaneData& impl_getTaskPaneData( ElementType _eType );
366 void impl_fillTaskPaneData( ElementType _eType, TaskPaneData& _rData ) const;
369 #endif // INCLUDED_DBACCESS_SOURCE_UI_APP_APPDETAILVIEW_HXX
371 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */