diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-02-12 01:58:23 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-02-13 21:37:48 +0000 |
commit | 36ef9f8d077afe2c605e9d22588dc3f698440d89 (patch) | |
tree | f355d82d3c83a5c3c26be94ce4d1115c73c997b4 /sc/qa/extras | |
parent | f9ead4c6612b3e36b56f2cb83602f019ccaf1dc4 (diff) |
tdf#76183: refresh objects' positions on optimal height recalc
Since commit b10833d4db6046f2d32ea44a60cb19a626d80447, it's required
to detect when objects' placement should be adjusted, and call
SetDrawPageSize manually.
Unit test included
Change-Id: I933ba4802b212400cc47ed0fb7e1f8f44049bb81
Reviewed-on: https://gerrit.libreoffice.org/34165
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/qa/extras')
-rw-r--r-- | sc/qa/extras/anchor.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sc/qa/extras/anchor.cxx b/sc/qa/extras/anchor.cxx index b5310abe69d3..04e06cb63873 100644 --- a/sc/qa/extras/anchor.cxx +++ b/sc/qa/extras/anchor.cxx @@ -13,10 +13,15 @@ #include <sfx2/dispatch.hxx> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/text/XText.hpp> #include <unonames.hxx> #include "tabvwsh.hxx" #include "docsh.hxx" +#include "svx/svdocirc.hxx" +#include "scitems.hxx" #include "sc.hrc" @@ -32,9 +37,11 @@ public: virtual void tearDown() override; void testUndoAnchor(); + void testTdf76183(); CPPUNIT_TEST_SUITE(ScAnchorTest); CPPUNIT_TEST(testUndoAnchor); + CPPUNIT_TEST(testTdf76183); CPPUNIT_TEST_SUITE_END(); private: @@ -148,6 +155,36 @@ void ScAnchorTest::testUndoAnchor() xComponent->dispose(); } +void ScAnchorTest::testTdf76183() +{ + uno::Reference< lang::XComponent > xComponent = loadFromDesktop("private:factory/scalc"); + SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent); + ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell); + ScDocument& rDoc = pDocSh->GetDocument(); + ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer(); + SdrPage *pPage = pDrawLayer->GetPage(0); + + // Add a circle somewhere below first row. + const Rectangle aOrigRect = Rectangle(1000, 1000, 1200, 1200); + SdrCircObj* pObj = new SdrCircObj(OBJ_CIRC, aOrigRect); + pPage->InsertObject(pObj); + // Anchor to cell + ScDrawLayer::SetCellAnchoredFromPosition(*pObj, rDoc, 0); + const Rectangle& rNewRect = pObj->GetLogicRect(); + + // Set word wrap to true + rDoc.ApplyAttr(0, 0, 0, SfxBoolItem(ATTR_LINEBREAK, true)); + // Add multi-line text to cell to initiate optimal height change + uno::Reference<sheet::XSpreadsheetDocument> xDoc(xComponent, uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIA(xDoc->getSheets(), uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<text::XText> xText(xSheet->getCellByPosition(0, 0), uno::UNO_QUERY_THROW); + xText->setString("first\nsecond\nthird"); + + // The resize of first row must have moved the object down after its anchor cell + CPPUNIT_ASSERT(aOrigRect.Top() < rNewRect.Top()); +} + void ScAnchorTest::tearDown() { if (mxComponent.is()) |