/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// Shape should be anchored to sheet by default
uno::Reference<sheet::XSpreadsheet> xSheetGet;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Anchor (XSpreadsheet)",
xShape->getPropertyValue(u"Anchor"_ustr) >>= xSheetGet);
// Anchor the shape to a cell
aNewValue <<= xCell;
xShape->setPropertyValue(u"Anchor"_ustr, aNewValue);
uno::Reference<table::XCell> xCellGet;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Anchor (XCell)",
xShape->getPropertyValue(u"Anchor"_ustr) >>= xCellGet);
// Shape should not resize with cell by default bool bIsResizeWithCell = {};
CPPUNIT_ASSERT(xShape->getPropertyValue(u"ResizeWithCell"_ustr) >>= bIsResizeWithCell);
CPPUNIT_ASSERT_MESSAGE("Shape should not resize with the cell", !bIsResizeWithCell);
xShape->setPropertyValue(u"ResizeWithCell"_ustr, uno::Any(true));
CPPUNIT_ASSERT(xShape->getPropertyValue(u"ResizeWithCell"_ustr) >>= bIsResizeWithCell);
CPPUNIT_ASSERT_MESSAGE("Shape should resize with the cell", bIsResizeWithCell);
// Anchoring to a different cell should keep the "ResizeWithCell" attribute
uno::Reference<table::XCell> xCell2(xSheet->getCellByPosition(1, 2), UNO_SET_THROW);
aNewValue <<= xCell2;
xShape->setPropertyValue(u"Anchor"_ustr, aNewValue);
CPPUNIT_ASSERT(xShape->getPropertyValue(u"ResizeWithCell"_ustr) >>= bIsResizeWithCell);
CPPUNIT_ASSERT_MESSAGE("ResizeWithCell should still be set", bIsResizeWithCell);
// Now anchor to sheet again
aNewValue <<= xSheet;
xShape->setPropertyValue(u"Anchor"_ustr, aNewValue);
CPPUNIT_ASSERT(xShape->getPropertyValue(u"Anchor"_ustr) >>= xSheetGet);
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Anchor (XSpreadsheet)",
xShape->getPropertyValue(u"Anchor"_ustr) >>= xSheetGet);
// Setting ResizeWithCell while anchored to page should not have any effect
CPPUNIT_ASSERT(xShape->getPropertyValue(u"ResizeWithCell"_ustr) >>= bIsResizeWithCell);
CPPUNIT_ASSERT_MESSAGE("ResizeWithCell should be false for sheet anchored shapes",
!bIsResizeWithCell);
xShape->setPropertyValue(u"ResizeWithCell"_ustr, uno::Any(true));
CPPUNIT_ASSERT(xShape->getPropertyValue(u"ResizeWithCell"_ustr) >>= bIsResizeWithCell);
CPPUNIT_ASSERT_MESSAGE("ResizeWithCell should be unchangeable for sheet anchored shapes",
!bIsResizeWithCell);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.