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: AppDetailPageHelper.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_APPDETAILPAGEHELPER_HXX
31 #define DBAUI_APPDETAILPAGEHELPER_HXX
35 #ifndef _RTL_USTRING_HXX_
36 #include <rtl/ustring.hxx>
38 #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
39 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
41 #ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_
42 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
44 #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
45 #include <com/sun/star/ucb/XContent.hpp>
47 #ifndef DBAUI_APPELEMENTTYPE_HXX
48 #include "AppElementType.hxx"
50 #ifndef _SVTREEBOX_HXX
51 #include <svtools/svtreebx.hxx>
53 #ifndef SVTOOLS_DOCUMENTINFOPREVIEW_HXX
54 #include <svtools/DocumentInfoPreview.hxx>
57 #include <vcl/fixed.hxx>
59 #ifndef _SV_TOOLBOX_HXX
60 #include <vcl/toolbox.hxx>
62 #ifndef _SV_CVTGRF_HXX
63 #include <vcl/cvtgrf.hxx>
66 #include <vcl/graph.hxx>
69 #include <goodies/grfmgr.hxx>
71 #include "callbacks.hxx"
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)
82 class OAppBorderWindow
;
85 class OPreviewWindow
: public Window
87 GraphicObject m_aGraphicObj
;
88 Rectangle m_aPreviewRect
;
90 /** gets the graphic cnter rect
94 the resulting rectangle
97 <TRUE/> when successfull
99 BOOL
ImplGetGraphicCenterRect( const Graphic
& rGraphic
, Rectangle
& rResultRect
) const;
100 void ImplInitSettings( BOOL bFont
, BOOL bForeground
, BOOL bBackground
);
102 virtual void DataChanged(const DataChangedEvent
& rDCEvt
);
104 OPreviewWindow(Window
* _pParent
);
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
;
120 ToolBox m_aTBPreview
;
122 OPreviewWindow m_aPreview
;
123 ::svtools::ODocumentInfoPreview
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
>
130 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XPersist
>
132 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>
135 /// returns the index of the visible control
136 int getVisibleControlIndex() const;
138 /** sorts the entries in the tree list box.
140 Which list should be sorted.
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
152 This can either be the queries, forms or report names.
154 the type of elements which are being filled
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
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
170 The control which should be visible.
172 void setDetailPage(Window
* _pWindow
);
174 /** sets all HandleCallbacks
176 The newly created DBTreeListBox
178 the resource id of the default icon
180 the resource id of the default icon (HC version)
184 DBTreeListBox
* createTree( DBTreeListBox
* _pTreeView
, const Image
& _rImage
, const Image
& _rImageHC
);
186 /** creates the tree and sets all HandleCallbacks
188 The help id of the control
189 @param _nCollapsedBitmap
190 The image to use for tree entries.
192 The image to use in high contrast mode.
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*);
208 DECL_LINK(OnDropdownClickHdl
, ToolBox
*);
210 inline OAppBorderWindow
& getBorderWin() const { return m_rBorderWin
; }
211 void ImplInitSettings();
214 OAppDetailPageHelper(Window
* _pParent
,OAppBorderWindow
& _rBorderWin
,PreviewMode _ePreviewMode
);
215 virtual ~OAppDetailPageHelper();
218 virtual void Resize();
219 virtual void KeyInput( const KeyEvent
& rKEvt
);
221 sal_Bool
isCutAllowed();
222 sal_Bool
isCopyAllowed();
223 sal_Bool
isPasteAllowed();
228 /** creates the tables page
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.
236 The type which should be created. E_TABLE isn't allowed.
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
253 /// returns <TRUE/> if it sorts ascending
254 sal_Bool
isSortUp() const;
256 /// sorts all entries ascending
259 /// sorts all entries descending
262 /** returns the element names which are selected
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.
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.
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
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
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
325 /// returns <TRUE/> when a detail page was filled
326 sal_Bool
isFilled() const;
328 /** adds a new object to the detail page.
330 The type where the entry shold be appended.
332 The name of the object to be inserted
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
344 The type where the entry shold be appended.
346 The old name of the object to be replaced
348 The new name of the object to be replaced
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.
358 The type where the entry shold be appended.
360 The name of the element to be removed.
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
376 the mode to set for the preview
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.
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
392 the name of table or query
394 <TRUE/> if it is a table, otherwise <FALSE/>
397 void showPreview( const ::rtl::OUString
& _sDataSourceName
,
398 const ::rtl::OUString
& _sName
,
402 void DataChanged( const DataChangedEvent
& rDCEvt
);
405 #endif // DBAUI_APPDETAILPAGEHELPER_HXX