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

Generated by: LCOV version 1.10