LibreOffice Module extensions (master) 1
bibbeam.cxx
Go to the documentation of this file.
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
22#include <com/sun/star/awt/PosSize.hpp>
23#include <com/sun/star/uno/XComponentContext.hpp>
24
25#include <vcl/taskpanelist.hxx>
26#include <tools/debug.hxx>
27#include "bibbeam.hxx"
28#include "datman.hxx"
29#include "bibtools.hxx"
30
31using namespace ::com::sun::star;
32using namespace ::com::sun::star::beans;
33using namespace ::com::sun::star::uno;
34
35
36#define ID_TOOLBAR 1
37#define ID_GRIDWIN 2
38
39namespace bib
40{
41
42 void HandleTaskPaneList( vcl::Window* pWindow, bool bAddToList )
43 {
44 vcl::Window* pParent = pWindow->GetParent();
45
46 DBG_ASSERT( pParent, "-GetTaskPaneList(): everybody here should have a parent!" );
47
48 SystemWindow* pSysWin = pParent->GetSystemWindow();
49 if( pSysWin )
50 {
51 TaskPaneList* pTaskPaneList = pSysWin->GetTaskPaneList();
52 if( pTaskPaneList )
53 {
54 if( bAddToList )
55 pTaskPaneList->AddWindow( pWindow );
56 else
57 pTaskPaneList->RemoveWindow( pWindow );
58 }
59 }
60 }
61
62
64 :public vcl::Window //DockingWindow
65 {
66 private:
67 Reference< awt::XWindow > m_xGridWin;
68 Reference< awt::XControlModel > m_xGridModel;
69 Reference< awt::XControl > m_xControl;
70 Reference< awt::XControlContainer > m_xControlContainer;
71 Reference< frame::XDispatchProviderInterception> m_xDispatchProviderInterception;
72
73 protected:
74
75 virtual void Resize() override;
76
77 public:
78
79 BibGridwin(vcl::Window* pParent, WinBits nStyle );
80 virtual ~BibGridwin() override;
81 virtual void dispose() override;
82
83 void createGridWin(const Reference< awt::XControlModel > & xDbForm);
84 void disposeGridWin();
85
86 const Reference< awt::XControlContainer >& getControlContainer() const { return m_xControlContainer; }
87 const Reference< frame::XDispatchProviderInterception>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception; }
88
89 virtual void GetFocus() override;
90 };
91
92 BibGridwin::BibGridwin( vcl::Window* _pParent, WinBits _nStyle ) : Window( _pParent, _nStyle )
93 {
95
96 AddToTaskPaneList( this );
97 }
98
100 {
101 disposeOnce();
102 }
103
105 {
107
110 }
111
113 {
114 if(m_xGridWin.is())
115 {
116 ::Size aSize = GetOutputSizePixel();
117 m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::SIZE);
118 }
119 }
120
121 void BibGridwin::createGridWin(const uno::Reference< awt::XControlModel > & xGModel)
122 {
123 m_xGridModel = xGModel;
124
125 if( !m_xControlContainer.is())
126 return;
127
128 uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
129
130 if ( !m_xGridModel.is())
131 return;
132
133 uno::Reference< XPropertySet > xPropSet( m_xGridModel, UNO_QUERY );
134
135 if ( xPropSet.is() && m_xGridModel.is() )
136 {
137 uno::Any aAny = xPropSet->getPropertyValue( "DefaultControl" );
138 OUString aControlName;
139 aAny >>= aControlName;
140
141 m_xControl.set( xContext->getServiceManager()->createInstanceWithContext(aControlName, xContext), UNO_QUERY_THROW );
142 m_xControl->setModel( m_xGridModel );
143 }
144
145 if ( !m_xControl.is() )
146 return;
147
148 // Peer as Child to the FrameWindow
149 m_xControlContainer->addControl("GridControl", m_xControl);
150 m_xGridWin.set(m_xControl, UNO_QUERY );
152 m_xGridWin->setVisible( true );
153 m_xControl->setDesignMode( true );
154 // initially switch on the design mode - switch it off _after_ loading the form
155
156 ::Size aSize = GetOutputSizePixel();
157 m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::POSSIZE);
158 }
159
161 {
162 if ( m_xControl.is() )
163 {
164 Reference< awt::XControl > xDel( m_xControl );
165 m_xControl = nullptr;
166 m_xGridWin = nullptr;
167
168 m_xControlContainer->removeControl( xDel );
169 xDel->dispose();
170 }
171 }
172
174 {
175 if(m_xGridWin.is())
176 m_xGridWin->setFocus();
177 }
178
181 ,pDatMan( _pDM )
182 ,pToolBar( nullptr )
183 ,pGridWin( nullptr )
184 {
188 pGridWin->Show();
190 }
191
193 {
194 disposeOnce();
195 }
196
198 {
199 if ( isFormConnected() )
201
202 if ( pToolBar )
203 pDatMan->SetToolbar(nullptr);
204
206 pGridWin.disposeAndClear();
208 }
209
211 {
212 pToolBar= VclPtr<BibToolBar>::Create(this, LINK( this, BibBeamer, RecalcLayout_Impl ));
213 ::Size aSize=pToolBar->get_preferred_size();
214 InsertItem(ID_TOOLBAR, pToolBar, aSize.Height(), 0, 0, SplitWindowItemFlags::Fixed );
215 if ( m_xController.is() )
216 pToolBar->SetXController( m_xController );
217 }
218
220 {
222
223 InsertItem(ID_GRIDWIN, pGridWin, 40, 1, 0, SplitWindowItemFlags::RelativeSize );
224
225 pGridWin->createGridWin( pDatMan->updateGridModel() );
226 }
227
228 Reference< awt::XControlContainer > BibBeamer::getControlContainer()
229 {
230 Reference< awt::XControlContainer > xReturn;
231 if ( pGridWin )
232 xReturn = pGridWin->getControlContainer();
233 return xReturn;
234 }
235
236 Reference< frame::XDispatchProviderInterception > BibBeamer::getDispatchProviderInterception() const
237 {
238 Reference< frame::XDispatchProviderInterception > xReturn;
239 if ( pGridWin )
240 xReturn = pGridWin->getDispatchProviderInterception();
241 return xReturn;
242 }
243
244 void BibBeamer::SetXController(const uno::Reference< frame::XController > & xCtr)
245 {
246 m_xController = xCtr;
247
248 if ( pToolBar )
249 pToolBar->SetXController( m_xController );
250
251 }
252
254 {
255 if( pGridWin )
256 pGridWin->GrabFocus();
257 }
258
259 IMPL_LINK_NOARG( BibBeamer, RecalcLayout_Impl, void*, void )
260 {
261 tools::Long nHeight = pToolBar->get_preferred_size().Height();
262 SetItemSize( ID_TOOLBAR, nHeight );
263 }
264
265} // namespace bib
266
267/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define ID_GRIDWIN
Definition: bibbeam.cxx:37
#define ID_TOOLBAR
Definition: bibbeam.cxx:36
css::uno::Reference< css::awt::XControlModel > const & updateGridModel(const css::uno::Reference< css::form::XForm > &xDbForm)
void SetToolbar(BibToolBar *pSet)
Definition: datman.cxx:1362
constexpr tools::Long Height() const
constexpr tools::Long Width() const
virtual void dispose() override
void InsertItem(sal_uInt16 nId, vcl::Window *pWindow, tools::Long nSize, sal_uInt16 nPos, sal_uInt16 nIntoSetId, SplitWindowItemFlags nBits)
TaskPaneList * GetTaskPaneList()
void AddWindow(vcl::Window *pWindow)
void RemoveWindow(vcl::Window *pWindow)
static css::uno::Reference< css::awt::XControlContainer > CreateControlContainer(vcl::Window *pWindow)
void disposeAndClear()
static VclPtr< reference_type > Create(Arg &&... arg)
BibDataManager * pDatMan
Definition: bibbeam.hxx:42
void SetXController(const css::uno::Reference< css::frame::XController > &)
Definition: bibbeam.cxx:244
VclPtr< BibToolBar > pToolBar
Definition: bibbeam.hxx:43
virtual css::uno::Reference< css::awt::XControlContainer > getControlContainer() override
Definition: bibbeam.cxx:228
void createGridWin()
Definition: bibbeam.cxx:219
css::uno::Reference< css::frame::XDispatchProviderInterception > getDispatchProviderInterception() const
Definition: bibbeam.cxx:236
void createToolBar()
Definition: bibbeam.cxx:210
virtual void GetFocus() override
Definition: bibbeam.cxx:253
virtual ~BibBeamer() override
Definition: bibbeam.cxx:192
BibBeamer(vcl::Window *pParent, BibDataManager *pDatMan)
Definition: bibbeam.cxx:179
css::uno::Reference< css::frame::XController > m_xController
Definition: bibbeam.hxx:40
VclPtr< BibGridwin > pGridWin
Definition: bibbeam.hxx:44
virtual void dispose() override
Definition: bibbeam.cxx:197
virtual void dispose() override
Definition: bibbeam.cxx:104
void createGridWin(const Reference< awt::XControlModel > &xDbForm)
Definition: bibbeam.cxx:121
Reference< awt::XControlContainer > m_xControlContainer
Definition: bibbeam.cxx:70
virtual ~BibGridwin() override
Definition: bibbeam.cxx:99
BibGridwin(vcl::Window *pParent, WinBits nStyle)
Definition: bibbeam.cxx:92
virtual void Resize() override
Definition: bibbeam.cxx:112
Reference< awt::XControlModel > m_xGridModel
Definition: bibbeam.cxx:68
const Reference< frame::XDispatchProviderInterception > & getDispatchProviderInterception() const
Definition: bibbeam.cxx:87
const Reference< awt::XControlContainer > & getControlContainer() const
Definition: bibbeam.cxx:86
void disposeGridWin()
Definition: bibbeam.cxx:160
virtual void GetFocus() override
Definition: bibbeam.cxx:173
Reference< frame::XDispatchProviderInterception > m_xDispatchProviderInterception
Definition: bibbeam.cxx:71
Reference< awt::XControl > m_xControl
Definition: bibbeam.cxx:69
Reference< awt::XWindow > m_xGridWin
Definition: bibbeam.cxx:67
void connectForm(const css::uno::Reference< css::form::XLoadable > &_rxForm)
virtual void dispose() override
vcl::Window * GetParent() const
SystemWindow * GetSystemWindow() const
Size GetOutputSizePixel() const
#define DBG_ASSERT(sCon, aError)
Definition: bibbeam.cxx:40
void AddToTaskPaneList(vcl::Window *pWindowToBeHandled)
Definition: bibtools.hxx:31
IMPL_LINK_NOARG(BibBeamer, RecalcLayout_Impl, void *, void)
Definition: bibbeam.cxx:259
void RemoveFromTaskPaneList(vcl::Window *pWindowToBeHandled)
Definition: bibtools.hxx:36
void HandleTaskPaneList(vcl::Window *pWindow, bool bAddToList)
Definition: bibbeam.cxx:42
Reference< XComponentContext > getProcessComponentContext()
long Long
sal_Int64 WinBits
WinBits const WB_3DLOOK
WinBits const WB_NOSPLITDRAW