LCOV - code coverage report
Current view: top level - svtools/source/graphic - graphic.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 93 0.0 %
Date: 2014-04-14 Functions: 0 21 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             : #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           0 : Graphic::Graphic() :
      36           0 :     mpGraphic( NULL )
      37             : {
      38           0 : }
      39             : 
      40             : 
      41             : 
      42           0 : Graphic::~Graphic()
      43           0 :     throw()
      44             : {
      45           0 :     delete mpGraphic;
      46           0 : }
      47             : 
      48             : 
      49             : 
      50           0 : void Graphic::init( const ::Graphic& rGraphic )
      51             :     throw()
      52             : {
      53           0 :     delete mpGraphic;
      54           0 :     mpGraphic = new ::Graphic( rGraphic );
      55           0 :     ::unographic::GraphicDescriptor::init( *mpGraphic );
      56           0 : }
      57             : 
      58             : 
      59             : 
      60           0 : uno::Any SAL_CALL Graphic::queryAggregation( const uno::Type& rType )
      61             :     throw( uno::RuntimeException, std::exception )
      62             : {
      63           0 :     uno::Any aAny;
      64           0 :     if( rType == ::getCppuType((const uno::Reference< graphic::XGraphic >*)0) )
      65           0 :         aAny <<= uno::Reference< graphic::XGraphic >( this );
      66           0 :     else if( rType == ::getCppuType((const uno::Reference< awt::XBitmap >*)0) )
      67           0 :         aAny <<= uno::Reference< awt::XBitmap >( this );
      68           0 :     else if( rType == ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0) )
      69           0 :         aAny <<= uno::Reference< lang::XUnoTunnel >(this);
      70             :     else
      71           0 :         aAny <<= ::unographic::GraphicDescriptor::queryAggregation( rType );
      72             : 
      73           0 :     return aAny ;
      74             : }
      75             : 
      76             : 
      77             : 
      78           0 : uno::Any SAL_CALL Graphic::queryInterface( const uno::Type & rType )
      79             :     throw( uno::RuntimeException, std::exception )
      80             : {
      81           0 :     ::com::sun::star::uno::Any aReturn = ::unographic::GraphicDescriptor::queryInterface( rType );
      82           0 :     if ( !aReturn.hasValue() )
      83           0 :         aReturn = ::cppu::queryInterface ( rType, static_cast< graphic::XGraphicTransformer*>( this ) );
      84           0 :     return aReturn;
      85             : }
      86             : 
      87             : 
      88             : 
      89           0 : void SAL_CALL Graphic::acquire()
      90             :     throw()
      91             : {
      92           0 :     ::unographic::GraphicDescriptor::acquire();
      93           0 : }
      94             : 
      95             : 
      96             : 
      97           0 : void SAL_CALL Graphic::release() throw()
      98             : {
      99           0 :     ::unographic::GraphicDescriptor::release();
     100           0 : }
     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 ] = ::getCppuType((const uno::Reference< graphic::XGraphic>*)0);
     155           0 :     aRet[ nOldCount+1 ] = ::getCppuType((const uno::Reference< awt::XBitmap>*)0);
     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           0 : ::sal_Int8 SAL_CALL Graphic::getType()
     171             :      throw (uno::RuntimeException, std::exception)
     172             : {
     173           0 :     ::sal_Int8 cRet = graphic::GraphicType::EMPTY;
     174             : 
     175           0 :     if( mpGraphic && ( mpGraphic->GetType() != GRAPHIC_NONE ) )
     176           0 :         cRet = ( ( mpGraphic->GetType() == GRAPHIC_BITMAP ) ? graphic::GraphicType::PIXEL : graphic::GraphicType::VECTOR );
     177             : 
     178           0 :     return cRet;
     179             : }
     180             : 
     181             : 
     182             : // XBitmap
     183             : 
     184             : 
     185           0 : awt::Size SAL_CALL Graphic::getSize(  ) throw (uno::RuntimeException, std::exception)
     186             : {
     187           0 :     SolarMutexGuard aGuard;
     188             : 
     189           0 :     ::Size aVclSize;
     190           0 :     if( mpGraphic && ( mpGraphic->GetType() != GRAPHIC_NONE ) )
     191           0 :         aVclSize = mpGraphic->GetSizePixel();
     192             : 
     193           0 :     return awt::Size( aVclSize.Width(), aVclSize.Height() );
     194             : }
     195             : 
     196             : 
     197             : 
     198           0 : uno::Sequence< ::sal_Int8 > SAL_CALL Graphic::getDIB(  ) throw (uno::RuntimeException, std::exception)
     199             : {
     200           0 :     SolarMutexGuard aGuard;
     201             : 
     202           0 :     if( mpGraphic && ( mpGraphic->GetType() != GRAPHIC_NONE ) )
     203             :     {
     204           0 :         SvMemoryStream aMem;
     205             : 
     206           0 :         WriteDIB(mpGraphic->GetBitmapEx().GetBitmap(), aMem, false, true);
     207           0 :         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           0 :     }
     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           0 : const ::Graphic* Graphic::getImplementation( const uno::Reference< uno::XInterface >& rxIFace )
     236             :     throw()
     237             : {
     238           0 :     uno::Reference< lang::XUnoTunnel > xTunnel( rxIFace, uno::UNO_QUERY );
     239           0 :     return( xTunnel.is() ? reinterpret_cast< ::Graphic* >( xTunnel->getSomething( ::Graphic::getUnoTunnelId() ) ) : NULL );
     240             : }
     241             : 
     242             : 
     243           0 : sal_Int64 SAL_CALL Graphic::getSomething( const uno::Sequence< sal_Int8 >& rId )
     244             :     throw( uno::RuntimeException, std::exception )
     245             : {
     246           0 :     return( ( rId.getLength() == 16 && 0 == memcmp( ::Graphic::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) ?
     247             :             reinterpret_cast< sal_Int64 >( mpGraphic ) :
     248           0 :             0 );
     249             : }
     250             : 
     251             : }
     252             : 
     253             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10