1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AppView.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef DBAUI_APPVIEW_HXX
31 #define DBAUI_APPVIEW_HXX
33 #ifndef DBAUI_DATAVIEW_HXX
34 #include "dataview.hxx"
36 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
37 #include <com/sun/star/container/XNameAccess.hpp>
39 #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
40 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
42 #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
43 #include <com/sun/star/ucb/XContent.hpp>
45 #ifndef _COM_SUN_STAR_SDB_APPLICATION_NAMEDDATABASEOBJECT_HPP_
46 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
49 #include <vcl/fixed.hxx>
51 #ifndef _UNOTOOLS_EVENTLISTENERADAPTER_HXX_
52 #include <unotools/eventlisteneradapter.hxx>
54 #ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
55 #include "IClipBoardTest.hxx"
57 #ifndef DBAUI_APPELEMENTTYPE_HXX
58 #include "AppElementType.hxx"
61 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{ class XPropertySet
; } } } }
65 class MnemonicGenerator
;
69 class IControlActionListener
;
70 class IApplicationController
;
71 class OApplicationView
;
72 class OApplicationDetailView
;
73 class OApplicationSwapWindow
;
75 //==================================================================
76 class OAppBorderWindow
: public Window
78 OTitleWindow
* m_pPanel
;
79 OApplicationDetailView
* m_pDetailView
;
80 OApplicationView
* m_pView
;
82 void ImplInitSettings();
85 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
87 OAppBorderWindow(OApplicationView
* _pParent
,PreviewMode _ePreviewMode
);
88 virtual ~OAppBorderWindow();
91 virtual void GetFocus();
92 virtual void Resize();
94 OApplicationView
* getView() const;
95 OApplicationSwapWindow
* getPanel() const;
96 OApplicationDetailView
* getDetailView() const;
99 //==================================================================
100 class OApplicationView
: public ODataView
101 ,public IClipboardTest
102 ,public ::utl::OEventListenerAdapter
111 ::com::sun::star::lang::Locale m_aLocale
;
112 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>
114 OAppBorderWindow
* m_pWin
;
115 IApplicationController
& m_rAppController
;
116 ChildFocusState m_eChildFocus
;
118 IClipboardTest
* getActiveChild() const;
120 void ImplInitSettings();
124 // return the Rectangle where I can paint myself
125 virtual void resizeDocumentView(Rectangle
& rRect
);
127 // OEventListenerAdapter
128 virtual void _disposing( const ::com::sun::star::lang::EventObject
& _rSource
);
131 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
133 OApplicationView( Window
* pParent
134 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>&
135 ,IApplicationController
& _rAppController
136 ,PreviewMode _ePreviewMode
138 virtual ~OApplicationView();
140 /// automatically creates mnemonics for the icon/texts in our left hand side panel
141 void createIconAutoMnemonics( MnemonicGenerator
& _rMnemonics
);
143 /// automatically creates mnemonics for the texts in our task pane
144 void setTaskExternalMnemonics( MnemonicGenerator
& _rMnemonics
);
147 virtual long PreNotify( NotifyEvent
& rNEvt
);
148 virtual void GetFocus();
150 inline IApplicationController
& getAppController() const { return m_rAppController
; }
151 inline const ::com::sun::star::lang::Locale
& getLocale() const { return m_aLocale
;}
154 virtual sal_Bool
isCutAllowed();
155 virtual sal_Bool
isCopyAllowed();
156 virtual sal_Bool
isPasteAllowed();
157 virtual sal_Bool
hasChildPathFocus() { return HasChildPathFocus(); }
160 virtual void paste();
162 /// get the left panel
163 inline OApplicationSwapWindow
* getPanel() const { return m_pWin
->getPanel(); }
164 /// get the detail page
165 inline OApplicationDetailView
* getDetailView() const { return m_pWin
->getDetailView(); }
167 /** return the qualified name.
169 The entry of a table, or query, form, report to get the qualified name.
170 If the entry is <NULL/>, the first selected is chosen.
174 ::rtl::OUString
getQualifiedName( SvLBoxEntry
* _pEntry
) const;
176 /** returns if an entry is a leaf
180 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
182 sal_Bool
isLeaf(SvLBoxEntry
* _pEntry
) const;
184 /** returns if one of the selected entries is a leaf
186 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
188 sal_Bool
isALeafSelected() const;
190 /** select all entries in the detail page
194 /// returns <TRUE/> if it sorts ascending
195 sal_Bool
isSortUp() const;
197 /// sort the entries in the detail page down
200 /// sort the entries in the detail page up
203 /// returns <TRUE/> when a detail page was filled
204 sal_Bool
isFilled() const;
206 /// return the element of currently select entry
207 ElementType
getElementType() const;
209 /// returns the count of entries
210 sal_Int32
getElementCount();
212 /// returns the count of selected entries
213 sal_Int32
getSelectionCount();
215 /** clears the detail page and the selection on the left side.
217 If <TRUE/> the task window will also be cleared.
219 void clearPages(sal_Bool _bTaskAlso
= sal_True
);
221 /** returns the element names which are selected
223 The list will be filled.
225 void getSelectionElementNames( ::std::vector
< ::rtl::OUString
>& _rNames
) const;
227 /** describes the current selection for the given control
229 void describeCurrentSelectionForControl(
230 const Control
& _rControl
,
231 ::com::sun::star::uno::Sequence
< ::com::sun::star::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
234 /** describes the current selection for the given ElementType
236 void describeCurrentSelectionForType(
237 const ElementType _eType
,
238 ::com::sun::star::uno::Sequence
< ::com::sun::star::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
241 /** select all names on the currently selected container. Non existence names where ignored.
243 * \param _aNames the element names
245 void selectElements(const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& _aNames
);
247 /** adds a new object to the detail page.
249 The type where the entry shold be appended.
251 The name of the object to be inserted
255 If we insert a table, the connection must be set.
257 SvLBoxEntry
* elementAdded(ElementType _eType
258 ,const ::rtl::OUString
& _rName
259 ,const ::com::sun::star::uno::Any
& _rObject
);
261 /** replaces a objects name with a new one
263 The type where the entry shold be appended.
265 The old name of the object to be replaced
267 The new name of the object to be replaced
269 If we insert a table, the connection must be set.
271 The object which was replaced
273 void elementReplaced(ElementType eType
274 ,const ::rtl::OUString
& _rOldName
275 ,const ::rtl::OUString
& _rNewName
);
277 /** removes an element from the detail page.
279 The type where the entry shold be appended.
281 The name of the element to be removed.
283 If we remove a table, the connection must be set.
285 void elementRemoved(ElementType _eType
286 ,const ::rtl::OUString
& _rName
);
289 /** changes the container which should be displayed. The select handler will also be called.
291 Which container to show.
293 void selectContainer(ElementType _eType
);
295 /// returns the preview mode
296 PreviewMode
getPreviewMode();
298 /// <TRUE/> if the preview is enabled
299 sal_Bool
isPreviewEnabled();
301 /** switches to the given preview mode
303 the mode to set for the preview
305 void switchPreview(PreviewMode _eMode
);
307 /** shows the Preview of the content when it is enabled.
309 The content which must support the "preview" command.
311 void showPreview(const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XContent
>& _xContent
);
313 /** shows the Preview of a table or query
314 @param _sDataSourceName
315 the name of the data source
317 the connection which will be shared
319 the name of table or query
321 <TRUE/> if it is a table, otherwise <FALSE/>
324 void showPreview( const ::rtl::OUString
& _sDataSourceName
,
325 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _xConnection
,
326 const ::rtl::OUString
& _sName
,
329 SvLBoxEntry
* getEntry( const Point
& _aPosPixel
) const;
331 DECL_LINK( SwitchHdl
, Accelerator
* );
334 #endif // DBAUI_APPVIEW_HXX