Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / dbaccess / source / ui / app / AppDetailPageHelper.hxx
blob69a050c8e2ea813f36682e1aa61d8449320452b6
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
31 #include <vector>
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"
46 #include <memory>
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)
54 namespace dbaui
56 class OAppBorderWindow;
57 class DBTreeListBox;
59 class OPreviewWindow : public Window
61 GraphicObject m_aGraphicObj;
62 Rectangle m_aPreviewRect;
64 /** gets the graphic cnter rect
65 @param rGraphic
66 the graphic
67 @param rResultRect
68 the resulting rectangle
70 @return
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 );
75 protected:
76 virtual void DataChanged(const DataChangedEvent& rDCEvt);
77 public:
78 OPreviewWindow(Window* _pParent);
80 // window overloads
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;
93 FixedLine m_aFL;
94 ToolBox m_aTBPreview;
95 Window m_aBorder;
96 OPreviewWindow m_aPreview;
97 ::svtools::ODocumentInfoPreview
98 m_aDocumentInfo;
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 >
103 m_xFrame;
104 ::com::sun::star::uno::Reference < ::com::sun::star::io::XPersist >
105 m_xDocInfo;
106 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >
107 m_xWindow;
109 /// returns the index of the visible control
110 int getVisibleControlIndex() const;
112 /** sorts the entries in the tree list box.
113 @param _nPos
114 Which list should be sorted.
115 @param _eSortMode
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
125 @param _xContainer
126 This can either be the queries, forms or report names.
127 @param _eType
128 the type of elements which are being filled
129 @param _nImageId
130 the resource id of the image to use for non-container entries
131 @param _pParent
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
140 @param _pWindow
141 The control which should be visible.
143 void setDetailPage(Window* _pWindow);
145 /** sets all HandleCallbacks
146 @param _pTreeView
147 The newly created DBTreeListBox
148 @param _rImage
149 the resource id of the default icon
150 @return
151 The new tree.
153 DBTreeListBox* createTree( DBTreeListBox* _pTreeView, const Image& _rImage );
155 /** creates the tree and sets all HandleCallbacks
156 @param _nHelpId
157 The help id of the control
158 @param _nCollapsedBitmap
159 The image to use in high contrast mode.
160 @return
161 The new tree.
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*);
174 // click a TB slot
175 DECL_LINK(OnDropdownClickHdl, ToolBox*);
177 inline OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
178 void ImplInitSettings();
180 public:
181 OAppDetailPageHelper(Window* _pParent,OAppBorderWindow& _rBorderWin,PreviewMode _ePreviewMode);
182 virtual ~OAppDetailPageHelper();
184 // window overloads
185 virtual void Resize();
186 virtual void KeyInput( const KeyEvent& rKEvt );
188 sal_Bool isCutAllowed();
189 sal_Bool isCopyAllowed();
190 sal_Bool isPasteAllowed();
191 void copy();
192 void cut();
193 void paste();
195 /** creates the tables page
196 @param _xConnection
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.
202 @param _eType
203 The type which should be created. E_TABLE isn't allowed.
204 @param _xContainer
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
218 void selectAll();
220 /// returns <TRUE/> if it sorts ascending
221 sal_Bool isSortUp() const;
223 /// sorts all entries ascending
224 void sortDown();
226 /// sorts all entries descending
227 void sortUp();
229 /** returns the element names which are selected
230 @param _rNames
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.
256 @param _pEntry
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.
259 @return
260 the qualified name
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
274 @param _pEntry
275 The entry to check
276 @return
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
282 @return
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
290 void clearPages();
292 /// returns <TRUE/> when a detail page was filled
293 sal_Bool isFilled() const;
295 /** adds a new object to the detail page.
296 @param _eType
297 The type where the entry shold be appended.
298 @param _rName
299 The name of the object to be inserted
300 @param _rObject
301 The object to add.
302 @param _rxConn
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
310 @param _eType
311 The type where the entry shold be appended.
312 @param _rOldName
313 The old name of the object to be replaced
314 @param _rNewName
315 The new name of the object to be replaced
316 @param _rxConn
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.
324 @param _eType
325 The type where the entry shold be appended.
326 @param _rName
327 The name of the element to be removed.
328 @param _rxConn
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
342 @param _eMode
343 the mode to set for the preview
344 @param _bForce
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.
350 @param _xContent
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
358 @param _sName
359 the name of table or query
360 @param _bTable
361 <TRUE/> if it is a table, otherwise <FALSE/>
362 @return void
364 void showPreview( const ::rtl::OUString& _sDataSourceName,
365 const ::rtl::OUString& _sName,
366 sal_Bool _bTable);
368 protected:
369 void DataChanged( const DataChangedEvent& rDCEvt );
372 #endif // DBAUI_APPDETAILPAGEHELPER_HXX
374 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */