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/uno/XComponentContext.hpp>
25 #include <vcl/taskpanelist.hxx>
26 #include <tools/debug.hxx>
27 #include "bibbeam.hxx"
29 #include "bibtools.hxx"
31 using namespace ::com::sun::star
;
32 using namespace ::com::sun::star::beans
;
33 using namespace ::com::sun::star::uno
;
42 void HandleTaskPaneList( vcl::Window
* pWindow
, bool bAddToList
)
44 vcl::Window
* pParent
= pWindow
->GetParent();
46 assert(pParent
&& "-GetTaskPaneList(): everybody here should have a parent!");
48 SystemWindow
* pSysWin
= pParent
->GetSystemWindow();
51 TaskPaneList
* pTaskPaneList
= pSysWin
->GetTaskPaneList();
55 pTaskPaneList
->AddWindow( pWindow
);
57 pTaskPaneList
->RemoveWindow( pWindow
);
64 :public vcl::Window
//DockingWindow
67 Reference
< awt::XWindow
> m_xGridWin
;
68 Reference
< awt::XControlModel
> m_xGridModel
;
69 Reference
< awt::XControl
> m_xControl
;
70 Reference
< awt::XControlContainer
> m_xControlContainer
;
71 Reference
< frame::XDispatchProviderInterception
> m_xDispatchProviderInterception
;
75 virtual void Resize() override
;
79 BibGridwin(vcl::Window
* pParent
, WinBits nStyle
);
80 virtual ~BibGridwin() override
;
81 virtual void dispose() override
;
83 void createGridWin(const Reference
< awt::XControlModel
> & xDbForm
);
84 void disposeGridWin();
86 const Reference
< awt::XControlContainer
>& getControlContainer() const { return m_xControlContainer
; }
87 const Reference
< frame::XDispatchProviderInterception
>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception
; }
89 virtual void GetFocus() override
;
92 BibGridwin::BibGridwin( vcl::Window
* _pParent
, WinBits _nStyle
) : Window( _pParent
, _nStyle
)
94 m_xControlContainer
= VCLUnoHelper::CreateControlContainer(this);
96 AddToTaskPaneList( this );
99 BibGridwin::~BibGridwin()
104 void BibGridwin::dispose()
106 RemoveFromTaskPaneList( this );
109 vcl::Window::dispose();
112 void BibGridwin::Resize()
116 ::Size aSize
= GetOutputSizePixel();
117 m_xGridWin
->setPosSize(0, 0, aSize
.Width(),aSize
.Height(), awt::PosSize::SIZE
);
121 void BibGridwin::createGridWin(const uno::Reference
< awt::XControlModel
> & xGModel
)
123 m_xGridModel
= xGModel
;
125 if( !m_xControlContainer
.is())
128 const uno::Reference
< uno::XComponentContext
>& xContext
= comphelper::getProcessComponentContext();
130 if ( !m_xGridModel
.is())
133 uno::Reference
< XPropertySet
> xPropSet( m_xGridModel
, UNO_QUERY
);
135 if ( xPropSet
.is() && m_xGridModel
.is() )
137 uno::Any aAny
= xPropSet
->getPropertyValue( u
"DefaultControl"_ustr
);
138 OUString aControlName
;
139 aAny
>>= aControlName
;
141 m_xControl
.set( xContext
->getServiceManager()->createInstanceWithContext(aControlName
, xContext
), UNO_QUERY_THROW
);
142 m_xControl
->setModel( m_xGridModel
);
145 if ( !m_xControl
.is() )
148 // Peer as Child to the FrameWindow
149 m_xControlContainer
->addControl(u
"GridControl"_ustr
, 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
);
160 void BibGridwin::disposeGridWin()
162 if ( m_xControl
.is() )
164 Reference
< awt::XControl
> xDel( m_xControl
);
165 m_xControl
= nullptr;
166 m_xGridWin
= nullptr;
168 m_xControlContainer
->removeControl( xDel
);
173 void BibGridwin::GetFocus()
176 m_xGridWin
->setFocus();
179 BibBeamer::BibBeamer( vcl::Window
* _pParent
, BibDataManager
* _pDM
)
180 :BibSplitWindow( _pParent
, WB_3DLOOK
| WB_NOSPLITDRAW
)
187 pDatMan
->SetToolbar(pToolBar
);
189 connectForm( pDatMan
);
192 BibBeamer::~BibBeamer()
197 void BibBeamer::dispose()
199 if ( isFormConnected() )
203 pDatMan
->SetToolbar(nullptr);
205 pToolBar
.disposeAndClear();
206 pGridWin
.disposeAndClear();
207 BibSplitWindow::dispose();
210 void BibBeamer::createToolBar()
212 pToolBar
= VclPtr
<BibToolBar
>::Create(this, LINK( this, BibBeamer
, RecalcLayout_Impl
));
213 ::Size aSize
=pToolBar
->get_preferred_size();
214 InsertItem(ID_TOOLBAR
, pToolBar
, aSize
.Height(), 0, 0, SplitWindowItemFlags::Fixed
);
215 if ( m_xController
.is() )
216 pToolBar
->SetXController( m_xController
);
219 void BibBeamer::createGridWin()
221 pGridWin
= VclPtr
<BibGridwin
>::Create(this,0);
223 InsertItem(ID_GRIDWIN
, pGridWin
, 40, 1, 0, SplitWindowItemFlags::RelativeSize
);
225 pGridWin
->createGridWin( pDatMan
->updateGridModel() );
228 Reference
< awt::XControlContainer
> BibBeamer::getControlContainer()
230 Reference
< awt::XControlContainer
> xReturn
;
232 xReturn
= pGridWin
->getControlContainer();
236 Reference
< frame::XDispatchProviderInterception
> BibBeamer::getDispatchProviderInterception() const
238 Reference
< frame::XDispatchProviderInterception
> xReturn
;
240 xReturn
= pGridWin
->getDispatchProviderInterception();
244 void BibBeamer::SetXController(const uno::Reference
< frame::XController
> & xCtr
)
246 m_xController
= xCtr
;
249 pToolBar
->SetXController( m_xController
);
253 void BibBeamer::GetFocus()
256 pGridWin
->GrabFocus();
259 IMPL_LINK_NOARG( BibBeamer
, RecalcLayout_Impl
, void*, void )
261 tools::Long nHeight
= pToolBar
->get_preferred_size().Height();
262 SetItemSize( ID_TOOLBAR
, nHeight
);
267 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */