summaryrefslogtreecommitdiffstats
path: root/sc/qa
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2012-01-11 16:23:45 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2012-01-11 16:26:41 -0500
commit75bc746b97b5d1e08cd26c7bb5afde348085f6bf (patch)
tree13af3beaa064cb1d0c946dbc3e2029d6235ce232 /sc/qa
parentmade formatindex="33" the ISO 8601 YYYY-MM-DD that it needs to be (diff)
downloadcore-75bc746b97b5d1e08cd26c7bb5afde348085f6bf.tar.gz
core-75bc746b97b5d1e08cd26c7bb5afde348085f6bf.zip
Unit test for repositioning of cell-anchored line objects.
Preivously, before my fix, relocating a cell-anchored bottom-left to top-right line object would get flipped when its position changed. This is a test for that use case.
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/ucalc.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index d45ddb4c58e5..c843eb74767d 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -62,11 +62,13 @@
#include "formula/IFunctionDescription.hxx"
+#include <basegfx/polygon/b2dpolygon.hxx>
#include <editeng/boxitem.hxx>
#include <svx/svdograf.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdocirc.hxx>
+#include <svx/svdopath.hxx>
#include <sfx2/docfile.hxx>
@@ -2504,6 +2506,35 @@ void Test::testGraphicsInGroup()
CPPUNIT_ASSERT_MESSAGE("Failed to move back to its original position.", aOrigRect == rNewRect);
}
+ {
+ // Add a line.
+ basegfx::B2DPolygon aTempPoly;
+ Point aStartPos(10,300), aEndPos(110,200); // bottom-left to top-right.
+ Rectangle aOrigRect(10,200,110,300); // 100 x 100
+ aTempPoly.append(basegfx::B2DPoint(aStartPos.X(), aStartPos.Y()));
+ aTempPoly.append(basegfx::B2DPoint(aEndPos.X(), aEndPos.Y()));
+ SdrPathObj* pObj = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aTempPoly));
+ pObj->NbcSetLogicRect(aOrigRect);
+ pPage->InsertObject(pObj);
+ const Rectangle& rNewRect = pObj->GetLogicRect();
+ CPPUNIT_ASSERT_MESSAGE("Size differ.", aOrigRect == rNewRect);
+
+ ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *m_pDoc, 0);
+ CPPUNIT_ASSERT_MESSAGE("Size changed when cell-anchored. Not good.",
+ aOrigRect == rNewRect);
+
+ // Insert 2 rows at the top and delete them immediately.
+ m_pDoc->InsertRow(0, 0, MAXCOL, 0, 0, 2);
+ m_pDoc->DeleteRow(0, 0, MAXCOL, 0, 0, 2);
+ CPPUNIT_ASSERT_MESSAGE("Size of a line object changed after row insertion and removal.",
+ aOrigRect == rNewRect);
+
+ sal_Int32 n = pObj->GetPointCount();
+ CPPUNIT_ASSERT_MESSAGE("There should be exactly 2 points in a line object.", n == 2);
+ CPPUNIT_ASSERT_MESSAGE("Line shape has changed.",
+ aStartPos == pObj->GetPoint(0) && aEndPos == pObj->GetPoint(1));
+ }
+
m_pDoc->DeleteTab(0);
}