1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
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
49 //.........................................................................
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();
65 TaskPaneList
* pTaskPaneList
= pSysWin
->GetTaskPaneList();
69 pTaskPaneList
->AddWindow( pWindow
);
71 pTaskPaneList
->RemoveWindow( pWindow
);
76 //=====================================================================
78 //=====================================================================
80 :public Window
//DockingWindow
83 Reference
< awt::XWindow
> m_xGridWin
;
84 Reference
< awt::XControlModel
> m_xGridModel
;
85 Reference
< awt::XControl
> m_xControl
;
86 Reference
< awt::XControlContainer
> m_xControlContainer
;
88 Reference
< frame::XDispatchProviderInterception
> m_xDispatchProviderInterception
;
92 virtual void Resize();
96 BibGridwin(Window
* pParent
, WinBits nStyle
= WB_3DLOOK
);
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 );
125 //---------------------------------------------------------------------
126 void BibGridwin::Resize()
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
);
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
);
187 m_xControlContainer
->removeControl( xDel
);
192 //---------------------------------------------------------------------
193 void BibGridwin::GetFocus()
196 m_xGridWin
->setFocus();
199 //---------------------------------------------------------------------
200 BibBeamer::BibBeamer( Window
* _pParent
, BibDataManager
* _pDM
, WinBits _nStyle
)
201 :BibSplitWindow( _pParent
, _nStyle
| WB_NOSPLITDRAW
)
209 pDatMan
->SetToolbar(pToolBar
);
213 connectForm( pDatMan
);
216 //---------------------------------------------------------------------
217 BibBeamer::~BibBeamer()
219 if ( isFormConnected() )
222 if ( m_xToolBarRef
.is() )
223 m_xToolBarRef
->dispose();
228 pDatMan
->SetToolbar(0);
235 BibGridwin
* pDel
= pGridWin
;
237 pDel
->disposeGridWin();
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
;
268 xReturn
= pGridWin
->getControlContainer();
272 // #100312# -----------------------------------------------------------
273 Reference
< frame::XDispatchProviderInterception
> BibBeamer::getDispatchProviderInterception()
275 Reference
< frame::XDispatchProviderInterception
> xReturn
;
277 xReturn
= pGridWin
->getDispatchProviderInterception();
281 //---------------------------------------------------------------------
282 void BibBeamer::SetXController(const uno::Reference
< frame::XController
> & xCtr
)
284 m_xController
= xCtr
;
287 pToolBar
->SetXController( m_xController
);
291 //---------------------------------------------------------------------
292 void BibBeamer::GetFocus()
295 pGridWin
->GrabFocus();
298 //---------------------------------------------------------------------
299 IMPL_LINK( BibBeamer
, RecalcLayout_Impl
, void*, /*pVoid*/ )
301 long nHeight
= pToolBar
->GetSizePixel().Height();
302 SetItemSize( ID_TOOLBAR
, nHeight
);
306 //.........................................................................
308 //.........................................................................
310 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */