LCOV - code coverage report
Current view: top level - filter/source/flash - swfwriter2.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 299 0.0 %
Date: 2014-04-11 Functions: 0 39 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 "swfwriter.hxx"
      21             : #include <vcl/virdev.hxx>
      22             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      23             : 
      24             : #include <math.h>
      25             : 
      26             : using namespace ::swf;
      27             : using namespace ::std;
      28             : using namespace ::com::sun::star::uno;
      29             : using namespace ::com::sun::star::io;
      30             : 
      31             : 
      32             : 
      33           0 : sal_uInt16 getMaxBitsUnsigned( sal_uInt32 nValue )
      34             : {
      35           0 :     sal_uInt16 nBits = 0;
      36             : 
      37           0 :     while( nValue )
      38             :     {
      39           0 :         nBits++;
      40           0 :         nValue >>= 1;
      41             :     }
      42             : 
      43           0 :     return nBits;
      44             : }
      45             : 
      46             : 
      47             : 
      48           0 : sal_uInt16 getMaxBitsSigned( sal_Int32 nValue )
      49             : {
      50           0 :     if( nValue < 0 )
      51           0 :         nValue *= -1;
      52             : 
      53           0 :     return getMaxBitsUnsigned( static_cast< sal_uInt32 >(nValue) ) + 1;
      54             : }
      55             : 
      56             : 
      57             : 
      58           0 : BitStream::BitStream()
      59             : {
      60           0 :     mnBitPos = 8;
      61           0 :     mnCurrentByte = 0;
      62           0 : }
      63             : 
      64             : 
      65             : 
      66           0 : void BitStream::writeUB( sal_uInt32 nValue, sal_uInt16 nBits )
      67             : {
      68           0 :     while( nBits != 0 )
      69             :     {
      70           0 :         mnCurrentByte |= nValue << (32 - nBits) >> (32 - mnBitPos);
      71             : 
      72           0 :         if ( nBits > mnBitPos )
      73             :         {
      74           0 :             nBits = nBits - mnBitPos;
      75           0 :             mnBitPos = 0;
      76             :         }
      77             :         else
      78             :         {
      79           0 :             mnBitPos = sal::static_int_cast<sal_uInt8>( mnBitPos - nBits );
      80           0 :             nBits = 0;
      81             :         }
      82             : 
      83           0 :         if( 0 == mnBitPos )
      84           0 :             pad();
      85             :     }
      86           0 : }
      87             : 
      88             : 
      89             : 
      90           0 : void BitStream::writeSB( sal_Int32 nValue, sal_uInt16 nBits )
      91             : {
      92           0 :     writeUB( static_cast< sal_uInt32 >(nValue), nBits );
      93           0 : }
      94             : 
      95             : 
      96             : 
      97           0 : void BitStream::writeFB( sal_uInt32 nValue, sal_uInt16 nBits )
      98             : {
      99           0 :     writeUB( nValue, nBits );
     100           0 : }
     101             : 
     102             : 
     103             : 
     104           0 : void BitStream::pad()
     105             : {
     106           0 :     if( 8 != mnBitPos )
     107             :     {
     108           0 :         maData.push_back( mnCurrentByte );
     109           0 :         mnCurrentByte = 0;
     110           0 :         mnBitPos = 8;
     111             :     }
     112           0 : }
     113             : 
     114             : 
     115             : 
     116           0 : void BitStream::writeTo( SvStream& out )
     117             : {
     118           0 :     pad();
     119             : 
     120           0 :     vector< sal_uInt8 >::iterator aIter( maData.begin() );
     121           0 :     const vector< sal_uInt8>::iterator aEnd( maData.end() );
     122           0 :     while(aIter != aEnd)
     123             :     {
     124           0 :         out.WriteUChar( (*aIter++) );
     125             :     }
     126           0 : }
     127             : 
     128             : 
     129             : 
     130           0 : sal_uInt32 BitStream::getOffset() const
     131             : {
     132           0 :     return maData.size();
     133             : }
     134             : 
     135             : 
     136             : 
     137           0 : Tag::Tag( sal_uInt8 nTagId )
     138             : {
     139           0 :     mnTagId = nTagId;
     140           0 : }
     141             : 
     142             : 
     143             : 
     144           0 : void Tag::write( SvStream &out )
     145             : {
     146           0 :     Seek( STREAM_SEEK_TO_END );
     147           0 :     sal_uInt32 nSz = Tell();
     148           0 :     Seek( STREAM_SEEK_TO_BEGIN );
     149             : 
     150           0 :     if( mnTagId != 0xff )
     151             :     {
     152           0 :         bool bLarge = nSz > 62;
     153             : 
     154           0 :         sal_uInt16 nCode = ( mnTagId << 6 ) | ( bLarge ? 0x3f : _uInt16(nSz) );
     155             : 
     156           0 :         out.WriteUChar( (sal_uInt8)nCode );
     157           0 :         out.WriteUChar( (sal_uInt8)(nCode >> 8) );
     158             : 
     159           0 :         if( bLarge )
     160             :         {
     161           0 :             sal_uInt32 nTmp = nSz;
     162             : 
     163           0 :             out.WriteUChar( (sal_uInt8)nTmp );
     164           0 :             nTmp >>= 8;
     165           0 :             out.WriteUChar( (sal_uInt8)nTmp );
     166           0 :             nTmp >>= 8;
     167           0 :             out.WriteUChar( (sal_uInt8)nTmp );
     168           0 :             nTmp >>= 8;
     169           0 :             out.WriteUChar( (sal_uInt8)nTmp );
     170             :         }
     171             :     }
     172             : 
     173           0 :     out.Write( GetData(), nSz );
     174           0 : }
     175             : #if 0
     176             : 
     177             : 
     178             : void Tag::addI32( sal_Int32 nValue )
     179             : {
     180             :     addUI32( static_cast<sal_uInt32>( nValue ) );
     181             : }
     182             : #endif
     183             : 
     184             : 
     185           0 : void Tag::addUI32( sal_uInt32 nValue )
     186             : {
     187           0 :     WriteUInt32( nValue );
     188           0 : }
     189             : #if 0
     190             : 
     191             : 
     192             : void Tag::addI16( sal_Int16 nValue )
     193             : {
     194             :     addUI16( static_cast<sal_uInt16>( nValue ) );
     195             : }
     196             : #endif
     197             : 
     198             : 
     199           0 : void Tag::addUI16( sal_uInt16 nValue )
     200             : {
     201           0 :     WriteUChar( (sal_uInt8)nValue );
     202           0 :     WriteUChar( (sal_uInt8)(nValue >> 8) );
     203           0 : }
     204             : 
     205             : 
     206             : 
     207           0 : void Tag::addUI8( sal_uInt8 nValue )
     208             : {
     209           0 :     WriteUChar( (sal_uInt8)nValue );
     210           0 : }
     211             : 
     212             : 
     213             : 
     214           0 : void Tag::addBits( BitStream& rIn )
     215             : {
     216           0 :     rIn.writeTo( *this );
     217           0 : }
     218             : 
     219             : 
     220             : 
     221           0 : void Tag::addRGBA( const Color& rColor )
     222             : {
     223           0 :     addUI8( rColor.GetRed() );
     224           0 :     addUI8( rColor.GetGreen() );
     225           0 :     addUI8( rColor.GetBlue() );
     226           0 :     addUI8( 0xff - rColor.GetTransparency() );
     227           0 : }
     228             : 
     229             : 
     230             : 
     231           0 : void Tag::addRGB( const Color& rColor )
     232             : {
     233           0 :     addUI8( rColor.GetRed() );
     234           0 :     addUI8( rColor.GetGreen() );
     235           0 :     addUI8( rColor.GetBlue() );
     236           0 : }
     237             : 
     238             : 
     239             : 
     240           0 : void Tag::addRect( const Rectangle& rRect )
     241             : {
     242           0 :     writeRect( *this, rRect );
     243           0 : }
     244             : 
     245             : 
     246             : 
     247           0 : void Tag::writeRect( SvStream& rOut, const Rectangle& rRect )
     248             : {
     249           0 :     BitStream aBits;
     250             : 
     251             :     sal_Int32 minX, minY, maxX, maxY;
     252             : 
     253           0 :     if( rRect.Left() < rRect.Right() )
     254             :     {
     255           0 :         minX = rRect.Left();
     256           0 :         maxX = rRect.Right();
     257             :     }
     258             :     else
     259             :     {
     260           0 :         maxX = rRect.Left();
     261           0 :         minX = rRect.Right();
     262             :     }
     263             : 
     264             : 
     265           0 :     if( rRect.Top() < rRect.Bottom() )
     266             :     {
     267           0 :         minY = rRect.Top();
     268           0 :         maxY = rRect.Bottom();
     269             :     }
     270             :     else
     271             :     {
     272           0 :         maxY = rRect.Top();
     273           0 :         minY = rRect.Bottom();
     274             :     }
     275             : 
     276             :     // AS: Figure out the maximum nubmer of bits required to represent any of the
     277             :     //  rectangle coordinates.  Since minX or minY could be negative, they could
     278             :     //  actually require more bits than maxX or maxY.
     279             :     // AS: Christian, can they be negative, or is that a wasted check?
     280             :     // CL: I think so, f.e. for shapes that have the top and/or left edge outside
     281             :     //         the page origin
     282           0 :     sal_uInt8 nBits1 = sal::static_int_cast<sal_uInt8>( max( getMaxBitsSigned( minX ), getMaxBitsSigned( minY ) ) );
     283           0 :     sal_uInt8 nBits2 = sal::static_int_cast<sal_uInt8>( max( getMaxBitsSigned( maxX ), getMaxBitsSigned( maxY ) ) );
     284           0 :     sal_uInt8 nBitsMax = max( nBits1, nBits2 );
     285             : 
     286           0 :     aBits.writeUB( nBitsMax, 5 );
     287           0 :     aBits.writeSB( minX, nBitsMax );
     288           0 :     aBits.writeSB( maxX, nBitsMax );
     289           0 :     aBits.writeSB( minY, nBitsMax );
     290           0 :     aBits.writeSB( maxY, nBitsMax );
     291             : 
     292           0 :     aBits.writeTo( rOut );
     293           0 : }
     294             : 
     295             : 
     296             : 
     297           0 : void Tag::addMatrix( const ::basegfx::B2DHomMatrix& rMatrix ) // #i73264#
     298             : {
     299           0 :     writeMatrix( *this, rMatrix );
     300           0 : }
     301             : 
     302             : 
     303             : 
     304           0 : void Tag::writeMatrix( SvStream& rOut, const ::basegfx::B2DHomMatrix& rMatrix ) // #i73264#
     305             : {
     306             : 
     307           0 :     BitStream aBits;
     308             : 
     309           0 :     const sal_uInt8 bHasScale = rMatrix.get(0, 0) != 1.0 || rMatrix.get(1, 1) != 1.0;
     310             : 
     311           0 :     aBits.writeUB( bHasScale, 1 );
     312             : 
     313           0 :     if( bHasScale )
     314             :     {
     315           0 :         sal_uInt8 nScaleBits = 31;
     316             : 
     317           0 :         aBits.writeUB( nScaleBits, 5 );
     318           0 :         aBits.writeFB( getFixed( rMatrix.get(0, 0) ), nScaleBits ); // Scale X
     319           0 :         aBits.writeFB( getFixed( rMatrix.get(1, 1) ), nScaleBits ); // Scale Y
     320             :     }
     321             : 
     322           0 :     const sal_uInt8 bHasRotate = rMatrix.get(0, 1) != 0.0 || rMatrix.get(1, 0) != 0.0;
     323             : 
     324           0 :     aBits.writeUB( bHasRotate, 1 );
     325             : 
     326           0 :     if( bHasRotate )
     327             :     {
     328           0 :         sal_uInt8 nRotateBits = 31;
     329             : 
     330           0 :         aBits.writeUB( nRotateBits, 5 );
     331           0 :         aBits.writeFB( getFixed( rMatrix.get(0, 1) ), nRotateBits );    // RotateSkew0
     332           0 :         aBits.writeFB( getFixed( rMatrix.get(1, 0) ), nRotateBits );    // RotateSkew1
     333             :     }
     334             : 
     335           0 :     sal_uInt8 nTranslateBits = 16;
     336             : 
     337           0 :     aBits.writeUB( nTranslateBits, 5 );
     338           0 :     aBits.writeSB( (sal_Int16)rMatrix.get(0, 2), nTranslateBits );      // Translate X
     339           0 :     aBits.writeSB( (sal_Int16)rMatrix.get(1, 2), nTranslateBits );      // Translate Y
     340             : 
     341           0 :     aBits.writeTo( rOut );
     342           0 : }
     343             : 
     344             : 
     345             : 
     346           0 : void Tag::addString( const char* pString )
     347             : {
     348           0 :     if( pString )
     349             :     {
     350           0 :         while( *pString )
     351           0 :             addUI8( *pString++ );
     352             :     }
     353             : 
     354           0 :     addUI8( 0 );
     355           0 : }
     356             : 
     357             : 
     358             : 
     359           0 : void Tag::addStream( SvStream& rIn )
     360             : {
     361           0 :     (*this).WriteStream( rIn );
     362           0 : }
     363             : 
     364             : 
     365             : 
     366           0 : Sprite::Sprite( sal_uInt16 nId )
     367           0 : : mnId( nId ), mnFrames(0)
     368             : {
     369           0 : }
     370             : 
     371             : 
     372             : 
     373           0 : Sprite::~Sprite()
     374             : {
     375           0 :     for(vector< Tag* >::iterator i = maTags.begin(); i != maTags.end(); ++i)
     376           0 :         delete *i;
     377           0 : }
     378             : 
     379             : 
     380             : 
     381           0 : void Sprite::write( SvStream& out )
     382             : {
     383           0 :     SvMemoryStream aTmp;
     384           0 :     for(vector< Tag* >::iterator i = maTags.begin(); i != maTags.end(); ++i)
     385           0 :         (*i)->write( aTmp );
     386             : 
     387           0 :     if( !mnFrames )
     388           0 :         mnFrames = 1;
     389             : 
     390           0 :     aTmp.Seek(0);
     391             : 
     392           0 :     Tag aTag( TAG_DEFINESPRITE );
     393           0 :     aTag.addUI16( mnId );
     394           0 :     aTag.addUI16( _uInt16( mnFrames ) );
     395           0 :     aTag.addStream( aTmp );
     396           0 :     aTag.write( out );
     397           0 : }
     398             : 
     399             : 
     400             : 
     401           0 : void Sprite::addTag( Tag* pNewTag )
     402             : {
     403           0 :     if( pNewTag )
     404             :     {
     405           0 :         if( pNewTag->getTagId() == TAG_SHOWFRAME )
     406           0 :             mnFrames++;
     407             : 
     408           0 :         maTags.push_back( pNewTag );
     409             :     }
     410           0 : }
     411             : 
     412             : 
     413             : 
     414           0 : sal_uInt32 swf::getFixed( double fValue )
     415             : {
     416           0 :     sal_Int16 nUpper = (sal_Int16)floor(fValue);
     417           0 :     sal_uInt16 nLower = (sal_uInt16)((fValue - floor(fValue))*0x10000);
     418             : 
     419           0 :     sal_uInt32 temp = ((sal_Int32)nUpper)<<16;
     420           0 :     temp |= nLower;
     421             : 
     422           0 :     return temp;
     423             : }
     424             : 
     425             : 
     426             : 
     427             : /** constructs a new flash font for the given VCL Font */
     428           0 : FlashFont::FlashFont( const Font& rFont, sal_uInt16 nId )
     429           0 : : maFont( rFont ), mnNextIndex(0), mnId( nId )
     430             : {
     431           0 : }
     432             : 
     433             : 
     434             : 
     435           0 : FlashFont::~FlashFont()
     436             : {
     437           0 : }
     438             : 
     439             : 
     440             : 
     441             : /** gets the glyph id for the given character. The glyphs are created on demand */
     442           0 : sal_uInt16 FlashFont::getGlyph( sal_uInt16 nChar, VirtualDevice* pVDev )
     443             : {
     444             :     // see if we already created a glyph for this character
     445           0 :     std::map<sal_uInt16, sal_uInt16, ltuint16>::iterator aIter( maGlyphIndex.find(nChar) );
     446           0 :     if( aIter != maGlyphIndex.end() )
     447             :     {
     448           0 :         return aIter->second;
     449             :     }
     450             : 
     451             :     // if not, we create one now
     452             : 
     453           0 :     maGlyphIndex[nChar] = mnNextIndex;
     454             : 
     455           0 :     Font aOldFont( pVDev->GetFont() );
     456           0 :     Font aNewFont( aOldFont );
     457           0 :     aNewFont.SetAlign( ALIGN_BASELINE );
     458           0 :     pVDev->SetFont( aNewFont );
     459           0 :     aOldFont.SetOrientation(0);
     460             : 
     461             :     // let the virtual device convert the character to polygons
     462           0 :     PolyPolygon aPolyPoly;
     463           0 :     pVDev->GetTextOutline( aPolyPoly, OUString(nChar) );
     464             : 
     465           0 :     maGlyphOffsets.push_back( _uInt16( maGlyphData.getOffset() ) );
     466             : 
     467             :     // Number of fill and line index bits set to 1
     468           0 :     maGlyphData.writeUB( 0x11, 8 );
     469             : 
     470           0 :     const sal_uInt16 nCount = aPolyPoly.Count();
     471             :     sal_uInt16 i,n;
     472           0 :     for( i = 0; i < nCount; i++ )
     473             :     {
     474           0 :         Polygon& rPoly = aPolyPoly[ i ];
     475             : 
     476           0 :         const sal_uInt16 nSize = rPoly.GetSize();
     477           0 :         if( nSize )
     478             :         {
     479             :             // convert polygon to flash EM_SQUARE (1024x1024)
     480           0 :             for( n = 0; n < nSize; n++ )
     481             :             {
     482           0 :                 Point aPoint( rPoly[n] );
     483           0 :                 aPoint.X() = static_cast<long>((double(aPoint.X()) * 1024.0 ) / double(aOldFont.GetHeight()));
     484           0 :                 aPoint.Y() = static_cast<long>((double(aPoint.Y()) * 1024.0 ) / double(aOldFont.GetHeight()));
     485           0 :                 rPoly[n] = aPoint;
     486             :             }
     487           0 :             Writer::Impl_addPolygon( maGlyphData, rPoly, true );
     488             :         }
     489             :     }
     490           0 :     Writer::Impl_addEndShapeRecord( maGlyphData );
     491             : 
     492           0 :     maGlyphData.pad();
     493             : 
     494           0 :     pVDev->SetFont( aOldFont );
     495             : 
     496           0 :     return mnNextIndex++;
     497             : }
     498             : 
     499             : 
     500             : 
     501           0 : void FlashFont::write( SvStream& out )
     502             : {
     503           0 :     Tag aTag( TAG_DEFINEFONT );
     504             : 
     505           0 :     aTag.addUI16( mnId );
     506             : 
     507           0 :     sal_uInt16 nGlyphs = _uInt16( maGlyphOffsets.size() );
     508           0 :     sal_uInt16 nOffset = nGlyphs * sizeof( sal_uInt16 );
     509             : 
     510           0 :     for(vector< sal_uInt16 >::iterator i = maGlyphOffsets.begin(); i != maGlyphOffsets.end(); ++i)
     511           0 :         aTag.addUI16( nOffset + (*i) );
     512             : 
     513           0 :     aTag.addBits( maGlyphData );
     514             : 
     515           0 :     aTag.write( out );
     516           0 : }
     517             : 
     518             : 
     519             : 
     520             : /** this c'tor creates a solid fill style */
     521           0 : FillStyle::FillStyle( const Color& rSolidColor )
     522             :     : meType(solid )
     523             :     , mnBitmapId(0)
     524           0 :     , maColor(rSolidColor)
     525             : {
     526           0 : }
     527             : 
     528             : 
     529             : 
     530             : /** this c'tor creates a tiled or clipped bitmap fill style */
     531           0 : FillStyle::FillStyle( sal_uInt16 nBitmapId, bool bClipped, const ::basegfx::B2DHomMatrix& rMatrix ) // #i73264#
     532             : :   meType( bClipped ? clipped_bitmap : tiled_bitmap ),
     533             :     maMatrix( rMatrix ),
     534           0 :     mnBitmapId( nBitmapId )
     535             : {
     536           0 : }
     537             : 
     538             : 
     539             : 
     540           0 : FillStyle::FillStyleType Impl_getFillStyleType( const Gradient& rGradient )
     541             : {
     542           0 :     switch( rGradient.GetStyle() )
     543             :     {
     544             :     case GradientStyle_ELLIPTICAL:
     545             :     case GradientStyle_RADIAL:
     546           0 :         return FillStyle::radial_gradient;
     547             : //  case GradientStyle_AXIAL:
     548             : //  case GradientStyle_SQUARE:
     549             : //  case GradientStyle_RECT:
     550             : //  case GradientStyle_LINEAR:
     551             :     default:
     552           0 :         return FillStyle::linear_gradient;
     553             :     }
     554             : }
     555             : 
     556             : 
     557             : 
     558             : /** this c'tor creates a linear or radial gradient fill style */
     559           0 : FillStyle::FillStyle( const Rectangle& rBoundRect, const Gradient& rGradient )
     560           0 :     : meType(Impl_getFillStyleType(rGradient))
     561             :     , mnBitmapId(0)
     562             :     , maGradient(rGradient)
     563           0 :     , maBoundRect(rBoundRect)
     564             : {
     565           0 : }
     566             : 
     567             : 
     568             : 
     569           0 : void FillStyle::addTo( Tag* pTag ) const
     570             : {
     571           0 :     pTag->addUI8( sal::static_int_cast<sal_uInt8>( meType ) );
     572           0 :     switch( meType )
     573             :     {
     574             :     case solid:
     575           0 :         pTag->addRGBA( maColor );
     576           0 :         break;
     577             :     case linear_gradient:
     578             :     case radial_gradient:
     579           0 :         Impl_addGradient( pTag );
     580           0 :         break;
     581             :     case tiled_bitmap:
     582             :     case clipped_bitmap:
     583           0 :         pTag->addUI16( mnBitmapId );
     584           0 :         pTag->addMatrix( maMatrix );
     585           0 :         break;
     586             :     }
     587           0 : }
     588             : 
     589             : 
     590             : 
     591             : struct GradRecord
     592             : {
     593             :     sal_uInt8   mnRatio;
     594             :     Color       maColor;
     595             : 
     596           0 :     GradRecord( sal_uInt8 nRatio, const Color& rColor ) : mnRatio( nRatio ), maColor( rColor ) {}
     597             : };
     598             : 
     599             : // TODO: better emulation of our gradients
     600           0 : void FillStyle::Impl_addGradient( Tag* pTag ) const
     601             : {
     602           0 :     vector< struct GradRecord > aGradientRecords;
     603           0 :     basegfx::B2DHomMatrix m(basegfx::tools::createRotateB2DHomMatrix((maGradient.GetAngle() - 900) * F_PI1800));
     604             : 
     605           0 :     switch( maGradient.GetStyle() )
     606             :     {
     607             :     case GradientStyle_ELLIPTICAL:
     608             :     case GradientStyle_RADIAL:
     609             :         {
     610           0 :             aGradientRecords.push_back( GradRecord( 0x00, maGradient.GetEndColor() ) );
     611           0 :             aGradientRecords.push_back( GradRecord( 0xff, maGradient.GetStartColor() ) );
     612             : 
     613           0 :             double tx = ( maGradient.GetOfsX() * 32768.0 ) / 100.0;
     614           0 :             double ty = ( maGradient.GetOfsY() * 32768.0 ) / 100.0;
     615           0 :             double scalex = (double)maBoundRect.GetWidth() / 32768.0;
     616           0 :             double scaley = (double)maBoundRect.GetHeight() / 32768.0;
     617             : 
     618           0 :             m.scale( 1.2, 1.2 );
     619             : 
     620           0 :             if( scalex > scaley )
     621             :             {
     622           0 :                 double scale_move = scaley / scalex;
     623             : 
     624           0 :                 m.translate( tx, scale_move * ty );
     625             : 
     626             : 
     627           0 :                 m.scale( scalex, scalex );
     628             :             }
     629             :             else
     630             :             {
     631           0 :                 double scale_move = scalex / scaley;
     632             : 
     633           0 :                 m.translate( scale_move * tx, ty );
     634             : 
     635             : 
     636           0 :                 m.scale( scaley, scaley );
     637             :             }
     638             : 
     639             :         }
     640           0 :         break;
     641             :     case GradientStyle_AXIAL:
     642             :         {
     643           0 :             aGradientRecords.push_back( GradRecord( 0x00, maGradient.GetEndColor() ) );
     644           0 :             aGradientRecords.push_back( GradRecord( 0x80, maGradient.GetStartColor() ) );
     645           0 :             aGradientRecords.push_back( GradRecord( 0xff, maGradient.GetEndColor() ) );
     646           0 :             double tx = ( 32768.0 / 2.0 );
     647           0 :             double ty = ( 32768.0 / 2.0 );
     648           0 :             double scalex = (double)maBoundRect.GetWidth() / 32768.0;
     649           0 :             double scaley = (double)maBoundRect.GetHeight() / 32768.0;
     650             : 
     651           0 :             m.translate( tx, ty );
     652           0 :             m.scale( scalex, scaley );
     653             :         }
     654           0 :         break;
     655             :     case GradientStyle_SQUARE:
     656             :     case GradientStyle_RECT:
     657             :     case GradientStyle_LINEAR:
     658             :         {
     659           0 :             aGradientRecords.push_back( GradRecord( 0x00, maGradient.GetStartColor() ) );
     660           0 :             aGradientRecords.push_back( GradRecord( 0xff, maGradient.GetEndColor() ) );
     661           0 :             double scalex = (double)maBoundRect.GetWidth() / 32768.0;
     662           0 :             double scaley = (double)maBoundRect.GetHeight() / 32768.0;
     663             : 
     664           0 :             m.scale( scalex, scaley );
     665             : 
     666           0 :             m.translate( maBoundRect.GetWidth() / 2.0, maBoundRect.GetHeight() / 2.0 );
     667             :         }
     668           0 :         break;
     669           0 :     case  GradientStyle_FORCE_EQUAL_SIZE: break;
     670             :     }
     671             : 
     672           0 :     m.translate( maBoundRect.Left(), maBoundRect.Top() );
     673             : 
     674           0 :     pTag->addMatrix( m );
     675             : 
     676             :     DBG_ASSERT( aGradientRecords.size() < 8, "Illegal FlashGradient!" );
     677             : 
     678           0 :     pTag->addUI8( static_cast<sal_uInt8>( aGradientRecords.size() ) );
     679             : 
     680           0 :     for(std::vector< GradRecord >::iterator i = aGradientRecords.begin(); i != aGradientRecords.end(); ++i)
     681             :     {
     682           0 :         pTag->addUI8( (*i).mnRatio );
     683           0 :         pTag->addRGBA( (*i).maColor );
     684           0 :     }
     685           0 : }
     686             : 
     687             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10