1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include <osl/mutex.hxx>
31 #include <tools/urlobj.hxx>
32 #include <toolkit/helper/vclunohelper.hxx>
33 #include <comphelper/processfactory.hxx>
34 #include <com/sun/star/awt/PosSize.hpp>
35 #include <com/sun/star/frame/XDispatch.hpp>
36 #include <com/sun/star/util/XURLTransformer.hpp>
38 #include "bibliography.hrc"
39 #include <vcl/lstbox.hxx>
40 #include <vcl/edit.hxx>
41 #include <tools/debug.hxx>
42 #include "bibbeam.hxx"
43 #include "toolbar.hrc"
44 #include "bibresid.hxx"
47 #include "bibtools.hxx"
51 using namespace ::com::sun::star
;
52 using namespace ::com::sun::star::beans
;
53 using namespace ::com::sun::star::uno
;
55 #define C2U(cChar) OUString::createFromAscii(cChar)
57 #define PROPERTY_FRAME 1
61 //.........................................................................
64 //.........................................................................
66 using namespace ::com::sun::star::uno
;
68 void HandleTaskPaneList( Window
* pWindow
, BOOL bAddToList
)
70 Window
* pParent
= pWindow
->GetParent();
72 DBG_ASSERT( pParent
, "-GetTaskPaneList(): everybody here should have a parent!" );
74 SystemWindow
* pSysWin
= pParent
->GetSystemWindow();
77 TaskPaneList
* pTaskPaneList
= pSysWin
->GetTaskPaneList();
81 pTaskPaneList
->AddWindow( pWindow
);
83 pTaskPaneList
->RemoveWindow( pWindow
);
88 //=====================================================================
90 //=====================================================================
92 :public Window
//DockingWindow
95 Reference
< awt::XWindow
> m_xGridWin
;
96 Reference
< awt::XControlModel
> m_xGridModel
;
97 Reference
< awt::XControl
> m_xControl
;
98 Reference
< awt::XControlContainer
> m_xControlContainer
;
100 Reference
< frame::XDispatchProviderInterception
> m_xDispatchProviderInterception
;
104 virtual void Resize();
108 BibGridwin(Window
* pParent
, WinBits nStyle
= WB_3DLOOK
);
111 void createGridWin(const Reference
< awt::XControlModel
> & xDbForm
);
112 void disposeGridWin();
114 const Reference
< awt::XControlContainer
>& getControlContainer() const { return m_xControlContainer
; }
115 // #100312# ---------
116 const Reference
< frame::XDispatchProviderInterception
>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception
; }
118 virtual void GetFocus();
121 //---------------------------------------------------------------------
122 BibGridwin::BibGridwin( Window
* _pParent
, WinBits _nStyle
) : Window( _pParent
, _nStyle
)
124 m_xControlContainer
= VCLUnoHelper::CreateControlContainer(this);
126 AddToTaskPaneList( this );
129 //---------------------------------------------------------------------
130 BibGridwin::~BibGridwin()
132 RemoveFromTaskPaneList( this );
137 //---------------------------------------------------------------------
138 void BibGridwin::Resize()
142 ::Size aSize
= GetOutputSizePixel();
143 m_xGridWin
->setPosSize(0, 0, aSize
.Width(),aSize
.Height(), awt::PosSize::SIZE
);
147 //---------------------------------------------------------------------
148 void BibGridwin::createGridWin(const uno::Reference
< awt::XControlModel
> & xGModel
)
150 m_xGridModel
= xGModel
;
152 if( m_xControlContainer
.is())
154 uno::Reference
< lang::XMultiServiceFactory
> xMgr
= comphelper::getProcessServiceFactory();
156 if ( m_xGridModel
.is() && xMgr
.is())
158 uno::Reference
< XPropertySet
> xPropSet( m_xGridModel
, UNO_QUERY
);
160 if ( xPropSet
.is() && m_xGridModel
.is() )
162 uno::Any aAny
= xPropSet
->getPropertyValue( C2U("DefaultControl") );
163 rtl::OUString aControlName
;
164 aAny
>>= aControlName
;
166 m_xControl
= Reference
< awt::XControl
> (xMgr
->createInstance( aControlName
), UNO_QUERY
);
167 DBG_ASSERT( m_xControl
.is(), "no GridControl created" );
168 if ( m_xControl
.is() )
169 m_xControl
->setModel( m_xGridModel
);
172 if ( m_xControl
.is() )
174 // Peer als Child zu dem FrameWindow
175 m_xControlContainer
->addControl(C2U("GridControl"), m_xControl
);
176 m_xGridWin
=uno::Reference
< awt::XWindow
> (m_xControl
, UNO_QUERY
);
178 m_xDispatchProviderInterception
=uno::Reference
< frame::XDispatchProviderInterception
> (m_xControl
, UNO_QUERY
);
179 m_xGridWin
->setVisible( sal_True
);
180 m_xControl
->setDesignMode( sal_True
);
181 // initially switch on the desing mode - switch it off _after_ loading the form
182 // 17.10.2001 - 93107 - frank.schoenheit@sun.com
184 ::Size aSize
= GetOutputSizePixel();
185 m_xGridWin
->setPosSize(0, 0, aSize
.Width(),aSize
.Height(), awt::PosSize::POSSIZE
);
191 //---------------------------------------------------------------------
192 void BibGridwin::disposeGridWin()
194 if ( m_xControl
.is() )
196 Reference
< awt::XControl
> xDel( m_xControl
);
200 m_xControlContainer
->removeControl( xDel
);
205 //---------------------------------------------------------------------
206 void BibGridwin::GetFocus()
209 m_xGridWin
->setFocus();
212 //---------------------------------------------------------------------
213 BibBeamer::BibBeamer( Window
* _pParent
, BibDataManager
* _pDM
, WinBits _nStyle
)
214 :BibSplitWindow( _pParent
, _nStyle
| WB_NOSPLITDRAW
)
222 pDatMan
->SetToolbar(pToolBar
);
226 connectForm( pDatMan
);
229 //---------------------------------------------------------------------
230 BibBeamer::~BibBeamer()
232 if ( isFormConnected() )
235 if ( m_xToolBarRef
.is() )
236 m_xToolBarRef
->dispose();
241 pDatMan
->SetToolbar(0);
248 BibGridwin
* pDel
= pGridWin
;
250 pDel
->disposeGridWin();
256 //---------------------------------------------------------------------
257 void BibBeamer::createToolBar()
259 pToolBar
= new BibToolBar(this, LINK( this, BibBeamer
, RecalcLayout_Impl
));
260 ::Size aSize
=pToolBar
->GetSizePixel();
261 InsertItem(ID_TOOLBAR
, pToolBar
, aSize
.Height(), 0, 0, SWIB_FIXED
);
262 if ( m_xController
.is() )
263 pToolBar
->SetXController( m_xController
);
266 //---------------------------------------------------------------------
267 void BibBeamer::createGridWin()
269 pGridWin
= new BibGridwin(this,0);
271 InsertItem(ID_GRIDWIN
, pGridWin
, 40, 1, 0, SWIB_RELATIVESIZE
);
273 pGridWin
->createGridWin( pDatMan
->updateGridModel() );
276 //---------------------------------------------------------------------
277 Reference
< awt::XControlContainer
> BibBeamer::getControlContainer()
279 Reference
< awt::XControlContainer
> xReturn
;
281 xReturn
= pGridWin
->getControlContainer();
285 // #100312# -----------------------------------------------------------
286 Reference
< frame::XDispatchProviderInterception
> BibBeamer::getDispatchProviderInterception()
288 Reference
< frame::XDispatchProviderInterception
> xReturn
;
290 xReturn
= pGridWin
->getDispatchProviderInterception();
294 //---------------------------------------------------------------------
295 void BibBeamer::SetXController(const uno::Reference
< frame::XController
> & xCtr
)
297 m_xController
= xCtr
;
300 pToolBar
->SetXController( m_xController
);
304 //---------------------------------------------------------------------
305 void BibBeamer::GetFocus()
308 pGridWin
->GrabFocus();
311 //---------------------------------------------------------------------
312 IMPL_LINK( BibBeamer
, RecalcLayout_Impl
, void*, /*pVoid*/ )
314 long nHeight
= pToolBar
->GetSizePixel().Height();
315 SetItemSize( ID_TOOLBAR
, nHeight
);
319 //.........................................................................
321 //.........................................................................