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
;
45 //.........................................................................
48 //.........................................................................
50 using namespace ::com::sun::star::uno
;
52 void HandleTaskPaneList( Window
* pWindow
, sal_Bool bAddToList
)
54 Window
* pParent
= pWindow
->GetParent();
56 DBG_ASSERT( pParent
, "-GetTaskPaneList(): everybody here should have a parent!" );
58 SystemWindow
* pSysWin
= pParent
->GetSystemWindow();
61 TaskPaneList
* pTaskPaneList
= pSysWin
->GetTaskPaneList();
65 pTaskPaneList
->AddWindow( pWindow
);
67 pTaskPaneList
->RemoveWindow( pWindow
);
72 //=====================================================================
74 //=====================================================================
76 :public Window
//DockingWindow
79 Reference
< awt::XWindow
> m_xGridWin
;
80 Reference
< awt::XControlModel
> m_xGridModel
;
81 Reference
< awt::XControl
> m_xControl
;
82 Reference
< awt::XControlContainer
> m_xControlContainer
;
84 Reference
< frame::XDispatchProviderInterception
> m_xDispatchProviderInterception
;
88 virtual void Resize();
92 BibGridwin(Window
* pParent
, WinBits nStyle
= WB_3DLOOK
);
95 void createGridWin(const Reference
< awt::XControlModel
> & xDbForm
);
96 void disposeGridWin();
98 const Reference
< awt::XControlContainer
>& getControlContainer() const { return m_xControlContainer
; }
100 const Reference
< frame::XDispatchProviderInterception
>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception
; }
102 virtual void GetFocus();
105 //---------------------------------------------------------------------
106 BibGridwin::BibGridwin( Window
* _pParent
, WinBits _nStyle
) : Window( _pParent
, _nStyle
)
108 m_xControlContainer
= VCLUnoHelper::CreateControlContainer(this);
110 AddToTaskPaneList( this );
113 //---------------------------------------------------------------------
114 BibGridwin::~BibGridwin()
116 RemoveFromTaskPaneList( this );
121 //---------------------------------------------------------------------
122 void BibGridwin::Resize()
126 ::Size aSize
= GetOutputSizePixel();
127 m_xGridWin
->setPosSize(0, 0, aSize
.Width(),aSize
.Height(), awt::PosSize::SIZE
);
131 //---------------------------------------------------------------------
132 void BibGridwin::createGridWin(const uno::Reference
< awt::XControlModel
> & xGModel
)
134 m_xGridModel
= xGModel
;
136 if( m_xControlContainer
.is())
138 uno::Reference
< uno::XComponentContext
> xContext
= comphelper::getProcessComponentContext();
140 if ( m_xGridModel
.is())
142 uno::Reference
< XPropertySet
> xPropSet( m_xGridModel
, UNO_QUERY
);
144 if ( xPropSet
.is() && m_xGridModel
.is() )
146 uno::Any aAny
= xPropSet
->getPropertyValue( "DefaultControl" );
147 OUString aControlName
;
148 aAny
>>= aControlName
;
150 m_xControl
= Reference
< awt::XControl
> ( xContext
->getServiceManager()->createInstanceWithContext(aControlName
, xContext
), UNO_QUERY_THROW
);
151 m_xControl
->setModel( m_xGridModel
);
154 if ( m_xControl
.is() )
156 // Peer als Child zu dem FrameWindow
157 m_xControlContainer
->addControl("GridControl", m_xControl
);
158 m_xGridWin
=uno::Reference
< awt::XWindow
> (m_xControl
, UNO_QUERY
);
160 m_xDispatchProviderInterception
=uno::Reference
< frame::XDispatchProviderInterception
> (m_xControl
, UNO_QUERY
);
161 m_xGridWin
->setVisible( sal_True
);
162 m_xControl
->setDesignMode( sal_True
);
163 // initially switch on the desing mode - switch it off _after_ loading the form
165 ::Size aSize
= GetOutputSizePixel();
166 m_xGridWin
->setPosSize(0, 0, aSize
.Width(),aSize
.Height(), awt::PosSize::POSSIZE
);
172 //---------------------------------------------------------------------
173 void BibGridwin::disposeGridWin()
175 if ( m_xControl
.is() )
177 Reference
< awt::XControl
> xDel( m_xControl
);
181 m_xControlContainer
->removeControl( xDel
);
186 //---------------------------------------------------------------------
187 void BibGridwin::GetFocus()
190 m_xGridWin
->setFocus();
193 //---------------------------------------------------------------------
194 BibBeamer::BibBeamer( Window
* _pParent
, BibDataManager
* _pDM
, WinBits _nStyle
)
195 :BibSplitWindow( _pParent
, _nStyle
| WB_NOSPLITDRAW
)
203 pDatMan
->SetToolbar(pToolBar
);
207 connectForm( pDatMan
);
210 //---------------------------------------------------------------------
211 BibBeamer::~BibBeamer()
213 if ( isFormConnected() )
216 if ( m_xToolBarRef
.is() )
217 m_xToolBarRef
->dispose();
222 pDatMan
->SetToolbar(0);
229 BibGridwin
* pDel
= pGridWin
;
231 pDel
->disposeGridWin();
237 //---------------------------------------------------------------------
238 void BibBeamer::createToolBar()
240 pToolBar
= new BibToolBar(this, LINK( this, BibBeamer
, RecalcLayout_Impl
));
241 ::Size aSize
=pToolBar
->GetSizePixel();
242 InsertItem(ID_TOOLBAR
, pToolBar
, aSize
.Height(), 0, 0, SWIB_FIXED
);
243 if ( m_xController
.is() )
244 pToolBar
->SetXController( m_xController
);
247 //---------------------------------------------------------------------
248 void BibBeamer::createGridWin()
250 pGridWin
= new BibGridwin(this,0);
252 InsertItem(ID_GRIDWIN
, pGridWin
, 40, 1, 0, SWIB_RELATIVESIZE
);
254 pGridWin
->createGridWin( pDatMan
->updateGridModel() );
257 //---------------------------------------------------------------------
258 Reference
< awt::XControlContainer
> BibBeamer::getControlContainer()
260 Reference
< awt::XControlContainer
> xReturn
;
262 xReturn
= pGridWin
->getControlContainer();
266 // #100312# -----------------------------------------------------------
267 Reference
< frame::XDispatchProviderInterception
> BibBeamer::getDispatchProviderInterception()
269 Reference
< frame::XDispatchProviderInterception
> xReturn
;
271 xReturn
= pGridWin
->getDispatchProviderInterception();
275 //---------------------------------------------------------------------
276 void BibBeamer::SetXController(const uno::Reference
< frame::XController
> & xCtr
)
278 m_xController
= xCtr
;
281 pToolBar
->SetXController( m_xController
);
285 //---------------------------------------------------------------------
286 void BibBeamer::GetFocus()
289 pGridWin
->GrabFocus();
292 //---------------------------------------------------------------------
293 IMPL_LINK( BibBeamer
, RecalcLayout_Impl
, void*, /*pVoid*/ )
295 long nHeight
= pToolBar
->GetSizePixel().Height();
296 SetItemSize( ID_TOOLBAR
, nHeight
);
300 //.........................................................................
302 //.........................................................................
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */