15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
35b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
55b190011SAndrew Rist * distributed with this work for additional information
65b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
75b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist * "License"); you may not use this file except in compliance
95b190011SAndrew Rist * with the License. You may obtain a copy of the License at
105b190011SAndrew Rist *
115b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
125b190011SAndrew Rist *
135b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist * software distributed under the License is distributed on an
155b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist * KIND, either express or implied. See the License for the
175b190011SAndrew Rist * specific language governing permissions and limitations
185b190011SAndrew Rist * under the License.
195b190011SAndrew Rist *
205b190011SAndrew Rist *************************************************************/
215b190011SAndrew Rist
225b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "precompiled_sd.hxx"
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include "FullScreenPane.hxx"
27cdf0e10cSrcweir #include "ViewShellBase.hxx"
28cdf0e10cSrcweir #include <cppcanvas/vclfactory.hxx>
29cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
30cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
31cdf0e10cSrcweir #include <vcl/svapp.hxx>
32cdf0e10cSrcweir #include <vcl/dialog.hxx>
33cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
34cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
35cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
36cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
37cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
38cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp>
39cdf0e10cSrcweir
40cdf0e10cSrcweir using namespace ::com::sun::star;
41cdf0e10cSrcweir using namespace ::com::sun::star::uno;
42cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
43cdf0e10cSrcweir using ::rtl::OUString;
44cdf0e10cSrcweir
45cdf0e10cSrcweir #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
46cdf0e10cSrcweir
47cdf0e10cSrcweir namespace sd { namespace framework {
48cdf0e10cSrcweir
FullScreenPane(const Reference<XComponentContext> & rxComponentContext,const Reference<XResourceId> & rxPaneId,const::Window * pViewShellWindow)49cdf0e10cSrcweir FullScreenPane::FullScreenPane (
50cdf0e10cSrcweir const Reference<XComponentContext>& rxComponentContext,
51cdf0e10cSrcweir const Reference<XResourceId>& rxPaneId,
52cdf0e10cSrcweir const ::Window* pViewShellWindow)
53cdf0e10cSrcweir : FrameWindowPane(rxPaneId,NULL),
54cdf0e10cSrcweir mxComponentContext(rxComponentContext),
55cdf0e10cSrcweir mpWorkWindow(NULL)
56cdf0e10cSrcweir {
57cdf0e10cSrcweir ::Window* pParent = NULL;
58cdf0e10cSrcweir mpWorkWindow.reset(new WorkWindow(
59cdf0e10cSrcweir pParent,
60cdf0e10cSrcweir 0)); // For debugging (non-fullscreen) use WB_BORDER | WB_MOVEABLE | WB_SIZEABLE));
61cdf0e10cSrcweir
62cdf0e10cSrcweir if ( ! rxPaneId.is())
63cdf0e10cSrcweir throw lang::IllegalArgumentException();
64cdf0e10cSrcweir
65cdf0e10cSrcweir sal_Int32 nScreenNumber = 1;
66cdf0e10cSrcweir ExtractArguments(rxPaneId, nScreenNumber);
67cdf0e10cSrcweir
68cdf0e10cSrcweir if (mpWorkWindow.get() == NULL)
69cdf0e10cSrcweir return;
70cdf0e10cSrcweir
71cdf0e10cSrcweir // Create a new top-leve window that is displayed full screen.
72cdf0e10cSrcweir mpWorkWindow->ShowFullScreenMode(sal_True, nScreenNumber);
73cdf0e10cSrcweir // For debugging (non-fullscreen) use mpWorkWindow->SetScreenNumber(nScreenNumber);
74cdf0e10cSrcweir mpWorkWindow->SetMenuBarMode(MENUBAR_MODE_HIDE);
75cdf0e10cSrcweir mpWorkWindow->SetBorderStyle(WINDOW_BORDER_REMOVEBORDER);
76cdf0e10cSrcweir mpWorkWindow->SetBackground(Wallpaper());
77cdf0e10cSrcweir // Don't show the window right now in order to allow the setting of an
78cdf0e10cSrcweir // accessibility object: accessibility objects are typically
79cdf0e10cSrcweir // requested by AT-tools when the window is shown. Chaning it
80cdf0e10cSrcweir // afterwards may or may not work.
81cdf0e10cSrcweir
82cdf0e10cSrcweir // Add resize listener at the work window.
83cdf0e10cSrcweir Link aWindowEventHandler (LINK(this, FullScreenPane, WindowEventHandler));
84cdf0e10cSrcweir mpWorkWindow->AddEventListener(aWindowEventHandler);
85cdf0e10cSrcweir
86cdf0e10cSrcweir // Set title and icon of the new window to those of the current window
87cdf0e10cSrcweir // of the view shell.
88cdf0e10cSrcweir if (pViewShellWindow != NULL)
89cdf0e10cSrcweir {
90cdf0e10cSrcweir const SystemWindow* pSystemWindow = pViewShellWindow->GetSystemWindow();
91cdf0e10cSrcweir mpWorkWindow->SetText(pSystemWindow->GetText());
92cdf0e10cSrcweir mpWorkWindow->SetIcon(pSystemWindow->GetIcon());
93cdf0e10cSrcweir }
94cdf0e10cSrcweir
95cdf0e10cSrcweir // For some reason the VCL canvas can not paint into a WorkWindow.
96cdf0e10cSrcweir // Therefore a child window is created that covers the WorkWindow
97cdf0e10cSrcweir // completely.
98cdf0e10cSrcweir mpWindow = new ::Window(mpWorkWindow.get());
99cdf0e10cSrcweir mpWindow->SetPosSizePixel(Point(0,0), mpWorkWindow->GetSizePixel());
100cdf0e10cSrcweir mpWindow->SetBackground(Wallpaper());
101cdf0e10cSrcweir mxWindow = VCLUnoHelper::GetInterface(mpWindow);
102cdf0e10cSrcweir
103cdf0e10cSrcweir // Create the canvas.
104cdf0e10cSrcweir mxCanvas = CreateCanvas();
105cdf0e10cSrcweir
106cdf0e10cSrcweir mpWindow->GrabFocus();
107cdf0e10cSrcweir }
108cdf0e10cSrcweir
109cdf0e10cSrcweir
110cdf0e10cSrcweir
111cdf0e10cSrcweir
~FullScreenPane(void)112cdf0e10cSrcweir FullScreenPane::~FullScreenPane (void) throw()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir }
115cdf0e10cSrcweir
116cdf0e10cSrcweir
117cdf0e10cSrcweir
118cdf0e10cSrcweir
disposing(void)119cdf0e10cSrcweir void SAL_CALL FullScreenPane::disposing (void)
120cdf0e10cSrcweir {
121cdf0e10cSrcweir // We have created the window pointed to by mpWindow, we delete it.
122cdf0e10cSrcweir if (mpWindow != NULL)
123cdf0e10cSrcweir {
124cdf0e10cSrcweir delete mpWindow;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir if (mpWorkWindow.get() != NULL)
128cdf0e10cSrcweir {
129cdf0e10cSrcweir Link aWindowEventHandler (LINK(this, FullScreenPane, WindowEventHandler));
130cdf0e10cSrcweir mpWorkWindow->RemoveEventListener(aWindowEventHandler);
131cdf0e10cSrcweir mpWorkWindow.reset();
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
134cdf0e10cSrcweir
135cdf0e10cSrcweir FrameWindowPane::disposing();
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
138cdf0e10cSrcweir
139cdf0e10cSrcweir
140cdf0e10cSrcweir
141cdf0e10cSrcweir //----- XPane -----------------------------------------------------------------
142cdf0e10cSrcweir
isVisible(void)143cdf0e10cSrcweir sal_Bool SAL_CALL FullScreenPane::isVisible (void)
144cdf0e10cSrcweir throw (RuntimeException)
145cdf0e10cSrcweir {
146cdf0e10cSrcweir ThrowIfDisposed();
147cdf0e10cSrcweir
148cdf0e10cSrcweir if (mpWindow != NULL)
149cdf0e10cSrcweir return mpWindow->IsReallyVisible();
150cdf0e10cSrcweir else
151cdf0e10cSrcweir return false;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
154cdf0e10cSrcweir
155cdf0e10cSrcweir
156cdf0e10cSrcweir
setVisible(const sal_Bool bIsVisible)157cdf0e10cSrcweir void SAL_CALL FullScreenPane::setVisible (const sal_Bool bIsVisible)
158cdf0e10cSrcweir throw (RuntimeException)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir ThrowIfDisposed();
161cdf0e10cSrcweir
162cdf0e10cSrcweir if (mpWindow != NULL)
163cdf0e10cSrcweir mpWindow->Show(bIsVisible);
164*b862c97cSHerbert Dürr if( bool(mpWorkWindow))
165cdf0e10cSrcweir mpWorkWindow->Show(bIsVisible);
166cdf0e10cSrcweir }
167cdf0e10cSrcweir
168cdf0e10cSrcweir
169cdf0e10cSrcweir
170cdf0e10cSrcweir
getAccessible(void)171cdf0e10cSrcweir Reference<accessibility::XAccessible> SAL_CALL FullScreenPane::getAccessible (void)
172cdf0e10cSrcweir throw (RuntimeException)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir ThrowIfDisposed();
175cdf0e10cSrcweir
176*b862c97cSHerbert Dürr if( bool(mpWorkWindow))
177cdf0e10cSrcweir return mpWorkWindow->GetAccessible(sal_False);
178cdf0e10cSrcweir else
179cdf0e10cSrcweir return NULL;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir
182cdf0e10cSrcweir
183cdf0e10cSrcweir
184cdf0e10cSrcweir
setAccessible(const Reference<accessibility::XAccessible> & rxAccessible)185cdf0e10cSrcweir void SAL_CALL FullScreenPane::setAccessible (
186cdf0e10cSrcweir const Reference<accessibility::XAccessible>& rxAccessible)
187cdf0e10cSrcweir throw (RuntimeException)
188cdf0e10cSrcweir {
189cdf0e10cSrcweir ThrowIfDisposed();
190cdf0e10cSrcweir
191cdf0e10cSrcweir if (mpWindow != NULL)
192cdf0e10cSrcweir {
193cdf0e10cSrcweir Reference<lang::XInitialization> xInitializable (rxAccessible, UNO_QUERY);
194cdf0e10cSrcweir if (xInitializable.is())
195cdf0e10cSrcweir {
196cdf0e10cSrcweir ::Window* pParentWindow = mpWindow->GetParent();
197cdf0e10cSrcweir Reference<accessibility::XAccessible> xAccessibleParent;
198cdf0e10cSrcweir if (pParentWindow != NULL)
199cdf0e10cSrcweir xAccessibleParent = pParentWindow->GetAccessible();
200cdf0e10cSrcweir Sequence<Any> aArguments (1);
201cdf0e10cSrcweir aArguments[0] = Any(xAccessibleParent);
202cdf0e10cSrcweir xInitializable->initialize(aArguments);
203cdf0e10cSrcweir }
204cdf0e10cSrcweir GetWindow()->SetAccessible(rxAccessible);
205cdf0e10cSrcweir }
206cdf0e10cSrcweir }
207cdf0e10cSrcweir
208cdf0e10cSrcweir
209cdf0e10cSrcweir
210cdf0e10cSrcweir
211cdf0e10cSrcweir //-----------------------------------------------------------------------------
212cdf0e10cSrcweir
IMPL_LINK(FullScreenPane,WindowEventHandler,VclWindowEvent *,pEvent)213cdf0e10cSrcweir IMPL_LINK(FullScreenPane, WindowEventHandler, VclWindowEvent*, pEvent)
214cdf0e10cSrcweir {
215cdf0e10cSrcweir switch (pEvent->GetId())
216cdf0e10cSrcweir {
217cdf0e10cSrcweir case VCLEVENT_WINDOW_RESIZE:
218cdf0e10cSrcweir GetWindow()->SetPosPixel(Point(0,0));
219cdf0e10cSrcweir GetWindow()->SetSizePixel(Size(
220cdf0e10cSrcweir mpWorkWindow->GetSizePixel().Width(),
221cdf0e10cSrcweir mpWorkWindow->GetSizePixel().Height()));
222cdf0e10cSrcweir break;
223cdf0e10cSrcweir
224cdf0e10cSrcweir case VCLEVENT_OBJECT_DYING:
225cdf0e10cSrcweir mpWorkWindow.reset();
226cdf0e10cSrcweir break;
227cdf0e10cSrcweir }
228cdf0e10cSrcweir return 1;
229cdf0e10cSrcweir }
230cdf0e10cSrcweir
231cdf0e10cSrcweir
232cdf0e10cSrcweir
233cdf0e10cSrcweir
CreateCanvas(void)234cdf0e10cSrcweir Reference<rendering::XCanvas> FullScreenPane::CreateCanvas (void)
235cdf0e10cSrcweir throw (RuntimeException)
236cdf0e10cSrcweir {
237cdf0e10cSrcweir ::Window* pWindow = VCLUnoHelper::GetWindow(mxWindow);
238cdf0e10cSrcweir if (pWindow != NULL)
239cdf0e10cSrcweir {
240cdf0e10cSrcweir Sequence<Any> aArg (5);
241cdf0e10cSrcweir
242cdf0e10cSrcweir // common: first any is VCL pointer to window (for VCL canvas)
243cdf0e10cSrcweir aArg[0] = makeAny(reinterpret_cast<sal_Int64>(pWindow));
244cdf0e10cSrcweir aArg[1] = Any();
245cdf0e10cSrcweir aArg[2] = makeAny(::com::sun::star::awt::Rectangle());
246cdf0e10cSrcweir aArg[3] = makeAny(sal_False);
247cdf0e10cSrcweir aArg[4] = makeAny(mxWindow);
248cdf0e10cSrcweir
249cdf0e10cSrcweir Reference<lang::XMultiServiceFactory> xFactory (
250cdf0e10cSrcweir mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
251cdf0e10cSrcweir return Reference<rendering::XCanvas>(
252cdf0e10cSrcweir xFactory->createInstanceWithArguments(
253cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.rendering.SpriteCanvas.VCL"),
254cdf0e10cSrcweir aArg),
255cdf0e10cSrcweir UNO_QUERY);
256cdf0e10cSrcweir }
257cdf0e10cSrcweir else
258cdf0e10cSrcweir throw RuntimeException();
259cdf0e10cSrcweir }
260cdf0e10cSrcweir
261cdf0e10cSrcweir
262cdf0e10cSrcweir
263cdf0e10cSrcweir
ExtractArguments(const Reference<XResourceId> & rxPaneId,sal_Int32 & rnScreenNumberReturnValue)264cdf0e10cSrcweir void FullScreenPane::ExtractArguments (
265cdf0e10cSrcweir const Reference<XResourceId>& rxPaneId,
266cdf0e10cSrcweir sal_Int32& rnScreenNumberReturnValue)
267cdf0e10cSrcweir {
268cdf0e10cSrcweir // Extract arguments from the resource URL.
269cdf0e10cSrcweir const util::URL aURL = rxPaneId->getFullResourceURL();
270cdf0e10cSrcweir sal_Int32 nIndex = 0;
271cdf0e10cSrcweir while (nIndex >= 0)
272cdf0e10cSrcweir {
273cdf0e10cSrcweir const OUString aToken = aURL.Arguments.getToken(0, '&', nIndex);
274cdf0e10cSrcweir if (aToken.getLength() > 0)
275cdf0e10cSrcweir {
276cdf0e10cSrcweir // Split at the first '='.
277cdf0e10cSrcweir const sal_Int32 nAssign = aToken.indexOf('=');
278cdf0e10cSrcweir const OUString sKey = aToken.copy(0, nAssign);
279cdf0e10cSrcweir const OUString sValue = aToken.copy(nAssign+1);
280cdf0e10cSrcweir
281cdf0e10cSrcweir if (sKey.compareToAscii("ScreenNumber") == 0)
282cdf0e10cSrcweir {
283cdf0e10cSrcweir rnScreenNumberReturnValue = sValue.toInt32();
284cdf0e10cSrcweir }
285cdf0e10cSrcweir }
286cdf0e10cSrcweir }
287cdf0e10cSrcweir }
288cdf0e10cSrcweir
289cdf0e10cSrcweir
290cdf0e10cSrcweir } } // end of namespace sd::framework
291