LCOV - code coverage report
Current view: top level - sd/source/ui/framework/factories - Pane.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 20 70 28.6 %
Date: 2015-06-13 12:38:46 Functions: 8 17 47.1 %
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 "framework/Pane.hxx"
      21             : 
      22             : #include <vcl/svapp.hxx>
      23             : #include <osl/mutex.hxx>
      24             : #include <toolkit/helper/vclunohelper.hxx>
      25             : #include <vcl/window.hxx>
      26             : #include <cppcanvas/vclfactory.hxx>
      27             : #include <comphelper/servicehelper.hxx>
      28             : 
      29             : using namespace ::com::sun::star;
      30             : using namespace ::com::sun::star::uno;
      31             : using namespace ::com::sun::star::drawing::framework;
      32             : 
      33             : namespace sd { namespace framework {
      34             : 
      35         380 : Pane::Pane (
      36             :     const Reference<XResourceId>& rxPaneId,
      37             :     vcl::Window* pWindow)
      38             :     throw ()
      39             :     : PaneInterfaceBase(MutexOwner::maMutex),
      40             :       mxPaneId(rxPaneId),
      41             :       mpWindow(pWindow),
      42         380 :       mxWindow(VCLUnoHelper::GetInterface(pWindow))
      43             : {
      44         380 : }
      45             : 
      46         381 : Pane::~Pane()
      47             : {
      48         381 : }
      49             : 
      50         254 : void Pane::disposing()
      51             : {
      52         254 :     mxWindow = NULL;
      53         254 :     mpWindow = NULL;
      54         254 : }
      55             : 
      56           0 : vcl::Window* Pane::GetWindow()
      57             : {
      58           0 :     if (mxWindow.is())
      59           0 :         return mpWindow;
      60             :     else
      61           0 :         return NULL;
      62             : }
      63             : 
      64             : //----- XPane -----------------------------------------------------------------
      65             : 
      66         658 : Reference<awt::XWindow> SAL_CALL Pane::getWindow()
      67             :     throw (RuntimeException, std::exception)
      68             : {
      69         658 :     ThrowIfDisposed();
      70             : 
      71         658 :     return mxWindow;
      72             : }
      73             : 
      74           0 : Reference<rendering::XCanvas> SAL_CALL Pane::getCanvas()
      75             :     throw (RuntimeException, std::exception)
      76             : {
      77           0 :     ::osl::MutexGuard aGuard (maMutex);
      78           0 :     ThrowIfDisposed();
      79             : 
      80           0 :     if ( ! mxCanvas.is())
      81           0 :         mxCanvas = CreateCanvas();
      82             : 
      83           0 :     return mxCanvas;
      84             : }
      85             : 
      86             : //----- XPane2 ----------------------------------------------------------------
      87             : 
      88           0 : sal_Bool SAL_CALL Pane::isVisible()
      89             :     throw (RuntimeException, std::exception)
      90             : {
      91           0 :     ThrowIfDisposed();
      92             : 
      93           0 :     const vcl::Window* pWindow = GetWindow();
      94           0 :     if (pWindow != NULL)
      95           0 :         return pWindow->IsVisible();
      96             :     else
      97           0 :         return false;
      98             : }
      99             : 
     100           0 : void SAL_CALL Pane::setVisible (sal_Bool bIsVisible)
     101             :     throw (RuntimeException, std::exception)
     102             : {
     103           0 :     ThrowIfDisposed();
     104             : 
     105           0 :     vcl::Window* pWindow = GetWindow();
     106           0 :     if (pWindow != NULL)
     107           0 :         pWindow->Show(bIsVisible);
     108           0 : }
     109             : 
     110           0 : Reference<css::accessibility::XAccessible> SAL_CALL Pane::getAccessible()
     111             :     throw (RuntimeException, std::exception)
     112             : {
     113           0 :     ThrowIfDisposed();
     114           0 :     vcl::Window* pWindow = GetWindow();
     115           0 :     if (pWindow != NULL)
     116           0 :         return pWindow->GetAccessible(false);
     117             :     else
     118           0 :         return NULL;
     119             : }
     120             : 
     121           0 : void SAL_CALL Pane::setAccessible (
     122             :     const Reference<css::accessibility::XAccessible>& rxAccessible)
     123             :     throw (RuntimeException, std::exception)
     124             : {
     125           0 :     ThrowIfDisposed();
     126           0 :     vcl::Window* pWindow = GetWindow();
     127           0 :     if (pWindow != NULL)
     128           0 :         pWindow->SetAccessible(rxAccessible);
     129           0 : }
     130             : 
     131             : //----- XResource -------------------------------------------------------------
     132             : 
     133         319 : Reference<XResourceId> SAL_CALL Pane::getResourceId()
     134             :     throw (RuntimeException, std::exception)
     135             : {
     136         319 :     ThrowIfDisposed();
     137             : 
     138         319 :     return mxPaneId;
     139             : }
     140             : 
     141         329 : sal_Bool SAL_CALL Pane::isAnchorOnly()
     142             :     throw (RuntimeException, std::exception)
     143             : {
     144         329 :     return true;
     145             : }
     146             : 
     147             : //----- XUnoTunnel ------------------------------------------------------------
     148             : 
     149             : namespace
     150             : {
     151             :     class thePaneUnoTunnelId : public rtl::Static< UnoTunnelIdInit, thePaneUnoTunnelId > {};
     152             : }
     153             : 
     154           0 : const Sequence<sal_Int8>& Pane::getUnoTunnelId()
     155             : {
     156           0 :     return thePaneUnoTunnelId::get().getSeq();
     157             : }
     158             : 
     159           0 : sal_Int64 SAL_CALL Pane::getSomething (const Sequence<sal_Int8>& rId)
     160             :     throw (RuntimeException, std::exception)
     161             : {
     162           0 :     sal_Int64 nResult = 0;
     163             : 
     164           0 :     if (rId.getLength() == 16
     165           0 :         && memcmp(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
     166             :     {
     167           0 :         nResult = reinterpret_cast<sal_Int64>(this);
     168             :     }
     169             : 
     170           0 :     return nResult;
     171             : }
     172             : 
     173           0 : Reference<rendering::XCanvas> Pane::CreateCanvas()
     174             :     throw (RuntimeException)
     175             : {
     176           0 :     Reference<rendering::XCanvas> xCanvas;
     177             : 
     178           0 :     if (mpWindow != nullptr)
     179             :     {
     180             :         ::cppcanvas::SpriteCanvasSharedPtr pCanvas (
     181           0 :             cppcanvas::VCLFactory::createSpriteCanvas(*mpWindow));
     182           0 :         if (pCanvas.get() != NULL)
     183           0 :             xCanvas = Reference<rendering::XCanvas>(pCanvas->getUNOSpriteCanvas(), UNO_QUERY);
     184             :     }
     185             : 
     186           0 :     return xCanvas;
     187             : }
     188             : 
     189        1043 : void Pane::ThrowIfDisposed() const
     190             :     throw (lang::DisposedException)
     191             : {
     192        1043 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     193             :     {
     194             :         throw lang::DisposedException ("Pane object has already been disposed",
     195           0 :             const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
     196             :     }
     197        1043 : }
     198             : 
     199             : } } // end of namespace sd::framework
     200             : 
     201             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11