vcl/source/gdi/CommonSalLayout.cxx | 68 ++-- vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 40 +- vcl/source/gdi/alpha.cxx | 102 +++--- vcl/source/gdi/bitmap3.cxx | 76 ++-- vcl/source/gdi/bitmapex.cxx | 44 +- vcl/source/gdi/bmpacc.cxx | 118 +++---- vcl/source/gdi/bmpacc3.cxx | 240 +++++++------- vcl/source/gdi/gdimtf.cxx | 134 ++++---- vcl/source/gdi/impvect.cxx | 38 +- vcl/source/gdi/lineinfo.cxx | 86 ++--- vcl/source/gdi/metaact.cxx | 232 +++++++------- vcl/source/gdi/pdfwriter_impl.cxx | 456 ++++++++++++++-------------- vcl/source/gdi/pdfwriter_impl2.cxx | 262 ++++++++-------- vcl/source/gdi/print.cxx | 204 ++++++------ vcl/source/gdi/print3.cxx | 124 +++---- vcl/source/gdi/regband.cxx | 40 +- vcl/source/gdi/region.cxx | 34 +- vcl/source/gdi/salgdilayout.cxx | 74 ++-- vcl/source/gdi/sallayout.cxx | 30 - vcl/source/gdi/vectorgraphicdata.cxx | 122 +++---- 20 files changed, 1262 insertions(+), 1262 deletions(-)
New commits: commit 750a6bddf16a2e85555ae3859bf5facfd8cff955 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Aug 4 00:16:03 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Aug 4 01:41:27 2020 +0200 loplugin:flatten in vcl/gdi Change-Id: Ief1736264e62acfac3a9a83c54dc564c03d6fba9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100034 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index d5ce806fa747..998e07169c51 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -769,45 +769,45 @@ void GenericSalLayout::ApplyDXArray(const ImplLayoutArgs& rArgs) } // Insert Kashida glyphs. - if (bKashidaJustify && !pKashidas.empty()) + if (!bKashidaJustify || pKashidas.empty()) + return; + + size_t nInserted = 0; + for (auto const& pKashida : pKashidas) { - size_t nInserted = 0; - for (auto const& pKashida : pKashidas) - { - auto pGlyphIter = m_GlyphItems.Impl()->begin() + nInserted + pKashida.first; + auto pGlyphIter = m_GlyphItems.Impl()->begin() + nInserted + pKashida.first; - // The total Kashida width. - DeviceCoordinate nTotalWidth = pKashida.second; + // The total Kashida width. + DeviceCoordinate nTotalWidth = pKashida.second; - // Number of times to repeat each Kashida. - int nCopies = 1; - if (nTotalWidth > nKashidaWidth) - nCopies = nTotalWidth / nKashidaWidth; + // Number of times to repeat each Kashida. + int nCopies = 1; + if (nTotalWidth > nKashidaWidth) + nCopies = nTotalWidth / nKashidaWidth; - // See if we can improve the fit by adding an extra Kashidas and - // squeezing them together a bit. - DeviceCoordinate nOverlap = 0; - DeviceCoordinate nShortfall = nTotalWidth - nKashidaWidth * nCopies; - if (nShortfall > 0) - { - ++nCopies; - DeviceCoordinate nExcess = nCopies * nKashidaWidth - nTotalWidth; - if (nExcess > 0) - nOverlap = nExcess / (nCopies - 1); - } + // See if we can improve the fit by adding an extra Kashidas and + // squeezing them together a bit. + DeviceCoordinate nOverlap = 0; + DeviceCoordinate nShortfall = nTotalWidth - nKashidaWidth * nCopies; + if (nShortfall > 0) + { + ++nCopies; + DeviceCoordinate nExcess = nCopies * nKashidaWidth - nTotalWidth; + if (nExcess > 0) + nOverlap = nExcess / (nCopies - 1); + } - Point aPos(pGlyphIter->m_aLinearPos.getX() - nTotalWidth, 0); - int nCharPos = pGlyphIter->charPos(); - GlyphItemFlags const nFlags = GlyphItemFlags::IS_IN_CLUSTER | GlyphItemFlags::IS_RTL_GLYPH; - while (nCopies--) - { - GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, nKashidaWidth, 0, &GetFont()); - pGlyphIter = m_GlyphItems.Impl()->insert(pGlyphIter, aKashida); - aPos.AdjustX(nKashidaWidth ); - aPos.AdjustX( -nOverlap ); - ++pGlyphIter; - ++nInserted; - } + Point aPos(pGlyphIter->m_aLinearPos.getX() - nTotalWidth, 0); + int nCharPos = pGlyphIter->charPos(); + GlyphItemFlags const nFlags = GlyphItemFlags::IS_IN_CLUSTER | GlyphItemFlags::IS_RTL_GLYPH; + while (nCopies--) + { + GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, nKashidaWidth, 0, &GetFont()); + pGlyphIter = m_GlyphItems.Impl()->insert(pGlyphIter, aKashida); + aPos.AdjustX(nKashidaWidth ); + aPos.AdjustX( -nOverlap ); + ++pGlyphIter; + ++nInserted; } } } diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index 01698c4e3d6f..ba7cce24c338 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -116,26 +116,26 @@ FileDefinitionWidgetDraw::FileDefinitionWidgetDraw(SalGraphics& rGraphics) m_pWidgetDefinition = getWidgetDefinitionForTheme("ios"); #endif - if (m_pWidgetDefinition) - { - auto& pSettings = m_pWidgetDefinition->mpSettings; - - ImplSVData* pSVData = ImplGetSVData(); - pSVData->maNWFData.mbNoFocusRects = true; - pSVData->maNWFData.mbNoFocusRectsForFlatButtons = true; - pSVData->maNWFData.mbNoActiveTabTextRaise - = getSettingValueBool(pSettings->msNoActiveTabTextRaise, true); - pSVData->maNWFData.mbCenteredTabs = getSettingValueBool(pSettings->msCenteredTabs, true); - pSVData->maNWFData.mbProgressNeedsErase = true; - pSVData->maNWFData.mnStatusBarLowerRightOffset = 10; - pSVData->maNWFData.mbCanDrawWidgetAnySize = true; - - int nDefaultListboxEntryMargin = pSVData->maNWFData.mnListBoxEntryMargin; - pSVData->maNWFData.mnListBoxEntryMargin - = getSettingValueInteger(pSettings->msListBoxEntryMargin, nDefaultListboxEntryMargin); - - m_bIsActive = true; - } + if (!m_pWidgetDefinition) + return; + + auto& pSettings = m_pWidgetDefinition->mpSettings; + + ImplSVData* pSVData = ImplGetSVData(); + pSVData->maNWFData.mbNoFocusRects = true; + pSVData->maNWFData.mbNoFocusRectsForFlatButtons = true; + pSVData->maNWFData.mbNoActiveTabTextRaise + = getSettingValueBool(pSettings->msNoActiveTabTextRaise, true); + pSVData->maNWFData.mbCenteredTabs = getSettingValueBool(pSettings->msCenteredTabs, true); + pSVData->maNWFData.mbProgressNeedsErase = true; + pSVData->maNWFData.mnStatusBarLowerRightOffset = 10; + pSVData->maNWFData.mbCanDrawWidgetAnySize = true; + + int nDefaultListboxEntryMargin = pSVData->maNWFData.mnListBoxEntryMargin; + pSVData->maNWFData.mnListBoxEntryMargin + = getSettingValueInteger(pSettings->msListBoxEntryMargin, nDefaultListboxEntryMargin); + + m_bIsActive = true; } bool FileDefinitionWidgetDraw::isNativeControlSupported(ControlType eType, ControlPart ePart) diff --git a/vcl/source/gdi/alpha.cxx b/vcl/source/gdi/alpha.cxx index 3fa43c8eaa6a..168f4fcf5840 100644 --- a/vcl/source/gdi/alpha.cxx +++ b/vcl/source/gdi/alpha.cxx @@ -82,21 +82,21 @@ void AlphaMask::Replace( const Bitmap& rMask, sal_uInt8 cReplaceTransparency ) Bitmap::ScopedReadAccess pMaskAcc( const_cast<Bitmap&>(rMask) ); AlphaScopedWriteAccess pAcc(*this); - if( pMaskAcc && pAcc ) - { - const BitmapColor aReplace( cReplaceTransparency ); - const long nWidth = std::min( pMaskAcc->Width(), pAcc->Width() ); - const long nHeight = std::min( pMaskAcc->Height(), pAcc->Height() ); - const BitmapColor aMaskWhite( pMaskAcc->GetBestMatchingColor( COL_WHITE ) ); + if( !(pMaskAcc && pAcc) ) + return; - for( long nY = 0; nY < nHeight; nY++ ) - { - Scanline pScanline = pAcc->GetScanline(nY); - Scanline pScanlineMask = pMaskAcc->GetScanline(nY); - for( long nX = 0; nX < nWidth; nX++ ) - if( pMaskAcc->GetPixelFromData( pScanlineMask, nX ) == aMaskWhite ) - pAcc->SetPixelOnData( pScanline, nX, aReplace ); - } + const BitmapColor aReplace( cReplaceTransparency ); + const long nWidth = std::min( pMaskAcc->Width(), pAcc->Width() ); + const long nHeight = std::min( pMaskAcc->Height(), pAcc->Height() ); + const BitmapColor aMaskWhite( pMaskAcc->GetBestMatchingColor( COL_WHITE ) ); + + for( long nY = 0; nY < nHeight; nY++ ) + { + Scanline pScanline = pAcc->GetScanline(nY); + Scanline pScanlineMask = pMaskAcc->GetScanline(nY); + for( long nX = 0; nX < nWidth; nX++ ) + if( pMaskAcc->GetPixelFromData( pScanlineMask, nX ) == aMaskWhite ) + pAcc->SetPixelOnData( pScanline, nX, aReplace ); } } @@ -104,35 +104,35 @@ void AlphaMask::Replace( sal_uInt8 cSearchTransparency, sal_uInt8 cReplaceTransp { AlphaScopedWriteAccess pAcc(*this); - if( pAcc && pAcc->GetBitCount() == 8 ) - { - const long nWidth = pAcc->Width(), nHeight = pAcc->Height(); + if( !(pAcc && pAcc->GetBitCount() == 8) ) + return; - if( pAcc->GetScanlineFormat() == ScanlineFormat::N8BitPal ) + const long nWidth = pAcc->Width(), nHeight = pAcc->Height(); + + if( pAcc->GetScanlineFormat() == ScanlineFormat::N8BitPal ) + { + for( long nY = 0; nY < nHeight; nY++ ) { - for( long nY = 0; nY < nHeight; nY++ ) - { - Scanline pScan = pAcc->GetScanline( nY ); + Scanline pScan = pAcc->GetScanline( nY ); - for( long nX = 0; nX < nWidth; nX++, pScan++ ) - { - if( *pScan == cSearchTransparency ) - *pScan = cReplaceTransparency; - } + for( long nX = 0; nX < nWidth; nX++, pScan++ ) + { + if( *pScan == cSearchTransparency ) + *pScan = cReplaceTransparency; } } - else - { - BitmapColor aReplace( cReplaceTransparency ); + } + else + { + BitmapColor aReplace( cReplaceTransparency ); - for( long nY = 0; nY < nHeight; nY++ ) + for( long nY = 0; nY < nHeight; nY++ ) + { + Scanline pScanline = pAcc->GetScanline(nY); + for( long nX = 0; nX < nWidth; nX++ ) { - Scanline pScanline = pAcc->GetScanline(nY); - for( long nX = 0; nX < nWidth; nX++ ) - { - if( pAcc->GetIndexFromData( pScanline, nX ) == cSearchTransparency ) - pAcc->SetPixelOnData( pScanline, nX, aReplace ); - } + if( pAcc->GetIndexFromData( pScanline, nX ) == cSearchTransparency ) + pAcc->SetPixelOnData( pScanline, nX, aReplace ); } } } @@ -143,23 +143,23 @@ void AlphaMask::BlendWith(const Bitmap& rOther) AlphaMask aOther(rOther); // to 8 bits Bitmap::ScopedReadAccess pOtherAcc(aOther); AlphaScopedWriteAccess pAcc(*this); - if (pOtherAcc && pAcc && pOtherAcc->GetBitCount() == 8 && pAcc->GetBitCount() == 8) + if (!(pOtherAcc && pAcc && pOtherAcc->GetBitCount() == 8 && pAcc->GetBitCount() == 8)) + return; + + const long nHeight = std::min(pOtherAcc->Height(), pAcc->Height()); + const long nWidth = std::min(pOtherAcc->Width(), pAcc->Width()); + for (long y = 0; y < nHeight; ++y) { - const long nHeight = std::min(pOtherAcc->Height(), pAcc->Height()); - const long nWidth = std::min(pOtherAcc->Width(), pAcc->Width()); - for (long y = 0; y < nHeight; ++y) + Scanline scanline = pAcc->GetScanline( y ); + ConstScanline otherScanline = pOtherAcc->GetScanline( y ); + for (long x = 0; x < nWidth; ++x) { - Scanline scanline = pAcc->GetScanline( y ); - ConstScanline otherScanline = pOtherAcc->GetScanline( y ); - for (long x = 0; x < nWidth; ++x) - { - // Use sal_uInt16 for following multiplication - const sal_uInt16 nGrey1 = *scanline; - const sal_uInt16 nGrey2 = *otherScanline; - *scanline = static_cast<sal_uInt8>(nGrey1 + nGrey2 - nGrey1 * nGrey2 / 255); - ++scanline; - ++otherScanline; - } + // Use sal_uInt16 for following multiplication + const sal_uInt16 nGrey1 = *scanline; + const sal_uInt16 nGrey2 = *otherScanline; + *scanline = static_cast<sal_uInt8>(nGrey1 + nGrey2 - nGrey1 * nGrey2 / 255); + ++scanline; + ++otherScanline; } } } diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index ec80b03c6008..3e9972569a16 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -794,54 +794,54 @@ bool Bitmap::HasFastScale() void Bitmap::AdaptBitCount(Bitmap& rNew) const { // aNew is the result of some operation; adapt it's BitCount to the original (this) - if(GetBitCount() != rNew.GetBitCount()) + if(GetBitCount() == rNew.GetBitCount()) + return; + + switch(GetBitCount()) { - switch(GetBitCount()) + case 1: { - case 1: - { - rNew.Convert(BmpConversion::N1BitThreshold); - break; - } - case 4: - { - if(HasGreyPaletteAny()) - { - rNew.Convert(BmpConversion::N4BitGreys); - } - else - { - rNew.Convert(BmpConversion::N4BitColors); - } - break; - } - case 8: + rNew.Convert(BmpConversion::N1BitThreshold); + break; + } + case 4: + { + if(HasGreyPaletteAny()) { - if(HasGreyPaletteAny()) - { - rNew.Convert(BmpConversion::N8BitGreys); - } - else - { - rNew.Convert(BmpConversion::N8BitColors); - } - break; + rNew.Convert(BmpConversion::N4BitGreys); } - case 24: + else { - rNew.Convert(BmpConversion::N24Bit); - break; + rNew.Convert(BmpConversion::N4BitColors); } - case 32: + break; + } + case 8: + { + if(HasGreyPaletteAny()) { - rNew.Convert(BmpConversion::N32Bit); - break; + rNew.Convert(BmpConversion::N8BitGreys); } - default: + else { - SAL_WARN("vcl", "BitDepth adaptation failed, from " << rNew.GetBitCount() << " to " << GetBitCount()); - break; + rNew.Convert(BmpConversion::N8BitColors); } + break; + } + case 24: + { + rNew.Convert(BmpConversion::N24Bit); + break; + } + case 32: + { + rNew.Convert(BmpConversion::N32Bit); + break; + } + default: + { + SAL_WARN("vcl", "BitDepth adaptation failed, from " << rNew.GetBitCount() << " to " << GetBitCount()); + break; } } } diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 3f65117392a5..8dbe7bc1fbc9 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -456,21 +456,21 @@ void BitmapEx::Expand( sal_uLong nDX, sal_uLong nDY, bool bExpandTransparent ) { bool bRet = false; - if( !!maBitmap ) - { - bRet = maBitmap.Expand( nDX, nDY ); - - if( bRet && ( meTransparent == TransparentType::Bitmap ) && !!maMask ) - { - Color aColor( bExpandTransparent ? COL_WHITE : COL_BLACK ); - maMask.Expand( nDX, nDY, &aColor ); - } + if( !maBitmap ) + return; - SetSizePixel(maBitmap.GetSizePixel()); + bRet = maBitmap.Expand( nDX, nDY ); - SAL_WARN_IF(!!maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl", - "BitmapEx::Expand(): size mismatch for bitmap and alpha mask."); + if( bRet && ( meTransparent == TransparentType::Bitmap ) && !!maMask ) + { + Color aColor( bExpandTransparent ? COL_WHITE : COL_BLACK ); + maMask.Expand( nDX, nDY, &aColor ); } + + SetSizePixel(maBitmap.GetSizePixel()); + + SAL_WARN_IF(!!maMask && maBitmap.GetSizePixel() != maMask.GetSizePixel(), "vcl", + "BitmapEx::Expand(): size mismatch for bitmap and alpha mask."); } bool BitmapEx::CopyPixel( const tools::Rectangle& rRectDst, const tools::Rectangle& rRectSrc, @@ -1539,18 +1539,18 @@ void BitmapEx::setAlphaFrom( sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo ) BitmapScopedWriteAccess pWriteAccess(aAlphaMask); Bitmap::ScopedReadAccess pReadAccess(maBitmap); assert( pReadAccess.get() && pWriteAccess.get() ); - if ( pReadAccess.get() && pWriteAccess.get() ) + if ( !(pReadAccess.get() && pWriteAccess.get()) ) + return; + + for ( long nY = 0; nY < pReadAccess->Height(); nY++ ) { - for ( long nY = 0; nY < pReadAccess->Height(); nY++ ) + Scanline pScanline = pWriteAccess->GetScanline( nY ); + Scanline pScanlineRead = pReadAccess->GetScanline( nY ); + for ( long nX = 0; nX < pReadAccess->Width(); nX++ ) { - Scanline pScanline = pWriteAccess->GetScanline( nY ); - Scanline pScanlineRead = pReadAccess->GetScanline( nY ); - for ( long nX = 0; nX < pReadAccess->Width(); nX++ ) - { - const sal_uInt8 cIndex = pReadAccess->GetPixelFromData( pScanlineRead, nX ).GetIndex(); - if ( cIndex == cIndexFrom ) - pWriteAccess->SetPixelOnData( pScanline, nX, BitmapColor(nAlphaTo) ); - } + const sal_uInt8 cIndex = pReadAccess->GetPixelFromData( pScanlineRead, nX ).GetIndex(); + if ( cIndex == cIndexFrom ) + pWriteAccess->SetPixelOnData( pScanline, nX, BitmapColor(nAlphaTo) ); } } } diff --git a/vcl/source/gdi/bmpacc.cxx b/vcl/source/gdi/bmpacc.cxx index 8b7760772880..a406951cd7f7 100644 --- a/vcl/source/gdi/bmpacc.cxx +++ b/vcl/source/gdi/bmpacc.cxx @@ -364,70 +364,70 @@ void BitmapWriteAccess::CopyScanline( long nY, ConstScanline aSrcScanline, const sal_uLong nCount = std::min( GetScanlineSize(), nSrcScanlineSize ); - if( nCount ) + if( !nCount ) + return; + + if( GetScanlineFormat() == RemoveScanline( nSrcScanlineFormat ) ) + memcpy(GetScanline(nY), aSrcScanline, nCount); + else { - if( GetScanlineFormat() == RemoveScanline( nSrcScanlineFormat ) ) - memcpy(GetScanline(nY), aSrcScanline, nCount); - else - { - DBG_ASSERT( nFormat != ScanlineFormat::N8BitTcMask && - nFormat != ScanlineFormat::N32BitTcMask, - "No support for pixel formats with color masks yet!" ); + DBG_ASSERT( nFormat != ScanlineFormat::N8BitTcMask && + nFormat != ScanlineFormat::N32BitTcMask, + "No support for pixel formats with color masks yet!" ); - // TODO: use fastbmp infrastructure - FncGetPixel pFncGetPixel; + // TODO: use fastbmp infrastructure + FncGetPixel pFncGetPixel; - switch( nFormat ) - { - case ScanlineFormat::N1BitMsbPal: pFncGetPixel = GetPixelForN1BitMsbPal; break; - case ScanlineFormat::N1BitLsbPal: pFncGetPixel = GetPixelForN1BitLsbPal; break; - case ScanlineFormat::N4BitMsnPal: pFncGetPixel = GetPixelForN4BitMsnPal; break; - case ScanlineFormat::N4BitLsnPal: pFncGetPixel = GetPixelForN4BitLsnPal; break; - case ScanlineFormat::N8BitPal: pFncGetPixel = GetPixelForN8BitPal; break; - case ScanlineFormat::N8BitTcMask: pFncGetPixel = GetPixelForN8BitTcMask; break; - case ScanlineFormat::N24BitTcBgr: pFncGetPixel = GetPixelForN24BitTcBgr; break; - case ScanlineFormat::N24BitTcRgb: pFncGetPixel = GetPixelForN24BitTcRgb; break; - case ScanlineFormat::N32BitTcAbgr: - if (Bitmap32IsPreMultipled()) - pFncGetPixel = GetPixelForN32BitTcAbgr; - else - pFncGetPixel = GetPixelForN32BitTcXbgr; - break; - case ScanlineFormat::N32BitTcArgb: - if (Bitmap32IsPreMultipled()) - pFncGetPixel = GetPixelForN32BitTcArgb; - else - pFncGetPixel = GetPixelForN32BitTcXrgb; - break; - case ScanlineFormat::N32BitTcBgra: - if (Bitmap32IsPreMultipled()) - pFncGetPixel = GetPixelForN32BitTcBgra; - else - pFncGetPixel = GetPixelForN32BitTcBgrx; - break; - case ScanlineFormat::N32BitTcRgba: - if (Bitmap32IsPreMultipled()) - pFncGetPixel = GetPixelForN32BitTcRgba; - else - pFncGetPixel = GetPixelForN32BitTcRgbx; - break; - case ScanlineFormat::N32BitTcMask: - pFncGetPixel = GetPixelForN32BitTcMask; - break; - - default: - assert(false); - pFncGetPixel = nullptr; + switch( nFormat ) + { + case ScanlineFormat::N1BitMsbPal: pFncGetPixel = GetPixelForN1BitMsbPal; break; + case ScanlineFormat::N1BitLsbPal: pFncGetPixel = GetPixelForN1BitLsbPal; break; + case ScanlineFormat::N4BitMsnPal: pFncGetPixel = GetPixelForN4BitMsnPal; break; + case ScanlineFormat::N4BitLsnPal: pFncGetPixel = GetPixelForN4BitLsnPal; break; + case ScanlineFormat::N8BitPal: pFncGetPixel = GetPixelForN8BitPal; break; + case ScanlineFormat::N8BitTcMask: pFncGetPixel = GetPixelForN8BitTcMask; break; + case ScanlineFormat::N24BitTcBgr: pFncGetPixel = GetPixelForN24BitTcBgr; break; + case ScanlineFormat::N24BitTcRgb: pFncGetPixel = GetPixelForN24BitTcRgb; break; + case ScanlineFormat::N32BitTcAbgr: + if (Bitmap32IsPreMultipled()) + pFncGetPixel = GetPixelForN32BitTcAbgr; + else + pFncGetPixel = GetPixelForN32BitTcXbgr; + break; + case ScanlineFormat::N32BitTcArgb: + if (Bitmap32IsPreMultipled()) + pFncGetPixel = GetPixelForN32BitTcArgb; + else + pFncGetPixel = GetPixelForN32BitTcXrgb; + break; + case ScanlineFormat::N32BitTcBgra: + if (Bitmap32IsPreMultipled()) + pFncGetPixel = GetPixelForN32BitTcBgra; + else + pFncGetPixel = GetPixelForN32BitTcBgrx; + break; + case ScanlineFormat::N32BitTcRgba: + if (Bitmap32IsPreMultipled()) + pFncGetPixel = GetPixelForN32BitTcRgba; + else + pFncGetPixel = GetPixelForN32BitTcRgbx; + break; + case ScanlineFormat::N32BitTcMask: + pFncGetPixel = GetPixelForN32BitTcMask; break; - } - if( pFncGetPixel ) - { - const ColorMask aDummyMask; - Scanline pScanline = GetScanline(nY); - for (long nX = 0, nWidth = mpBuffer->mnWidth; nX < nWidth; ++nX) - SetPixelOnData(pScanline, nX, pFncGetPixel(aSrcScanline, nX, aDummyMask)); - } + default: + assert(false); + pFncGetPixel = nullptr; + break; + } + + if( pFncGetPixel ) + { + const ColorMask aDummyMask; + Scanline pScanline = GetScanline(nY); + for (long nX = 0, nWidth = mpBuffer->mnWidth; nX < nWidth; ++nX) + SetPixelOnData(pScanline, nX, pFncGetPixel(aSrcScanline, nX, aDummyMask)); } } } diff --git a/vcl/source/gdi/bmpacc3.cxx b/vcl/source/gdi/bmpacc3.cxx index f2fc66427e29..7e107d248c89 100644 --- a/vcl/source/gdi/bmpacc3.cxx +++ b/vcl/source/gdi/bmpacc3.cxx @@ -99,134 +99,134 @@ void BitmapWriteAccess::Erase( const Color& rColor ) void BitmapWriteAccess::DrawLine( const Point& rStart, const Point& rEnd ) { - if (mpLineColor) + if (!mpLineColor) + return; + + const BitmapColor& rLineColor = *mpLineColor; + long nX, nY; + + if (rStart.X() == rEnd.X()) { - const BitmapColor& rLineColor = *mpLineColor; - long nX, nY; + // Vertical Line + const long nEndY = rEnd.Y(); + + nX = rStart.X(); + nY = rStart.Y(); - if (rStart.X() == rEnd.X()) + if (nEndY > nY) { - // Vertical Line - const long nEndY = rEnd.Y(); + for (; nY <= nEndY; nY++ ) + SetPixel( nY, nX, rLineColor ); + } + else + { + for (; nY >= nEndY; nY-- ) + SetPixel( nY, nX, rLineColor ); + } + } + else if (rStart.Y() == rEnd.Y()) + { + // Horizontal Line + const long nEndX = rEnd.X(); - nX = rStart.X(); - nY = rStart.Y(); + nX = rStart.X(); + nY = rStart.Y(); - if (nEndY > nY) - { - for (; nY <= nEndY; nY++ ) - SetPixel( nY, nX, rLineColor ); - } - else - { - for (; nY >= nEndY; nY-- ) - SetPixel( nY, nX, rLineColor ); - } + if (nEndX > nX) + { + for (; nX <= nEndX; nX++) + SetPixel(nY, nX, rLineColor); } - else if (rStart.Y() == rEnd.Y()) + else { - // Horizontal Line - const long nEndX = rEnd.X(); - - nX = rStart.X(); - nY = rStart.Y(); + for (; nX >= nEndX; nX--) + SetPixel(nY, nX, rLineColor); + } + } + else + { + const long nDX = labs( rEnd.X() - rStart.X() ); + const long nDY = labs( rEnd.Y() - rStart.Y() ); + long nX1; + long nY1; + long nX2; + long nY2; - if (nEndX > nX) + if (nDX >= nDY) + { + if (rStart.X() < rEnd.X()) { - for (; nX <= nEndX; nX++) - SetPixel(nY, nX, rLineColor); + nX1 = rStart.X(); + nY1 = rStart.Y(); + nX2 = rEnd.X(); + nY2 = rEnd.Y(); } else { - for (; nX >= nEndX; nX--) - SetPixel(nY, nX, rLineColor); + nX1 = rEnd.X(); + nY1 = rEnd.Y(); + nX2 = rStart.X(); + nY2 = rStart.Y(); } - } - else - { - const long nDX = labs( rEnd.X() - rStart.X() ); - const long nDY = labs( rEnd.Y() - rStart.Y() ); - long nX1; - long nY1; - long nX2; - long nY2; - - if (nDX >= nDY) - { - if (rStart.X() < rEnd.X()) - { - nX1 = rStart.X(); - nY1 = rStart.Y(); - nX2 = rEnd.X(); - nY2 = rEnd.Y(); - } - else - { - nX1 = rEnd.X(); - nY1 = rEnd.Y(); - nX2 = rStart.X(); - nY2 = rStart.Y(); - } - const long nDYX = (nDY - nDX) << 1; - const long nDY2 = nDY << 1; - long nD = nDY2 - nDX; - bool bPos = nY1 < nY2; + const long nDYX = (nDY - nDX) << 1; + const long nDY2 = nDY << 1; + long nD = nDY2 - nDX; + bool bPos = nY1 < nY2; - for (nX = nX1, nY = nY1; nX <= nX2; nX++) + for (nX = nX1, nY = nY1; nX <= nX2; nX++) + { + SetPixel(nY, nX, rLineColor); + + if (nD < 0) + nD += nDY2; + else { - SetPixel(nY, nX, rLineColor); + nD += nDYX; - if (nD < 0) - nD += nDY2; + if (bPos) + nY++; else - { - nD += nDYX; - - if (bPos) - nY++; - else - nY--; - } + nY--; } } + } + else + { + if (rStart.Y() < rEnd.Y()) + { + nX1 = rStart.X(); + nY1 = rStart.Y(); + nX2 = rEnd.X(); + nY2 = rEnd.Y(); + } else { - if (rStart.Y() < rEnd.Y()) - { - nX1 = rStart.X(); - nY1 = rStart.Y(); - nX2 = rEnd.X(); - nY2 = rEnd.Y(); - } - else - { - nX1 = rEnd.X(); - nY1 = rEnd.Y(); - nX2 = rStart.X(); - nY2 = rStart.Y(); - } + nX1 = rEnd.X(); + nY1 = rEnd.Y(); + nX2 = rStart.X(); + nY2 = rStart.Y(); + } - const long nDYX = (nDX - nDY) << 1; - const long nDY2 = nDX << 1; - long nD = nDY2 - nDY; - bool bPos = nX1 < nX2; + const long nDYX = (nDX - nDY) << 1; + const long nDY2 = nDX << 1; + long nD = nDY2 - nDY; + bool bPos = nX1 < nX2; + + for (nX = nX1, nY = nY1; nY <= nY2; nY++) + { + SetPixel(nY, nX, rLineColor); - for (nX = nX1, nY = nY1; nY <= nY2; nY++) + if (nD < 0) + nD += nDY2; + else { - SetPixel(nY, nX, rLineColor); + nD += nDYX; - if (nD < 0) - nD += nDY2; + if (bPos) + nX++; else - { - nD += nDYX; - - if (bPos) - nX++; - else - nX--; - } + nX--; } } } @@ -235,28 +235,28 @@ void BitmapWriteAccess::DrawLine( const Point& rStart, const Point& rEnd ) void BitmapWriteAccess::FillRect( const tools::Rectangle& rRect ) { - if (mpFillColor) - { - const BitmapColor& rFillColor = *mpFillColor; - tools::Rectangle aRect(Point(), maBitmap.GetSizePixel()); + if (!mpFillColor) + return; - aRect.Intersection(rRect); + const BitmapColor& rFillColor = *mpFillColor; + tools::Rectangle aRect(Point(), maBitmap.GetSizePixel()); - if (!aRect.IsEmpty()) - { - const long nStartX = rRect.Left(); - const long nStartY = rRect.Top(); - const long nEndX = rRect.Right(); - const long nEndY = rRect.Bottom(); + aRect.Intersection(rRect); - for (long nY = nStartY; nY <= nEndY; nY++) - { - Scanline pScanline = GetScanline( nY ); - for (long nX = nStartX; nX <= nEndX; nX++) - { - SetPixelOnData(pScanline, nX, rFillColor); - } - } + if (aRect.IsEmpty()) + return; + + const long nStartX = rRect.Left(); + const long nStartY = rRect.Top(); + const long nEndX = rRect.Right(); + const long nEndY = rRect.Bottom(); + + for (long nY = nStartY; nY <= nEndY; nY++) + { + Scanline pScanline = GetScanline( nY ); + for (long nX = nStartX; nX <= nEndX; nX++) + { + SetPixelOnData(pScanline, nX, rFillColor); } } } diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 7a4d2343e300..246b3c91f4de 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -324,67 +324,67 @@ void GDIMetaFile::Record( OutputDevice* pOut ) void GDIMetaFile::Play( GDIMetaFile& rMtf ) { - if ( !m_bRecord && !rMtf.m_bRecord ) - { - MetaAction* pAction = GetCurAction(); - const size_t nObjCount = m_aList.size(); + if (m_bRecord || rMtf.m_bRecord) + return; - rMtf.UseCanvas( rMtf.GetUseCanvas() || m_bUseCanvas ); + MetaAction* pAction = GetCurAction(); + const size_t nObjCount = m_aList.size(); - for( size_t nCurPos = m_nCurrentActionElement; nCurPos < nObjCount; nCurPos++ ) - { - if( pAction ) - { - rMtf.AddAction( pAction ); - } + rMtf.UseCanvas( rMtf.GetUseCanvas() || m_bUseCanvas ); - pAction = NextAction(); + for( size_t nCurPos = m_nCurrentActionElement; nCurPos < nObjCount; nCurPos++ ) + { + if( pAction ) + { + rMtf.AddAction( pAction ); } + + pAction = NextAction(); } } void GDIMetaFile::Play( OutputDevice* pOut, size_t nPos ) { - if( !m_bRecord ) - { - MetaAction* pAction = GetCurAction(); - const size_t nObjCount = m_aList.size(); - size_t nSyncCount = pOut->GetSyncCount(); + if( m_bRecord ) + return; - if( nPos > nObjCount ) - nPos = nObjCount; + MetaAction* pAction = GetCurAction(); + const size_t nObjCount = m_aList.size(); + size_t nSyncCount = pOut->GetSyncCount(); - // #i23407# Set backwards-compatible text language and layout mode - // This is necessary, since old metafiles don't even know of these - // recent add-ons. Newer metafiles must of course explicitly set - // those states. - pOut->Push( PushFlags::TEXTLAYOUTMODE|PushFlags::TEXTLANGUAGE ); - pOut->SetLayoutMode( ComplexTextLayoutFlags::Default ); - pOut->SetDigitLanguage( LANGUAGE_SYSTEM ); + if( nPos > nObjCount ) + nPos = nObjCount; - SAL_INFO( "vcl.gdi", "GDIMetaFile::Play on device of size: " << pOut->GetOutputSizePixel().Width() << " " << pOut->GetOutputSizePixel().Height()); + // #i23407# Set backwards-compatible text language and layout mode + // This is necessary, since old metafiles don't even know of these + // recent add-ons. Newer metafiles must of course explicitly set + // those states. + pOut->Push( PushFlags::TEXTLAYOUTMODE|PushFlags::TEXTLANGUAGE ); + pOut->SetLayoutMode( ComplexTextLayoutFlags::Default ); + pOut->SetDigitLanguage( LANGUAGE_SYSTEM ); + + SAL_INFO( "vcl.gdi", "GDIMetaFile::Play on device of size: " << pOut->GetOutputSizePixel().Width() << " " << pOut->GetOutputSizePixel().Height()); - if( !ImplPlayWithRenderer( pOut, Point(0,0), pOut->GetOutputSize() ) ) { - size_t i = 0; - for( size_t nCurPos = m_nCurrentActionElement; nCurPos < nPos; nCurPos++ ) + if( !ImplPlayWithRenderer( pOut, Point(0,0), pOut->GetOutputSize() ) ) { + size_t i = 0; + for( size_t nCurPos = m_nCurrentActionElement; nCurPos < nPos; nCurPos++ ) + { + if( pAction ) { - if( pAction ) - { - pAction->Execute( pOut ); + pAction->Execute( pOut ); - // flush output from time to time - if( i++ > nSyncCount ) - { - static_cast<vcl::Window*>( pOut )->Flush(); - i = 0; - } + // flush output from time to time + if( i++ > nSyncCount ) + { + static_cast<vcl::Window*>( pOut )->Flush(); + i = 0; } - - pAction = NextAction(); } + + pAction = NextAction(); } - pOut->Pop(); } + pOut->Pop(); } bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, Size rLogicDestSize ) @@ -520,21 +520,21 @@ void GDIMetaFile::Play( OutputDevice* pOut, const Point& rPos, void GDIMetaFile::Pause( bool _bPause ) { - if( m_bRecord ) - { - if( _bPause ) - { - if( !m_bPause ) - Linker( m_pOutDev, false ); - } - else - { - if( m_bPause ) - Linker( m_pOutDev, true ); - } + if( !m_bRecord ) + return; - m_bPause = _bPause; + if( _bPause ) + { + if( !m_bPause ) + Linker( m_pOutDev, false ); } + else + { + if( m_bPause ) + Linker( m_pOutDev, true ); + } + + m_bPause = _bPause; } void GDIMetaFile::Stop() @@ -1287,20 +1287,20 @@ static void ImplActionBounds( tools::Rectangle& o_rOutBounds, tools::Rectangle aBounds( i_rInBounds ); if( ! i_rInBounds.IsEmpty() && ! i_rClipStack.empty() && ! i_rClipStack.back().IsEmpty() ) aBounds.Intersection( i_rClipStack.back() ); - if( ! aBounds.IsEmpty() ) + if( aBounds.IsEmpty() ) + return; + + if( ! o_rOutBounds.IsEmpty() ) + o_rOutBounds.Union( aBounds ); + else + o_rOutBounds = aBounds; + + if(o_pHairline) { - if( ! o_rOutBounds.IsEmpty() ) - o_rOutBounds.Union( aBounds ); + if( ! o_pHairline->IsEmpty() ) + o_pHairline->Union( aBounds ); else - o_rOutBounds = aBounds; - - if(o_pHairline) - { - if( ! o_pHairline->IsEmpty() ) - o_pHairline->Union( aBounds ); - else - *o_pHairline = aBounds; - } + *o_pHairline = aBounds; } } diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx index a750586fc38c..d442cfca49b7 100644 --- a/vcl/source/gdi/impvect.cxx +++ b/vcl/source/gdi/impvect.cxx @@ -747,34 +747,34 @@ bool ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf, void ImplLimitPolyPoly( tools::PolyPolygon& rPolyPoly ) { - if( rPolyPoly.Count() > VECT_POLY_MAX ) + if( rPolyPoly.Count() <= VECT_POLY_MAX ) + return; + + tools::PolyPolygon aNewPolyPoly; + long nReduce = 0; + sal_uInt16 nNewCount; + + do { - tools::PolyPolygon aNewPolyPoly; - long nReduce = 0; - sal_uInt16 nNewCount; + aNewPolyPoly.Clear(); + nReduce++; - do + for( sal_uInt16 i = 0, nCount = rPolyPoly.Count(); i < nCount; i++ ) { - aNewPolyPoly.Clear(); - nReduce++; + const tools::Rectangle aBound( rPolyPoly[ i ].GetBoundRect() ); - for( sal_uInt16 i = 0, nCount = rPolyPoly.Count(); i < nCount; i++ ) + if( aBound.GetWidth() > nReduce && aBound.GetHeight() > nReduce ) { - const tools::Rectangle aBound( rPolyPoly[ i ].GetBoundRect() ); - - if( aBound.GetWidth() > nReduce && aBound.GetHeight() > nReduce ) - { - if( rPolyPoly[ i ].GetSize() ) - aNewPolyPoly.Insert( rPolyPoly[ i ] ); - } + if( rPolyPoly[ i ].GetSize() ) + aNewPolyPoly.Insert( rPolyPoly[ i ] ); } - - nNewCount = aNewPolyPoly.Count(); } - while( nNewCount > VECT_POLY_MAX ); - rPolyPoly = aNewPolyPoly; + nNewCount = aNewPolyPoly.Count(); } + while( nNewCount > VECT_POLY_MAX ); + + rPolyPoly = aNewPolyPoly; } ImplVectMap* ImplExpand( BitmapReadAccess* pRAcc, const Color& rColor ) diff --git a/vcl/source/gdi/lineinfo.cxx b/vcl/source/gdi/lineinfo.cxx index dd460d77e4b5..602ac8af9f18 100644 --- a/vcl/source/gdi/lineinfo.cxx +++ b/vcl/source/gdi/lineinfo.cxx @@ -199,63 +199,63 @@ void LineInfo::applyToB2DPolyPolygon( { o_rFillPolyPolygon.clear(); - if(io_rLinePolyPolygon.count()) - { - if(LineStyle::Dash == GetStyle()) - { - ::std::vector< double > fDotDashArray; - const double fDashLen(GetDashLen()); - const double fDotLen(GetDotLen()); - const double fDistance(GetDistance()); - - for(sal_uInt16 a(0); a < GetDashCount(); a++) - { - fDotDashArray.push_back(fDashLen); - fDotDashArray.push_back(fDistance); - } + if(!io_rLinePolyPolygon.count()) + return; - for(sal_uInt16 b(0); b < GetDotCount(); b++) - { - fDotDashArray.push_back(fDotLen); - fDotDashArray.push_back(fDistance); - } + if(LineStyle::Dash == GetStyle()) + { + ::std::vector< double > fDotDashArray; + const double fDashLen(GetDashLen()); + const double fDotLen(GetDotLen()); + const double fDistance(GetDistance()); - const double fAccumulated(::std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0)); + for(sal_uInt16 a(0); a < GetDashCount(); a++) + { + fDotDashArray.push_back(fDashLen); + fDotDashArray.push_back(fDistance); + } - if(fAccumulated > 0.0) - { - basegfx::B2DPolyPolygon aResult; - - for(auto const& rPolygon : io_rLinePolyPolygon) - { - basegfx::B2DPolyPolygon aLineTraget; - basegfx::utils::applyLineDashing( - rPolygon, - fDotDashArray, - &aLineTraget); - aResult.append(aLineTraget); - } - - io_rLinePolyPolygon = aResult; - } + for(sal_uInt16 b(0); b < GetDotCount(); b++) + { + fDotDashArray.push_back(fDotLen); + fDotDashArray.push_back(fDistance); } - if(GetWidth() > 1 && io_rLinePolyPolygon.count()) + const double fAccumulated(::std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0)); + + if(fAccumulated > 0.0) { - const double fHalfLineWidth((GetWidth() * 0.5) + 0.5); + basegfx::B2DPolyPolygon aResult; for(auto const& rPolygon : io_rLinePolyPolygon) { - o_rFillPolyPolygon.append(basegfx::utils::createAreaGeometry( + basegfx::B2DPolyPolygon aLineTraget; + basegfx::utils::applyLineDashing( rPolygon, - fHalfLineWidth, - GetLineJoin(), - GetLineCap())); + fDotDashArray, + &aLineTraget); + aResult.append(aLineTraget); } - io_rLinePolyPolygon.clear(); + io_rLinePolyPolygon = aResult; } } + + if(!(GetWidth() > 1 && io_rLinePolyPolygon.count())) + return; + + const double fHalfLineWidth((GetWidth() * 0.5) + 0.5); + + for(auto const& rPolygon : io_rLinePolyPolygon) + { + o_rFillPolyPolygon.append(basegfx::utils::createAreaGeometry( + rPolygon, + fHalfLineWidth, + GetLineJoin(), + GetLineCap())); + } + + io_rLinePolyPolygon.clear(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 0f55e2fbe00d..b84af258ebc9 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -979,32 +979,32 @@ void MetaPolyPolygonAction::Read( SvStream& rIStm, ImplMetaReadData* ) VersionCompat aCompat(rIStm, StreamMode::READ); ReadPolyPolygon( rIStm, maPolyPoly ); // Version 1 - if ( aCompat.GetVersion() >= 2 ) // Version 2 + if ( aCompat.GetVersion() < 2 ) // Version 2 + return; + + sal_uInt16 nNumberOfComplexPolygons(0); + rIStm.ReadUInt16( nNumberOfComplexPolygons ); + const size_t nMinRecordSize = sizeof(sal_uInt16); + const size_t nMaxRecords = rIStm.remainingSize() / nMinRecordSize; + if (nNumberOfComplexPolygons > nMaxRecords) { - sal_uInt16 nNumberOfComplexPolygons(0); - rIStm.ReadUInt16( nNumberOfComplexPolygons ); - const size_t nMinRecordSize = sizeof(sal_uInt16); - const size_t nMaxRecords = rIStm.remainingSize() / nMinRecordSize; - if (nNumberOfComplexPolygons > nMaxRecords) - { - SAL_WARN("vcl.gdi", "Parsing error: " << nMaxRecords << - " max possible entries, but " << nNumberOfComplexPolygons << " claimed, truncating"); - nNumberOfComplexPolygons = nMaxRecords; - } - for (sal_uInt16 i = 0; i < nNumberOfComplexPolygons; ++i) + SAL_WARN("vcl.gdi", "Parsing error: " << nMaxRecords << + " max possible entries, but " << nNumberOfComplexPolygons << " claimed, truncating"); + nNumberOfComplexPolygons = nMaxRecords; + } + for (sal_uInt16 i = 0; i < nNumberOfComplexPolygons; ++i) + { + sal_uInt16 nIndex(0); + rIStm.ReadUInt16( nIndex ); + tools::Polygon aPoly; + aPoly.Read( rIStm ); + if (nIndex >= maPolyPoly.Count()) { - sal_uInt16 nIndex(0); - rIStm.ReadUInt16( nIndex ); - tools::Polygon aPoly; - aPoly.Read( rIStm ); - if (nIndex >= maPolyPoly.Count()) - { - SAL_WARN("vcl.gdi", "svm contains polygon index " << nIndex - << " outside possible range " << maPolyPoly.Count()); - continue; - } - maPolyPoly.Replace( aPoly, nIndex ); + SAL_WARN("vcl.gdi", "svm contains polygon index " << nIndex + << " outside possible range " << maPolyPoly.Count()); + continue; } + maPolyPoly.Replace( aPoly, nIndex ); } } @@ -3183,54 +3183,54 @@ rtl::Reference<MetaAction> MetaCommentAction::Clone() void MetaCommentAction::Move( long nXMove, long nYMove ) { - if ( nXMove || nYMove ) + if ( !(nXMove || nYMove) ) + return; + + if ( !(mnDataSize && mpData) ) + return; + + bool bPathStroke = (maComment == "XPATHSTROKE_SEQ_BEGIN"); + if ( !(bPathStroke || maComment == "XPATHFILL_SEQ_BEGIN") ) + return; + + SvMemoryStream aMemStm( static_cast<void*>(mpData.get()), mnDataSize, StreamMode::READ ); + SvMemoryStream aDest; + if ( bPathStroke ) { - if ( mnDataSize && mpData ) - { - bool bPathStroke = (maComment == "XPATHSTROKE_SEQ_BEGIN"); - if ( bPathStroke || maComment == "XPATHFILL_SEQ_BEGIN" ) - { - SvMemoryStream aMemStm( static_cast<void*>(mpData.get()), mnDataSize, StreamMode::READ ); - SvMemoryStream aDest; - if ( bPathStroke ) - { - SvtGraphicStroke aStroke; - ReadSvtGraphicStroke( aMemStm, aStroke ); + SvtGraphicStroke aStroke; + ReadSvtGraphicStroke( aMemStm, aStroke ); - tools::Polygon aPath; - aStroke.getPath( aPath ); - aPath.Move( nXMove, nYMove ); - aStroke.setPath( aPath ); + tools::Polygon aPath; + aStroke.getPath( aPath ); + aPath.Move( nXMove, nYMove ); + aStroke.setPath( aPath ); - tools::PolyPolygon aStartArrow; - aStroke.getStartArrow(aStartArrow); - aStartArrow.Move(nXMove, nYMove); - aStroke.setStartArrow(aStartArrow); + tools::PolyPolygon aStartArrow; + aStroke.getStartArrow(aStartArrow); + aStartArrow.Move(nXMove, nYMove); + aStroke.setStartArrow(aStartArrow); - tools::PolyPolygon aEndArrow; - aStroke.getEndArrow(aEndArrow); - aEndArrow.Move(nXMove, nYMove); - aStroke.setEndArrow(aEndArrow); + tools::PolyPolygon aEndArrow; + aStroke.getEndArrow(aEndArrow); + aEndArrow.Move(nXMove, nYMove); + aStroke.setEndArrow(aEndArrow); - WriteSvtGraphicStroke( aDest, aStroke ); - } - else - { - SvtGraphicFill aFill; - ReadSvtGraphicFill( aMemStm, aFill ); + WriteSvtGraphicStroke( aDest, aStroke ); + } + else + { + SvtGraphicFill aFill; + ReadSvtGraphicFill( aMemStm, aFill ); - tools::PolyPolygon aPath; - aFill.getPath( aPath ); - aPath.Move( nXMove, nYMove ); - aFill.setPath( aPath ); + tools::PolyPolygon aPath; + aFill.getPath( aPath ); + aPath.Move( nXMove, nYMove ); + aFill.setPath( aPath ); - WriteSvtGraphicFill( aDest, aFill ); - } - mpData.reset(); - ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() ); - } - } + WriteSvtGraphicFill( aDest, aFill ); } + mpData.reset(); + ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() ); } // SJ: 25.07.06 #i56656# we are not able to mirror certain kind of @@ -3239,62 +3239,62 @@ void MetaCommentAction::Move( long nXMove, long nYMove ) // FIXME: fake comment to apply the next hunk in the right location void MetaCommentAction::Scale( double fXScale, double fYScale ) { - if ( ( fXScale != 1.0 ) || ( fYScale != 1.0 ) ) + if (( fXScale == 1.0 ) && ( fYScale == 1.0 )) + return; + + if ( !(mnDataSize && mpData) ) + return; + + bool bPathStroke = (maComment == "XPATHSTROKE_SEQ_BEGIN"); + if ( bPathStroke || maComment == "XPATHFILL_SEQ_BEGIN" ) { - if ( mnDataSize && mpData ) + SvMemoryStream aMemStm( static_cast<void*>(mpData.get()), mnDataSize, StreamMode::READ ); + SvMemoryStream aDest; + if ( bPathStroke ) { - bool bPathStroke = (maComment == "XPATHSTROKE_SEQ_BEGIN"); - if ( bPathStroke || maComment == "XPATHFILL_SEQ_BEGIN" ) - { - SvMemoryStream aMemStm( static_cast<void*>(mpData.get()), mnDataSize, StreamMode::READ ); - SvMemoryStream aDest; - if ( bPathStroke ) - { - SvtGraphicStroke aStroke; - ReadSvtGraphicStroke( aMemStm, aStroke ); - aStroke.scale( fXScale, fYScale ); - WriteSvtGraphicStroke( aDest, aStroke ); - } - else - { - SvtGraphicFill aFill; - ReadSvtGraphicFill( aMemStm, aFill ); - tools::PolyPolygon aPath; - aFill.getPath( aPath ); - aPath.Scale( fXScale, fYScale ); - aFill.setPath( aPath ); - WriteSvtGraphicFill( aDest, aFill ); - } - mpData.reset(); - ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() ); - } else if( maComment == "EMF_PLUS_HEADER_INFO" ){ - SvMemoryStream aMemStm( static_cast<void*>(mpData.get()), mnDataSize, StreamMode::READ ); - SvMemoryStream aDest; - - sal_Int32 nLeft(0), nRight(0), nTop(0), nBottom(0); - sal_Int32 nPixX(0), nPixY(0), nMillX(0), nMillY(0); - float m11(0), m12(0), m21(0), m22(0), mdx(0), mdy(0); - - // read data - aMemStm.ReadInt32( nLeft ).ReadInt32( nTop ).ReadInt32( nRight ).ReadInt32( nBottom ); - aMemStm.ReadInt32( nPixX ).ReadInt32( nPixY ).ReadInt32( nMillX ).ReadInt32( nMillY ); - aMemStm.ReadFloat( m11 ).ReadFloat( m12 ).ReadFloat( m21 ).ReadFloat( m22 ).ReadFloat( mdx ).ReadFloat( mdy ); - - // add scale to the transformation - m11 *= fXScale; - m12 *= fXScale; - m22 *= fYScale; - m21 *= fYScale; - - // prepare new data - aDest.WriteInt32( nLeft ).WriteInt32( nTop ).WriteInt32( nRight ).WriteInt32( nBottom ); - aDest.WriteInt32( nPixX ).WriteInt32( nPixY ).WriteInt32( nMillX ).WriteInt32( nMillY ); - aDest.WriteFloat( m11 ).WriteFloat( m12 ).WriteFloat( m21 ).WriteFloat( m22 ).WriteFloat( mdx ).WriteFloat( mdy ); - - // save them - ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() ); - } + SvtGraphicStroke aStroke; + ReadSvtGraphicStroke( aMemStm, aStroke ); + aStroke.scale( fXScale, fYScale ); + WriteSvtGraphicStroke( aDest, aStroke ); + } + else + { + SvtGraphicFill aFill; + ReadSvtGraphicFill( aMemStm, aFill ); + tools::PolyPolygon aPath; + aFill.getPath( aPath ); + aPath.Scale( fXScale, fYScale ); + aFill.setPath( aPath ); + WriteSvtGraphicFill( aDest, aFill ); } + mpData.reset(); + ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() ); + } else if( maComment == "EMF_PLUS_HEADER_INFO" ){ + SvMemoryStream aMemStm( static_cast<void*>(mpData.get()), mnDataSize, StreamMode::READ ); + SvMemoryStream aDest; + + sal_Int32 nLeft(0), nRight(0), nTop(0), nBottom(0); + sal_Int32 nPixX(0), nPixY(0), nMillX(0), nMillY(0); + float m11(0), m12(0), m21(0), m22(0), mdx(0), mdy(0); + + // read data + aMemStm.ReadInt32( nLeft ).ReadInt32( nTop ).ReadInt32( nRight ).ReadInt32( nBottom ); + aMemStm.ReadInt32( nPixX ).ReadInt32( nPixY ).ReadInt32( nMillX ).ReadInt32( nMillY ); + aMemStm.ReadFloat( m11 ).ReadFloat( m12 ).ReadFloat( m21 ).ReadFloat( m22 ).ReadFloat( mdx ).ReadFloat( mdy ); + + // add scale to the transformation + m11 *= fXScale; + m12 *= fXScale; + m22 *= fYScale; + m21 *= fYScale; + + // prepare new data + aDest.WriteInt32( nLeft ).WriteInt32( nTop ).WriteInt32( nRight ).WriteInt32( nBottom ); + aDest.WriteInt32( nPixX ).WriteInt32( nPixY ).WriteInt32( nMillX ).WriteInt32( nMillY ); + aDest.WriteFloat( m11 ).WriteFloat( m12 ).WriteFloat( m21 ).WriteFloat( m22 ).WriteFloat( mdx ).WriteFloat( mdy ); + + // save them + ImplInitDynamicData( static_cast<const sal_uInt8*>( aDest.GetData() ), aDest.Tell() ); } } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index e40cc7c00872..b814d871702e 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -525,39 +525,39 @@ void appendDouble( double fValue, OStringBuffer& rBuffer, sal_Int32 nPrecision = if( bNeg && ( nInt || nFrac ) ) rBuffer.append( '-' ); rBuffer.append( nInt ); - if( nFrac ) + if( !nFrac ) + return; + + int i; + rBuffer.append( '.' ); + sal_Int64 nBound = static_cast<sal_Int64>(pow( 10.0, nPrecision - 1.0 )+0.5); + for ( i = 0; ( i < nPrecision ) && nFrac; i++ ) { - int i; - rBuffer.append( '.' ); - sal_Int64 nBound = static_cast<sal_Int64>(pow( 10.0, nPrecision - 1.0 )+0.5); - for ( i = 0; ( i < nPrecision ) && nFrac; i++ ) - { - sal_Int64 nNumb = nFrac / nBound; - nFrac -= nNumb * nBound; - rBuffer.append( nNumb ); - nBound /= 10; - } + sal_Int64 nNumb = nFrac / nBound; + nFrac -= nNumb * nBound; + rBuffer.append( nNumb ); + nBound /= 10; } } void appendColor( const Color& rColor, OStringBuffer& rBuffer, bool bConvertToGrey ) { - if( rColor != COL_TRANSPARENT ) + if( rColor == COL_TRANSPARENT ) + return; + + if( bConvertToGrey ) { - if( bConvertToGrey ) - { - sal_uInt8 cByte = rColor.GetLuminance(); - appendDouble( static_cast<double>(cByte) / 255.0, rBuffer ); - } - else - { - appendDouble( static_cast<double>(rColor.GetRed()) / 255.0, rBuffer ); - rBuffer.append( ' ' ); - appendDouble( static_cast<double>(rColor.GetGreen()) / 255.0, rBuffer ); - rBuffer.append( ' ' ); - appendDouble( static_cast<double>(rColor.GetBlue()) / 255.0, rBuffer ); - } + sal_uInt8 cByte = rColor.GetLuminance(); + appendDouble( static_cast<double>(cByte) / 255.0, rBuffer ); + } + else + { + appendDouble( static_cast<double>(rColor.GetRed()) / 255.0, rBuffer ); + rBuffer.append( ' ' ); + appendDouble( static_cast<double>(rColor.GetGreen()) / 255.0, rBuffer ); + rBuffer.append( ' ' ); + appendDouble( static_cast<double>(rColor.GetBlue()) / 255.0, rBuffer ); } } @@ -924,42 +924,42 @@ void PDFPage::appendPolygon( const tools::Polygon& rPoly, OStringBuffer& rBuffer * #108582# applications do weird things */ sal_uInt32 nBufLen = rBuffer.getLength(); - if( nPoints > 0 ) + if( nPoints <= 0 ) + return; + + const PolyFlags* pFlagArray = rPoly.GetConstFlagAry(); + appendPoint( rPoly[0], rBuffer ); + rBuffer.append( " m\n" ); + for( sal_uInt16 i = 1; i < nPoints; i++ ) { - const PolyFlags* pFlagArray = rPoly.GetConstFlagAry(); - appendPoint( rPoly[0], rBuffer ); - rBuffer.append( " m\n" ); - for( sal_uInt16 i = 1; i < nPoints; i++ ) + if( pFlagArray && pFlagArray[i] == PolyFlags::Control && nPoints-i > 2 ) { - if( pFlagArray && pFlagArray[i] == PolyFlags::Control && nPoints-i > 2 ) - { - // bezier - SAL_WARN_IF( pFlagArray[i+1] != PolyFlags::Control || pFlagArray[i+2] == PolyFlags::Control, "vcl.pdfwriter", "unexpected sequence of control points" ); - appendPoint( rPoly[i], rBuffer ); - rBuffer.append( " " ); - appendPoint( rPoly[i+1], rBuffer ); - rBuffer.append( " " ); - appendPoint( rPoly[i+2], rBuffer ); - rBuffer.append( " c" ); - i += 2; // add additionally consumed points - } - else - { - // line - appendPoint( rPoly[i], rBuffer ); - rBuffer.append( " l" ); - } - if( (rBuffer.getLength() - nBufLen) > 65 ) - { - rBuffer.append( "\n" ); - nBufLen = rBuffer.getLength(); - } - else - rBuffer.append( " " ); + // bezier + SAL_WARN_IF( pFlagArray[i+1] != PolyFlags::Control || pFlagArray[i+2] == PolyFlags::Control, "vcl.pdfwriter", "unexpected sequence of control points" ); + appendPoint( rPoly[i], rBuffer ); + rBuffer.append( " " ); + appendPoint( rPoly[i+1], rBuffer ); + rBuffer.append( " " ); + appendPoint( rPoly[i+2], rBuffer ); + rBuffer.append( " c" ); + i += 2; // add additionally consumed points } - if( bClose ) - rBuffer.append( "h\n" ); + else + { + // line + appendPoint( rPoly[i], rBuffer ); + rBuffer.append( " l" ); + } + if( (rBuffer.getLength() - nBufLen) > 65 ) + { + rBuffer.append( "\n" ); + nBufLen = rBuffer.getLength(); + } + else + rBuffer.append( " " ); } + if( bClose ) + rBuffer.append( "h\n" ); } void PDFPage::appendPolygon( const basegfx::B2DPolygon& rPoly, OStringBuffer& rBuffer ) const @@ -982,59 +982,59 @@ void PDFPage::appendPolygon( const basegfx::B2DPolygon& rPoly, OStringBuffer& rB return; } sal_uInt32 nPoints = aPoly.count(); - if( nPoints > 0 ) + if( nPoints <= 0 ) + return; + + sal_uInt32 nBufLen = rBuffer.getLength(); + basegfx::B2DPoint aLastPoint( aPoly.getB2DPoint( 0 ) ); + appendPixelPoint( aLastPoint, rBuffer ); + rBuffer.append( " m\n" ); + for( sal_uInt32 i = 1; i <= nPoints; i++ ) { - sal_uInt32 nBufLen = rBuffer.getLength(); - basegfx::B2DPoint aLastPoint( aPoly.getB2DPoint( 0 ) ); - appendPixelPoint( aLastPoint, rBuffer ); - rBuffer.append( " m\n" ); - for( sal_uInt32 i = 1; i <= nPoints; i++ ) + if( i != nPoints || aPoly.isClosed() ) { - if( i != nPoints || aPoly.isClosed() ) + sal_uInt32 nCurPoint = i % nPoints; + sal_uInt32 nLastPoint = i-1; + basegfx::B2DPoint aPoint( aPoly.getB2DPoint( nCurPoint ) ); + if( aPoly.isNextControlPointUsed( nLastPoint ) && + aPoly.isPrevControlPointUsed( nCurPoint ) ) { - sal_uInt32 nCurPoint = i % nPoints; - sal_uInt32 nLastPoint = i-1; - basegfx::B2DPoint aPoint( aPoly.getB2DPoint( nCurPoint ) ); - if( aPoly.isNextControlPointUsed( nLastPoint ) && - aPoly.isPrevControlPointUsed( nCurPoint ) ) - { - appendPixelPoint( aPoly.getNextControlPoint( nLastPoint ), rBuffer ); - rBuffer.append( ' ' ); - appendPixelPoint( aPoly.getPrevControlPoint( nCurPoint ), rBuffer ); - rBuffer.append( ' ' ); - appendPixelPoint( aPoint, rBuffer ); - rBuffer.append( " c" ); - } - else if( aPoly.isNextControlPointUsed( nLastPoint ) ) - { - appendPixelPoint( aPoly.getNextControlPoint( nLastPoint ), rBuffer ); - rBuffer.append( ' ' ); - appendPixelPoint( aPoint, rBuffer ); - rBuffer.append( " y" ); - } - else if( aPoly.isPrevControlPointUsed( nCurPoint ) ) - { - appendPixelPoint( aPoly.getPrevControlPoint( nCurPoint ), rBuffer ); - rBuffer.append( ' ' ); - appendPixelPoint( aPoint, rBuffer ); - rBuffer.append( " v" ); - } - else - { - appendPixelPoint( aPoint, rBuffer ); - rBuffer.append( " l" ); - } - if( (rBuffer.getLength() - nBufLen) > 65 ) - { - rBuffer.append( "\n" ); - nBufLen = rBuffer.getLength(); - } - else - rBuffer.append( " " ); + appendPixelPoint( aPoly.getNextControlPoint( nLastPoint ), rBuffer ); + rBuffer.append( ' ' ); + appendPixelPoint( aPoly.getPrevControlPoint( nCurPoint ), rBuffer ); + rBuffer.append( ' ' ); + appendPixelPoint( aPoint, rBuffer ); + rBuffer.append( " c" ); + } + else if( aPoly.isNextControlPointUsed( nLastPoint ) ) + { + appendPixelPoint( aPoly.getNextControlPoint( nLastPoint ), rBuffer ); + rBuffer.append( ' ' ); + appendPixelPoint( aPoint, rBuffer ); + rBuffer.append( " y" ); } + else if( aPoly.isPrevControlPointUsed( nCurPoint ) ) + { + appendPixelPoint( aPoly.getPrevControlPoint( nCurPoint ), rBuffer ); + rBuffer.append( ' ' ); + appendPixelPoint( aPoint, rBuffer ); + rBuffer.append( " v" ); + } + else + { + appendPixelPoint( aPoint, rBuffer ); + rBuffer.append( " l" ); + } + if( (rBuffer.getLength() - nBufLen) > 65 ) + { + rBuffer.append( "\n" ); + nBufLen = rBuffer.getLength(); + } + else + rBuffer.append( " " ); } - rBuffer.append( "h\n" ); } + rBuffer.append( "h\n" ); } void PDFPage::appendPolyPolygon( const tools::PolyPolygon& rPolyPoly, OStringBuffer& rBuffer ) const @@ -7339,31 +7339,31 @@ void PDFWriterImpl::drawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uI void PDFWriterImpl::pushResource( ResourceKind eKind, const OString& rResource, sal_Int32 nObject ) { - if( nObject >= 0 ) + if( nObject < 0 ) + return; + + switch( eKind ) { - switch( eKind ) - { - case ResourceKind::XObject: - m_aGlobalResourceDict.m_aXObjects[ rResource ] = nObject; - if( ! m_aOutputStreams.empty() ) - m_aOutputStreams.front().m_aResourceDict.m_aXObjects[ rResource ] = nObject; - break; - case ResourceKind::ExtGState: - m_aGlobalResourceDict.m_aExtGStates[ rResource ] = nObject; - if( ! m_aOutputStreams.empty() ) - m_aOutputStreams.front().m_aResourceDict.m_aExtGStates[ rResource ] = nObject; - break; - case ResourceKind::Shading: - m_aGlobalResourceDict.m_aShadings[ rResource ] = nObject; - if( ! m_aOutputStreams.empty() ) - m_aOutputStreams.front().m_aResourceDict.m_aShadings[ rResource ] = nObject; - break; - case ResourceKind::Pattern: - m_aGlobalResourceDict.m_aPatterns[ rResource ] = nObject; - if( ! m_aOutputStreams.empty() ) - m_aOutputStreams.front().m_aResourceDict.m_aPatterns[ rResource ] = nObject; - break; - } + case ResourceKind::XObject: + m_aGlobalResourceDict.m_aXObjects[ rResource ] = nObject; + if( ! m_aOutputStreams.empty() ) + m_aOutputStreams.front().m_aResourceDict.m_aXObjects[ rResource ] = nObject; + break; + case ResourceKind::ExtGState: + m_aGlobalResourceDict.m_aExtGStates[ rResource ] = nObject; + if( ! m_aOutputStreams.empty() ) + m_aOutputStreams.front().m_aResourceDict.m_aExtGStates[ rResource ] = nObject; + break; + case ResourceKind::Shading: + m_aGlobalResourceDict.m_aShadings[ rResource ] = nObject; + if( ! m_aOutputStreams.empty() ) + m_aOutputStreams.front().m_aResourceDict.m_aShadings[ rResource ] = nObject; + break; + case ResourceKind::Pattern: + m_aGlobalResourceDict.m_aPatterns[ rResource ] = nObject; + if( ! m_aOutputStreams.empty() ) + m_aOutputStreams.front().m_aResourceDict.m_aPatterns[ rResource ] = nObject; + break; } } @@ -7979,21 +7979,21 @@ void PDFWriterImpl::drawPolyLine( const tools::Polygon& rPoly, const PDFWriter:: } writeBuffer( "Q\n", 2 ); - if( rInfo.m_fTransparency != 0.0 ) + if( rInfo.m_fTransparency == 0.0 ) + return; + + // FIXME: actually this may be incorrect with bezier polygons + tools::Rectangle aBoundRect( rPoly.GetBoundRect() ); + // avoid clipping with thick lines + if( rInfo.m_fLineWidth > 0.0 ) { - // FIXME: actually this may be incorrect with bezier polygons - tools::Rectangle aBoundRect( rPoly.GetBoundRect() ); - // avoid clipping with thick lines - if( rInfo.m_fLineWidth > 0.0 ) - { - sal_Int32 nLW = sal_Int32(rInfo.m_fLineWidth); - aBoundRect.AdjustTop( -nLW ); - aBoundRect.AdjustLeft( -nLW ); - aBoundRect.AdjustRight(nLW ); - aBoundRect.AdjustBottom(nLW ); - } - endTransparencyGroup( aBoundRect, static_cast<sal_uInt16>(100.0*rInfo.m_fTransparency) ); + sal_Int32 nLW = sal_Int32(rInfo.m_fLineWidth); + aBoundRect.AdjustTop( -nLW ); + aBoundRect.AdjustLeft( -nLW ); + aBoundRect.AdjustRight(nLW ); + aBoundRect.AdjustBottom(nLW ); } + endTransparencyGroup( aBoundRect, static_cast<sal_uInt16>(100.0*rInfo.m_fTransparency) ); } void PDFWriterImpl::drawPixel( const Point& rPoint, const Color& rColor ) @@ -9698,31 +9698,31 @@ void PDFWriterImpl::setClipRegion( const basegfx::B2DPolyPolygon& rRegion ) void PDFWriterImpl::moveClipRegion( sal_Int32 nX, sal_Int32 nY ) { - if( m_aGraphicsStack.front().m_bClipRegion && m_aGraphicsStack.front().m_aClipRegion.count() ) - { - // tdf#130150 improve coordinate manipulations to double precision transformations - basegfx::B2DHomMatrix aConvertA; - - if(MapUnit::MapPixel == m_aGraphicsStack.front().m_aMapMode.GetMapUnit()) - { - aConvertA = GetInverseViewTransformation(m_aMapMode); - } - else - { - aConvertA = LogicToLogic(m_aGraphicsStack.front().m_aMapMode, m_aMapMode); - } + if( !(m_aGraphicsStack.front().m_bClipRegion && m_aGraphicsStack.front().m_aClipRegion.count()) ) + return; - basegfx::B2DPoint aB2DPointA(nX, nY); - basegfx::B2DPoint aB2DPointB(0.0, 0.0); - aB2DPointA *= aConvertA; - aB2DPointB *= aConvertA; - aB2DPointA -= aB2DPointB; - basegfx::B2DHomMatrix aMat; + // tdf#130150 improve coordinate manipulations to double precision transformations + basegfx::B2DHomMatrix aConvertA; - aMat.translate(aB2DPointA.getX(), aB2DPointA.getY()); - m_aGraphicsStack.front().m_aClipRegion.transform( aMat ); - m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::ClipRegion; + if(MapUnit::MapPixel == m_aGraphicsStack.front().m_aMapMode.GetMapUnit()) + { + aConvertA = GetInverseViewTransformation(m_aMapMode); } + else + { + aConvertA = LogicToLogic(m_aGraphicsStack.front().m_aMapMode, m_aMapMode); + } + + basegfx::B2DPoint aB2DPointA(nX, nY); + basegfx::B2DPoint aB2DPointB(0.0, 0.0); + aB2DPointA *= aConvertA; + aB2DPointB *= aConvertA; + aB2DPointA -= aB2DPointB; + basegfx::B2DHomMatrix aMat; + + aMat.translate(aB2DPointA.getX(), aB2DPointA.getY()); + m_aGraphicsStack.front().m_aClipRegion.transform( aMat ); + m_aGraphicsStack.front().m_nUpdateFlags |= GraphicsStateUpdateFlags::ClipRegion; } void PDFWriterImpl::intersectClipRegion( const tools::Rectangle& rRect ) @@ -10269,62 +10269,62 @@ void PDFWriterImpl::addInternalStructureContainer( PDFStructureElement& rEle ) } } - if( rEle.m_nOwnElement != rEle.m_nParentElement ) - { - if( !rEle.m_aKids.empty() ) - { - if( rEle.m_aKids.size() > ncMaxPDFArraySize ) { - //then we need to add the containers for the kids elements - // a list to be used for the new kid element - std::list< PDFStructureElementKid > aNewKids; - std::list< sal_Int32 > aNewChildren; + if( rEle.m_nOwnElement == rEle.m_nParentElement ) + return; - // add Div in RoleMap, in case no one else did (TODO: is it needed? Is it dangerous?) - OString aAliasName("Div"); - addRoleMap(aAliasName, PDFWriter::Division); + if( rEle.m_aKids.empty() ) + return; - while( rEle.m_aKids.size() > ncMaxPDFArraySize ) - { - sal_Int32 nCurrentStructElement = rEle.m_nOwnElement; - sal_Int32 nNewId = sal_Int32(m_aStructure.size()); - m_aStructure.emplace_back( ); - PDFStructureElement& rEleNew = m_aStructure.back(); - rEleNew.m_aAlias = aAliasName; - rEleNew.m_eType = PDFWriter::Division; // a new Div type container - rEleNew.m_nOwnElement = nNewId; - rEleNew.m_nParentElement = nCurrentStructElement; - //inherit the same page as the first child to be reparented - rEleNew.m_nFirstPageObject = m_aStructure[ rEle.m_aChildren.front() ].m_nFirstPageObject; - rEleNew.m_nObject = createObject();//assign a PDF object number - //add the object to the kid list of the parent - aNewKids.emplace_back( rEleNew.m_nObject ); - aNewChildren.push_back( nNewId ); - - std::list< sal_Int32 >::iterator aChildEndIt( rEle.m_aChildren.begin() ); - std::list< PDFStructureElementKid >::iterator aKidEndIt( rEle.m_aKids.begin() ); - advance( aChildEndIt, ncMaxPDFArraySize ); - advance( aKidEndIt, ncMaxPDFArraySize ); - - rEleNew.m_aKids.splice( rEleNew.m_aKids.begin(), - rEle.m_aKids, - rEle.m_aKids.begin(), - aKidEndIt ); - rEleNew.m_aChildren.splice( rEleNew.m_aChildren.begin(), - rEle.m_aChildren, - rEle.m_aChildren.begin(), - aChildEndIt ); - // set the kid's new parent - for (auto const& child : rEleNew.m_aChildren) - { - m_aStructure[ child ].m_nParentElement = nNewId; - } - } - //finally add the new kids resulting from the container added - rEle.m_aKids.insert( rEle.m_aKids.begin(), aNewKids.begin(), aNewKids.end() ); - rEle.m_aChildren.insert( rEle.m_aChildren.begin(), aNewChildren.begin(), aNewChildren.end() ); - } - } - } + if( rEle.m_aKids.size() <= ncMaxPDFArraySize ) return; + + //then we need to add the containers for the kids elements + // a list to be used for the new kid element + std::list< PDFStructureElementKid > aNewKids; + std::list< sal_Int32 > aNewChildren; + + // add Div in RoleMap, in case no one else did (TODO: is it needed? Is it dangerous?) + OString aAliasName("Div"); + addRoleMap(aAliasName, PDFWriter::Division); + + while( rEle.m_aKids.size() > ncMaxPDFArraySize ) + { + sal_Int32 nCurrentStructElement = rEle.m_nOwnElement; + sal_Int32 nNewId = sal_Int32(m_aStructure.size()); + m_aStructure.emplace_back( ); + PDFStructureElement& rEleNew = m_aStructure.back(); + rEleNew.m_aAlias = aAliasName; + rEleNew.m_eType = PDFWriter::Division; // a new Div type container + rEleNew.m_nOwnElement = nNewId; + rEleNew.m_nParentElement = nCurrentStructElement; + //inherit the same page as the first child to be reparented + rEleNew.m_nFirstPageObject = m_aStructure[ rEle.m_aChildren.front() ].m_nFirstPageObject; + rEleNew.m_nObject = createObject();//assign a PDF object number + //add the object to the kid list of the parent + aNewKids.emplace_back( rEleNew.m_nObject ); + aNewChildren.push_back( nNewId ); + + std::list< sal_Int32 >::iterator aChildEndIt( rEle.m_aChildren.begin() ); + std::list< PDFStructureElementKid >::iterator aKidEndIt( rEle.m_aKids.begin() ); + advance( aChildEndIt, ncMaxPDFArraySize ); + advance( aKidEndIt, ncMaxPDFArraySize ); + + rEleNew.m_aKids.splice( rEleNew.m_aKids.begin(), + rEle.m_aKids, + rEle.m_aKids.begin(), + aKidEndIt ); + rEleNew.m_aChildren.splice( rEleNew.m_aChildren.begin(), + rEle.m_aChildren, + rEle.m_aChildren.begin(), + aChildEndIt ); + // set the kid's new parent + for (auto const& child : rEleNew.m_aChildren) + { + m_aStructure[ child ].m_nParentElement = nNewId; + } + } + //finally add the new kids resulting from the container added + rEle.m_aKids.insert( rEle.m_aKids.begin(), aNewKids.begin(), aNewKids.end() ); + rEle.m_aChildren.insert( rEle.m_aChildren.begin(), aNewChildren.begin(), aNewChildren.end() ); } bool PDFWriterImpl::setCurrentStructureElement( sal_Int32 nEle ) @@ -10692,18 +10692,18 @@ void PDFWriterImpl::setStructureBoundingBox( const tools::Rectangle& rRect ) if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) || !m_aContext.Tagged ) return; - if( m_nCurrentStructElement > 0 && m_bEmitStructure ) + if( !(m_nCurrentStructElement > 0 && m_bEmitStructure) ) + return; + + PDFWriter::StructElement eType = m_aStructure[ m_nCurrentStructElement ].m_eType; + if( eType == PDFWriter::Figure || + eType == PDFWriter::Formula || + eType == PDFWriter::Form || + eType == PDFWriter::Table ) { - PDFWriter::StructElement eType = m_aStructure[ m_nCurrentStructElement ].m_eType; - if( eType == PDFWriter::Figure || - eType == PDFWriter::Formula || - eType == PDFWriter::Form || - eType == PDFWriter::Table ) - { - m_aStructure[ m_nCurrentStructElement ].m_aBBox = rRect; - // convert to default user space now, since the mapmode may change - m_aPages[nPageNr].convertRect( m_aStructure[ m_nCurrentStructElement ].m_aBBox ); - } + m_aStructure[ m_nCurrentStructElement ].m_aBBox = rRect; + // convert to default user space now, since the mapmode may change + m_aPages[nPageNr].convertRect( m_aStructure[ m_nCurrentStructElement ].m_aBBox ); } } diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index 0701561de576..c8e5847aaa4d 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -153,124 +153,124 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz } const Size aSizePixel( aBitmapEx.GetSizePixel() ); - if ( aSizePixel.Width() && aSizePixel.Height() ) + if ( !(aSizePixel.Width() && aSizePixel.Height()) ) + return; + + if( m_aContext.ColorMode == PDFWriter::DrawGreyscale ) { - if( m_aContext.ColorMode == PDFWriter::DrawGreyscale ) - { - BmpConversion eConv = BmpConversion::N8BitGreys; - int nDepth = aBitmapEx.GetBitmap().GetBitCount(); - if( nDepth <= 4 ) - eConv = BmpConversion::N4BitGreys; - if( nDepth > 1 ) - aBitmapEx.Convert( eConv ); - } - bool bUseJPGCompression = !i_rContext.m_bOnlyLosslessCompression; - if ( bIsPng || ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) ) - bUseJPGCompression = false; + BmpConversion eConv = BmpConversion::N8BitGreys; + int nDepth = aBitmapEx.GetBitmap().GetBitCount(); + if( nDepth <= 4 ) + eConv = BmpConversion::N4BitGreys; + if( nDepth > 1 ) + aBitmapEx.Convert( eConv ); + } + bool bUseJPGCompression = !i_rContext.m_bOnlyLosslessCompression; + if ( bIsPng || ( aSizePixel.Width() < 32 ) || ( aSizePixel.Height() < 32 ) ) + bUseJPGCompression = false; - auto pStrm=std::make_shared<SvMemoryStream>(); - Bitmap aMask; + auto pStrm=std::make_shared<SvMemoryStream>(); + Bitmap aMask; - bool bTrueColorJPG = true; - if ( bUseJPGCompression ) + bool bTrueColorJPG = true; + if ( bUseJPGCompression ) + { + // TODO this checks could be done much earlier, saving us + // from trying conversion & stores before... + if ( !aBitmapEx.IsTransparent() ) { - // TODO this checks could be done much earlier, saving us - // from trying conversion & stores before... - if ( !aBitmapEx.IsTransparent() ) + const auto& rCacheEntry=m_aPDFBmpCache.find( + aBitmapEx.GetChecksum()); + if ( rCacheEntry != m_aPDFBmpCache.end() ) { - const auto& rCacheEntry=m_aPDFBmpCache.find( - aBitmapEx.GetChecksum()); - if ( rCacheEntry != m_aPDFBmpCache.end() ) - { - m_rOuterFace.DrawJPGBitmap( *rCacheEntry->second, true, aSizePixel, - tools::Rectangle( aPoint, aSize ), aMask, i_Graphic ); - return; - } - } - sal_uInt32 nZippedFileSize = 0; // sj: we will calculate the filesize of a zipped bitmap - if ( !bIsJpeg ) // to determine if jpeg compression is useful - { - SvMemoryStream aTemp; - aTemp.SetCompressMode( aTemp.GetCompressMode() | SvStreamCompressFlags::ZBITMAP ); - aTemp.SetVersion( SOFFICE_FILEFORMAT_40 ); // sj: up from version 40 our bitmap stream operator - WriteDIBBitmapEx(aBitmapEx, aTemp); // is capable of zlib stream compression - nZippedFileSize = aTemp.TellEnd(); + m_rOuterFace.DrawJPGBitmap( *rCacheEntry->second, true, aSizePixel, + tools::Rectangle( aPoint, aSize ), aMask, i_Graphic ); + return; } - if ( aBitmapEx.IsTransparent() ) - { - if ( aBitmapEx.IsAlpha() ) - aMask = aBitmapEx.GetAlpha().GetBitmap(); - else - aMask = aBitmapEx.GetMask(); - } - Graphic aGraphic( aBitmapEx.GetBitmap() ); + } + sal_uInt32 nZippedFileSize = 0; // sj: we will calculate the filesize of a zipped bitmap + if ( !bIsJpeg ) // to determine if jpeg compression is useful + { + SvMemoryStream aTemp; + aTemp.SetCompressMode( aTemp.GetCompressMode() | SvStreamCompressFlags::ZBITMAP ); + aTemp.SetVersion( SOFFICE_FILEFORMAT_40 ); // sj: up from version 40 our bitmap stream operator + WriteDIBBitmapEx(aBitmapEx, aTemp); // is capable of zlib stream compression + nZippedFileSize = aTemp.TellEnd(); + } + if ( aBitmapEx.IsTransparent() ) + { + if ( aBitmapEx.IsAlpha() ) + aMask = aBitmapEx.GetAlpha().GetBitmap(); + else + aMask = aBitmapEx.GetMask(); + } + Graphic aGraphic( aBitmapEx.GetBitmap() ); - Sequence< PropertyValue > aFilterData( 2 ); - aFilterData[ 0 ].Name = "Quality"; - aFilterData[ 0 ].Value <<= sal_Int32(i_rContext.m_nJPEGQuality); - aFilterData[ 1 ].Name = "ColorMode"; - aFilterData[ 1 ].Value <<= sal_Int32(0); + Sequence< PropertyValue > aFilterData( 2 ); + aFilterData[ 0 ].Name = "Quality"; + aFilterData[ 0 ].Value <<= sal_Int32(i_rContext.m_nJPEGQuality); + aFilterData[ 1 ].Name = "ColorMode"; + aFilterData[ 1 ].Value <<= sal_Int32(0); - try + try + { + uno::Reference < io::XStream > xStream = new utl::OStreamWrapper( *pStrm ); + uno::Reference< io::XSeekable > xSeekable( xStream, UNO_QUERY_THROW ); + uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); + uno::Reference< graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(xContext) ); + uno::Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() ); + uno::Reference < io::XOutputStream > xOut( xStream->getOutputStream() ); + uno::Sequence< beans::PropertyValue > aOutMediaProperties( 3 ); + aOutMediaProperties[0].Name = "OutputStream"; + aOutMediaProperties[0].Value <<= xOut; + aOutMediaProperties[1].Name = "MimeType"; + aOutMediaProperties[1].Value <<= OUString("image/jpeg"); + aOutMediaProperties[2].Name = "FilterData"; + aOutMediaProperties[2].Value <<= aFilterData; + xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); + xOut->flush(); + if ( !bIsJpeg && xSeekable->getLength() > nZippedFileSize ) { - uno::Reference < io::XStream > xStream = new utl::OStreamWrapper( *pStrm ); - uno::Reference< io::XSeekable > xSeekable( xStream, UNO_QUERY_THROW ); - uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); - uno::Reference< graphic::XGraphicProvider > xGraphicProvider( graphic::GraphicProvider::create(xContext) ); - uno::Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() ); - uno::Reference < io::XOutputStream > xOut( xStream->getOutputStream() ); - uno::Sequence< beans::PropertyValue > aOutMediaProperties( 3 ); - aOutMediaProperties[0].Name = "OutputStream"; - aOutMediaProperties[0].Value <<= xOut; - aOutMediaProperties[1].Name = "MimeType"; - aOutMediaProperties[1].Value <<= OUString("image/jpeg"); - aOutMediaProperties[2].Name = "FilterData"; - aOutMediaProperties[2].Value <<= aFilterData; - xGraphicProvider->storeGraphic( xGraphic, aOutMediaProperties ); - xOut->flush(); - if ( !bIsJpeg && xSeekable->getLength() > nZippedFileSize ) - { - bUseJPGCompression = false; - } - else + bUseJPGCompression = false; + } + else + { + pStrm->Seek( STREAM_SEEK_TO_END ); + + xSeekable->seek( 0 ); + Sequence< PropertyValue > aArgs( 1 ); + aArgs[ 0 ].Name = "InputStream"; + aArgs[ 0 ].Value <<= xStream; + uno::Reference< XPropertySet > xPropSet( xGraphicProvider->queryGraphicDescriptor( aArgs ) ); + if ( xPropSet.is() ) { - pStrm->Seek( STREAM_SEEK_TO_END ); - - xSeekable->seek( 0 ); - Sequence< PropertyValue > aArgs( 1 ); - aArgs[ 0 ].Name = "InputStream"; - aArgs[ 0 ].Value <<= xStream; - uno::Reference< XPropertySet > xPropSet( xGraphicProvider->queryGraphicDescriptor( aArgs ) ); - if ( xPropSet.is() ) + sal_Int16 nBitsPerPixel = 24; + if ( xPropSet->getPropertyValue("BitsPerPixel") >>= nBitsPerPixel ) { - sal_Int16 nBitsPerPixel = 24; - if ( xPropSet->getPropertyValue("BitsPerPixel") >>= nBitsPerPixel ) - { - bTrueColorJPG = nBitsPerPixel != 8; - } + bTrueColorJPG = nBitsPerPixel != 8; } } } - catch( uno::Exception& ) - { - bUseJPGCompression = false; - } } - if ( bUseJPGCompression ) + catch( uno::Exception& ) { - m_rOuterFace.DrawJPGBitmap( *pStrm, bTrueColorJPG, aSizePixel, tools::Rectangle( aPoint, aSize ), aMask, i_Graphic ); - if (!aBitmapEx.IsTransparent() && bTrueColorJPG) - { - // Cache last jpeg export - m_aPDFBmpCache.insert( - {aBitmapEx.GetChecksum(), pStrm}); - } + bUseJPGCompression = false; } - else if ( aBitmapEx.IsTransparent() ) - m_rOuterFace.DrawBitmapEx( aPoint, aSize, aBitmapEx ); - else - m_rOuterFace.DrawBitmap( aPoint, aSize, aBitmapEx.GetBitmap(), i_Graphic ); } + if ( bUseJPGCompression ) + { + m_rOuterFace.DrawJPGBitmap( *pStrm, bTrueColorJPG, aSizePixel, tools::Rectangle( aPoint, aSize ), aMask, i_Graphic ); + if (!aBitmapEx.IsTransparent() && bTrueColorJPG) + { + // Cache last jpeg export + m_aPDFBmpCache.insert( + {aBitmapEx.GetChecksum(), pStrm}); + } + } + else if ( aBitmapEx.IsTransparent() ) + m_rOuterFace.DrawBitmapEx( aPoint, aSize, aBitmapEx ); + else + m_rOuterFace.DrawBitmap( aPoint, aSize, aBitmapEx.GetBitmap(), i_Graphic ); } @@ -1090,41 +1090,41 @@ EncHashTransporter* EncHashTransporter::getEncHashTransporter( const uno::Refere void PDFWriterImpl::checkAndEnableStreamEncryption( sal_Int32 nObject ) { - if( m_aContext.Encryption.Encrypt() ) - { - m_bEncryptThisStream = true; - sal_Int32 i = m_nKeyLength; - m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>(nObject); - m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 8 ); - m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 16 ); - // the other location of m_nEncryptionKey is already set to 0, our fixed generation number - // do the MD5 hash - ::std::vector<unsigned char> const nMD5Sum(::comphelper::Hash::calculateHash( - m_aContext.Encryption.EncryptionKey.data(), i+2, ::comphelper::HashType::MD5)); - // the i+2 to take into account the generation number, always zero - // initialize the RC4 with the key - // key length: see algorithm 3.1, step 4: (N+5) max 16 - rtl_cipher_initARCFOUR( m_aCipher, rtl_Cipher_DirectionEncode, nMD5Sum.data(), m_nRC4KeyLength, nullptr, 0 ); - } + if( !m_aContext.Encryption.Encrypt() ) + return; + + m_bEncryptThisStream = true; + sal_Int32 i = m_nKeyLength; + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>(nObject); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 8 ); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 16 ); + // the other location of m_nEncryptionKey is already set to 0, our fixed generation number + // do the MD5 hash + ::std::vector<unsigned char> const nMD5Sum(::comphelper::Hash::calculateHash( + m_aContext.Encryption.EncryptionKey.data(), i+2, ::comphelper::HashType::MD5)); + // the i+2 to take into account the generation number, always zero + // initialize the RC4 with the key + // key length: see algorithm 3.1, step 4: (N+5) max 16 + rtl_cipher_initARCFOUR( m_aCipher, rtl_Cipher_DirectionEncode, nMD5Sum.data(), m_nRC4KeyLength, nullptr, 0 ); } void PDFWriterImpl::enableStringEncryption( sal_Int32 nObject ) { - if( m_aContext.Encryption.Encrypt() ) - { - sal_Int32 i = m_nKeyLength; - m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>(nObject); - m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 8 ); - m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 16 ); - // the other location of m_nEncryptionKey is already set to 0, our fixed generation number - // do the MD5 hash - // the i+2 to take into account the generation number, always zero - ::std::vector<unsigned char> const nMD5Sum(::comphelper::Hash::calculateHash( - m_aContext.Encryption.EncryptionKey.data(), i+2, ::comphelper::HashType::MD5)); - // initialize the RC4 with the key - // key length: see algorithm 3.1, step 4: (N+5) max 16 - rtl_cipher_initARCFOUR( m_aCipher, rtl_Cipher_DirectionEncode, nMD5Sum.data(), m_nRC4KeyLength, nullptr, 0 ); - } + if( !m_aContext.Encryption.Encrypt() ) + return; + + sal_Int32 i = m_nKeyLength; + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>(nObject); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 8 ); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 16 ); + // the other location of m_nEncryptionKey is already set to 0, our fixed generation number + // do the MD5 hash + // the i+2 to take into account the generation number, always zero + ::std::vector<unsigned char> const nMD5Sum(::comphelper::Hash::calculateHash( + m_aContext.Encryption.EncryptionKey.data(), i+2, ::comphelper::HashType::MD5)); + // initialize the RC4 with the key + // key length: see algorithm 3.1, step 4: (N+5) max 16 + rtl_cipher_initARCFOUR( m_aCipher, rtl_Cipher_DirectionEncode, nMD5Sum.data(), m_nRC4KeyLength, nullptr, 0 ); } /* init the encryption engine diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 6bdf36bc1d4d..a2b163442187 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -1252,26 +1252,26 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup ) // If the printer supports landscape orientation, check paper sizes again // with landscape orientation. This is necessary as a printer driver provides // all paper sizes with portrait orientation only!! - if ( rData.GetPaperFormat() == PAPER_USER && + if ( !(rData.GetPaperFormat() == PAPER_USER && nLandscapeAngle != 0 && - HasSupport( PrinterSupport::SetOrientation )) + HasSupport( PrinterSupport::SetOrientation ))) + return; + + const long nRotatedWidth = rData.GetPaperHeight(); + const long nRotatedHeight = rData.GetPaperWidth(); + PaperInfo aRotatedInfo(nRotatedWidth, nRotatedHeight); + + for ( int i = 0; i < nPaperCount; i++ ) { - const long nRotatedWidth = rData.GetPaperHeight(); - const long nRotatedHeight = rData.GetPaperWidth(); - PaperInfo aRotatedInfo(nRotatedWidth, nRotatedHeight); + const PaperInfo& rPaperInfo = GetPaperInfo( i ); - for ( int i = 0; i < nPaperCount; i++ ) + if ( aRotatedInfo.sloppyEqual( rPaperInfo ) ) { - const PaperInfo& rPaperInfo = GetPaperInfo( i ); - - if ( aRotatedInfo.sloppyEqual( rPaperInfo ) ) - { - rData.SetPaperFormat( - ImplGetPaperFormat( rPaperInfo.getWidth(), - rPaperInfo.getHeight() )); - rData.SetOrientation( Orientation::Landscape ); - return; - } + rData.SetPaperFormat( + ImplGetPaperFormat( rPaperInfo.getWidth(), + rPaperInfo.getHeight() )); + rData.SetOrientation( Orientation::Landscape ); + return; } } } @@ -1281,37 +1281,37 @@ void Printer::SetPaper( Paper ePaper ) if ( mbInPrintPage ) return; - if ( maJobSetup.ImplGetConstData().GetPaperFormat() != ePaper ) - { - JobSetup aJobSetup = maJobSetup; - ImplJobSetup& rData = aJobSetup.ImplGetData(); + if ( maJobSetup.ImplGetConstData().GetPaperFormat() == ePaper ) + return; - rData.SetPaperFormat( ePaper ); - if ( ePaper != PAPER_USER ) - { - PaperInfo aInfo(ePaper); - rData.SetPaperWidth( aInfo.getWidth() ); - rData.SetPaperHeight( aInfo.getHeight() ); - } + JobSetup aJobSetup = maJobSetup; + ImplJobSetup& rData = aJobSetup.ImplGetData(); - if ( IsDisplayPrinter() ) - { - mbNewJobSetup = true; - maJobSetup = aJobSetup; - return; - } + rData.SetPaperFormat( ePaper ); + if ( ePaper != PAPER_USER ) + { + PaperInfo aInfo(ePaper); + rData.SetPaperWidth( aInfo.getWidth() ); + rData.SetPaperHeight( aInfo.getHeight() ); + } - ReleaseGraphics(); - if ( ePaper == PAPER_USER ) - ImplFindPaperFormatForUserSize( aJobSetup ); - if ( mpInfoPrinter->SetData( JobSetFlags::PAPERSIZE | JobSetFlags::ORIENTATION, &rData )) - { - ImplUpdateJobSetupPaper( aJobSetup ); - mbNewJobSetup = true; - maJobSetup = aJobSetup; - ImplUpdatePageData(); - ImplUpdateFontList(); - } + if ( IsDisplayPrinter() ) + { + mbNewJobSetup = true; + maJobSetup = aJobSetup; + return; + } + + ReleaseGraphics(); + if ( ePaper == PAPER_USER ) + ImplFindPaperFormatForUserSize( aJobSetup ); + if ( mpInfoPrinter->SetData( JobSetFlags::PAPERSIZE | JobSetFlags::ORIENTATION, &rData )) + { + ImplUpdateJobSetupPaper( aJobSetup ); + mbNewJobSetup = true; + maJobSetup = aJobSetup; + ImplUpdatePageData(); + ImplUpdateFontList(); } } @@ -1433,29 +1433,29 @@ void Printer::SetDuplexMode( DuplexMode eDuplex ) if ( mbInPrintPage ) return; - if ( maJobSetup.ImplGetConstData().GetDuplexMode() != eDuplex ) - { - JobSetup aJobSetup = maJobSetup; - ImplJobSetup& rData = aJobSetup.ImplGetData(); + if ( maJobSetup.ImplGetConstData().GetDuplexMode() == eDuplex ) + return; - rData.SetDuplexMode( eDuplex ); + JobSetup aJobSetup = maJobSetup; + ImplJobSetup& rData = aJobSetup.ImplGetData(); - if ( IsDisplayPrinter() ) - { - mbNewJobSetup = true; - maJobSetup = aJobSetup; - return; - } + rData.SetDuplexMode( eDuplex ); - ReleaseGraphics(); - if ( mpInfoPrinter->SetData( JobSetFlags::DUPLEXMODE, &rData ) ) - { - ImplUpdateJobSetupPaper( aJobSetup ); - mbNewJobSetup = true; - maJobSetup = aJobSetup; - ImplUpdatePageData(); - ImplUpdateFontList(); - } + if ( IsDisplayPrinter() ) + { + mbNewJobSetup = true; + maJobSetup = aJobSetup; + return; + } + + ReleaseGraphics(); + if ( mpInfoPrinter->SetData( JobSetFlags::DUPLEXMODE, &rData ) ) + { + ImplUpdateJobSetupPaper( aJobSetup ); + mbNewJobSetup = true; + maJobSetup = aJobSetup; + ImplUpdatePageData(); + ImplUpdateFontList(); } } @@ -1539,21 +1539,21 @@ void Printer::ImplStartPage() if ( !IsJobActive() ) return; - if ( mpPrinter ) - { - SalGraphics* pGraphics = mpPrinter->StartPage( &maJobSetup.ImplGetData(), - mbNewJobSetup ); - if ( pGraphics ) - { - ReleaseGraphics(); ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits