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 <toolkit/helper/vclunohelper.hxx>
21 #include <comphelper/processfactory.hxx>
22 #include <com/sun/star/awt/PosSize.hpp>
23 #include <com/sun/star/util/XURLTransformer.hpp>
24 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <vcl/edit.hxx>
27 #include <tools/debug.hxx>
28 #include "bibbeam.hxx"
29 #include "bibview.hxx"
30 #include "bibresid.hxx"
32 #include "bibtools.hxx"
34 using namespace ::com::sun::star
;
35 using namespace ::com::sun::star::beans
;
36 using namespace ::com::sun::star::uno
;
45 void HandleTaskPaneList( vcl::Window
* pWindow
, bool bAddToList
)
47 vcl::Window
* pParent
= pWindow
->GetParent();
49 DBG_ASSERT( pParent
, "-GetTaskPaneList(): everybody here should have a parent!" );
51 SystemWindow
* pSysWin
= pParent
->GetSystemWindow();
54 TaskPaneList
* pTaskPaneList
= pSysWin
->GetTaskPaneList();
58 pTaskPaneList
->AddWindow( pWindow
);
60 pTaskPaneList
->RemoveWindow( pWindow
);
67 :public vcl::Window
//DockingWindow
70 Reference
< awt::XWindow
> m_xGridWin
;
71 Reference
< awt::XControlModel
> m_xGridModel
;
72 Reference
< awt::XControl
> m_xControl
;
73 Reference
< awt::XControlContainer
> m_xControlContainer
;
74 Reference
< frame::XDispatchProviderInterception
> m_xDispatchProviderInterception
;
78 virtual void Resize() override
;
82 BibGridwin(vcl::Window
* pParent
, WinBits nStyle
);
83 virtual ~BibGridwin() override
;
84 virtual void dispose() override
;
86 void createGridWin(const Reference
< awt::XControlModel
> & xDbForm
);
87 void disposeGridWin();
89 const Reference
< awt::XControlContainer
>& getControlContainer() const { return m_xControlContainer
; }
90 const Reference
< frame::XDispatchProviderInterception
>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception
; }
92 virtual void GetFocus() override
;
95 BibGridwin::BibGridwin( vcl::Window
* _pParent
, WinBits _nStyle
) : Window( _pParent
, _nStyle
)
97 m_xControlContainer
= VCLUnoHelper::CreateControlContainer(this);
99 AddToTaskPaneList( this );
102 BibGridwin::~BibGridwin()
107 void BibGridwin::dispose()
109 RemoveFromTaskPaneList( this );
112 vcl::Window::dispose();
115 void BibGridwin::Resize()
119 ::Size aSize
= GetOutputSizePixel();
120 m_xGridWin
->setPosSize(0, 0, aSize
.Width(),aSize
.Height(), awt::PosSize::SIZE
);
124 void BibGridwin::createGridWin(const uno::Reference
< awt::XControlModel
> & xGModel
)
126 m_xGridModel
= xGModel
;
128 if( m_xControlContainer
.is())
130 uno::Reference
< uno::XComponentContext
> xContext
= comphelper::getProcessComponentContext();
132 if ( m_xGridModel
.is())
134 uno::Reference
< XPropertySet
> xPropSet( m_xGridModel
, UNO_QUERY
);
136 if ( xPropSet
.is() && m_xGridModel
.is() )
138 uno::Any aAny
= xPropSet
->getPropertyValue( "DefaultControl" );
139 OUString aControlName
;
140 aAny
>>= aControlName
;
142 m_xControl
.set( xContext
->getServiceManager()->createInstanceWithContext(aControlName
, xContext
), UNO_QUERY_THROW
);
143 m_xControl
->setModel( m_xGridModel
);
146 if ( m_xControl
.is() )
148 // Peer as Child to the FrameWindow
149 m_xControlContainer
->addControl("GridControl", m_xControl
);
150 m_xGridWin
.set(m_xControl
, UNO_QUERY
);
151 m_xDispatchProviderInterception
.set(m_xControl
, UNO_QUERY
);
152 m_xGridWin
->setVisible( true );
153 m_xControl
->setDesignMode( true );
154 // initially switch on the design mode - switch it off _after_ loading the form
156 ::Size aSize
= GetOutputSizePixel();
157 m_xGridWin
->setPosSize(0, 0, aSize
.Width(),aSize
.Height(), awt::PosSize::POSSIZE
);
163 void BibGridwin::disposeGridWin()
165 if ( m_xControl
.is() )
167 Reference
< awt::XControl
> xDel( m_xControl
);
168 m_xControl
= nullptr;
169 m_xGridWin
= nullptr;
171 m_xControlContainer
->removeControl( xDel
);
176 void BibGridwin::GetFocus()
179 m_xGridWin
->setFocus();
182 BibBeamer::BibBeamer( vcl::Window
* _pParent
, BibDataManager
* _pDM
)
183 :BibSplitWindow( _pParent
, WB_3DLOOK
| WB_NOSPLITDRAW
)
190 pDatMan
->SetToolbar(pToolBar
);
192 connectForm( pDatMan
);
195 BibBeamer::~BibBeamer()
200 void BibBeamer::dispose()
202 if ( isFormConnected() )
206 pDatMan
->SetToolbar(nullptr);
208 pToolBar
.disposeAndClear();
209 pGridWin
.disposeAndClear();
210 BibSplitWindow::dispose();
213 void BibBeamer::createToolBar()
215 pToolBar
= VclPtr
<BibToolBar
>::Create(this, LINK( this, BibBeamer
, RecalcLayout_Impl
));
216 ::Size aSize
=pToolBar
->get_preferred_size();
217 InsertItem(ID_TOOLBAR
, pToolBar
, aSize
.Height(), 0, 0, SplitWindowItemFlags::Fixed
);
218 if ( m_xController
.is() )
219 pToolBar
->SetXController( m_xController
);
222 void BibBeamer::createGridWin()
224 pGridWin
= VclPtr
<BibGridwin
>::Create(this,0);
226 InsertItem(ID_GRIDWIN
, pGridWin
, 40, 1, 0, SplitWindowItemFlags::RelativeSize
);
228 pGridWin
->createGridWin( pDatMan
->updateGridModel() );
231 Reference
< awt::XControlContainer
> BibBeamer::getControlContainer()
233 Reference
< awt::XControlContainer
> xReturn
;
235 xReturn
= pGridWin
->getControlContainer();
239 Reference
< frame::XDispatchProviderInterception
> BibBeamer::getDispatchProviderInterception()
241 Reference
< frame::XDispatchProviderInterception
> xReturn
;
243 xReturn
= pGridWin
->getDispatchProviderInterception();
247 void BibBeamer::SetXController(const uno::Reference
< frame::XController
> & xCtr
)
249 m_xController
= xCtr
;
252 pToolBar
->SetXController( m_xController
);
256 void BibBeamer::GetFocus()
259 pGridWin
->GrabFocus();
262 IMPL_LINK_NOARG( BibBeamer
, RecalcLayout_Impl
, void*, void )
264 long nHeight
= pToolBar
->get_preferred_size().Height();
265 SetItemSize( ID_TOOLBAR
, nHeight
);
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */