1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bibbeam.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
33 #include <osl/mutex.hxx>
34 #include <tools/urlobj.hxx>
35 #ifndef _TOOLKIT_UNOHLP_HXX
36 #include <toolkit/helper/vclunohelper.hxx>
38 #include <comphelper/processfactory.hxx>
39 #include <com/sun/star/awt/PosSize.hpp>
40 #include <com/sun/star/frame/XDispatch.hpp>
41 #include <com/sun/star/util/XURLTransformer.hpp>
43 #ifndef EXTENSIONS_INC_EXTENSIO_HRC
44 #include "extensio.hrc"
46 #include <vcl/lstbox.hxx>
47 #include <vcl/edit.hxx>
48 #include <tools/debug.hxx>
49 #include "bibbeam.hxx"
50 #include "toolbar.hrc"
51 #include "bibresid.hxx"
54 #include "bibtools.hxx"
58 using namespace ::com::sun::star
;
59 using namespace ::com::sun::star::beans
;
60 using namespace ::com::sun::star::uno
;
62 #define C2U(cChar) OUString::createFromAscii(cChar)
64 #define PROPERTY_FRAME 1
68 //.........................................................................
71 //.........................................................................
73 using namespace ::com::sun::star::uno
;
75 void HandleTaskPaneList( Window
* pWindow
, BOOL bAddToList
)
77 Window
* pParent
= pWindow
->GetParent();
79 DBG_ASSERT( pParent
, "-GetTaskPaneList(): everybody here should have a parent!" );
81 SystemWindow
* pSysWin
= pParent
->GetSystemWindow();
84 TaskPaneList
* pTaskPaneList
= pSysWin
->GetTaskPaneList();
88 pTaskPaneList
->AddWindow( pWindow
);
90 pTaskPaneList
->RemoveWindow( pWindow
);
95 //=====================================================================
97 //=====================================================================
99 :public Window
//DockingWindow
102 Reference
< awt::XWindow
> m_xGridWin
;
103 Reference
< awt::XControlModel
> m_xGridModel
;
104 Reference
< awt::XControl
> m_xControl
;
105 Reference
< awt::XControlContainer
> m_xControlContainer
;
106 // #100312# ---------
107 Reference
< frame::XDispatchProviderInterception
> m_xDispatchProviderInterception
;
111 virtual void Resize();
115 BibGridwin(Window
* pParent
, WinBits nStyle
= WB_3DLOOK
);
118 void createGridWin(const Reference
< awt::XControlModel
> & xDbForm
);
119 void disposeGridWin();
121 const Reference
< awt::XControlContainer
>& getControlContainer() const { return m_xControlContainer
; }
122 // #100312# ---------
123 const Reference
< frame::XDispatchProviderInterception
>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception
; }
125 virtual void GetFocus();
128 //---------------------------------------------------------------------
129 BibGridwin::BibGridwin( Window
* _pParent
, WinBits _nStyle
) : Window( _pParent
, _nStyle
)
131 m_xControlContainer
= VCLUnoHelper::CreateControlContainer(this);
133 AddToTaskPaneList( this );
136 //---------------------------------------------------------------------
137 BibGridwin::~BibGridwin()
139 RemoveFromTaskPaneList( this );
144 //---------------------------------------------------------------------
145 void BibGridwin::Resize()
149 ::Size aSize
= GetOutputSizePixel();
150 m_xGridWin
->setPosSize(0, 0, aSize
.Width(),aSize
.Height(), awt::PosSize::SIZE
);
154 //---------------------------------------------------------------------
155 void BibGridwin::createGridWin(const uno::Reference
< awt::XControlModel
> & xGModel
)
157 m_xGridModel
= xGModel
;
159 if( m_xControlContainer
.is())
161 uno::Reference
< lang::XMultiServiceFactory
> xMgr
= comphelper::getProcessServiceFactory();
163 if ( m_xGridModel
.is() && xMgr
.is())
165 uno::Reference
< XPropertySet
> xPropSet( m_xGridModel
, UNO_QUERY
);
167 if ( xPropSet
.is() && m_xGridModel
.is() )
169 uno::Any aAny
= xPropSet
->getPropertyValue( C2U("DefaultControl") );
170 rtl::OUString aControlName
;
171 aAny
>>= aControlName
;
173 m_xControl
= Reference
< awt::XControl
> (xMgr
->createInstance( aControlName
), UNO_QUERY
);
174 DBG_ASSERT( m_xControl
.is(), "no GridControl created" );
175 if ( m_xControl
.is() )
176 m_xControl
->setModel( m_xGridModel
);
179 if ( m_xControl
.is() )
181 // Peer als Child zu dem FrameWindow
182 m_xControlContainer
->addControl(C2U("GridControl"), m_xControl
);
183 m_xGridWin
=uno::Reference
< awt::XWindow
> (m_xControl
, UNO_QUERY
);
185 m_xDispatchProviderInterception
=uno::Reference
< frame::XDispatchProviderInterception
> (m_xControl
, UNO_QUERY
);
186 m_xGridWin
->setVisible( sal_True
);
187 m_xControl
->setDesignMode( sal_True
);
188 // initially switch on the desing mode - switch it off _after_ loading the form
189 // 17.10.2001 - 93107 - frank.schoenheit@sun.com
191 ::Size aSize
= GetOutputSizePixel();
192 m_xGridWin
->setPosSize(0, 0, aSize
.Width(),aSize
.Height(), awt::PosSize::POSSIZE
);
198 //---------------------------------------------------------------------
199 void BibGridwin::disposeGridWin()
201 if ( m_xControl
.is() )
203 Reference
< awt::XControl
> xDel( m_xControl
);
207 m_xControlContainer
->removeControl( xDel
);
212 //---------------------------------------------------------------------
213 void BibGridwin::GetFocus()
216 m_xGridWin
->setFocus();
219 //---------------------------------------------------------------------
220 BibBeamer::BibBeamer( Window
* _pParent
, BibDataManager
* _pDM
, WinBits _nStyle
)
221 :BibSplitWindow( _pParent
, _nStyle
| WB_NOSPLITDRAW
)
229 pDatMan
->SetToolbar(pToolBar
);
233 connectForm( pDatMan
);
236 //---------------------------------------------------------------------
237 BibBeamer::~BibBeamer()
239 if ( isFormConnected() )
242 if ( m_xToolBarRef
.is() )
243 m_xToolBarRef
->dispose();
248 pDatMan
->SetToolbar(0);
255 BibGridwin
* pDel
= pGridWin
;
257 pDel
->disposeGridWin();
263 //---------------------------------------------------------------------
264 void BibBeamer::createToolBar()
266 pToolBar
= new BibToolBar(this, LINK( this, BibBeamer
, RecalcLayout_Impl
));
267 ::Size aSize
=pToolBar
->GetSizePixel();
268 InsertItem(ID_TOOLBAR
, pToolBar
, aSize
.Height(), 0, 0, SWIB_FIXED
);
269 if ( m_xController
.is() )
270 pToolBar
->SetXController( m_xController
);
273 //---------------------------------------------------------------------
274 void BibBeamer::createGridWin()
276 pGridWin
= new BibGridwin(this,0);
278 InsertItem(ID_GRIDWIN
, pGridWin
, 40, 1, 0, SWIB_RELATIVESIZE
);
280 pGridWin
->createGridWin( pDatMan
->updateGridModel() );
283 //---------------------------------------------------------------------
284 Reference
< awt::XControlContainer
> BibBeamer::getControlContainer()
286 Reference
< awt::XControlContainer
> xReturn
;
288 xReturn
= pGridWin
->getControlContainer();
292 // #100312# -----------------------------------------------------------
293 Reference
< frame::XDispatchProviderInterception
> BibBeamer::getDispatchProviderInterception()
295 Reference
< frame::XDispatchProviderInterception
> xReturn
;
297 xReturn
= pGridWin
->getDispatchProviderInterception();
301 //---------------------------------------------------------------------
302 void BibBeamer::SetXController(const uno::Reference
< frame::XController
> & xCtr
)
304 m_xController
= xCtr
;
307 pToolBar
->SetXController( m_xController
);
311 //---------------------------------------------------------------------
312 void BibBeamer::GetFocus()
315 pGridWin
->GrabFocus();
318 //---------------------------------------------------------------------
319 IMPL_LINK( BibBeamer
, RecalcLayout_Impl
, void*, /*pVoid*/ )
321 long nHeight
= pToolBar
->GetSizePixel().Height();
322 SetItemSize( ID_TOOLBAR
, nHeight
);
326 //.........................................................................
328 //.........................................................................