xref: /trunk/main/dbaccess/source/ui/app/AppView.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef DBAUI_APPVIEW_HXX
28 #define DBAUI_APPVIEW_HXX
29 
30 #ifndef DBAUI_DATAVIEW_HXX
31 #include "dataview.hxx"
32 #endif
33 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
34 #include <com/sun/star/container/XNameAccess.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
37 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
40 #include <com/sun/star/ucb/XContent.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_
43 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
44 #endif
45 #ifndef _SV_FIXED_HXX
46 #include <vcl/fixed.hxx>
47 #endif
48 #ifndef _UNOTOOLS_EVENTLISTENERADAPTER_HXX_
49 #include <unotools/eventlisteneradapter.hxx>
50 #endif
51 #ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
52 #include "IClipBoardTest.hxx"
53 #endif
54 #ifndef DBAUI_APPELEMENTTYPE_HXX
55 #include "AppElementType.hxx"
56 #endif
57 
58 namespace com{ namespace sun { namespace star { namespace beans    { class XPropertySet; } } } }
59 
60 class Control;
61 class SvLBoxEntry;
62 class MnemonicGenerator;
63 
64 namespace dbaui
65 {
66     class IControlActionListener;
67     class IApplicationController;
68     class OApplicationView;
69     class OApplicationDetailView;
70     class OApplicationSwapWindow;
71     class OTitleWindow;
72     //==================================================================
73     class OAppBorderWindow : public Window
74     {
75         OTitleWindow*                       m_pPanel;
76         OApplicationDetailView*             m_pDetailView;
77         OApplicationView*                   m_pView;
78 
79         void ImplInitSettings();
80     protected:
81         // Window
82         virtual void DataChanged( const DataChangedEvent& rDCEvt );
83     public:
84         OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePreviewMode);
85         virtual ~OAppBorderWindow();
86 
87         // window overloads
88         virtual void GetFocus();
89         virtual void Resize();
90 
91         OApplicationView*       getView() const;
92         OApplicationSwapWindow* getPanel() const;
93         OApplicationDetailView* getDetailView() const;
94     };
95 
96     //==================================================================
97     class OApplicationView : public ODataView
98                             ,public IClipboardTest
99                             ,public ::utl::OEventListenerAdapter
100     {
101         enum ChildFocusState
102         {
103             PANELSWAP,
104             DETAIL,
105             NONE
106         };
107     private:
108         ::com::sun::star::lang::Locale      m_aLocale;
109         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
110                                             m_xObject;
111         OAppBorderWindow*                   m_pWin;
112         IApplicationController&             m_rAppController;
113         ChildFocusState                     m_eChildFocus;
114 
115         IClipboardTest* getActiveChild() const;
116 
117         void ImplInitSettings();
118     protected:
119 
120 
121         // return the Rectangle where I can paint myself
122         virtual void resizeDocumentView(Rectangle& rRect);
123 
124         // OEventListenerAdapter
125         virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
126 
127         // Window
128         virtual void DataChanged( const DataChangedEvent& rDCEvt );
129     public:
130         OApplicationView(   Window* pParent
131                             ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
132                             ,IApplicationController&            _rAppController
133                             ,PreviewMode _ePreviewMode
134                             );
135         virtual ~OApplicationView();
136 
137         /// automatically creates mnemonics for the icon/texts in our left hand side panel
138         void    createIconAutoMnemonics( MnemonicGenerator& _rMnemonics );
139 
140         /// automatically creates mnemonics for the texts in our task pane
141         void    setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics );
142 
143         // window overloads
144         virtual long PreNotify( NotifyEvent& rNEvt );
145         virtual void GetFocus();
146 
147         inline IApplicationController&                  getAppController() const { return m_rAppController; }
148         inline const ::com::sun::star::lang::Locale&    getLocale() const { return m_aLocale;}
149 
150         // IClipboardTest
151         virtual sal_Bool isCutAllowed();
152         virtual sal_Bool isCopyAllowed();
153         virtual sal_Bool isPasteAllowed();
154         virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
155         virtual void copy();
156         virtual void cut();
157         virtual void paste();
158 
159         /// get the left panel
160         inline OApplicationSwapWindow*  getPanel()      const { return m_pWin->getPanel(); }
161         /// get the detail page
162         inline OApplicationDetailView*  getDetailView() const { return m_pWin->getDetailView(); }
163 
164         /** return the qualified name.
165             @param  _pEntry
166                 The entry of a table, or query, form, report to get the qualified name.
167                 If the entry is <NULL/>, the first selected is chosen.
168             @return
169                 the qualified name
170         */
171         ::rtl::OUString getQualifiedName( SvLBoxEntry* _pEntry ) const;
172 
173         /** returns if an entry is a leaf
174             @param _pEntry
175                 The entry to check
176             @return
177                 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
178         */
179         sal_Bool isLeaf(SvLBoxEntry* _pEntry) const;
180 
181         /** returns if one of the selected entries is a leaf
182             @return
183                 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
184         */
185         sal_Bool isALeafSelected() const;
186 
187         /** select all entries in the detail page
188         */
189         void selectAll();
190 
191         /// returns <TRUE/> if it sorts ascending
192         sal_Bool isSortUp() const;
193 
194         /// sort the entries in the detail page down
195         void sortDown();
196 
197         /// sort the entries in the detail page up
198         void sortUp();
199 
200         /// returns <TRUE/> when a detail page was filled
201         sal_Bool isFilled() const;
202 
203         /// return the element of currently select entry
204         ElementType getElementType() const;
205 
206         /// returns the count of entries
207         sal_Int32 getElementCount();
208 
209         /// returns the count of selected entries
210         sal_Int32 getSelectionCount();
211 
212         /** clears the detail page and the selection on the left side.
213             @param  _bTaskAlso
214                 If <TRUE/> the task window will also be cleared.
215         */
216         void clearPages(sal_Bool _bTaskAlso = sal_True);
217 
218         /** returns the element names which are selected
219             @param  _rNames
220                 The list will be filled.
221         */
222         void getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const;
223 
224         /** describes the current selection for the given control
225         */
226         void    describeCurrentSelectionForControl(
227                     const Control& _rControl,
228                     ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
229                 );
230 
231         /** describes the current selection for the given ElementType
232         */
233         void    describeCurrentSelectionForType(
234                     const ElementType _eType,
235                     ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
236                 );
237 
238         /** select all names on the currently selected container. Non existence names where ignored.
239         *
240         * \param _aNames the element names
241         */
242         void selectElements(const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aNames);
243 
244         /** adds a new object to the detail page.
245             @param  _eType
246                 The type where the entry shold be appended.
247             @param  _rName
248                 The name of the object to be inserted
249             @param  _rObject
250                 The object to add.
251             @param  _rxConn
252                 If we insert a table, the connection must be set.
253         */
254         SvLBoxEntry* elementAdded(ElementType _eType
255                         ,const ::rtl::OUString& _rName
256                         ,const ::com::sun::star::uno::Any& _rObject );
257 
258         /** replaces a objects name with a new one
259             @param  _eType
260                 The type where the entry shold be appended.
261             @param  _rOldName
262                 The old name of the object to be replaced
263             @param  _rNewName
264                 The new name of the object to be replaced
265             @param  _rxConn
266                 If we insert a table, the connection must be set.
267             @param  _xObject
268                 The object which was replaced
269         */
270         void elementReplaced(ElementType eType
271                         ,const ::rtl::OUString& _rOldName
272                         ,const ::rtl::OUString& _rNewName );
273 
274         /** removes an element from the detail page.
275             @param  _eType
276                 The type where the entry shold be appended.
277             @param  _rName
278                 The name of the element to be removed.
279             @param  _rxConn
280                 If we remove a table, the connection must be set.
281         */
282         void elementRemoved(ElementType _eType
283                             ,const ::rtl::OUString& _rName );
284 
285 
286         /** changes the container which should be displayed. The select handler will also be called.
287             @param  _eType
288                 Which container to show.
289         */
290         void selectContainer(ElementType _eType);
291 
292         /// returns the preview mode
293         PreviewMode getPreviewMode();
294 
295         /// <TRUE/> if the preview is enabled
296         sal_Bool isPreviewEnabled();
297 
298         /** switches to the given preview mode
299             @param  _eMode
300                 the mode to set for the preview
301         */
302         void switchPreview(PreviewMode _eMode);
303 
304         /** shows the Preview of the content when it is enabled.
305             @param  _xContent
306                 The content which must support the "preview" command.
307         */
308         void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
309 
310         /** shows the Preview of a table or query
311             @param  _sDataSourceName
312                 the name of the data source
313             @param  _xConnection
314                 the connection which will be shared
315             @param  _sName
316                 the name of table or query
317             @param  _bTable
318                 <TRUE/> if it is a table, otherwise <FALSE/>
319             @return void
320         */
321         void showPreview(   const ::rtl::OUString& _sDataSourceName,
322                             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
323                             const ::rtl::OUString& _sName,
324                             sal_Bool _bTable);
325 
326         SvLBoxEntry* getEntry( const Point& _aPosPixel ) const;
327 
328         DECL_LINK( SwitchHdl, Accelerator* );
329     };
330 }
331 #endif // DBAUI_APPVIEW_HXX
332 
333