summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2011-11-02 17:49:42 +0100
committerMichael Stahl <mstahl@redhat.com>2011-11-02 17:49:42 +0100
commit66d9925bb6e9c43aacfe9e4ac6f1ee10a8e25166 (patch)
treeea3e9cb2bd0ca5a8fe7432908bdfdd5071f0773d /sc
parentb2254d5d6fde8c28501e99e29bc824e935a25247 (diff)
parentf6f5c89259867b5aeb86d5509f826da949d122c4 (diff)
Merge branch 'master' of git://anongit.freedesktop.org/libreoffice/core
Diffstat (limited to 'sc')
-rw-r--r--sc/CppunitTest_sc_filters_test.mk3
-rw-r--r--sc/CppunitTest_sc_macros_test.mk4
-rw-r--r--sc/inc/document.hxx3
-rw-r--r--sc/qa/unit/data/contentCSV/bugFix_Sheet2.csv6
-rw-r--r--sc/qa/unit/data/contentCSV/spreadsheet-functions.csv4
-rw-r--r--sc/qa/unit/data/ods/bug-fixes.odsbin9361 -> 10467 bytes
-rw-r--r--sc/qa/unit/data/ods/functions.odsbin10500 -> 10519 bytes
-rw-r--r--sc/qa/unit/filters-test.cxx6
-rw-r--r--sc/qa/unit/macros-test.cxx2
-rw-r--r--sc/qa/unit/ucalc.cxx74
-rw-r--r--sc/source/core/data/document.cxx11
-rw-r--r--sc/source/core/tool/scmatrix.cxx8
-rw-r--r--sc/source/filter/xml/xmlimprt.cxx3
-rw-r--r--sc/source/filter/xml/xmlsubti.cxx18
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx79
-rw-r--r--sc/source/ui/view/tabview3.cxx2
16 files changed, 153 insertions, 70 deletions
diff --git a/sc/CppunitTest_sc_filters_test.mk b/sc/CppunitTest_sc_filters_test.mk
index e40ae2e63e33..3260d32d0605 100644
--- a/sc/CppunitTest_sc_filters_test.mk
+++ b/sc/CppunitTest_sc_filters_test.mk
@@ -99,8 +99,9 @@ $(eval $(call gb_CppunitTest_add_service_rdbs,sc_filters_test,\
$(eval $(call gb_CppunitTest_set_args,sc_filters_test,\
--headless \
--protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \
- -env:OOO_CONFIG_REGISTRY_DIR=$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) \
+ "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool)" \
))
+ # .../spool is required for the (somewhat strange) filter configuration
# we need to
# a) explicitly depend on library msword because it is not implied by a link
diff --git a/sc/CppunitTest_sc_macros_test.mk b/sc/CppunitTest_sc_macros_test.mk
index 0da63485bfe7..5d39769a3f15 100644
--- a/sc/CppunitTest_sc_macros_test.mk
+++ b/sc/CppunitTest_sc_macros_test.mk
@@ -99,9 +99,9 @@ $(eval $(call gb_CppunitTest_add_service_rdbs,sc_macros_test,\
$(eval $(call gb_CppunitTest_set_args,sc_macros_test,\
--headless \
--protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \
- -env:OOO_CONFIG_REGISTRY_DIR=$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) \
- -env:OOO_CONFIG_REGISTRY_EXTRA_DIR=$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/user) \
+ "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool) xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/user)" \
))
+ # .../spool is required for the (somewhat strange) filter configuration
# we need to
# a) explicitly depend on library msword because it is not implied by a link
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index a7ae1c3bb576..582901cc72e4 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -575,6 +575,9 @@ public:
SC_DLLPUBLIC void CreateValidTabName(String& rName) const;
SC_DLLPUBLIC void CreateValidTabName(rtl::OUString& rName) const;
SC_DLLPUBLIC void CreateValidTabNames(std::vector<rtl::OUString>& aNames, SCTAB nCount) const;
+
+ void AppendTabOnLoad(const rtl::OUString& rName);
+
SC_DLLPUBLIC sal_Bool InsertTab( SCTAB nPos, const String& rName,
sal_Bool bExternalDocument = false );
SC_DLLPUBLIC bool InsertTabs( SCTAB nPos, const std::vector<rtl::OUString>& rNames,
diff --git a/sc/qa/unit/data/contentCSV/bugFix_Sheet2.csv b/sc/qa/unit/data/contentCSV/bugFix_Sheet2.csv
new file mode 100644
index 000000000000..c6fbdda00504
--- /dev/null
+++ b/sc/qa/unit/data/contentCSV/bugFix_Sheet2.csv
@@ -0,0 +1,6 @@
+success
+fail
+success
+fail
+success
+fail
diff --git a/sc/qa/unit/data/contentCSV/spreadsheet-functions.csv b/sc/qa/unit/data/contentCSV/spreadsheet-functions.csv
index da534337f3ed..83a33b299820 100644
--- a/sc/qa/unit/data/contentCSV/spreadsheet-functions.csv
+++ b/sc/qa/unit/data/contentCSV/spreadsheet-functions.csv
@@ -1,4 +1,4 @@
$C$2, $A$1, Sheet.B$2, Sheet!R2C2
-2, 4, 4, 5, 6, 15, 15, 6
+2, 4, 4, 5, 6, 15, 15, 6, 9
1, 3, 4, 4, 2, 2
-2, 4, 7, 8
+2, 4, 7, 8, 4
diff --git a/sc/qa/unit/data/ods/bug-fixes.ods b/sc/qa/unit/data/ods/bug-fixes.ods
index dcdbd69e66c7..686423527107 100644
--- a/sc/qa/unit/data/ods/bug-fixes.ods
+++ b/sc/qa/unit/data/ods/bug-fixes.ods
Binary files differ
diff --git a/sc/qa/unit/data/ods/functions.ods b/sc/qa/unit/data/ods/functions.ods
index 231747370137..cfdd26351808 100644
--- a/sc/qa/unit/data/ods/functions.ods
+++ b/sc/qa/unit/data/ods/functions.ods
Binary files differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 059ef174f988..74a90065201a 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -599,7 +599,11 @@ void ScFiltersTest::testBugFixesODS()
CPPUNIT_ASSERT_MESSAGE("Failed to load bugFixes.ods", xDocSh.Is());
ScDocument* pDoc = xDocSh->GetDocument();
- CPPUNIT_ASSERT_MESSAGE("No Document", pDoc); //remove with first test
+
+ rtl::OUString aCSVFileName;
+ createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bugFix_Sheet2.")), aCSVFileName);
+ testFile(aCSVFileName, pDoc, 1);
+
xDocSh->DoClose();
}
diff --git a/sc/qa/unit/macros-test.cxx b/sc/qa/unit/macros-test.cxx
index aff5bc537e28..22faa26cf915 100644
--- a/sc/qa/unit/macros-test.cxx
+++ b/sc/qa/unit/macros-test.cxx
@@ -126,7 +126,6 @@ public:
void testStarBasic();
void testVba();
CPPUNIT_TEST_SUITE(ScMacrosTest);
-#if 0
#ifndef MACOSX
//enable this test if you want to play with star basic macros in unit tests
//works but does nothing useful yet
@@ -135,7 +134,6 @@ public:
//does not work, still problems during loading
CPPUNIT_TEST(testVba);
#endif
-#endif
CPPUNIT_TEST_SUITE_END();
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 21db934c46e4..a19e300da250 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -127,6 +127,7 @@ public:
void testSheetCopy();
void testSheetMove();
void testExternalRef();
+ void testExternalRefFunctions();
void testDataArea();
void testAutofilter();
void testCopyPaste();
@@ -169,6 +170,7 @@ public:
CPPUNIT_TEST(testSheetCopy);
CPPUNIT_TEST(testSheetMove);
CPPUNIT_TEST(testExternalRef);
+ CPPUNIT_TEST(testExternalRefFunctions);
CPPUNIT_TEST(testDataArea);
CPPUNIT_TEST(testGraphicsInGroup);
CPPUNIT_TEST(testStreamValid);
@@ -638,6 +640,24 @@ void Test::testMatrix()
pMat->And() && pMat->Or());
}
+ // Test the AND and OR evaluations.
+ for (int i = 0; i < 2; ++i)
+ {
+ pMat = new ScMatrix(2, 2, eDT[i]);
+
+ // Only some of the elements are non-zero.
+ pMat->PutBoolean(true, 0, 0);
+ pMat->PutDouble(1.0, 1, 1);
+ CPPUNIT_ASSERT_MESSAGE("incorrect OR result", pMat->Or());
+ CPPUNIT_ASSERT_MESSAGE("incorrect AND result", !pMat->And());
+
+ // All of the elements are non-zero.
+ pMat->PutBoolean(true, 0, 1);
+ pMat->PutDouble(2.3, 1, 0);
+ CPPUNIT_ASSERT_MESSAGE("incorrect OR result", pMat->Or());
+ CPPUNIT_ASSERT_MESSAGE("incorrect AND result", pMat->And());
+ }
+
// Now test the emtpy matrix types.
eDT[0] = ScMatrix::FILLED_EMPTY;
eDT[1] = ScMatrix::SPARSE_EMPTY;
@@ -1498,6 +1518,60 @@ void Test::testExternalRef()
m_pDoc->DeleteTab(0);
}
+void Test::testExternalRefFunctions()
+{
+ ScDocShellRef xExtDocSh = new ScDocShell;
+ OUString aExtDocName(RTL_CONSTASCII_USTRINGPARAM("file:///extdata.fake"));
+ SfxMedium* pMed = new SfxMedium(aExtDocName, STREAM_STD_READWRITE);
+ xExtDocSh->DoInitNew(pMed);
+ CPPUNIT_ASSERT_MESSAGE("external document instance not loaded.",
+ findLoadedDocShellByName(aExtDocName) != NULL);
+
+ // Populate the external source document.
+ ScDocument* pExtDoc = xExtDocSh->GetDocument();
+ pExtDoc->InsertTab(0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data")));
+ double val = 1;
+ pExtDoc->SetValue(0, 0, 0, val);
+ // leave cell B1 empty.
+ val = 2;
+ pExtDoc->SetValue(0, 1, 0, val);
+ pExtDoc->SetValue(1, 1, 0, val);
+ val = 3;
+ pExtDoc->SetValue(0, 2, 0, val);
+ pExtDoc->SetValue(1, 2, 0, val);
+ val = 4;
+ pExtDoc->SetValue(0, 3, 0, val);
+ pExtDoc->SetValue(1, 3, 0, val);
+
+ m_pDoc->InsertTab(0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Test")));
+
+ struct {
+ const char* pFormula; double fResult;
+ } aChecks[] = {
+ { "=SUM('file:///extdata.fake'#Data.A1:A4)", 10 },
+ { "=SUM('file:///extdata.fake'#Data.B1:B4)", 9 },
+ { "=AVERAGE('file:///extdata.fake'#Data.A1:A4)", 2.5 },
+ { "=AVERAGE('file:///extdata.fake'#Data.B1:B4)", 3 },
+ { "=COUNT('file:///extdata.fake'#Data.A1:A4)", 4 },
+ { "=COUNT('file:///extdata.fake'#Data.B1:B4)", 3 }
+ };
+
+ for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
+ {
+ m_pDoc->SetString(0, 0, 0, rtl::OUString::createFromAscii(aChecks[i].pFormula));
+ m_pDoc->CalcAll();
+ m_pDoc->GetValue(0, 0, 0, val);
+ CPPUNIT_ASSERT_MESSAGE("unexpected result involving external ranges.", val == aChecks[i].fResult);
+ }
+
+ // Unload the external document shell.
+ xExtDocSh->DoClose();
+ CPPUNIT_ASSERT_MESSAGE("external document instance should have been unloaded.",
+ findLoadedDocShellByName(aExtDocName) == NULL);
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testDataArea()
{
m_pDoc->InsertTab(0, OUString(RTL_CONSTASCII_USTRINGPARAM("Data")));
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index b9526d31f272..196bc17fae9b 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -401,6 +401,17 @@ void ScDocument::CreateValidTabNames(std::vector<rtl::OUString>& aNames, SCTAB n
}
}
+void ScDocument::AppendTabOnLoad(const rtl::OUString& rName)
+{
+ SCTAB nTabCount = static_cast<SCTAB>(maTabs.size());
+
+ if (ValidTab(nTabCount) && ValidNewTabName(rName))
+ {
+ maTabs.push_back( new ScTable(this, nTabCount, rName) );
+ maTabs[nTabCount]->SetCodeName( rName );
+ }
+}
+
sal_Bool ScDocument::InsertTab( SCTAB nPos, const String& rName,
sal_Bool bExternalDocument )
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 9470e76a0886..dea2c2896948 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -591,8 +591,10 @@ bool ScMatrixImpl::IsEmpty( SCSIZE nC, SCSIZE nR ) const
bool ScMatrixImpl::IsEmptyPath( SCSIZE nC, SCSIZE nR ) const
{
// 'Empty path' is empty plus non-zero flag.
- ValidColRowReplicated( nC, nR );
- return maMat.get_type(nR, nC) == ::mdds::element_empty && maMat.get_flag(nR, nC) != 0;
+ if (ValidColRowOrReplicated( nC, nR ))
+ return maMat.get_type(nR, nC) == ::mdds::element_empty && maMat.get_flag(nR, nC) != 0;
+ else
+ return true;
}
bool ScMatrixImpl::IsValue( SCSIZE nIndex ) const
@@ -732,7 +734,7 @@ bool EvalMatrix(const MatrixImplType& rMat)
for (size_t j = 0; j < nCols; ++j)
{
matrix_element_t eType = rMat.get_type(i, j);
- if (eType != mdds::element_numeric && eType == mdds::element_boolean)
+ if (eType != mdds::element_numeric && eType != mdds::element_boolean)
// assuming a CompareMat this is an error
return CreateDoubleError(errIllegalArgument);
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 7e6d98a97615..3beef270d01d 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -2782,8 +2782,7 @@ public:
if ( nUnoType & sheet::NamedRangeFlag::COLUMN_HEADER ) nNewType |= RT_COLHEADER;
if ( nUnoType & sheet::NamedRangeFlag::ROW_HEADER ) nNewType |= RT_ROWHEADER;
-
- if (mpDoc && !mrRangeName.findByName(r.sName))
+ if (mpDoc)
{
// Insert a new name.
ScAddress aPos;
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index 12d9cad96c88..04f9a8e5daac 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -192,22 +192,8 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString&
{
if (nCurrentSheet > 0)
{
- try
- {
- xSheets->insertNewByName(sTableName, nCurrentSheet);
- }
- catch ( uno::RuntimeException& )
- {
- ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel());
- if (pDoc)
- {
- ScXMLImport::MutexGuard aGuard(rImport);
- String sTabName(String::CreateFromAscii("Table"));
- pDoc->CreateValidTabName(sTabName);
- rtl::OUString sOUTabName(sTabName);
- xSheets->insertNewByName(sOUTabName, nCurrentSheet);
- }
- }
+ ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel());
+ pDoc->AppendTabOnLoad(sTableName);
}
uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY );
if ( xIndex.is() )
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index c80653193daf..408feb6d6fb5 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1412,8 +1412,8 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange&
pUsedRange.reset(new ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0));
ScMatrixRef xMat = new ScMatrix(
- static_cast<SCSIZE>(nDataCol2-nDataCol1+1),
- static_cast<SCSIZE>(nDataRow2-nDataRow1+1));
+ static_cast<SCSIZE>(nCol2-nCol1+1),
+ static_cast<SCSIZE>(nRow2-nRow1+1), ScMatrix::SPARSE_EMPTY);
for (SCCOL nCol = nDataCol1; nCol <= nDataCol2; ++nCol)
{
@@ -1423,53 +1423,52 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange&
ScBaseCell* pCell;
pSrcDoc->GetCell(nCol, nRow, nTab, pCell);
if (!pCell || pCell->HasEmptyData())
- xMat->PutEmpty(nC, nR);
- else
+ // Skip empty cells. Matrix's default values are empty elements.
+ continue;
+
+ switch (pCell->GetCellType())
{
- switch (pCell->GetCellType())
+ case CELLTYPE_EDIT:
+ {
+ String aStr;
+ static_cast<ScEditCell*>(pCell)->GetString(aStr);
+ xMat->PutString(aStr, nC, nR);
+ }
+ break;
+ case CELLTYPE_STRING:
+ {
+ String aStr;
+ static_cast<ScStringCell*>(pCell)->GetString(aStr);
+ xMat->PutString(aStr, nC, nR);
+ }
+ break;
+ case CELLTYPE_VALUE:
+ {
+ double fVal = static_cast<ScValueCell*>(pCell)->GetValue();
+ xMat->PutDouble(fVal, nC, nR);
+ }
+ break;
+ case CELLTYPE_FORMULA:
{
- case CELLTYPE_EDIT:
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ sal_uInt16 nError = pFCell->GetErrCode();
+ if (nError)
+ xMat->PutDouble( CreateDoubleError( nError), nC, nR);
+ else if (pFCell->IsValue())
{
- String aStr;
- static_cast<ScEditCell*>(pCell)->GetString(aStr);
- xMat->PutString(aStr, nC, nR);
+ double fVal = pFCell->GetValue();
+ xMat->PutDouble(fVal, nC, nR);
}
- break;
- case CELLTYPE_STRING:
+ else
{
String aStr;
- static_cast<ScStringCell*>(pCell)->GetString(aStr);
+ pFCell->GetString(aStr);
xMat->PutString(aStr, nC, nR);
}
- break;
- case CELLTYPE_VALUE:
- {
- double fVal = static_cast<ScValueCell*>(pCell)->GetValue();
- xMat->PutDouble(fVal, nC, nR);
- }
- break;
- case CELLTYPE_FORMULA:
- {
- ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
- sal_uInt16 nError = pFCell->GetErrCode();
- if (nError)
- xMat->PutDouble( CreateDoubleError( nError), nC, nR);
- else if (pFCell->IsValue())
- {
- double fVal = pFCell->GetValue();
- xMat->PutDouble(fVal, nC, nR);
- }
- else
- {
- String aStr;
- pFCell->GetString(aStr);
- xMat->PutString(aStr, nC, nR);
- }
- }
- break;
- default:
- OSL_FAIL("attempted to convert an unknown cell type.");
}
+ break;
+ default:
+ OSL_FAIL("attempted to convert an unknown cell type.");
}
}
}
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index de2d683d4ad0..fdb0b923bfd9 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1511,7 +1511,6 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa
// Fenster findet (wird aus SetCursor gerufen)
UpdateShow();
aViewData.ResetOldCursor();
- SetCursor( aViewData.GetCurX(), aViewData.GetCurY(), true );
SfxBindings& rBindings = aViewData.GetBindings();
ScMarkData& rMark = aViewData.GetMarkData();
@@ -1548,6 +1547,7 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa
rBindings.Invalidate( FID_TAB_DESELECTALL );
}
+ SetCursor( aViewData.GetCurX(), aViewData.GetCurY(), true );
bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
// recalc zoom-dependent values (before TabChanged, before UpdateEditViewPos)