[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - 2 commits - include/test sc/qa sc/source test/source
Laurent Godard
lgodard.libre at laposte.net
Wed Dec 18 03:42:52 PST 2013
include/test/sheet/xsheetannotations.hxx | 3 ++-
sc/qa/extras/scannotationsobj.cxx | 12 ++++++------
sc/source/core/data/document.cxx | 2 +-
sc/source/ui/unoobj/docuno.cxx | 7 +++++--
test/source/sheet/xsheetannotations.cxx | 24 ++++++++++++++++++++++++
5 files changed, 38 insertions(+), 10 deletions(-)
New commits:
commit 2279208fa0570ef5fa2d49c14a721b7d59be069d
Author: Laurent Godard <lgodard.libre at laposte.net>
Date: Fri Dec 6 12:36:41 2013 +0100
count notes - GetNotesInRange now include last tab
- refactor tests
- add unit test on counting notes on a sheet
Change-Id: I6762a0e791a745b828800645effdfc044ac33710
Reviewed-on: https://gerrit.libreoffice.org/6954
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/include/test/sheet/xsheetannotations.hxx b/include/test/sheet/xsheetannotations.hxx
index 24e1dd5..403af94 100644
--- a/include/test/sheet/xsheetannotations.hxx
+++ b/include/test/sheet/xsheetannotations.hxx
@@ -20,11 +20,12 @@ public:
// XSheetAnnotations
void testInsertNew();
void testRemoveByIndex();
+ void testCount();
protected:
~XSheetAnnotations() {}
- virtual css::uno::Reference< css::sheet::XSheetAnnotations> getAnnotations() = 0;
+ virtual css::uno::Reference< css::sheet::XSheetAnnotations> getAnnotations(long nIndex) = 0;
};
}
diff --git a/sc/qa/extras/scannotationsobj.cxx b/sc/qa/extras/scannotationsobj.cxx
index 485173c..190efe5 100644
--- a/sc/qa/extras/scannotationsobj.cxx
+++ b/sc/qa/extras/scannotationsobj.cxx
@@ -20,7 +20,7 @@ using namespace css::uno;
namespace sc_apitest {
-#define NUMBER_OF_TESTS 2
+#define NUMBER_OF_TESTS 3
class ScAnnontationsObj : public CalcUnoApiTest, apitest::XSheetAnnotations
{
@@ -31,11 +31,12 @@ public:
virtual void tearDown();
virtual uno::Reference< uno::XInterface > init();
- virtual uno::Reference< sheet::XSheetAnnotations> getAnnotations();
+ virtual uno::Reference< sheet::XSheetAnnotations > getAnnotations(long nIndex);
CPPUNIT_TEST_SUITE(ScAnnontationsObj);
CPPUNIT_TEST(testInsertNew);
CPPUNIT_TEST(testRemoveByIndex);
+ CPPUNIT_TEST(testCount);
CPPUNIT_TEST_SUITE_END();
private:
@@ -51,12 +52,12 @@ ScAnnontationsObj::ScAnnontationsObj()
{
}
-uno::Reference< sheet::XSheetAnnotations> ScAnnontationsObj::getAnnotations()
+uno::Reference< sheet::XSheetAnnotations> ScAnnontationsObj::getAnnotations(long nIndex)
{
// get the sheet
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
- uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(nIndex), UNO_QUERY_THROW);
// get the annotations collection
uno::Reference< sheet::XSheetAnnotationsSupplier > xAnnotationSupplier(xSheet, UNO_QUERY_THROW);
@@ -76,9 +77,8 @@ uno::Reference< uno::XInterface > ScAnnontationsObj::init()
mxComponent = loadFromDesktop(aFileURL);
CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxComponent.is());
- return getAnnotations();
+ return getAnnotations(0);
}
-
void ScAnnontationsObj::setUp()
{
nTest++;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 8048d02..1bd256e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6240,7 +6240,7 @@ void ScDocument::GetNotesInRange( const ScRangeList& rRange, std::vector<sc::Not
for( size_t i = 0; i < rRange.size(); ++i)
{
const ScRange* pRange = rRange[i];
- for( SCTAB nTab = pRange->aStart.Tab(); nTab < pRange->aEnd.Tab(); ++nTab )
+ for( SCTAB nTab = pRange->aStart.Tab(); nTab <= pRange->aEnd.Tab(); ++nTab )
{
maTabs[nTab]->GetNotesInRange( *pRange, rNotes );
}
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 0d39c5e..8cbd9fb 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -3611,7 +3611,7 @@ uno::Reference<container::XEnumeration> SAL_CALL ScAnnotationsObj::createEnumera
sal_Int32 SAL_CALL ScAnnotationsObj::getCount() throw(uno::RuntimeException)
{
SolarMutexGuard aGuard;
- sal_uLong nCount = 0;
+ sal_Int32 nCount = 0;
if (pDocShell)
{
ScDocument* pDoc = pDocShell->GetDocument();
diff --git a/test/source/sheet/xsheetannotations.cxx b/test/source/sheet/xsheetannotations.cxx
index 6671593..a56fc6b 100644
--- a/test/source/sheet/xsheetannotations.cxx
+++ b/test/source/sheet/xsheetannotations.cxx
@@ -22,6 +22,27 @@ using namespace css::uno;
namespace apitest {
+void XSheetAnnotations::testCount()
+{
+ uno::Reference< sheet::XSheetAnnotations > aSheetAnnotations (init(), UNO_QUERY_THROW);
+
+ // count on sheet 1 before inserting
+ uno::Reference< container::XIndexAccess > xAnnotationsIndex (aSheetAnnotations, UNO_QUERY_THROW);
+ sal_Int32 nBefore = xAnnotationsIndex->getCount();
+
+ // get Sheet 2 annotations
+ uno::Reference< sheet::XSheetAnnotations > xSheet2Annotations( getAnnotations(1), UNO_QUERY_THROW);
+
+ // insert a note on sheet 2
+ table::CellAddress xTargetCellAddress (1,0,0);
+ xSheet2Annotations->insertNew(xTargetCellAddress, "an inserted annotation on sheet 2");
+
+ // count again on sheet 1
+ sal_Int32 nAfter = xAnnotationsIndex->getCount();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Annotations count should not change on sheet 1", nBefore, nAfter);
+}
+
void XSheetAnnotations::testInsertNew()
{
uno::Reference< sheet::XSheetAnnotations > aSheetAnnotations (init(), UNO_QUERY_THROW);
@@ -30,6 +51,9 @@ void XSheetAnnotations::testInsertNew()
uno::Reference< container::XIndexAccess > xAnnotationsIndex (aSheetAnnotations, UNO_QUERY_THROW);
sal_Int32 nBefore = xAnnotationsIndex->getCount();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "There should already be one note", 1, nBefore );
+
// insert the annotation
table::CellAddress xTargetCellAddress (0,3,4);
aSheetAnnotations->insertNew(xTargetCellAddress, "an inserted annotation");
commit 30b34a5dfde0a976c611b32ae1058412395f5bf3
Author: Laurent Godard <lgodard.libre at laposte.net>
Date: Thu Dec 5 12:04:31 2013 +0100
counting notes is per table, not on the whole document
Change-Id: Id4afa4eee961f159f8ea8caeac620d101cfb103e
Reviewed-on: https://gerrit.libreoffice.org/6941
Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 2b4d3e2..0d39c5e 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -3615,7 +3615,10 @@ sal_Int32 SAL_CALL ScAnnotationsObj::getCount() throw(uno::RuntimeException)
if (pDocShell)
{
ScDocument* pDoc = pDocShell->GetDocument();
- nCount = pDoc->CountNotes();
+ const ScRangeList aRangeList( ScRange( 0, 0, nTab, MAXCOL, MAXROW, nTab) );
+ std::vector<sc::NoteEntry> rNotes;
+ pDoc->GetNotesInRange(aRangeList, rNotes);
+ nCount = rNotes.size();
}
return nCount;
}
More information about the Libreoffice-commits
mailing list