LCOV - code coverage report
Current view: top level - sd/source/ui/framework/factories - FullScreenPane.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 107 0.9 %
Date: 2014-11-03 Functions: 2 14 14.3 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "ViewShellBase.hxx"
      22             : #include <cppcanvas/vclfactory.hxx>
      23             : #include <sfx2/dispatch.hxx>
      24             : #include <vcl/wrkwin.hxx>
      25             : #include <vcl/svapp.hxx>
      26             : #include <vcl/dialog.hxx>
      27             : #include <toolkit/helper/vclunohelper.hxx>
      28             : #include <com/sun/star/beans/XPropertySet.hpp>
      29             : #include <com/sun/star/frame/XLayoutManager.hpp>
      30             : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      31             : #include <com/sun/star/lang/XInitialization.hpp>
      32             : #include <com/sun/star/util/URL.hpp>
      33             : 
      34             : using namespace ::com::sun::star;
      35             : using namespace ::com::sun::star::uno;
      36             : using namespace ::com::sun::star::drawing::framework;
      37             : 
      38             : namespace sd { namespace framework {
      39             : 
      40           0 : FullScreenPane::FullScreenPane (
      41             :     const Reference<XComponentContext>& rxComponentContext,
      42             :     const Reference<XResourceId>& rxPaneId,
      43             :     const vcl::Window* pViewShellWindow)
      44             :     : FrameWindowPane(rxPaneId,NULL),
      45             :       mxComponentContext(rxComponentContext),
      46           0 :       mpWorkWindow(NULL)
      47             : {
      48           0 :     vcl::Window* pParent = NULL;
      49             :     mpWorkWindow.reset(new WorkWindow(
      50             :         pParent,
      51           0 :         0));  // For debugging (non-fullscreen) use WB_BORDER | WB_MOVEABLE | WB_SIZEABLE));
      52             : 
      53           0 :     if ( ! rxPaneId.is())
      54           0 :         throw lang::IllegalArgumentException();
      55             : 
      56           0 :     sal_Int32 nScreenNumber = 1;
      57           0 :     ExtractArguments(rxPaneId, nScreenNumber);
      58             : 
      59           0 :     if (mpWorkWindow.get() == NULL)
      60           0 :         return;
      61             : 
      62             :     // Create a new top-leve window that is displayed full screen.
      63           0 :     mpWorkWindow->ShowFullScreenMode(true, nScreenNumber);
      64             :     // For debugging (non-fullscreen) use mpWorkWindow->SetScreenNumber(nScreenNumber);
      65           0 :     mpWorkWindow->SetMenuBarMode(MENUBAR_MODE_HIDE);
      66           0 :     mpWorkWindow->SetBorderStyle(WindowBorderStyle::REMOVEBORDER);
      67           0 :     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.  Chaning it
      71             :     // afterwards may or may not work.
      72             : 
      73             :     // Add resize listener at the work window.
      74           0 :     Link aWindowEventHandler (LINK(this, FullScreenPane, WindowEventHandler));
      75           0 :     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           0 :     if (pViewShellWindow != NULL)
      80             :     {
      81           0 :         const SystemWindow* pSystemWindow = pViewShellWindow->GetSystemWindow();
      82           0 :         mpWorkWindow->SetText(pSystemWindow->GetText());
      83           0 :         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.
      89           0 :     mpWindow = new vcl::Window(mpWorkWindow.get());
      90           0 :     mpWindow->SetPosSizePixel(Point(0,0), mpWorkWindow->GetSizePixel());
      91           0 :     mpWindow->SetBackground(Wallpaper());
      92           0 :     mxWindow = VCLUnoHelper::GetInterface(mpWindow);
      93             : 
      94             :     // Create the canvas.
      95           0 :     mxCanvas = CreateCanvas();
      96             : 
      97           0 :     mpWindow->GrabFocus();
      98             : }
      99             : 
     100           0 : FullScreenPane::~FullScreenPane (void) throw()
     101             : {
     102           0 : }
     103             : 
     104           0 : void SAL_CALL FullScreenPane::disposing (void)
     105             : {
     106             :     // We have created the window pointed to by mpWindow, we delete it.
     107           0 :     if (mpWindow != NULL)
     108             :     {
     109           0 :         delete mpWindow;
     110             :     }
     111             : 
     112           0 :     if (mpWorkWindow.get() != NULL)
     113             :     {
     114           0 :         Link aWindowEventHandler (LINK(this, FullScreenPane, WindowEventHandler));
     115           0 :         mpWorkWindow->RemoveEventListener(aWindowEventHandler);
     116           0 :         mpWorkWindow.reset();
     117             :     }
     118             : 
     119           0 :     FrameWindowPane::disposing();
     120           0 : }
     121             : 
     122             : //----- XPane -----------------------------------------------------------------
     123             : 
     124           0 : sal_Bool SAL_CALL FullScreenPane::isVisible (void)
     125             :     throw (RuntimeException, std::exception)
     126             : {
     127           0 :     ThrowIfDisposed();
     128             : 
     129           0 :     if (mpWindow != NULL)
     130           0 :         return mpWindow->IsReallyVisible();
     131             :     else
     132           0 :         return false;
     133             : }
     134             : 
     135           0 : void SAL_CALL FullScreenPane::setVisible (const sal_Bool bIsVisible)
     136             :     throw (RuntimeException, std::exception)
     137             : {
     138           0 :     ThrowIfDisposed();
     139             : 
     140           0 :     if (mpWindow != NULL)
     141           0 :         mpWindow->Show(bIsVisible);
     142           0 :     if (mpWorkWindow != 0)
     143           0 :         mpWorkWindow->Show(bIsVisible);
     144           0 : }
     145             : 
     146           0 : Reference<css::accessibility::XAccessible> SAL_CALL FullScreenPane::getAccessible (void)
     147             :     throw (RuntimeException, std::exception)
     148             : {
     149           0 :     ThrowIfDisposed();
     150             : 
     151           0 :     if (mpWorkWindow != 0)
     152           0 :         return mpWorkWindow->GetAccessible(false);
     153             :     else
     154           0 :         return NULL;
     155             : }
     156             : 
     157           0 : void SAL_CALL FullScreenPane::setAccessible (
     158             :     const Reference<css::accessibility::XAccessible>& rxAccessible)
     159             :     throw (RuntimeException, std::exception)
     160             : {
     161           0 :     ThrowIfDisposed();
     162             : 
     163           0 :     if (mpWindow != NULL)
     164             :     {
     165           0 :         Reference<lang::XInitialization> xInitializable (rxAccessible, UNO_QUERY);
     166           0 :         if (xInitializable.is())
     167             :         {
     168           0 :             vcl::Window* pParentWindow = mpWindow->GetParent();
     169           0 :             Reference<css::accessibility::XAccessible> xAccessibleParent;
     170           0 :             if (pParentWindow != NULL)
     171           0 :                 xAccessibleParent = pParentWindow->GetAccessible();
     172           0 :             Sequence<Any> aArguments (1);
     173           0 :             aArguments[0] = Any(xAccessibleParent);
     174           0 :             xInitializable->initialize(aArguments);
     175             :         }
     176           0 :         GetWindow()->SetAccessible(rxAccessible);
     177             :     }
     178           0 : }
     179             : 
     180           0 : IMPL_LINK(FullScreenPane, WindowEventHandler, VclWindowEvent*, pEvent)
     181             : {
     182           0 :     switch (pEvent->GetId())
     183             :     {
     184             :         case VCLEVENT_WINDOW_RESIZE:
     185           0 :             GetWindow()->SetPosPixel(Point(0,0));
     186           0 :             GetWindow()->SetSizePixel(Size(
     187           0 :                 mpWorkWindow->GetSizePixel().Width(),
     188           0 :                 mpWorkWindow->GetSizePixel().Height()));
     189           0 :             break;
     190             : 
     191             :         case VCLEVENT_OBJECT_DYING:
     192           0 :             mpWorkWindow.reset();
     193           0 :             break;
     194             :     }
     195           0 :     return 1;
     196             : }
     197             : 
     198           0 : Reference<rendering::XCanvas> FullScreenPane::CreateCanvas (void)
     199             :     throw (RuntimeException)
     200             : {
     201           0 :     vcl::Window* pWindow = VCLUnoHelper::GetWindow(mxWindow);
     202           0 :     if (pWindow != NULL)
     203             :     {
     204           0 :         Sequence<Any> aArg (5);
     205             : 
     206             :         // common: first any is VCL pointer to window (for VCL canvas)
     207           0 :         aArg[0] = makeAny(reinterpret_cast<sal_Int64>(pWindow));
     208           0 :         aArg[1] = Any();
     209           0 :         aArg[2] = makeAny(::com::sun::star::awt::Rectangle());
     210           0 :         aArg[3] = makeAny(sal_False);
     211           0 :         aArg[4] = makeAny(mxWindow);
     212             : 
     213             :         Reference<lang::XMultiServiceFactory> xFactory (
     214           0 :             mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
     215             :         return Reference<rendering::XCanvas>(
     216           0 :             xFactory->createInstanceWithArguments("com.sun.star.rendering.SpriteCanvas.VCL",
     217           0 :                 aArg),
     218           0 :             UNO_QUERY);
     219             :     }
     220             :     else
     221           0 :         throw RuntimeException();
     222             : }
     223             : 
     224           0 : void FullScreenPane::ExtractArguments (
     225             :     const Reference<XResourceId>& rxPaneId,
     226             :     sal_Int32& rnScreenNumberReturnValue)
     227             : {
     228             :     // Extract arguments from the resource URL.
     229           0 :     const util::URL aURL = rxPaneId->getFullResourceURL();
     230           0 :     sal_Int32 nIndex = 0;
     231           0 :     while (nIndex >= 0)
     232             :     {
     233           0 :         const OUString aToken = aURL.Arguments.getToken(0, '&', nIndex);
     234           0 :         if (!aToken.isEmpty())
     235             :         {
     236             :             // Split at the first '='.
     237           0 :             const sal_Int32 nAssign = aToken.indexOf('=');
     238           0 :             const OUString sKey = aToken.copy(0, nAssign);
     239           0 :             const OUString sValue = aToken.copy(nAssign+1);
     240             : 
     241           0 :             if (sKey.equalsAscii("ScreenNumber"))
     242             :             {
     243           0 :                 rnScreenNumberReturnValue = sValue.toInt32();
     244           0 :             }
     245             :         }
     246           0 :     }
     247           0 : }
     248             : 
     249         114 : } } // end of namespace sd::framework
     250             : 
     251             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10