summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorGulsah Kose <gulsah.1004@gmail.com>2016-05-26 03:37:37 +0300
committerArmin Le Grand <Armin.Le.Grand@cib.de>2016-06-10 14:15:12 +0000
commite9fadde3c56a1e8bbb1ffe3ded861fbcd3252407 (patch)
tree5bf753f9948360bb0957fbcdab696d69e32640e6 /svx
parent34d9db285589c58e6f0dd1b37adc882252847637 (diff)
tdf#87667 If image is cropped, set cropped size as original size.
Change-Id: Ief76037f087a2225442294b972d331fc4476bbec Signed-off-by: Gulsah Kose <gulsah.1004@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/25486 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdograf.cxx29
1 files changed, 21 insertions, 8 deletions
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 6655c4f88f34..93a662ba487e 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -531,6 +531,11 @@ bool SdrGrafObj::IsSwappedOut() const
return mbIsPreview || pGraphic->IsSwappedOut();
}
+bool SdrGrafObj::IsCropped() const
+{
+ return aGrafInfo.IsCropped();
+}
+
const MapMode& SdrGrafObj::GetGrafPrefMapMode() const
{
return pGraphic->GetPrefMapMode();
@@ -561,18 +566,26 @@ OUString SdrGrafObj::GetGrafStreamURL() const
Size SdrGrafObj::getOriginalSize() const
{
- Size aSize;
+ Size aSize = GetGrafPrefSize();
- if ( GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL )
- aSize = Application::GetDefaultDevice()->PixelToLogic( GetGrafPrefSize(),
- GetModel()->GetScaleUnit() );
- else
+ if (IsCropped())
{
- aSize = OutputDevice::LogicToLogic( GetGrafPrefSize(),
- GetGrafPrefMapMode(),
- GetModel()->GetScaleUnit() );
+ long aCroppedTop = OutputDevice::LogicToLogic( aGrafInfo.GetTopCrop(), GetModel()->GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit());
+ long aCroppedBottom = OutputDevice::LogicToLogic( aGrafInfo.GetBottomCrop(), GetModel()->GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit());
+ long aCroppedLeft = OutputDevice::LogicToLogic( aGrafInfo.GetLeftCrop(), GetModel()->GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit());
+ long aCroppedRight = OutputDevice::LogicToLogic( aGrafInfo.GetRightCrop(), GetModel()->GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit());
+
+ long aCroppedWidth = aSize.getWidth() - aCroppedLeft + aCroppedRight;
+ long aCroppedHeight = aSize.getHeight() - aCroppedTop + aCroppedBottom;
+
+ aSize = Size ( aCroppedWidth, aCroppedHeight);
}
+ if ( GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL )
+ aSize = Application::GetDefaultDevice()->PixelToLogic( aSize, GetModel()->GetScaleUnit() );
+ else
+ aSize = OutputDevice::LogicToLogic( aSize, GetGrafPrefMapMode(), GetModel()->GetScaleUnit() );
+
return aSize;
}