LibreOffice Module dbaccess (master) 1
AppDetailPageHelper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
21#include <vector>
22
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>
35
36namespace com::sun::star::awt { class XWindow; }
37namespace com::sun::star::frame { class XFrame2; }
38namespace com::sun::star::io { class XPersist; }
39
40namespace dbaui
41{
42 class OAppBorderWindow;
43 class ODocumentInfoPreview;
44 class DBTreeViewBase;
45 class TreeListBox;
46
48 {
51
63 bool ImplGetGraphicCenterRect(const vcl::RenderContext& rRenderContext, const Graphic& rGraphic, tools::Rectangle& rResultRect) const;
64
65 public:
67
68 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
69
70 void setGraphic(const Graphic& _rGraphic ) { m_aGraphicObj.SetGraphic(_rGraphic); }
71 };
72
73 // A helper class for the controls in the detail page.
74 // Combines general functionality.
76 {
77 std::unique_ptr<DBTreeViewBase> m_aLists[size_t(E_ELEMENT_TYPE_COUNT)];
79 std::unique_ptr<weld::Container> m_xBox;
80 std::unique_ptr<weld::Widget> m_xFL;
81 std::unique_ptr<weld::MenuButton> m_xMBPreview;
82
83 std::unique_ptr<OPreviewWindow> m_xPreview;
84 std::unique_ptr<weld::CustomWeld> m_xPreviewWin;
85
86 std::unique_ptr<ODocumentInfoPreview> m_xDocumentInfo;
87 std::unique_ptr<weld::CustomWeld> m_xDocumentInfoWin;
88
89 std::unique_ptr<weld::Container> m_xTablePreview;
90
92 css::uno::Reference < css::frame::XFrame2 >
94 css::uno::Reference< css::awt::XWindow >
96
98 int getVisibleControlIndex() const;
99
106 void sort(int nPos, bool bAscending);
107
110 static OUString getElementIcons(ElementType _eType);
111
122 void fillNames( const css::uno::Reference< css::container::XNameAccess >& _xContainer,
123 const ElementType _eType,
124 const OUString& rImageId,
125 const weld::TreeIter* _pParent );
126
131 void setDetailPage(DBTreeViewBase& rTreeView);
132
137 void setupTree(DBTreeViewBase& rTreeView);
138
147 std::unique_ptr<DBTreeViewBase> createSimpleTree(const OUString& rHelpId, ElementType eType);
148
149 DECL_LINK( OnEntryDoubleClick, weld::TreeView&, bool );
150 DECL_LINK( OnEntrySelChange, LinkParamNone*, void );
151
152 DECL_LINK( OnCopyEntry, LinkParamNone*, void );
153 DECL_LINK( OnPasteEntry, LinkParamNone*, void );
154 DECL_LINK( OnDeleteEntry, LinkParamNone*, void );
155
156 DECL_LINK(OnDropdownClickHdl, weld::Toggleable&, void);
157 DECL_LINK(MenuSelectHdl, const OUString&, void);
158
160
161 public:
162 OAppDetailPageHelper(weld::Container* pParent, OAppBorderWindow& rBorderWin, PreviewMode ePreviewMode);
163 virtual ~OAppDetailPageHelper() override;
164
165 virtual void GrabFocus() override;
166 virtual bool HasChildPathFocus() const override;
167
172 void createTablesPage(const css::uno::Reference< css::sdbc::XConnection>& _xConnection);
173
180 void createPage(ElementType _eType,const css::uno::Reference< css::container::XNameAccess >& _xContainer);
181
185 {
187 return (eType != E_NONE ) ? m_aLists[static_cast<sal_Int32>(eType)].get() : nullptr;
188 }
189
191 void selectAll();
192
194 bool isSortUp() const;
195
197 void sortDown();
198
200 void sortUp();
201
206 void getSelectionElementNames( std::vector< OUString>& _rNames ) const;
207
211 const weld::TreeView& rControl,
212 css::uno::Sequence< css::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
213 );
214
218 const ElementType _eType,
219 css::uno::Sequence< css::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
220 );
221
224 vcl::Window* getMenuParent() const;
225 void adjustMenuPosition(const weld::TreeView& rControl, ::Point& rPos) const;
226
231 void selectElements(const css::uno::Sequence< OUString>& _aNames);
232
240 OUString getQualifiedName( const weld::TreeIter* _pEntry ) const;
241
244
246 sal_Int32 getSelectionCount();
247
249 sal_Int32 getElementCount() const;
250
259 static bool isLeaf(const weld::TreeView& rTreeView, const weld::TreeIter& rEntry);
260
265 bool isALeafSelected() const;
266
267 std::unique_ptr<weld::TreeIter> getEntry(const Point& rPosPixel) const;
268
270 void clearPages();
271
273 bool isFilled() const;
274
285 std::unique_ptr<weld::TreeIter> elementAdded(ElementType eType,
286 const OUString& rName,
287 const css::uno::Any& rObject);
288
300 ,const OUString& _rOldName
301 ,const OUString& _rNewName );
302
311 void elementRemoved(ElementType _eType
312 ,const OUString& _rName );
313
316
318 bool isPreviewEnabled() const;
319
326 void switchPreview(PreviewMode _eMode,bool _bForce = false);
327
332 void showPreview(const css::uno::Reference< css::ucb::XContent >& _xContent);
333
343 void showPreview( const OUString& _sDataSourceName,
344 const OUString& _sName,
345 bool _bTable);
346 };
347}
348
349/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetGraphic(const Graphic &rGraphic)
std::unique_ptr< weld::MenuButton > m_xMBPreview
void sortUp()
sorts all entries descending
void fillNames(const css::uno::Reference< css::container::XNameAccess > &_xContainer, const ElementType _eType, const OUString &rImageId, const weld::TreeIter *_pParent)
fills the names in the listbox
static bool isLeaf(const weld::TreeView &rTreeView, const weld::TreeIter &rEntry)
returns if an entry is a leaf
void sortDown()
sorts all entries ascending
bool isSortUp() const
returns <TRUE> if it sorts ascending
PreviewMode getPreviewMode() const
returns the preview mode
void sort(int nPos, bool bAscending)
sorts the entries in the tree list box.
std::unique_ptr< weld::CustomWeld > m_xDocumentInfoWin
std::unique_ptr< weld::Widget > m_xFL
virtual ~OAppDetailPageHelper() override
DECL_LINK(OnCopyEntry, LinkParamNone *, void)
virtual bool HasChildPathFocus() const override
OUString getQualifiedName(const weld::TreeIter *_pEntry) const
return the qualified name.
std::unique_ptr< DBTreeViewBase > createSimpleTree(const OUString &rHelpId, ElementType eType)
creates the tree and sets all HandleCallbacks
std::unique_ptr< weld::Container > m_xTablePreview
DECL_LINK(OnDeleteEntry, LinkParamNone *, void)
DECL_LINK(MenuSelectHdl, const OUString &, void)
void elementReplaced(ElementType eType, const OUString &_rOldName, const OUString &_rNewName)
replaces an objects name with a new one
vcl::Window * getMenuParent() const
get the menu parent window for the given control
static OUString getElementIcons(ElementType _eType)
retrieves the resource ids of the images representing elements of the given type
DECL_LINK(OnDropdownClickHdl, weld::Toggleable &, void)
sal_Int32 getSelectionCount()
returns the count of selected entries
std::unique_ptr< weld::CustomWeld > m_xPreviewWin
bool isALeafSelected() const
returns if one of the selected entries is a leaf
int getVisibleControlIndex() const
returns the index of the visible control
void selectAll()
select all entries in the visible control
void setDetailPage(DBTreeViewBase &rTreeView)
sets the detail page
void setupTree(DBTreeViewBase &rTreeView)
sets all HandleCallbacks
std::unique_ptr< weld::TreeIter > getEntry(const Point &rPosPixel) const
bool isFilled() const
returns <TRUE> when a detail page was filled
css::uno::Reference< css::awt::XWindow > m_xWindow
DBTreeViewBase * getCurrentView() const
returns the current visible tree list box
virtual void GrabFocus() override
DECL_LINK(OnEntryDoubleClick, weld::TreeView &, bool)
std::unique_ptr< weld::Container > m_xBox
void adjustMenuPosition(const weld::TreeView &rControl, ::Point &rPos) const
std::unique_ptr< ODocumentInfoPreview > m_xDocumentInfo
void elementRemoved(ElementType _eType, const OUString &_rName)
removes an element from the detail page.
bool isPreviewEnabled() const
<TRUE> if the preview is enabled
DECL_LINK(OnEntrySelChange, LinkParamNone *, void)
sal_Int32 getElementCount() const
returns the count of entries
OAppBorderWindow & getBorderWin() const
std::unique_ptr< weld::TreeIter > elementAdded(ElementType eType, const OUString &rName, const css::uno::Any &rObject)
adds a new object to the detail page.
void getSelectionElementNames(std::vector< OUString > &_rNames) const
returns the element names which are selected
void createPage(ElementType _eType, const css::uno::Reference< css::container::XNameAccess > &_xContainer)
creates the page for the specific type.
css::uno::Reference< css::frame::XFrame2 > m_xFrame
void describeCurrentSelectionForType(const ElementType _eType, css::uno::Sequence< css::sdb::application::NamedDatabaseObject > &_out_rSelectedObjects)
describes the current selection for the given ElementType
void selectElements(const css::uno::Sequence< OUString > &_aNames)
select all names on the currently selected container.
OAppDetailPageHelper(weld::Container *pParent, OAppBorderWindow &rBorderWin, PreviewMode ePreviewMode)
ElementType getElementType() const
return the element of currently select entry
void showPreview(const css::uno::Reference< css::ucb::XContent > &_xContent)
shows the Preview of the content when it is enabled.
std::unique_ptr< DBTreeViewBase > m_aLists[size_t(E_ELEMENT_TYPE_COUNT)]
void switchPreview(PreviewMode _eMode, bool _bForce=false)
switches to the given preview mode
void describeCurrentSelectionForControl(const weld::TreeView &rControl, css::uno::Sequence< css::sdb::application::NamedDatabaseObject > &_out_rSelectedObjects)
describes the current selection for the given control
DECL_LINK(OnPasteEntry, LinkParamNone *, void)
void clearPages()
clears the detail pages
std::unique_ptr< OPreviewWindow > m_xPreview
void createTablesPage(const css::uno::Reference< css::sdbc::XConnection > &_xConnection)
creates the tables page
void setGraphic(const Graphic &_rGraphic)
bool ImplGetGraphicCenterRect(const vcl::RenderContext &rRenderContext, const Graphic &rGraphic, tools::Rectangle &rResultRect) const
gets the graphic center rect
tools::Rectangle m_aPreviewRect
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
OUString eType
Definition: generalpage.cxx:78
@ E_ELEMENT_TYPE_COUNT
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)