fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / app / AppDetailPageHelper.hxx
blob8c75918a2a6276c7b75904b02983feabf94c597a
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_APPDETAILPAGEHELPER_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_APP_APPDETAILPAGEHELPER_HXX
22 #include <vector>
24 #include <rtl/ustring.hxx>
25 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
26 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
27 #include <com/sun/star/ucb/XContent.hpp>
28 #include "AppElementType.hxx"
29 #include <svtools/treelistbox.hxx>
30 #include <svtools/DocumentInfoPreview.hxx>
31 #include <vcl/fixed.hxx>
32 #include <vcl/toolbox.hxx>
33 #include <vcl/cvtgrf.hxx>
34 #include <vcl/graph.hxx>
35 #include <svtools/grfmgr.hxx>
36 #include "callbacks.hxx"
37 #include <memory>
39 namespace com{ namespace sun { namespace star { namespace awt { class XWindow; } } } }
40 namespace com{ namespace sun { namespace star { namespace frame { class XFrame2; } } } }
41 namespace com{ namespace sun { namespace star { namespace io { class XPersist; } } } }
43 #define ELEMENT_COUNT size_t(E_ELEMENT_TYPE_COUNT)
45 namespace dbaui
47 class OAppBorderWindow;
48 class DBTreeListBox;
50 class OPreviewWindow : public vcl::Window
52 GraphicObject m_aGraphicObj;
53 Rectangle m_aPreviewRect;
55 /** gets the graphic cnter rect
56 @param rGraphic
57 the graphic
58 @param rResultRect
59 the resulting rectangle
61 @return
62 <TRUE/> when successful
64 bool ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const;
65 void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
66 protected:
67 virtual void DataChanged(const DataChangedEvent& rDCEvt) SAL_OVERRIDE;
68 public:
69 OPreviewWindow(vcl::Window* _pParent);
71 // Window overrides
72 virtual void Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect) SAL_OVERRIDE;
74 void setGraphic(const Graphic& _rGraphic ) { m_aGraphicObj.SetGraphic(_rGraphic); }
76 // A helper class for the controls in the detail page.
77 // Combines general functionality.
78 class OAppDetailPageHelper : public vcl::Window
80 VclPtr<DBTreeListBox> m_pLists[ELEMENT_COUNT];
81 OAppBorderWindow& m_rBorderWin;
82 VclPtr<FixedLine> m_aFL;
83 VclPtr<ToolBox> m_aTBPreview;
84 VclPtr<Window> m_aBorder;
85 VclPtr<OPreviewWindow> m_aPreview;
86 VclPtr< ::svtools::ODocumentInfoPreview>
87 m_aDocumentInfo;
88 VclPtr<vcl::Window> m_pTablePreview;
89 ::std::unique_ptr<PopupMenu> m_aMenu;
90 PreviewMode m_ePreviewMode;
91 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame2 >
92 m_xFrame;
93 ::com::sun::star::uno::Reference < ::com::sun::star::io::XPersist >
94 m_xDocInfo;
95 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >
96 m_xWindow;
98 /// returns the index of the visible control
99 int getVisibleControlIndex() const;
101 /** sorts the entries in the tree list box.
102 @param _nPos
103 Which list should be sorted.
104 @param _eSortMode
105 How should be sorted.
107 void sort(int _nPos,SvSortMode _eSortMode );
109 /** retrieves the resource ids of the images representing elements of the given type
111 static void getElementIcons( ElementType _eType, sal_uInt16& _rImageId);
113 /** fills the names in the listbox
114 @param _xContainer
115 This can either be the queries, forms or report names.
116 @param _eType
117 the type of elements which are being filled
118 @param _nImageId
119 the resource id of the image to use for non-container entries
120 @param _pParent
121 The parent of the entries to be inserted.
123 void fillNames( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer,
124 const ElementType _eType,
125 const sal_uInt16 _nImageId,
126 SvTreeListEntry* _pParent );
128 /** sets the detail page
129 @param _pWindow
130 The control which should be visible.
132 void setDetailPage(vcl::Window* _pWindow);
134 /** sets all HandleCallbacks
135 @param _pTreeView
136 The newly created DBTreeListBox
137 @param _rImage
138 the resource id of the default icon
139 @return
140 The new tree.
142 DBTreeListBox* createTree( DBTreeListBox* _pTreeView, const Image& _rImage );
144 /** creates the tree and sets all HandleCallbacks
145 @param _nHelpId
146 The help id of the control
147 @param _nCollapsedBitmap
148 The image to use in high contrast mode.
149 @return
150 The new tree.
152 DBTreeListBox* createSimpleTree( const OString& _sHelpId, const Image& _rImage);
154 DECL_LINK( OnEntryDoubleClick, SvTreeListBox* );
155 DECL_LINK( OnEntrySelChange, void* );
157 DECL_LINK( OnCutEntry, void* );
158 DECL_LINK( OnCopyEntry, void* );
159 DECL_LINK( OnPasteEntry, void* );
160 DECL_LINK( OnDeleteEntry, void* );
162 DECL_LINK(PreviewChangeHdl, void*);
163 // click a TB slot
164 DECL_LINK_TYPED(OnDropdownClickHdl, ToolBox*, void);
166 inline OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
167 void ImplInitSettings();
169 public:
170 OAppDetailPageHelper(vcl::Window* _pParent,OAppBorderWindow& _rBorderWin,PreviewMode _ePreviewMode);
171 virtual ~OAppDetailPageHelper();
172 virtual void dispose() SAL_OVERRIDE;
174 // Window overrides
175 virtual void Resize() SAL_OVERRIDE;
176 virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
178 /** creates the tables page
179 @param _xConnection
180 The connection to get the table names
182 void createTablesPage(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
184 /** creates the page for the specific type.
185 @param _eType
186 The type which should be created. E_TABLE isn't allowed.
187 @param _xContainer
188 The container of the elements to be inserted.
190 void createPage(ElementType _eType,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer);
192 /** returns the current visible tree list box
194 inline DBTreeListBox* getCurrentView() const
196 ElementType eType = getElementType();
197 return (eType != E_NONE ) ? m_pLists[static_cast<sal_Int32>(eType)].get() : NULL;
200 /// select all entries in the visible control
201 void selectAll();
203 /// returns <TRUE/> if it sorts ascending
204 bool isSortUp() const;
206 /// sorts all entries ascending
207 void sortDown();
209 /// sorts all entries descending
210 void sortUp();
212 /** returns the element names which are selected
213 @param _rNames
214 The list will be filled.
216 void getSelectionElementNames( ::std::vector< OUString>& _rNames ) const;
218 /** describes the current selection for the given control
220 void describeCurrentSelectionForControl(
221 const Control& _rControl,
222 ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
225 /** describes the current selection for the given ElementType
227 void describeCurrentSelectionForType(
228 const ElementType _eType,
229 ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
232 /** select all names on the currently selected container. Non existence names where ignored.
234 * \param _aNames the element names
236 void selectElements(const ::com::sun::star::uno::Sequence< OUString>& _aNames);
238 /** return the qualified name.
239 @param _pEntry
240 The entry of a table, or query, form, report to get the qualified name.
241 If the entry is <NULL/>, the first selected is chosen.
242 @return
243 the qualified name
245 OUString getQualifiedName( SvTreeListEntry* _pEntry ) const;
247 /// return the element of currently select entry
248 ElementType getElementType() const;
250 /// returns the count of selected entries
251 sal_Int32 getSelectionCount();
253 /// returns the count of entries
254 sal_Int32 getElementCount();
256 /** returns if an entry is a leaf
257 @param _pEntry
258 The entry to check
259 @return
260 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
262 static bool isLeaf(SvTreeListEntry* _pEntry);
264 /** returns if one of the selected entries is a leaf
265 @return
266 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
268 bool isALeafSelected() const;
270 SvTreeListEntry* getEntry( const Point& _aPosPixel ) const;
272 /// clears the detail pages
273 void clearPages();
275 /// returns <TRUE/> when a detail page was filled
276 bool isFilled() const;
278 /** adds a new object to the detail page.
279 @param _eType
280 The type where the entry shold be appended.
281 @param _rName
282 The name of the object to be inserted
283 @param _rObject
284 The object to add.
285 @param _rxConn
286 If we insert a table, the connection must be set.
288 SvTreeListEntry* elementAdded(ElementType eType
289 ,const OUString& _rName
290 ,const ::com::sun::star::uno::Any& _rObject );
292 /** replaces a objects name with a new one
293 @param _eType
294 The type where the entry shold be appended.
295 @param _rOldName
296 The old name of the object to be replaced
297 @param _rNewName
298 The new name of the object to be replaced
299 @param _rxConn
300 If we insert a table, the connection must be set.
302 void elementReplaced(ElementType eType
303 ,const OUString& _rOldName
304 ,const OUString& _rNewName );
306 /** removes an element from the detail page.
307 @param _eType
308 The type where the entry shold be appended.
309 @param _rName
310 The name of the element to be removed.
311 @param _rxConn
312 If we remove a table, the connection must be set.
314 void elementRemoved(ElementType _eType
315 ,const OUString& _rName );
317 /// returns the preview mode
318 PreviewMode getPreviewMode() { return m_ePreviewMode;}
320 /// <TRUE/> if the preview is enabled
321 bool isPreviewEnabled();
323 /** switches to the given preview mode
324 @param _eMode
325 the mode to set for the preview
326 @param _bForce
327 Force the preview to be resetted
329 void switchPreview(PreviewMode _eMode,bool _bForce = false);
331 /** shows the Preview of the content when it is enabled.
332 @param _xContent
333 The content which must support the "preview" command.
335 void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
337 /** shows the Preview of a table or query
338 @param _sDataSourceName
339 the name of the data source
340 @param _sName
341 the name of table or query
342 @param _bTable
343 <TRUE/> if it is a table, otherwise <FALSE/>
344 @return void
346 void showPreview( const OUString& _sDataSourceName,
347 const OUString& _sName,
348 bool _bTable);
350 protected:
351 void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
354 #endif // INCLUDED_DBACCESS_SOURCE_UI_APP_APPDETAILPAGEHELPER_HXX
356 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */