tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / dbaccess / source / ui / app / AppDetailPageHelper.hxx
blobfb47cb70c5585dd3ba803cd9f4e5a8c9f8591919
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 #pragma once
21 #include <vector>
23 #include <rtl/ustring.hxx>
24 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
25 #include <com/sun/star/sdbc/XConnection.hpp>
26 #include <com/sun/star/ucb/XContent.hpp>
27 #include <com/sun/star/container/XNameAccess.hpp>
28 #include <vcl/graph.hxx>
29 #include <vcl/GraphicObject.hxx>
30 #include <vcl/customweld.hxx>
31 #include <vcl/weld.hxx>
32 #include <AppElementType.hxx>
33 #include <ChildWindow.hxx>
34 #include "DocumentInfoPreview.hxx"
36 namespace com::sun::star::awt { class XWindow; }
37 namespace com::sun::star::frame { class XFrame2; }
38 namespace com::sun::star::io { class XPersist; }
40 namespace dbaui
42 class OAppBorderWindow;
43 class ODocumentInfoPreview;
44 class DBTreeViewBase;
45 class TreeListBox;
47 class OPreviewWindow final : public weld::CustomWidgetController
49 GraphicObject m_aGraphicObj;
50 tools::Rectangle m_aPreviewRect;
52 /** gets the graphic center rect
53 @param rRenderContext
54 the context to which we are drawing
55 @param rGraphic
56 the graphic
57 @param rResultRect
58 the resulting rectangle
60 @return
61 <TRUE/> when successful
63 bool ImplGetGraphicCenterRect(const vcl::RenderContext& rRenderContext, const Graphic& rGraphic, tools::Rectangle& rResultRect) const;
65 public:
66 OPreviewWindow();
68 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
70 void setGraphic(const Graphic& _rGraphic ) { m_aGraphicObj.SetGraphic(_rGraphic); }
73 // A helper class for the controls in the detail page.
74 // Combines general functionality.
75 class OAppDetailPageHelper final : public OChildWindow
77 std::unique_ptr<DBTreeViewBase> m_aLists[size_t(E_ELEMENT_TYPE_COUNT)];
78 OAppBorderWindow& m_rBorderWin;
79 std::unique_ptr<weld::Container> m_xBox;
80 std::unique_ptr<weld::Widget> m_xFL;
81 std::unique_ptr<weld::MenuButton> m_xMBPreview;
83 std::unique_ptr<OPreviewWindow> m_xPreview;
84 std::unique_ptr<weld::CustomWeld> m_xPreviewWin;
86 std::unique_ptr<ODocumentInfoPreview> m_xDocumentInfo;
87 std::unique_ptr<weld::CustomWeld> m_xDocumentInfoWin;
89 std::unique_ptr<weld::Container> m_xTablePreview;
91 PreviewMode m_ePreviewMode;
92 css::uno::Reference < css::frame::XFrame2 >
93 m_xFrame;
94 css::uno::Reference< css::awt::XWindow >
95 m_xWindow;
97 /// returns the index of the visible control
98 int getVisibleControlIndex() const;
100 /** sorts the entries in the tree list box.
101 @param nPos
102 Which list should be sorted.
103 @param bAscending
104 If sort should be Ascending of Descending
106 void sort(int nPos, bool bAscending);
108 /** retrieves the resource ids of the images representing elements of the given type
110 static OUString getElementIcons(ElementType _eType);
112 /** fills the names in the listbox
113 @param _xContainer
114 This can either be the queries, forms or report names.
115 @param _eType
116 the type of elements which are being filled
117 @param _nImageId
118 the resource id of the image to use for non-container entries
119 @param _pParent
120 The parent of the entries to be inserted.
122 void fillNames( const css::uno::Reference< css::container::XNameAccess >& _xContainer,
123 const ElementType _eType,
124 const OUString& rImageId,
125 const weld::TreeIter* _pParent );
127 /** sets the detail page
128 @param rTreeView
129 The control which should be visible.
131 void setDetailPage(DBTreeViewBase& rTreeView);
133 /** sets all HandleCallbacks
134 @param rTreeView
135 The newly created DBTreeViewBase
137 void setupTree(DBTreeViewBase& rTreeView);
139 /** creates the tree and sets all HandleCallbacks
140 @param nHelpId
141 The help id of the control
142 @param eType
143 The element type of the control
144 @return
145 The new tree.
147 std::unique_ptr<DBTreeViewBase> createSimpleTree(const OUString& rHelpId, ElementType eType);
149 DECL_LINK( OnEntryDoubleClick, weld::TreeView&, bool );
150 DECL_LINK( OnEntrySelChange, LinkParamNone*, void );
152 DECL_LINK( OnCopyEntry, LinkParamNone*, void );
153 DECL_LINK( OnPasteEntry, LinkParamNone*, void );
154 DECL_LINK( OnDeleteEntry, LinkParamNone*, void );
156 DECL_LINK(OnDropdownClickHdl, weld::Toggleable&, void);
157 DECL_LINK(MenuSelectHdl, const OUString&, void);
159 OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
161 public:
162 OAppDetailPageHelper(weld::Container* pParent, OAppBorderWindow& rBorderWin, PreviewMode ePreviewMode);
163 virtual ~OAppDetailPageHelper() override;
165 virtual void GrabFocus() override;
166 virtual bool HasChildPathFocus() const override;
168 /** creates the tables page
169 @param _xConnection
170 The connection to get the table names
172 void createTablesPage(const css::uno::Reference< css::sdbc::XConnection>& _xConnection);
174 /** creates the page for the specific type.
175 @param _eType
176 The type which should be created. E_TABLE isn't allowed.
177 @param _xContainer
178 The container of the elements to be inserted.
180 void createPage(ElementType _eType,const css::uno::Reference< css::container::XNameAccess >& _xContainer);
182 /** returns the current visible tree list box
184 DBTreeViewBase* getCurrentView() const
186 ElementType eType = getElementType();
187 return (eType != E_NONE ) ? m_aLists[static_cast<sal_Int32>(eType)].get() : nullptr;
190 /// select all entries in the visible control
191 void selectAll();
193 /// returns <TRUE/> if it sorts ascending
194 bool isSortUp() const;
196 /// sorts all entries ascending
197 void sortDown();
199 /// sorts all entries descending
200 void sortUp();
202 /** returns the element names which are selected
203 @param _rNames
204 The list will be filled.
206 void getSelectionElementNames( std::vector< OUString>& _rNames ) const;
208 /** describes the current selection for the given control
210 void describeCurrentSelectionForControl(
211 const weld::TreeView& rControl,
212 css::uno::Sequence< css::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
215 /** describes the current selection for the given ElementType
217 void describeCurrentSelectionForType(
218 const ElementType _eType,
219 css::uno::Sequence< css::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
222 /** get the menu parent window for the given control
224 vcl::Window* getMenuParent() const;
225 void adjustMenuPosition(const weld::TreeView& rControl, ::Point& rPos) const;
227 /** select all names on the currently selected container. Non existence names where ignored.
229 * \param _aNames the element names
231 void selectElements(const css::uno::Sequence< OUString>& _aNames);
233 /** return the qualified name.
234 @param _pEntry
235 The entry of a table, or query, form, report to get the qualified name.
236 If the entry is <NULL/>, the first selected is chosen.
237 @return
238 the qualified name
240 OUString getQualifiedName( const weld::TreeIter* _pEntry ) const;
242 /// return the element of currently select entry
243 ElementType getElementType() const;
245 /// returns the count of selected entries
246 sal_Int32 getSelectionCount();
248 /// returns the count of entries
249 sal_Int32 getElementCount() const;
251 /** returns if an entry is a leaf
252 @param rTreeView
253 The TreeView rEntry belongs to
254 @param rEntry
255 The entry to check
256 @return
257 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
259 static bool isLeaf(const weld::TreeView& rTreeView, const weld::TreeIter& rEntry);
261 /** returns if one of the selected entries is a leaf
262 @return
263 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
265 bool isALeafSelected() const;
267 std::unique_ptr<weld::TreeIter> getEntry(const Point& rPosPixel) const;
269 /// clears the detail pages
270 void clearPages();
272 /// returns <TRUE/> when a detail page was filled
273 bool isFilled() const;
275 /** adds a new object to the detail page.
276 @param _eType
277 The type where the entry should be appended.
278 @param _rName
279 The name of the object to be inserted
280 @param _rObject
281 The object to add.
282 @param _rxConn
283 If we insert a table, the connection must be set.
285 std::unique_ptr<weld::TreeIter> elementAdded(ElementType eType,
286 const OUString& rName,
287 const css::uno::Any& rObject);
289 /** replaces an objects name with a new one
290 @param _eType
291 The type where the entry should be appended.
292 @param _rOldName
293 The old name of the object to be replaced
294 @param _rNewName
295 The new name of the object to be replaced
296 @param _rxConn
297 If we insert a table, the connection must be set.
299 void elementReplaced(ElementType eType
300 ,const OUString& _rOldName
301 ,const OUString& _rNewName );
303 /** removes an element from the detail page.
304 @param _eType
305 The type where the entry should be appended.
306 @param _rName
307 The name of the element to be removed.
308 @param _rxConn
309 If we remove a table, the connection must be set.
311 void elementRemoved(ElementType _eType
312 ,const OUString& _rName );
314 /// returns the preview mode
315 PreviewMode getPreviewMode() const { return m_ePreviewMode;}
317 /// <TRUE/> if the preview is enabled
318 bool isPreviewEnabled() const;
320 /** switches to the given preview mode
321 @param _eMode
322 the mode to set for the preview
323 @param _bForce
324 Force the preview to be reset
326 void switchPreview(PreviewMode _eMode,bool _bForce = false);
328 /** shows the Preview of the content when it is enabled.
329 @param _xContent
330 The content which must support the "preview" command.
332 void showPreview(const css::uno::Reference< css::ucb::XContent >& _xContent);
334 /** shows the Preview of a table or query
335 @param _sDataSourceName
336 the name of the data source
337 @param _sName
338 the name of table or query
339 @param _bTable
340 <TRUE/> if it is a table, otherwise <FALSE/>
341 @return void
343 void showPreview( const OUString& _sDataSourceName,
344 const OUString& _sName,
345 bool _bTable);
349 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */