12#include <com/sun/star/container/XIndexAccess.hpp>
13#include <com/sun/star/container/XNamed.hpp>
14#include <com/sun/star/sheet/XSpreadsheets.hpp>
16#include <cppunit/TestAssert.h>
26 uno::Reference< sheet::XSpreadsheets > xSpreadsheets(
init(), UNO_QUERY_THROW);
28 OUString newSheetName(
"SheetToInsert" );
29 xSpreadsheets->insertNewByName(newSheetName, 0);
31 uno::Reference< container::XNameAccess > xNameAccess(xSpreadsheets, UNO_QUERY_THROW);
32 CPPUNIT_ASSERT_MESSAGE(
"Sheet was not insert",
33 xNameAccess->hasByName(newSheetName));
38 uno::Reference< sheet::XSpreadsheets > xSpreadsheets(
init(), UNO_QUERY_THROW);
40 CPPUNIT_ASSERT_THROW_MESSAGE(
"No exception thrown",
41 xSpreadsheets->insertNewByName(
"$%#/?\\", 0),
42 uno::RuntimeException);
47 uno::Reference< sheet::XSpreadsheets > xSpreadsheets(
init(), UNO_QUERY_THROW);
50 xSpreadsheets->insertNewByName(
"SheetToMove", 0);
51 uno::Reference< container::XNameAccess > xNameAccess(xSpreadsheets, UNO_QUERY_THROW);
52 CPPUNIT_ASSERT_MESSAGE(
"Sheet to move was not insert",
53 xNameAccess->hasByName(
"SheetToMove"));
55 xSpreadsheets->moveByName(
"SheetToMove", 2);
58 uno::Reference< container::XIndexAccess > oIndexAccess(xSpreadsheets, UNO_QUERY_THROW);
59 uno::Any aAny = oIndexAccess->getByIndex(1);
60 uno::Reference< container::XNamed > xNamed;
61 CPPUNIT_ASSERT(aAny >>= xNamed);
63 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Sheet was not moved",
64 OUString(
"SheetToMove"),
70 uno::Reference< sheet::XSpreadsheets > xSpreadsheets(
init(), UNO_QUERY_THROW);
73 xSpreadsheets->insertNewByName(
"SheetToCopySrc", 0);
74 uno::Reference< container::XNameAccess > xNameAccess(xSpreadsheets, UNO_QUERY_THROW);
75 CPPUNIT_ASSERT_MESSAGE(
"Sheet to copy was not insert",
76 xNameAccess->hasByName(
"SheetToCopySrc"));
78 xSpreadsheets->copyByName(
"SheetToCopySrc",
"SheetToCopyDst", 0);
79 CPPUNIT_ASSERT_MESSAGE(
"Sheet was not copied",
80 xNameAccess->hasByName(
"SheetToCopyDst"));
void testInsertNewByName()
virtual css::uno::Reference< css::uno::XInterface > init()=0
void testInsertNewByNameBadName()