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"
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
58 //.........................................................................
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();
74 TaskPaneList
* pTaskPaneList
= pSysWin
->GetTaskPaneList();
78 pTaskPaneList
->AddWindow( pWindow
);
80 pTaskPaneList
->RemoveWindow( pWindow
);
85 //=====================================================================
87 //=====================================================================
89 :public Window
//DockingWindow
92 Reference
< awt::XWindow
> m_xGridWin
;
93 Reference
< awt::XControlModel
> m_xGridModel
;
94 Reference
< awt::XControl
> m_xControl
;
95 Reference
< awt::XControlContainer
> m_xControlContainer
;
97 Reference
< frame::XDispatchProviderInterception
> m_xDispatchProviderInterception
;
101 virtual void Resize();
105 BibGridwin(Window
* pParent
, WinBits nStyle
= WB_3DLOOK
);
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 );
134 //---------------------------------------------------------------------
135 void BibGridwin::Resize()
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
);
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
);
196 m_xControlContainer
->removeControl( xDel
);
201 //---------------------------------------------------------------------
202 void BibGridwin::GetFocus()
205 m_xGridWin
->setFocus();
208 //---------------------------------------------------------------------
209 BibBeamer::BibBeamer( Window
* _pParent
, BibDataManager
* _pDM
, WinBits _nStyle
)
210 :BibSplitWindow( _pParent
, _nStyle
| WB_NOSPLITDRAW
)
218 pDatMan
->SetToolbar(pToolBar
);
222 connectForm( pDatMan
);
225 //---------------------------------------------------------------------
226 BibBeamer::~BibBeamer()
228 if ( isFormConnected() )
231 if ( m_xToolBarRef
.is() )
232 m_xToolBarRef
->dispose();
237 pDatMan
->SetToolbar(0);
244 BibGridwin
* pDel
= pGridWin
;
246 pDel
->disposeGridWin();
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
;
277 xReturn
= pGridWin
->getControlContainer();
281 // #100312# -----------------------------------------------------------
282 Reference
< frame::XDispatchProviderInterception
> BibBeamer::getDispatchProviderInterception()
284 Reference
< frame::XDispatchProviderInterception
> xReturn
;
286 xReturn
= pGridWin
->getDispatchProviderInterception();
290 //---------------------------------------------------------------------
291 void BibBeamer::SetXController(const uno::Reference
< frame::XController
> & xCtr
)
293 m_xController
= xCtr
;
296 pToolBar
->SetXController( m_xController
);
300 //---------------------------------------------------------------------
301 void BibBeamer::GetFocus()
304 pGridWin
->GrabFocus();
307 //---------------------------------------------------------------------
308 IMPL_LINK( BibBeamer
, RecalcLayout_Impl
, void*, /*pVoid*/ )
310 long nHeight
= pToolBar
->GetSizePixel().Height();
311 SetItemSize( ID_TOOLBAR
, nHeight
);
315 //.........................................................................
317 //.........................................................................
319 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */