Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <osl/mutex.hxx>
30 : : #include <toolkit/helper/vclunohelper.hxx>
31 : : #include <comphelper/processfactory.hxx>
32 : : #include <com/sun/star/awt/PosSize.hpp>
33 : : #include <com/sun/star/frame/XDispatch.hpp>
34 : : #include <com/sun/star/util/XURLTransformer.hpp>
35 : :
36 : : #include "bibliography.hrc"
37 : : #include <vcl/lstbox.hxx>
38 : : #include <vcl/edit.hxx>
39 : : #include <tools/debug.hxx>
40 : : #include "bibbeam.hxx"
41 : : #include "toolbar.hrc"
42 : : #include "bibresid.hxx"
43 : : #include "datman.hxx"
44 : : #include "bibtools.hxx"
45 : :
46 : : using namespace ::com::sun::star;
47 : : using namespace ::com::sun::star::beans;
48 : : using namespace ::com::sun::star::uno;
49 : :
50 : : using ::rtl::OUString;
51 : :
52 : : #define C2U(cChar) OUString::createFromAscii(cChar)
53 : :
54 : : #define PROPERTY_FRAME 1
55 : : #define ID_TOOLBAR 1
56 : : #define ID_GRIDWIN 2
57 : :
58 : : //.........................................................................
59 : : namespace bib
60 : : {
61 : : //.........................................................................
62 : :
63 : : using namespace ::com::sun::star::uno;
64 : :
65 : 0 : void HandleTaskPaneList( Window* pWindow, sal_Bool bAddToList )
66 : : {
67 : 0 : Window* pParent = pWindow->GetParent();
68 : :
69 : : DBG_ASSERT( pParent, "-GetTaskPaneList(): everybody here should have a parent!" );
70 : :
71 : 0 : SystemWindow* pSysWin = pParent->GetSystemWindow();
72 [ # # ]: 0 : if( pSysWin )
73 : : {
74 : 0 : TaskPaneList* pTaskPaneList = pSysWin->GetTaskPaneList();
75 [ # # ]: 0 : if( pTaskPaneList )
76 : : {
77 [ # # ]: 0 : if( bAddToList )
78 : 0 : pTaskPaneList->AddWindow( pWindow );
79 : : else
80 : 0 : pTaskPaneList->RemoveWindow( pWindow );
81 : : }
82 : : }
83 : 0 : }
84 : :
85 : : //=====================================================================
86 : : //= BibGridwin
87 : : //=====================================================================
88 : : class BibGridwin
89 : : :public Window //DockingWindow
90 : : {
91 : : private:
92 : : Reference< awt::XWindow > m_xGridWin;
93 : : Reference< awt::XControlModel > m_xGridModel;
94 : : Reference< awt::XControl > m_xControl;
95 : : Reference< awt::XControlContainer > m_xControlContainer;
96 : : // #100312# ---------
97 : : Reference< frame::XDispatchProviderInterception> m_xDispatchProviderInterception;
98 : :
99 : : protected:
100 : :
101 : : virtual void Resize();
102 : :
103 : : public:
104 : :
105 : : BibGridwin(Window* pParent, WinBits nStyle = WB_3DLOOK );
106 : : ~BibGridwin();
107 : :
108 : : void createGridWin(const Reference< awt::XControlModel > & xDbForm);
109 : : void disposeGridWin();
110 : :
111 : 0 : const Reference< awt::XControlContainer >& getControlContainer() const { return m_xControlContainer; }
112 : : // #100312# ---------
113 : 0 : const Reference< frame::XDispatchProviderInterception>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception; }
114 : :
115 : : virtual void GetFocus();
116 : : };
117 : :
118 : : //---------------------------------------------------------------------
119 : 0 : BibGridwin::BibGridwin( Window* _pParent, WinBits _nStyle ) : Window( _pParent, _nStyle )
120 : : {
121 [ # # ][ # # ]: 0 : m_xControlContainer = VCLUnoHelper::CreateControlContainer(this);
122 : :
123 [ # # ]: 0 : AddToTaskPaneList( this );
124 : 0 : }
125 : :
126 : : //---------------------------------------------------------------------
127 : 0 : BibGridwin::~BibGridwin()
128 : : {
129 [ # # ]: 0 : RemoveFromTaskPaneList( this );
130 : :
131 [ # # ]: 0 : disposeGridWin();
132 [ # # ]: 0 : }
133 : :
134 : : //---------------------------------------------------------------------
135 : 0 : void BibGridwin::Resize()
136 : : {
137 [ # # ]: 0 : if(m_xGridWin.is())
138 : : {
139 : 0 : ::Size aSize = GetOutputSizePixel();
140 [ # # ][ # # ]: 0 : m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::SIZE);
141 : : }
142 : 0 : }
143 : :
144 : : //---------------------------------------------------------------------
145 : 0 : void BibGridwin::createGridWin(const uno::Reference< awt::XControlModel > & xGModel)
146 : : {
147 : 0 : m_xGridModel = xGModel;
148 : :
149 [ # # ]: 0 : if( m_xControlContainer.is())
150 : : {
151 [ # # ]: 0 : uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
152 : :
153 [ # # ][ # # ]: 0 : if ( m_xGridModel.is() && xMgr.is())
[ # # ]
154 : : {
155 [ # # ]: 0 : uno::Reference< XPropertySet > xPropSet( m_xGridModel, UNO_QUERY );
156 : :
157 [ # # ][ # # ]: 0 : if ( xPropSet.is() && m_xGridModel.is() )
[ # # ]
158 : : {
159 [ # # ][ # # ]: 0 : uno::Any aAny = xPropSet->getPropertyValue( C2U("DefaultControl") );
160 : 0 : rtl::OUString aControlName;
161 : 0 : aAny >>= aControlName;
162 : :
163 [ # # ][ # # ]: 0 : m_xControl = Reference< awt::XControl > (xMgr->createInstance( aControlName ), UNO_QUERY );
[ # # ][ # # ]
164 : : DBG_ASSERT( m_xControl.is(), "no GridControl created" );
165 [ # # ]: 0 : if ( m_xControl.is() )
166 [ # # ][ # # ]: 0 : m_xControl->setModel( m_xGridModel );
167 : : }
168 : :
169 [ # # ]: 0 : if ( m_xControl.is() )
170 : : {
171 : : // Peer als Child zu dem FrameWindow
172 [ # # ][ # # ]: 0 : m_xControlContainer->addControl(C2U("GridControl"), m_xControl);
173 [ # # ][ # # ]: 0 : m_xGridWin=uno::Reference< awt::XWindow > (m_xControl, UNO_QUERY );
174 : : // #100312# -----
175 [ # # ][ # # ]: 0 : m_xDispatchProviderInterception=uno::Reference< frame::XDispatchProviderInterception > (m_xControl, UNO_QUERY );
176 [ # # ][ # # ]: 0 : m_xGridWin->setVisible( sal_True );
177 [ # # ][ # # ]: 0 : m_xControl->setDesignMode( sal_True );
178 : : // initially switch on the desing mode - switch it off _after_ loading the form
179 : :
180 : 0 : ::Size aSize = GetOutputSizePixel();
181 [ # # ][ # # ]: 0 : m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::POSSIZE);
182 : 0 : }
183 : 0 : }
184 : : }
185 : 0 : }
186 : :
187 : : //---------------------------------------------------------------------
188 : 0 : void BibGridwin::disposeGridWin()
189 : : {
190 [ # # ]: 0 : if ( m_xControl.is() )
191 : : {
192 : 0 : Reference< awt::XControl > xDel( m_xControl );
193 [ # # ]: 0 : m_xControl = NULL;
194 [ # # ]: 0 : m_xGridWin = NULL;
195 : :
196 [ # # ][ # # ]: 0 : m_xControlContainer->removeControl( xDel );
197 [ # # ][ # # ]: 0 : xDel->dispose();
198 : : }
199 : 0 : }
200 : :
201 : : //---------------------------------------------------------------------
202 : 0 : void BibGridwin::GetFocus()
203 : : {
204 [ # # ]: 0 : if(m_xGridWin.is())
205 : 0 : m_xGridWin->setFocus();
206 : 0 : }
207 : :
208 : : //---------------------------------------------------------------------
209 : 0 : BibBeamer::BibBeamer( Window* _pParent, BibDataManager* _pDM, WinBits _nStyle )
210 : : :BibSplitWindow( _pParent, _nStyle | WB_NOSPLITDRAW )
211 : : ,pDatMan( _pDM )
212 : : ,pToolBar( NULL )
213 [ # # ]: 0 : ,pGridWin( NULL )
214 : : {
215 [ # # ]: 0 : createToolBar();
216 [ # # ]: 0 : createGridWin();
217 [ # # ]: 0 : if ( pDatMan )
218 [ # # ]: 0 : pDatMan->SetToolbar(pToolBar);
219 [ # # ]: 0 : pGridWin->Show();
220 : :
221 [ # # ]: 0 : if ( pDatMan )
222 [ # # ][ # # ]: 0 : connectForm( pDatMan );
[ # # ]
223 : 0 : }
224 : :
225 : : //---------------------------------------------------------------------
226 [ # # ]: 0 : BibBeamer::~BibBeamer()
227 : : {
228 [ # # ]: 0 : if ( isFormConnected() )
229 [ # # ]: 0 : disconnectForm();
230 : :
231 [ # # ]: 0 : if ( m_xToolBarRef.is() )
232 [ # # ][ # # ]: 0 : m_xToolBarRef->dispose();
233 : :
234 [ # # ]: 0 : if ( pToolBar )
235 : : {
236 [ # # ]: 0 : if ( pDatMan )
237 [ # # ]: 0 : pDatMan->SetToolbar(0);
238 : :
239 [ # # ][ # # ]: 0 : DELETEZ( pToolBar );
240 : : }
241 : :
242 [ # # ]: 0 : if( pGridWin )
243 : : {
244 : 0 : BibGridwin* pDel = pGridWin;
245 : 0 : pGridWin = NULL;
246 [ # # ]: 0 : pDel->disposeGridWin();
247 [ # # ][ # # ]: 0 : delete pDel;
248 : : }
249 : :
250 [ # # ]: 0 : }
251 : :
252 : : //---------------------------------------------------------------------
253 : 0 : void BibBeamer::createToolBar()
254 : : {
255 [ # # ][ # # ]: 0 : pToolBar= new BibToolBar(this, LINK( this, BibBeamer, RecalcLayout_Impl ));
[ # # ]
256 [ # # ]: 0 : ::Size aSize=pToolBar->GetSizePixel();
257 [ # # ]: 0 : InsertItem(ID_TOOLBAR, pToolBar, aSize.Height(), 0, 0, SWIB_FIXED );
258 [ # # ]: 0 : if ( m_xController.is() )
259 [ # # ]: 0 : pToolBar->SetXController( m_xController );
260 : 0 : }
261 : :
262 : : //---------------------------------------------------------------------
263 : 0 : void BibBeamer::createGridWin()
264 : : {
265 [ # # ]: 0 : pGridWin = new BibGridwin(this,0);
266 : :
267 : 0 : InsertItem(ID_GRIDWIN, pGridWin, 40, 1, 0, SWIB_RELATIVESIZE );
268 : :
269 [ # # ]: 0 : pGridWin->createGridWin( pDatMan->updateGridModel() );
270 : 0 : }
271 : :
272 : : //---------------------------------------------------------------------
273 : 0 : Reference< awt::XControlContainer > BibBeamer::getControlContainer()
274 : : {
275 : 0 : Reference< awt::XControlContainer > xReturn;
276 [ # # ]: 0 : if ( pGridWin )
277 [ # # ]: 0 : xReturn = pGridWin->getControlContainer();
278 : 0 : return xReturn;
279 : : }
280 : :
281 : : // #100312# -----------------------------------------------------------
282 : 0 : Reference< frame::XDispatchProviderInterception > BibBeamer::getDispatchProviderInterception()
283 : : {
284 : 0 : Reference< frame::XDispatchProviderInterception > xReturn;
285 [ # # ]: 0 : if ( pGridWin )
286 [ # # ]: 0 : xReturn = pGridWin->getDispatchProviderInterception();
287 : 0 : return xReturn;
288 : : }
289 : :
290 : : //---------------------------------------------------------------------
291 : 0 : void BibBeamer::SetXController(const uno::Reference< frame::XController > & xCtr)
292 : : {
293 : 0 : m_xController = xCtr;
294 : :
295 [ # # ]: 0 : if ( pToolBar )
296 : 0 : pToolBar->SetXController( m_xController );
297 : :
298 : 0 : }
299 : :
300 : : //---------------------------------------------------------------------
301 : 0 : void BibBeamer::GetFocus()
302 : : {
303 [ # # ]: 0 : if( pGridWin )
304 : 0 : pGridWin->GrabFocus();
305 : 0 : }
306 : :
307 : : //---------------------------------------------------------------------
308 : 0 : IMPL_LINK( BibBeamer, RecalcLayout_Impl, void*, /*pVoid*/ )
309 : : {
310 : 0 : long nHeight = pToolBar->GetSizePixel().Height();
311 : 0 : SetItemSize( ID_TOOLBAR, nHeight );
312 : 0 : return 0L;
313 : : }
314 : :
315 : : //.........................................................................
316 : : } // namespace bib
317 : : //.........................................................................
318 : :
319 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|