LibreOffice Module sd (master) 1
FullScreenPane.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 "FullScreenPane.hxx"
21#include <vcl/vclevent.hxx>
22#include <vcl/wrkwin.hxx>
23#include <o3tl/string_view.hxx>
25#include <com/sun/star/lang/IllegalArgumentException.hpp>
26#include <com/sun/star/lang/XInitialization.hpp>
27#include <com/sun/star/util/URL.hpp>
28#include <com/sun/star/uno/XComponentContext.hpp>
29
30using namespace ::com::sun::star;
31using namespace ::com::sun::star::uno;
33
34namespace sd::framework {
35
37 const Reference<XComponentContext>& rxComponentContext,
38 const Reference<XResourceId>& rxPaneId,
39 const vcl::Window* pViewShellWindow)
40 : FrameWindowPane(rxPaneId,nullptr),
41 mxComponentContext(rxComponentContext)
42{
43 sal_Int32 nScreenNumber = 1;
44 bool bFullScreen = true;
45 ExtractArguments(rxPaneId, nScreenNumber, bFullScreen);
46
47 vcl::Window* pParent = nullptr;
48 WinBits nStyle = bFullScreen ? 0 : (WB_BORDER | WB_MOVEABLE | WB_SIZEABLE);
49
51 pParent,
52 nStyle)); // For debugging (non-fullscreen) use WB_BORDER | WB_MOVEABLE | WB_SIZEABLE));
53
54 if ( ! rxPaneId.is())
55 throw lang::IllegalArgumentException();
56
57 if (!mpWorkWindow)
58 return;
59
60 // Create a new top-level window that is displayed full screen.
61 if (bFullScreen)
62 mpWorkWindow->ShowFullScreenMode(bFullScreen, nScreenNumber);
63
64 // For debugging (non-fullscreen) use mpWorkWindow->SetScreenNumber(nScreenNumber);
65 mpWorkWindow->SetMenuBarMode(MenuBarMode::Hide);
66 mpWorkWindow->SetBorderStyle(WindowBorderStyle::REMOVEBORDER);
67 mpWorkWindow->SetBackground(Wallpaper());
68 // Don't show the window right now in order to allow the setting of an
69 // accessibility object: accessibility objects are typically
70 // requested by AT-tools when the window is shown. Chaining it
71 // afterwards may or may not work.
72
73 // Add resize listener at the work window.
74 Link<VclWindowEvent&,void> aWindowEventHandler (LINK(this, FullScreenPane, WindowEventHandler));
75 mpWorkWindow->AddEventListener(aWindowEventHandler);
76
77 // Set title and icon of the new window to those of the current window
78 // of the view shell.
79 if (pViewShellWindow != nullptr)
80 {
81 const SystemWindow* pSystemWindow = pViewShellWindow->GetSystemWindow();
82 mpWorkWindow->SetText(pSystemWindow->GetText());
83 mpWorkWindow->SetIcon(pSystemWindow->GetIcon());
84 }
85
86 // For some reason the VCL canvas can not paint into a WorkWindow.
87 // Therefore a child window is created that covers the WorkWindow
88 // completely.
90 mpWindow->SetPosSizePixel(Point(0,0), mpWorkWindow->GetSizePixel());
91 mpWindow->SetBackground(Wallpaper());
93
94 // Create the canvas.
96
97 mpWindow->GrabFocus();
98}
99
101{
102}
103
105{
107
108 if (mpWorkWindow)
109 {
110 Link<VclWindowEvent&,void> aWindowEventHandler (LINK(this, FullScreenPane, WindowEventHandler));
111 mpWorkWindow->RemoveEventListener(aWindowEventHandler);
113 }
114
116}
117
118//----- XPane -----------------------------------------------------------------
119
121{
123
124 if (mpWindow != nullptr)
125 return mpWindow->IsReallyVisible();
126 else
127 return false;
128}
129
130void SAL_CALL FullScreenPane::setVisible (const sal_Bool bIsVisible)
131{
133
134 if (mpWindow != nullptr)
135 mpWindow->Show(bIsVisible);
136 if (mpWorkWindow != nullptr)
137 mpWorkWindow->Show(bIsVisible);
138}
139
140Reference<css::accessibility::XAccessible> SAL_CALL FullScreenPane::getAccessible()
141{
143
144 if (mpWorkWindow != nullptr)
145 return mpWorkWindow->GetAccessible(false);
146 else
147 return nullptr;
148}
149
151 const Reference<css::accessibility::XAccessible>& rxAccessible)
152{
154
155 if (mpWindow == nullptr)
156 return;
157
158 Reference<lang::XInitialization> xInitializable (rxAccessible, UNO_QUERY);
159 if (xInitializable.is())
160 {
161 vcl::Window* pParentWindow = mpWindow->GetParent();
162 Reference<css::accessibility::XAccessible> xAccessibleParent;
163 if (pParentWindow != nullptr)
164 xAccessibleParent = pParentWindow->GetAccessible();
165 Sequence<Any> aArguments{ Any(xAccessibleParent) };
166 xInitializable->initialize(aArguments);
167 }
168 GetWindow()->SetAccessible(rxAccessible);
169}
170
171IMPL_LINK(FullScreenPane, WindowEventHandler, VclWindowEvent&, rEvent, void)
172{
173 switch (rEvent.GetId())
174 {
175 case VclEventId::WindowResize:
176 GetWindow()->SetPosPixel(Point(0,0));
177 GetWindow()->SetSizePixel(Size(
178 mpWorkWindow->GetSizePixel().Width(),
179 mpWorkWindow->GetSizePixel().Height()));
180 break;
181
182 case VclEventId::ObjectDying:
183 mpWorkWindow.disposeAndClear();
184 break;
185
186 default: break;
187 }
188}
189
190Reference<rendering::XCanvas> FullScreenPane::CreateCanvas()
191{
193 if (!pWindow)
194 throw RuntimeException();
195
196 Sequence<Any> aArg{ // common: first any is VCL pointer to window (for VCL canvas)
197 Any(reinterpret_cast<sal_Int64>(pWindow.get())),
198 Any(css::awt::Rectangle()),
199 Any(false),
201 };
202
203 Reference<lang::XMultiServiceFactory> xFactory (
204 mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
205 return Reference<rendering::XCanvas>(
206 xFactory->createInstanceWithArguments("com.sun.star.rendering.SpriteCanvas.VCL",
207 aArg),
208 UNO_QUERY);
209}
210
212 const Reference<XResourceId>& rxPaneId,
213 sal_Int32& rnScreenNumberReturnValue,
214 bool& rbFullScreen)
215{
216 // Extract arguments from the resource URL.
217 const util::URL aURL = rxPaneId->getFullResourceURL();
218 for (sal_Int32 nIndex{ 0 }; nIndex >= 0; )
219 {
220 const std::u16string_view aToken = o3tl::getToken(aURL.Arguments, 0, '&', nIndex);
221 std::u16string_view sValue;
222 if (o3tl::starts_with(aToken, u"ScreenNumber=", &sValue))
223 {
224 rnScreenNumberReturnValue = o3tl::toInt32(sValue);
225 }
226 if (o3tl::starts_with(aToken, u"FullScreen=", &sValue))
227 {
228 rbFullScreen = o3tl::equalsAscii(sValue, "true");
229 }
230 }
231}
232
233} // end of namespace sd::framework
234
235/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
virtual OUString GetText() const override
sal_uInt16 GetIcon() const
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
void disposeAndClear()
void reset(reference_type *pBody)
reference_type * get() const
static VclPtr< reference_type > Create(Arg &&... arg)
This subclass is not necessary anymore.
The full screen pane creates a pane that covers the complete application window, i....
static void ExtractArguments(const css::uno::Reference< css::drawing::framework::XResourceId > &rxPaneId, sal_Int32 &rnScreenNumberReturnValue, bool &rbFullScreen)
FullScreenPane(const css::uno::Reference< css::uno::XComponentContext > &rxComponentContext, const css::uno::Reference< css::drawing::framework::XResourceId > &rxPaneId, const vcl::Window *pViewShellWindow)
Create a new full screen pane.
virtual ~FullScreenPane() noexcept override
virtual css::uno::Reference< css::rendering::XCanvas > CreateCanvas() override
Override this method, not getCanvas(), when you want to provide a different canvas.
virtual void SAL_CALL setVisible(sal_Bool bIsVisible) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessible() override
virtual void SAL_CALL disposing() override
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
VclPtr< WorkWindow > mpWorkWindow
virtual sal_Bool SAL_CALL isVisible() override
virtual void SAL_CALL setAccessible(const css::uno::Reference< css::accessibility::XAccessible > &rxAccessible) override
VclPtr< vcl::Window > mpWindow
Definition: Pane.hxx:110
css::uno::Reference< css::rendering::XCanvas > mxCanvas
Definition: Pane.hxx:112
virtual void SAL_CALL disposing() override
Definition: Pane.cxx:50
css::uno::Reference< css::awt::XWindow > mxWindow
Definition: Pane.hxx:111
virtual vcl::Window * GetWindow()
This method is typically used to obtain a Window pointer from an XPane object.
Definition: Pane.cxx:56
void ThrowIfDisposed() const
Throw DisposedException when the object has already been disposed or is currently being disposed.
Definition: Pane.cxx:154
void SetAccessible(const css::uno::Reference< css::accessibility::XAccessible > &)
SystemWindow * GetSystemWindow() const
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
URL aURL
float u
Reference< XSingleServiceFactory > xFactory
Sequence< PropertyValue > aArguments
sal_Int32 nIndex
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
bool equalsAscii(std::u16string_view s1, std::string_view s2)
IMPL_LINK(FullScreenPane, WindowEventHandler, VclWindowEvent &, rEvent, void)
unsigned char sal_Bool
sal_Int64 WinBits
WinBits const WB_MOVEABLE
WinBits const WB_SIZEABLE
WinBits const WB_BORDER