summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/UITest_sw_uibase_shells.mk16
-rw-r--r--sw/qa/uitest/data/image-rel-size.fodt40
-rw-r--r--sw/qa/uitest/uibase/shells/shells.py32
-rw-r--r--sw/source/uibase/shells/grfsh.cxx10
5 files changed, 99 insertions, 0 deletions
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index fd5b7024cc50..de0affba1bc7 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -199,6 +199,7 @@ $(eval $(call gb_Module_add_uicheck_targets,sw,\
UITest_sw_styleInspector \
UITest_sw_ui_fmtui \
UITest_sw_ui_index \
+ UITest_sw_uibase_shells \
UITest_classification \
UITest_writer_macro_tests \
UITest_writer_dialogs \
diff --git a/sw/UITest_sw_uibase_shells.mk b/sw/UITest_sw_uibase_shells.mk
new file mode 100644
index 000000000000..de9cb7c8a9d9
--- /dev/null
+++ b/sw/UITest_sw_uibase_shells.mk
@@ -0,0 +1,16 @@
+# 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/.
+#
+
+$(eval $(call gb_UITest_UITest,sw_uibase_shells))
+
+$(eval $(call gb_UITest_add_modules,sw_uibase_shells,$(SRCDIR)/sw/qa/uitest,\
+ uibase/shells/ \
+))
+
+$(eval $(call gb_UITest_set_defs,sw_uibase_shells, \
+ TDOC="$(SRCDIR)/sw/qa/uitest/data" \
+))
diff --git a/sw/qa/uitest/data/image-rel-size.fodt b/sw/qa/uitest/data/image-rel-size.fodt
new file mode 100644
index 000000000000..9df285861616
--- /dev/null
+++ b/sw/qa/uitest/data/image-rel-size.fodt
@@ -0,0 +1,40 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<office:document xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:automatic-styles>
+ <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Graphics">
+ <style:graphic-properties style:vertical-pos="top" style:vertical-rel="baseline"/>
+ </style:style>
+ <style:page-layout style:name="pm1">
+ <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm">
+ </style:page-layout-properties>
+ <style:header-style/>
+ <style:footer-style/>
+ </style:page-layout>
+ <style:style style:name="dp1" style:family="drawing-page">
+ <style:drawing-page-properties draw:background-size="full"/>
+ </style:style>
+ </office:automatic-styles>
+ <office:master-styles>
+ <style:master-page style:name="Standard" style:page-layout-name="pm1" draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+ <office:text>
+ <text:p text:style-name="Standard"><draw:frame draw:style-name="fr1" draw:name="Bild1" text:anchor-type="as-char" svg:width="40.282cm" style:rel-width="80%" svg:height="15.88cm" style:rel-height="scale" draw:z-index="0"><draw:image draw:mime-type="image/png"><office:binary-data>iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAAAFz
+ UkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA
+ AAJiS0dEAACqjSMyAAAACW9GRnMAAAAGAAAAAAAMc1XTAAAACXBIWXMAAA3XAAAN1wFCKJt4
+ AAAACXZwQWcAAABMAAAAQACdMTgbAAABzUlEQVRo3u3ZPU/CQBjA8X+Jxs3ESUDj4iK+LA5+
+ BBfjqBE1cXB2MlFAEqMgxvhNNL4sLsK3UPQL6ObkoAETz+FKW2mxCPRYnucWUu76/OC59C49
+ cGOCKqrD9kHRc6ddPv7oW2WCwMh0nF63Myz7Tm8hPTNu0pgHMER3scepTbgK6enJNND83RLn
+ /878yRaPmgBZFDuMsNLeWB9gmFQHP77MIg9gsYciR50NFKvtjIy10yk84pSZA7DYpwR8scmF
+ QQCMuoQMpzbh0iAARrlnVn90CWHTsZcAiHPPdINQAuqsc2MQAAnKDUKWEhZ10twaBEDSJWQo
+ YlFj7S9CzwEegkXWIbQsRAQASFJhpplwbRAACS+hANRJBxMiAkDcJeQ4sQkBhYgMoJ+Ozlwo
+ 2YQ7AJ6CRxyiUGnVy3hVKb0Af9v7hUG2Wy9TEQCUelFTDULB2S+YKYGOMcpM6UIccOQnRA6A
+ cSp6ibfI+wkGADBGpTEd8xz1AaAfTQ7huA8AvUw5hVjuA0D/C5OaMN8XACRZ8F0zCggKAQhA
+ AAIQgAAEIAABCEAAAhCAAAQgAAH4zg3feY4w3Xs44M5+oW0qvCWoGcvaIlM3x/f/ab+O738A
+ hOCNQr34oD4AAAAldEVYdGNyZWF0ZS1kYXRlADIwMTAtMTItMjBUMTc6MDg6MzYrMDE6MDB6
+ 5RscAAAAJXRFWHRtb2RpZnktZGF0ZQAyMDEwLTEyLTIwVDE3OjA4OjM3KzAxOjAwgyNmnAAA
+ AABJRU5ErkJggg==
+ </office:binary-data></draw:image></draw:frame></text:p>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/uitest/uibase/shells/shells.py b/sw/qa/uitest/uibase/shells/shells.py
new file mode 100644
index 000000000000..e422c012a322
--- /dev/null
+++ b/sw/qa/uitest/uibase/shells/shells.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 uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import get_url_for_data_file
+import time
+
+
+class TestSwGrfShell(UITestCase):
+ def testFormatGraphicDlg(self):
+ # Given a document with an image with a relative size:
+ with self.ui_test.load_file(get_url_for_data_file("image-rel-size.fodt")) as component:
+ self.xUITest.executeCommand(".uno:JumpToNextFrame")
+ # 120 ms in the SwView ctor
+ time.sleep(0.2)
+ # When opening the properties dialog for the image:
+ with self.ui_test.execute_dialog_through_command(".uno:GraphicDialog") as dialog:
+ # Then make sure the width is 80% as in the file:
+ widthField = dialog.getChild('width')
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: '237%' != '80%'
+ # i.e. the percent width of the image was wrong.
+ self.assertEqual(get_state_as_dict(widthField)["Text"], "80%")
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx
index bb60338f1ce0..86dde1851c3a 100644
--- a/sw/source/uibase/shells/grfsh.cxx
+++ b/sw/source/uibase/shells/grfsh.cxx
@@ -63,6 +63,7 @@
#include <swslots.hxx>
#include <swabstdlg.hxx>
#include <unocrsr.hxx>
+#include <flyfrm.hxx>
#include <memory>
constexpr OUStringLiteral TOOLBOX_NAME = u"colorbar";
@@ -317,6 +318,15 @@ void SwGrfShell::Execute(SfxRequest &rReq)
aSet.Put( aFrameSize );
aSet.Put( aMgr.GetAttrSet() );
+ SwFlyFrame* pFly = rSh.GetSelectedFlyFrame();
+ if (pFly)
+ {
+ // Work with the up to date layout size if possible.
+ SwFormatFrameSize aSize = aSet.Get(RES_FRM_SIZE);
+ aSize.SetWidth(pFly->getFrameArea().Width());
+ aSize.SetHeight(pFly->getFrameArea().Height());
+ aSet.Put(aSize);
+ }
aSet.SetParent( aMgr.GetAttrSet().GetParent() );
// At percentage values initialize size