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_APPDETAILPAGEHELPER_HXX
29 #define DBAUI_APPDETAILPAGEHELPER_HXX
33 #include <rtl/ustring.hxx>
34 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
35 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
36 #include <com/sun/star/ucb/XContent.hpp>
37 #include "AppElementType.hxx"
38 #include <svtools/svtreebx.hxx>
39 #include <svtools/DocumentInfoPreview.hxx>
40 #include <vcl/fixed.hxx>
41 #include <vcl/toolbox.hxx>
42 #include <vcl/cvtgrf.hxx>
43 #include <vcl/graph.hxx>
44 #include <svtools/grfmgr.hxx>
45 #include "callbacks.hxx"
48 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ class XWindow
; } } } }
49 namespace com
{ namespace sun
{ namespace star
{ namespace frame
{ class XFrame
; } } } }
50 namespace com
{ namespace sun
{ namespace star
{ namespace io
{ class XPersist
; } } } }
52 #define ELEMENT_COUNT size_t(E_ELEMENT_TYPE_COUNT)
56 class OAppBorderWindow
;
59 class OPreviewWindow
: public Window
61 GraphicObject m_aGraphicObj
;
62 Rectangle m_aPreviewRect
;
64 /** gets the graphic cnter rect
68 the resulting rectangle
71 <TRUE/> when successfull
73 sal_Bool
ImplGetGraphicCenterRect( const Graphic
& rGraphic
, Rectangle
& rResultRect
) const;
74 void ImplInitSettings( sal_Bool bFont
, sal_Bool bForeground
, sal_Bool bBackground
);
76 virtual void DataChanged(const DataChangedEvent
& rDCEvt
);
78 OPreviewWindow(Window
* _pParent
);
81 virtual void Paint(const Rectangle
& rRect
);
83 void setGraphic(const Graphic
& _rGraphic
) { m_aGraphicObj
.SetGraphic(_rGraphic
); }
85 //==================================================================
86 // A helper class for the controls in the detail page.
87 // Combines general functionality.
88 //==================================================================
89 class OAppDetailPageHelper
: public Window
91 DBTreeListBox
* m_pLists
[ELEMENT_COUNT
];
92 OAppBorderWindow
& m_rBorderWin
;
96 OPreviewWindow m_aPreview
;
97 ::svtools::ODocumentInfoPreview
99 Window
* m_pTablePreview
;
100 ::std::auto_ptr
<PopupMenu
> m_aMenu
;
101 PreviewMode m_ePreviewMode
;
102 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>
104 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XPersist
>
106 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>
109 /// returns the index of the visible control
110 int getVisibleControlIndex() const;
112 /** sorts the entries in the tree list box.
114 Which list should be sorted.
116 How should be sorted.
118 void sort(int _nPos
,SvSortMode _eSortMode
);
120 /** retrieves the resource ids of the images representing elements of the given type
122 void getElementIcons( ElementType _eType
, sal_uInt16
& _rImageId
);
124 /** fills the names in the listbox
126 This can either be the queries, forms or report names.
128 the type of elements which are being filled
130 the resource id of the image to use for non-container entries
132 The parent of the entries to be inserted.
134 void fillNames( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>& _xContainer
,
135 const ElementType _eType
,
136 const sal_uInt16 _nImageId
,
137 SvLBoxEntry
* _pParent
);
139 /** sets the detail page
141 The control which should be visible.
143 void setDetailPage(Window
* _pWindow
);
145 /** sets all HandleCallbacks
147 The newly created DBTreeListBox
149 the resource id of the default icon
153 DBTreeListBox
* createTree( DBTreeListBox
* _pTreeView
, const Image
& _rImage
);
155 /** creates the tree and sets all HandleCallbacks
157 The help id of the control
158 @param _nCollapsedBitmap
159 The image to use in high contrast mode.
163 DBTreeListBox
* createSimpleTree( const rtl::OString
& _sHelpId
, const Image
& _rImage
);
165 DECL_LINK( OnEntryDoubleClick
, SvTreeListBox
* );
166 DECL_LINK( OnEntrySelChange
, void* );
168 DECL_LINK( OnCutEntry
, void* );
169 DECL_LINK( OnCopyEntry
, void* );
170 DECL_LINK( OnPasteEntry
, void* );
171 DECL_LINK( OnDeleteEntry
, void* );
173 DECL_LINK(PreviewChangeHdl
, void*);
175 DECL_LINK(OnDropdownClickHdl
, ToolBox
*);
177 inline OAppBorderWindow
& getBorderWin() const { return m_rBorderWin
; }
178 void ImplInitSettings();
181 OAppDetailPageHelper(Window
* _pParent
,OAppBorderWindow
& _rBorderWin
,PreviewMode _ePreviewMode
);
182 virtual ~OAppDetailPageHelper();
185 virtual void Resize();
186 virtual void KeyInput( const KeyEvent
& rKEvt
);
188 sal_Bool
isCutAllowed();
189 sal_Bool
isCopyAllowed();
190 sal_Bool
isPasteAllowed();
195 /** creates the tables page
197 The connection to get the table names
199 void createTablesPage(const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _xConnection
);
201 /** creates the page for the specific type.
203 The type which should be created. E_TABLE isn't allowed.
205 The container of the elements to be inserted.
207 void createPage(ElementType _eType
,const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>& _xContainer
);
209 /** returns the current visible tree list box
211 inline DBTreeListBox
* getCurrentView() const
213 ElementType eType
= getElementType();
214 return (eType
!= E_NONE
) ? m_pLists
[static_cast<sal_Int32
>(eType
)] : NULL
;
217 /// select all entries in the visible control
220 /// returns <TRUE/> if it sorts ascending
221 sal_Bool
isSortUp() const;
223 /// sorts all entries ascending
226 /// sorts all entries descending
229 /** returns the element names which are selected
231 The list will be filled.
233 void getSelectionElementNames( ::std::vector
< ::rtl::OUString
>& _rNames
) const;
235 /** describes the current selection for the given control
237 void describeCurrentSelectionForControl(
238 const Control
& _rControl
,
239 ::com::sun::star::uno::Sequence
< ::com::sun::star::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
242 /** describes the current selection for the given ElementType
244 void describeCurrentSelectionForType(
245 const ElementType _eType
,
246 ::com::sun::star::uno::Sequence
< ::com::sun::star::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
249 /** select all names on the currently selected container. Non existence names where ignored.
251 * \param _aNames the element names
253 void selectElements(const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& _aNames
);
255 /** return the qualified name.
257 The entry of a table, or query, form, report to get the qualified name.
258 If the entry is <NULL/>, the first selected is chosen.
262 ::rtl::OUString
getQualifiedName( SvLBoxEntry
* _pEntry
) const;
264 /// return the element of currently select entry
265 ElementType
getElementType() const;
267 /// returns the count of selected entries
268 sal_Int32
getSelectionCount();
270 /// returns the count of entries
271 sal_Int32
getElementCount();
273 /** returns if an entry is a leaf
277 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
279 bool isLeaf(SvLBoxEntry
* _pEntry
) const;
281 /** returns if one of the selected entries is a leaf
283 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
285 sal_Bool
isALeafSelected() const;
287 SvLBoxEntry
* getEntry( const Point
& _aPosPixel
) const;
289 /// clears the detail pages
292 /// returns <TRUE/> when a detail page was filled
293 sal_Bool
isFilled() const;
295 /** adds a new object to the detail page.
297 The type where the entry shold be appended.
299 The name of the object to be inserted
303 If we insert a table, the connection must be set.
305 SvLBoxEntry
* elementAdded(ElementType eType
306 ,const ::rtl::OUString
& _rName
307 ,const ::com::sun::star::uno::Any
& _rObject
);
309 /** replaces a objects name with a new one
311 The type where the entry shold be appended.
313 The old name of the object to be replaced
315 The new name of the object to be replaced
317 If we insert a table, the connection must be set.
319 void elementReplaced(ElementType eType
320 ,const ::rtl::OUString
& _rOldName
321 ,const ::rtl::OUString
& _rNewName
);
323 /** removes an element from the detail page.
325 The type where the entry shold be appended.
327 The name of the element to be removed.
329 If we remove a table, the connection must be set.
331 void elementRemoved(ElementType _eType
332 ,const ::rtl::OUString
& _rName
);
335 /// returns the preview mode
336 PreviewMode
getPreviewMode();
338 /// <TRUE/> if the preview is enabled
339 sal_Bool
isPreviewEnabled();
341 /** switches to the given preview mode
343 the mode to set for the preview
345 Force the preview to be resetted
347 void switchPreview(PreviewMode _eMode
,sal_Bool _bForce
= sal_False
);
349 /** shows the Preview of the content when it is enabled.
351 The content which must support the "preview" command.
353 void showPreview(const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XContent
>& _xContent
);
355 /** shows the Preview of a table or query
356 @param _sDataSourceName
357 the name of the data source
359 the name of table or query
361 <TRUE/> if it is a table, otherwise <FALSE/>
364 void showPreview( const ::rtl::OUString
& _sDataSourceName
,
365 const ::rtl::OUString
& _sName
,
369 void DataChanged( const DataChangedEvent
& rDCEvt
);
372 #endif // DBAUI_APPDETAILPAGEHELPER_HXX
374 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */