[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/svx svx/Module_svx.mk svx/qa svx/source svx/UITest_svx_table.mk
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Dec 17 15:52:02 UTC 2020
include/svx/sdr/table/tablecontroller.hxx | 1
svx/Module_svx.mk | 4 ++
svx/UITest_svx_table.mk | 16 ++++++++++
svx/qa/uitest/table/tablecontroller.py | 45 ++++++++++++++++++++++++++++++
svx/source/table/tablecontroller.cxx | 33 +++++++++++++++++++++-
5 files changed, 98 insertions(+), 1 deletion(-)
New commits:
commit 6f45e70aadcfb1930a0955c140e1811689b28be6
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Dec 15 17:17:56 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Dec 17 16:51:27 2020 +0100
tdf#129961 svx: finish UI for table shadow as direct format
Normally properties on an SdrObject is set using SetAttributes(), but
that would take the selection controller into account, so we would call
SvxTableController::SetAttributes(), which sets the item set on the
selected cells instead. So use SetAttrToMarked() instead, which works on
the shape's item set, even in the table case. Don't replace all existing
items because we only have shadow properties here and also a disabled
shadow is still a (set) SdrOnOffItem (with value=false), so no old
SdrOnOffItem will be forgotten in the shape's item set.
Also add an outer undo grouping, so once the user presses OK in the
table properties dialog, we only create a single user-visible undo
action, not two.
(cherry picked from commit fdeb04f7c59cf8032fe17072ed779e70505cc6ab)
Conflicts:
svx/source/table/tablecontroller.cxx
Change-Id: I77b55ba1f07b8d0eeac5070e0ec07d39573d1f9a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107880
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx
index 8359a15c4dbe..7e438015e907 100644
--- a/include/svx/sdr/table/tablecontroller.hxx
+++ b/include/svx/sdr/table/tablecontroller.hxx
@@ -85,6 +85,7 @@ public:
SVX_DLLPRIVATE void MergeAttrFromSelectedCells(SfxItemSet& rAttr, bool bOnlyHardAttr) const;
SVX_DLLPRIVATE void SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll);
+ void SetAttrToSelectedShape(const SfxItemSet& rAttr);
/** Fill the values that are common for all selected cells.
*
* This lets the Borders dialog to display the line arrangement
diff --git a/svx/Module_svx.mk b/svx/Module_svx.mk
index 48ab6bcb071d..2577539356c4 100644
--- a/svx/Module_svx.mk
+++ b/svx/Module_svx.mk
@@ -53,6 +53,10 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,svx,\
))
endif
+$(eval $(call gb_Module_add_uicheck_targets,svx,\
+ UITest_svx_table \
+))
+
#todo: noopt for EnhanceCustomShapesFunctionParser.cxx on Solaris Sparc and MacOSX
#todo: -DBOOST_SPIRIT_USE_OLD_NAMESPACE only in CustomShapes ?
#todo: -DUNICODE and -D_UNICODE on WNT for source/dialog
diff --git a/svx/UITest_svx_table.mk b/svx/UITest_svx_table.mk
new file mode 100644
index 000000000000..df24798f59c4
--- /dev/null
+++ b/svx/UITest_svx_table.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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,svx_table))
+
+$(eval $(call gb_UITest_add_modules,svx_table,$(SRCDIR)/svx/qa/uitest,\
+ table/ \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/svx/qa/uitest/table/tablecontroller.py b/svx/qa/uitest/table/tablecontroller.py
new file mode 100644
index 000000000000..27ed4a1d7ccb
--- /dev/null
+++ b/svx/qa/uitest/table/tablecontroller.py
@@ -0,0 +1,45 @@
+#
+# 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 select_pos
+
+
+# Test for SvxTableController.
+class SvxTableControllerTest(UITestCase):
+
+ def testOnFormatTable(self):
+ # Create an Impress document with a single table in it.
+ self.ui_test.create_doc_in_start_center("impress")
+ template = self.xUITest.getTopFocusWindow()
+ self.ui_test.close_dialog_through_button(template.getChild("cancel"))
+ self.xUITest.executeCommand(".uno:SelectAll")
+ self.xUITest.executeCommand(".uno:Delete")
+ self.xUITest.executeCommand(".uno:InsertTable?Columns:short=2&Rows:short=2")
+
+ # Enable shadow.
+ self.ui_test.execute_dialog_through_command(".uno:TableDialog")
+ tableDialog = self.xUITest.getTopFocusWindow()
+ tabs = tableDialog.getChild("tabcontrol")
+ # Select "shadow".
+ select_pos(tabs, "4")
+ shadowCheckbox = tableDialog.getChild("TSB_SHOW_SHADOW")
+ shadowCheckbox.executeAction("CLICK", tuple())
+ self.ui_test.close_dialog_through_button(tableDialog.getChild("ok"))
+
+ # Check if the shadow was enabled.
+ component = self.ui_test.get_component()
+ drawPage = component.getDrawPages().getByIndex(0)
+ shape = drawPage.getByIndex(0)
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: False != True
+ # i.e. the table still had no shadow.
+ self.assertEqual(shape.Shadow, True)
+
+ # Close the document.
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index 07fb110756b0..2badfa5a5ef0 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -973,7 +973,26 @@ void SvxTableController::onFormatTable(const SfxRequest& rReq)
if( aNewBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) != aBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) )
aNewSet.Put(makeSdrTextLowerDistItem( aNewBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) ) );
- pThis->SetAttrToSelectedCells(aNewSet, false);
+ if (pThis->checkTableObject() && pThis->mxTable.is())
+ {
+ // Create a single undo action when applying the result of the dialog.
+ SdrTableObj& rTableObject(*pThis->mxTableObj.get());
+ SdrModel& rSdrModel(rTableObject.getSdrModelFromSdrObject());
+ bool bUndo = rSdrModel.IsUndoEnabled();
+ if (bUndo)
+ {
+ rSdrModel.BegUndo(SvxResId(STR_TABLE_NUMFORMAT));
+ }
+
+ pThis->SetAttrToSelectedCells(aNewSet, false);
+
+ pThis->SetAttrToSelectedShape(aNewSet);
+
+ if (bUndo)
+ {
+ rSdrModel.EndUndo();
+ }
+ }
}
};
@@ -2692,6 +2711,18 @@ void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bR
rModel.EndUndo();
}
+void SvxTableController::SetAttrToSelectedShape(const SfxItemSet& rAttr)
+{
+ if (!checkTableObject() || !mxTable.is())
+ return;
+
+ // Filter out non-shadow items from rAttr.
+ SfxItemSet aSet(*rAttr.GetPool(), svl::Items<SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST>{});
+ aSet.Put(rAttr);
+
+ // Set shadow items on the marked shape.
+ mrView.SetAttrToMarked(aSet, /*bReplaceAll=*/false);
+}
bool SvxTableController::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const
{
More information about the Libreoffice-commits
mailing list