include/sfx2/sfxbasemodel.hxx | 2 - sfx2/source/doc/sfxbasemodel.cxx | 16 +++++++++--- vcl/unx/generic/gdi/salgdi2.cxx | 50 ++++++++++++++++++++++----------------- 3 files changed, 42 insertions(+), 26 deletions(-)
New commits: commit c1df0c41b602ac144fdde4efcf546549443afa86 Author: Caolán McNamara <caol...@redhat.com> Date: Thu Jun 26 21:06:35 2014 +0100 Resolves: fdo#80160 PNG with 1-bit colormap only show black and white Change-Id: If0c9950c18e6091fafea47954a4654db436a3a44 (cherry picked from commit 986c0451d05e7bb6ff7edd9f27d0e45532bcd22c) diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx index ef76996..be722c5 100644 --- a/vcl/unx/generic/gdi/salgdi2.cxx +++ b/vcl/unx/generic/gdi/salgdi2.cxx @@ -440,6 +440,32 @@ void X11SalGraphics::copyArea ( long nDestX, long nDestY, copyBits ( aPosAry, 0 ); } +namespace +{ + void setForeBack(XGCValues& rValues, const SalColormap& rColMap, const SalBitmap& rSalBitmap) + { + rValues.foreground = rColMap.GetWhitePixel(); + rValues.background = rColMap.GetBlackPixel(); + + //fdo#33455 and fdo#80160 handle 1 bit depth pngs with palette entries + //to set fore/back colors + SalBitmap& rBitmap = const_cast<SalBitmap&>(rSalBitmap); + if (const BitmapBuffer* pBitmapBuffer = rBitmap.AcquireBuffer(true)) + { + const BitmapPalette& rPalette = pBitmapBuffer->maPalette; + if (rPalette.GetEntryCount() == 2) + { + const BitmapColor aWhite(rPalette[rPalette.GetBestIndex(Color(COL_WHITE))]); + rValues.foreground = rColMap.GetPixel(ImplColorToSal(aWhite)); + + const BitmapColor aBlack(rPalette[rPalette.GetBestIndex(Color(COL_BLACK))]); + rValues.background = rColMap.GetPixel(ImplColorToSal(aBlack)); + } + rBitmap.ReleaseBuffer(pBitmapBuffer, true); + } + } +} + void X11SalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) { const SalDisplay* pSalDisp = GetDisplay(); @@ -455,24 +481,7 @@ void X11SalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSa { // set foreground/background values for 1Bit bitmaps XGetGCValues( pXDisp, aGC, nValues, &aOldVal ); - - aNewVal.foreground = rColMap.GetWhitePixel(); - aNewVal.background = rColMap.GetBlackPixel(); - - //fdo#33455 handle 1 bit depth pngs with palette entries - //to set fore/back colors - if (const BitmapBuffer* pBitmapBuffer = const_cast<SalBitmap&>(rSalBitmap).AcquireBuffer(true)) - { - const BitmapPalette& rPalette = pBitmapBuffer->maPalette; - if (rPalette.GetEntryCount() == 2) - { - const BitmapColor aBlack( rPalette[rPalette.GetBestIndex( Color( COL_BLACK ) )] ); - const BitmapColor aWhite( rPalette[rPalette.GetBestIndex( Color( COL_WHITE ) )] ); - aNewVal.foreground = rColMap.GetPixel(ImplColorToSal(aWhite)); - aNewVal.background = rColMap.GetPixel(ImplColorToSal(aBlack)); - } - } - + setForeBack(aNewVal, rColMap, rSalBitmap); XChangeGC( pXDisp, aGC, nValues, &aNewVal ); } @@ -525,13 +534,12 @@ void X11SalGraphics::drawMaskedBitmap( const SalTwoRect& rPosAry, { GC aTmpGC; XGCValues aValues; - const SalColormap& rColMap = pSalDisp->GetColormap( m_nXScreen ); - const int nBlack = rColMap.GetBlackPixel(), nWhite = rColMap.GetWhitePixel(); + setForeBack(aValues, pSalDisp->GetColormap(m_nXScreen), rSalBitmap); const int nValues = GCFunction | GCForeground | GCBackground; SalTwoRect aTmpRect( rPosAry ); aTmpRect.mnDestX = aTmpRect.mnDestY = 0; // draw paint bitmap in pixmap #1 - aValues.function = GXcopy, aValues.foreground = nWhite, aValues.background = nBlack; + aValues.function = GXcopy; aTmpGC = XCreateGC( pXDisp, aFG, nValues, &aValues ); static_cast<const X11SalBitmap&>(rSalBitmap).ImplDraw( aFG, m_nXScreen, nDepth, aTmpRect, aTmpGC ); DBG_TESTTRANS( aFG ); commit e7161741d186e7edfbaaaf405f157e1cdfccdb5c Author: Caolán McNamara <caol...@redhat.com> Date: Thu Jun 26 09:50:18 2014 +0100 clang: Use-after-free Change-Id: I5dd857dbf39c8cd62df8b8cd0323b873a79976ae (cherry picked from commit 112645f75816c4902ccf8a2a97ef57e8f13429b8) diff --git a/include/sfx2/sfxbasemodel.hxx b/include/sfx2/sfxbasemodel.hxx index fd33b2d..c5c5a87 100644 --- a/include/sfx2/sfxbasemodel.hxx +++ b/include/sfx2/sfxbasemodel.hxx @@ -879,7 +879,7 @@ private: SAL_DLLPRIVATE void loadCmisProperties(); - SAL_DLLPRIVATE void handleLoadError( sal_uInt32 nError, SfxMedium* pMedium ); + SAL_DLLPRIVATE SfxMedium* handleLoadError( sal_uInt32 nError, SfxMedium* pMedium ); // private variables and methods diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 40ab212..d307e9d 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -1790,6 +1790,9 @@ OUString getFilterProvider( SfxMedium& rMedium ) void setUpdatePickList( SfxMedium* pMedium ) { + if (!pMedium) + return; + bool bHidden = false; SFX_ITEMSET_ARG(pMedium->GetItemSet(), pHidItem, SfxBoolItem, SID_HIDDEN, false); if (pHidItem) @@ -1829,7 +1832,7 @@ void SAL_CALL SfxBaseModel::load( const Sequence< beans::PropertyValue >& seqA if (!m_pData->m_pObjectShell->DoLoadExternal(pMedium)) nError = ERRCODE_IO_GENERAL; - handleLoadError(nError, pMedium); + pMedium = handleLoadError(nError, pMedium); setUpdatePickList(pMedium); return; } @@ -1917,7 +1920,7 @@ void SAL_CALL SfxBaseModel::load( const Sequence< beans::PropertyValue >& seqA m_pData->m_pObjectShell->ResetError(); - handleLoadError(nError, pMedium); + pMedium = handleLoadError(nError, pMedium); loadCmisProperties(); setUpdatePickList(pMedium); @@ -2662,11 +2665,13 @@ void SfxBaseModel::loadCmisProperties( ) } } -void SfxBaseModel::handleLoadError( sal_uInt32 nError, SfxMedium* pMedium ) +SfxMedium* SfxBaseModel::handleLoadError( sal_uInt32 nError, SfxMedium* pMedium ) { if (!nError) + { // No error condition. - return; + return pMedium; + } bool bSilent = false; SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSilentItem, SfxBoolItem, SID_SILENT, false); @@ -2689,6 +2694,7 @@ void SfxBaseModel::handleLoadError( sal_uInt32 nError, SfxMedium* pMedium ) // for whatever reason document now has another medium OSL_FAIL("Document has rejected the medium?!"); delete pMedium; + pMedium = NULL; } if ( !bWarning ) // #i30711# don't abort loading if it's only a warning @@ -2698,6 +2704,8 @@ void SfxBaseModel::handleLoadError( sal_uInt32 nError, SfxMedium* pMedium ) "SfxBaseModel::handleLoadError: 0x" + OUString::number(nError, 16), Reference< XInterface >(), nError); } + + return pMedium; }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits