[Libreoffice-commits] core.git: sc/CppunitTest_sc_shapetest.mk sc/qa sc/source
Regina Henschel (via logerrit)
logerrit at kemper.freedesktop.org
Wed Feb 10 12:15:30 UTC 2021
sc/CppunitTest_sc_shapetest.mk | 1
sc/qa/unit/scshapetest.cxx | 38 +++++++++++++++++++++++++++++++++++++
sc/source/core/data/drwlayer.cxx | 5 +---
sc/source/ui/drawfunc/fuconuno.cxx | 2 +
4 files changed, 43 insertions(+), 3 deletions(-)
New commits:
commit 1d53f3709de2956f14db31677b6c461f33843bd9
Author: Regina Henschel <rb.henschel at t-online.de>
AuthorDate: Tue Feb 9 13:42:24 2021 +0100
Commit: Regina Henschel <rb.henschel at t-online.de>
CommitDate: Wed Feb 10 13:14:40 2021 +0100
tdf#140252 Controls in Calc are always on layer 'controls'
The ctor of SdDrawLayer had set the name of the control layer to
'Controls' (uppercase), whereas the ctor of SdrLayerAdmin sets it to
'controls' (lowercase).
In result, for a control object in Calc the layer was not found and
therefore set to default layer ID 0. I have not investigated in detail
why it was not found, but simple change the name in Calc to use
'controls' too.
Second error was, that a control, which was inserted as default object
via ctrl+click, had not get 'controls' als layer.
Change-Id: Iaac349cda0b0dcf3f098ca3484308ac52a83aa38
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110636
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel at t-online.de>
diff --git a/sc/CppunitTest_sc_shapetest.mk b/sc/CppunitTest_sc_shapetest.mk
index cf97cf99da13..50891e1da50a 100644
--- a/sc/CppunitTest_sc_shapetest.mk
+++ b/sc/CppunitTest_sc_shapetest.mk
@@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_shapetest, \
sc \
sfx \
subsequenttest \
+ svl \
svx \
svxcore \
test \
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 3c8630033d0f..9923e5c00af2 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -16,10 +16,12 @@
#include <comphelper/propertyvalue.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/request.hxx>
+#include <svl/intitem.hxx>
#include <svx/svdoashp.hxx>
#include <svx/svdomeas.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdorect.hxx>
+#include <svx/svdouno.hxx>
#include <unotools/tempfile.hxx>
#include <vcl/keycodes.hxx>
@@ -40,6 +42,7 @@ public:
ScShapeTest();
void saveAndReload(css::uno::Reference<css::lang::XComponent>& xComponent,
const OUString& rFilter);
+ void testTdf140252_LayerOfControl();
void testTdf137082_LTR_to_RTL();
void testTdf137082_RTL_cell_anchored();
void testTdf137081_RTL_page_anchored();
@@ -63,6 +66,7 @@ public:
void testCustomShapeCellAnchoredRotatedShape();
CPPUNIT_TEST_SUITE(ScShapeTest);
+ CPPUNIT_TEST(testTdf140252_LayerOfControl);
CPPUNIT_TEST(testTdf137082_LTR_to_RTL);
CPPUNIT_TEST(testTdf137082_RTL_cell_anchored);
CPPUNIT_TEST(testTdf137081_RTL_page_anchored);
@@ -192,6 +196,40 @@ static SdrObject* lcl_getSdrObjectWithAssert(ScDocument& rDoc, sal_uInt16 nObjNu
return pObj;
}
+void ScShapeTest::testTdf140252_LayerOfControl()
+{
+ // Error was, that a newly inserted control shape was put on layer
+ // "vorne" instead of layer "control".
+ // Load an empty document.
+ OUString aFileURL;
+ createFileURL(u"ManualColWidthRowHeight.ods", aFileURL);
+ uno::Reference<css::lang::XComponent> xComponent = loadFromDesktop(aFileURL);
+ CPPUNIT_ASSERT(xComponent.is());
+
+ // Get ScDocShell
+ ScDocShell* pDocSh = lcl_getScDocShellWithAssert(xComponent);
+
+ // Create default push button
+ SfxUInt16Item aIdentifierItem(SID_FM_CONTROL_IDENTIFIER, OBJ_FM_BUTTON);
+ SfxUInt32Item aInventorItem(SID_FM_CONTROL_INVENTOR, sal_uInt32(SdrInventor::FmForm));
+ const SfxPoolItem* pArgs[] = { &aIdentifierItem, &aInventorItem, nullptr };
+ const SfxPoolItem* pInternalArgs[] = { nullptr };
+ ScTabViewShell* pTabViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
+ pTabViewShell->GetViewData().GetDispatcher().Execute(
+ SID_FM_CREATE_CONTROL, SfxCallMode::SYNCHRON, pArgs, KEY_MOD1, pInternalArgs);
+
+ // Get document and newly created push button.
+ ScDocument& rDoc = pDocSh->GetDocument();
+ SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
+
+ // Check LayerID of object. Without the fix in place it was 0.
+ sal_uInt8 nExpectedID = sal_uInt8(SC_LAYER_CONTROLS);
+ sal_uInt8 nActualID = pObj->GetLayer().get();
+ CPPUNIT_ASSERT_EQUAL(nExpectedID, nActualID);
+
+ pDocSh->DoClose();
+}
+
void ScShapeTest::testTdf137082_LTR_to_RTL()
{
// Before the fix for tdf137081 and tdf137082, when flipping sheet from LTR to RTL, page anchored
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index c7d2ad49b7a9..4ae406cceb9f 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -283,10 +283,9 @@ ScDrawLayer::ScDrawLayer( ScDocument* pDocument, const OUString& rName ) :
rAdmin.NewLayer("vorne", sal_uInt8(SC_LAYER_FRONT));
rAdmin.NewLayer("hinten", sal_uInt8(SC_LAYER_BACK));
rAdmin.NewLayer("intern", sal_uInt8(SC_LAYER_INTERN));
- rAdmin.NewLayer("Controls", sal_uInt8(SC_LAYER_CONTROLS));
- rAdmin.SetControlLayerName("Controls");
+ // tdf#140252 use same name as in ctor of SdrLayerAdmin
+ rAdmin.NewLayer(rAdmin.GetControlLayerName(), sal_uInt8(SC_LAYER_CONTROLS));
rAdmin.NewLayer("hidden", sal_uInt8(SC_LAYER_HIDDEN));
- // "Controls" is new - must also be created when loading
// Set link for URL-Fields
ScModule* pScMod = SC_MOD();
diff --git a/sc/source/ui/drawfunc/fuconuno.cxx b/sc/source/ui/drawfunc/fuconuno.cxx
index 6f543e516878..e0257f97feec 100644
--- a/sc/source/ui/drawfunc/fuconuno.cxx
+++ b/sc/source/ui/drawfunc/fuconuno.cxx
@@ -112,6 +112,8 @@ SdrObjectUniquePtr FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nI
if(pObj)
{
pObj->SetLogicRect(rRectangle);
+ // tdf#140252 Controls are always on layer "controls"
+ pObj->NbcSetLayer(SC_LAYER_CONTROLS);
}
return pObj;
More information about the Libreoffice-commits
mailing list