Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/view/presvish.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/lang/XMultiServiceFactory.hpp>
21
#include <com/sun/star/beans/XPropertySet.hpp>
22
23
#include <PresentationViewShell.hxx>
24
#include <sfx2/dispatch.hxx>
25
#include <sfx2/objface.hxx>
26
#include <sfx2/viewfrm.hxx>
27
#include <svx/svxids.hrc>
28
#include <svx/ruler.hxx>
29
#include <FrameView.hxx>
30
#include <DrawDocShell.hxx>
31
#include <slideshow.hxx>
32
#include <app.hrc>
33
#include <ViewShellBase.hxx>
34
35
#include <fupoor.hxx>
36
#include <Window.hxx>
37
38
#define ShellClass_PresentationViewShell
39
using namespace sd;
40
#include <sdslots.hxx>
41
42
namespace sd {
43
44
SFX_IMPL_INTERFACE(PresentationViewShell, DrawViewShell)
45
46
void PresentationViewShell::InitInterface_Impl()
47
5
{
48
5
    GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_TOOLS, SfxVisibilityFlags::Standard | SfxVisibilityFlags::FullScreen | SfxVisibilityFlags::Server,
49
5
                                            ToolbarId::Draw_Toolbox_Sd);
50
5
    GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION, SfxVisibilityFlags::Standard | SfxVisibilityFlags::Client | SfxVisibilityFlags::Viewer | SfxVisibilityFlags::ReadonlyDoc,
51
5
                                            ToolbarId::Draw_Viewer_Toolbox);
52
5
    GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OPTIONS, SfxVisibilityFlags::Standard | SfxVisibilityFlags::Server,
53
5
                                            ToolbarId::Draw_Options_Toolbox);
54
5
    GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_COMMONTASK, SfxVisibilityFlags::Standard | SfxVisibilityFlags::Server,
55
5
                                            ToolbarId::Draw_CommonTask_Toolbox);
56
5
}
57
58
59
PresentationViewShell::PresentationViewShell( ViewShellBase& rViewShellBase, vcl::Window* pParentWindow, FrameView* pFrameView)
60
0
    : DrawViewShell(rViewShellBase, pParentWindow, PageKind::Standard, pFrameView)
61
0
    , mnAbortSlideShowEvent(nullptr)
62
0
{
63
0
    if( GetDocSh() && GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
64
0
        maOldVisArea = GetDocSh()->GetVisArea( ASPECT_CONTENT );
65
0
    meShellType = ST_PRESENTATION;
66
0
}
67
68
PresentationViewShell::~PresentationViewShell()
69
0
{
70
0
    if (mnAbortSlideShowEvent)
71
0
        Application::RemoveUserEvent(mnAbortSlideShowEvent);
72
73
0
    if( GetDocSh() && GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED && !maOldVisArea.IsEmpty() )
74
0
        GetDocSh()->SetVisArea( maOldVisArea );
75
0
}
76
77
void PresentationViewShell::FinishInitialization( FrameView* pFrameView )
78
0
{
79
0
    DrawViewShell::Init(true);
80
81
    // Use the frame view that comes form the view shell that initiated our
82
    // creation.
83
0
    if (pFrameView != nullptr)
84
0
    {
85
0
        GetFrameView()->Disconnect();
86
0
        SetFrameView (pFrameView);
87
0
        pFrameView->Connect();
88
0
    }
89
0
    SetRuler(false);
90
0
    WriteFrameViewData();
91
92
0
    GetActiveWindow()->GrabFocus();
93
0
}
94
95
VclPtr<SvxRuler> PresentationViewShell::CreateHRuler(::sd::Window*)
96
0
{
97
0
    return nullptr;
98
0
}
99
100
VclPtr<SvxRuler> PresentationViewShell::CreateVRuler(::sd::Window*)
101
0
{
102
0
    return nullptr;
103
0
}
104
105
IMPL_LINK_NOARG(PresentationViewShell, AbortSlideShowHdl, void*, void)
106
0
{
107
0
    mnAbortSlideShowEvent = nullptr;
108
0
    rtl::Reference<SlideShow> xSlideShow(SlideShow::GetSlideShow(GetViewShellBase()));
109
0
    if (xSlideShow.is())
110
0
        xSlideShow->end();
111
0
}
112
113
void PresentationViewShell::Activate( bool bIsMDIActivate )
114
0
{
115
0
    DrawViewShell::Activate( bIsMDIActivate );
116
117
0
    if( bIsMDIActivate )
118
0
    {
119
0
        SfxBoolItem aItem( SID_NAVIGATOR_INIT, true );
120
121
0
        GetViewFrame()->GetDispatcher()->ExecuteList(SID_NAVIGATOR_INIT,
122
0
                SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem });
123
124
0
        rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
125
0
        if( xSlideShow.is() )
126
0
        {
127
0
            bool bSuccess = xSlideShow->activate(GetViewShellBase());
128
0
            if (!bSuccess)
129
0
            {
130
                /* tdf#64711 PresentationViewShell is deleted by 'end' due to end closing
131
                   the object shell. So if we call xSlideShow->end during Activate there are
132
                   a lot of places in the call stack of Activate which understandable don't
133
                   expect this ViewShell to be deleted during use. Defer to the next event
134
                   loop the abort of the slideshow
135
                */
136
0
                if (!mnAbortSlideShowEvent)
137
0
                    mnAbortSlideShowEvent = Application::PostUserEvent(LINK(this, PresentationViewShell, AbortSlideShowHdl));
138
0
            }
139
0
        }
140
141
0
        if( HasCurrentFunction() )
142
0
            GetCurrentFunction()->Activate();
143
144
0
        ReadFrameViewData(mpFrameView);
145
0
    }
146
147
0
    GetDocSh()->Connect( this );
148
0
}
149
150
void PresentationViewShell::Paint( const ::tools::Rectangle& /*rRect*/, ::sd::Window* )
151
0
{
152
0
    rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
153
0
    if( xSlideShow.is() )
154
0
        xSlideShow->paint();
155
0
}
156
157
void PresentationViewShell::Resize()
158
0
{
159
0
    ViewShell::Resize(); // do not call DrawViewShell here!
160
161
0
    rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
162
0
    if( xSlideshow.is() )
163
0
        xSlideshow->resize(maViewSize);
164
0
}
165
166
} // end of namespace sd
167
168
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */