Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sfx2/source/dialog/partwnd.cxx
Line
Count
Source
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>
24
#include <comphelper/processfactory.hxx>
25
#include <osl/diagnose.h>
26
27
#include <toolkit/helper/vclunohelper.hxx>
28
29
#include <vcl/event.hxx>
30
#include <sfx2/sfxsids.hrc>
31
#include <partwnd.hxx>
32
#include <sfx2/bindings.hxx>
33
#include <sfx2/chalign.hxx>
34
#include <sfx2/dispatch.hxx>
35
#include <sfx2/viewfrm.hxx>
36
#include <sfx2/frame.hxx>
37
38
39
// SfxPartChildWnd_Impl
40
41
42
SFX_IMPL_DOCKINGWINDOW( SfxPartChildWnd_Impl, SID_BROWSER );
43
44
SfxPartChildWnd_Impl::SfxPartChildWnd_Impl(vcl::Window* pParentWnd, sal_uInt16 nId,
45
                                           SfxBindings& rBindings, SfxChildWinInfo& rInfo)
46
0
    : SfxChildWindow(pParentWnd, nId)
47
0
{
48
    // Create Window
49
0
    SetWindow(VclPtr<SfxPartDockWnd_Impl>::Create(
50
0
        rBindings, this, pParentWnd, WB_STDDOCKWIN | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK));
51
0
    SetAlignment(SfxChildAlignment::TOP);
52
53
0
    rInfo.nFlags |= SfxChildWindowFlags::FORCEDOCK;
54
55
0
    static_cast<SfxDockingWindow*>(GetWindow())->SetFloatingSize( Size( 175, 175 ) );
56
0
    GetWindow()->SetSizePixel( Size( 175, 175 ) );
57
58
0
    static_cast<SfxDockingWindow*>(GetWindow())->Initialize(rInfo);
59
0
    SetHideNotDelete( true );
60
0
}
61
62
SfxPartChildWnd_Impl::~SfxPartChildWnd_Impl()
63
0
{
64
0
    css::uno::Reference< css::frame::XFrame > xFrame = GetFrame();
65
66
    // If xFrame=NULL release pMgr! Because this window lives longer than the manager!
67
    // In these case we got a xFrame->dispose() call from outside ... and has release our
68
    // frame reference in our own DisposingListener.
69
    // But don't do it, if xFrame already exist. Then dispose() must come from inside ...
70
    // and we need a valid pMgr for further operations ...
71
72
0
    SfxPartDockWnd_Impl* pWin = static_cast<SfxPartDockWnd_Impl*>(GetWindow());
73
74
0
    if ( pWin && xFrame == pWin->GetBindings().GetActiveFrame() )
75
0
        pWin->GetBindings().SetActiveFrame( nullptr );
76
0
}
77
78
bool SfxPartChildWnd_Impl::QueryClose()
79
0
{
80
0
    return static_cast<SfxPartDockWnd_Impl*>(GetWindow())->QueryClose();
81
0
}
82
83
84
// SfxPartDockWnd_Impl
85
86
SfxPartDockWnd_Impl::SfxPartDockWnd_Impl(SfxBindings& rBindings, SfxChildWindow* pChildWin,
87
                                         vcl::Window* pParent, WinBits nBits)
88
0
    : SfxDockingWindow(rBindings, pChildWin, pParent, nBits)
89
0
{
90
0
    css::uno::Reference < css::frame::XFrame2 > xFrame = css::frame::Frame::create(
91
0
            ::comphelper::getProcessComponentContext() );
92
0
    xFrame->initialize( VCLUnoHelper::GetInterface ( this ) );
93
94
0
    try
95
0
    {
96
0
        css::uno::Reference< css::beans::XPropertySet > xLMPropSet( xFrame->getLayoutManager(), css::uno::UNO_QUERY_THROW );
97
98
0
        xLMPropSet->setPropertyValue( u"AutomaticToolbars"_ustr, css::uno::Any( false ));
99
0
    }
100
0
    catch( css::uno::RuntimeException& )
101
0
    {
102
0
        throw;
103
0
    }
104
0
    catch( css::uno::Exception& )
105
0
    {
106
0
    }
107
108
0
    pChildWin->SetFrame( css::uno::Reference<css::frame::XFrame>(xFrame,css::uno::UNO_QUERY_THROW) );
109
0
    if (rBindings.GetDispatcher())
110
0
    {
111
0
        css::uno::Reference<css::frame::XFramesSupplier> xSupp(
112
0
            rBindings.GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(),
113
0
            css::uno::UNO_QUERY);
114
0
        if ( xSupp.is() )
115
0
            xSupp->getFrames()->append( css::uno::Reference<css::frame::XFrame>(xFrame, css::uno::UNO_QUERY_THROW) );
116
0
    }
117
0
    else {
118
0
        OSL_FAIL("Bindings without Dispatcher!");
119
0
    }
120
0
}
Unexecuted instantiation: SfxPartDockWnd_Impl::SfxPartDockWnd_Impl(SfxBindings&, SfxChildWindow*, vcl::Window*, long)
Unexecuted instantiation: SfxPartDockWnd_Impl::SfxPartDockWnd_Impl(SfxBindings&, SfxChildWindow*, vcl::Window*, long)
121
122
123
bool SfxPartDockWnd_Impl::QueryClose()
124
0
{
125
0
    bool bClose = true;
126
0
    SfxChildWindow* pChild = GetChildWindow_Impl();
127
0
    if( pChild )
128
0
    {
129
0
        css::uno::Reference< css::frame::XFrame > xFrame = pChild->GetFrame();
130
0
        if( xFrame.is() )
131
0
        {
132
0
            css::uno::Reference< css::frame::XController >  xCtrl = xFrame->getController();
133
0
            if( xCtrl.is() )
134
0
                bClose = xCtrl->suspend( true );
135
0
        }
136
0
    }
137
138
0
    return bClose;
139
0
}
140
141
142
bool SfxPartDockWnd_Impl::EventNotify( NotifyEvent& rEvt )
143
0
{
144
0
    if( rEvt.GetType() == NotifyEventType::GETFOCUS )
145
0
    {
146
0
        SfxChildWindow* pChild = GetChildWindow_Impl();
147
0
        if( pChild )
148
0
        {
149
0
            css::uno::Reference< css::frame::XFrame > xFrame = pChild->GetFrame();
150
0
            if( xFrame.is() )
151
0
                xFrame->activate();
152
0
        }
153
0
    }
154
155
0
    return SfxDockingWindow::EventNotify( rEvt );
156
0
}
157
158
void SfxPartDockWnd_Impl::FillInfo( SfxChildWinInfo& rInfo ) const
159
0
{
160
0
    SfxDockingWindow::FillInfo( rInfo );
161
0
    rInfo.bVisible = false;
162
0
}
163
164
165
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */