LCOV - code coverage report
Current view: top level - svtools/source/graphic - graphic.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 58 94 61.7 %
Date: 2014-11-03 Functions: 15 23 65.2 %
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 <osl/mutex.hxx>
      21             : #include <vcl/svapp.hxx>
      22             : #include <com/sun/star/graphic/GraphicType.hpp>
      23             : #include <com/sun/star/graphic/XGraphicTransformer.hpp>
      24             : #include <vcl/dibtools.hxx>
      25             : #include <vcl/graph.hxx>
      26             : #include "graphic.hxx"
      27             : #include <comphelper/servicehelper.hxx>
      28             : #include <cppuhelper/supportsservice.hxx>
      29             : #include <string.h>
      30             : 
      31             : using namespace com::sun::star;
      32             : 
      33             : namespace unographic {
      34             : 
      35      137458 : Graphic::Graphic() :
      36      137458 :     mpGraphic( NULL )
      37             : {
      38      137458 : }
      39             : 
      40             : 
      41             : 
      42      274912 : Graphic::~Graphic()
      43      274912 :     throw()
      44             : {
      45      137456 :     delete mpGraphic;
      46      274912 : }
      47             : 
      48             : 
      49             : 
      50      137458 : void Graphic::init( const ::Graphic& rGraphic )
      51             :     throw()
      52             : {
      53      137458 :     delete mpGraphic;
      54      137458 :     mpGraphic = new ::Graphic( rGraphic );
      55      137458 :     ::unographic::GraphicDescriptor::init( *mpGraphic );
      56      137458 : }
      57             : 
      58             : 
      59             : 
      60      145418 : uno::Any SAL_CALL Graphic::queryAggregation( const uno::Type& rType )
      61             :     throw( uno::RuntimeException, std::exception )
      62             : {
      63      145418 :     uno::Any aAny;
      64      145418 :     if( rType == cppu::UnoType<graphic::XGraphic>::get())
      65        6520 :         aAny <<= uno::Reference< graphic::XGraphic >( this );
      66      138898 :     else if( rType == cppu::UnoType<awt::XBitmap>::get())
      67        1164 :         aAny <<= uno::Reference< awt::XBitmap >( this );
      68      137734 :     else if( rType == cppu::UnoType<lang::XUnoTunnel>::get())
      69      137042 :         aAny <<= uno::Reference< lang::XUnoTunnel >(this);
      70             :     else
      71         692 :         aAny <<= ::unographic::GraphicDescriptor::queryAggregation( rType );
      72             : 
      73      145418 :     return aAny ;
      74             : }
      75             : 
      76             : 
      77             : 
      78      145418 : uno::Any SAL_CALL Graphic::queryInterface( const uno::Type & rType )
      79             :     throw( uno::RuntimeException, std::exception )
      80             : {
      81      145418 :     ::com::sun::star::uno::Any aReturn = ::unographic::GraphicDescriptor::queryInterface( rType );
      82      145418 :     if ( !aReturn.hasValue() )
      83           6 :         aReturn = ::cppu::queryInterface ( rType, static_cast< graphic::XGraphicTransformer*>( this ) );
      84      145418 :     return aReturn;
      85             : }
      86             : 
      87             : 
      88             : 
      89      890080 : void SAL_CALL Graphic::acquire()
      90             :     throw()
      91             : {
      92      890080 :     ::unographic::GraphicDescriptor::acquire();
      93      890080 : }
      94             : 
      95             : 
      96             : 
      97      890078 : void SAL_CALL Graphic::release() throw()
      98             : {
      99      890078 :     ::unographic::GraphicDescriptor::release();
     100      890078 : }
     101             : 
     102           0 : OUString Graphic::getImplementationName_Static()
     103             :     throw()
     104             : {
     105           0 :     return OUString( "com.sun.star.comp.graphic.Graphic" );
     106             : }
     107             : 
     108             : 
     109             : 
     110           0 : uno::Sequence< OUString > Graphic::getSupportedServiceNames_Static()
     111             :     throw()
     112             : {
     113           0 :     uno::Sequence< OUString > aSeq( 1 );
     114             : 
     115           0 :     aSeq.getArray()[ 0 ] = "com.sun.star.graphic.Graphic";
     116             : 
     117           0 :     return aSeq;
     118             : }
     119             : 
     120           0 : OUString SAL_CALL Graphic::getImplementationName()
     121             :     throw( uno::RuntimeException, std::exception )
     122             : {
     123           0 :     return getImplementationName_Static();
     124             : }
     125             : 
     126           0 : sal_Bool SAL_CALL Graphic::supportsService( const OUString& rServiceName )
     127             :     throw( uno::RuntimeException, std::exception )
     128             : {
     129           0 :     return cppu::supportsService( this, rServiceName );
     130             : }
     131             : 
     132           0 : uno::Sequence< OUString > SAL_CALL Graphic::getSupportedServiceNames()
     133             :     throw( uno::RuntimeException, std::exception )
     134             : {
     135           0 :     uno::Sequence< OUString >    aRet( ::unographic::GraphicDescriptor::getSupportedServiceNames() );
     136           0 :     uno::Sequence< OUString >    aNew( getSupportedServiceNames_Static() );
     137           0 :     sal_Int32                           nOldCount = aRet.getLength();
     138             : 
     139           0 :     aRet.realloc( nOldCount + aNew.getLength() );
     140             : 
     141           0 :     for( sal_Int32 i = 0; i < aNew.getLength(); ++i )
     142           0 :         aRet[ nOldCount++ ] = aNew[ i ];
     143             : 
     144           0 :     return aRet;
     145             : }
     146             : 
     147           0 : uno::Sequence< uno::Type > SAL_CALL Graphic::getTypes()
     148             :     throw(uno::RuntimeException, std::exception)
     149             : {
     150           0 :     uno::Sequence< uno::Type >  aRet( ::unographic::GraphicDescriptor::getTypes() );
     151           0 :     sal_Int32                   nOldCount = aRet.getLength();
     152             : 
     153           0 :     aRet.realloc( nOldCount + 2 );
     154           0 :     aRet[ nOldCount ] = cppu::UnoType<graphic::XGraphic>::get();
     155           0 :     aRet[ nOldCount+1 ] = cppu::UnoType<awt::XBitmap>::get();
     156             : 
     157           0 :     return aRet;
     158             : }
     159             : 
     160             : 
     161             : 
     162           0 : uno::Sequence< sal_Int8 > SAL_CALL Graphic::getImplementationId()
     163             :     throw(uno::RuntimeException, std::exception)
     164             : {
     165           0 :     return css::uno::Sequence<sal_Int8>();
     166             : }
     167             : 
     168             : 
     169             : 
     170           2 : ::sal_Int8 SAL_CALL Graphic::getType()
     171             :      throw (uno::RuntimeException, std::exception)
     172             : {
     173           2 :     ::sal_Int8 cRet = graphic::GraphicType::EMPTY;
     174             : 
     175           2 :     if( mpGraphic && ( mpGraphic->GetType() != GRAPHIC_NONE ) )
     176           2 :         cRet = ( ( mpGraphic->GetType() == GRAPHIC_BITMAP ) ? graphic::GraphicType::PIXEL : graphic::GraphicType::VECTOR );
     177             : 
     178           2 :     return cRet;
     179             : }
     180             : 
     181             : 
     182             : // XBitmap
     183             : 
     184             : 
     185         510 : awt::Size SAL_CALL Graphic::getSize(  ) throw (uno::RuntimeException, std::exception)
     186             : {
     187         510 :     SolarMutexGuard aGuard;
     188             : 
     189         510 :     ::Size aVclSize;
     190         510 :     if( mpGraphic && ( mpGraphic->GetType() != GRAPHIC_NONE ) )
     191         510 :         aVclSize = mpGraphic->GetSizePixel();
     192             : 
     193         510 :     return awt::Size( aVclSize.Width(), aVclSize.Height() );
     194             : }
     195             : 
     196             : 
     197             : 
     198           6 : uno::Sequence< ::sal_Int8 > SAL_CALL Graphic::getDIB(  ) throw (uno::RuntimeException, std::exception)
     199             : {
     200           6 :     SolarMutexGuard aGuard;
     201             : 
     202           6 :     if( mpGraphic && ( mpGraphic->GetType() != GRAPHIC_NONE ) )
     203             :     {
     204           6 :         SvMemoryStream aMem;
     205             : 
     206           6 :         WriteDIB(mpGraphic->GetBitmapEx().GetBitmap(), aMem, false, true);
     207           6 :         return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
     208             :     }
     209             :     else
     210             :     {
     211           0 :         return uno::Sequence<sal_Int8>();
     212           6 :     }
     213             : }
     214             : 
     215             : 
     216             : 
     217           0 : uno::Sequence< ::sal_Int8 > SAL_CALL Graphic::getMaskDIB(  ) throw (uno::RuntimeException, std::exception)
     218             : {
     219           0 :     SolarMutexGuard aGuard;
     220             : 
     221           0 :     if( mpGraphic && ( mpGraphic->GetType() != GRAPHIC_NONE ) )
     222             :     {
     223           0 :         SvMemoryStream aMem;
     224             : 
     225           0 :         WriteDIB(mpGraphic->GetBitmapEx().GetMask(), aMem, false, true);
     226           0 :         return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
     227             :     }
     228             :     else
     229             :     {
     230           0 :         return uno::Sequence<sal_Int8>();
     231           0 :     }
     232             : }
     233             : 
     234             : 
     235           8 : const ::Graphic* Graphic::getImplementation( const uno::Reference< uno::XInterface >& rxIFace )
     236             :     throw()
     237             : {
     238           8 :     uno::Reference< lang::XUnoTunnel > xTunnel( rxIFace, uno::UNO_QUERY );
     239           8 :     return( xTunnel.is() ? reinterpret_cast< ::Graphic* >( xTunnel->getSomething( ::Graphic::getUnoTunnelId() ) ) : NULL );
     240             : }
     241             : 
     242             : 
     243      137042 : sal_Int64 SAL_CALL Graphic::getSomething( const uno::Sequence< sal_Int8 >& rId )
     244             :     throw( uno::RuntimeException, std::exception )
     245             : {
     246      548168 :     return( ( rId.getLength() == 16 && 0 == memcmp( ::Graphic::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) ?
     247             :             reinterpret_cast< sal_Int64 >( mpGraphic ) :
     248      548168 :             0 );
     249             : }
     250             : 
     251        1227 : }
     252             : 
     253             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10