LCOV - code coverage report
Current view: top level - forms/source/component - imgprod.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 120 248 48.4 %
Date: 2014-04-11 Functions: 16 29 55.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             : 
      21             : #include "imgprod.hxx"
      22             : 
      23             : #include <vcl/bmpacc.hxx>
      24             : #include <vcl/cvtgrf.hxx>
      25             : #include <vcl/svapp.hxx>
      26             : #include <unotools/ucbstreamhelper.hxx>
      27             : #include <vcl/graphicfilter.hxx>
      28             : #include <com/sun/star/io/XInputStream.hpp>
      29             : 
      30             : #include "svtools/imageresourceaccess.hxx"
      31             : #include <comphelper/processfactory.hxx>
      32             : 
      33             : 
      34             : // - ImgProdLockBytes -
      35             : 
      36             : 
      37             : class ImgProdLockBytes : public SvLockBytes
      38             : {
      39             :     ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >      xStmRef;
      40             :     ::com::sun::star::uno::Sequence<sal_Int8>       maSeq;
      41             : 
      42             :                         ImgProdLockBytes() {};
      43             : 
      44             : public:
      45             : 
      46             :                         ImgProdLockBytes( SvStream* pStm, sal_Bool bOwner );
      47             :                         ImgProdLockBytes( ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > & rStreamRef );
      48             :     virtual             ~ImgProdLockBytes();
      49             : 
      50             :     virtual ErrCode     ReadAt( sal_uInt64 nPos, void* pBuffer, sal_Size nCount, sal_Size * pRead ) const SAL_OVERRIDE;
      51             :     virtual ErrCode     WriteAt( sal_uInt64 nPos, const void* pBuffer, sal_Size nCount, sal_Size * pWritten ) SAL_OVERRIDE;
      52             :     virtual ErrCode     Flush() const SAL_OVERRIDE;
      53             :     virtual ErrCode     SetSize( sal_uInt64 nSize ) SAL_OVERRIDE;
      54             :     virtual ErrCode     Stat( SvLockBytesStat*, SvLockBytesStatFlag ) const SAL_OVERRIDE;
      55             : };
      56             : 
      57             : 
      58             : 
      59           0 : ImgProdLockBytes::ImgProdLockBytes( SvStream* pStm, sal_Bool bOwner ) :
      60           0 :         SvLockBytes( pStm, bOwner )
      61             : {
      62           0 : }
      63             : 
      64             : 
      65             : 
      66           1 : ImgProdLockBytes::ImgProdLockBytes( ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > & rStmRef ) :
      67           1 :         xStmRef( rStmRef )
      68             : {
      69           1 :     if( xStmRef.is() )
      70             :     {
      71           1 :         const sal_uInt32    nBytesToRead = 65535;
      72             :         sal_uInt32          nRead;
      73             : 
      74           1 :         do
      75             :         {
      76           1 :             ::com::sun::star::uno::Sequence< sal_Int8 > aReadSeq;
      77             : 
      78           1 :             nRead = xStmRef->readSomeBytes( aReadSeq, nBytesToRead );
      79             : 
      80           1 :             if( nRead )
      81             :             {
      82           1 :                 const sal_uInt32 nOldLength = maSeq.getLength();
      83           1 :                 maSeq.realloc( nOldLength + nRead );
      84           1 :                 memcpy( maSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() );
      85           1 :             }
      86             :         }
      87             :         while( nBytesToRead == nRead );
      88             :     }
      89           1 : }
      90             : 
      91             : 
      92             : 
      93           3 : ImgProdLockBytes::~ImgProdLockBytes()
      94             : {
      95           3 : }
      96             : 
      97           4 : ErrCode ImgProdLockBytes::ReadAt(sal_uInt64 const nPos,
      98             :         void* pBuffer, sal_Size nCount, sal_Size * pRead) const
      99             : {
     100           4 :     if( GetStream() )
     101             :     {
     102           0 :         ( (SvStream*) GetStream() )->ResetError();
     103           0 :         const ErrCode nErr = SvLockBytes::ReadAt( nPos, pBuffer, nCount, pRead );
     104           0 :         ( (SvStream*) GetStream() )->ResetError();
     105           0 :         return nErr;
     106             :     }
     107             :     else
     108             :     {
     109           4 :         const sal_Size nSeqLen = maSeq.getLength();
     110           4 :         ErrCode nErr = ERRCODE_NONE;
     111             : 
     112           4 :         if( nPos < nSeqLen )
     113             :         {
     114           4 :             if( ( nPos + nCount ) > nSeqLen )
     115           1 :                 nCount = nSeqLen - nPos;
     116             : 
     117           4 :             memcpy( pBuffer, maSeq.getConstArray() + nPos, nCount );
     118           4 :             *pRead = nCount;
     119             :         }
     120             :         else
     121           0 :             *pRead = 0UL;
     122             : 
     123           4 :         return nErr;
     124             :     }
     125             : }
     126             : 
     127           0 : ErrCode ImgProdLockBytes::WriteAt(sal_uInt64 const nPos,
     128             :         const void* pBuffer, sal_Size nCount, sal_Size * pWritten)
     129             : {
     130           0 :     if( GetStream() )
     131           0 :         return SvLockBytes::WriteAt( nPos, pBuffer, nCount, pWritten );
     132             :     else
     133             :     {
     134             :         DBG_ASSERT( xStmRef.is(), "ImgProdLockBytes::WriteAt: xInputStream has no reference..." );
     135           0 :         return ERRCODE_IO_CANTWRITE;
     136             :     }
     137             : }
     138             : 
     139             : 
     140             : 
     141           1 : ErrCode ImgProdLockBytes::Flush() const
     142             : {
     143           1 :     return ERRCODE_NONE;
     144             : }
     145             : 
     146             : 
     147             : 
     148           0 : ErrCode ImgProdLockBytes::SetSize(sal_uInt64 const nSize)
     149             : {
     150           0 :     if( GetStream() )
     151           0 :         return SvLockBytes::SetSize( nSize );
     152             :     else
     153             :     {
     154             :         OSL_FAIL( "ImgProdLockBytes::SetSize not supported for xInputStream..." );
     155           0 :         return ERRCODE_IO_CANTWRITE;
     156             :     }
     157             : }
     158             : 
     159             : 
     160             : 
     161           1 : ErrCode ImgProdLockBytes::Stat( SvLockBytesStat* pStat, SvLockBytesStatFlag eFlag ) const
     162             : {
     163           1 :     if( GetStream() )
     164           0 :         return SvLockBytes::Stat( pStat, eFlag );
     165             :     else
     166             :     {
     167             :         DBG_ASSERT( xStmRef.is(), "ImgProdLockBytes::Stat: xInputStream has no reference..." );
     168           1 :         pStat->nSize = maSeq.getLength();
     169           1 :         return ERRCODE_NONE;
     170             :     }
     171             : }
     172             : 
     173             : // - ImageProducer -
     174          72 : ImageProducer::ImageProducer()
     175             :     : mpStm(NULL)
     176             :     , mnTransIndex(0)
     177          72 :     , mbConsInit(sal_False)
     178             : {
     179          72 :     mpGraphic = new Graphic;
     180          72 : }
     181             : 
     182         198 : ImageProducer::~ImageProducer()
     183             : {
     184          66 :     delete mpGraphic;
     185          66 :     mpGraphic = NULL;
     186             : 
     187          66 :     delete mpStm;
     188          66 :     mpStm = NULL;
     189         132 : }
     190             : 
     191             : // ::com::sun::star::uno::XInterface
     192           1 : ::com::sun::star::uno::Any ImageProducer::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     193             : {
     194             :     ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
     195             :                                         (static_cast< ::com::sun::star::lang::XInitialization* >(this)),
     196           1 :                                         (static_cast< ::com::sun::star::awt::XImageProducer* >(this)) );
     197           1 :     return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
     198             : }
     199             : 
     200             : 
     201             : 
     202           0 : void ImageProducer::addConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& rxConsumer )
     203             :     throw(::com::sun::star::uno::RuntimeException,
     204             :           std::exception)
     205             : {
     206             :     DBG_ASSERT( rxConsumer.is(), "::AddConsumer(...): No consumer referenced!" );
     207           0 :     if( rxConsumer.is() )
     208           0 :         maConsList.push_back( new ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > ( rxConsumer ));
     209           0 : }
     210             : 
     211             : 
     212             : 
     213           0 : void ImageProducer::removeConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& rxConsumer ) throw(::com::sun::star::uno::RuntimeException, std::exception)
     214             : {
     215           0 :     ConsumerList_t::reverse_iterator riter = std::find(maConsList.rbegin(),maConsList.rend(),rxConsumer);
     216             : 
     217           0 :     if (riter != maConsList.rend())
     218           0 :         maConsList.erase(riter.base()-1);
     219           0 : }
     220             : 
     221             : 
     222             : 
     223           1 : void ImageProducer::SetImage( const OUString& rPath )
     224             : {
     225           1 :     maURL = rPath;
     226           1 :     mpGraphic->Clear();
     227           1 :     mbConsInit = sal_False;
     228           1 :     delete mpStm;
     229             : 
     230           1 :     if ( ::svt::GraphicAccess::isSupportedURL( maURL ) )
     231             :     {
     232           0 :         mpStm = ::svt::GraphicAccess::getImageStream( ::comphelper::getProcessComponentContext(), maURL );
     233             :     }
     234           1 :     else if( !maURL.isEmpty() )
     235             :     {
     236           0 :         SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( maURL, STREAM_STD_READ );
     237           0 :         mpStm = pIStm ? new SvStream( new ImgProdLockBytes( pIStm, sal_True ) ) : NULL;
     238             :     }
     239             :     else
     240           1 :         mpStm = NULL;
     241           1 : }
     242             : 
     243             : 
     244             : 
     245           0 : void ImageProducer::SetImage( SvStream& rStm )
     246             : {
     247           0 :     maURL = OUString();
     248           0 :     mpGraphic->Clear();
     249           0 :     mbConsInit = sal_False;
     250             : 
     251           0 :     delete mpStm;
     252           0 :     mpStm = new SvStream( new ImgProdLockBytes( &rStm, sal_False ) );
     253           0 : }
     254             : 
     255             : 
     256             : 
     257           6 : void ImageProducer::setImage( ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > & rInputStmRef )
     258             : {
     259           6 :     maURL = OUString();
     260           6 :     mpGraphic->Clear();
     261           6 :     mbConsInit = sal_False;
     262           6 :     delete mpStm;
     263             : 
     264           6 :     if( rInputStmRef.is() )
     265           1 :         mpStm = new SvStream( new ImgProdLockBytes( rInputStmRef ) );
     266             :     else
     267           5 :         mpStm = NULL;
     268           6 : }
     269             : 
     270             : 
     271             : 
     272           0 : void ImageProducer::NewDataAvailable()
     273             : {
     274           0 :     if( ( GRAPHIC_NONE == mpGraphic->GetType() ) || mpGraphic->GetContext() )
     275           0 :         startProduction();
     276           0 : }
     277             : 
     278             : 
     279             : 
     280           6 : void ImageProducer::startProduction() throw(::com::sun::star::uno::RuntimeException, std::exception)
     281             : {
     282           6 :     if( !maConsList.empty() || maDoneHdl.IsSet() )
     283             :     {
     284           6 :         bool bNotifyEmptyGraphics = false;
     285             : 
     286             :         // valid stream or filled graphic? => update consumers
     287           6 :         if( mpStm || ( mpGraphic->GetType() != GRAPHIC_NONE ) )
     288             :         {
     289             :             // if we already have a graphic, we don't have to import again;
     290             :             // graphic is cleared if a new Stream is set
     291           1 :             if( ( mpGraphic->GetType() == GRAPHIC_NONE ) || mpGraphic->GetContext() )
     292             :             {
     293           1 :                 if ( ImplImportGraphic( *mpGraphic ) && maDoneHdl.IsSet() )
     294           1 :                     maDoneHdl.Call( mpGraphic );
     295             :             }
     296             : 
     297           1 :             if( mpGraphic->GetType() != GRAPHIC_NONE )
     298           1 :                 ImplUpdateData( *mpGraphic );
     299             :             else
     300           0 :                 bNotifyEmptyGraphics = true;
     301             :         }
     302             :         else
     303           5 :             bNotifyEmptyGraphics = true;
     304             : 
     305           6 :         if ( bNotifyEmptyGraphics )
     306             :         {
     307             :             // reset image
     308             :             // create temporary list to hold interfaces
     309           5 :             ConsumerList_t aTmp = maConsList;
     310             : 
     311             :             // iterate through interfaces
     312           5 :             for( ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter )
     313             :             {
     314           0 :                 (*iter)->init( 0, 0 );
     315           0 :                 (*iter)->complete( ::com::sun::star::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this );
     316             :             }
     317             : 
     318           5 :             if ( maDoneHdl.IsSet() )
     319           5 :                 maDoneHdl.Call( NULL );
     320             :         }
     321             :     }
     322           6 : }
     323             : 
     324             : 
     325             : 
     326           1 : sal_Bool ImageProducer::ImplImportGraphic( Graphic& rGraphic )
     327             : {
     328           1 :     if (!mpStm)
     329           0 :         return false;
     330             : 
     331           1 :     if( ERRCODE_IO_PENDING == mpStm->GetError() )
     332           0 :         mpStm->ResetError();
     333             : 
     334           1 :     mpStm->Seek( 0UL );
     335             : 
     336           1 :     sal_Bool bRet = GraphicConverter::Import( *mpStm, rGraphic ) == ERRCODE_NONE;
     337             : 
     338           1 :     if( ERRCODE_IO_PENDING == mpStm->GetError() )
     339           0 :         mpStm->ResetError();
     340             : 
     341           1 :     return bRet;
     342             : }
     343             : 
     344             : 
     345             : 
     346           1 : void ImageProducer::ImplUpdateData( const Graphic& rGraphic )
     347             : {
     348           1 :     ImplInitConsumer( rGraphic );
     349             : 
     350           1 :     if( mbConsInit && !maConsList.empty() )
     351             :     {
     352             :         // create temporary list to hold interfaces
     353           0 :         ConsumerList_t aTmp = maConsList;
     354             : 
     355           0 :         ImplUpdateConsumer( rGraphic );
     356           0 :         mbConsInit = sal_False;
     357             : 
     358             :         // iterate through interfaces
     359           0 :         for( ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter )
     360           0 :             (*iter)->complete( ::com::sun::star::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this );
     361             :     }
     362           1 : }
     363             : 
     364             : 
     365             : 
     366           1 : void ImageProducer::ImplInitConsumer( const Graphic& rGraphic )
     367             : {
     368           1 :     Bitmap              aBmp( rGraphic.GetBitmapEx().GetBitmap() );
     369           1 :     BitmapReadAccess*   pBmpAcc = aBmp.AcquireReadAccess();
     370             : 
     371           1 :     if( pBmpAcc )
     372             :     {
     373           1 :         sal_uInt16       nPalCount = 0;
     374           1 :         sal_uInt32       nRMask = 0;
     375           1 :         sal_uInt32       nGMask = 0;
     376           1 :         sal_uInt32       nBMask = 0;
     377           1 :         sal_uInt32       nAMask = 0;
     378           1 :         ::com::sun::star::uno::Sequence< sal_Int32 >    aRGBPal;
     379             : 
     380           1 :         if( pBmpAcc->HasPalette() )
     381             :         {
     382           1 :             nPalCount = pBmpAcc->GetPaletteEntryCount();
     383             : 
     384           1 :             if( nPalCount )
     385             :             {
     386           1 :                 aRGBPal = ::com::sun::star::uno::Sequence< sal_Int32 >( nPalCount + 1 );
     387             : 
     388           1 :                 sal_Int32* pTmp = aRGBPal.getArray();
     389             : 
     390         257 :                 for( sal_uInt32 i = 0; i < nPalCount; i++, pTmp++ )
     391             :                 {
     392         256 :                     const BitmapColor& rCol = pBmpAcc->GetPaletteColor( (sal_uInt16) i );
     393             : 
     394         256 :                     *pTmp = ( (sal_Int32) rCol.GetRed() ) << (sal_Int32)(24L);
     395         256 :                     *pTmp |= ( (sal_Int32) rCol.GetGreen() ) << (sal_Int32)(16L);
     396         256 :                     *pTmp |= ( (sal_Int32) rCol.GetBlue() ) << (sal_Int32)(8L);
     397         256 :                     *pTmp |= (sal_Int32)(0x000000ffL);
     398             :                 }
     399             : 
     400           1 :                 if( rGraphic.IsTransparent() )
     401             :                 {
     402             :                     // append transparent entry
     403           1 :                     *pTmp = (sal_Int32)(0xffffff00L);
     404           1 :                     mnTransIndex = nPalCount;
     405           1 :                     nPalCount++;
     406             :                 }
     407             :                 else
     408           0 :                     mnTransIndex = 0;
     409             : 
     410             :             }
     411             :         }
     412             :         else
     413             :         {
     414           0 :             nRMask = 0xff000000UL;
     415           0 :             nGMask = 0x00ff0000UL;
     416           0 :             nBMask = 0x0000ff00UL;
     417           0 :             nAMask = 0x000000ffUL;
     418             :         }
     419             : 
     420             :         // create temporary list to hold interfaces
     421           2 :         ConsumerList_t aTmp = maConsList;
     422             : 
     423             :         // iterate through interfaces
     424           1 :         for( ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter)
     425             :         {
     426           0 :             (*iter)->init( pBmpAcc->Width(), pBmpAcc->Height() );
     427           0 :             (*iter)->setColorModel( pBmpAcc->GetBitCount(),aRGBPal, nRMask, nGMask, nBMask, nAMask );
     428             :         }
     429             : 
     430           1 :         aBmp.ReleaseAccess( pBmpAcc );
     431           2 :         mbConsInit = sal_True;
     432           1 :     }
     433           1 : }
     434             : 
     435             : 
     436             : 
     437           0 : void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
     438             : {
     439           0 :     BitmapEx            aBmpEx( rGraphic.GetBitmapEx() );
     440           0 :     Bitmap              aBmp( aBmpEx.GetBitmap() );
     441           0 :     BitmapReadAccess*   pBmpAcc = aBmp.AcquireReadAccess();
     442             : 
     443           0 :     if( pBmpAcc )
     444             :     {
     445           0 :         Bitmap              aMask( aBmpEx.GetMask() );
     446           0 :         BitmapReadAccess*   pMskAcc = !!aMask ? aMask.AcquireReadAccess() : NULL;
     447           0 :         const long          nWidth = pBmpAcc->Width();
     448           0 :         const long          nHeight = pBmpAcc->Height();
     449           0 :         const long          nStartX = 0L;
     450           0 :         const long          nEndX = nWidth - 1L;
     451           0 :         const long          nStartY = 0L;
     452           0 :         const long          nEndY = nHeight - 1L;
     453           0 :         const long          nPartWidth = nEndX - nStartX + 1;
     454           0 :         const long          nPartHeight = nEndY - nStartY + 1;
     455             : 
     456           0 :         if( !pMskAcc )
     457             :         {
     458           0 :             aMask = Bitmap( aBmp.GetSizePixel(), 1 );
     459           0 :             aMask.Erase( COL_BLACK );
     460           0 :             pMskAcc = aMask.AcquireReadAccess();
     461             :         }
     462             : 
     463             :         // create temporary list to hold interfaces
     464           0 :         ConsumerList_t aTmp = maConsList;
     465             : 
     466           0 :         if( pBmpAcc->HasPalette() )
     467             :         {
     468           0 :             const BitmapColor aWhite( pMskAcc->GetBestMatchingColor( Color( COL_WHITE ) ) );
     469             : 
     470           0 :             if( mnTransIndex < 256 )
     471             :             {
     472           0 :                 ::com::sun::star::uno::Sequence<sal_Int8>   aData( nPartWidth * nPartHeight );
     473           0 :                 sal_Int8*                                   pTmp = aData.getArray();
     474             : 
     475           0 :                 for( long nY = nStartY; nY <= nEndY; nY++ )
     476             :                 {
     477           0 :                     for( long nX = nStartX; nX <= nEndX; nX++ )
     478             :                     {
     479           0 :                         if( pMskAcc->GetPixel( nY, nX ) == aWhite )
     480             :                             *pTmp++ = sal::static_int_cast< sal_Int8 >(
     481           0 :                                 mnTransIndex );
     482             :                         else
     483           0 :                             *pTmp++ = pBmpAcc->GetPixel( nY, nX ).GetIndex();
     484             :                     }
     485             :                 }
     486             : 
     487             :                 // iterate through interfaces
     488           0 :                 for (ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter)
     489           0 :                     (*iter)->setPixelsByBytes( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth );
     490             :             }
     491             :             else
     492             :             {
     493           0 :                 ::com::sun::star::uno::Sequence<sal_Int32>  aData( nPartWidth * nPartHeight );
     494           0 :                 sal_Int32*                                  pTmp = aData.getArray();
     495             : 
     496           0 :                 for( long nY = nStartY; nY <= nEndY; nY++ )
     497             :                 {
     498           0 :                     for( long nX = nStartX; nX <= nEndX; nX++ )
     499             :                     {
     500           0 :                         if( pMskAcc->GetPixel( nY, nX ) == aWhite )
     501           0 :                             *pTmp++ = mnTransIndex;
     502             :                         else
     503           0 :                             *pTmp++ = pBmpAcc->GetPixel( nY, nX ).GetIndex();
     504             :                     }
     505             :                 }
     506             : 
     507             :                 // iterate through interfaces
     508           0 :                 for (ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter)
     509           0 :                     (*iter)->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth );
     510           0 :             }
     511             :         }
     512             :         else
     513             :         {
     514           0 :             ::com::sun::star::uno::Sequence<sal_Int32>  aData( nPartWidth * nPartHeight );
     515           0 :             const BitmapColor                           aWhite( pMskAcc->GetBestMatchingColor( Color( COL_WHITE ) ) );
     516           0 :             sal_Int32*                                  pTmp = aData.getArray();
     517             : 
     518           0 :             for( long nY = nStartY; nY <= nEndY; nY++ )
     519             :             {
     520           0 :                 for( long nX = nStartX; nX <= nEndX; nX++, pTmp++ )
     521             :                 {
     522           0 :                     const BitmapColor aCol( pBmpAcc->GetPixel( nY, nX ) );
     523             : 
     524           0 :                     *pTmp = ( (sal_Int32) aCol.GetRed() ) << (sal_Int32)(24L);
     525           0 :                     *pTmp |= ( (sal_Int32) aCol.GetGreen() ) << (sal_Int32)(16L);
     526           0 :                     *pTmp |= ( (sal_Int32) aCol.GetBlue() ) << (sal_Int32)(8L);
     527             : 
     528           0 :                     if( pMskAcc->GetPixel( nY, nX ) != aWhite )
     529           0 :                         *pTmp |= 0x000000ffUL;
     530           0 :                 }
     531             :             }
     532             : 
     533             :             // iterate through interfaces
     534           0 :                 for (ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter)
     535           0 :                     (*iter)->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth );
     536             :         }
     537             : 
     538           0 :         aBmp.ReleaseAccess( pBmpAcc );
     539           0 :         aMask.ReleaseAccess( pMskAcc );
     540           0 :     }
     541           0 : }
     542             : 
     543           0 : void ImageProducer::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception)
     544             : {
     545           0 :     if ( aArguments.getLength() == 1 )
     546             :     {
     547           0 :         ::com::sun::star::uno::Any aArg = aArguments.getConstArray()[0];
     548           0 :         OUString aURL;
     549           0 :         if ( aArg >>= aURL )
     550             :         {
     551           0 :             SetImage( aURL );
     552           0 :         }
     553             :     }
     554           0 : }
     555             : 
     556             : namespace frm
     557             : {
     558             : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     559           0 : SAL_CALL ImageProducer_CreateInstance(
     560             :     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& )
     561             : {
     562             :     return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >(
     563           0 :         ( ::cppu::OWeakObject* ) new ImageProducer );
     564             : }
     565             : } // namespace frm
     566             : 
     567             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10