1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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"
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)
47 class OAppBorderWindow
;
50 class OPreviewWindow
: public vcl::Window
52 GraphicObject m_aGraphicObj
;
53 Rectangle m_aPreviewRect
;
55 /** gets the graphic cnter rect
59 the resulting rectangle
62 <TRUE/> when successful
64 bool ImplGetGraphicCenterRect( const Graphic
& rGraphic
, Rectangle
& rResultRect
) const;
65 void ImplInitSettings( bool bFont
, bool bForeground
, bool bBackground
);
67 virtual void DataChanged(const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
69 OPreviewWindow(vcl::Window
* _pParent
);
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
>
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
>
93 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XPersist
>
95 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>
98 /// returns the index of the visible control
99 int getVisibleControlIndex() const;
101 /** sorts the entries in the tree list box.
103 Which list should be sorted.
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
115 This can either be the queries, forms or report names.
117 the type of elements which are being filled
119 the resource id of the image to use for non-container entries
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
130 The control which should be visible.
132 void setDetailPage(vcl::Window
* _pWindow
);
134 /** sets all HandleCallbacks
136 The newly created DBTreeListBox
138 the resource id of the default icon
142 DBTreeListBox
* createTree( DBTreeListBox
* _pTreeView
, const Image
& _rImage
);
144 /** creates the tree and sets all HandleCallbacks
146 The help id of the control
147 @param _nCollapsedBitmap
148 The image to use in high contrast mode.
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*);
164 DECL_LINK_TYPED(OnDropdownClickHdl
, ToolBox
*, void);
166 inline OAppBorderWindow
& getBorderWin() const { return m_rBorderWin
; }
167 void ImplInitSettings();
170 OAppDetailPageHelper(vcl::Window
* _pParent
,OAppBorderWindow
& _rBorderWin
,PreviewMode _ePreviewMode
);
171 virtual ~OAppDetailPageHelper();
172 virtual void dispose() SAL_OVERRIDE
;
175 virtual void Resize() SAL_OVERRIDE
;
176 virtual void KeyInput( const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
178 /** creates the tables page
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.
186 The type which should be created. E_TABLE isn't allowed.
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
203 /// returns <TRUE/> if it sorts ascending
204 bool isSortUp() const;
206 /// sorts all entries ascending
209 /// sorts all entries descending
212 /** returns the element names which are selected
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.
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.
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
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
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
275 /// returns <TRUE/> when a detail page was filled
276 bool isFilled() const;
278 /** adds a new object to the detail page.
280 The type where the entry shold be appended.
282 The name of the object to be inserted
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
294 The type where the entry shold be appended.
296 The old name of the object to be replaced
298 The new name of the object to be replaced
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.
308 The type where the entry shold be appended.
310 The name of the element to be removed.
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
325 the mode to set for the preview
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.
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
341 the name of table or query
343 <TRUE/> if it is a table, otherwise <FALSE/>
346 void showPreview( const OUString
& _sDataSourceName
,
347 const OUString
& _sName
,
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: */