[Libreoffice-commits] .: 9 commits - sc/CppunitTest_sc_datapilotdescriptorbase.mk sc/Module_sc.mk sc/qa
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Wed Jan 18 09:13:39 PST 2012
sc/CppunitTest_sc_datapilotdescriptorbase.mk | 9
sc/Module_sc.mk | 1
sc/qa/extras/cellproperties.cxx | 36 +++
sc/qa/extras/tableautoformatfield.cxx | 27 ++
sc/qa/extras/testdocuments/rangenamessrc.ods |binary
sc/qa/extras/xcellrangesquery.cxx | 37 ++-
sc/qa/extras/xdatabaserange.cxx | 38 +++
sc/qa/extras/xdatapilottable.cxx | 6
sc/qa/extras/xspreadsheets2.cxx | 274 ++++++++++++++++++++-------
9 files changed, 344 insertions(+), 84 deletions(-)
New commits:
commit e3e54d74d6b9d8f5f2c256741fbaade69f4f0318
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jan 18 18:11:13 2012 +0100
enable new datapilot api test
diff --git a/sc/CppunitTest_sc_datapilotdescriptorbase.mk b/sc/CppunitTest_sc_datapilotdescriptorbase.mk
index 954cd6d..16e5cd9 100644
--- a/sc/CppunitTest_sc_datapilotdescriptorbase.mk
+++ b/sc/CppunitTest_sc_datapilotdescriptorbase.mk
@@ -115,17 +115,14 @@ $(eval $(call gb_CppunitTest_add_components,sc_datapilotdescriptorbase,\
sot/util/sot \
svl/source/fsstor/fsstorage \
toolkit/util/tk \
+ ucb/source/core/ucb1 \
+ ucb/source/ucp/file/ucpfile1 \
+ ucb/source/ucp/tdoc/ucptdoc1 \
unotools/util/utl \
unoxml/source/rdf/unordf \
unoxml/source/service/unoxml \
))
-$(eval $(call gb_CppunitTest_add_old_components,sc_datapilotdescriptorbase,\
- ucb1 \
- ucpfile1 \
- ucptdoc1 \
-))
-
$(eval $(call gb_CppunitTest_set_args,sc_datapilotdescriptorbase,\
--headless \
--protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index e57a433..266f822 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -41,6 +41,7 @@ $(eval $(call gb_Module_add_check_targets,sc,\
$(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
CppunitTest_sc_cellrangesbase \
+ CppunitTest_sc_datapilotdescriptorbase \
CppunitTest_sc_datapilotfieldobj \
CppunitTest_sc_macros_test \
CppunitTest_sc_namedrangeobj \
commit 5f1acc94095849f76a1ccd9711c2a4b524ca7d50
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jan 18 18:00:55 2012 +0100
little clean-up in xspreadsheet2 test
diff --git a/sc/qa/extras/xspreadsheets2.cxx b/sc/qa/extras/xspreadsheets2.cxx
index 2c79d8e..f694556 100644
--- a/sc/qa/extras/xspreadsheets2.cxx
+++ b/sc/qa/extras/xspreadsheets2.cxx
@@ -67,11 +67,6 @@ public:
virtual void setUp();
virtual void tearDown();
- uno::Reference< sheet::XSpreadsheetDocument> getDoc(const rtl::OUString, uno::Reference< lang::XComponent >);
- uno::Reference< sheet::XNamedRanges> getNamedRanges(uno::Reference< sheet::XSpreadsheetDocument >);
- void importSheetToCopy();
- bool isExternalReference(const rtl::OUString aDestContent, const rtl::OUString aSrcContent );
-
// XSpreadsheets2
void testImportedSheetNameAndIndex();
void testImportString();
@@ -99,6 +94,11 @@ public:
CPPUNIT_TEST_SUITE_END();
private:
+ uno::Reference< sheet::XSpreadsheetDocument> getDoc(const rtl::OUString, uno::Reference< lang::XComponent >&);
+ uno::Reference< sheet::XNamedRanges> getNamedRanges(uno::Reference< sheet::XSpreadsheetDocument >);
+ void importSheetToCopy();
+ bool isExternalReference(const rtl::OUString aDestContent, const rtl::OUString aSrcContent );
+
static int nTest;
static uno::Reference< lang::XComponent > xComponent;
@@ -132,7 +132,7 @@ rtl::OUString ScXSpreadsheets2::aSrcSheetName(RTL_CONSTASCII_USTRINGPARAM("Sheet
rtl::OUString ScXSpreadsheets2::aSrcFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenamessrc.ods"));
rtl::OUString ScXSpreadsheets2::aDestFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods"));
sal_Int32 ScXSpreadsheets2::nDestPos = 0;
-sal_Int32 ScXSpreadsheets2::nDestPosEffective;
+sal_Int32 ScXSpreadsheets2::nDestPosEffective = 0;
void ScXSpreadsheets2::testImportedSheetNameAndIndex()
{
@@ -352,7 +352,7 @@ void ScXSpreadsheets2::testImportCellStyle()
CPPUNIT_ASSERT_MESSAGE("New style: VertJustify not set", aVertJustify == table::CellVertJustify_CENTER);
}
-uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::getDoc(const rtl::OUString aFileBase, uno::Reference< lang::XComponent > xComp)
+uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::getDoc(const rtl::OUString aFileBase, uno::Reference< lang::XComponent >& xComp)
{
rtl::OUString aFileURL;
createFileURL(aFileBase, aFileURL);
@@ -401,11 +401,6 @@ void ScXSpreadsheets2::importSheetToCopy()
xDestSheet = uno::Reference< sheet::XSpreadsheet > ( xDestSheetNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW);
bIsSheetImported = true;
-
- // store destFile
- //uno::Reference< frame::XStorable > xStore (xDestDoc, UNO_QUERY_THROW);
- //xStore->store();
-
}
}
@@ -413,13 +408,7 @@ bool ScXSpreadsheets2::isExternalReference(rtl::OUString aDestContent, rtl::OUSt
{
rtl::OUString aStart(RTL_CONSTASCII_USTRINGPARAM("'file://"));
const sal_Char* sSrcContent = rtl::OUStringToOString( aSrcContent, RTL_TEXTENCODING_UTF8 ).getStr();
-/*
- std::cout << "aDestContent " << aDestContent << std::endl;
- std::cout << "aSrcContent " << aSrcContent << std::endl;
- std::cout << "endsWithIgnoreAsciiCaseAsciiL " << aDestContent.endsWithIgnoreAsciiCaseAsciiL(sSrcContent, aSrcContent.getLength()) << std::endl;
- std::cout << "indexOf(aStart) " << aDestContent.indexOf(aStart) << std::endl;
- std::cout << "indexOf(aSrcFileBase) " << aDestContent.indexOf(aSrcFileBase) << std::endl;
-*/
+
return (aDestContent.endsWithIgnoreAsciiCaseAsciiL(sSrcContent, aSrcContent.getLength()) // same cell address
&& aDestContent.indexOf(aStart)==0 // starts with 'file://
&& aDestContent.indexOf(aSrcFileBase)>0); // contains source file name
commit 51ed3a6324a5af91e2155ce11458785c30f5c878
Author: Laurent Godard <lgodard.libre at laposte.net>
Date: Mon Jan 9 10:09:07 2012 +0100
sc test : refactor importSheet tests
diff --git a/sc/qa/extras/testdocuments/rangenamessrc.ods b/sc/qa/extras/testdocuments/rangenamessrc.ods
index c780aef..f6546e9 100644
Binary files a/sc/qa/extras/testdocuments/rangenamessrc.ods and b/sc/qa/extras/testdocuments/rangenamessrc.ods differ
diff --git a/sc/qa/extras/xspreadsheets2.cxx b/sc/qa/extras/xspreadsheets2.cxx
index ef1cd53..2c79d8e 100644
--- a/sc/qa/extras/xspreadsheets2.cxx
+++ b/sc/qa/extras/xspreadsheets2.cxx
@@ -40,6 +40,7 @@
#include <com/sun/star/table/XCell.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
@@ -51,6 +52,9 @@
#include <com/sun/star/table/CellVertJustify.hpp>
#include <rtl/oustringostreaminserter.hxx>
+#include <rtl/string.hxx>
+
+
namespace ScSpreadsheetObj {
@@ -63,115 +67,186 @@ public:
virtual void setUp();
virtual void tearDown();
- uno::Reference< sheet::XSpreadsheetDocument> getDoc(const rtl::OUString);
+ uno::Reference< sheet::XSpreadsheetDocument> getDoc(const rtl::OUString, uno::Reference< lang::XComponent >);
uno::Reference< sheet::XNamedRanges> getNamedRanges(uno::Reference< sheet::XSpreadsheetDocument >);
+ void importSheetToCopy();
+ bool isExternalReference(const rtl::OUString aDestContent, const rtl::OUString aSrcContent );
// XSpreadsheets2
- void testImportSheet();
+ void testImportedSheetNameAndIndex();
+ void testImportString();
+ void testImportValue();
+ void testImportFormulaBasicMath();
+ void testImportFormulaWithNamedRange();
+ void testImportOverExistingNamedRange();
+ void testImportNamedRangeDefinedInSource();
+ void testImportNamedRangeRedefinedInSource();
+ void testImportNewNamedRange();
+ void testImportCellStyle();
CPPUNIT_TEST_SUITE(ScXSpreadsheets2);
- // disable test, test fails, might be the ongoing copy refs work
- CPPUNIT_TEST(testImportSheet);
+ CPPUNIT_TEST(testImportedSheetNameAndIndex);
+ CPPUNIT_TEST(testImportString);
+ CPPUNIT_TEST(testImportValue);
+ CPPUNIT_TEST(testImportFormulaBasicMath);
+ CPPUNIT_TEST(testImportFormulaWithNamedRange);
+ CPPUNIT_TEST(testImportOverExistingNamedRange);
+ CPPUNIT_TEST(testImportNamedRangeDefinedInSource);
+ CPPUNIT_TEST(testImportNamedRangeRedefinedInSource);
+ CPPUNIT_TEST(testImportNewNamedRange);
+ CPPUNIT_TEST(testImportCellStyle);
+
CPPUNIT_TEST_SUITE_END();
private:
static int nTest;
static uno::Reference< lang::XComponent > xComponent;
+
+ static bool bIsSheetImported;
+ static uno::Reference< sheet::XSpreadsheetDocument> xSrcDoc;
+ static uno::Reference< sheet::XSpreadsheetDocument> xDestDoc;
+ static uno::Reference< container::XNameAccess > xSrcNamedRangesNameAccess;
+ static uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess;
+ static uno::Reference< container::XNameAccess > xDestSheetNameAccess;
+ static uno::Reference< sheet::XSpreadsheet > xDestSheet;
+ static uno::Reference< sheet::XSpreadsheet > xSrcSheet;
+ static sal_Int32 nDestPosEffective;
+ static rtl::OUString aSrcSheetName;
+ static rtl::OUString aSrcFileBase;
+ static rtl::OUString aDestFileBase;
+ static sal_Int32 nDestPos;
};
int ScXSpreadsheets2::nTest = 0;
uno::Reference< lang::XComponent > ScXSpreadsheets2::xComponent;
-void ScXSpreadsheets2::testImportSheet()
+bool ScXSpreadsheets2::bIsSheetImported = false;
+uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::xSrcDoc;
+uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::xDestDoc;
+uno::Reference< container::XNameAccess > ScXSpreadsheets2::xSrcNamedRangesNameAccess;
+uno::Reference< container::XNameAccess > ScXSpreadsheets2::xDestNamedRangesNameAccess;
+uno::Reference< container::XNameAccess > ScXSpreadsheets2::xDestSheetNameAccess;
+uno::Reference< sheet::XSpreadsheet > ScXSpreadsheets2::xDestSheet;
+uno::Reference< sheet::XSpreadsheet > ScXSpreadsheets2::xSrcSheet;
+rtl::OUString ScXSpreadsheets2::aSrcSheetName(RTL_CONSTASCII_USTRINGPARAM("SheetToCopy"));
+rtl::OUString ScXSpreadsheets2::aSrcFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenamessrc.ods"));
+rtl::OUString ScXSpreadsheets2::aDestFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods"));
+sal_Int32 ScXSpreadsheets2::nDestPos = 0;
+sal_Int32 ScXSpreadsheets2::nDestPosEffective;
+
+void ScXSpreadsheets2::testImportedSheetNameAndIndex()
{
- const rtl::OUString aSrcFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenamessrc.ods"));
- uno::Reference< sheet::XSpreadsheetDocument> xSrcDoc = getDoc(aSrcFileBase);
- CPPUNIT_ASSERT(xSrcDoc.is());
+/**
+ Verfiy that the imported sheet has the correct name and is placed at the right requested index
+*/
- uno::Reference< container::XNameAccess > xSrcNamedRangesNameAccess (getNamedRanges(xSrcDoc), UNO_QUERY_THROW);
+ importSheetToCopy();
- const rtl::OUString aDestFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods"));
- uno::Reference< sheet::XSpreadsheetDocument> xDestDoc = getDoc(aDestFileBase);
- CPPUNIT_ASSERT(xDestDoc.is());
- uno::Reference< sheet::XSpreadsheets2 > xDest (xDestDoc->getSheets(), UNO_QUERY_THROW);
-
- uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess(getNamedRanges(xDestDoc), UNO_QUERY_THROW);
-
- // import sheet
- const sal_Int32 nDestPos = 0;
- const rtl::OUString aSrcSheetName(RTL_CONSTASCII_USTRINGPARAM("SheetToCopy"));
- sal_Int32 nDestPosEffective = xDest->importSheet(xSrcDoc, aSrcSheetName, nDestPos);
-
- //sheet index in dest is ok
+ CPPUNIT_ASSERT_MESSAGE("Wrong sheet name", xDestSheetNameAccess->hasByName(aSrcSheetName));
CPPUNIT_ASSERT_MESSAGE("Wrong sheet index", nDestPosEffective == nDestPos);
- uno::Reference< container::XNameAccess > xDestSheetNameAccess (xDestDoc->getSheets(), UNO_QUERY_THROW);
- uno::Reference< sheet::XSpreadsheet > xDestSheet( xDestSheetNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW);
-
- uno::Reference< container::XNameAccess > xSrcSheetNameAccess (xSrcDoc->getSheets(), UNO_QUERY_THROW);
- uno::Reference< sheet::XSpreadsheet > xSrcSheet( xSrcSheetNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW);
-
- //new sheet name in dest is ok
- CPPUNIT_ASSERT_MESSAGE("Wrong sheet name", xDestSheetNameAccess->hasByName(aSrcSheetName));
+}
- uno::Reference< table::XCell > xDestCell;
- uno::Reference< table::XCell > xSrcCell;
+void ScXSpreadsheets2::testImportString()
+{
+/**
+ tests the cell A1 containing a string correctly imported
+*/
+ importSheetToCopy();
- //imported string
- xSrcCell = xSrcSheet->getCellByPosition(0,0);
+ uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(0,0);
uno::Reference< text::XTextRange > xSrcTextRange(xSrcCell, UNO_QUERY_THROW);
rtl::OUString aSrcString = xSrcTextRange->getString();
- xDestCell = xDestSheet->getCellByPosition(0,0);
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(0,0);
uno::Reference< text::XTextRange > xDestTextRange(xDestCell, UNO_QUERY_THROW);
rtl::OUString aDestString = xDestTextRange->getString();
CPPUNIT_ASSERT_MESSAGE("Wrong string imported", aDestString.equals(aSrcString));
+}
+
+void ScXSpreadsheets2::testImportValue()
+{
+/**
+ tests the cell B1 containing a value correctly imported
+*/
+ importSheetToCopy();
- //imported value
- xSrcCell = xSrcSheet->getCellByPosition(1,0);
+ uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(1,0);
sal_Int32 aSrcValue = xSrcCell->getValue();
- xDestCell = xDestSheet->getCellByPosition(1,0);
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(1,0);
sal_Int32 aDestValue = xDestCell->getValue();
CPPUNIT_ASSERT_MESSAGE("Wrong value imported", aSrcValue == aDestValue);
+}
+
+void ScXSpreadsheets2::testImportFormulaBasicMath()
+{
+/**
+ tests the cell C1 containing an arithmetic formula correctly imported
+*/
+ importSheetToCopy();
- //mathematical formula
- xSrcCell = xSrcSheet->getCellByPosition(2,0);
+ uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(2,0);
rtl::OUString aSrcFormula = xSrcCell->getFormula();
- xDestCell = xDestSheet->getCellByPosition(2,0);
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(2,0);
rtl::OUString aDestFormula = xDestCell->getFormula();
// potential problem later: formulas might be adjusted
// add some tests that the formulas are correctly adjusted
CPPUNIT_ASSERT_MESSAGE("Wrong formula imported", aDestFormula.equals(aSrcFormula));
+}
- //formula with an already existing named range in dest - initial1
- xSrcCell = xSrcSheet->getCellByPosition(3,0);
- aSrcFormula = xSrcCell->getFormula();
+void ScXSpreadsheets2::testImportFormulaWithNamedRange()
+{
+/**
+ tests the cell D1 containing a formula that uses a NamedRange expression
+*/
+ importSheetToCopy();
- xDestCell = xDestSheet->getCellByPosition(3,0);
- aDestFormula = xDestCell->getFormula();
+ uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(3,0);
+ rtl::OUString aSrcFormula = xSrcCell->getFormula();
+
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(3,0);
+ rtl::OUString aDestFormula = xDestCell->getFormula();
CPPUNIT_ASSERT_MESSAGE("Wrong Namedrange formula imported", aDestFormula.equals(aSrcFormula));
+}
+
+void ScXSpreadsheets2::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
+
+ NEED MORE WORK
+*/
+ importSheetToCopy();
- // initial NamedRange content is correct
rtl::OUString aNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
uno::Any aNr = xDestNamedRangesNameAccess->getByName(aNamedRangeString);
uno::Reference< sheet::XNamedRange > xDestNamedRange(aNr, UNO_QUERY_THROW);
rtl::OUString aNrDestContent = xDestNamedRange->getContent();
- aNr = xSrcNamedRangesNameAccess->getByName(aNamedRangeString);
- uno::Reference< sheet::XNamedRange > xSrcNamedRange(aNr, UNO_QUERY_THROW);
- rtl::OUString aNrSrcContent = xSrcNamedRange->getContent();
-
- std::cout << "testImportSheet : initial1 aNrDestContent " << aNrDestContent << std::endl; // is $Sheet1.$B$1
- std::cout << "testImportSheet : initial1 aNrSrcContent " << aNrSrcContent << std::endl; // is $Sheet1.$B$2
rtl::OUString aExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1"));
-// CPPUNIT_ASSERT_MESSAGE("Sheet name for initial1 has been changed in dest (expected $Sheet1.$B$1) ", aNrDestContent.equals(aExpectedContent));
+
+ std::cout << "testImportSheet : initial1 aNrDestContent " << aNrDestContent << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("Wrong address for initial1", aNrDestContent.equals(aExpectedContent));
+
+}
+
+void ScXSpreadsheets2::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
rtl::OUString aNewInSheetNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("InSheetRangeName"));
@@ -181,9 +256,20 @@ void ScXSpreadsheets2::testImportSheet()
uno::Reference< sheet::XNamedRange > xDestNewInSheetNamedRange(aNewInSheetNr, UNO_QUERY_THROW);
rtl::OUString aNewInSheetNrDestContent = xDestNewInSheetNamedRange->getContent();
rtl::OUString aNewInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$SheetToCopy.$A$7"));
+
std::cout << "testImportSheet : InSheetRangeName content " << aNewInSheetNrDestContent << std::endl;
std::cout << "testImportSheet : InSheetRangeName expected " << aNewInSheetExpectedContent << std::endl;
CPPUNIT_ASSERT_MESSAGE("Wrong address for InSheetRangeName", aNewInSheetNrDestContent.equals(aNewInSheetExpectedContent));
+}
+
+void ScXSpreadsheets2::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
rtl::OUString aRedefinedInSheetNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial2"));
@@ -192,9 +278,19 @@ void ScXSpreadsheets2::testImportSheet()
uno::Any aRedefinedInSheetNr = xDestNamedRangesNameAccess->getByName(aRedefinedInSheetNamedRangeString);
uno::Reference< sheet::XNamedRange > xDestRedefinedInSheetNamedRange(aRedefinedInSheetNr, UNO_QUERY_THROW);
rtl::OUString aRedefinedInSheetNrDestContent = xDestRedefinedInSheetNamedRange->getContent();
- rtl::OUString aRedefinedInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$SheetToCopy.$A$10"));
+ rtl::OUString aRedefinedInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$2"));
std::cout << "testImportSheet : initial2 content " << aRedefinedInSheetNrDestContent << std::endl;
CPPUNIT_ASSERT_MESSAGE("Wrong address for Redefined InSheet named range", aRedefinedInSheetNrDestContent.equals(aRedefinedInSheetExpectedContent));
+}
+
+void ScXSpreadsheets2::testImportNewNamedRange()
+{
+/**
+ in Soucre 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-existant named range in dest - new_rangename
rtl::OUString aNewNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("new_rangename"));
@@ -210,7 +306,22 @@ void ScXSpreadsheets2::testImportSheet()
std::cout << "testImportSheet : new_rangename aNewExpectedContent " << aNewExpectedContent << std::endl;
std::cout << "testImportSheet : new_rangename aNewNrDestContent " << aNewNrDestContent << std::endl;
- CPPUNIT_ASSERT_MESSAGE("Wrong New NamedRange formula string value", aNewExpectedContent.equals(aNewExpectedContent));
+ CPPUNIT_ASSERT_MESSAGE("Wrong New NamedRange formula string value", isExternalReference(aNewNrDestContent, aNewExpectedContent));
+}
+
+void ScXSpreadsheets2::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();
+
+ uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(3,0);
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(3,0);
//new style created in dest
uno::Reference< beans::XPropertySet > xSrcCellPropSet (xSrcCell, UNO_QUERY_THROW);
@@ -241,17 +352,17 @@ void ScXSpreadsheets2::testImportSheet()
CPPUNIT_ASSERT_MESSAGE("New style: VertJustify not set", aVertJustify == table::CellVertJustify_CENTER);
}
-uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::getDoc(const rtl::OUString aFileBase)
+uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::getDoc(const rtl::OUString aFileBase, uno::Reference< lang::XComponent > xComp)
{
rtl::OUString aFileURL;
createFileURL(aFileBase, aFileURL);
- if (!xComponent.is())
- xComponent = loadFromDesktop(aFileURL);
+ if (!xComp.is())
+ xComp = loadFromDesktop(aFileURL);
- CPPUNIT_ASSERT(xComponent.is());
+ CPPUNIT_ASSERT(xComp.is());
- uno::Reference< sheet::XSpreadsheetDocument > xDoc(xComponent, UNO_QUERY_THROW);
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(xComp, UNO_QUERY_THROW);
CPPUNIT_ASSERT(xDoc.is());
return xDoc;
}
@@ -266,6 +377,54 @@ uno::Reference< sheet::XNamedRanges> ScXSpreadsheets2::getNamedRanges(uno::Refer
return xNamedRanges;
}
+void ScXSpreadsheets2::importSheetToCopy()
+{
+ if (!bIsSheetImported)
+ {
+ xSrcDoc = getDoc(aSrcFileBase, xComponent);
+ CPPUNIT_ASSERT(xSrcDoc.is());
+ xSrcNamedRangesNameAccess = uno::Reference< container::XNameAccess> (getNamedRanges(xSrcDoc), UNO_QUERY_THROW);
+
+ uno::Reference< lang::XComponent > xDestComponent;
+ xDestDoc = getDoc(aDestFileBase, xDestComponent);
+ CPPUNIT_ASSERT(xDestDoc.is());
+ xDestNamedRangesNameAccess = uno::Reference< container::XNameAccess > (getNamedRanges(xDestDoc), UNO_QUERY_THROW);
+
+ // import sheet
+ uno::Reference< sheet::XSpreadsheets2 > xDestSheets (xDestDoc->getSheets(), UNO_QUERY_THROW);
+ nDestPosEffective = xDestSheets->importSheet(xSrcDoc, aSrcSheetName, nDestPos);
+
+ uno::Reference< container::XNameAccess > xSrcSheetNameAccess (xSrcDoc->getSheets(), UNO_QUERY_THROW);
+ xSrcSheet = uno::Reference< sheet::XSpreadsheet > (xSrcSheetNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW);
+
+ xDestSheetNameAccess = uno::Reference< container::XNameAccess > (xDestDoc->getSheets(), UNO_QUERY_THROW);
+ xDestSheet = uno::Reference< sheet::XSpreadsheet > ( xDestSheetNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW);
+
+ bIsSheetImported = true;
+
+ // store destFile
+ //uno::Reference< frame::XStorable > xStore (xDestDoc, UNO_QUERY_THROW);
+ //xStore->store();
+
+ }
+}
+
+bool ScXSpreadsheets2::isExternalReference(rtl::OUString aDestContent, rtl::OUString aSrcContent )
+{
+ rtl::OUString aStart(RTL_CONSTASCII_USTRINGPARAM("'file://"));
+ const sal_Char* sSrcContent = rtl::OUStringToOString( aSrcContent, RTL_TEXTENCODING_UTF8 ).getStr();
+/*
+ std::cout << "aDestContent " << aDestContent << std::endl;
+ std::cout << "aSrcContent " << aSrcContent << std::endl;
+ std::cout << "endsWithIgnoreAsciiCaseAsciiL " << aDestContent.endsWithIgnoreAsciiCaseAsciiL(sSrcContent, aSrcContent.getLength()) << std::endl;
+ std::cout << "indexOf(aStart) " << aDestContent.indexOf(aStart) << std::endl;
+ std::cout << "indexOf(aSrcFileBase) " << aDestContent.indexOf(aSrcFileBase) << std::endl;
+*/
+ return (aDestContent.endsWithIgnoreAsciiCaseAsciiL(sSrcContent, aSrcContent.getLength()) // same cell address
+ && aDestContent.indexOf(aStart)==0 // starts with 'file://
+ && aDestContent.indexOf(aSrcFileBase)>0); // contains source file name
+}
+
void ScXSpreadsheets2::setUp()
{
nTest += 1;
commit 206b748f884da6b3bd9628a0e1f3ed6fa38918f6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Wed Jan 18 10:25:53 2012 +0100
it is not possible to start/terminate libreoffice twice in the same program
we have a static variable that prevents us from terminating libreoffice
in this case here
diff --git a/sc/qa/extras/cellproperties.cxx b/sc/qa/extras/cellproperties.cxx
index c86d33a..2937915 100644
--- a/sc/qa/extras/cellproperties.cxx
+++ b/sc/qa/extras/cellproperties.cxx
@@ -139,11 +139,6 @@ void ScCellProperties::tearDown()
UnoApiTest::tearDown();
- if (nTest == NUMBER_OF_TESTS)
- {
- mxDesktop->terminate();
- uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
- }
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScCellProperties);
diff --git a/sc/qa/extras/xcellrangesquery.cxx b/sc/qa/extras/xcellrangesquery.cxx
index 78654e3..a5a5a6f 100644
--- a/sc/qa/extras/xcellrangesquery.cxx
+++ b/sc/qa/extras/xcellrangesquery.cxx
@@ -185,11 +185,6 @@ void ScXCellRangesQuery::tearDown()
UnoApiTest::tearDown();
- if (nTest == NUMBER_OF_TESTS)
- {
- mxDesktop->terminate();
- uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
- }
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScXCellRangesQuery);
commit c0e1ef3bcb6fa15b0b9aa75565b6e43df62c9ad8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jan 17 12:37:57 2012 +0100
terminate xcellrangesquery correctly
diff --git a/sc/qa/extras/xcellrangesquery.cxx b/sc/qa/extras/xcellrangesquery.cxx
index dc9b777..78654e3 100644
--- a/sc/qa/extras/xcellrangesquery.cxx
+++ b/sc/qa/extras/xcellrangesquery.cxx
@@ -34,18 +34,21 @@
#include <com/sun/star/sheet/XSheetCellRanges.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/sheet/CellFlags.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
using namespace com::sun::star;
namespace ScCellRangeBase {
+#define NUMBER_OF_TESTS 5
+
class ScXCellRangesQuery : public UnoApiTest
{
public:
- ScXCellRangesQuery();
- uno::Reference<sheet::XCellRangesQuery> init();
+ virtual void setUp();
+ virtual void tearDown();
//Testcases
void testQueryColumnDifference();
@@ -66,12 +69,15 @@ public:
CPPUNIT_TEST(testQueryRowDifference);
CPPUNIT_TEST_SUITE_END();
-};
+private:
+ uno::Reference<sheet::XCellRangesQuery> init();
-ScXCellRangesQuery::ScXCellRangesQuery()
-{
+ static int nTest;
+ static uno::Reference< lang::XComponent > xComponent;
+};
-}
+int ScXCellRangesQuery::nTest = 0;
+uno::Reference< lang::XComponent > ScXCellRangesQuery::xComponent;
uno::Reference<sheet::XCellRangesQuery> ScXCellRangesQuery::init()
{
@@ -79,7 +85,6 @@ uno::Reference<sheet::XCellRangesQuery> ScXCellRangesQuery::init()
const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xcellrangesquery.ods"));
createFileURL(aFileBase, aFileURL);
std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- static uno::Reference< lang::XComponent > xComponent;
if( !xComponent.is())
xComponent = loadFromDesktop(aFileURL);
uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
@@ -164,6 +169,29 @@ void ScXCellRangesQuery::testQueryVisibleCells()
CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
}
+void ScXCellRangesQuery::setUp()
+{
+ nTest += 1;
+ UnoApiTest::setUp();
+}
+
+void ScXCellRangesQuery::tearDown()
+{
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
+ xCloseable->close( false );
+ }
+
+ UnoApiTest::tearDown();
+
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ mxDesktop->terminate();
+ uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScXCellRangesQuery);
CPPUNIT_PLUGIN_IMPLEMENT();
commit 7fb6d6250792311d1a55d7435569c0b89efecba6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jan 17 12:41:31 2012 +0100
terminate xdatabaserange correctly
diff --git a/sc/qa/extras/xdatabaserange.cxx b/sc/qa/extras/xdatabaserange.cxx
index 64a4f09..22a2680 100644
--- a/sc/qa/extras/xdatabaserange.cxx
+++ b/sc/qa/extras/xdatabaserange.cxx
@@ -34,14 +34,18 @@
#include <com/sun/star/sheet/XDatabaseRange.hpp>
#include <com/sun/star/sheet/XDatabaseRanges.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <rtl/oustringostreaminserter.hxx>
namespace ScDatabaseRangeObj {
+#define NUMBER_OF_TESTS 3
+
class ScXDatabaseRange : public UnoApiTest
{
- uno::Reference< sheet::XDatabaseRange > init(const rtl::OUString& rName);
+ virtual void setUp();
+ virtual void tearDown();
void testDataArea();
void testGetSortDescriptor();
@@ -52,8 +56,16 @@ class ScXDatabaseRange : public UnoApiTest
CPPUNIT_TEST(testGetSortDescriptor);
CPPUNIT_TEST(testGetSubtotalDescriptor);
CPPUNIT_TEST_SUITE_END();
+private:
+ uno::Reference< sheet::XDatabaseRange > init(const rtl::OUString& rName);
+
+ static int nTest;
+ static uno::Reference< lang::XComponent > xComponent;
};
+int ScXDatabaseRange::nTest = 0;
+uno::Reference< lang::XComponent > ScXDatabaseRange::xComponent;
+
/**
* tests setDataArea and getDataArea
*/
@@ -154,7 +166,6 @@ uno::Reference< sheet::XDatabaseRange > ScXDatabaseRange::init(const rtl::OUStri
const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xdatabaserange.ods"));
createFileURL(aFileBase, aFileURL);
std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- static uno::Reference< lang::XComponent > xComponent;
if( !xComponent.is())
xComponent = loadFromDesktop(aFileURL);
uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
@@ -166,6 +177,29 @@ uno::Reference< sheet::XDatabaseRange > ScXDatabaseRange::init(const rtl::OUStri
return xDBRange;
}
+void ScXDatabaseRange::setUp()
+{
+ nTest += 1;
+ UnoApiTest::setUp();
+}
+
+void ScXDatabaseRange::tearDown()
+{
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
+ xCloseable->close( false );
+ }
+
+ UnoApiTest::tearDown();
+
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ mxDesktop->terminate();
+ uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScXDatabaseRange);
CPPUNIT_PLUGIN_IMPLEMENT();
commit 27553fa07e680edcdae68b40eba4fa201b6cdf59
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jan 17 12:45:50 2012 +0100
correctly terminate cellproperties
diff --git a/sc/qa/extras/cellproperties.cxx b/sc/qa/extras/cellproperties.cxx
index 2f59002..c86d33a 100644
--- a/sc/qa/extras/cellproperties.cxx
+++ b/sc/qa/extras/cellproperties.cxx
@@ -33,12 +33,17 @@
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
namespace ScCellRangeBase {
+#define NUMBER_OF_TESTS 2
+
class ScCellProperties : public UnoApiTest
{
- uno::Reference < beans::XPropertySet > init();
+public:
+ virtual void setUp();
+ virtual void tearDown();
void testVertJustify();
void testRotateReference();
@@ -46,8 +51,18 @@ class ScCellProperties : public UnoApiTest
CPPUNIT_TEST(testVertJustify);
CPPUNIT_TEST(testRotateReference);
CPPUNIT_TEST_SUITE_END();
+
+private:
+ uno::Reference < beans::XPropertySet > init();
+
+ static int nTest;
+ static uno::Reference< lang::XComponent > xComponent;
};
+int ScCellProperties::nTest = 0;
+uno::Reference< lang::XComponent > ScCellProperties::xComponent;
+
+
void ScCellProperties::testVertJustify()
{
uno::Reference< beans::XPropertySet > xCellRangeBase = init();
@@ -89,7 +104,6 @@ uno::Reference< beans::XPropertySet > ScCellProperties::init()
rtl::OUString aFileURL;
const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xcellrangesquery.ods"));
createFileURL(aFileBase, aFileURL);
- static uno::Reference< lang::XComponent > xComponent;
if( !xComponent.is())
xComponent = loadFromDesktop(aFileURL);
uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
@@ -109,6 +123,29 @@ uno::Reference< beans::XPropertySet > ScCellProperties::init()
return xReturn;
}
+void ScCellProperties::setUp()
+{
+ nTest += 1;
+ UnoApiTest::setUp();
+}
+
+void ScCellProperties::tearDown()
+{
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
+ xCloseable->close( false );
+ }
+
+ UnoApiTest::tearDown();
+
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ mxDesktop->terminate();
+ uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScCellProperties);
}
commit 55abb2c6bb8f554ceb2fe85ba873b9be7d6633ea
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jan 17 13:29:44 2012 +0100
correctly terminate tableautoformatfield
diff --git a/sc/qa/extras/tableautoformatfield.cxx b/sc/qa/extras/tableautoformatfield.cxx
index c4f5962..ac0ad8c 100644
--- a/sc/qa/extras/tableautoformatfield.cxx
+++ b/sc/qa/extras/tableautoformatfield.cxx
@@ -34,10 +34,15 @@
namespace ScAutoFormatFieldObj {
+#define NUMBER_OF_TESTS 2
+
class ScTableAutoFormatField : public UnoApiTest
{
public:
+ virtual void setUp();
+ virtual void tearDown();
+
uno::Reference< beans::XPropertySet > init(); void testRotateReference();
void testVertJustify();
@@ -46,8 +51,13 @@ public:
CPPUNIT_TEST(testVertJustify);
CPPUNIT_TEST_SUITE_END();
+private:
+
+ static int nTest;
};
+int ScTableAutoFormatField::nTest = 0;
+
uno::Reference< beans::XPropertySet > ScTableAutoFormatField::init()
{
uno::Reference< container::XIndexAccess > xAutoFormatFields( m_xSFactory->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.TableAutoFormats"))), UNO_QUERY_THROW );
@@ -95,6 +105,23 @@ void ScTableAutoFormatField::testVertJustify()
CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3);
}
+void ScTableAutoFormatField::setUp()
+{
+ nTest += 1;
+ UnoApiTest::setUp();
+}
+
+void ScTableAutoFormatField::tearDown()
+{
+ UnoApiTest::tearDown();
+
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ mxDesktop->terminate();
+ uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScTableAutoFormatField);
CPPUNIT_PLUGIN_IMPLEMENT();
commit d4273a37a59601f7dbc7f72282cba11c2cc883b3
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon Jan 16 08:55:47 2012 +0100
these two variables don't need to be static
diff --git a/sc/qa/extras/xdatapilottable.cxx b/sc/qa/extras/xdatapilottable.cxx
index c9d3ab9..c19c484 100644
--- a/sc/qa/extras/xdatapilottable.cxx
+++ b/sc/qa/extras/xdatapilottable.cxx
@@ -64,14 +64,12 @@ private:
static int nTest;
static uno::Reference< lang::XComponent > xComponent;
- static uno::Reference< table::XCell > xCellForChange;
- static uno::Reference< table::XCell > xCellForCheck;
+ uno::Reference< table::XCell > xCellForChange;
+ uno::Reference< table::XCell > xCellForCheck;
};
int ScXDataPilotTable::nTest = 0;
uno::Reference< lang::XComponent > ScXDataPilotTable::xComponent;
-uno::Reference< table::XCell > ScXDataPilotTable::xCellForChange;
-uno::Reference< table::XCell > ScXDataPilotTable::xCellForCheck;
void ScXDataPilotTable::testGetOutputRange()
{
More information about the Libreoffice-commits
mailing list