Bump version to 4.1-6
[LibreOffice.git] / sfx2 / source / dialog / partwnd.cxx
blobfb0058f9cb22aa227defe13744ba3f521ccbde66
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>
46 //****************************************************************************
47 // SfxPartChildWnd_Impl
48 //****************************************************************************
50 SFX_IMPL_DOCKINGWINDOW( SfxPartChildWnd_Impl, SID_BROWSER );
52 SfxPartChildWnd_Impl::SfxPartChildWnd_Impl
54 Window* pParentWnd,
55 sal_uInt16 nId,
56 SfxBindings* pBindings,
57 SfxChildWinInfo* pInfo
59 : SfxChildWindow( pParentWnd, nId )
61 // Create Window
62 pWindow = new SfxPartDockWnd_Impl( pBindings, this, pParentWnd, WB_STDDOCKWIN | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK );
63 eChildAlignment = SFX_ALIGN_TOP;
64 if ( pInfo )
65 pInfo->nFlags |= SFX_CHILDWIN_FORCEDOCK;
67 ((SfxDockingWindow*)pWindow)->SetFloatingSize( Size( 175, 175 ) );
68 pWindow->SetSizePixel( Size( 175, 175 ) );
70 ( ( SfxDockingWindow* ) pWindow )->Initialize( pInfo );
71 SetHideNotDelete( sal_True );
74 SfxPartChildWnd_Impl::~SfxPartChildWnd_Impl()
76 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = GetFrame();
78 // If xFrame=NULL release pMgr! Because this window lives longer then the manager!
79 // In these case we got a xFrame->dispose() call from outside ... and has release our
80 // frame reference in our own DisposingListener.
81 // But don't do it, if xFrame already exist. Then dispose() must come from inside ...
82 // and we need a valid pMgr for further operations ...
84 SfxPartDockWnd_Impl* pWin = (SfxPartDockWnd_Impl*) pWindow;
86 if ( pWin && xFrame == pWin->GetBindings().GetActiveFrame() )
87 pWin->GetBindings().SetActiveFrame( NULL );
90 sal_Bool SfxPartChildWnd_Impl::QueryClose()
92 return ( (SfxPartDockWnd_Impl*)pWindow )->QueryClose();
95 //****************************************************************************
96 // SfxPartDockWnd_Impl
97 //****************************************************************************
99 SfxPartDockWnd_Impl::SfxPartDockWnd_Impl
101 SfxBindings* pBind,
102 SfxChildWindow* pChildWin,
103 Window* pParent,
104 WinBits nBits
106 : SfxDockingWindow( pBind, pChildWin, pParent, nBits )
108 css::uno::Reference < css::frame::XFrame2 > xFrame = css::frame::Frame::create(
109 ::comphelper::getProcessComponentContext() );
110 xFrame->initialize( VCLUnoHelper::GetInterface ( this ) );
114 css::uno::Reference< css::beans::XPropertySet > xLMPropSet( xFrame->getLayoutManager(), css::uno::UNO_QUERY_THROW );
116 const OUString aAutomaticToolbars( "AutomaticToolbars" );
117 xLMPropSet->setPropertyValue( aAutomaticToolbars, css::uno::Any( sal_False ));
119 catch( css::uno::RuntimeException& )
121 throw;
123 catch( css::uno::Exception& )
127 pChildWin->SetFrame( css::uno::Reference<css::frame::XFrame>(xFrame,css::uno::UNO_QUERY_THROW) );
128 if ( pBind->GetDispatcher() )
130 css::uno::Reference < css::frame::XFramesSupplier >
131 xSupp ( pBind->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY );
132 if ( xSupp.is() )
133 xSupp->getFrames()->append( css::uno::Reference<css::frame::XFrame>(xFrame, css::uno::UNO_QUERY_THROW) );
135 else {
136 OSL_FAIL("Bindings without Dispatcher!");
140 //****************************************************************************
142 SfxPartDockWnd_Impl::~SfxPartDockWnd_Impl()
146 //****************************************************************************
148 void SfxPartDockWnd_Impl::Resize()
150 /* [Description]
152 Adjusting the size of the controls wrt the new window size
156 SfxDockingWindow::Resize();
159 //****************************************************************************
161 sal_Bool SfxPartDockWnd_Impl::QueryClose()
163 sal_Bool bClose = sal_True;
164 SfxChildWindow* pChild = GetChildWindow_Impl();
165 if( pChild )
167 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pChild->GetFrame();
168 if( xFrame.is() )
170 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xCtrl = xFrame->getController();
171 if( xCtrl.is() )
172 bClose = xCtrl->suspend( sal_True );
176 return bClose;
179 //****************************************************************************
181 long SfxPartDockWnd_Impl::Notify( NotifyEvent& rEvt )
183 if( rEvt.GetType() == EVENT_GETFOCUS )
185 SfxChildWindow* pChild = GetChildWindow_Impl();
186 if( pChild )
188 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pChild->GetFrame();
189 if( xFrame.is() )
190 xFrame->activate();
194 return SfxDockingWindow::Notify( rEvt );
197 void SfxPartDockWnd_Impl::FillInfo( SfxChildWinInfo& rInfo ) const
199 SfxDockingWindow::FillInfo( rInfo );
200 rInfo.bVisible = sal_False;
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */