CppunitTest_sc_shapetest: inherit from ScModelTestBase
which inherits from UnoApiXmlTest. In order to get rid of duplicated code Change-Id: I36b1edf21fd58eecce482331f5cca577ac7f7b01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142758 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
parent
59b62978c7
commit
ea9c2c4edb
2 changed files with 151 additions and 220 deletions
|
@ -11,7 +11,11 @@
|
|||
|
||||
$(eval $(call gb_CppunitTest_CppunitTest,sc_shapetest))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_external,sc_shapetest,boost_headers))
|
||||
$(eval $(call gb_CppunitTest_use_externals,sc_shapetest, \
|
||||
boost_headers \
|
||||
mdds_headers \
|
||||
libxml2 \
|
||||
))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_common_precompiled_header,sc_shapetest))
|
||||
|
||||
|
@ -24,6 +28,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_shapetest, \
|
|||
cppuhelper \
|
||||
sal \
|
||||
sc \
|
||||
scqahelper \
|
||||
sfx \
|
||||
subsequenttest \
|
||||
svl \
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <string_view>
|
||||
|
||||
#include <test/unoapi_test.hxx>
|
||||
#include "helper/qahelper.hxx"
|
||||
|
||||
#include <comphelper/propertyvalue.hxx>
|
||||
#include <sfx2/dispatch.hxx>
|
||||
|
@ -38,7 +38,7 @@ using namespace css;
|
|||
|
||||
namespace sc_apitest
|
||||
{
|
||||
class ScShapeTest : public UnoApiTest
|
||||
class ScShapeTest : public ScModelTestBase
|
||||
{
|
||||
public:
|
||||
ScShapeTest();
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
};
|
||||
|
||||
ScShapeTest::ScShapeTest()
|
||||
: UnoApiTest("sc/qa/unit/data/ods")
|
||||
: ScModelTestBase("sc/qa/unit/data/ods")
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -148,23 +148,6 @@ static void lcl_AssertPointEqualWithTolerance(std::string_view sInfo, const Poin
|
|||
CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Y() - rActual.Y()) <= nTolerance);
|
||||
}
|
||||
|
||||
static ScDocShell*
|
||||
lcl_getScDocShellWithAssert(css::uno::Reference<css::lang::XComponent>& xComponent)
|
||||
{
|
||||
SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
|
||||
CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
|
||||
ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
|
||||
CPPUNIT_ASSERT(pDocSh);
|
||||
return pDocSh;
|
||||
}
|
||||
|
||||
static ScTabViewShell* lcl_getScTabViewShellWithAssert(ScDocShell* pDocSh)
|
||||
{
|
||||
ScTabViewShell* pTabViewShell = pDocSh->GetBestViewShell(false);
|
||||
CPPUNIT_ASSERT_MESSAGE("No ScTabViewShell", pTabViewShell);
|
||||
return pTabViewShell;
|
||||
}
|
||||
|
||||
static SdrPage* lcl_getSdrPageWithAssert(ScDocument& rDoc)
|
||||
{
|
||||
ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
|
||||
|
@ -192,22 +175,18 @@ void ScShapeTest::testTdf144242_OpenBezier_noSwapWH()
|
|||
// swapped, because they report a rotation. (Rotation was introduced to align text with curve.)
|
||||
|
||||
// Create a spreadsheet document with default row height and col width
|
||||
mxComponent
|
||||
= loadFromDesktop("private:factory/scalc", "com.sun.star.sheet.SpreadsheetDocument");
|
||||
|
||||
// Get ScDocShell
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
createScDoc();
|
||||
|
||||
// Insert default open Bezier curve
|
||||
ScTabViewShell* pTabViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
|
||||
ScTabViewShell* pTabViewShell = getViewShell();
|
||||
SfxRequest aReq(pTabViewShell->GetViewFrame(), SID_DRAW_BEZIER_NOFILL);
|
||||
aReq.SetModifier(KEY_MOD1); // Ctrl
|
||||
pTabViewShell->ExecDraw(aReq);
|
||||
pTabViewShell->SetDrawShell(false);
|
||||
|
||||
// Get document and newly created object
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Rotate object by 300deg
|
||||
pObj->Rotate(pObj->GetSnapRect().Center(), 30000_deg100, sin(toRadians(30000_deg100)),
|
||||
|
@ -216,9 +195,8 @@ void ScShapeTest::testTdf144242_OpenBezier_noSwapWH()
|
|||
|
||||
// Save, reload and compare
|
||||
saveAndReload("Calc Office Open XML");
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc2, 0);
|
||||
pDoc = getScDoc();
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
tools::Rectangle aSnapRect(pObj->GetSnapRect());
|
||||
// Without fix in place width and height were swapped
|
||||
lcl_AssertRectEqualWithTolerance("Reload: wrong pos and size", aExpectRect, aSnapRect, 40);
|
||||
|
@ -230,22 +208,18 @@ void ScShapeTest::testTdf144242_Line_noSwapWH()
|
|||
// swapped, because they report a rotation. (Rotation was introduced to align text with line.)
|
||||
|
||||
// Create a spreadsheet document with default row height and col width
|
||||
mxComponent
|
||||
= loadFromDesktop("private:factory/scalc", "com.sun.star.sheet.SpreadsheetDocument");
|
||||
|
||||
// Get ScDocShell
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
createScDoc();
|
||||
|
||||
// Insert default line
|
||||
ScTabViewShell* pTabViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
|
||||
ScTabViewShell* pTabViewShell = getViewShell();
|
||||
SfxRequest aReq(pTabViewShell->GetViewFrame(), SID_DRAW_LINE);
|
||||
aReq.SetModifier(KEY_MOD1); // Ctrl
|
||||
pTabViewShell->ExecDraw(aReq);
|
||||
pTabViewShell->SetDrawShell(false);
|
||||
|
||||
// Get document and newly created object
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Rotate object by 300deg
|
||||
pObj->Rotate(pObj->GetSnapRect().Center(), 30000_deg100, sin(toRadians(30000_deg100)),
|
||||
|
@ -254,9 +228,8 @@ void ScShapeTest::testTdf144242_Line_noSwapWH()
|
|||
|
||||
// Save, reload and compare
|
||||
saveAndReload("Calc Office Open XML");
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc2, 0);
|
||||
pDoc = getScDoc();
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
tools::Rectangle aSnapRect(pObj->GetSnapRect());
|
||||
// Without fix in place width and height were swapped
|
||||
lcl_AssertRectEqualWithTolerance("Reload: wrong pos and size", aExpectRect, aSnapRect, 40);
|
||||
|
@ -265,14 +238,13 @@ void ScShapeTest::testTdf144242_Line_noSwapWH()
|
|||
void ScShapeTest::testTdf143619_validation_circle_pos()
|
||||
{
|
||||
// Load a document, which has validation circle around cell E6.
|
||||
loadFromURL(u"tdf143619_validationCirclePos.ods");
|
||||
createScDoc("tdf143619_validationCirclePos.ods");
|
||||
|
||||
// Get document
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
ScDocument* pDoc = getScDoc();
|
||||
|
||||
// Get shape. That is the validation circle.
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Error was, that deleting row and col before E6 does not move circle to D5, but to B3.
|
||||
// Delete first row and first column.
|
||||
|
@ -294,11 +266,10 @@ void ScShapeTest::testTdf140252_DragCreateFormControl()
|
|||
// Error was, that drag-created form controls were initially not on layer 'controls' and thus
|
||||
// other shapes could be placed in front of form controls.
|
||||
// Load an empty document.
|
||||
loadFromURL(u"ManualColWidthRowHeight.ods");
|
||||
createScDoc("ManualColWidthRowHeight.ods");
|
||||
|
||||
// Get ScTabViewShell
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScTabViewShell* pTabViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
|
||||
ScTabViewShell* pTabViewShell = getViewShell();
|
||||
|
||||
// drag-create a push button as example of form control
|
||||
SfxUInt16Item aIdentifierItem(SID_FM_CONTROL_IDENTIFIER,
|
||||
|
@ -326,8 +297,8 @@ void ScShapeTest::testTdf140252_DragCreateFormControl()
|
|||
pTabViewShell->SetDrawShell(false);
|
||||
|
||||
// Get document and newly created push button.
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrUnoObj* pObj = static_cast<SdrUnoObj*>(lcl_getSdrObjectWithAssert(rDoc, 0));
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrUnoObj* pObj = static_cast<SdrUnoObj*>(lcl_getSdrObjectWithAssert(*pDoc, 0));
|
||||
|
||||
// Without the fix in place, the shape would be on layer SC_LAYER_FRONT (0)
|
||||
sal_Int16 nExpectedID = SC_LAYER_CONTROLS.get();
|
||||
|
@ -341,11 +312,10 @@ void ScShapeTest::testTdf134355_DragCreateCustomShape()
|
|||
// layer is exclusively for form controls. Effect was, that other shapes could not be brought in
|
||||
// front of custom shapes.
|
||||
// Load an empty document.
|
||||
loadFromURL(u"ManualColWidthRowHeight.ods");
|
||||
createScDoc("ManualColWidthRowHeight.ods");
|
||||
|
||||
// Get ScTabView
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScTabViewShell* pTabViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
|
||||
ScTabViewShell* pTabViewShell = getViewShell();
|
||||
ScTabView* pTabView = pTabViewShell->GetViewData().GetView();
|
||||
|
||||
// drag-create custom shape
|
||||
|
@ -367,8 +337,8 @@ void ScShapeTest::testTdf134355_DragCreateCustomShape()
|
|||
pTabViewShell->SetDrawShell(false);
|
||||
|
||||
// Get document and newly created custom shape.
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObjCustomShape* pObj = static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(rDoc, 0));
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObjCustomShape* pObj = static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(*pDoc, 0));
|
||||
|
||||
// Without the fix in place, the shape would be on layer SC_LAYER_CONTROLS (3)
|
||||
sal_Int16 nExpectedID = SC_LAYER_FRONT.get();
|
||||
|
@ -381,10 +351,7 @@ 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.
|
||||
loadFromURL(u"ManualColWidthRowHeight.ods");
|
||||
|
||||
// Get ScDocShell
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
createScDoc("ManualColWidthRowHeight.ods");
|
||||
|
||||
// Create default push button
|
||||
SfxUInt16Item aIdentifierItem(SID_FM_CONTROL_IDENTIFIER,
|
||||
|
@ -392,13 +359,13 @@ void ScShapeTest::testTdf140252_LayerOfControl()
|
|||
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);
|
||||
ScTabViewShell* pTabViewShell = getViewShell();
|
||||
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);
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Check LayerID of object. Without the fix in place it was 0.
|
||||
sal_Int16 nExpectedID = SC_LAYER_CONTROLS.get();
|
||||
|
@ -413,20 +380,19 @@ void ScShapeTest::testTdf137082_LTR_to_RTL()
|
|||
// mirrored. Graphics are still not mirrored but shifted. This test makes sure a shape is mirrored
|
||||
// and an image is not mirrored.
|
||||
|
||||
loadFromURL(u"tdf137082_LTR_arrow_image.ods");
|
||||
createScDoc("tdf137082_LTR_arrow_image.ods");
|
||||
|
||||
// Get document
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
ScDocument* pDoc = getScDoc();
|
||||
|
||||
// Get objects and their transformation angles
|
||||
SdrObject* pObjCS = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
SdrObject* pObjCS = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
const Degree100 nRotateLTR = pObjCS->GetRotateAngle();
|
||||
SdrObject* pObjImage = lcl_getSdrObjectWithAssert(rDoc, 1);
|
||||
SdrObject* pObjImage = lcl_getSdrObjectWithAssert(*pDoc, 1);
|
||||
const Degree100 nShearLTR = pObjImage->GetShearAngle();
|
||||
|
||||
// Switch to RTL
|
||||
ScTabViewShell* pViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
|
||||
ScTabViewShell* pViewShell = getViewShell();
|
||||
pViewShell->GetViewData().GetDispatcher().Execute(FID_TAB_RTL);
|
||||
|
||||
// Check custom shape is mirrored, image not.
|
||||
|
@ -443,11 +409,10 @@ void ScShapeTest::testTdf137082_RTL_cell_anchored()
|
|||
{
|
||||
// Error was, that cell anchored custom shapes wrote wrong offsets to file and thus were wrong on
|
||||
// reloading. The file contains one custom shape with "resize" and another one without.
|
||||
loadFromURL(u"tdf137082_RTL_cell_anchored.ods");
|
||||
createScDoc("tdf137082_RTL_cell_anchored.ods");
|
||||
|
||||
// Get document
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
ScDocument* pDoc = getScDoc();
|
||||
|
||||
// Expected values.
|
||||
const Point aTopLeftA(-20500, 3500); // shape A without "resize"
|
||||
|
@ -457,23 +422,21 @@ void ScShapeTest::testTdf137082_RTL_cell_anchored()
|
|||
const tools::Rectangle aSnapRectB(aTopLeftB, aSize);
|
||||
|
||||
// Test reading was correct
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
lcl_AssertRectEqualWithTolerance("load shape A: ", aSnapRectA, pObj->GetSnapRect(), 1);
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc, 1);
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 1);
|
||||
lcl_AssertRectEqualWithTolerance("load shape B: ", aSnapRectB, pObj->GetSnapRect(), 1);
|
||||
|
||||
// Save and reload.
|
||||
saveAndReload("calc8");
|
||||
CPPUNIT_ASSERT(mxComponent);
|
||||
|
||||
// Get document
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
pDoc = getScDoc();
|
||||
|
||||
// And test again
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc2, 0);
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
lcl_AssertRectEqualWithTolerance("reload shape A: ", aSnapRectA, pObj->GetSnapRect(), 1);
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc2, 1);
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 1);
|
||||
lcl_AssertRectEqualWithTolerance("reload shape B: ", aSnapRectB, pObj->GetSnapRect(), 1);
|
||||
}
|
||||
|
||||
|
@ -481,11 +444,10 @@ void ScShapeTest::testTdf137081_RTL_page_anchored()
|
|||
{
|
||||
// Error was, that page anchored lines and custom shapes were mirrored on opening. The document
|
||||
// contains measure line, polyline and transformed custom shape.
|
||||
loadFromURL(u"tdf137081_RTL_page_anchored.ods");
|
||||
createScDoc("tdf137081_RTL_page_anchored.ods");
|
||||
|
||||
// Get document
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
ScDocument* pDoc = getScDoc();
|
||||
|
||||
// Expected values.
|
||||
// Measure line
|
||||
|
@ -499,42 +461,40 @@ void ScShapeTest::testTdf137081_RTL_page_anchored()
|
|||
const Point aTopLeft(-20500, 4583);
|
||||
|
||||
// Test reading was correct
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
// Measure line
|
||||
lcl_AssertPointEqualWithTolerance("measure line start", aStart, pObj->GetPoint(0), 1);
|
||||
lcl_AssertPointEqualWithTolerance("measure line end", aEnd, pObj->GetPoint(1), 1);
|
||||
// Polyline
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc, 1);
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 1);
|
||||
lcl_AssertPointEqualWithTolerance("polyline 1: ", aFirst, pObj->GetPoint(0), 1);
|
||||
lcl_AssertPointEqualWithTolerance("polyline 2: ", aSecond, pObj->GetPoint(1), 1);
|
||||
lcl_AssertPointEqualWithTolerance("polyline 3: ", aThird, pObj->GetPoint(2), 1);
|
||||
//Custom shape
|
||||
SdrObjCustomShape* pObjCS
|
||||
= static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(rDoc, 2));
|
||||
= static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(*pDoc, 2));
|
||||
CPPUNIT_ASSERT(!pObjCS->IsMirroredX());
|
||||
lcl_AssertPointEqualWithTolerance("custom shape top left: ", aTopLeft,
|
||||
pObjCS->GetLogicRect().TopLeft(), 1);
|
||||
|
||||
// Save and reload.
|
||||
saveAndReload("calc8");
|
||||
CPPUNIT_ASSERT(mxComponent);
|
||||
|
||||
// Get document
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
pDoc = getScDoc();
|
||||
|
||||
// And test again
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc2, 0);
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
// Measure line
|
||||
lcl_AssertPointEqualWithTolerance("measure line start", aStart, pObj->GetPoint(0), 1);
|
||||
lcl_AssertPointEqualWithTolerance("measure line end", aEnd, pObj->GetPoint(1), 1);
|
||||
// Polyline
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc2, 1);
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 1);
|
||||
lcl_AssertPointEqualWithTolerance("polyline 1: ", aFirst, pObj->GetPoint(0), 1);
|
||||
lcl_AssertPointEqualWithTolerance("polyline 2: ", aSecond, pObj->GetPoint(1), 1);
|
||||
lcl_AssertPointEqualWithTolerance("polyline 3: ", aThird, pObj->GetPoint(2), 1);
|
||||
//Custom shape
|
||||
pObjCS = static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(rDoc2, 2));
|
||||
pObjCS = static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(*pDoc, 2));
|
||||
CPPUNIT_ASSERT(!pObjCS->IsMirroredX());
|
||||
lcl_AssertPointEqualWithTolerance("custom shape top left: ", aTopLeft,
|
||||
pObjCS->GetLogicRect().TopLeft(), 1);
|
||||
|
@ -543,16 +503,15 @@ void ScShapeTest::testTdf137081_RTL_page_anchored()
|
|||
void ScShapeTest::testTdf139583_Rotate180deg()
|
||||
{
|
||||
// Load an empty document.
|
||||
loadFromURL(u"ManualColWidthRowHeight.ods");
|
||||
createScDoc("ManualColWidthRowHeight.ods");
|
||||
|
||||
// Get document and draw page
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrPage* pPage = lcl_getSdrPageWithAssert(rDoc);
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrPage* pPage = lcl_getSdrPageWithAssert(*pDoc);
|
||||
|
||||
// Insert Shape
|
||||
const tools::Rectangle aRect(Point(3000, 4000), Size(5000, 2000));
|
||||
ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
|
||||
ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
|
||||
CPPUNIT_ASSERT_MESSAGE("No ScDrawLayer", pDrawLayer);
|
||||
rtl::Reference<SdrRectObj> pObj = new SdrRectObj(*pDrawLayer, aRect);
|
||||
CPPUNIT_ASSERT_MESSAGE("Could not create rectangle", pObj);
|
||||
|
@ -560,18 +519,16 @@ void ScShapeTest::testTdf139583_Rotate180deg()
|
|||
|
||||
// Anchor "to cell (resize with cell)" and then rotate it by 180deg around center
|
||||
// The order is important here.
|
||||
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, rDoc, 0 /*SCTAB*/, true /*bResizeWithCell*/);
|
||||
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, 0 /*SCTAB*/, true /*bResizeWithCell*/);
|
||||
pObj->Rotate(aRect.Center(), Degree100(18000), 0.0, -1.0);
|
||||
pObj.clear();
|
||||
|
||||
// Save and reload.
|
||||
saveAndReload("calc8");
|
||||
CPPUNIT_ASSERT(mxComponent);
|
||||
|
||||
// Get document and object
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
pObj = static_cast<SdrRectObj*>(lcl_getSdrObjectWithAssert(rDoc2, 0));
|
||||
pDoc = getScDoc();
|
||||
pObj = static_cast<SdrRectObj*>(lcl_getSdrObjectWithAssert(*pDoc, 0));
|
||||
|
||||
// Without the fix in place, the shape would have nearly zero size.
|
||||
lcl_AssertRectEqualWithTolerance("Show: Object geometry should not change", aRect,
|
||||
|
@ -582,27 +539,24 @@ void ScShapeTest::testTdf137033_FlipHori_Resize()
|
|||
{
|
||||
// Load a document, which has a rotated custom shape, which is horizontal flipped. Error was, that
|
||||
// if such shape was anchored "resize with cell", then after save and reload it was distorted.
|
||||
loadFromURL(u"tdf137033_FlipHoriRotCustomShape.ods");
|
||||
createScDoc("tdf137033_FlipHoriRotCustomShape.ods");
|
||||
|
||||
// Get document and shape
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObjCustomShape* pObj = static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(rDoc, 0));
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObjCustomShape* pObj = static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(*pDoc, 0));
|
||||
|
||||
// Verify shape is correctly loaded. Then set shape to "resize with cell".
|
||||
tools::Rectangle aSnapRect(pObj->GetSnapRect());
|
||||
const tools::Rectangle aExpectRect(Point(4998, 7000), Size(9644, 6723));
|
||||
lcl_AssertRectEqualWithTolerance("Load, wrong pos or size: ", aExpectRect, aSnapRect, 1);
|
||||
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, rDoc, 0 /*SCTAB*/, true /*bResizeWithCell*/);
|
||||
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, 0 /*SCTAB*/, true /*bResizeWithCell*/);
|
||||
|
||||
// Save and reload.
|
||||
saveAndReload("calc8");
|
||||
CPPUNIT_ASSERT(mxComponent);
|
||||
|
||||
// Get document and shape
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
pObj = static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(rDoc2, 0));
|
||||
pDoc = getScDoc();
|
||||
pObj = static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(*pDoc, 0));
|
||||
|
||||
// Check shape has the original geometry, besides rounding and unit conversion errors
|
||||
aSnapRect = pObj->GetSnapRect();
|
||||
|
@ -616,18 +570,17 @@ void ScShapeTest::testTdf137033_RotShear_ResizeHide()
|
|||
// of the full sized shape were written to file but the changed one.
|
||||
|
||||
// Load a document, which has a rotated and sheared shape, anchored to cell with resize.
|
||||
loadFromURL(u"tdf137033_RotShearResizeAnchor.ods");
|
||||
createScDoc("tdf137033_RotShearResizeAnchor.ods");
|
||||
|
||||
// Get document
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
ScDocument* pDoc = getScDoc();
|
||||
|
||||
// Hide rows 4 and 5 (UI number), which are inside the shape and thus change shape geometry
|
||||
rDoc.SetRowHidden(3, 4, 0, true);
|
||||
rDoc.SetDrawPageSize(0); // trigger recalcpos, otherwise shapes are not changed
|
||||
pDoc->SetRowHidden(3, 4, 0, true);
|
||||
pDoc->SetDrawPageSize(0); // trigger recalcpos, otherwise shapes are not changed
|
||||
|
||||
// Get shape
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Verify hiding has changed shape geometry as expected
|
||||
tools::Rectangle aSnapRect(pObj->GetSnapRect());
|
||||
|
@ -646,12 +599,10 @@ void ScShapeTest::testTdf137033_RotShear_ResizeHide()
|
|||
|
||||
// Save and reload.
|
||||
saveAndReload("calc8");
|
||||
CPPUNIT_ASSERT(mxComponent);
|
||||
|
||||
// Get document and shape
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc2, 0);
|
||||
pDoc = getScDoc();
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Check shape has the original geometry, besides heavy rounding and unit conversion errors
|
||||
aSnapRect = pObj->GetSnapRect();
|
||||
|
@ -671,24 +622,21 @@ void ScShapeTest::testTdf137033_RotShear_Hide()
|
|||
// makes a difference.
|
||||
|
||||
// Load a document, which has a rotated and sheared shape, anchored to cell, without resize.
|
||||
loadFromURL(u"tdf137033_RotShearCellAnchor.ods");
|
||||
createScDoc("tdf137033_RotShearCellAnchor.ods");
|
||||
|
||||
// Get document
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
ScDocument* pDoc = getScDoc();
|
||||
|
||||
// Hide column C, which is left from logic rect, but right from left edge of snap rect
|
||||
rDoc.SetColHidden(2, 2, 0, true);
|
||||
rDoc.SetDrawPageSize(0); // trigger recalcpos, otherwise shapes are not changed
|
||||
pDoc->SetColHidden(2, 2, 0, true);
|
||||
pDoc->SetDrawPageSize(0); // trigger recalcpos, otherwise shapes are not changed
|
||||
|
||||
// Save and reload.
|
||||
saveAndReload("calc8");
|
||||
CPPUNIT_ASSERT(mxComponent);
|
||||
|
||||
// Get document and shape
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc2, 0);
|
||||
pDoc = getScDoc();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Check shape is visible. With the old version, the shape was moved to column C and
|
||||
// thus hidden on reload.
|
||||
|
@ -706,23 +654,20 @@ void ScShapeTest::testTdf137576_LogicRectInDefaultMeasureline()
|
|||
// resulted in zeros in NonRotatedAnchor and a wrong position when reloading.
|
||||
|
||||
// Load an empty document.
|
||||
loadFromURL(u"ManualColWidthRowHeight.ods");
|
||||
|
||||
// Get ScDocShell
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
createScDoc("ManualColWidthRowHeight.ods");
|
||||
|
||||
// Create default measureline by SfxRequest that corresponds to Ctrl+Click
|
||||
ScTabViewShell* pTabViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
|
||||
ScTabViewShell* pTabViewShell = getViewShell();
|
||||
SfxRequest aReq(pTabViewShell->GetViewFrame(), SID_DRAW_MEASURELINE);
|
||||
aReq.SetModifier(KEY_MOD1); // Ctrl
|
||||
pTabViewShell->ExecDraw(aReq);
|
||||
|
||||
// Get document and newly created measure line.
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Anchor "to Cell (resize with cell)"
|
||||
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, rDoc, 0 /*SCTAB*/, true /*bResizeWithCell*/);
|
||||
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, 0 /*SCTAB*/, true /*bResizeWithCell*/);
|
||||
// Deselect shape and switch to object selection type "Cell".
|
||||
pTabViewShell->SetDrawShell(false);
|
||||
|
||||
|
@ -739,12 +684,10 @@ void ScShapeTest::testTdf137576_LogicRectInDefaultMeasureline()
|
|||
|
||||
// Save and reload, get ScDocShell
|
||||
saveAndReload("calc8");
|
||||
CPPUNIT_ASSERT(mxComponent);
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
|
||||
// Get document and object
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc2, 0);
|
||||
pDoc = getScDoc();
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Assert object position is unchanged, besides Twips<->Hmm inaccuracy.
|
||||
Point aNewPos = pObj->GetRelativePos();
|
||||
|
@ -757,24 +700,23 @@ void ScShapeTest::testTdf137576_LogicRectInNewMeasureline()
|
|||
// NonRotatedAnchor. As a result the position was wrong when reloading.
|
||||
|
||||
// Load an empty document
|
||||
loadFromURL(u"ManualColWidthRowHeight.ods");
|
||||
createScDoc("ManualColWidthRowHeight.ods");
|
||||
|
||||
// Get document and draw page
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrPage* pPage = lcl_getSdrPageWithAssert(rDoc);
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrPage* pPage = lcl_getSdrPageWithAssert(*pDoc);
|
||||
|
||||
// Create a new measure line and insert it
|
||||
Point aStartPoint(5000, 5500);
|
||||
Point aEndPoint(13000, 8000);
|
||||
ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
|
||||
ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
|
||||
CPPUNIT_ASSERT_MESSAGE("No ScDrawLayer", pDrawLayer);
|
||||
rtl::Reference<SdrMeasureObj> pObj = new SdrMeasureObj(*pDrawLayer, aStartPoint, aEndPoint);
|
||||
CPPUNIT_ASSERT_MESSAGE("Could not create measure line", pObj);
|
||||
pPage->InsertObject(pObj.get());
|
||||
|
||||
// Anchor "to cell (resize with cell)" and examine NonRotatedAnchor
|
||||
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, rDoc, 0 /*SCTAB*/, true /*bResizeWithCell*/);
|
||||
ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, 0 /*SCTAB*/, true /*bResizeWithCell*/);
|
||||
ScDrawObjData* pNData = ScDrawLayer::GetNonRotatedObjData(pObj.get());
|
||||
CPPUNIT_ASSERT_MESSAGE("Failed to get NonRotatedAnchor", pNData);
|
||||
// Without the fix all four values would be zero.
|
||||
|
@ -791,12 +733,11 @@ void ScShapeTest::testMeasurelineHideColSave()
|
|||
// The document contains a SdrMeasureObj anchored "To Cell (resize with cell)" with start in cell
|
||||
// D11 and end in cell I5. Error was, that after hiding col A and saving, start and end point
|
||||
// position were lost.
|
||||
loadFromURL(u"measurelineHideColSave.ods");
|
||||
createScDoc("measurelineHideColSave.ods");
|
||||
|
||||
// Get document and shape
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Make sure loading is correct
|
||||
Point aStartPoint(7500, 15000); // according UI
|
||||
|
@ -805,8 +746,8 @@ void ScShapeTest::testMeasurelineHideColSave()
|
|||
lcl_AssertPointEqualWithTolerance("Load end: ", aEndPoint, pObj->GetPoint(1), 1);
|
||||
|
||||
// Hide column A
|
||||
rDoc.SetColHidden(0, 0, 0, true);
|
||||
rDoc.SetDrawPageSize(0); // trigger recalcpos, otherwise shapes are not changed
|
||||
pDoc->SetColHidden(0, 0, 0, true);
|
||||
pDoc->SetDrawPageSize(0); // trigger recalcpos, otherwise shapes are not changed
|
||||
// Shape should move by column width, here 3000
|
||||
aStartPoint.Move(-3000, 0);
|
||||
aEndPoint.Move(-3000, 0);
|
||||
|
@ -815,12 +756,10 @@ void ScShapeTest::testMeasurelineHideColSave()
|
|||
|
||||
// save and reload
|
||||
saveAndReload("calc8");
|
||||
CPPUNIT_ASSERT(mxComponent);
|
||||
|
||||
// Get document and shape
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc2, 0);
|
||||
pDoc = getScDoc();
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Check that start and end point are unchanged besides rounding and unit conversion errors
|
||||
lcl_AssertPointEqualWithTolerance("Reload start: ", aStartPoint, pObj->GetPoint(0), 2);
|
||||
|
@ -833,12 +772,11 @@ void ScShapeTest::testHideColsShow()
|
|||
//ends in cell D5. Error was, that hiding cols C and D and then show them again extends the shape
|
||||
// to column E
|
||||
|
||||
loadFromURL(u"hideColsShow.ods");
|
||||
createScDoc("hideColsShow.ods");
|
||||
|
||||
// Get document and shape
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObjCustomShape* pObj = static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(rDoc, 0));
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObjCustomShape* pObj = static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(*pDoc, 0));
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE("Load: Object should be visible", pObj->IsVisible());
|
||||
tools::Rectangle aSnapRectOrig(pObj->GetSnapRect());
|
||||
|
@ -849,7 +787,7 @@ void ScShapeTest::testHideColsShow()
|
|||
};
|
||||
dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues);
|
||||
|
||||
ScTabViewShell* pViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
|
||||
ScTabViewShell* pViewShell = getViewShell();
|
||||
pViewShell->GetViewData().GetDispatcher().Execute(FID_COL_HIDE);
|
||||
|
||||
// Check object is invisible
|
||||
|
@ -873,12 +811,11 @@ void ScShapeTest::testTdf138138_MoveCellWithRotatedShape()
|
|||
{
|
||||
// The document contains a 90deg rotated, cell-anchored rectangle in column D. Insert 2 columns
|
||||
// after column B, save and reload. The shape was not correctly moved to column F.
|
||||
loadFromURL(u"tdf138138_MoveCellWithRotatedShape.ods");
|
||||
createScDoc("tdf138138_MoveCellWithRotatedShape.ods");
|
||||
|
||||
// Get document and shape
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Check anchor and position of shape. The expected values are taken from UI.
|
||||
tools::Rectangle aSnapRect = pObj->GetSnapRect();
|
||||
|
@ -891,7 +828,7 @@ void ScShapeTest::testTdf138138_MoveCellWithRotatedShape()
|
|||
};
|
||||
dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues);
|
||||
|
||||
ScTabViewShell* pViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
|
||||
ScTabViewShell* pViewShell = getViewShell();
|
||||
pViewShell->GetViewData().GetDispatcher().Execute(FID_INS_COLUMNS_AFTER);
|
||||
aExpectedRect = tools::Rectangle(Point(16000, 3000), Size(1000, 7500)); // col width 3000
|
||||
aSnapRect = pObj->GetSnapRect();
|
||||
|
@ -900,12 +837,10 @@ void ScShapeTest::testTdf138138_MoveCellWithRotatedShape()
|
|||
|
||||
// Save and reload
|
||||
saveAndReload("calc8");
|
||||
CPPUNIT_ASSERT(mxComponent);
|
||||
|
||||
// Get document and shape
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc2, 0);
|
||||
pDoc = getScDoc();
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Assert objects size is unchanged, position is shifted.
|
||||
aSnapRect = pObj->GetSnapRect();
|
||||
|
@ -917,12 +852,11 @@ void ScShapeTest::testLoadVerticalFlip()
|
|||
{
|
||||
// The document has a cell anchored custom shape with vertical flip. Error was, that the
|
||||
// flip was lost on loading.
|
||||
loadFromURL(u"loadVerticalFlip.ods");
|
||||
createScDoc("loadVerticalFlip.ods");
|
||||
|
||||
// Get document and shape
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObjCustomShape* pObj = static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(rDoc, 0));
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObjCustomShape* pObj = static_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(*pDoc, 0));
|
||||
|
||||
// Check that shape is flipped
|
||||
CPPUNIT_ASSERT_MESSAGE("Load: Object should be vertically flipped", pObj->IsMirroredY());
|
||||
|
@ -933,16 +867,15 @@ void ScShapeTest::testTdf117948_CollapseBeforeShape()
|
|||
// The document contains a column group left from the image. The group is expanded. Collapse the
|
||||
// group, save and reload. The original error was, that the line was on wrong position after reload.
|
||||
// After the fix for 'resize with cell', the custom shape had wrong position and size too.
|
||||
loadFromURL(u"tdf117948_CollapseBeforeShape.ods");
|
||||
createScDoc("tdf117948_CollapseBeforeShape.ods");
|
||||
|
||||
// Get document and objects
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObject* pObj0 = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
SdrObject* pObj1 = lcl_getSdrObjectWithAssert(rDoc, 1);
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObject* pObj0 = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
SdrObject* pObj1 = lcl_getSdrObjectWithAssert(*pDoc, 1);
|
||||
|
||||
// Collapse the group
|
||||
ScTabViewShell* pViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
|
||||
ScTabViewShell* pViewShell = getViewShell();
|
||||
pViewShell->GetViewData().SetCurX(1);
|
||||
pViewShell->GetViewData().SetCurY(0);
|
||||
pViewShell->GetViewData().GetDispatcher().Execute(SID_OUTLINE_HIDE);
|
||||
|
@ -958,13 +891,11 @@ void ScShapeTest::testTdf117948_CollapseBeforeShape()
|
|||
|
||||
// Save and reload
|
||||
saveAndReload("calc8");
|
||||
CPPUNIT_ASSERT(mxComponent);
|
||||
|
||||
// Get document and objects
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
pObj0 = lcl_getSdrObjectWithAssert(rDoc2, 0);
|
||||
pObj1 = lcl_getSdrObjectWithAssert(rDoc2, 1);
|
||||
pDoc = getScDoc();
|
||||
pObj0 = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
pObj1 = lcl_getSdrObjectWithAssert(*pDoc, 1);
|
||||
|
||||
// Assert objects size and position are not changed. Actual values differ a little bit
|
||||
// because of cumulated Twips-Hmm conversion errors.
|
||||
|
@ -982,23 +913,22 @@ void ScShapeTest::testTdf137355_UndoHideRows()
|
|||
// The document contains a shape anchored "To Cell" with start in cell C3 and end in cell D6.
|
||||
// Error was, that hiding rows 3 to 6 and undo that action "lost" the shape.
|
||||
// Actually it was not lost but hidden.
|
||||
loadFromURL(u"tdf137355_UndoHideRows.ods");
|
||||
createScDoc("tdf137355_UndoHideRows.ods");
|
||||
|
||||
// Get document and shape
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE("Load: Object should be visible", pObj->IsVisible());
|
||||
tools::Rectangle aSnapRectOrig(pObj->GetSnapRect());
|
||||
|
||||
// Hide rows 3 to 6 in UI. [Note: Simple rDoc.SetRowHidden(2,5,0,true) does not work, because it
|
||||
// Hide rows 3 to 6 in UI. [Note: Simple pDoc->SetRowHidden(2,5,0,true) does not work, because it
|
||||
// does not produce the needed undo items.]
|
||||
uno::Sequence<beans::PropertyValue> aPropertyValues = {
|
||||
comphelper::makePropertyValue("ToPoint", OUString("$A$3:$A$6")),
|
||||
};
|
||||
dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues);
|
||||
ScTabViewShell* pViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
|
||||
ScTabViewShell* pViewShell = getViewShell();
|
||||
pViewShell->GetViewData().GetDispatcher().Execute(FID_ROW_HIDE);
|
||||
|
||||
// Check object is invisible
|
||||
|
@ -1021,18 +951,17 @@ void ScShapeTest::testTdf115655_HideDetail()
|
|||
// belongs to a group. On loading the group is expanded.
|
||||
// Error was, that after collapsing the group, save and reload, and expanding the group, the image
|
||||
// was "lost". Actually is was resized to zero height.
|
||||
loadFromURL(u"tdf115655_HideDetail.ods");
|
||||
createScDoc("tdf115655_HideDetail.ods");
|
||||
|
||||
// Get document and image
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(rDoc, 0);
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Get image size
|
||||
tools::Rectangle aSnapRectOrig = pObj->GetSnapRect();
|
||||
|
||||
// Collapse the group
|
||||
ScTabViewShell* pViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
|
||||
ScTabViewShell* pViewShell = getViewShell();
|
||||
pViewShell->GetViewData().SetCurX(0);
|
||||
pViewShell->GetViewData().SetCurY(1);
|
||||
pViewShell->GetViewData().GetDispatcher().Execute(SID_OUTLINE_HIDE);
|
||||
|
@ -1044,16 +973,13 @@ void ScShapeTest::testTdf115655_HideDetail()
|
|||
|
||||
// Save and reload
|
||||
saveAndReload("calc8");
|
||||
CPPUNIT_ASSERT(mxComponent);
|
||||
|
||||
// Get document and image
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc2 = pDocSh->GetDocument();
|
||||
pObj = lcl_getSdrObjectWithAssert(rDoc2, 0);
|
||||
pDoc = getScDoc();
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Expand the group
|
||||
pViewShell = pDocSh->GetBestViewShell(false);
|
||||
CPPUNIT_ASSERT_MESSAGE("Reload: No ScTabViewShell", pViewShell);
|
||||
pViewShell = getViewShell();
|
||||
pViewShell->GetViewData().SetCurX(0);
|
||||
pViewShell->GetViewData().SetCurY(1);
|
||||
pViewShell->GetViewData().GetDispatcher().Execute(SID_OUTLINE_SHOW);
|
||||
|
@ -1070,15 +996,15 @@ void ScShapeTest::testFitToCellSize()
|
|||
// The document has a cell anchored custom shape. Applying
|
||||
// FitToCellSize should resize and position the shape so,
|
||||
// that it fits into its anchor cell. That did not happened.
|
||||
loadFromURL(u"tdf119191_FitToCellSize.ods");
|
||||
createScDoc("tdf119191_FitToCellSize.ods");
|
||||
|
||||
// Get document and shape
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObjCustomShape* pObj = dynamic_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(rDoc, 0));
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObjCustomShape* pObj
|
||||
= dynamic_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(*pDoc, 0));
|
||||
|
||||
// Get the draw view of the document
|
||||
ScTabViewShell* pViewShell = lcl_getScTabViewShellWithAssert(pDocSh);
|
||||
ScTabViewShell* pViewShell = getViewShell();
|
||||
ScDrawView* pDrawView = pViewShell->GetViewData().GetScDrawView();
|
||||
CPPUNIT_ASSERT(pDrawView);
|
||||
|
||||
|
@ -1090,7 +1016,7 @@ void ScShapeTest::testFitToCellSize()
|
|||
pViewShell->GetViewData().GetDispatcher().Execute(SID_FITCELLSIZE);
|
||||
|
||||
const tools::Rectangle& rShapeRect(pObj->GetSnapRect());
|
||||
const tools::Rectangle aCellRect = rDoc.GetMMRect(1, 1, 1, 1, 0);
|
||||
const tools::Rectangle aCellRect = pDoc->GetMMRect(1, 1, 1, 1, 0);
|
||||
lcl_AssertRectEqualWithTolerance("Cell and SnapRect should be equal", aCellRect, rShapeRect, 2);
|
||||
}
|
||||
|
||||
|
@ -1099,15 +1025,15 @@ void ScShapeTest::testCustomShapeCellAnchoredRotatedShape()
|
|||
// The example doc contains a cell anchored custom shape that is rotated
|
||||
// and sheared. Error was, that the shape lost position and size on
|
||||
// loading.
|
||||
loadFromURL(u"tdf119191_transformedShape.ods");
|
||||
createScDoc("tdf119191_transformedShape.ods");
|
||||
|
||||
// Get document and shape
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
SdrObjCustomShape* pObj = dynamic_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(rDoc, 0));
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObjCustomShape* pObj
|
||||
= dynamic_cast<SdrObjCustomShape*>(lcl_getSdrObjectWithAssert(*pDoc, 0));
|
||||
|
||||
// Check Position and Size
|
||||
rDoc.SetDrawPageSize(0); // trigger recalcpos
|
||||
pDoc->SetDrawPageSize(0); // trigger recalcpos
|
||||
tools::Rectangle aRect(2400, 751, 5772, 3694); // expected snap rect from values in file
|
||||
const tools::Rectangle& rShapeRect(pObj->GetSnapRect());
|
||||
lcl_AssertRectEqualWithTolerance("Load: wrong pos and size", aRect, rShapeRect, 1);
|
||||
|
@ -1128,10 +1054,10 @@ void ScShapeTest::testLargeAnchorOffset()
|
|||
// The example doc contains a resize-with-cell-anchored measure line
|
||||
// with a large vertical offset that shifts the start point onto the
|
||||
// next cell below.
|
||||
loadFromURL(u"LargeAnchorOffset.ods");
|
||||
createScDoc("LargeAnchorOffset.ods");
|
||||
|
||||
ScDocShell* pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(pDocSh->GetDocument(), 0);
|
||||
ScDocument* pDoc = getScDoc();
|
||||
SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
const Point aOldPos = pObj->GetRelativePos();
|
||||
// Just to check that it imports correctly
|
||||
|
@ -1139,8 +1065,8 @@ void ScShapeTest::testLargeAnchorOffset()
|
|||
|
||||
saveAndReload("calc8");
|
||||
|
||||
pDocSh = lcl_getScDocShellWithAssert(mxComponent);
|
||||
pObj = lcl_getSdrObjectWithAssert(pDocSh->GetDocument(), 0);
|
||||
pDoc = getScDoc();
|
||||
pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
|
||||
|
||||
// Without the fix, this would fail:
|
||||
// Test name: sc_apitest::ScShapeTest::testLargeAnchorOffset
|
||||
|
|
Loading…
Reference in a new issue