summaryrefslogtreecommitdiff
path: root/sc/qa/unit/tiledrendering/tiledrendering.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/qa/unit/tiledrendering/tiledrendering.cxx')
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx56
1 files changed, 56 insertions, 0 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 7dc38facfa8e..1b6cf11d4211 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -178,6 +178,7 @@ public:
void testCellInvalidationDocWithExistingZoom();
void testOptimalRowHeight();
void testExtendedAreasDontOverlap();
+ void testEditShapeText();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnHeaders);
@@ -257,6 +258,7 @@ public:
CPPUNIT_TEST(testCellInvalidationDocWithExistingZoom);
CPPUNIT_TEST(testOptimalRowHeight);
CPPUNIT_TEST(testExtendedAreasDontOverlap);
+ CPPUNIT_TEST(testEditShapeText);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3941,6 +3943,60 @@ void ScTiledRenderingTest::testExtendedAreasDontOverlap()
aView1.m_aInvalidations[1].Top());
}
+Bitmap getTile(ScModelObj* pModelObj, int nTilePosX, int nTilePosY, tools::Long nTileWidth, tools::Long nTileHeight)
+{
+ size_t nCanvasSize = 1024;
+ size_t nTileSize = 256;
+ std::vector<unsigned char> aPixmap(nCanvasSize * nCanvasSize * 4, 0);
+ ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT);
+ pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
+ pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasSize, nCanvasSize),
+ Fraction(1.0), Point(), aPixmap.data());
+ pModelObj->paintTile(*pDevice, nCanvasSize, nCanvasSize, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+ pDevice->EnableMapMode(false);
+ return pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize));
+}
+
+// Ensure that editing a shape not in the topleft tile has its text shown inside the shape
+// center while editing
+void ScTiledRenderingTest::testEditShapeText()
+{
+ ScModelObj* pModelObj = createDoc("edit-shape-text.ods");
+
+ // Set View to initial 100%
+ pModelObj->setClientVisibleArea(tools::Rectangle(0, 0, 28050, 10605));
+ pModelObj->setClientZoom(256, 256, 1920, 1920);
+
+ ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+ CPPUNIT_ASSERT(pView);
+
+ const bool bShapeSelected = pView->SelectObject(u"Shape 1");
+ CPPUNIT_ASSERT(bShapeSelected);
+
+ CPPUNIT_ASSERT(ScDocShell::GetViewData()->GetScDrawView()->AreObjectsMarked());
+
+ Scheduler::ProcessEventsToIdle();
+
+ // Enter editing mode, shape start with no text
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::F2);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::F2);
+
+ Scheduler::ProcessEventsToIdle();
+
+ // Grab a snapshot of the center of the shape
+ Bitmap aBitmapBefore = getTile(pModelObj, 4096, 3584, 15360, 7680);
+
+ // reuse this to type into the active shape edit
+ lcl_typeCharsInCell("MMMMMMM", 0, 0, pView, pModelObj, true, false);
+
+ // Grab a new snapshot of the center of the shape
+ Bitmap aBitmapAfter = getTile(pModelObj, 4096, 3584, 15360, 7680);
+
+ // Without the fix, the text is not inside this tile and the before and
+ // after are the same.
+ CPPUNIT_ASSERT_MESSAGE("Text is not visible", aBitmapBefore != aBitmapAfter);
+}
+
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);