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_APPVIEW_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_APP_APPVIEW_HXX
22 #include <dbaccess/dataview.hxx>
23 #include <com/sun/star/container/XNameAccess.hpp>
24 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
25 #include <com/sun/star/ucb/XContent.hpp>
26 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
27 #include <vcl/fixed.hxx>
28 #include <unotools/eventlisteneradapter.hxx>
29 #include "IClipBoardTest.hxx"
30 #include "AppElementType.hxx"
32 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{ class XPropertySet
; } } } }
35 class SvTreeListEntry
;
36 class MnemonicGenerator
;
40 class IApplicationController
;
41 class OApplicationView
;
42 class OApplicationDetailView
;
43 class OApplicationSwapWindow
;
45 class OAppBorderWindow
: public vcl::Window
47 VclPtr
<OTitleWindow
> m_pPanel
;
48 VclPtr
<OApplicationDetailView
> m_pDetailView
;
49 VclPtr
<OApplicationView
> m_pView
;
51 void ImplInitSettings();
54 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
56 OAppBorderWindow(OApplicationView
* _pParent
,PreviewMode _ePreviewMode
);
57 virtual ~OAppBorderWindow();
58 virtual void dispose() SAL_OVERRIDE
;
61 virtual void GetFocus() SAL_OVERRIDE
;
62 virtual void Resize() SAL_OVERRIDE
;
64 OApplicationView
* getView() const { return m_pView
;}
65 OApplicationSwapWindow
* getPanel() const;
66 OApplicationDetailView
* getDetailView() const { return m_pDetailView
;}
69 class OApplicationView
: public ODataView
70 ,public IClipboardTest
71 ,public ::utl::OEventListenerAdapter
80 ::com::sun::star::lang::Locale m_aLocale
;
81 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>
83 VclPtr
<OAppBorderWindow
> m_pWin
;
84 IApplicationController
& m_rAppController
;
85 ChildFocusState m_eChildFocus
;
87 IClipboardTest
* getActiveChild() const;
89 void ImplInitSettings();
92 // return the Rectangle where I can paint myself
93 virtual void resizeDocumentView(Rectangle
& rRect
) SAL_OVERRIDE
;
95 // OEventListenerAdapter
96 virtual void _disposing( const ::com::sun::star::lang::EventObject
& _rSource
) SAL_OVERRIDE
;
99 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
101 OApplicationView( vcl::Window
* pParent
102 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>&
103 ,IApplicationController
& _rAppController
104 ,PreviewMode _ePreviewMode
106 virtual ~OApplicationView();
107 virtual void dispose() SAL_OVERRIDE
;
109 /// automatically creates mnemonics for the icon/texts in our left hand side panel
110 void createIconAutoMnemonics( MnemonicGenerator
& _rMnemonics
);
112 /// automatically creates mnemonics for the texts in our task pane
113 void setTaskExternalMnemonics( MnemonicGenerator
& _rMnemonics
);
116 virtual bool PreNotify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
117 virtual void GetFocus() SAL_OVERRIDE
;
119 inline IApplicationController
& getAppController() const { return m_rAppController
; }
120 inline const ::com::sun::star::lang::Locale
& getLocale() const { return m_aLocale
;}
123 virtual bool isCutAllowed() SAL_OVERRIDE
;
124 virtual bool isCopyAllowed() SAL_OVERRIDE
;
125 virtual bool isPasteAllowed() SAL_OVERRIDE
;
126 virtual bool hasChildPathFocus() SAL_OVERRIDE
{ return HasChildPathFocus(); }
127 virtual void copy() SAL_OVERRIDE
;
128 virtual void cut() SAL_OVERRIDE
;
129 virtual void paste() SAL_OVERRIDE
;
131 /// get the left panel
132 inline OApplicationSwapWindow
* getPanel() const { return m_pWin
->getPanel(); }
133 /// get the detail page
134 inline OApplicationDetailView
* getDetailView() const { return m_pWin
->getDetailView(); }
136 /** return the qualified name.
138 The entry of a table, or query, form, report to get the qualified name.
139 If the entry is <NULL/>, the first selected is chosen.
143 OUString
getQualifiedName( SvTreeListEntry
* _pEntry
) const;
145 /** returns if an entry is a leaf
149 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
151 bool isLeaf(SvTreeListEntry
* _pEntry
) const;
153 /** returns if one of the selected entries is a leaf
155 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
157 bool isALeafSelected() const;
159 /** select all entries in the detail page
163 /// returns <TRUE/> if it sorts ascending
164 bool isSortUp() const;
166 /// sort the entries in the detail page down
169 /// sort the entries in the detail page up
172 /// returns <TRUE/> when a detail page was filled
173 bool isFilled() const;
175 /// return the element of currently select entry
176 ElementType
getElementType() const;
178 /// returns the count of entries
179 sal_Int32
getElementCount();
181 /// returns the count of selected entries
182 sal_Int32
getSelectionCount();
184 /** clears the detail page and the selection on the left side.
186 If <TRUE/> the task window will also be cleared.
188 void clearPages(bool _bTaskAlso
= true);
190 /** returns the element names which are selected
192 The list will be filled.
194 void getSelectionElementNames( ::std::vector
< OUString
>& _rNames
) const;
196 /** describes the current selection for the given control
198 void describeCurrentSelectionForControl(
199 const Control
& _rControl
,
200 ::com::sun::star::uno::Sequence
< ::com::sun::star::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
203 /** describes the current selection for the given ElementType
205 void describeCurrentSelectionForType(
206 const ElementType _eType
,
207 ::com::sun::star::uno::Sequence
< ::com::sun::star::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
210 /** select all names on the currently selected container. Non existence names where ignored.
212 * \param _aNames the element names
214 void selectElements(const ::com::sun::star::uno::Sequence
< OUString
>& _aNames
);
216 /** adds a new object to the detail page.
218 The type where the entry shold be appended.
220 The name of the object to be inserted
224 If we insert a table, the connection must be set.
226 SvTreeListEntry
* elementAdded(ElementType _eType
227 ,const OUString
& _rName
228 ,const ::com::sun::star::uno::Any
& _rObject
);
230 /** replaces a objects name with a new one
232 The type where the entry shold be appended.
234 The old name of the object to be replaced
236 The new name of the object to be replaced
238 If we insert a table, the connection must be set.
240 The object which was replaced
242 void elementReplaced(ElementType eType
243 ,const OUString
& _rOldName
244 ,const OUString
& _rNewName
);
246 /** removes an element from the detail page.
248 The type where the entry shold be appended.
250 The name of the element to be removed.
252 If we remove a table, the connection must be set.
254 void elementRemoved(ElementType _eType
255 ,const OUString
& _rName
);
257 /** changes the container which should be displayed. The select handler will also be called.
259 Which container to show.
261 void selectContainer(ElementType _eType
);
263 /// returns the preview mode
264 PreviewMode
getPreviewMode();
266 /// <TRUE/> if the preview is enabled
267 bool isPreviewEnabled();
269 /** switches to the given preview mode
271 the mode to set for the preview
273 void switchPreview(PreviewMode _eMode
);
275 /** shows the Preview of the content when it is enabled.
277 The content which must support the "preview" command.
279 void showPreview(const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XContent
>& _xContent
);
281 /** shows the Preview of a table or query
282 @param _sDataSourceName
283 the name of the data source
285 the connection which will be shared
287 the name of table or query
289 <TRUE/> if it is a table, otherwise <FALSE/>
292 void showPreview( const OUString
& _sDataSourceName
,
293 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _xConnection
,
294 const OUString
& _sName
,
297 SvTreeListEntry
* getEntry( const Point
& _aPosPixel
) const;
300 #endif // INCLUDED_DBACCESS_SOURCE_UI_APP_APPVIEW_HXX
302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */