Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / extensions / source / bibliography / bibbeam.cxx
blobbfde70bf5fa6e43f56d5a1aa20b2d8d21d9274b3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <osl/mutex.hxx>
21 #include <toolkit/helper/vclunohelper.hxx>
22 #include <comphelper/processfactory.hxx>
23 #include <com/sun/star/awt/PosSize.hpp>
24 #include <com/sun/star/frame/XDispatch.hpp>
25 #include <com/sun/star/util/XURLTransformer.hpp>
27 #include "bibliography.hrc"
28 #include <vcl/lstbox.hxx>
29 #include <vcl/edit.hxx>
30 #include <tools/debug.hxx>
31 #include "bibbeam.hxx"
32 #include "toolbar.hrc"
33 #include "bibresid.hxx"
34 #include "datman.hxx"
35 #include "bibtools.hxx"
37 using namespace ::com::sun::star;
38 using namespace ::com::sun::star::beans;
39 using namespace ::com::sun::star::uno;
41 using ::rtl::OUString;
43 #define C2U(cChar) OUString::createFromAscii(cChar)
45 #define PROPERTY_FRAME 1
46 #define ID_TOOLBAR 1
47 #define ID_GRIDWIN 2
49 //.........................................................................
50 namespace bib
52 //.........................................................................
54 using namespace ::com::sun::star::uno;
56 void HandleTaskPaneList( Window* pWindow, sal_Bool bAddToList )
58 Window* pParent = pWindow->GetParent();
60 DBG_ASSERT( pParent, "-GetTaskPaneList(): everybody here should have a parent!" );
62 SystemWindow* pSysWin = pParent->GetSystemWindow();
63 if( pSysWin )
65 TaskPaneList* pTaskPaneList = pSysWin->GetTaskPaneList();
66 if( pTaskPaneList )
68 if( bAddToList )
69 pTaskPaneList->AddWindow( pWindow );
70 else
71 pTaskPaneList->RemoveWindow( pWindow );
76 //=====================================================================
77 //= BibGridwin
78 //=====================================================================
79 class BibGridwin
80 :public Window //DockingWindow
82 private:
83 Reference< awt::XWindow > m_xGridWin;
84 Reference< awt::XControlModel > m_xGridModel;
85 Reference< awt::XControl > m_xControl;
86 Reference< awt::XControlContainer > m_xControlContainer;
87 // #100312# ---------
88 Reference< frame::XDispatchProviderInterception> m_xDispatchProviderInterception;
90 protected:
92 virtual void Resize();
94 public:
96 BibGridwin(Window* pParent, WinBits nStyle = WB_3DLOOK );
97 ~BibGridwin();
99 void createGridWin(const Reference< awt::XControlModel > & xDbForm);
100 void disposeGridWin();
102 const Reference< awt::XControlContainer >& getControlContainer() const { return m_xControlContainer; }
103 // #100312# ---------
104 const Reference< frame::XDispatchProviderInterception>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception; }
106 virtual void GetFocus();
109 //---------------------------------------------------------------------
110 BibGridwin::BibGridwin( Window* _pParent, WinBits _nStyle ) : Window( _pParent, _nStyle )
112 m_xControlContainer = VCLUnoHelper::CreateControlContainer(this);
114 AddToTaskPaneList( this );
117 //---------------------------------------------------------------------
118 BibGridwin::~BibGridwin()
120 RemoveFromTaskPaneList( this );
122 disposeGridWin();
125 //---------------------------------------------------------------------
126 void BibGridwin::Resize()
128 if(m_xGridWin.is())
130 ::Size aSize = GetOutputSizePixel();
131 m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::SIZE);
135 //---------------------------------------------------------------------
136 void BibGridwin::createGridWin(const uno::Reference< awt::XControlModel > & xGModel)
138 m_xGridModel = xGModel;
140 if( m_xControlContainer.is())
142 uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
144 if ( m_xGridModel.is() && xMgr.is())
146 uno::Reference< XPropertySet > xPropSet( m_xGridModel, UNO_QUERY );
148 if ( xPropSet.is() && m_xGridModel.is() )
150 uno::Any aAny = xPropSet->getPropertyValue( C2U("DefaultControl") );
151 rtl::OUString aControlName;
152 aAny >>= aControlName;
154 m_xControl = Reference< awt::XControl > (xMgr->createInstance( aControlName ), UNO_QUERY );
155 DBG_ASSERT( m_xControl.is(), "no GridControl created" );
156 if ( m_xControl.is() )
157 m_xControl->setModel( m_xGridModel );
160 if ( m_xControl.is() )
162 // Peer als Child zu dem FrameWindow
163 m_xControlContainer->addControl(C2U("GridControl"), m_xControl);
164 m_xGridWin=uno::Reference< awt::XWindow > (m_xControl, UNO_QUERY );
165 // #100312# -----
166 m_xDispatchProviderInterception=uno::Reference< frame::XDispatchProviderInterception > (m_xControl, UNO_QUERY );
167 m_xGridWin->setVisible( sal_True );
168 m_xControl->setDesignMode( sal_True );
169 // initially switch on the desing mode - switch it off _after_ loading the form
171 ::Size aSize = GetOutputSizePixel();
172 m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::POSSIZE);
178 //---------------------------------------------------------------------
179 void BibGridwin::disposeGridWin()
181 if ( m_xControl.is() )
183 Reference< awt::XControl > xDel( m_xControl );
184 m_xControl = NULL;
185 m_xGridWin = NULL;
187 m_xControlContainer->removeControl( xDel );
188 xDel->dispose();
192 //---------------------------------------------------------------------
193 void BibGridwin::GetFocus()
195 if(m_xGridWin.is())
196 m_xGridWin->setFocus();
199 //---------------------------------------------------------------------
200 BibBeamer::BibBeamer( Window* _pParent, BibDataManager* _pDM, WinBits _nStyle )
201 :BibSplitWindow( _pParent, _nStyle | WB_NOSPLITDRAW )
202 ,pDatMan( _pDM )
203 ,pToolBar( NULL )
204 ,pGridWin( NULL )
206 createToolBar();
207 createGridWin();
208 if ( pDatMan )
209 pDatMan->SetToolbar(pToolBar);
210 pGridWin->Show();
212 if ( pDatMan )
213 connectForm( pDatMan );
216 //---------------------------------------------------------------------
217 BibBeamer::~BibBeamer()
219 if ( isFormConnected() )
220 disconnectForm();
222 if ( m_xToolBarRef.is() )
223 m_xToolBarRef->dispose();
225 if ( pToolBar )
227 if ( pDatMan )
228 pDatMan->SetToolbar(0);
230 DELETEZ( pToolBar );
233 if( pGridWin )
235 BibGridwin* pDel = pGridWin;
236 pGridWin = NULL;
237 pDel->disposeGridWin();
238 delete pDel;
243 //---------------------------------------------------------------------
244 void BibBeamer::createToolBar()
246 pToolBar= new BibToolBar(this, LINK( this, BibBeamer, RecalcLayout_Impl ));
247 ::Size aSize=pToolBar->GetSizePixel();
248 InsertItem(ID_TOOLBAR, pToolBar, aSize.Height(), 0, 0, SWIB_FIXED );
249 if ( m_xController.is() )
250 pToolBar->SetXController( m_xController );
253 //---------------------------------------------------------------------
254 void BibBeamer::createGridWin()
256 pGridWin = new BibGridwin(this,0);
258 InsertItem(ID_GRIDWIN, pGridWin, 40, 1, 0, SWIB_RELATIVESIZE );
260 pGridWin->createGridWin( pDatMan->updateGridModel() );
263 //---------------------------------------------------------------------
264 Reference< awt::XControlContainer > BibBeamer::getControlContainer()
266 Reference< awt::XControlContainer > xReturn;
267 if ( pGridWin )
268 xReturn = pGridWin->getControlContainer();
269 return xReturn;
272 // #100312# -----------------------------------------------------------
273 Reference< frame::XDispatchProviderInterception > BibBeamer::getDispatchProviderInterception()
275 Reference< frame::XDispatchProviderInterception > xReturn;
276 if ( pGridWin )
277 xReturn = pGridWin->getDispatchProviderInterception();
278 return xReturn;
281 //---------------------------------------------------------------------
282 void BibBeamer::SetXController(const uno::Reference< frame::XController > & xCtr)
284 m_xController = xCtr;
286 if ( pToolBar )
287 pToolBar->SetXController( m_xController );
291 //---------------------------------------------------------------------
292 void BibBeamer::GetFocus()
294 if( pGridWin )
295 pGridWin->GrabFocus();
298 //---------------------------------------------------------------------
299 IMPL_LINK( BibBeamer, RecalcLayout_Impl, void*, /*pVoid*/ )
301 long nHeight = pToolBar->GetSizePixel().Height();
302 SetItemSize( ID_TOOLBAR, nHeight );
303 return 0L;
306 //.........................................................................
307 } // namespace bib
308 //.........................................................................
310 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */