LCOV - code coverage report
Current view: top level - sd/source/ui/framework/factories - FullScreenPane.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 106 0.0 %
Date: 2012-08-25 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 177 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "FullScreenPane.hxx"
      31                 :            : #include "ViewShellBase.hxx"
      32                 :            : #include <cppcanvas/vclfactory.hxx>
      33                 :            : #include <sfx2/dispatch.hxx>
      34                 :            : #include <vcl/wrkwin.hxx>
      35                 :            : #include <vcl/svapp.hxx>
      36                 :            : #include <vcl/dialog.hxx>
      37                 :            : #include <toolkit/helper/vclunohelper.hxx>
      38                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      39                 :            : #include <com/sun/star/frame/XLayoutManager.hpp>
      40                 :            : #include <com/sun/star/lang/IllegalArgumentException.hpp>
      41                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      42                 :            : #include <com/sun/star/util/URL.hpp>
      43                 :            : 
      44                 :            : using namespace ::com::sun::star;
      45                 :            : using namespace ::com::sun::star::uno;
      46                 :            : using namespace ::com::sun::star::drawing::framework;
      47                 :            : using ::rtl::OUString;
      48                 :            : 
      49                 :            : 
      50                 :            : namespace sd { namespace framework {
      51                 :            : 
      52                 :          0 : FullScreenPane::FullScreenPane (
      53                 :            :     const Reference<XComponentContext>& rxComponentContext,
      54                 :            :     const Reference<XResourceId>& rxPaneId,
      55                 :            :     const ::Window* pViewShellWindow)
      56                 :            :     : FrameWindowPane(rxPaneId,NULL),
      57                 :            :       mxComponentContext(rxComponentContext),
      58                 :          0 :       mpWorkWindow(NULL)
      59                 :            : {
      60                 :          0 :     ::Window* pParent = NULL;
      61                 :            :     mpWorkWindow.reset(new WorkWindow(
      62                 :            :         pParent,
      63 [ #  # ][ #  # ]:          0 :         0));  // For debugging (non-fullscreen) use WB_BORDER | WB_MOVEABLE | WB_SIZEABLE));
                 [ #  # ]
      64                 :            : 
      65         [ #  # ]:          0 :     if ( ! rxPaneId.is())
      66         [ #  # ]:          0 :         throw lang::IllegalArgumentException();
      67                 :            : 
      68                 :          0 :     sal_Int32 nScreenNumber = 1;
      69         [ #  # ]:          0 :     ExtractArguments(rxPaneId, nScreenNumber);
      70                 :            : 
      71         [ #  # ]:          0 :     if (mpWorkWindow.get() == NULL)
      72                 :          0 :         return;
      73                 :            : 
      74                 :            :     // Create a new top-leve window that is displayed full screen.
      75         [ #  # ]:          0 :     mpWorkWindow->ShowFullScreenMode(sal_True, nScreenNumber);
      76                 :            :     // For debugging (non-fullscreen) use mpWorkWindow->SetScreenNumber(nScreenNumber);
      77         [ #  # ]:          0 :     mpWorkWindow->SetMenuBarMode(MENUBAR_MODE_HIDE);
      78         [ #  # ]:          0 :     mpWorkWindow->SetBorderStyle(WINDOW_BORDER_REMOVEBORDER);
      79 [ #  # ][ #  # ]:          0 :     mpWorkWindow->SetBackground(Wallpaper());
                 [ #  # ]
      80                 :            :     // Don't show the window right now in order to allow the setting of an
      81                 :            :     // accessibility object: accessibility objects are typically
      82                 :            :     // requested by AT-tools when the window is shown.  Chaning it
      83                 :            :     // afterwards may or may not work.
      84                 :            : 
      85                 :            :     // Add resize listener at the work window.
      86         [ #  # ]:          0 :     Link aWindowEventHandler (LINK(this, FullScreenPane, WindowEventHandler));
      87         [ #  # ]:          0 :     mpWorkWindow->AddEventListener(aWindowEventHandler);
      88                 :            : 
      89                 :            :     // Set title and icon of the new window to those of the current window
      90                 :            :     // of the view shell.
      91         [ #  # ]:          0 :     if (pViewShellWindow != NULL)
      92                 :            :     {
      93         [ #  # ]:          0 :         const SystemWindow* pSystemWindow = pViewShellWindow->GetSystemWindow();
      94 [ #  # ][ #  # ]:          0 :         mpWorkWindow->SetText(pSystemWindow->GetText());
                 [ #  # ]
      95         [ #  # ]:          0 :         mpWorkWindow->SetIcon(pSystemWindow->GetIcon());
      96                 :            :     }
      97                 :            : 
      98                 :            :     // For some reason the VCL canvas can not paint into a WorkWindow.
      99                 :            :     // Therefore a child window is created that covers the WorkWindow
     100                 :            :     // completely.
     101 [ #  # ][ #  # ]:          0 :     mpWindow = new ::Window(mpWorkWindow.get());
     102 [ #  # ][ #  # ]:          0 :     mpWindow->SetPosSizePixel(Point(0,0), mpWorkWindow->GetSizePixel());
     103 [ #  # ][ #  # ]:          0 :     mpWindow->SetBackground(Wallpaper());
                 [ #  # ]
     104 [ #  # ][ #  # ]:          0 :     mxWindow = VCLUnoHelper::GetInterface(mpWindow);
     105                 :            : 
     106                 :            :     // Create the canvas.
     107 [ #  # ][ #  # ]:          0 :     mxCanvas = CreateCanvas();
     108                 :            : 
     109         [ #  # ]:          0 :     mpWindow->GrabFocus();
     110                 :            : }
     111                 :            : 
     112                 :            : 
     113                 :            : 
     114                 :            : 
     115         [ #  # ]:          0 : FullScreenPane::~FullScreenPane (void) throw()
     116                 :            : {
     117         [ #  # ]:          0 : }
     118                 :            : 
     119                 :            : 
     120                 :            : 
     121                 :            : 
     122                 :          0 : void SAL_CALL FullScreenPane::disposing (void)
     123                 :            : {
     124                 :            :     // We have created the window pointed to by mpWindow, we delete it.
     125         [ #  # ]:          0 :     if (mpWindow != NULL)
     126                 :            :     {
     127         [ #  # ]:          0 :         delete mpWindow;
     128                 :            :     }
     129                 :            : 
     130         [ #  # ]:          0 :     if (mpWorkWindow.get() != NULL)
     131                 :            :     {
     132         [ #  # ]:          0 :         Link aWindowEventHandler (LINK(this, FullScreenPane, WindowEventHandler));
     133         [ #  # ]:          0 :         mpWorkWindow->RemoveEventListener(aWindowEventHandler);
     134         [ #  # ]:          0 :         mpWorkWindow.reset();
     135                 :            :     }
     136                 :            : 
     137                 :            : 
     138                 :          0 :     FrameWindowPane::disposing();
     139                 :          0 : }
     140                 :            : 
     141                 :            : 
     142                 :            : 
     143                 :            : 
     144                 :            : //----- XPane -----------------------------------------------------------------
     145                 :            : 
     146                 :          0 : sal_Bool SAL_CALL FullScreenPane::isVisible (void)
     147                 :            :     throw (RuntimeException)
     148                 :            : {
     149                 :          0 :     ThrowIfDisposed();
     150                 :            : 
     151         [ #  # ]:          0 :     if (mpWindow != NULL)
     152                 :          0 :         return mpWindow->IsReallyVisible();
     153                 :            :     else
     154                 :          0 :         return false;
     155                 :            : }
     156                 :            : 
     157                 :            : 
     158                 :            : 
     159                 :            : 
     160                 :          0 : void SAL_CALL FullScreenPane::setVisible (const sal_Bool bIsVisible)
     161                 :            :     throw (RuntimeException)
     162                 :            : {
     163                 :          0 :     ThrowIfDisposed();
     164                 :            : 
     165         [ #  # ]:          0 :     if (mpWindow != NULL)
     166                 :          0 :         mpWindow->Show(bIsVisible);
     167         [ #  # ]:          0 :     if (mpWorkWindow != NULL)
     168                 :          0 :         mpWorkWindow->Show(bIsVisible);
     169                 :          0 : }
     170                 :            : 
     171                 :            : 
     172                 :            : 
     173                 :            : 
     174                 :          0 : Reference<accessibility::XAccessible> SAL_CALL FullScreenPane::getAccessible (void)
     175                 :            :     throw (RuntimeException)
     176                 :            : {
     177                 :          0 :     ThrowIfDisposed();
     178                 :            : 
     179         [ #  # ]:          0 :     if (mpWorkWindow != NULL)
     180                 :          0 :         return mpWorkWindow->GetAccessible(sal_False);
     181                 :            :     else
     182                 :          0 :         return NULL;
     183                 :            : }
     184                 :            : 
     185                 :            : 
     186                 :            : 
     187                 :            : 
     188                 :          0 : void SAL_CALL FullScreenPane::setAccessible (
     189                 :            :     const Reference<accessibility::XAccessible>& rxAccessible)
     190                 :            :     throw (RuntimeException)
     191                 :            : {
     192                 :          0 :     ThrowIfDisposed();
     193                 :            : 
     194         [ #  # ]:          0 :     if (mpWindow != NULL)
     195                 :            :     {
     196         [ #  # ]:          0 :         Reference<lang::XInitialization> xInitializable (rxAccessible, UNO_QUERY);
     197         [ #  # ]:          0 :         if (xInitializable.is())
     198                 :            :         {
     199         [ #  # ]:          0 :             ::Window* pParentWindow = mpWindow->GetParent();
     200                 :          0 :             Reference<accessibility::XAccessible> xAccessibleParent;
     201         [ #  # ]:          0 :             if (pParentWindow != NULL)
     202 [ #  # ][ #  # ]:          0 :                 xAccessibleParent = pParentWindow->GetAccessible();
     203         [ #  # ]:          0 :             Sequence<Any> aArguments (1);
     204 [ #  # ][ #  # ]:          0 :             aArguments[0] = Any(xAccessibleParent);
     205 [ #  # ][ #  # ]:          0 :             xInitializable->initialize(aArguments);
                 [ #  # ]
     206                 :            :         }
     207 [ #  # ][ #  # ]:          0 :         GetWindow()->SetAccessible(rxAccessible);
     208                 :            :     }
     209                 :          0 : }
     210                 :            : 
     211                 :            : 
     212                 :            : 
     213                 :            : 
     214                 :            : //-----------------------------------------------------------------------------
     215                 :            : 
     216                 :          0 : IMPL_LINK(FullScreenPane, WindowEventHandler, VclWindowEvent*, pEvent)
     217                 :            : {
     218      [ #  #  # ]:          0 :     switch (pEvent->GetId())
     219                 :            :     {
     220                 :            :         case VCLEVENT_WINDOW_RESIZE:
     221         [ #  # ]:          0 :             GetWindow()->SetPosPixel(Point(0,0));
     222                 :          0 :             GetWindow()->SetSizePixel(Size(
     223         [ #  # ]:          0 :                 mpWorkWindow->GetSizePixel().Width(),
     224         [ #  # ]:          0 :                 mpWorkWindow->GetSizePixel().Height()));
     225                 :          0 :             break;
     226                 :            : 
     227                 :            :         case VCLEVENT_OBJECT_DYING:
     228                 :          0 :             mpWorkWindow.reset();
     229                 :          0 :             break;
     230                 :            :     }
     231                 :          0 :     return 1;
     232                 :            : }
     233                 :            : 
     234                 :            : 
     235                 :            : 
     236                 :            : 
     237                 :          0 : Reference<rendering::XCanvas> FullScreenPane::CreateCanvas (void)
     238                 :            :     throw (RuntimeException)
     239                 :            : {
     240                 :          0 :     ::Window* pWindow = VCLUnoHelper::GetWindow(mxWindow);
     241         [ #  # ]:          0 :     if (pWindow != NULL)
     242                 :            :     {
     243         [ #  # ]:          0 :         Sequence<Any> aArg (5);
     244                 :            : 
     245                 :            :         // common: first any is VCL pointer to window (for VCL canvas)
     246 [ #  # ][ #  # ]:          0 :         aArg[0] = makeAny(reinterpret_cast<sal_Int64>(pWindow));
     247         [ #  # ]:          0 :         aArg[1] = Any();
     248 [ #  # ][ #  # ]:          0 :         aArg[2] = makeAny(::com::sun::star::awt::Rectangle());
     249 [ #  # ][ #  # ]:          0 :         aArg[3] = makeAny(sal_False);
     250 [ #  # ][ #  # ]:          0 :         aArg[4] = makeAny(mxWindow);
     251                 :            : 
     252                 :            :         Reference<lang::XMultiServiceFactory> xFactory (
     253 [ #  # ][ #  # ]:          0 :             mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
                 [ #  # ]
     254                 :            :         return Reference<rendering::XCanvas>(
     255         [ #  # ]:          0 :             xFactory->createInstanceWithArguments("com.sun.star.rendering.SpriteCanvas.VCL",
     256                 :          0 :                 aArg),
     257 [ #  # ][ #  # ]:          0 :             UNO_QUERY);
                 [ #  # ]
     258                 :            :     }
     259                 :            :     else
     260         [ #  # ]:          0 :         throw RuntimeException();
     261                 :            : }
     262                 :            : 
     263                 :            : 
     264                 :            : 
     265                 :            : 
     266                 :          0 : void FullScreenPane::ExtractArguments (
     267                 :            :     const Reference<XResourceId>& rxPaneId,
     268                 :            :     sal_Int32& rnScreenNumberReturnValue)
     269                 :            : {
     270                 :            :     // Extract arguments from the resource URL.
     271 [ #  # ][ #  # ]:          0 :     const util::URL aURL = rxPaneId->getFullResourceURL();
     272                 :          0 :     sal_Int32 nIndex = 0;
     273         [ #  # ]:          0 :     while (nIndex >= 0)
     274                 :            :     {
     275                 :          0 :         const OUString aToken = aURL.Arguments.getToken(0, '&', nIndex);
     276         [ #  # ]:          0 :         if (!aToken.isEmpty())
     277                 :            :         {
     278                 :            :             // Split at the first '='.
     279                 :          0 :             const sal_Int32 nAssign = aToken.indexOf('=');
     280                 :          0 :             const OUString sKey = aToken.copy(0, nAssign);
     281                 :          0 :             const OUString sValue = aToken.copy(nAssign+1);
     282                 :            : 
     283         [ #  # ]:          0 :             if (sKey.compareToAscii("ScreenNumber") == 0)
     284                 :            :             {
     285                 :          0 :                 rnScreenNumberReturnValue = sValue.toInt32();
     286                 :          0 :             }
     287                 :            :         }
     288                 :          0 :     }
     289                 :          0 : }
     290                 :            : 
     291                 :            : 
     292                 :            : } } // end of namespace sd::framework
     293                 :            : 
     294                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10