LCOV - code coverage report
Current view: top level - sd/source/ui/framework/factories - FullScreenPane.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 106 0.9 %
Date: 2015-06-13 12:38:46 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(VclPtr<WorkWindow>::Create(
      50             : 
      51             :         pParent,
      52           0 :         0));  // For debugging (non-fullscreen) use WB_BORDER | WB_MOVEABLE | WB_SIZEABLE));
      53             : 
      54           0 :     if ( ! rxPaneId.is())
      55           0 :         throw lang::IllegalArgumentException();
      56             : 
      57           0 :     sal_Int32 nScreenNumber = 1;
      58           0 :     ExtractArguments(rxPaneId, nScreenNumber);
      59             : 
      60           0 :     if (mpWorkWindow.get() == NULL)
      61           0 :         return;
      62             : 
      63             :     // Create a new top-leve window that is displayed full screen.
      64           0 :     mpWorkWindow->ShowFullScreenMode(true, nScreenNumber);
      65             :     // For debugging (non-fullscreen) use mpWorkWindow->SetScreenNumber(nScreenNumber);
      66           0 :     mpWorkWindow->SetMenuBarMode(MenuBarMode::Hide);
      67           0 :     mpWorkWindow->SetBorderStyle(WindowBorderStyle::REMOVEBORDER);
      68           0 :     mpWorkWindow->SetBackground(Wallpaper());
      69             :     // Don't show the window right now in order to allow the setting of an
      70             :     // accessibility object: accessibility objects are typically
      71             :     // requested by AT-tools when the window is shown.  Chaning it
      72             :     // afterwards may or may not work.
      73             : 
      74             :     // Add resize listener at the work window.
      75           0 :     Link<> aWindowEventHandler (LINK(this, FullScreenPane, WindowEventHandler));
      76           0 :     mpWorkWindow->AddEventListener(aWindowEventHandler);
      77             : 
      78             :     // Set title and icon of the new window to those of the current window
      79             :     // of the view shell.
      80           0 :     if (pViewShellWindow != NULL)
      81             :     {
      82           0 :         const SystemWindow* pSystemWindow = pViewShellWindow->GetSystemWindow();
      83           0 :         mpWorkWindow->SetText(pSystemWindow->GetText());
      84           0 :         mpWorkWindow->SetIcon(pSystemWindow->GetIcon());
      85             :     }
      86             : 
      87             :     // For some reason the VCL canvas can not paint into a WorkWindow.
      88             :     // Therefore a child window is created that covers the WorkWindow
      89             :     // completely.
      90           0 :     mpWindow = VclPtr<vcl::Window>::Create(mpWorkWindow.get());
      91           0 :     mpWindow->SetPosSizePixel(Point(0,0), mpWorkWindow->GetSizePixel());
      92           0 :     mpWindow->SetBackground(Wallpaper());
      93           0 :     mxWindow = VCLUnoHelper::GetInterface(mpWindow);
      94             : 
      95             :     // Create the canvas.
      96           0 :     mxCanvas = CreateCanvas();
      97             : 
      98           0 :     mpWindow->GrabFocus();
      99             : }
     100             : 
     101           0 : FullScreenPane::~FullScreenPane() throw()
     102             : {
     103           0 : }
     104             : 
     105           0 : void SAL_CALL FullScreenPane::disposing()
     106             : {
     107           0 :     mpWindow.disposeAndClear();
     108             : 
     109           0 :     if (mpWorkWindow.get() != NULL)
     110             :     {
     111           0 :         Link<> aWindowEventHandler (LINK(this, FullScreenPane, WindowEventHandler));
     112           0 :         mpWorkWindow->RemoveEventListener(aWindowEventHandler);
     113           0 :         mpWorkWindow.reset();
     114             :     }
     115             : 
     116           0 :     FrameWindowPane::disposing();
     117           0 : }
     118             : 
     119             : //----- XPane -----------------------------------------------------------------
     120             : 
     121           0 : sal_Bool SAL_CALL FullScreenPane::isVisible()
     122             :     throw (RuntimeException, std::exception)
     123             : {
     124           0 :     ThrowIfDisposed();
     125             : 
     126           0 :     if (mpWindow != nullptr)
     127           0 :         return mpWindow->IsReallyVisible();
     128             :     else
     129           0 :         return false;
     130             : }
     131             : 
     132           0 : void SAL_CALL FullScreenPane::setVisible (const sal_Bool bIsVisible)
     133             :     throw (RuntimeException, std::exception)
     134             : {
     135           0 :     ThrowIfDisposed();
     136             : 
     137           0 :     if (mpWindow != nullptr)
     138           0 :         mpWindow->Show(bIsVisible);
     139           0 :     if (mpWorkWindow != nullptr)
     140           0 :         mpWorkWindow->Show(bIsVisible);
     141           0 : }
     142             : 
     143           0 : Reference<css::accessibility::XAccessible> SAL_CALL FullScreenPane::getAccessible()
     144             :     throw (RuntimeException, std::exception)
     145             : {
     146           0 :     ThrowIfDisposed();
     147             : 
     148           0 :     if (mpWorkWindow != nullptr)
     149           0 :         return mpWorkWindow->GetAccessible(false);
     150             :     else
     151           0 :         return NULL;
     152             : }
     153             : 
     154           0 : void SAL_CALL FullScreenPane::setAccessible (
     155             :     const Reference<css::accessibility::XAccessible>& rxAccessible)
     156             :     throw (RuntimeException, std::exception)
     157             : {
     158           0 :     ThrowIfDisposed();
     159             : 
     160           0 :     if (mpWindow != nullptr)
     161             :     {
     162           0 :         Reference<lang::XInitialization> xInitializable (rxAccessible, UNO_QUERY);
     163           0 :         if (xInitializable.is())
     164             :         {
     165           0 :             vcl::Window* pParentWindow = mpWindow->GetParent();
     166           0 :             Reference<css::accessibility::XAccessible> xAccessibleParent;
     167           0 :             if (pParentWindow != NULL)
     168           0 :                 xAccessibleParent = pParentWindow->GetAccessible();
     169           0 :             Sequence<Any> aArguments (1);
     170           0 :             aArguments[0] = Any(xAccessibleParent);
     171           0 :             xInitializable->initialize(aArguments);
     172             :         }
     173           0 :         GetWindow()->SetAccessible(rxAccessible);
     174             :     }
     175           0 : }
     176             : 
     177           0 : IMPL_LINK(FullScreenPane, WindowEventHandler, VclWindowEvent*, pEvent)
     178             : {
     179           0 :     switch (pEvent->GetId())
     180             :     {
     181             :         case VCLEVENT_WINDOW_RESIZE:
     182           0 :             GetWindow()->SetPosPixel(Point(0,0));
     183           0 :             GetWindow()->SetSizePixel(Size(
     184           0 :                 mpWorkWindow->GetSizePixel().Width(),
     185           0 :                 mpWorkWindow->GetSizePixel().Height()));
     186           0 :             break;
     187             : 
     188             :         case VCLEVENT_OBJECT_DYING:
     189           0 :             mpWorkWindow.reset();
     190           0 :             break;
     191             :     }
     192           0 :     return 1;
     193             : }
     194             : 
     195           0 : Reference<rendering::XCanvas> FullScreenPane::CreateCanvas()
     196             :     throw (RuntimeException)
     197             : {
     198           0 :     vcl::Window* pWindow = VCLUnoHelper::GetWindow(mxWindow);
     199           0 :     if (pWindow != NULL)
     200             :     {
     201           0 :         Sequence<Any> aArg (5);
     202             : 
     203             :         // common: first any is VCL pointer to window (for VCL canvas)
     204           0 :         aArg[0] = makeAny(reinterpret_cast<sal_Int64>(pWindow));
     205           0 :         aArg[1] = Any();
     206           0 :         aArg[2] = makeAny(::com::sun::star::awt::Rectangle());
     207           0 :         aArg[3] = makeAny(sal_False);
     208           0 :         aArg[4] = makeAny(mxWindow);
     209             : 
     210             :         Reference<lang::XMultiServiceFactory> xFactory (
     211           0 :             mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
     212             :         return Reference<rendering::XCanvas>(
     213           0 :             xFactory->createInstanceWithArguments("com.sun.star.rendering.SpriteCanvas.VCL",
     214           0 :                 aArg),
     215           0 :             UNO_QUERY);
     216             :     }
     217             :     else
     218           0 :         throw RuntimeException();
     219             : }
     220             : 
     221           0 : void FullScreenPane::ExtractArguments (
     222             :     const Reference<XResourceId>& rxPaneId,
     223             :     sal_Int32& rnScreenNumberReturnValue)
     224             : {
     225             :     // Extract arguments from the resource URL.
     226           0 :     const util::URL aURL = rxPaneId->getFullResourceURL();
     227           0 :     sal_Int32 nIndex = 0;
     228           0 :     while (nIndex >= 0)
     229             :     {
     230           0 :         const OUString aToken = aURL.Arguments.getToken(0, '&', nIndex);
     231           0 :         if (!aToken.isEmpty())
     232             :         {
     233             :             // Split at the first '='.
     234           0 :             const sal_Int32 nAssign = aToken.indexOf('=');
     235           0 :             const OUString sKey = aToken.copy(0, nAssign);
     236           0 :             const OUString sValue = aToken.copy(nAssign+1);
     237             : 
     238           0 :             if (sKey == "ScreenNumber")
     239             :             {
     240           0 :                 rnScreenNumberReturnValue = sValue.toInt32();
     241           0 :             }
     242             :         }
     243           0 :     }
     244           0 : }
     245             : 
     246          66 : } } // end of namespace sd::framework
     247             : 
     248             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11