diff options
author | Attila Bakos (NISZ) <bakos.attilakaroly@nisz.hu> | 2021-11-03 15:39:32 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-11-24 11:51:07 +0100 |
commit | eabcfb3f18a6944d9ad89cecd3eb3ca7a2259cf3 (patch) | |
tree | d1c66ab6056a467e3fc07bdbf6f07e179cb9e678 /sw/qa/uitest/writer_tests4 | |
parent | becd76743fd7a3ae84404f26b1afb60b923cabb2 (diff) |
tdf#129183 sw: textboxes in group shapes - part 3
Grouping/ungrouping nested groups works now.
Manual test:
1. Insert Shape.
2. Right-click on selected shape, Add Text Box (and some text).
3. Insert a new shape.
4. Select and group the two shapes.
3. Insert a third shape.
4. Select and group the shape and the previously grouped shapes.
The text box remains in the nested shape group.
Details:
1) tdf#144271 memory leak of SwTextBoxHelper, by replacing the
textbox structure vector with std::unordered map, and rethinking
of the ownership of the objects. If a SwFrameFormat dies, and that
is a FLYFRMFMT, it will be deleted from the textbox node and the
FrameFormat table in the doc too, and the drawing will be stay as
it was before. If the dying format is a drawing, all the textboxes,
and the node will be deleted.
2) Introducing the new UNO property TextBoxContent, which is needed
for writerfilter/xmloff later to set a new textbox for the shape
via UNO.
3) Missing parameters are present now for syncing the textbox
parameters.
4) Introducing a new function namely the handleGroupTextBox() to
do the tasks simply with all textboxes in a group shape.
This can handle nested groups as well (group in a group).
Known issues: now copy of nested group objects is implemented
but not enabled, because it causes an assert.
Change-Id: I931886eda01c7a3db93098de10f5e5f48f2f217b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124657
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa/uitest/writer_tests4')
-rw-r--r-- | sw/qa/uitest/writer_tests4/ComplexGroupShapeTest.py | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/sw/qa/uitest/writer_tests4/ComplexGroupShapeTest.py b/sw/qa/uitest/writer_tests4/ComplexGroupShapeTest.py new file mode 100644 index 000000000000..cdac088a32d7 --- /dev/null +++ b/sw/qa/uitest/writer_tests4/ComplexGroupShapeTest.py @@ -0,0 +1,124 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 select_pos +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +import time + +class ComplexGroupShapeTest(UITestCase): + def test_ComplexGroupShape(self): + with self.ui_test.load_file(get_url_for_data_file("ComplexGroupShapeTest.odt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() + + # check the shape type + self.assertEqual("com.sun.star.drawing.GroupShape", document.DrawPage.getByIndex(1).ShapeType) + + # select the shape + self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.ui_test.wait_until_child_is_available('metricfield') + + # go inside the group + self.xUITest.executeCommand(".uno:EnterGroup") + + # select a shape in the group + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + + # add a textbox to this subshape + self.xUITest.executeCommand(".uno:AddTextBox") + + # select the next shape in the group + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + + # add a textbox to this subshape + self.xUITest.executeCommand(".uno:AddTextBox") + + # leave the groupshape + self.xUITest.executeCommand(".uno:LeaveGroup") + + # select the other shape + self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.ui_test.wait_until_child_is_available('metricfield') + + # get the current selection + ShapeCollection = document.getCurrentSelection() + + # extend the selection with the grouped shape + ShapeCollection.add(document.DrawPage.getByIndex(0)) + ShapeCollection.add(document.DrawPage.getByIndex(1)) + + # select these shapes + document.getCurrentController().select(ShapeCollection) + + # do ungroup + self.xUITest.executeCommand(".uno:FormatGroup") + + # deselect + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"ESC"})) + time.sleep(0.1) + + # select the group + self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.ui_test.wait_until_child_is_available('metricfield') + + # move it down + for i in range(1, 30): + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + time.sleep(0.1) + + # select again + self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.ui_test.wait_until_child_is_available('metricfield') + + # do ungroup + self.xUITest.executeCommand(".uno:FormatUngroup") + + # deselect everything + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"ESC"})) + time.sleep(0.1) + + # select the first ex-group member shape + self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.ui_test.wait_until_child_is_available('metricfield') + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + + # check if it is a textbox + self.assertEqual(True,document.getCurrentSelection().getByIndex(0).TextBox) + + # go to the other one + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + + # this is still a group, so it cannot be a textbox + self.assertEqual(False,document.getCurrentSelection().getByIndex(0).TextBox) + + # do ungroup + self.xUITest.executeCommand(".uno:FormatUngroup") + + # deselect + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"ESC"})) + time.sleep(0.1) + + # select one shape of the last group + self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.ui_test.wait_until_child_is_available('metricfield') + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + + # check if it is a textbox + self.assertEqual(True,document.getCurrentSelection().getByIndex(0).TextBox) + + # Without the fix in place, the following problems occurred during this test: + # - After the grouping old textbox frames detached from their shape before + # - Moving caused messed layout + # - After ungroup, the shapes in the embed group lost their textbox + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |