1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <toolkit/helper/vclunohelper.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <vcl/taskpanelist.hxx>
#include <tools/debug.hxx>
#include "bibbeam.hxx"
#include "datman.hxx"
#include "bibtools.hxx"
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
#define ID_TOOLBAR 1
#define ID_GRIDWIN 2
namespace bib
{
void HandleTaskPaneList( vcl::Window* pWindow, bool bAddToList )
{
vcl::Window* pParent = pWindow->GetParent();
DBG_ASSERT( pParent, "-GetTaskPaneList(): everybody here should have a parent!" );
SystemWindow* pSysWin = pParent->GetSystemWindow();
if( pSysWin )
{
TaskPaneList* pTaskPaneList = pSysWin->GetTaskPaneList();
if( pTaskPaneList )
{
if( bAddToList )
pTaskPaneList->AddWindow( pWindow );
else
pTaskPaneList->RemoveWindow( pWindow );
}
}
}
class BibGridwin
:public vcl::Window //DockingWindow
{
private:
Reference< awt::XWindow > m_xGridWin;
Reference< awt::XControlModel > m_xGridModel;
Reference< awt::XControl > m_xControl;
Reference< awt::XControlContainer > m_xControlContainer;
Reference< frame::XDispatchProviderInterception> m_xDispatchProviderInterception;
protected:
virtual void Resize() override;
public:
BibGridwin(vcl::Window* pParent, WinBits nStyle );
virtual ~BibGridwin() override;
virtual void dispose() override;
void createGridWin(const Reference< awt::XControlModel > & xDbForm);
void disposeGridWin();
const Reference< awt::XControlContainer >& getControlContainer() const { return m_xControlContainer; }
const Reference< frame::XDispatchProviderInterception>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception; }
virtual void GetFocus() override;
};
BibGridwin::BibGridwin( vcl::Window* _pParent, WinBits _nStyle ) : Window( _pParent, _nStyle )
{
m_xControlContainer = VCLUnoHelper::CreateControlContainer(this);
AddToTaskPaneList( this );
}
BibGridwin::~BibGridwin()
{
disposeOnce();
}
void BibGridwin::dispose()
{
RemoveFromTaskPaneList( this );
disposeGridWin();
vcl::Window::dispose();
}
void BibGridwin::Resize()
{
if(m_xGridWin.is())
{
::Size aSize = GetOutputSizePixel();
m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::SIZE);
}
}
void BibGridwin::createGridWin(const uno::Reference< awt::XControlModel > & xGModel)
{
m_xGridModel = xGModel;
if( !m_xControlContainer.is())
return;
uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
if ( !m_xGridModel.is())
return;
uno::Reference< XPropertySet > xPropSet( m_xGridModel, UNO_QUERY );
if ( xPropSet.is() && m_xGridModel.is() )
{
uno::Any aAny = xPropSet->getPropertyValue( "DefaultControl" );
OUString aControlName;
aAny >>= aControlName;
m_xControl.set( xContext->getServiceManager()->createInstanceWithContext(aControlName, xContext), UNO_QUERY_THROW );
m_xControl->setModel( m_xGridModel );
}
if ( !m_xControl.is() )
return;
// Peer as Child to the FrameWindow
m_xControlContainer->addControl("GridControl", m_xControl);
m_xGridWin.set(m_xControl, UNO_QUERY );
m_xDispatchProviderInterception.set(m_xControl, UNO_QUERY );
m_xGridWin->setVisible( true );
m_xControl->setDesignMode( true );
// initially switch on the design mode - switch it off _after_ loading the form
::Size aSize = GetOutputSizePixel();
m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::POSSIZE);
}
void BibGridwin::disposeGridWin()
{
if ( m_xControl.is() )
{
Reference< awt::XControl > xDel( m_xControl );
m_xControl = nullptr;
m_xGridWin = nullptr;
m_xControlContainer->removeControl( xDel );
xDel->dispose();
}
}
void BibGridwin::GetFocus()
{
if(m_xGridWin.is())
m_xGridWin->setFocus();
}
BibBeamer::BibBeamer( vcl::Window* _pParent, BibDataManager* _pDM )
:BibSplitWindow( _pParent, WB_3DLOOK | WB_NOSPLITDRAW )
,pDatMan( _pDM )
,pToolBar( nullptr )
,pGridWin( nullptr )
{
createToolBar();
createGridWin();
pDatMan->SetToolbar(pToolBar);
pGridWin->Show();
connectForm( pDatMan );
}
BibBeamer::~BibBeamer()
{
disposeOnce();
}
void BibBeamer::dispose()
{
if ( isFormConnected() )
disconnectForm();
if ( pToolBar )
pDatMan->SetToolbar(nullptr);
pToolBar.disposeAndClear();
pGridWin.disposeAndClear();
BibSplitWindow::dispose();
}
void BibBeamer::createToolBar()
{
pToolBar= VclPtr<BibToolBar>::Create(this, LINK( this, BibBeamer, RecalcLayout_Impl ));
::Size aSize=pToolBar->get_preferred_size();
InsertItem(ID_TOOLBAR, pToolBar, aSize.Height(), 0, 0, SplitWindowItemFlags::Fixed );
if ( m_xController.is() )
pToolBar->SetXController( m_xController );
}
void BibBeamer::createGridWin()
{
pGridWin = VclPtr<BibGridwin>::Create(this,0);
InsertItem(ID_GRIDWIN, pGridWin, 40, 1, 0, SplitWindowItemFlags::RelativeSize );
pGridWin->createGridWin( pDatMan->updateGridModel() );
}
Reference< awt::XControlContainer > BibBeamer::getControlContainer()
{
Reference< awt::XControlContainer > xReturn;
if ( pGridWin )
xReturn = pGridWin->getControlContainer();
return xReturn;
}
Reference< frame::XDispatchProviderInterception > BibBeamer::getDispatchProviderInterception() const
{
Reference< frame::XDispatchProviderInterception > xReturn;
if ( pGridWin )
xReturn = pGridWin->getDispatchProviderInterception();
return xReturn;
}
void BibBeamer::SetXController(const uno::Reference< frame::XController > & xCtr)
{
m_xController = xCtr;
if ( pToolBar )
pToolBar->SetXController( m_xController );
}
void BibBeamer::GetFocus()
{
if( pGridWin )
pGridWin->GrabFocus();
}
IMPL_LINK_NOARG( BibBeamer, RecalcLayout_Impl, void*, void )
{
long nHeight = pToolBar->get_preferred_size().Height();
SetItemSize( ID_TOOLBAR, nHeight );
}
} // namespace bib
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|