1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef DBAUI_APPVIEW_HXX
29 #define DBAUI_APPVIEW_HXX
31 #include "dataview.hxx"
32 #include <com/sun/star/container/XNameAccess.hpp>
33 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
34 #include <com/sun/star/ucb/XContent.hpp>
35 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
36 #include <vcl/fixed.hxx>
37 #include <unotools/eventlisteneradapter.hxx>
38 #include "IClipBoardTest.hxx"
39 #include "AppElementType.hxx"
41 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{ class XPropertySet
; } } } }
45 class MnemonicGenerator
;
49 class IControlActionListener
;
50 class IApplicationController
;
51 class OApplicationView
;
52 class OApplicationDetailView
;
53 class OApplicationSwapWindow
;
55 //==================================================================
56 class OAppBorderWindow
: public Window
58 OTitleWindow
* m_pPanel
;
59 OApplicationDetailView
* m_pDetailView
;
60 OApplicationView
* m_pView
;
62 void ImplInitSettings();
65 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
67 OAppBorderWindow(OApplicationView
* _pParent
,PreviewMode _ePreviewMode
);
68 virtual ~OAppBorderWindow();
71 virtual void GetFocus();
72 virtual void Resize();
74 OApplicationView
* getView() const;
75 OApplicationSwapWindow
* getPanel() const;
76 OApplicationDetailView
* getDetailView() const;
79 //==================================================================
80 class OApplicationView
: public ODataView
81 ,public IClipboardTest
82 ,public ::utl::OEventListenerAdapter
91 ::com::sun::star::lang::Locale m_aLocale
;
92 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>
94 OAppBorderWindow
* m_pWin
;
95 IApplicationController
& m_rAppController
;
96 ChildFocusState m_eChildFocus
;
98 IClipboardTest
* getActiveChild() const;
100 void ImplInitSettings();
104 // return the Rectangle where I can paint myself
105 virtual void resizeDocumentView(Rectangle
& rRect
);
107 // OEventListenerAdapter
108 virtual void _disposing( const ::com::sun::star::lang::EventObject
& _rSource
);
111 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
113 OApplicationView( Window
* pParent
114 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>&
115 ,IApplicationController
& _rAppController
116 ,PreviewMode _ePreviewMode
118 virtual ~OApplicationView();
120 /// automatically creates mnemonics for the icon/texts in our left hand side panel
121 void createIconAutoMnemonics( MnemonicGenerator
& _rMnemonics
);
123 /// automatically creates mnemonics for the texts in our task pane
124 void setTaskExternalMnemonics( MnemonicGenerator
& _rMnemonics
);
127 virtual long PreNotify( NotifyEvent
& rNEvt
);
128 virtual void GetFocus();
130 inline IApplicationController
& getAppController() const { return m_rAppController
; }
131 inline const ::com::sun::star::lang::Locale
& getLocale() const { return m_aLocale
;}
134 virtual sal_Bool
isCutAllowed();
135 virtual sal_Bool
isCopyAllowed();
136 virtual sal_Bool
isPasteAllowed();
137 virtual sal_Bool
hasChildPathFocus() { return HasChildPathFocus(); }
140 virtual void paste();
142 /// get the left panel
143 inline OApplicationSwapWindow
* getPanel() const { return m_pWin
->getPanel(); }
144 /// get the detail page
145 inline OApplicationDetailView
* getDetailView() const { return m_pWin
->getDetailView(); }
147 /** return the qualified name.
149 The entry of a table, or query, form, report to get the qualified name.
150 If the entry is <NULL/>, the first selected is chosen.
154 ::rtl::OUString
getQualifiedName( SvLBoxEntry
* _pEntry
) const;
156 /** returns if an entry is a leaf
160 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
162 sal_Bool
isLeaf(SvLBoxEntry
* _pEntry
) const;
164 /** returns if one of the selected entries is a leaf
166 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
168 sal_Bool
isALeafSelected() const;
170 /** select all entries in the detail page
174 /// returns <TRUE/> if it sorts ascending
175 sal_Bool
isSortUp() const;
177 /// sort the entries in the detail page down
180 /// sort the entries in the detail page up
183 /// returns <TRUE/> when a detail page was filled
184 sal_Bool
isFilled() const;
186 /// return the element of currently select entry
187 ElementType
getElementType() const;
189 /// returns the count of entries
190 sal_Int32
getElementCount();
192 /// returns the count of selected entries
193 sal_Int32
getSelectionCount();
195 /** clears the detail page and the selection on the left side.
197 If <TRUE/> the task window will also be cleared.
199 void clearPages(sal_Bool _bTaskAlso
= sal_True
);
201 /** returns the element names which are selected
203 The list will be filled.
205 void getSelectionElementNames( ::std::vector
< ::rtl::OUString
>& _rNames
) const;
207 /** describes the current selection for the given control
209 void describeCurrentSelectionForControl(
210 const Control
& _rControl
,
211 ::com::sun::star::uno::Sequence
< ::com::sun::star::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
214 /** describes the current selection for the given ElementType
216 void describeCurrentSelectionForType(
217 const ElementType _eType
,
218 ::com::sun::star::uno::Sequence
< ::com::sun::star::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
221 /** select all names on the currently selected container. Non existence names where ignored.
223 * \param _aNames the element names
225 void selectElements(const ::com::sun::star::uno::Sequence
< ::rtl::OUString
>& _aNames
);
227 /** adds a new object to the detail page.
229 The type where the entry shold be appended.
231 The name of the object to be inserted
235 If we insert a table, the connection must be set.
237 SvLBoxEntry
* elementAdded(ElementType _eType
238 ,const ::rtl::OUString
& _rName
239 ,const ::com::sun::star::uno::Any
& _rObject
);
241 /** replaces a objects name with a new one
243 The type where the entry shold be appended.
245 The old name of the object to be replaced
247 The new name of the object to be replaced
249 If we insert a table, the connection must be set.
251 The object which was replaced
253 void elementReplaced(ElementType eType
254 ,const ::rtl::OUString
& _rOldName
255 ,const ::rtl::OUString
& _rNewName
);
257 /** removes an element from the detail page.
259 The type where the entry shold be appended.
261 The name of the element to be removed.
263 If we remove a table, the connection must be set.
265 void elementRemoved(ElementType _eType
266 ,const ::rtl::OUString
& _rName
);
269 /** changes the container which should be displayed. The select handler will also be called.
271 Which container to show.
273 void selectContainer(ElementType _eType
);
275 /// returns the preview mode
276 PreviewMode
getPreviewMode();
278 /// <TRUE/> if the preview is enabled
279 sal_Bool
isPreviewEnabled();
281 /** switches to the given preview mode
283 the mode to set for the preview
285 void switchPreview(PreviewMode _eMode
);
287 /** shows the Preview of the content when it is enabled.
289 The content which must support the "preview" command.
291 void showPreview(const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XContent
>& _xContent
);
293 /** shows the Preview of a table or query
294 @param _sDataSourceName
295 the name of the data source
297 the connection which will be shared
299 the name of table or query
301 <TRUE/> if it is a table, otherwise <FALSE/>
304 void showPreview( const ::rtl::OUString
& _sDataSourceName
,
305 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _xConnection
,
306 const ::rtl::OUString
& _sName
,
309 SvLBoxEntry
* getEntry( const Point
& _aPosPixel
) const;
312 #endif // DBAUI_APPVIEW_HXX
314 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */