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 .
21 #include <dbaccess/dataview.hxx>
22 #include <com/sun/star/ucb/XContent.hpp>
23 #include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
24 #include <com/sun/star/sdbc/XConnection.hpp>
25 #include <unotools/eventlisteneradapter.hxx>
26 #include <vcl/InterimItemWindow.hxx>
27 #include <vcl/weld.hxx>
28 #include <IClipBoardTest.hxx>
29 #include <AppElementType.hxx>
31 namespace com::sun::star::beans
{ class XPropertySet
; }
33 class MnemonicGenerator
;
37 class OApplicationView
;
38 class OApplicationDetailView
;
39 class OApplicationSwapWindow
;
41 class OApplicationController
;
43 class OAppBorderWindow final
: public InterimItemWindow
45 std::unique_ptr
<weld::Container
> m_xPanelParent
;
46 std::unique_ptr
<weld::Container
> m_xDetailViewParent
;
47 std::unique_ptr
<OTitleWindow
> m_xPanel
;
48 std::unique_ptr
<OApplicationDetailView
> m_xDetailView
;
49 VclPtr
<OApplicationView
> m_xView
;
52 OAppBorderWindow(OApplicationView
* pParent
, PreviewMode ePreviewMode
);
53 virtual ~OAppBorderWindow() override
;
54 virtual void dispose() override
;
57 virtual void GetFocus() override
;
59 OApplicationView
* getView() const { return m_xView
.get(); }
60 OApplicationSwapWindow
* getPanel() const;
61 OApplicationDetailView
* getDetailView() const { return m_xDetailView
.get(); }
62 weld::Container
& getTopLevel() { return *m_xContainer
; }
65 class OApplicationView
: public ODataView
66 ,public IClipboardTest
67 ,public ::utl::OEventListenerAdapter
76 css::uno::Reference
< css::lang::XComponent
>
78 VclPtr
<OAppBorderWindow
> m_pWin
;
79 OApplicationController
& m_rAppController
;
81 ChildFocusState
getChildFocus() const;
82 IClipboardTest
* getActiveChild() const;
84 void ImplInitSettings();
87 // return the Rectangle where I can paint myself
88 virtual void resizeDocumentView(tools::Rectangle
& rRect
) override
;
90 // OEventListenerAdapter
91 virtual void _disposing( const css::lang::EventObject
& _rSource
) override
;
94 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
96 OApplicationView( vcl::Window
* pParent
97 ,const css::uno::Reference
< css::uno::XComponentContext
>&
98 ,OApplicationController
& _rAppController
99 ,PreviewMode _ePreviewMode
101 virtual ~OApplicationView() override
;
102 virtual void dispose() override
;
104 /// automatically creates mnemonics for the icon/texts in our left hand side panel
105 void createIconAutoMnemonics( MnemonicGenerator
& _rMnemonics
);
107 /// automatically creates mnemonics for the texts in our task pane
108 void setTaskExternalMnemonics( MnemonicGenerator
const & _rMnemonics
);
111 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
112 virtual void GetFocus() override
;
114 OApplicationController
& getAppController() const { return m_rAppController
; }
117 virtual bool isCutAllowed() override
;
118 virtual bool isCopyAllowed() override
;
119 virtual bool isPasteAllowed() override
;
120 virtual void copy() override
;
121 virtual void cut() override
;
122 virtual void paste() override
;
124 /// get the left panel
125 OApplicationSwapWindow
* getPanel() const { return m_pWin
->getPanel(); }
126 /// get the detail page
127 OApplicationDetailView
* getDetailView() const { return m_pWin
->getDetailView(); }
129 /** return the qualified name.
131 The entry of a table, or query, form, report to get the qualified name.
132 If the entry is <NULL/>, the first selected is chosen.
136 OUString
getQualifiedName(const weld::TreeIter
* _pEntry
) const;
138 /** returns if an entry is a leaf
140 The TreeView rEntry belongs to
144 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
146 bool isLeaf(const weld::TreeView
& rTreeView
, const weld::TreeIter
& rEntry
) const;
148 /** returns if one of the selected entries is a leaf
150 <TRUE/> if the entry is a leaf, otherwise <FALSE/>
152 bool isALeafSelected() const;
154 /** select all entries in the detail page
158 /// returns <TRUE/> if it sorts ascending
159 bool isSortUp() const;
161 /// sort the entries in the detail page down
164 /// sort the entries in the detail page up
167 /// returns <TRUE/> when a detail page was filled
168 bool isFilled() const;
170 /// return the element of currently select entry
171 ElementType
getElementType() const;
173 /// returns the count of entries
174 sal_Int32
getElementCount() const;
176 /// returns the count of selected entries
177 sal_Int32
getSelectionCount() const;
179 /** clears the detail page and the selection on the left side.
180 The task window will also be cleared.
184 /** returns the element names which are selected
186 The list will be filled.
188 void getSelectionElementNames( std::vector
< OUString
>& _rNames
) const;
190 /** describes the current selection for the given control
192 void describeCurrentSelectionForControl(
193 const weld::TreeView
& rControl
,
194 css::uno::Sequence
< css::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
197 /** describes the current selection for the given ElementType
199 void describeCurrentSelectionForType(
200 const ElementType _eType
,
201 css::uno::Sequence
< css::sdb::application::NamedDatabaseObject
>& _out_rSelectedObjects
204 /** get the menu parent window for the given control
206 vcl::Window
* getMenuParent() const;
208 /** adjust rPos relative to rControl to instead relative to getMenuParent */
209 void adjustMenuPosition(const weld::TreeView
& rControl
, ::Point
& rPos
) const;
211 /** select all names on the currently selected container. Non existence names where ignored.
213 * \param _aNames the element names
215 void selectElements(const css::uno::Sequence
< OUString
>& _aNames
);
217 /** adds a new object to the detail page.
219 The type where the entry should be appended.
221 The name of the object to be inserted
225 If we insert a table, the connection must be set.
227 std::unique_ptr
<weld::TreeIter
> elementAdded(ElementType eType
,
228 const OUString
& rName
,
229 const css::uno::Any
& rObject
);
231 /** replaces an objects name with a new one
233 The type where the entry should 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 should 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
);
258 /** changes the container which should be displayed. The select handler will also be called.
260 Which container to show.
262 void selectContainer(ElementType _eType
);
264 /// returns the preview mode
265 PreviewMode
getPreviewMode() const;
267 /// <TRUE/> if the preview is enabled
268 bool isPreviewEnabled() const;
270 /** switches to the given preview mode
272 the mode to set for the preview
274 void switchPreview(PreviewMode _eMode
);
276 /** shows the Preview of the content when it is enabled.
278 The content which must support the "preview" command.
280 void showPreview(const css::uno::Reference
< css::ucb::XContent
>& _xContent
);
282 /** shows the Preview of a table or query
283 @param _sDataSourceName
284 the name of the data source
286 the connection which will be shared
288 the name of table or query
290 <TRUE/> if it is a table, otherwise <FALSE/>
293 void showPreview( const OUString
& _sDataSourceName
,
294 const css::uno::Reference
< css::sdbc::XConnection
>& _xConnection
,
295 const OUString
& _sName
,
298 std::unique_ptr
<weld::TreeIter
> getEntry(const Point
& rPosPixel
) const;
302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */