Author: hdu
Date: Thu Dec 12 14:08:12 2013
New Revision: 1550420

URL: http://svn.apache.org/r1550420
Log:
#i123840# fix narrowing conversions in CoreGraphic's array initializers

C++11 says that narrowing conversions in array initializers are illegal.
This often happened for signed/unsigned and 32bit/64bit mismatches when
initializing CoreGraphics elementary types. Using CoreGraphic helper
methods for primitives solves these problems and is recommended anyway.

Modified:
    openoffice/trunk/main/vcl/aqua/source/gdi/salgdi.cxx

Modified: openoffice/trunk/main/vcl/aqua/source/gdi/salgdi.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/vcl/aqua/source/gdi/salgdi.cxx?rev=1550420&r1=1550419&r2=1550420&view=diff
==============================================================================
--- openoffice/trunk/main/vcl/aqua/source/gdi/salgdi.cxx (original)
+++ openoffice/trunk/main/vcl/aqua/source/gdi/salgdi.cxx Thu Dec 12 14:08:12 
2013
@@ -592,7 +592,7 @@ bool AquaSalGraphics::setClipRegion( con
 
                 if(nH)
                 {
-                    CGRect aRect = {{ aRectIter->Left(), aRectIter->Top() }, { 
nW, nH }};
+                    const CGRect aRect = CGRectMake( aRectIter->Left(), 
aRectIter->Top(), nW, nH);
                     CGPathAddRect( mxClipPath, NULL, aRect );
                 }
             }
@@ -676,7 +676,7 @@ void AquaSalGraphics::ImplDrawPixel( lon
        // overwrite the fill color
        CGContextSetFillColor( mrContext, rColor.AsArray() );
        // draw 1x1 rect, there is no pixel drawing in Quartz
-       CGRect aDstRect = {{nX,nY,},{1,1}};
+       const CGRect aDstRect = CGRectMake( nX, nY, 1, 1);
        CGContextFillRect( mrContext, aDstRect );
     RefreshRect( aDstRect );
     // reset the fill color
@@ -1133,7 +1133,7 @@ void AquaSalGraphics::copyBits( const Sa
 
        DBG_ASSERT( pSrc->mxLayer!=NULL, "AquaSalGraphics::copyBits() from 
non-layered graphics" );
 
-       const CGPoint aDstPoint = { +rPosAry.mnDestX - rPosAry.mnSrcX, 
rPosAry.mnDestY - rPosAry.mnSrcY };
+       const CGPoint aDstPoint = CGPointMake( +rPosAry.mnDestX - 
rPosAry.mnSrcX, rPosAry.mnDestY - rPosAry.mnSrcY);
        if( (rPosAry.mnSrcWidth == rPosAry.mnDestWidth && rPosAry.mnSrcHeight 
== rPosAry.mnDestHeight) &&
            (!mnBitmapDepth || (aDstPoint.x + pSrc->mnWidth) <= mnWidth) ) // 
workaround a Quartz crasher
     {
@@ -1145,7 +1145,7 @@ void AquaSalGraphics::copyBits( const Sa
                            xCopyContext = mpXorEmulation->GetTargetContext();
 
            CGContextSaveGState( xCopyContext );
-           const CGRect aDstRect = { {rPosAry.mnDestX, rPosAry.mnDestY}, 
{rPosAry.mnDestWidth, rPosAry.mnDestHeight} };
+           const CGRect aDstRect = CGRectMake( rPosAry.mnDestX, 
rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight);
            CGContextClipToRect( xCopyContext, aDstRect );
 
            // draw at new destination
@@ -1211,10 +1211,10 @@ void AquaSalGraphics::copyArea( long nDs
        CGLayerRef xSrcLayer = mxLayer;
        // TODO: if( mnBitmapDepth > 0 )
        {
-               const CGSize aSrcSize = { nSrcWidth, nSrcHeight };
+               const CGSize aSrcSize = CGSizeMake( nSrcWidth, nSrcHeight);
                xSrcLayer = ::CGLayerCreateWithContext( xCopyContext, aSrcSize, 
NULL );
                const CGContextRef xSrcContext = CGLayerGetContext( xSrcLayer );
-               CGPoint aSrcPoint = { -nSrcX, -nSrcY };
+               CGPoint aSrcPoint = CGPointMake( -nSrcX, -nSrcY);
                if( IsFlipped() )
                {
                        ::CGContextTranslateCTM( xSrcContext, 0, +nSrcHeight );
@@ -1225,7 +1225,7 @@ void AquaSalGraphics::copyArea( long nDs
        }
 
        // draw at new destination
-       const CGPoint aDstPoint = { +nDstX, +nDstY };
+       const CGPoint aDstPoint = CGPointMake( +nDstX, +nDstY);
        ::CGContextDrawLayerAtPoint( xCopyContext, aDstPoint, xSrcLayer );
 
        // cleanup
@@ -1249,7 +1249,7 @@ void AquaSalGraphics::drawBitmap( const 
        if( !xImage )
                return;
 
-       const CGRect aDstRect = {{rPosAry.mnDestX, rPosAry.mnDestY}, 
{rPosAry.mnDestWidth, rPosAry.mnDestHeight}};
+       const CGRect aDstRect = CGRectMake( rPosAry.mnDestX, rPosAry.mnDestY, 
rPosAry.mnDestWidth, rPosAry.mnDestHeight);
        CGContextDrawImage( mrContext, aDstRect, xImage );
        CGImageRelease( xImage );
        RefreshRect( aDstRect );
@@ -1259,7 +1259,7 @@ void AquaSalGraphics::drawBitmap( const 
 
 void AquaSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& 
rSalBitmap,SalColor )
 {
-       DBG_ERROR("not implemented for color masking!");
+       DBG_ERROR( "not implemented for color masking!");
        drawBitmap( rPosAry, rSalBitmap );
 }
 
@@ -1276,7 +1276,7 @@ void AquaSalGraphics::drawBitmap( const 
        if( !xMaskedImage )
                return;
 
-       const CGRect aDstRect = {{rPosAry.mnDestX, rPosAry.mnDestY}, 
{rPosAry.mnDestWidth, rPosAry.mnDestHeight}};
+       const CGRect aDstRect = CGRectMake( rPosAry.mnDestX, rPosAry.mnDestY, 
rPosAry.mnDestWidth, rPosAry.mnDestHeight);
        CGContextDrawImage( mrContext, aDstRect, xMaskedImage );
        CGImageRelease( xMaskedImage );
        RefreshRect( aDstRect );
@@ -1294,7 +1294,7 @@ void AquaSalGraphics::drawMask( const Sa
        if( !xImage )
                return;
 
-       const CGRect aDstRect = {{rPosAry.mnDestX, rPosAry.mnDestY}, 
{rPosAry.mnDestWidth, rPosAry.mnDestHeight}};
+       const CGRect aDstRect = CGRectMake( rPosAry.mnDestX, rPosAry.mnDestY, 
rPosAry.mnDestWidth, rPosAry.mnDestHeight);
        CGContextDrawImage( mrContext, aDstRect, xImage );
        CGImageRelease( xImage );
        RefreshRect( aDstRect );
@@ -1348,7 +1348,7 @@ SalColor AquaSalGraphics::getPixel( long
        // copy the requested pixel into the bitmap context
        if( IsFlipped() )
                nY = mnHeight - nY;
-       const CGPoint aCGPoint = {-nX, -nY};
+       const CGPoint aCGPoint = CGPointMake( -nX, -nY);
        CGContextDrawLayerAtPoint( xOnePixelContext, aCGPoint, mxLayer );
        CGContextRelease( xOnePixelContext );
 
@@ -1485,7 +1485,7 @@ sal_Bool AquaSalGraphics::drawEPS( long 
        [NSGraphicsContext setCurrentContext: pDrawNSCtx];
        
        // draw the EPS
-       const NSRect aDstRect = {{nX,nY},{nWidth,nHeight}};
+       const NSRect aDstRect = NSMakeRect( nX, nY, nWidth, nHeight);
        const BOOL bOK = [xEpsImage drawInRect: aDstRect];
 
        // restore the NSGraphicsContext
@@ -1521,7 +1521,7 @@ bool AquaSalGraphics::drawAlphaBitmap( c
 
     if ( CheckContext() )
     {
-               const CGRect aDstRect = {{rTR.mnDestX, rTR.mnDestY}, 
{rTR.mnDestWidth, rTR.mnDestHeight}};
+               const CGRect aDstRect = CGRectMake( rTR.mnDestX, rTR.mnDestY, 
rTR.mnDestWidth, rTR.mnDestHeight);
                CGContextDrawImage( mrContext, aDstRect, xMaskedImage );
                RefreshRect( aDstRect );
     }
@@ -1562,7 +1562,7 @@ bool AquaSalGraphics::drawTransformedBit
        CGContextConcatCTM( mrContext, aCGMat );
 
        // draw the transformed image
-       const CGRect aSrcRect = {{0,0}, {aSize.Width(), aSize.Height()}};
+       const CGRect aSrcRect = CGRectMake( 0, 0, aSize.Width(), 
aSize.Height());
        CGContextDrawImage( mrContext, aSrcRect, xImage );
        CGImageRelease( xImage );
        // restore the Quartz graphics state
@@ -1578,14 +1578,14 @@ bool AquaSalGraphics::drawTransformedBit
 bool AquaSalGraphics::drawAlphaRect( long nX, long nY, long nWidth,
                                      long nHeight, sal_uInt8 nTransparency )
 {
-    if( !CheckContext() )
-       return true;
+       if( !CheckContext() )
+               return true;
        
        // save the current state
        CGContextSaveGState( mrContext );
        CGContextSetAlpha( mrContext, (100-nTransparency) * (1.0/100) ); 
 
-       CGRect aRect = {{nX,nY},{nWidth-1,nHeight-1}};
+       CGRect aRect = CGRectMake( nX, nY, nWidth-1, nHeight-1);
        if( IsPenVisible() )
        {
                aRect.origin.x += 0.5;
@@ -2739,7 +2739,7 @@ bool XorEmulation::UpdateTarget()
                const int nWidth  = (int)CGImageGetWidth( xXorImage );
                const int nHeight = (int)CGImageGetHeight( xXorImage );
                // TODO: update minimal changerect
-               const CGRect aFullRect = {{0,0},{nWidth,nHeight}};
+               const CGRect aFullRect = CGRectMake( 0, 0, nWidth, nHeight);
                CGContextDrawImage( mxTargetContext, aFullRect, xXorImage );
                CGImageRelease( xXorImage );
        }


Reply via email to