Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_APP_APPVIEW_HXX
20 : #define INCLUDED_DBACCESS_SOURCE_UI_APP_APPVIEW_HXX
21 :
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"
31 :
32 : namespace com{ namespace sun { namespace star { namespace beans { class XPropertySet; } } } }
33 :
34 : class Control;
35 : class SvTreeListEntry;
36 : class MnemonicGenerator;
37 :
38 : namespace dbaui
39 : {
40 : class IApplicationController;
41 : class OApplicationView;
42 : class OApplicationDetailView;
43 : class OApplicationSwapWindow;
44 : class OTitleWindow;
45 : class OAppBorderWindow : public Window
46 : {
47 : OTitleWindow* m_pPanel;
48 : OApplicationDetailView* m_pDetailView;
49 : OApplicationView* m_pView;
50 :
51 : void ImplInitSettings();
52 : protected:
53 : // Window
54 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
55 : public:
56 : OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePreviewMode);
57 : virtual ~OAppBorderWindow();
58 :
59 : // window overloads
60 : virtual void GetFocus() SAL_OVERRIDE;
61 : virtual void Resize() SAL_OVERRIDE;
62 :
63 : OApplicationView* getView() const;
64 : OApplicationSwapWindow* getPanel() const;
65 : OApplicationDetailView* getDetailView() const;
66 : };
67 :
68 : class OApplicationView : public ODataView
69 : ,public IClipboardTest
70 : ,public ::utl::OEventListenerAdapter
71 : {
72 : enum ChildFocusState
73 : {
74 : PANELSWAP,
75 : DETAIL,
76 : NONE
77 : };
78 : private:
79 : ::com::sun::star::lang::Locale m_aLocale;
80 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
81 : m_xObject;
82 : OAppBorderWindow* m_pWin;
83 : IApplicationController& m_rAppController;
84 : ChildFocusState m_eChildFocus;
85 :
86 : IClipboardTest* getActiveChild() const;
87 :
88 : void ImplInitSettings();
89 : protected:
90 :
91 : // return the Rectangle where I can paint myself
92 : virtual void resizeDocumentView(Rectangle& rRect) SAL_OVERRIDE;
93 :
94 : // OEventListenerAdapter
95 : virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource ) SAL_OVERRIDE;
96 :
97 : // Window
98 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
99 : public:
100 : OApplicationView( Window* pParent
101 : ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&
102 : ,IApplicationController& _rAppController
103 : ,PreviewMode _ePreviewMode
104 : );
105 : virtual ~OApplicationView();
106 :
107 : /// automatically creates mnemonics for the icon/texts in our left hand side panel
108 : void createIconAutoMnemonics( MnemonicGenerator& _rMnemonics );
109 :
110 : /// automatically creates mnemonics for the texts in our task pane
111 : void setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics );
112 :
113 : // window overloads
114 : virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
115 : virtual void GetFocus() SAL_OVERRIDE;
116 :
117 0 : inline IApplicationController& getAppController() const { return m_rAppController; }
118 : inline const ::com::sun::star::lang::Locale& getLocale() const { return m_aLocale;}
119 :
120 : // IClipboardTest
121 : virtual sal_Bool isCutAllowed() SAL_OVERRIDE;
122 : virtual sal_Bool isCopyAllowed() SAL_OVERRIDE;
123 : virtual sal_Bool isPasteAllowed() SAL_OVERRIDE;
124 0 : virtual sal_Bool hasChildPathFocus() SAL_OVERRIDE { return HasChildPathFocus(); }
125 : virtual void copy() SAL_OVERRIDE;
126 : virtual void cut() SAL_OVERRIDE;
127 : virtual void paste() SAL_OVERRIDE;
128 :
129 : /// get the left panel
130 0 : inline OApplicationSwapWindow* getPanel() const { return m_pWin->getPanel(); }
131 : /// get the detail page
132 0 : inline OApplicationDetailView* getDetailView() const { return m_pWin->getDetailView(); }
133 :
134 : /** return the qualified name.
135 : @param _pEntry
136 : The entry of a table, or query, form, report to get the qualified name.
137 : If the entry is <NULL/>, the first selected is chosen.
138 : @return
139 : the qualified name
140 : */
141 : OUString getQualifiedName( SvTreeListEntry* _pEntry ) const;
142 :
143 : /** returns if an entry is a leaf
144 : @param _pEntry
145 : The entry to check
146 : @return
147 : <TRUE/> if the entry is a leaf, otherwise <FALSE/>
148 : */
149 : sal_Bool isLeaf(SvTreeListEntry* _pEntry) const;
150 :
151 : /** returns if one of the selected entries is a leaf
152 : @return
153 : <TRUE/> if the entry is a leaf, otherwise <FALSE/>
154 : */
155 : sal_Bool isALeafSelected() const;
156 :
157 : /** select all entries in the detail page
158 : */
159 : void selectAll();
160 :
161 : /// returns <TRUE/> if it sorts ascending
162 : sal_Bool isSortUp() const;
163 :
164 : /// sort the entries in the detail page down
165 : void sortDown();
166 :
167 : /// sort the entries in the detail page up
168 : void sortUp();
169 :
170 : /// returns <TRUE/> when a detail page was filled
171 : sal_Bool isFilled() const;
172 :
173 : /// return the element of currently select entry
174 : ElementType getElementType() const;
175 :
176 : /// returns the count of entries
177 : sal_Int32 getElementCount();
178 :
179 : /// returns the count of selected entries
180 : sal_Int32 getSelectionCount();
181 :
182 : /** clears the detail page and the selection on the left side.
183 : @param _bTaskAlso
184 : If <TRUE/> the task window will also be cleared.
185 : */
186 : void clearPages(sal_Bool _bTaskAlso = sal_True);
187 :
188 : /** returns the element names which are selected
189 : @param _rNames
190 : The list will be filled.
191 : */
192 : void getSelectionElementNames( ::std::vector< OUString>& _rNames ) const;
193 :
194 : /** describes the current selection for the given control
195 : */
196 : void describeCurrentSelectionForControl(
197 : const Control& _rControl,
198 : ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
199 : );
200 :
201 : /** describes the current selection for the given ElementType
202 : */
203 : void describeCurrentSelectionForType(
204 : const ElementType _eType,
205 : ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
206 : );
207 :
208 : /** select all names on the currently selected container. Non existence names where ignored.
209 : *
210 : * \param _aNames the element names
211 : */
212 : void selectElements(const ::com::sun::star::uno::Sequence< OUString>& _aNames);
213 :
214 : /** adds a new object to the detail page.
215 : @param _eType
216 : The type where the entry shold be appended.
217 : @param _rName
218 : The name of the object to be inserted
219 : @param _rObject
220 : The object to add.
221 : @param _rxConn
222 : If we insert a table, the connection must be set.
223 : */
224 : SvTreeListEntry* elementAdded(ElementType _eType
225 : ,const OUString& _rName
226 : ,const ::com::sun::star::uno::Any& _rObject );
227 :
228 : /** replaces a objects name with a new one
229 : @param _eType
230 : The type where the entry shold be appended.
231 : @param _rOldName
232 : The old name of the object to be replaced
233 : @param _rNewName
234 : The new name of the object to be replaced
235 : @param _rxConn
236 : If we insert a table, the connection must be set.
237 : @param _xObject
238 : The object which was replaced
239 : */
240 : void elementReplaced(ElementType eType
241 : ,const OUString& _rOldName
242 : ,const OUString& _rNewName );
243 :
244 : /** removes an element from the detail page.
245 : @param _eType
246 : The type where the entry shold be appended.
247 : @param _rName
248 : The name of the element to be removed.
249 : @param _rxConn
250 : If we remove a table, the connection must be set.
251 : */
252 : void elementRemoved(ElementType _eType
253 : ,const OUString& _rName );
254 :
255 : /** changes the container which should be displayed. The select handler will also be called.
256 : @param _eType
257 : Which container to show.
258 : */
259 : void selectContainer(ElementType _eType);
260 :
261 : /// returns the preview mode
262 : PreviewMode getPreviewMode();
263 :
264 : /// <TRUE/> if the preview is enabled
265 : sal_Bool isPreviewEnabled();
266 :
267 : /** switches to the given preview mode
268 : @param _eMode
269 : the mode to set for the preview
270 : */
271 : void switchPreview(PreviewMode _eMode);
272 :
273 : /** shows the Preview of the content when it is enabled.
274 : @param _xContent
275 : The content which must support the "preview" command.
276 : */
277 : void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
278 :
279 : /** shows the Preview of a table or query
280 : @param _sDataSourceName
281 : the name of the data source
282 : @param _xConnection
283 : the connection which will be shared
284 : @param _sName
285 : the name of table or query
286 : @param _bTable
287 : <TRUE/> if it is a table, otherwise <FALSE/>
288 : @return void
289 : */
290 : void showPreview( const OUString& _sDataSourceName,
291 : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
292 : const OUString& _sName,
293 : sal_Bool _bTable);
294 :
295 : SvTreeListEntry* getEntry( const Point& _aPosPixel ) const;
296 : };
297 : }
298 : #endif // INCLUDED_DBACCESS_SOURCE_UI_APP_APPVIEW_HXX
299 :
300 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|