bump product version to 5.0.4.1
[LibreOffice.git] / sfx2 / source / dialog / partwnd.cxx
blobf16288d4a1c7d2ae6979b169afe64084089d4128
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <com/sun/star/awt/XWindow.hpp>
21 #include <com/sun/star/awt/PosSize.hpp>
22 #include <com/sun/star/beans/PropertyValue.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/frame/Frame.hpp>
25 #include <com/sun/star/frame/XController.hpp>
26 #include <com/sun/star/lang/XComponent.hpp>
27 #include <com/sun/star/lang/DisposedException.hpp>
28 #include <com/sun/star/task/XStatusIndicator.hpp>
29 #include <com/sun/star/uno/Reference.h>
30 #include <com/sun/star/uno/Sequence.hxx>
31 #include <com/sun/star/util/URL.hpp>
32 #include <com/sun/star/util/XCloseable.hpp>
33 #include <com/sun/star/util/CloseVetoException.hpp>
34 #include <comphelper/processfactory.hxx>
36 #include <toolkit/helper/vclunohelper.hxx>
38 #include <sfx2/sfxsids.hrc>
39 #include "partwnd.hxx"
40 #include <sfx2/bindings.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <sfx2/viewfrm.hxx>
43 #include <sfx2/frame.hxx>
44 #include <sfx2/sfxuno.hxx>
47 // SfxPartChildWnd_Impl
50 SFX_IMPL_DOCKINGWINDOW( SfxPartChildWnd_Impl, SID_BROWSER );
52 SfxPartChildWnd_Impl::SfxPartChildWnd_Impl
54 vcl::Window* pParentWnd,
55 sal_uInt16 nId,
56 SfxBindings* pBindings,
57 SfxChildWinInfo* pInfo
59 : SfxChildWindow( pParentWnd, nId )
61 // Create Window
62 pWindow = VclPtr<SfxPartDockWnd_Impl>::Create( pBindings, this, pParentWnd, WB_STDDOCKWIN | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK );
63 eChildAlignment = SfxChildAlignment::TOP;
65 assert(pInfo);
66 pInfo->nFlags |= SfxChildWindowFlags::FORCEDOCK;
68 static_cast<SfxDockingWindow*>(pWindow.get())->SetFloatingSize( Size( 175, 175 ) );
69 pWindow->SetSizePixel( Size( 175, 175 ) );
71 static_cast<SfxDockingWindow*>(pWindow.get())->Initialize( pInfo );
72 SetHideNotDelete( true );
75 SfxPartChildWnd_Impl::~SfxPartChildWnd_Impl()
77 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = GetFrame();
79 // If xFrame=NULL release pMgr! Because this window lives longer then the manager!
80 // In these case we got a xFrame->dispose() call from outside ... and has release our
81 // frame reference in our own DisposingListener.
82 // But don't do it, if xFrame already exist. Then dispose() must come from inside ...
83 // and we need a valid pMgr for further operations ...
85 SfxPartDockWnd_Impl* pWin = static_cast<SfxPartDockWnd_Impl*>(pWindow.get());
87 if ( pWin && xFrame == pWin->GetBindings().GetActiveFrame() )
88 pWin->GetBindings().SetActiveFrame( NULL );
91 bool SfxPartChildWnd_Impl::QueryClose()
93 return static_cast<SfxPartDockWnd_Impl*>(pWindow.get())->QueryClose();
97 // SfxPartDockWnd_Impl
100 SfxPartDockWnd_Impl::SfxPartDockWnd_Impl
102 SfxBindings* pBind,
103 SfxChildWindow* pChildWin,
104 vcl::Window* pParent,
105 WinBits nBits
107 : SfxDockingWindow( pBind, pChildWin, pParent, nBits )
109 css::uno::Reference < css::frame::XFrame2 > xFrame = css::frame::Frame::create(
110 ::comphelper::getProcessComponentContext() );
111 xFrame->initialize( VCLUnoHelper::GetInterface ( this ) );
115 css::uno::Reference< css::beans::XPropertySet > xLMPropSet( xFrame->getLayoutManager(), css::uno::UNO_QUERY_THROW );
117 const OUString aAutomaticToolbars( "AutomaticToolbars" );
118 xLMPropSet->setPropertyValue( aAutomaticToolbars, css::uno::Any( sal_False ));
120 catch( css::uno::RuntimeException& )
122 throw;
124 catch( css::uno::Exception& )
128 pChildWin->SetFrame( css::uno::Reference<css::frame::XFrame>(xFrame,css::uno::UNO_QUERY_THROW) );
129 if ( pBind->GetDispatcher() )
131 css::uno::Reference < css::frame::XFramesSupplier >
132 xSupp ( pBind->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY );
133 if ( xSupp.is() )
134 xSupp->getFrames()->append( css::uno::Reference<css::frame::XFrame>(xFrame, css::uno::UNO_QUERY_THROW) );
136 else {
137 OSL_FAIL("Bindings without Dispatcher!");
143 void SfxPartDockWnd_Impl::Resize()
145 /* [Description]
147 Adjusting the size of the controls wrt the new window size
151 SfxDockingWindow::Resize();
156 bool SfxPartDockWnd_Impl::QueryClose()
158 bool bClose = true;
159 SfxChildWindow* pChild = GetChildWindow_Impl();
160 if( pChild )
162 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pChild->GetFrame();
163 if( xFrame.is() )
165 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xCtrl = xFrame->getController();
166 if( xCtrl.is() )
167 bClose = xCtrl->suspend( sal_True );
171 return bClose;
176 bool SfxPartDockWnd_Impl::Notify( NotifyEvent& rEvt )
178 if( rEvt.GetType() == MouseNotifyEvent::GETFOCUS )
180 SfxChildWindow* pChild = GetChildWindow_Impl();
181 if( pChild )
183 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pChild->GetFrame();
184 if( xFrame.is() )
185 xFrame->activate();
189 return SfxDockingWindow::Notify( rEvt );
192 void SfxPartDockWnd_Impl::FillInfo( SfxChildWinInfo& rInfo ) const
194 SfxDockingWindow::FillInfo( rInfo );
195 rInfo.bVisible = false;
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */