diff options
author | Tibor Nagy <nagy.tibor2@nisz.hu> | 2023-06-22 09:53:59 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2023-06-27 14:18:42 +0200 |
commit | f5bf91ea73bf8a7cd3abc0f343ab2bdceaad905a (patch) | |
tree | b8e705ee7fdb1efd60ed9ea1bce5ea6b2ac937c5 | |
parent | 3e0537a6e746db6ea746af6b91f94aeb9d2b05d9 (diff) |
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>
-rw-r--r-- | sc/qa/uitest/calc_tests8/tdf54768.py | 32 | ||||
-rw-r--r-- | sc/qa/uitest/data/tdf54768.ods | bin | 0 -> 28536 bytes | |||
-rw-r--r-- | sc/source/ui/view/drawvie4.cxx | 16 |
3 files changed, 36 insertions, 12 deletions
diff --git a/sc/qa/uitest/calc_tests8/tdf54768.py b/sc/qa/uitest/calc_tests8/tdf54768.py new file mode 100644 index 000000000000..a4342fb8e238 --- /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 Binary files differnew file mode 100644 index 000000000000..222481db8bb0 --- /dev/null +++ b/sc/qa/uitest/data/tdf54768.ods diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx index 5cc1655b83c4..2bd329098206 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 ) |