tdf#54768 sc: fix resizing of cropped images to original size
This is a follow up to commit a4e12cbfc69cfe668fa30756a3c5843e911e22b1
(tdf#155863 sd: fix resizing of cropped images to original size)
Change-Id: I923ed8b1df6c6559d527d43e4abe842497c4c28f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153449
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
(cherry picked from commit 54550800bf0d0208ea5085a2170100100d0da2d4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153660
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/uitest/calc_tests8/tdf54768.py b/sc/qa/uitest/calc_tests8/tdf54768.py
new file mode 100644
index 0000000..a4342fb
--- /dev/null
+++ b/sc/qa/uitest/calc_tests8/tdf54768.py
@@ -0,0 +1,32 @@
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import get_url_for_data_file
class tdf54768(UITestCase):
def test_tdf54768(self):
# This document contains an image with an original size of 7.99cm x 5.74cm.
# The image has been cropped 2.73cm at the top.
# Also, it has been resized to a width of 4.04cm.
with self.ui_test.load_file(get_url_for_data_file("tdf54768.ods")) as document:
xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
# select the image
xGridWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Image"}))
# click "Original Size"
self.xUITest.executeCommand(".uno:OriginalSize")
# tdf#155863: Without the fix in place, the image stays cropped,
# but stretches to the size of original image
self.assertEqual(7988, document.DrawPages[0].getByIndex(0).Size.Width)
self.assertEqual(3005, document.DrawPages[0].getByIndex(0).Size.Height)
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/tdf54768.ods b/sc/qa/uitest/data/tdf54768.ods
new file mode 100644
index 0000000..222481db
--- /dev/null
+++ b/sc/qa/uitest/data/tdf54768.ods
Binary files differ
diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx
index 5cc1655..2bd3290 100644
--- a/sc/source/ui/view/drawvie4.cxx
+++ b/sc/source/ui/view/drawvie4.cxx
@@ -476,9 +476,9 @@ void ScDrawView::SetMarkedOriginalSize()
}
else if (nIdent == SdrObjKind::Graphic)
{
const Graphic& rGraphic = static_cast<SdrGrafObj*>(pObj)->GetGraphic();
const SdrGrafObj* pSdrGrafObj = static_cast<const SdrGrafObj*>(pObj);
MapMode aSourceMap = rGraphic.GetPrefMapMode();
MapMode aSourceMap = pSdrGrafObj->GetGraphic().GetPrefMapMode();
MapMode aDestMap( MapUnit::Map100thMM );
if (aSourceMap.GetMapUnit() == MapUnit::MapPixel)
{
@@ -488,16 +488,8 @@ void ScDrawView::SetMarkedOriginalSize()
aDestMap.SetScaleX(aNormScaleX);
aDestMap.SetScaleY(aNormScaleY);
}
if (pViewData)
{
vcl::Window* pActWin = pViewData->GetActiveWin();
if (pActWin)
{
aOriginalSize = pActWin->LogicToLogic(
rGraphic.GetPrefSize(), &aSourceMap, &aDestMap );
bDo = true;
}
}
aOriginalSize = pSdrGrafObj->getOriginalSize();
bDo = true;
}
if ( bDo )