From 920d4463f6e59b815852c173e2974ffc7b4bb284 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 23 Jun 2016 13:13:28 +0200 Subject: loplugin:singlevalfields in vcl(part1) Change-Id: I0031199937cc95793951a070c4b3d8910933e69f Reviewed-on: https://gerrit.libreoffice.org/26595 Tested-by: Jenkins Reviewed-by: Noel Grandin --- vcl/source/gdi/animate.cxx | 7 +-- vcl/source/gdi/impgraph.cxx | 2 +- vcl/source/gdi/pdfwriter_impl.cxx | 103 ++++++++----------------------------- vcl/source/gdi/pdfwriter_impl2.cxx | 102 +++++++++++++++--------------------- vcl/source/gdi/print.cxx | 1 - vcl/source/gdi/print3.cxx | 4 +- 6 files changed, 68 insertions(+), 151 deletions(-) (limited to 'vcl/source/gdi') diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx index 2f4fabf08ef9..225d1f7e619b 100644 --- a/vcl/source/gdi/animate.cxx +++ b/vcl/source/gdi/animate.cxx @@ -66,8 +66,7 @@ Animation::Animation() : mnLoops ( 0 ), mnPos ( 0 ), mbIsInAnimation ( false ), - mbLoopTerminated ( false ), - mbIsWaiting ( false ) + mbLoopTerminated ( false ) { maTimer.SetTimeoutHdl( LINK( this, Animation, ImplTimeoutHdl ) ); } @@ -78,8 +77,7 @@ Animation::Animation( const Animation& rAnimation ) : mnLoopCount ( rAnimation.mnLoopCount ), mnPos ( rAnimation.mnPos ), mbIsInAnimation ( false ), - mbLoopTerminated ( rAnimation.mbLoopTerminated ), - mbIsWaiting ( rAnimation.mbIsWaiting ) + mbLoopTerminated ( rAnimation.mbLoopTerminated ) { for(const AnimationBitmap* i : rAnimation.maList) @@ -114,7 +112,6 @@ Animation& Animation::operator=( const Animation& rAnimation ) mnLoopCount = rAnimation.mnLoopCount; mnPos = rAnimation.mnPos; mbLoopTerminated = rAnimation.mbLoopTerminated; - mbIsWaiting = rAnimation.mbIsWaiting; mnLoops = mbLoopTerminated ? 0 : mnLoopCount; return *this; diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 371350bfdc1e..8c66d1a0e548 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -573,7 +573,7 @@ BitmapEx ImpGraphic::ImplGetBitmapEx(const GraphicConversionParameters& rParamet { aRetBmpEx.Scale( rParameters.getSizePixel(), - rParameters.getScaleHighQuality() ? BmpScaleFlag::Interpolate : BmpScaleFlag::Fast); + BmpScaleFlag::Fast); } } else if( ( meType != GraphicType::Default ) && ImplIsSupportedGraphic() ) diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index f29e8d1083d2..15d764fa4591 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -4842,25 +4842,20 @@ void PDFWriterImpl::createDefaultEditAppearance( PDFWidget& rEdit, const PDFWrit // prepare font to use, draw field border Font aFont = drawFieldBorder( rEdit, rWidget, rSettings ); - sal_Int32 nBest = m_aContext.FieldsUseSystemFonts ? getSystemFont( aFont ): getBestBuiltinFont( aFont ); + sal_Int32 nBest = getSystemFont( aFont ); // prepare DA string OStringBuffer aDA( 32 ); appendNonStrokingColor( replaceColor( rWidget.TextColor, rSettings.GetFieldTextColor() ), aDA ); aDA.append( ' ' ); - if( m_aContext.FieldsUseSystemFonts ) - { - aDA.append( "/F" ); - aDA.append( nBest ); - - OStringBuffer aDR( 32 ); - aDR.append( "/Font " ); - aDR.append( getFontDictObject() ); - aDR.append( " 0 R" ); - rEdit.m_aDRDict = aDR.makeStringAndClear(); - } - else - aDA.append( m_aBuiltinFonts[nBest].getNameObject() ); + aDA.append( "/F" ); + aDA.append( nBest ); + + OStringBuffer aDR( 32 ); + aDR.append( "/Font " ); + aDR.append( getFontDictObject() ); + aDR.append( " 0 R" ); + rEdit.m_aDRDict = aDR.makeStringAndClear(); aDA.append( ' ' ); m_aPages[ m_nCurrentPage ].appendMappedLength( sal_Int32( aFont.GetFontHeight() ), aDA ); aDA.append( " Tf" ); @@ -4894,7 +4889,7 @@ void PDFWriterImpl::createDefaultListBoxAppearance( PDFWidget& rBox, const PDFWr // prepare font to use, draw field border Font aFont = drawFieldBorder( rBox, rWidget, rSettings ); - sal_Int32 nBest = m_aContext.FieldsUseSystemFonts ? getSystemFont( aFont ): getBestBuiltinFont( aFont ); + sal_Int32 nBest = getSystemFont( aFont ); beginRedirect( pListBoxStream, rBox.m_aRect ); OStringBuffer aAppearance( 64 ); @@ -4917,19 +4912,14 @@ void PDFWriterImpl::createDefaultListBoxAppearance( PDFWidget& rBox, const PDFWr // prepare DA string appendNonStrokingColor( replaceColor( rWidget.TextColor, rSettings.GetFieldTextColor() ), aDA ); aDA.append( ' ' ); - if( m_aContext.FieldsUseSystemFonts ) - { - aDA.append( "/F" ); - aDA.append( nBest ); - - OStringBuffer aDR( 32 ); - aDR.append( "/Font " ); - aDR.append( getFontDictObject() ); - aDR.append( " 0 R" ); - rBox.m_aDRDict = aDR.makeStringAndClear(); - } - else - aDA.append( m_aBuiltinFonts[nBest].getNameObject() ); + aDA.append( "/F" ); + aDA.append( nBest ); + + OStringBuffer aDR( 32 ); + aDR.append( "/Font " ); + aDR.append( getFontDictObject() ); + aDR.append( " 0 R" ); + rBox.m_aDRDict = aDR.makeStringAndClear(); aDA.append( ' ' ); m_aPages[ m_nCurrentPage ].appendMappedLength( sal_Int32( aFont.GetFontHeight() ), aDA ); aDA.append( " Tf" ); @@ -4960,7 +4950,6 @@ void PDFWriterImpl::createDefaultCheckBoxAppearance( PDFWidget& rBox, const PDFW nDelta = 1; Rectangle aCheckRect, aTextRect; - if( rWidget.ButtonIsLeft ) { aCheckRect.Left() = rBox.m_aRect.Left() + nDelta; aCheckRect.Top() = rBox.m_aRect.Top() + (rBox.m_aRect.GetHeight()-aFontSize.Height())/2; @@ -4980,26 +4969,6 @@ void PDFWriterImpl::createDefaultCheckBoxAppearance( PDFWidget& rBox, const PDFW aTextRect.Right() = aTextRect.Left() + rBox.m_aRect.GetWidth() - aCheckRect.GetWidth()-6*nDelta; aTextRect.Bottom() = rBox.m_aRect.Bottom(); } - else - { - aCheckRect.Left() = rBox.m_aRect.Right() - nDelta - aFontSize.Height(); - aCheckRect.Top() = rBox.m_aRect.Top() + (rBox.m_aRect.GetHeight()-aFontSize.Height())/2; - aCheckRect.Right() = aCheckRect.Left() + aFontSize.Height(); - aCheckRect.Bottom() = aCheckRect.Top() + aFontSize.Height(); - - // #i74206# handle small controls without text area - while( aCheckRect.GetWidth() > rBox.m_aRect.GetWidth() && aCheckRect.GetWidth() > nDelta ) - { - aCheckRect.Left() += nDelta; - aCheckRect.Top() += nDelta/2; - aCheckRect.Bottom() -= nDelta - (nDelta/2); - } - - aTextRect.Left() = rBox.m_aRect.Left(); - aTextRect.Top() = rBox.m_aRect.Top(); - aTextRect.Right() = aTextRect.Left() + rBox.m_aRect.GetWidth() - aCheckRect.GetWidth()-6*nDelta; - aTextRect.Bottom() = rBox.m_aRect.Bottom(); - } setLineColor( Color( COL_BLACK ) ); setFillColor( Color( COL_TRANSPARENT ) ); OStringBuffer aLW( 32 ); @@ -5085,7 +5054,6 @@ void PDFWriterImpl::createDefaultRadioButtonAppearance( PDFWidget& rBox, const P nDelta = 1; Rectangle aCheckRect, aTextRect; - if( rWidget.ButtonIsLeft ) { aCheckRect.Left() = rBox.m_aRect.Left() + nDelta; aCheckRect.Top() = rBox.m_aRect.Top() + (rBox.m_aRect.GetHeight()-aFontSize.Height())/2; @@ -5105,26 +5073,6 @@ void PDFWriterImpl::createDefaultRadioButtonAppearance( PDFWidget& rBox, const P aTextRect.Right() = aTextRect.Left() + rBox.m_aRect.GetWidth() - aCheckRect.GetWidth()-6*nDelta; aTextRect.Bottom() = rBox.m_aRect.Bottom(); } - else - { - aCheckRect.Left() = rBox.m_aRect.Right() - nDelta - aFontSize.Height(); - aCheckRect.Top() = rBox.m_aRect.Top() + (rBox.m_aRect.GetHeight()-aFontSize.Height())/2; - aCheckRect.Right() = aCheckRect.Left() + aFontSize.Height(); - aCheckRect.Bottom() = aCheckRect.Top() + aFontSize.Height(); - - // #i74206# handle small controls without text area - while( aCheckRect.GetWidth() > rBox.m_aRect.GetWidth() && aCheckRect.GetWidth() > nDelta ) - { - aCheckRect.Left() += nDelta; - aCheckRect.Top() += nDelta/2; - aCheckRect.Bottom() -= nDelta - (nDelta/2); - } - - aTextRect.Left() = rBox.m_aRect.Left(); - aTextRect.Top() = rBox.m_aRect.Top(); - aTextRect.Right() = aTextRect.Left() + rBox.m_aRect.GetWidth() - aCheckRect.GetWidth()-6*nDelta; - aTextRect.Bottom() = rBox.m_aRect.Bottom(); - } setLineColor( Color( COL_BLACK ) ); setFillColor( Color( COL_TRANSPARENT ) ); OStringBuffer aLW( 32 ); @@ -7961,10 +7909,7 @@ bool PDFWriterImpl::emitTrailer() aLineS.append( " 0 obj\n" "<(rControl); - sigHidden = rSig.SigHidden; + sigHidden = true; - if ( sigHidden ) - rNewWidget.m_aRect = Rectangle(0, 0, 0, 0); + rNewWidget.m_aRect = Rectangle(0, 0, 0, 0); m_nSignatureObject = createObject(); rNewWidget.m_aValue = OUString::number( m_nSignatureObject ); diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index 694c698b8b21..d714f5d8a4ca 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -1277,7 +1277,7 @@ sal_Int32 PDFWriterImpl::computeAccessPermissions( const vcl::PDFWriter::PDFEncr - for 40 bit security the unused bit must be set to 1, since they are not used - for 128 bit security the same bit must be preset to 0 and set later if needed according to the table 3.15, pdf v 1.4 */ - sal_Int32 nAccessPermissions = ( i_rProperties.Security128bit ) ? 0xfffff0c0 : 0xffffffc0 ; + sal_Int32 nAccessPermissions = 0xfffff0c0; /* check permissions for 40 bit security case */ nAccessPermissions |= ( i_rProperties.CanPrintTheDocument ) ? 1 << 2 : 0; @@ -1287,16 +1287,13 @@ sal_Int32 PDFWriterImpl::computeAccessPermissions( const vcl::PDFWriter::PDFEncr o_rKeyLength = SECUR_40BIT_KEY; o_rRC4KeyLength = SECUR_40BIT_KEY+5; // for this value see PDF spec v 1.4, algorithm 3.1 step 4, where n is 5 - if( i_rProperties.Security128bit ) - { - o_rKeyLength = SECUR_128BIT_KEY; - o_rRC4KeyLength = 16; // for this value see PDF spec v 1.4, algorithm 3.1 step 4, where n is 16, thus maximum - // permitted value is 16 - nAccessPermissions |= ( i_rProperties.CanFillInteractive ) ? 1 << 8 : 0; - nAccessPermissions |= ( i_rProperties.CanExtractForAccessibility ) ? 1 << 9 : 0; - nAccessPermissions |= ( i_rProperties.CanAssemble ) ? 1 << 10 : 0; - nAccessPermissions |= ( i_rProperties.CanPrintFull ) ? 1 << 11 : 0; - } + o_rKeyLength = SECUR_128BIT_KEY; + o_rRC4KeyLength = 16; // for this value see PDF spec v 1.4, algorithm 3.1 step 4, where n is 16, thus maximum + // permitted value is 16 + nAccessPermissions |= ( i_rProperties.CanFillInteractive ) ? 1 << 8 : 0; + nAccessPermissions |= ( i_rProperties.CanExtractForAccessibility ) ? 1 << 9 : 0; + nAccessPermissions |= ( i_rProperties.CanAssemble ) ? 1 << 10 : 0; + nAccessPermissions |= ( i_rProperties.CanPrintFull ) ? 1 << 11 : 0; return nAccessPermissions; } @@ -1368,18 +1365,15 @@ bool PDFWriterImpl::computeEncryptionKey( EncHashTransporter* i_pTransporter, vc rtl_digest_getMD5( aDigest, nMD5Sum, sizeof( nMD5Sum ) ); //step 6, only if 128 bit - if( io_rProperties.Security128bit ) + for( sal_Int32 i = 0; i < 50; i++ ) { - for( sal_Int32 i = 0; i < 50; i++ ) + nError = rtl_digest_updateMD5( aDigest, &nMD5Sum, sizeof( nMD5Sum ) ); + if( nError != rtl_Digest_E_None ) { - nError = rtl_digest_updateMD5( aDigest, &nMD5Sum, sizeof( nMD5Sum ) ); - if( nError != rtl_Digest_E_None ) - { - bSuccess = false; - break; - } - rtl_digest_getMD5( aDigest, nMD5Sum, sizeof( nMD5Sum ) ); + bSuccess = false; + break; } + rtl_digest_getMD5( aDigest, nMD5Sum, sizeof( nMD5Sum ) ); } } else @@ -1514,52 +1508,38 @@ bool PDFWriterImpl::computeUDictionaryValue( EncHashTransporter* i_pTransporter, for( sal_Int32 i = i_nKeyLength, y = 0; y < 5 ; y++ ) io_rProperties.EncryptionKey[i++] = 0; - if( !io_rProperties.Security128bit ) + //or 3.5, for 128 bit security + //step6, initialize the last 16 bytes of the encrypted user password to 0 + for(sal_uInt32 i = MD5_DIGEST_SIZE; i < sal_uInt32(io_rProperties.UValue.size()); i++) + io_rProperties.UValue[i] = 0; + //steps 2 and 3 + if (rtl_digest_updateMD5( aDigest, s_nPadString, sizeof( s_nPadString ) ) != rtl_Digest_E_None + || rtl_digest_updateMD5( aDigest, &io_rProperties.DocumentIdentifier[0], sal_Int32(io_rProperties.DocumentIdentifier.size()) ) != rtl_Digest_E_None) { - //3.4 - //step 2 and 3 - rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode, - &io_rProperties.EncryptionKey[0], 5 , // key and key length - nullptr, 0 ); //destination data area - // encrypt the user password using the key set above, save for later use - rtl_cipher_encodeARCFOUR( aCipher, s_nPadString, sizeof( s_nPadString ), // the data to be encrypted - &io_rProperties.UValue[0], sal_Int32(io_rProperties.UValue.size()) ); //encrypted data, stored in class data member + bSuccess = false; } - else + + sal_uInt8 nMD5Sum[ RTL_DIGEST_LENGTH_MD5 ]; + rtl_digest_getMD5( aDigest, nMD5Sum, sizeof(nMD5Sum) ); + //Step 4 + rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode, + &io_rProperties.EncryptionKey[0], SECUR_128BIT_KEY, nullptr, 0 ); //destination data area + rtl_cipher_encodeARCFOUR( aCipher, nMD5Sum, sizeof( nMD5Sum ), // the data to be encrypted + &io_rProperties.UValue[0], sizeof( nMD5Sum ) ); //encrypted data, stored in class data member + //step 5 + sal_uInt32 i, y; + sal_uInt8 nLocalKey[SECUR_128BIT_KEY]; + + for( i = 1; i <= 19; i++ ) // do it 19 times, start with 1 { - //or 3.5, for 128 bit security - //step6, initialize the last 16 bytes of the encrypted user password to 0 - for(sal_uInt32 i = MD5_DIGEST_SIZE; i < sal_uInt32(io_rProperties.UValue.size()); i++) - io_rProperties.UValue[i] = 0; - //steps 2 and 3 - if (rtl_digest_updateMD5( aDigest, s_nPadString, sizeof( s_nPadString ) ) != rtl_Digest_E_None - || rtl_digest_updateMD5( aDigest, &io_rProperties.DocumentIdentifier[0], sal_Int32(io_rProperties.DocumentIdentifier.size()) ) != rtl_Digest_E_None) - { - bSuccess = false; - } + for( y = 0; y < sizeof( nLocalKey ) ; y++ ) + nLocalKey[y] = (sal_uInt8)( io_rProperties.EncryptionKey[y] ^ i ); - sal_uInt8 nMD5Sum[ RTL_DIGEST_LENGTH_MD5 ]; - rtl_digest_getMD5( aDigest, nMD5Sum, sizeof(nMD5Sum) ); - //Step 4 rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode, - &io_rProperties.EncryptionKey[0], SECUR_128BIT_KEY, nullptr, 0 ); //destination data area - rtl_cipher_encodeARCFOUR( aCipher, nMD5Sum, sizeof( nMD5Sum ), // the data to be encrypted - &io_rProperties.UValue[0], sizeof( nMD5Sum ) ); //encrypted data, stored in class data member - //step 5 - sal_uInt32 i, y; - sal_uInt8 nLocalKey[SECUR_128BIT_KEY]; - - for( i = 1; i <= 19; i++ ) // do it 19 times, start with 1 - { - for( y = 0; y < sizeof( nLocalKey ) ; y++ ) - nLocalKey[y] = (sal_uInt8)( io_rProperties.EncryptionKey[y] ^ i ); - - rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode, - nLocalKey, SECUR_128BIT_KEY, // key and key length - nullptr, 0 ); //destination data area, on init can be NULL - rtl_cipher_encodeARCFOUR( aCipher, &io_rProperties.UValue[0], SECUR_128BIT_KEY, // the data to be encrypted - &io_rProperties.UValue[0], SECUR_128BIT_KEY ); // encrypted data, can be the same as the input, encrypt "in place" - } + nLocalKey, SECUR_128BIT_KEY, // key and key length + nullptr, 0 ); //destination data area, on init can be NULL + rtl_cipher_encodeARCFOUR( aCipher, &io_rProperties.UValue[0], SECUR_128BIT_KEY, // the data to be encrypted + &io_rProperties.UValue[0], SECUR_128BIT_KEY ); // encrypted data, can be the same as the input, encrypt "in place" } } else diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 23dd0f2aa54b..23c93681df66 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -507,7 +507,6 @@ void Printer::ImplInitData() mpInfoPrinter = nullptr; mpPrinter = nullptr; mpDisplayDev = nullptr; - mbIsQueuePrinter = false; mpPrinterOptions = new PrinterOptions; // Add printer to the list diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 7b244caa51cd..3bc2fccad964 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1128,7 +1128,7 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte for( int nSubPage = 0; nSubPage < nSubPages; nSubPage++ ) { // map current sub page to real page - int nPage = (i_nFilteredPage * nSubPages + nSubPage) / rMPS.nRepeat; + int nPage = i_nFilteredPage * nSubPages + nSubPage; if( nSubPage == nSubPages-1 || nPage == nDocPages-1 ) { @@ -1198,7 +1198,7 @@ int PrinterController::getFilteredPageCount() int nDiv = mpImplData->maMultiPage.nRows * mpImplData->maMultiPage.nColumns; if( nDiv < 1 ) nDiv = 1; - return (getPageCountProtected() * mpImplData->maMultiPage.nRepeat + (nDiv-1)) / nDiv; + return (getPageCountProtected() + (nDiv-1)) / nDiv; } DrawModeFlags PrinterController::removeTransparencies( GDIMetaFile& i_rIn, GDIMetaFile& o_rOut ) -- cgit v1.2.3