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

Generated by: LCOV version 1.10