LCOV - code coverage report
Current view: top level - sd/source/ui/presenter - PresenterHelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 102 2.0 %
Date: 2012-08-25 Functions: 1 15 6.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 234 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 "PresenterHelper.hxx"
      31                 :            : #include "CanvasUpdateRequester.hxx"
      32                 :            : #include "PresenterCanvas.hxx"
      33                 :            : #include <cppcanvas/vclfactory.hxx>
      34                 :            : #include <com/sun/star/awt/WindowAttribute.hpp>
      35                 :            : #include <com/sun/star/awt/WindowClass.hpp>
      36                 :            : #include <com/sun/star/awt/WindowDescriptor.hpp>
      37                 :            : #include <osl/file.hxx>
      38                 :            : #include <toolkit/helper/vclunohelper.hxx>
      39                 :            : #include <vcl/svapp.hxx>
      40                 :            : #include <vcl/window.hxx>
      41                 :            : #include <vcl/wrkwin.hxx>
      42                 :            : 
      43                 :            : using namespace ::com::sun::star;
      44                 :            : using namespace ::com::sun::star::uno;
      45                 :            : using ::rtl::OUString;
      46                 :            : 
      47                 :            : namespace sd { namespace presenter {
      48                 :            : 
      49                 :            : //===== Service ===============================================================
      50                 :            : 
      51                 :          0 : Reference<XInterface> SAL_CALL PresenterHelperService_createInstance (
      52                 :            :     const Reference<XComponentContext>& rxContext)
      53                 :            : {
      54         [ #  # ]:          0 :     return Reference<XInterface>(static_cast<XWeak*>(new PresenterHelper(rxContext)));
      55                 :            : }
      56                 :            : 
      57                 :            : 
      58                 :            : 
      59                 :            : 
      60                 :         22 : ::rtl::OUString PresenterHelperService_getImplementationName (void)
      61                 :            :     throw(RuntimeException)
      62                 :            : {
      63                 :         22 :     return OUString("com.sun.star.comp.Draw.PresenterHelper");
      64                 :            : }
      65                 :            : 
      66                 :            : 
      67                 :            : 
      68                 :            : 
      69                 :          0 : Sequence<rtl::OUString> SAL_CALL PresenterHelperService_getSupportedServiceNames (void)
      70                 :            :     throw (RuntimeException)
      71                 :            : {
      72 [ #  # ][ #  # ]:          0 :     static const ::rtl::OUString sServiceName("com.sun.star.drawing.PresenterHelper");
      73                 :          0 :     return Sequence<rtl::OUString>(&sServiceName, 1);
      74                 :            : }
      75                 :            : 
      76                 :            : 
      77                 :            : 
      78                 :            : 
      79                 :            : //===== PresenterHelper =======================================================
      80                 :            : 
      81                 :          0 : PresenterHelper::PresenterHelper (
      82                 :            :     const Reference<XComponentContext>& rxContext)
      83                 :            :     : PresenterHelperInterfaceBase(m_aMutex),
      84         [ #  # ]:          0 :       mxComponentContext(rxContext)
      85                 :            : {
      86                 :          0 : }
      87                 :            : 
      88                 :            : 
      89                 :            : 
      90 [ #  # ][ #  # ]:          0 : PresenterHelper::~PresenterHelper (void)
                 [ #  # ]
      91                 :            : {
      92         [ #  # ]:          0 : }
      93                 :            : 
      94                 :            : 
      95                 :            : 
      96                 :            : 
      97                 :            : //----- XInitialize -----------------------------------------------------------
      98                 :            : 
      99                 :          0 : void SAL_CALL PresenterHelper::initialize (const Sequence<Any>& rArguments)
     100                 :            :     throw(Exception,RuntimeException)
     101                 :            : {
     102                 :            :     (void)rArguments;
     103                 :          0 : }
     104                 :            : 
     105                 :            : 
     106                 :            : 
     107                 :            : 
     108                 :            : //----- XPaneHelper ----------------------------------------------------
     109                 :            : 
     110                 :          0 : Reference<awt::XWindow> SAL_CALL PresenterHelper::createWindow (
     111                 :            :     const Reference<awt::XWindow>& rxParentWindow,
     112                 :            :     sal_Bool bCreateSystemChildWindow,
     113                 :            :     sal_Bool bInitiallyVisible,
     114                 :            :     sal_Bool bEnableChildTransparentMode,
     115                 :            :     sal_Bool bEnableParentClip)
     116                 :            :     throw (css::uno::RuntimeException)
     117                 :            : {
     118                 :          0 :     ::Window* pParentWindow = VCLUnoHelper::GetWindow(rxParentWindow);
     119                 :            : 
     120                 :            :     // Create a new window.
     121                 :          0 :     ::Window* pWindow = NULL;
     122         [ #  # ]:          0 :     if (bCreateSystemChildWindow)
     123                 :            :     {
     124         [ #  # ]:          0 :         pWindow = new WorkWindow(pParentWindow, WB_SYSTEMCHILDWINDOW);
     125                 :            :     }
     126                 :            :     else
     127                 :            :     {
     128         [ #  # ]:          0 :         pWindow = new ::Window(pParentWindow);
     129                 :            :     }
     130         [ #  # ]:          0 :     Reference<awt::XWindow> xWindow (pWindow->GetComponentInterface(), UNO_QUERY);
     131                 :            : 
     132         [ #  # ]:          0 :     if (bEnableChildTransparentMode)
     133                 :            :     {
     134                 :            :         // Make the frame window transparent and make the parent able to
     135                 :            :         // draw behind it.
     136         [ #  # ]:          0 :         if (pParentWindow != NULL)
     137         [ #  # ]:          0 :             pParentWindow->EnableChildTransparentMode(sal_True);
     138                 :            :     }
     139                 :            : 
     140         [ #  # ]:          0 :     if (pWindow != NULL)
     141                 :            :     {
     142         [ #  # ]:          0 :         pWindow->Show(bInitiallyVisible);
     143                 :            : 
     144 [ #  # ][ #  # ]:          0 :         pWindow->SetMapMode(MAP_PIXEL);
                 [ #  # ]
     145         [ #  # ]:          0 :         pWindow->SetBackground();
     146         [ #  # ]:          0 :         if ( ! bEnableParentClip)
     147                 :            :         {
     148         [ #  # ]:          0 :             pWindow->SetParentClipMode(PARENTCLIPMODE_NOCLIP);
     149         [ #  # ]:          0 :             pWindow->SetPaintTransparent(sal_True);
     150                 :            :         }
     151                 :            :         else
     152                 :            :         {
     153         [ #  # ]:          0 :             pWindow->SetParentClipMode(PARENTCLIPMODE_CLIP);
     154         [ #  # ]:          0 :             pWindow->SetPaintTransparent(sal_False);
     155                 :            :         }
     156                 :            : 
     157                 :            :     }
     158                 :            : 
     159                 :          0 :     return xWindow;
     160                 :            : }
     161                 :            : 
     162                 :            : 
     163                 :            : 
     164                 :            : 
     165                 :          0 : Reference<rendering::XCanvas> SAL_CALL PresenterHelper::createSharedCanvas (
     166                 :            :     const Reference<rendering::XSpriteCanvas>& rxUpdateCanvas,
     167                 :            :     const Reference<awt::XWindow>& rxUpdateWindow,
     168                 :            :     const Reference<rendering::XCanvas>& rxSharedCanvas,
     169                 :            :     const Reference<awt::XWindow>& rxSharedWindow,
     170                 :            :     const Reference<awt::XWindow>& rxWindow)
     171                 :            :     throw (css::uno::RuntimeException)
     172                 :            : {
     173   [ #  #  #  #  :          0 :     if ( ! rxSharedCanvas.is()
           #  # ][ #  # ]
     174                 :          0 :         || ! rxSharedWindow.is()
     175                 :          0 :         || ! rxWindow.is())
     176                 :            :     {
     177                 :            :         throw RuntimeException("illegal argument",
     178 [ #  # ][ #  # ]:          0 :             Reference<XInterface>(static_cast<XWeak*>(this)));
     179                 :            :     }
     180                 :            : 
     181         [ #  # ]:          0 :     if (rxWindow == rxSharedWindow)
     182                 :          0 :         return rxSharedCanvas;
     183                 :            :     else
     184                 :            :         return new PresenterCanvas(
     185                 :            :             rxUpdateCanvas,
     186                 :            :             rxUpdateWindow,
     187                 :            :             rxSharedCanvas,
     188                 :            :             rxSharedWindow,
     189 [ #  # ][ #  # ]:          0 :             rxWindow);
     190                 :            : }
     191                 :            : 
     192                 :            : 
     193                 :            : 
     194                 :            : 
     195                 :          0 : Reference<rendering::XCanvas> SAL_CALL PresenterHelper::createCanvas (
     196                 :            :     const Reference<awt::XWindow>& rxWindow,
     197                 :            :     sal_Int16 nRequestedCanvasFeatures,
     198                 :            :     const OUString& rsOptionalCanvasServiceName)
     199                 :            :     throw (css::uno::RuntimeException)
     200                 :            : {
     201                 :            :     (void)nRequestedCanvasFeatures;
     202                 :            : 
     203                 :            :     // No shared window is given or an explicit canvas service name is
     204                 :            :     // specified.  Create a new canvas.
     205                 :          0 :     ::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
     206         [ #  # ]:          0 :     if (pWindow != NULL)
     207                 :            :     {
     208         [ #  # ]:          0 :         Sequence<Any> aArg (5);
     209                 :            : 
     210                 :            :         // common: first any is VCL pointer to window (for VCL canvas)
     211 [ #  # ][ #  # ]:          0 :         aArg[0] = makeAny(reinterpret_cast<sal_Int64>(pWindow));
     212         [ #  # ]:          0 :         aArg[1] = Any();
     213 [ #  # ][ #  # ]:          0 :         aArg[2] = makeAny(::com::sun::star::awt::Rectangle());
     214 [ #  # ][ #  # ]:          0 :         aArg[3] = makeAny(sal_False);
     215 [ #  # ][ #  # ]:          0 :         aArg[4] = makeAny(rxWindow);
     216                 :            : 
     217                 :            :         Reference<lang::XMultiServiceFactory> xFactory (
     218 [ #  # ][ #  # ]:          0 :             mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
                 [ #  # ]
     219                 :            :         return Reference<rendering::XCanvas>(
     220         [ #  # ]:          0 :             xFactory->createInstanceWithArguments(
     221                 :          0 :                 !rsOptionalCanvasServiceName.isEmpty()
     222                 :            :                     ? rsOptionalCanvasServiceName
     223                 :            :                     : OUString("com.sun.star.rendering.VCLCanvas"),
     224                 :          0 :                 aArg),
     225 [ #  # ][ #  # ]:          0 :             UNO_QUERY);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     226                 :            :     }
     227                 :            :     else
     228         [ #  # ]:          0 :         throw RuntimeException();
     229                 :            : }
     230                 :            : 
     231                 :            : 
     232                 :            : 
     233                 :            : 
     234                 :          0 : void SAL_CALL PresenterHelper::toTop (
     235                 :            :     const Reference<awt::XWindow>& rxWindow)
     236                 :            :     throw (css::uno::RuntimeException)
     237                 :            : {
     238                 :          0 :     ::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
     239         [ #  # ]:          0 :     if (pWindow != NULL)
     240                 :            :     {
     241                 :          0 :         pWindow->ToTop();
     242                 :          0 :         pWindow->SetZOrder(NULL, WINDOW_ZORDER_LAST);
     243                 :            :     }
     244                 :          0 : }
     245                 :            : 
     246                 :            : 
     247                 :            : 
     248                 :            : 
     249                 :          0 : Reference<rendering::XBitmap> SAL_CALL PresenterHelper::loadBitmap (
     250                 :            :     const OUString& rsURL,
     251                 :            :     const Reference<rendering::XCanvas>& rxCanvas)
     252                 :            :     throw (RuntimeException)
     253                 :            : {
     254         [ #  # ]:          0 :     if ( ! rxCanvas.is())
     255         [ #  # ]:          0 :         return NULL;
     256                 :            : 
     257 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
     258                 :            : 
     259         [ #  # ]:          0 :     if (mpGraphicFilter.get() == NULL)
     260 [ #  # ][ #  # ]:          0 :         mpGraphicFilter.reset(new GraphicFilter(sal_False));
                 [ #  # ]
     261                 :            : 
     262                 :            :     const cppcanvas::CanvasSharedPtr pCanvas (
     263         [ #  # ]:          0 :         cppcanvas::VCLFactory::getInstance().createCanvas(
     264 [ #  # ][ #  # ]:          0 :             Reference<css::rendering::XBitmapCanvas>(rxCanvas,UNO_QUERY)));
         [ #  # ][ #  # ]
     265                 :            : 
     266 [ #  # ][ #  # ]:          0 :     if (pCanvas.get()!=NULL && !rsURL.isEmpty() && mpGraphicFilter.get()!=NULL)
         [ #  # ][ #  # ]
     267                 :            :     {
     268         [ #  # ]:          0 :         Graphic aGraphic;
     269                 :          0 :         OUString sFileName;
     270 [ #  # ][ #  # ]:          0 :         if (osl::FileBase::getSystemPathFromFileURL(rsURL, sFileName)
     271                 :            :             == osl::FileBase::E_None)
     272                 :            :         {
     273 [ #  # ][ #  # ]:          0 :             if (mpGraphicFilter->ImportGraphic(aGraphic, rsURL) == GRFILTER_OK)
         [ #  # ][ #  # ]
     274                 :            :             {
     275         [ #  # ]:          0 :                 BitmapEx aBitmapEx (aGraphic.GetBitmapEx());
     276         [ #  # ]:          0 :                 return cppcanvas::VCLFactory::getInstance().createBitmap(
     277                 :            :                     pCanvas,
     278 [ #  # ][ #  # ]:          0 :                     aBitmapEx)->getUNOBitmap();
         [ #  # ][ #  # ]
     279                 :            :             }
     280 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     281                 :            :     }
     282                 :            : 
     283 [ #  # ][ #  # ]:          0 :     return NULL;
                 [ #  # ]
     284                 :            : }
     285                 :            : 
     286                 :            : 
     287                 :            : 
     288                 :            : 
     289                 :            : 
     290                 :          0 : void SAL_CALL PresenterHelper::captureMouse (
     291                 :            :     const Reference<awt::XWindow>& rxWindow)
     292                 :            :     throw (RuntimeException)
     293                 :            : {
     294 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
     295                 :            : 
     296                 :            :     // Capture the mouse (if not already done.)
     297         [ #  # ]:          0 :     ::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
     298 [ #  # ][ #  # ]:          0 :     if (pWindow != NULL && ! pWindow->IsMouseCaptured())
         [ #  # ][ #  # ]
     299                 :            :     {
     300         [ #  # ]:          0 :         pWindow->CaptureMouse();
     301         [ #  # ]:          0 :     }
     302                 :          0 : }
     303                 :            : 
     304                 :            : 
     305                 :            : 
     306                 :            : 
     307                 :          0 : void SAL_CALL PresenterHelper::releaseMouse (const Reference<awt::XWindow>& rxWindow)
     308                 :            :     throw (RuntimeException)
     309                 :            : {
     310 [ #  # ][ #  # ]:          0 :     ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
     311                 :            : 
     312                 :            :     // Release the mouse (if not already done.)
     313         [ #  # ]:          0 :     ::Window* pWindow = VCLUnoHelper::GetWindow(rxWindow);
     314 [ #  # ][ #  # ]:          0 :     if (pWindow != NULL && pWindow->IsMouseCaptured())
         [ #  # ][ #  # ]
     315                 :            :     {
     316         [ #  # ]:          0 :         pWindow->ReleaseMouse();
     317         [ #  # ]:          0 :     }
     318                 :          0 : }
     319                 :            : 
     320                 :            : 
     321                 :            : 
     322                 :            : 
     323                 :          0 : awt::Rectangle PresenterHelper::getWindowExtentsRelative (
     324                 :            :     const Reference<awt::XWindow>& rxChildWindow,
     325                 :            :     const Reference<awt::XWindow>& rxParentWindow)
     326                 :            :     throw (RuntimeException)
     327                 :            : {
     328                 :          0 :     ::Window* pChildWindow = VCLUnoHelper::GetWindow(rxChildWindow);
     329                 :          0 :     ::Window* pParentWindow = VCLUnoHelper::GetWindow(rxParentWindow);
     330 [ #  # ][ #  # ]:          0 :     if (pChildWindow!=NULL && pParentWindow!=NULL)
     331                 :            :     {
     332         [ #  # ]:          0 :         Rectangle aBox (pChildWindow->GetWindowExtentsRelative(pParentWindow));
     333 [ #  # ][ #  # ]:          0 :         return awt::Rectangle(aBox.Left(),aBox.Top(),aBox.GetWidth(),aBox.GetHeight());
     334                 :            :     }
     335                 :            :     else
     336                 :          0 :         return awt::Rectangle();
     337                 :            : }
     338                 :            : 
     339                 :            : 
     340                 :            : 
     341                 :            : } } // end of namespace ::sd::presenter
     342                 :            : 
     343                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10