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 DBAUI_APPVIEW_HXX
20 #define DBAUI_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 //==================================================================
46 class OAppBorderWindow
: public Window
48 OTitleWindow
* m_pPanel
;
49 OApplicationDetailView
* m_pDetailView
;
50 OApplicationView
* m_pView
;
52 void ImplInitSettings();
55 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
57 OAppBorderWindow(OApplicationView
* _pParent
,PreviewMode _ePreviewMode
);
58 virtual ~OAppBorderWindow();
61 virtual void GetFocus();
62 virtual void Resize();
64 OApplicationView
* getView() const;
65 OApplicationSwapWindow
* getPanel() const;
66 OApplicationDetailView
* getDetailView() const;
69 //==================================================================
70 class OApplicationView
: public ODataView
71 ,public IClipboardTest
72 ,public ::utl::OEventListenerAdapter
81 ::com::sun::star::lang::Locale m_aLocale
;
82 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>
84 OAppBorderWindow
* m_pWin
;
85 IApplicationController
& m_rAppController
;
86 ChildFocusState m_eChildFocus
;
88 IClipboardTest
* getActiveChild() const;
90 void ImplInitSettings();
94 // return the Rectangle where I can paint myself
95 virtual void resizeDocumentView(Rectangle
& rRect
);
97 // OEventListenerAdapter
98 virtual void _disposing( const ::com::sun::star::lang::EventObject
& _rSource
);
101 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
103 OApplicationView( Window
* pParent
104 ,const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>&
105 ,IApplicationController
& _rAppController
106 ,PreviewMode _ePreviewMode
108 virtual ~OApplicationView();
110 /// automatically creates mnemonics for the icon/texts in our left hand side panel
111 void createIconAutoMnemonics( MnemonicGenerator
& _rMnemonics
);
113 /// automatically creates mnemonics for the texts in our task pane
114 void setTaskExternalMnemonics( MnemonicGenerator
& _rMnemonics
);
117 virtual long PreNotify( NotifyEvent
& rNEvt
);
118 virtual void GetFocus();
120 inline IApplicationController
& getAppController() const { return m_rAppController
; }
121 inline const ::com::sun::star::lang::Locale
& getLocale() const { return m_aLocale
;}
124 virtual sal_Bool
isCutAllowed();
125 virtual sal_Bool
isCopyAllowed();
126 virtual sal_Bool
isPasteAllowed();
127 virtual sal_Bool
hasChildPathFocus() { return HasChildPathFocus(); }
130 virtual void paste();
132 /// get the left panel
133 inline OApplicationSwapWindow
* getPanel() const { return m_pWin
->getPanel(); }
134 /// get the detail page
135 inline OApplicationDetailView
* getDetailView() const { return m_pWin
->getDetailView(); }
137 /** return the qualified name.
139 The entry of a table, or query, form, report to get the qualified name.
140 If the entry is <NULL/>, the first selected is chosen.
144 OUString
getQualifiedName( SvTreeListEntry
* _pEntry
) const;
146 /** returns if an entry is a leaf
150 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
152 sal_Bool
isLeaf(SvTreeListEntry
* _pEntry
) const;
154 /** returns if one of the selected entries is a leaf
156 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
158 sal_Bool
isALeafSelected() const;
160 /** select all entries in the detail page
164 /// returns <TRUE/> if it sorts ascending
165 sal_Bool
isSortUp() const;
167 /// sort the entries in the detail page down
170 /// sort the entries in the detail page up
173 /// returns <TRUE/> when a detail page was filled
174 sal_Bool
isFilled() const;
176 /// return the element of currently select entry
177 ElementType
getElementType() const;
179 /// returns the count of entries
180 sal_Int32
getElementCount();
182 /// returns the count of selected entries
183 sal_Int32
getSelectionCount();
185 /** clears the detail page and the selection on the left side.
187 If <TRUE/> the task window will also be cleared.
189 void clearPages(sal_Bool _bTaskAlso
= sal_True
);
191 /** returns the element names which are selected
193 The list will be filled.
195 void getSelectionElementNames( ::std::vector
< OUString
>& _rNames
) const;
197 /** describes the current selection for the given control
199 void describeCurrentSelectionForControl(
200 const Control
& _rControl
,
201 ::com::sun::star::uno::Sequence
< ::com::sun::star::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
204 /** describes the current selection for the given ElementType
206 void describeCurrentSelectionForType(
207 const ElementType _eType
,
208 ::com::sun::star::uno::Sequence
< ::com::sun::star::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
211 /** select all names on the currently selected container. Non existence names where ignored.
213 * \param _aNames the element names
215 void selectElements(const ::com::sun::star::uno::Sequence
< OUString
>& _aNames
);
217 /** adds a new object to the detail page.
219 The type where the entry shold be appended.
221 The name of the object to be inserted
225 If we insert a table, the connection must be set.
227 SvTreeListEntry
* elementAdded(ElementType _eType
228 ,const OUString
& _rName
229 ,const ::com::sun::star::uno::Any
& _rObject
);
231 /** replaces a objects name with a new one
233 The type where the entry shold be appended.
235 The old name of the object to be replaced
237 The new name of the object to be replaced
239 If we insert a table, the connection must be set.
241 The object which was replaced
243 void elementReplaced(ElementType eType
244 ,const OUString
& _rOldName
245 ,const OUString
& _rNewName
);
247 /** removes an element from the detail page.
249 The type where the entry shold be appended.
251 The name of the element to be removed.
253 If we remove a table, the connection must be set.
255 void elementRemoved(ElementType _eType
256 ,const OUString
& _rName
);
259 /** changes the container which should be displayed. The select handler will also be called.
261 Which container to show.
263 void selectContainer(ElementType _eType
);
265 /// returns the preview mode
266 PreviewMode
getPreviewMode();
268 /// <TRUE/> if the preview is enabled
269 sal_Bool
isPreviewEnabled();
271 /** switches to the given preview mode
273 the mode to set for the preview
275 void switchPreview(PreviewMode _eMode
);
277 /** shows the Preview of the content when it is enabled.
279 The content which must support the "preview" command.
281 void showPreview(const ::com::sun::star::uno::Reference
< ::com::sun::star::ucb::XContent
>& _xContent
);
283 /** shows the Preview of a table or query
284 @param _sDataSourceName
285 the name of the data source
287 the connection which will be shared
289 the name of table or query
291 <TRUE/> if it is a table, otherwise <FALSE/>
294 void showPreview( const OUString
& _sDataSourceName
,
295 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _xConnection
,
296 const OUString
& _sName
,
299 SvTreeListEntry
* getEntry( const Point
& _aPosPixel
) const;
302 #endif // DBAUI_APPVIEW_HXX
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */