summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-03-07 16:31:16 +0900
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-16 19:02:04 -0400
commit934bd8100e1a7df4104c065e2d69474d75acfa6a (patch)
tree1f232faaa42bd8b904b91cd93c5c189b894a3dd3
parentmove setAlphaFrom from GraphicTransformer to BitmapEx (diff)
downloadcore-934bd8100e1a7df4104c065e2d69474d75acfa6a.tar.gz
core-934bd8100e1a7df4104c065e2d69474d75acfa6a.zip
transformer: clean-up and pass originURL to transfored graphic
Change-Id: Iab01a5123ce6774120e2a0242616511a9fbe4403 Reviewed-on: https://gerrit.libreoffice.org/50867 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 19b6b8f8946a6fb720806a3f51a06760047d2ffc)
-rw-r--r--svtools/source/graphic/transformer.cxx55
1 files changed, 27 insertions, 28 deletions
diff --git a/svtools/source/graphic/transformer.cxx b/svtools/source/graphic/transformer.cxx
index 19eeedc2848e..4cf4d64673a8 100644
--- a/svtools/source/graphic/transformer.cxx
+++ b/svtools/source/graphic/transformer.cxx
@@ -54,8 +54,8 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
const uno::Reference< graphic::XGraphic >& rxGraphic, sal_Int32 nColorFrom, sal_Int8 nTolerance, sal_Int32 nColorTo, sal_Int8 nAlphaTo )
throw ( lang::IllegalArgumentException, uno::RuntimeException, std::exception)
{
- const uno::Reference< uno::XInterface > xIFace(rxGraphic, uno::UNO_QUERY);
- ::Graphic aGraphic(*::unographic::Graphic::getImplementation(xIFace));
+ ::Graphic aGraphic(rxGraphic);
+ ::Graphic aReturnGraphic;
BitmapColor aBmpColorFrom(static_cast< sal_uInt8 >(nColorFrom), static_cast< sal_uInt8 >(nColorFrom >> 8), static_cast< sal_uInt8 >(nColorFrom >> 16));
BitmapColor aBmpColorTo( static_cast< sal_uInt8 >(nColorTo), static_cast< sal_uInt8 >(nColorTo >> 8), static_cast< sal_uInt8 >(nColorTo >> 16));
@@ -65,7 +65,8 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
const sal_uInt8 cIndexFrom = aBmpColorFrom.GetBlueOrIndex();
- if (aGraphic.GetType() == GraphicType::Bitmap || aGraphic.GetType() == GraphicType::GdiMetafile)
+ if (aGraphic.GetType() == GraphicType::Bitmap ||
+ aGraphic.GetType() == GraphicType::GdiMetafile)
{
BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
Bitmap aBitmap(aBitmapEx.GetBitmap());
@@ -74,7 +75,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
{
aBitmapEx.setAlphaFrom( cIndexFrom, nAlphaTo );
aBitmapEx.Replace(aColorFrom, aColorTo, nTolerance);
- aGraphic = ::Graphic(aBitmapEx);
+ aReturnGraphic = ::Graphic(aBitmapEx);
}
else if (aBitmapEx.IsTransparent())
{
@@ -84,13 +85,13 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
Bitmap aMask2(aBitmap.CreateMask(aColorFrom, nTolerance));
aMask.CombineSimple(aMask2, BmpCombine::Or);
aBitmap.Replace(aColorFrom, aColorTo, nTolerance);
- aGraphic = ::Graphic(BitmapEx(aBitmap, aMask));
+ aReturnGraphic = ::Graphic(BitmapEx(aBitmap, aMask));
}
else
{
aBitmapEx.setAlphaFrom(cIndexFrom, 0xff - nAlphaTo);
aBitmapEx.Replace(aColorFrom, aColorTo, nTolerance);
- aGraphic = ::Graphic(aBitmapEx);
+ aReturnGraphic = ::Graphic(aBitmapEx);
}
}
else
@@ -99,59 +100,57 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
{
Bitmap aMask(aBitmap.CreateMask(aColorFrom, nTolerance));
aBitmap.Replace(aColorFrom, aColorTo, nTolerance);
- aGraphic = ::Graphic(BitmapEx(aBitmap, aMask));
+ aReturnGraphic = ::Graphic(BitmapEx(aBitmap, aMask));
}
else
{
aBitmapEx.setAlphaFrom(cIndexFrom, nAlphaTo);
aBitmapEx.Replace(aColorFrom, aColorTo, nTolerance);
- aGraphic = ::Graphic(aBitmapEx);
+ aReturnGraphic = ::Graphic(aBitmapEx);
}
}
}
- ::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic();
- pUnoGraphic->init(aGraphic);
- uno::Reference< graphic::XGraphic > xRet(pUnoGraphic);
+ aReturnGraphic.setOriginURL(aGraphic.getOriginURL());
- return xRet;
+ unographic::Graphic* pUnoGraphic = new unographic::Graphic();
+ pUnoGraphic->init(aReturnGraphic);
+ return uno::Reference<graphic::XGraphic>(pUnoGraphic);
}
uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::applyDuotone(
const uno::Reference< graphic::XGraphic >& rxGraphic, sal_Int32 nColorOne, sal_Int32 nColorTwo )
throw ( lang::IllegalArgumentException, uno::RuntimeException, std::exception)
{
- const uno::Reference< uno::XInterface > xIFace( rxGraphic, uno::UNO_QUERY );
- ::Graphic aGraphic( *::unographic::Graphic::getImplementation( xIFace ) );
+ ::Graphic aGraphic(rxGraphic);
+ ::Graphic aReturnGraphic;
BitmapEx aBitmapEx( aGraphic.GetBitmapEx() );
AlphaMask aMask( aBitmapEx.GetAlpha() );
Bitmap aBitmap( aBitmapEx.GetBitmap() );
BmpFilterParam aFilter( (sal_uLong) nColorOne, (sal_uLong) nColorTwo );
aBitmap.Filter( BmpFilter::DuoTone, &aFilter );
- aGraphic = ::Graphic( BitmapEx( aBitmap, aMask ) );
-
+ aReturnGraphic = ::Graphic( BitmapEx( aBitmap, aMask ) );
+ aReturnGraphic.setOriginURL(aGraphic.getOriginURL());
::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic();
- pUnoGraphic->init( aGraphic );
- uno::Reference< graphic::XGraphic > xRet( pUnoGraphic );
- return xRet;
+ pUnoGraphic->init(aReturnGraphic);
+ return uno::Reference<graphic::XGraphic>(pUnoGraphic);
}
uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::applyBrightnessContrast(
const uno::Reference< graphic::XGraphic >& rxGraphic, sal_Int32 nBrightness, sal_Int32 nContrast, sal_Bool mso )
throw ( lang::IllegalArgumentException, uno::RuntimeException, std::exception)
{
- const uno::Reference< uno::XInterface > xIFace( rxGraphic, uno::UNO_QUERY );
- ::Graphic aGraphic( *::unographic::Graphic::getImplementation( xIFace ) );
-
- BitmapEx aBitmapEx( aGraphic.GetBitmapEx() );
- aBitmapEx.Adjust( nBrightness, nContrast, 0, 0, 0, 0, false, mso );
- aGraphic = ::Graphic( aBitmapEx );
+ ::Graphic aGraphic(rxGraphic);
+ ::Graphic aReturnGraphic;
+ BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
+ aBitmapEx.Adjust(nBrightness, nContrast, 0, 0, 0, 0, false, mso);
+ aReturnGraphic = ::Graphic(aBitmapEx);
+ aReturnGraphic.setOriginURL(aGraphic.getOriginURL());
::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic();
- pUnoGraphic->init( aGraphic );
- uno::Reference< graphic::XGraphic > xRet( pUnoGraphic );
- return xRet;
+ pUnoGraphic->init(aReturnGraphic);
+ return uno::Reference<graphic::XGraphic>(pUnoGraphic);
}
}