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