Bump for 3.6-28
[LibreOffice.git] / extensions / source / bibliography / bibbeam.cxx
blob9458497e2c92b2497d28f04bbc45334f649e1a6e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
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>
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"
46 using namespace ::com::sun::star;
47 using namespace ::com::sun::star::beans;
48 using namespace ::com::sun::star::uno;
50 using ::rtl::OUString;
52 #define C2U(cChar) OUString::createFromAscii(cChar)
54 #define PROPERTY_FRAME 1
55 #define ID_TOOLBAR 1
56 #define ID_GRIDWIN 2
58 //.........................................................................
59 namespace bib
61 //.........................................................................
63 using namespace ::com::sun::star::uno;
65 void HandleTaskPaneList( Window* pWindow, sal_Bool bAddToList )
67 Window* pParent = pWindow->GetParent();
69 DBG_ASSERT( pParent, "-GetTaskPaneList(): everybody here should have a parent!" );
71 SystemWindow* pSysWin = pParent->GetSystemWindow();
72 if( pSysWin )
74 TaskPaneList* pTaskPaneList = pSysWin->GetTaskPaneList();
75 if( pTaskPaneList )
77 if( bAddToList )
78 pTaskPaneList->AddWindow( pWindow );
79 else
80 pTaskPaneList->RemoveWindow( pWindow );
85 //=====================================================================
86 //= BibGridwin
87 //=====================================================================
88 class BibGridwin
89 :public Window //DockingWindow
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;
99 protected:
101 virtual void Resize();
103 public:
105 BibGridwin(Window* pParent, WinBits nStyle = WB_3DLOOK );
106 ~BibGridwin();
108 void createGridWin(const Reference< awt::XControlModel > & xDbForm);
109 void disposeGridWin();
111 const Reference< awt::XControlContainer >& getControlContainer() const { return m_xControlContainer; }
112 // #100312# ---------
113 const Reference< frame::XDispatchProviderInterception>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception; }
115 virtual void GetFocus();
118 //---------------------------------------------------------------------
119 BibGridwin::BibGridwin( Window* _pParent, WinBits _nStyle ) : Window( _pParent, _nStyle )
121 m_xControlContainer = VCLUnoHelper::CreateControlContainer(this);
123 AddToTaskPaneList( this );
126 //---------------------------------------------------------------------
127 BibGridwin::~BibGridwin()
129 RemoveFromTaskPaneList( this );
131 disposeGridWin();
134 //---------------------------------------------------------------------
135 void BibGridwin::Resize()
137 if(m_xGridWin.is())
139 ::Size aSize = GetOutputSizePixel();
140 m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::SIZE);
144 //---------------------------------------------------------------------
145 void BibGridwin::createGridWin(const uno::Reference< awt::XControlModel > & xGModel)
147 m_xGridModel = xGModel;
149 if( m_xControlContainer.is())
151 uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
153 if ( m_xGridModel.is() && xMgr.is())
155 uno::Reference< XPropertySet > xPropSet( m_xGridModel, UNO_QUERY );
157 if ( xPropSet.is() && m_xGridModel.is() )
159 uno::Any aAny = xPropSet->getPropertyValue( C2U("DefaultControl") );
160 rtl::OUString aControlName;
161 aAny >>= aControlName;
163 m_xControl = Reference< awt::XControl > (xMgr->createInstance( aControlName ), UNO_QUERY );
164 DBG_ASSERT( m_xControl.is(), "no GridControl created" );
165 if ( m_xControl.is() )
166 m_xControl->setModel( m_xGridModel );
169 if ( m_xControl.is() )
171 // Peer als Child zu dem FrameWindow
172 m_xControlContainer->addControl(C2U("GridControl"), m_xControl);
173 m_xGridWin=uno::Reference< awt::XWindow > (m_xControl, UNO_QUERY );
174 // #100312# -----
175 m_xDispatchProviderInterception=uno::Reference< frame::XDispatchProviderInterception > (m_xControl, UNO_QUERY );
176 m_xGridWin->setVisible( sal_True );
177 m_xControl->setDesignMode( sal_True );
178 // initially switch on the desing mode - switch it off _after_ loading the form
180 ::Size aSize = GetOutputSizePixel();
181 m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::POSSIZE);
187 //---------------------------------------------------------------------
188 void BibGridwin::disposeGridWin()
190 if ( m_xControl.is() )
192 Reference< awt::XControl > xDel( m_xControl );
193 m_xControl = NULL;
194 m_xGridWin = NULL;
196 m_xControlContainer->removeControl( xDel );
197 xDel->dispose();
201 //---------------------------------------------------------------------
202 void BibGridwin::GetFocus()
204 if(m_xGridWin.is())
205 m_xGridWin->setFocus();
208 //---------------------------------------------------------------------
209 BibBeamer::BibBeamer( Window* _pParent, BibDataManager* _pDM, WinBits _nStyle )
210 :BibSplitWindow( _pParent, _nStyle | WB_NOSPLITDRAW )
211 ,pDatMan( _pDM )
212 ,pToolBar( NULL )
213 ,pGridWin( NULL )
215 createToolBar();
216 createGridWin();
217 if ( pDatMan )
218 pDatMan->SetToolbar(pToolBar);
219 pGridWin->Show();
221 if ( pDatMan )
222 connectForm( pDatMan );
225 //---------------------------------------------------------------------
226 BibBeamer::~BibBeamer()
228 if ( isFormConnected() )
229 disconnectForm();
231 if ( m_xToolBarRef.is() )
232 m_xToolBarRef->dispose();
234 if ( pToolBar )
236 if ( pDatMan )
237 pDatMan->SetToolbar(0);
239 DELETEZ( pToolBar );
242 if( pGridWin )
244 BibGridwin* pDel = pGridWin;
245 pGridWin = NULL;
246 pDel->disposeGridWin();
247 delete pDel;
252 //---------------------------------------------------------------------
253 void BibBeamer::createToolBar()
255 pToolBar= new BibToolBar(this, LINK( this, BibBeamer, RecalcLayout_Impl ));
256 ::Size aSize=pToolBar->GetSizePixel();
257 InsertItem(ID_TOOLBAR, pToolBar, aSize.Height(), 0, 0, SWIB_FIXED );
258 if ( m_xController.is() )
259 pToolBar->SetXController( m_xController );
262 //---------------------------------------------------------------------
263 void BibBeamer::createGridWin()
265 pGridWin = new BibGridwin(this,0);
267 InsertItem(ID_GRIDWIN, pGridWin, 40, 1, 0, SWIB_RELATIVESIZE );
269 pGridWin->createGridWin( pDatMan->updateGridModel() );
272 //---------------------------------------------------------------------
273 Reference< awt::XControlContainer > BibBeamer::getControlContainer()
275 Reference< awt::XControlContainer > xReturn;
276 if ( pGridWin )
277 xReturn = pGridWin->getControlContainer();
278 return xReturn;
281 // #100312# -----------------------------------------------------------
282 Reference< frame::XDispatchProviderInterception > BibBeamer::getDispatchProviderInterception()
284 Reference< frame::XDispatchProviderInterception > xReturn;
285 if ( pGridWin )
286 xReturn = pGridWin->getDispatchProviderInterception();
287 return xReturn;
290 //---------------------------------------------------------------------
291 void BibBeamer::SetXController(const uno::Reference< frame::XController > & xCtr)
293 m_xController = xCtr;
295 if ( pToolBar )
296 pToolBar->SetXController( m_xController );
300 //---------------------------------------------------------------------
301 void BibBeamer::GetFocus()
303 if( pGridWin )
304 pGridWin->GrabFocus();
307 //---------------------------------------------------------------------
308 IMPL_LINK( BibBeamer, RecalcLayout_Impl, void*, /*pVoid*/ )
310 long nHeight = pToolBar->GetSizePixel().Height();
311 SetItemSize( ID_TOOLBAR, nHeight );
312 return 0L;
315 //.........................................................................
316 } // namespace bib
317 //.........................................................................
319 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */