LibreOffice Module sfx2 (master) 1
partwnd.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <com/sun/star/beans/XPropertySet.hpp>
21#include <com/sun/star/frame/Frame.hpp>
22#include <com/sun/star/frame/XController.hpp>
23#include <com/sun/star/uno/Reference.h>
25#include <osl/diagnose.h>
26
28
29#include <vcl/event.hxx>
30#include <sfx2/sfxsids.hrc>
31#include <partwnd.hxx>
32#include <sfx2/bindings.hxx>
33#include <sfx2/dispatch.hxx>
34#include <sfx2/viewfrm.hxx>
35#include <sfx2/frame.hxx>
36
37
38// SfxPartChildWnd_Impl
39
40
42
44(
45 vcl::Window* pParentWnd,
46 sal_uInt16 nId,
47 SfxBindings* pBindings,
48 SfxChildWinInfo* pInfo
49)
50 : SfxChildWindow( pParentWnd, nId )
51{
52 // Create Window
55
56 assert(pInfo);
58
59 static_cast<SfxDockingWindow*>(GetWindow())->SetFloatingSize( Size( 175, 175 ) );
60 GetWindow()->SetSizePixel( Size( 175, 175 ) );
61
62 static_cast<SfxDockingWindow*>(GetWindow())->Initialize( pInfo );
63 SetHideNotDelete( true );
64}
65
67{
68 css::uno::Reference< css::frame::XFrame > xFrame = GetFrame();
69
70 // If xFrame=NULL release pMgr! Because this window lives longer then the manager!
71 // In these case we got a xFrame->dispose() call from outside ... and has release our
72 // frame reference in our own DisposingListener.
73 // But don't do it, if xFrame already exist. Then dispose() must come from inside ...
74 // and we need a valid pMgr for further operations ...
75
76 SfxPartDockWnd_Impl* pWin = static_cast<SfxPartDockWnd_Impl*>(GetWindow());
77
78 if ( pWin && xFrame == pWin->GetBindings().GetActiveFrame() )
79 pWin->GetBindings().SetActiveFrame( nullptr );
80}
81
83{
84 return static_cast<SfxPartDockWnd_Impl*>(GetWindow())->QueryClose();
85}
86
87
88// SfxPartDockWnd_Impl
89
90
92(
93 SfxBindings* pBind,
94 SfxChildWindow* pChildWin,
95 vcl::Window* pParent,
96 WinBits nBits
97)
98 : SfxDockingWindow( pBind, pChildWin, pParent, nBits )
99{
100 css::uno::Reference < css::frame::XFrame2 > xFrame = css::frame::Frame::create(
101 ::comphelper::getProcessComponentContext() );
102 xFrame->initialize( VCLUnoHelper::GetInterface ( this ) );
103
104 try
105 {
106 css::uno::Reference< css::beans::XPropertySet > xLMPropSet( xFrame->getLayoutManager(), css::uno::UNO_QUERY_THROW );
107
108 xLMPropSet->setPropertyValue( "AutomaticToolbars", css::uno::Any( false ));
109 }
110 catch( css::uno::RuntimeException& )
111 {
112 throw;
113 }
114 catch( css::uno::Exception& )
115 {
116 }
117
118 pChildWin->SetFrame( css::uno::Reference<css::frame::XFrame>(xFrame,css::uno::UNO_QUERY_THROW) );
119 if ( pBind->GetDispatcher() )
120 {
121 css::uno::Reference < css::frame::XFramesSupplier >
122 xSupp ( pBind->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY );
123 if ( xSupp.is() )
124 xSupp->getFrames()->append( css::uno::Reference<css::frame::XFrame>(xFrame, css::uno::UNO_QUERY_THROW) );
125 }
126 else {
127 OSL_FAIL("Bindings without Dispatcher!");
128 }
129}
130
131
133{
134 bool bClose = true;
136 if( pChild )
137 {
138 css::uno::Reference< css::frame::XFrame > xFrame = pChild->GetFrame();
139 if( xFrame.is() )
140 {
141 css::uno::Reference< css::frame::XController > xCtrl = xFrame->getController();
142 if( xCtrl.is() )
143 bClose = xCtrl->suspend( true );
144 }
145 }
146
147 return bClose;
148}
149
150
152{
153 if( rEvt.GetType() == NotifyEventType::GETFOCUS )
154 {
156 if( pChild )
157 {
158 css::uno::Reference< css::frame::XFrame > xFrame = pChild->GetFrame();
159 if( xFrame.is() )
160 xFrame->activate();
161 }
162 }
163
164 return SfxDockingWindow::EventNotify( rEvt );
165}
166
168{
170 rInfo.bVisible = false;
171}
172
173
174/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
NotifyEventType GetType() const
SfxDispatcher * GetDispatcher() const
Definition: bindings.hxx:172
css::uno::Reference< css::frame::XFrame > GetActiveFrame() const
Definition: bindings.cxx:1712
void SetActiveFrame(const css::uno::Reference< css::frame::XFrame > &rFrame)
Definition: bindings.cxx:1703
const css::uno::Reference< css::frame::XFrame > & GetFrame() const
Definition: childwin.cxx:590
void SetFrame(const css::uno::Reference< css::frame::XFrame > &)
Definition: childwin.cxx:595
void SetAlignment(SfxChildAlignment eAlign)
Definition: childwin.cxx:299
vcl::Window * GetWindow() const
Definition: childwin.hxx:117
void SetWindow(const VclPtr< vcl::Window > &p)
Definition: childwin.hxx:111
void SetHideNotDelete(bool bOn)
Definition: childwin.cxx:431
SfxViewFrame * GetFrame() const
Returns a pointer to the <SfxViewFrame> instance, which belongs to this SfxDispatcher.
Definition: dispatch.cxx:557
virtual void FillInfo(SfxChildWinInfo &) const
Fills a SfxChildWinInfo with specific data from SfxDockingWindow, so that it can be written in the IN...
Definition: dockwin.cxx:996
SfxBindings & GetBindings() const
Definition: dockwin.hxx:96
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: dockwin.cxx:1440
SAL_DLLPRIVATE SfxChildWindow * GetChildWindow_Impl()
Definition: dockwin.hxx:74
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
Definition: frame.cxx:515
virtual ~SfxPartChildWnd_Impl() override
Definition: partwnd.cxx:66
SfxPartChildWnd_Impl(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo)
Definition: partwnd.cxx:44
virtual bool QueryClose() override
Definition: partwnd.cxx:82
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: partwnd.cxx:151
virtual void FillInfo(SfxChildWinInfo &) const override
Fills a SfxChildWinInfo with specific data from SfxDockingWindow, so that it can be written in the IN...
Definition: partwnd.cxx:167
SfxPartDockWnd_Impl(SfxBindings *pBindings, SfxChildWindow *pChildWin, vcl::Window *pParent, WinBits nBits)
Definition: partwnd.cxx:92
SfxFrame & GetFrame() const
Definition: viewfrm.cxx:2782
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
virtual void SetSizePixel(const Size &rNewSize)
sal_Int16 nId
SFX_IMPL_DOCKINGWINDOW(SfxPartChildWnd_Impl, SID_BROWSER)
SfxChildWindowFlags nFlags
Definition: childwin.hxx:68
Reference< XFrame > xFrame
sal_Int64 WinBits
WinBits const WB_SIZEABLE
WinBits const WB_3DLOOK
WinBits const WB_STDDOCKWIN
WinBits const WB_CLIPCHILDREN