Update ooo320-m1
[ooovba.git] / dbaccess / source / ui / app / AppDetailPageHelper.hxx
blobb36d5ea75d215757f6a2d3d03909faa3e2ba73d8
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: AppDetailPageHelper.hxx,v $
10 * $Revision: 1.15 $
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_APPDETAILPAGEHELPER_HXX
31 #define DBAUI_APPDETAILPAGEHELPER_HXX
33 #include <vector>
35 #ifndef _RTL_USTRING_HXX_
36 #include <rtl/ustring.hxx>
37 #endif
38 #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
39 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
40 #endif
41 #ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_
42 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
43 #endif
44 #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
45 #include <com/sun/star/ucb/XContent.hpp>
46 #endif
47 #ifndef DBAUI_APPELEMENTTYPE_HXX
48 #include "AppElementType.hxx"
49 #endif
50 #ifndef _SVTREEBOX_HXX
51 #include <svtools/svtreebx.hxx>
52 #endif
53 #ifndef SVTOOLS_DOCUMENTINFOPREVIEW_HXX
54 #include <svtools/DocumentInfoPreview.hxx>
55 #endif
56 #ifndef _SV_FIXED_HXX
57 #include <vcl/fixed.hxx>
58 #endif
59 #ifndef _SV_TOOLBOX_HXX
60 #include <vcl/toolbox.hxx>
61 #endif
62 #ifndef _SV_CVTGRF_HXX
63 #include <vcl/cvtgrf.hxx>
64 #endif
65 #ifndef _SV_GRAPH_HXX
66 #include <vcl/graph.hxx>
67 #endif
68 #ifndef _GRFMGR_HXX
69 #include <goodies/grfmgr.hxx>
70 #endif
71 #include "callbacks.hxx"
72 #include <memory>
74 namespace com{ namespace sun { namespace star { namespace awt { class XWindow; } } } }
75 namespace com{ namespace sun { namespace star { namespace frame { class XFrame; } } } }
76 namespace com{ namespace sun { namespace star { namespace io { class XPersist; } } } }
78 #define ELEMENT_COUNT size_t(E_ELEMENT_TYPE_COUNT)
80 namespace dbaui
82 class OAppBorderWindow;
83 class DBTreeListBox;
85 class OPreviewWindow : public Window
87 GraphicObject m_aGraphicObj;
88 Rectangle m_aPreviewRect;
90 /** gets the graphic cnter rect
91 @param rGraphic
92 the graphic
93 @param rResultRect
94 the resulting rectangle
96 @return
97 <TRUE/> when successfull
99 BOOL ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const;
100 void ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );
101 protected:
102 virtual void DataChanged(const DataChangedEvent& rDCEvt);
103 public:
104 OPreviewWindow(Window* _pParent);
106 // window overloads
107 virtual void Paint(const Rectangle& rRect);
109 void setGraphic(const Graphic& _rGraphic ) { m_aGraphicObj.SetGraphic(_rGraphic); }
111 //==================================================================
112 // A helper class for the controls in the detail page.
113 // Combines general functionality.
114 //==================================================================
115 class OAppDetailPageHelper : public Window
117 DBTreeListBox* m_pLists[ELEMENT_COUNT];
118 OAppBorderWindow& m_rBorderWin;
119 FixedLine m_aFL;
120 ToolBox m_aTBPreview;
121 Window m_aBorder;
122 OPreviewWindow m_aPreview;
123 ::svtools::ODocumentInfoPreview
124 m_aDocumentInfo;
125 Window* m_pTablePreview;
126 ::std::auto_ptr<PopupMenu> m_aMenu;
127 PreviewMode m_ePreviewMode;
128 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >
129 m_xFrame;
130 ::com::sun::star::uno::Reference < ::com::sun::star::io::XPersist >
131 m_xDocInfo;
132 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >
133 m_xWindow;
135 /// returns the index of the visible control
136 int getVisibleControlIndex() const;
138 /** sorts the entries in the tree list box.
139 @param _nPos
140 Which list should be sorted.
141 @param _eSortMode
142 How should be sorted.
144 void sort(int _nPos,SvSortMode _eSortMode );
146 /** retrieves the resource ids of the images representing elements of the given type
148 void getElementIcons( ElementType _eType, USHORT& _rImageId, USHORT& _rHighContrastImageId );
150 /** fills the names in the listbox
151 @param _xContainer
152 This can either be the queries, forms or report names.
153 @param _eType
154 the type of elements which are being filled
155 @param _nImageId
156 the resource id of the image to use for non-container entries
157 @param _nHighContrastImageId
158 the resource id of the high contrast image to use for non-container entries
159 @param _pParent
160 The parent of the entries to be inserted.
162 void fillNames( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer,
163 const ElementType _eType,
164 const USHORT _nImageId,
165 const USHORT _nHighContrastImageId,
166 SvLBoxEntry* _pParent );
168 /** sets the detail page
169 @param _pWindow
170 The control which should be visible.
172 void setDetailPage(Window* _pWindow);
174 /** sets all HandleCallbacks
175 @param _pTreeView
176 The newly created DBTreeListBox
177 @param _rImage
178 the resource id of the default icon
179 @param _rImageHC
180 the resource id of the default icon (HC version)
181 @return
182 The new tree.
184 DBTreeListBox* createTree( DBTreeListBox* _pTreeView, const Image& _rImage, const Image& _rImageHC );
186 /** creates the tree and sets all HandleCallbacks
187 @param _nHelpId
188 The help id of the control
189 @param _nCollapsedBitmap
190 The image to use for tree entries.
191 @param _rImageHC
192 The image to use in high contrast mode.
193 @return
194 The new tree.
196 DBTreeListBox* createSimpleTree( ULONG _nHelpId, const Image& _rImage, const Image& _rImageHC );
198 DECL_LINK( OnEntryDoubleClick, SvTreeListBox* );
199 DECL_LINK( OnEntrySelChange, void* );
201 DECL_LINK( OnCutEntry, void* );
202 DECL_LINK( OnCopyEntry, void* );
203 DECL_LINK( OnPasteEntry, void* );
204 DECL_LINK( OnDeleteEntry, void* );
206 DECL_LINK(PreviewChangeHdl, void*);
207 // click a TB slot
208 DECL_LINK(OnDropdownClickHdl, ToolBox*);
210 inline OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
211 void ImplInitSettings();
213 public:
214 OAppDetailPageHelper(Window* _pParent,OAppBorderWindow& _rBorderWin,PreviewMode _ePreviewMode);
215 virtual ~OAppDetailPageHelper();
217 // window overloads
218 virtual void Resize();
219 virtual void KeyInput( const KeyEvent& rKEvt );
221 sal_Bool isCutAllowed();
222 sal_Bool isCopyAllowed();
223 sal_Bool isPasteAllowed();
224 void copy();
225 void cut();
226 void paste();
228 /** creates the tables page
229 @param _xConnection
230 The connection to get the table names
232 void createTablesPage(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
234 /** creates the page for the specific type.
235 @param _eType
236 The type which should be created. E_TABLE isn't allowed.
237 @param _xContainer
238 The container of the elements to be inserted.
240 void createPage(ElementType _eType,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer);
242 /** returns the current visible tree list box
244 inline DBTreeListBox* getCurrentView() const
246 ElementType eType = getElementType();
247 return (eType != E_NONE ) ? m_pLists[static_cast<sal_Int32>(eType)] : NULL;
250 /// select all entries in the visible control
251 void selectAll();
253 /// returns <TRUE/> if it sorts ascending
254 sal_Bool isSortUp() const;
256 /// sorts all entries ascending
257 void sortDown();
259 /// sorts all entries descending
260 void sortUp();
262 /** returns the element names which are selected
263 @param _rNames
264 The list will be filled.
266 void getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const;
268 /** describes the current selection for the given control
270 void describeCurrentSelectionForControl(
271 const Control& _rControl,
272 ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
275 /** describes the current selection for the given ElementType
277 void describeCurrentSelectionForType(
278 const ElementType _eType,
279 ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
282 /** select all names on the currently selected container. Non existence names where ignored.
284 * \param _aNames the element names
286 void selectElements(const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aNames);
288 /** return the qualified name.
289 @param _pEntry
290 The entry of a table, or query, form, report to get the qualified name.
291 If the entry is <NULL/>, the first selected is chosen.
292 @return
293 the qualified name
295 ::rtl::OUString getQualifiedName( SvLBoxEntry* _pEntry ) const;
297 /// return the element of currently select entry
298 ElementType getElementType() const;
300 /// returns the count of selected entries
301 sal_Int32 getSelectionCount();
303 /// returns the count of entries
304 sal_Int32 getElementCount();
306 /** returns if an entry is a leaf
307 @param _pEntry
308 The entry to check
309 @return
310 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
312 bool isLeaf(SvLBoxEntry* _pEntry) const;
314 /** returns if one of the selected entries is a leaf
315 @return
316 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
318 sal_Bool isALeafSelected() const;
320 SvLBoxEntry* getEntry( const Point& _aPosPixel ) const;
322 /// clears the detail pages
323 void clearPages();
325 /// returns <TRUE/> when a detail page was filled
326 sal_Bool isFilled() const;
328 /** adds a new object to the detail page.
329 @param _eType
330 The type where the entry shold be appended.
331 @param _rName
332 The name of the object to be inserted
333 @param _rObject
334 The object to add.
335 @param _rxConn
336 If we insert a table, the connection must be set.
338 SvLBoxEntry* elementAdded(ElementType eType
339 ,const ::rtl::OUString& _rName
340 ,const ::com::sun::star::uno::Any& _rObject );
342 /** replaces a objects name with a new one
343 @param _eType
344 The type where the entry shold be appended.
345 @param _rOldName
346 The old name of the object to be replaced
347 @param _rNewName
348 The new name of the object to be replaced
349 @param _rxConn
350 If we insert a table, the connection must be set.
352 void elementReplaced(ElementType eType
353 ,const ::rtl::OUString& _rOldName
354 ,const ::rtl::OUString& _rNewName );
356 /** removes an element from the detail page.
357 @param _eType
358 The type where the entry shold be appended.
359 @param _rName
360 The name of the element to be removed.
361 @param _rxConn
362 If we remove a table, the connection must be set.
364 void elementRemoved(ElementType _eType
365 ,const ::rtl::OUString& _rName );
368 /// returns the preview mode
369 PreviewMode getPreviewMode();
371 /// <TRUE/> if the preview is enabled
372 sal_Bool isPreviewEnabled();
374 /** switches to the given preview mode
375 @param _eMode
376 the mode to set for the preview
377 @param _bForce
378 Force the preview to be resetted
380 void switchPreview(PreviewMode _eMode,BOOL _bForce = FALSE);
382 /** shows the Preview of the content when it is enabled.
383 @param _xContent
384 The content which must support the "preview" command.
386 void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
388 /** shows the Preview of a table or query
389 @param _sDataSourceName
390 the name of the data source
391 @param _sName
392 the name of table or query
393 @param _bTable
394 <TRUE/> if it is a table, otherwise <FALSE/>
395 @return void
397 void showPreview( const ::rtl::OUString& _sDataSourceName,
398 const ::rtl::OUString& _sName,
399 sal_Bool _bTable);
401 protected:
402 void DataChanged( const DataChangedEvent& rDCEvt );
405 #endif // DBAUI_APPDETAILPAGEHELPER_HXX