/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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/.
*/
void XSpreadsheets2::testImportedSheetNameAndIndex()
{ /** Verify that the imported sheet has the correct name and is placed at the right requested index
*/
// potential problem later: formulas might be adjusted // add some tests that the formulas are correctly adjusted
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula imported", aSrcFormula, aDestFormula);
}
void XSpreadsheets2::testImportFormulaWithNamedRange()
{ /** tests the cell D1 containing a formula that uses a NamedRange expression
*/
importSheetToCopy();
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Namedrange formula imported", aSrcFormula, aDestFormula);
}
void XSpreadsheets2::testImportOverExistingNamedRange()
{ /** Both Source and Target file define the named range initial1 in Source, initial1 is defined outside the copied sheet In Target, after import sheet, initial1 should point on its initial definition $Sheet1.$B$1
void XSpreadsheets2::testImportNamedRangeDefinedInSource()
{ /** in Source file, InSheetRangeName named range is defined in the copied sheet it does not exists in target file test that the range named is created in target and that it points in the target copied sheet
*/
importSheetToCopy();
// New range name defined in imported sheet $SheetToCopy.$A$7
OUString aNewInSheetNamedRangeString(u"InSheetRangeName"_ustr);
uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess(getNamedRanges(xDestDoc), UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("InSheetRangeName", xDestNamedRangesNameAccess->hasByName(aNewInSheetNamedRangeString));
void XSpreadsheets2::testImportNamedRangeRedefinedInSource()
{ /** in Source file, initial2 named range is defined in the copied sheet it is defined in another sheet of target file test that the range named points in the target copied sheet
*/
importSheetToCopy();
// the source file redefines an existing named range in the imported sheet --> the target should not be changed
OUString aRedefinedInSheetNamedRangeString(u"initial2"_ustr);
uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess(getNamedRanges(xDestDoc), UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("aRedefinedInSheetNamedRangeString", xDestNamedRangesNameAccess->hasByName(aRedefinedInSheetNamedRangeString));
void XSpreadsheets2::testImportNewNamedRange()
{ /** in Source file, new_rangename range named is defined outside the copied sheet it does not exists in target file test that new_rangename is created and its content points to source file as an external reference
*/
importSheetToCopy();
//formula with a non-existent named range in dest - new_rangename
OUString aNewNamedRangeString(u"new_rangename"_ustr);
uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess(getNamedRanges(xDestDoc), UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("New NamedRange not created", xDestNamedRangesNameAccess->hasByName(aNewNamedRangeString));
// verify the content of this new namedrange, pointing on $Sheet1.$B$1 in source. This address is already defined in target as NR content
void XSpreadsheets2::testImportCellStyle()
{ /** in source file, imported sheet uses a cellstyle that does not exists in target test that - an imported cell D1 uses the right cellStyle - the cellStyle is created in CellStyles family - a property of the cellStyle (VertJustify) is correctly set
*/
importSheetToCopy();
CPPUNIT_ASSERT_EQUAL_MESSAGE("New style: VertJustify not set", table::CellVertJustify_CENTER, static_cast<table::CellVertJustify>(aVertJustify));
}
void XSpreadsheets2::testLastAfterInsertCopy()
{ /** Test that results in row 1 of all inserted sheets are equal to the source sheet. The loaded destination document is kept open so several sheets are imported.
*/
OUString aSrcString[nCols]; for (sal_Int32 nCol=0; nCol < nCols; ++nCol)
{
uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(nCol, 0);
uno::Reference< text::XTextRange > xSrcTextRange(xSrcCell, UNO_QUERY_THROW);
aSrcString[nCol] = xSrcTextRange->getString();
} // The named range 'initial2' is already present in the destination // document defined to $Sheet1.$B$2 and thus is not copied, pointing to // "content2" instead.
aSrcString[6] = "content2";
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.