[Libreoffice-commits] .: sc/inc sc/qa sc/source

2012-01-11 Thread Kohei Yoshida
 sc/inc/dpobject.hxx  |1 
 sc/qa/unit/ucalc.cxx |  133 +++
 sc/source/core/data/dpobject.cxx |6 +
 3 files changed, 127 insertions(+), 13 deletions(-)

New commits:
commit 6a14a5826b9c041d9e3e0878c4a0ecfb46ce
Author: Kohei Yoshida kohei.yosh...@suse.com
Date:   Wed Jan 11 21:10:14 2012 -0500

New test for pivot tables with named source ranges.

diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index db8ea92..48e43eb 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -286,6 +286,7 @@ public:
 ScDocument* mpDoc;
 public:
 NameCaches(ScDocument* pDoc);
+const ScDPCache* getCache(const rtl::OUString rName) const;
 const ScDPCache* getCache(const ::rtl::OUString rName, const ScRange 
rRange);
 private:
 void removeCache(const ::rtl::OUString rName);
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index c843eb7..ac683a0 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -133,6 +133,12 @@ public:
  * Test for pivot table's filtering functionality by page fields.
  */
 void testDataPilotFilters();
+
+/**
+ * Test for pivot table's named source range.
+ */
+void testDataPilotNamedSource();
+
 void testSheetCopy();
 void testSheetMove();
 void testExternalRef();
@@ -185,6 +191,7 @@ public:
 CPPUNIT_TEST(testDataPilot);
 CPPUNIT_TEST(testDataPilotLabels);
 CPPUNIT_TEST(testDataPilotFilters);
+CPPUNIT_TEST(testDataPilotNamedSource);
 CPPUNIT_TEST(testSheetCopy);
 CPPUNIT_TEST(testSheetMove);
 CPPUNIT_TEST(testExternalRef);
@@ -1152,17 +1159,12 @@ bool checkDPTableOutput(ScDocument* pDoc, const 
ScRange aOutRange, const char*
 return true;
 }
 
-ScDPObject* createDPFromRange(
-ScDocument* pDoc, const ScRange rRange, DPFieldDef aFields[], size_t 
nFieldCount,
+ScDPObject* createDPFromSourceDesc(
+ScDocument* pDoc, const ScSheetSourceDesc rDesc, DPFieldDef aFields[], 
size_t nFieldCount,
 bool bFilterButton)
 {
-SCROW nRow1 = rRange.aStart.Row(), nRow2 = rRange.aEnd.Row();
-SCCOL nCol1 = rRange.aStart.Col();
-
-ScSheetSourceDesc aSheetDesc(pDoc);
-aSheetDesc.SetSourceRange(rRange);
 ScDPObject* pDPObj = new ScDPObject(pDoc);
-pDPObj-SetSheetDesc(aSheetDesc);
+pDPObj-SetSheetDesc(rDesc);
 pDPObj-SetOutRange(ScAddress(0, 0, 1));
 ScPivotParam aParam;
 pDPObj-FillOldParam(aParam);
@@ -1182,16 +1184,16 @@ ScDPObject* createDPFromRange(
 aSaveData.SetDrillDown(true);
 
 // Check the sanity of the source range.
-const ScRange rSrcRange = aSheetDesc.GetSourceRange();
-nCol1 = rSrcRange.aStart.Col();
-nRow1 = rSrcRange.aStart.Row();
-nRow2 = rSrcRange.aEnd.Row();
+const ScRange rSrcRange = rDesc.GetSourceRange();
+SCCOL nCol1 = rSrcRange.aStart.Col();
+SCROW nRow1 = rSrcRange.aStart.Row();
+SCROW nRow2 = rSrcRange.aEnd.Row();
 CPPUNIT_ASSERT_MESSAGE(source range contains no data!, nRow2 - nRow1  
1);
 
 // Set the dimension information.
 for (size_t i = 0; i  nFieldCount; ++i)
 {
-OUString aDimName = pDoc-GetString(nCol1+i, nRow1, 
rRange.aStart.Tab());
+OUString aDimName = pDoc-GetString(nCol1+i, nRow1, 
rSrcRange.aStart.Tab());
 ScDPSaveDimension* pDim = aSaveData.GetDimensionByName(aDimName);
 pDim-SetOrientation(static_castsal_uInt16(aFields[i].eOrient));
 pDim-SetUsedHierarchy(0);
@@ -1247,6 +1249,15 @@ ScDPObject* createDPFromRange(
 return pDPObj;
 }
 
+ScDPObject* createDPFromRange(
+ScDocument* pDoc, const ScRange rRange, DPFieldDef aFields[], size_t 
nFieldCount,
+bool bFilterButton)
+{
+ScSheetSourceDesc aSheetDesc(pDoc);
+aSheetDesc.SetSourceRange(rRange);
+return createDPFromSourceDesc(pDoc, aSheetDesc, aFields, nFieldCount, 
bFilterButton);
+}
+
 }
 
 void Test::testDataPilot()
@@ -1573,6 +1584,102 @@ void Test::testDataPilotFilters()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testDataPilotNamedSource()
+{
+m_pDoc-InsertTab(0, OUString(RTL_CONSTASCII_USTRINGPARAM(Data)));
+m_pDoc-InsertTab(1, OUString(RTL_CONSTASCII_USTRINGPARAM(Table)));
+
+// Dimension definition
+DPFieldDef aFields[] = {
+{ Name,  sheet::DataPilotFieldOrientation_ROW },
+{ Group, sheet::DataPilotFieldOrientation_COLUMN },
+{ Score, sheet::DataPilotFieldOrientation_DATA }
+};
+
+// Raw data
+const char* aData[][3] = {
+{ Andy,A, 30 },
+{ Bruce,   A, 20 },
+{ Charlie, B, 45 },
+{ David,   B, 12 },
+{ Edward,  C,  8 },
+{ Frank,   C, 15 },
+};
+
+size_t nFieldCount = SAL_N_ELEMENTS(aFields);
+size_t nDataCount = SAL_N_ELEMENTS(aData);
+
+// Insert the raw data.
+ScRange aSrcRange = insertDPSourceData(m_pDoc, aFields, nFieldCount, 
aData, nDataCount);
+rtl::OUString aRangeStr;
+aSrcRange.Format(aRangeStr, SCR_ABS_3D, 

[Libreoffice-commits] .: sc/inc sc/qa sc/source

2012-01-11 Thread Kohei Yoshida
 sc/inc/dpobject.hxx  |3 ++-
 sc/qa/unit/ucalc.cxx |   12 +++-
 sc/source/core/data/dpobject.cxx |   17 ++---
 3 files changed, 27 insertions(+), 5 deletions(-)

New commits:
commit ca73d85cc813a2a95fbbba35be6de6dc5ff2967f
Author: Kohei Yoshida kohei.yosh...@suse.com
Date:   Wed Jan 11 22:00:50 2012 -0500

Test code for sheet source data cache relocation.

diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 48e43eb..dc20944 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -266,6 +266,7 @@ public:
 ScDocument* mpDoc;
 public:
 SheetCaches(ScDocument* pDoc);
+bool hasCache(const ScRange rRange) const;
 const ScDPCache* getCache(const ScRange rRange);
 
 void updateReference(
@@ -286,7 +287,7 @@ public:
 ScDocument* mpDoc;
 public:
 NameCaches(ScDocument* pDoc);
-const ScDPCache* getCache(const rtl::OUString rName) const;
+bool hasCache(const rtl::OUString rName) const;
 const ScDPCache* getCache(const ::rtl::OUString rName, const ScRange 
rRange);
 private:
 void removeCache(const ::rtl::OUString rName);
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ac683a0..b9e3013 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1386,6 +1386,16 @@ void Test::testDataPilot()
 CPPUNIT_ASSERT_MESSAGE(Table output check failed, bSuccess);
 }
 
+CPPUNIT_ASSERT_MESSAGE(Cache should be here., 
pDPs-GetSheetCaches().hasCache(aSrcRange));
+
+// Swap the two sheets.
+m_pDoc-MoveTab(1, 0);
+CPPUNIT_ASSERT_MESSAGE(Cache should have moved., 
!pDPs-GetSheetCaches().hasCache(aSrcRange));
+aSrcRange.aStart.SetTab(1);
+aSrcRange.aEnd.SetTab(1);
+CPPUNIT_ASSERT_MESSAGE(Cache should be here., 
pDPs-GetSheetCaches().hasCache(aSrcRange));
+
+
 pDPs-FreeTable(pDPObj2);
 CPPUNIT_ASSERT_MESSAGE(There shouldn't be any data pilot table stored 
with the document.,
pDPs-GetCount() == 0);
@@ -1671,7 +1681,7 @@ void Test::testDataPilotNamedSource()
 CPPUNIT_ASSERT_MESSAGE(Named source range has been altered unexpectedly!,
pDesc-GetRangeName().equals(aRangeName));
 
-CPPUNIT_ASSERT_MESSAGE(Cache should exist., 
pDPs-GetNameCaches().getCache(aRangeName) != NULL);
+CPPUNIT_ASSERT_MESSAGE(Cache should exist., 
pDPs-GetNameCaches().hasCache(aRangeName));
 pDPs-FreeTable(pDPObj);
 CPPUNIT_ASSERT_MESSAGE(There should be no more tables., pDPs-GetCount() 
== 0);
 
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index d384cd9..063c02a 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2471,6 +2471,18 @@ struct FindInvalidRange : public 
std::unary_functionScRange, bool
 
 }
 
+bool ScDPCollection::SheetCaches::hasCache(const ScRange rRange) const
+{
+RangeIndexType::const_iterator it = std::find(maRanges.begin(), 
maRanges.end(), rRange);
+if (it == maRanges.end())
+return false;
+
+// Already cached.
+size_t nIndex = std::distance(maRanges.begin(), it);
+CachesType::const_iterator itCache = maCaches.find(nIndex);
+return itCache != maCaches.end();
+}
+
 const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange rRange)
 {
 RangeIndexType::iterator it = std::find(maRanges.begin(), maRanges.end(), 
rRange);
@@ -2565,10 +2577,9 @@ void ScDPCollection::SheetCaches::removeCache(const 
ScRange rRange)
 
 ScDPCollection::NameCaches::NameCaches(ScDocument* pDoc) : mpDoc(pDoc) {}
 
-const ScDPCache* ScDPCollection::NameCaches::getCache(const OUString rName) 
const
+bool ScDPCollection::NameCaches::hasCache(const OUString rName) const
 {
-CachesType::const_iterator itr = maCaches.find(rName);
-return itr != maCaches.end() ? itr-second : NULL;
+return maCaches.count(rName) != 0;
 }
 
 const ScDPCache* ScDPCollection::NameCaches::getCache(const OUString rName, 
const ScRange rRange)
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: sc/inc sc/qa sc/source

2011-11-23 Thread Kohei Yoshida
 sc/inc/table.hxx  |   35 +++
 sc/qa/unit/ucalc.cxx  |1 +
 sc/source/core/data/cell.cxx  |2 ++
 sc/source/core/data/table1.cxx|1 +
 sc/source/core/data/table2.cxx|1 +
 sc/source/ui/vba/vbaworksheet.cxx |1 +
 6 files changed, 21 insertions(+), 20 deletions(-)

New commits:
commit 92e03b82880ab1c83a1bfd59e179e3fb9f565257
Author: Kohei Yoshida kohei.yosh...@suse.com
Date:   Wed Nov 23 23:34:18 2011 -0500

Cleaned up the ScTable declaration a bit.

* make it officially non-copyable. It was never copied anyway.
* retire std::auto_ptr which is deprecated.  Let's use boost::scoped_ptr.
* some unused typedef's.

diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 906d306..af57e62 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -30,7 +30,6 @@
 #define SC_TABLE_HXX
 
 #include vector
-#include memory
 #include utility
 #include tools/gen.hxx
 #include tools/color.hxx
@@ -38,11 +37,10 @@
 #include column.hxx
 #include sortparam.hxx
 #include compressedarray.hxx
-#include dbdata.hxx
 
-#include memory
 #include set
-#include boost/shared_ptr.hpp
+#include boost/scoped_ptr.hpp
+#include boost/noncopyable.hpp
 
 namespace utl {
 class TextSearch;
@@ -89,28 +87,25 @@ struct ScSetStringParam;
 struct ScColWidthParam;
 struct ScColWidthParam;
 class ScRangeName;
+class ScDBData;
 
-typedef boost::unordered_map ::rtl::OUString, rtl::OUString, 
::rtl::OUStringHash, ::std::equal_to ::rtl::OUString   NameToNameMap;
-
-class ScTable
+class ScTable : boost::noncopyable
 {
 private:
 typedef ::std::vector ScRange  ScRangeVec;
 typedef ::std::pair SCCOL, SCROW  ScAddress2D;
 typedef ::std::vector ScAddress2D  ScAddress2DVec;
-typedef ::std::auto_ptr ScAddress2DVec  ScAddress2DVecPtr;
 
-//  data per table
 ScColumnaCol[MAXCOLCOUNT];
 
 rtl::OUString aName;
 rtl::OUString aCodeName;
 rtl::OUString aComment;
 
-rtl::OUString  aLinkDoc;
-rtl::OUString  aLinkFlt;
-rtl::OUString  aLinkOpt;
-rtl::OUString  aLinkTab;
+rtl::OUString   aLinkDoc;
+rtl::OUString   aLinkFlt;
+rtl::OUString   aLinkOpt;
+rtl::OUString   aLinkTab;
 sal_uLong   nLinkRefreshDelay;
 sal_uInt8   nLinkMode;
 
@@ -122,17 +117,17 @@ private:
 SCROW   nRepeatStartY;
 SCROW   nRepeatEndY;
 
-::std::auto_ptrScTableProtection pTabProtection;
+boost::scoped_ptrScTableProtection pTabProtection;
 
 sal_uInt16* pColWidth;
-::boost::shared_ptrScFlatUInt16RowSegments mpRowHeights;
+boost::scoped_ptrScFlatUInt16RowSegments mpRowHeights;
 
 sal_uInt8*  pColFlags;
 ScBitMaskCompressedArray SCROW, sal_uInt8* pRowFlags;
-::boost::shared_ptrScFlatBoolColSegments  mpHiddenCols;
-::boost::shared_ptrScFlatBoolRowSegments  mpHiddenRows;
-::boost::shared_ptrScFlatBoolColSegments  mpFilteredCols;
-::boost::shared_ptrScFlatBoolRowSegments  mpFilteredRows;
+boost::scoped_ptrScFlatBoolColSegments  mpHiddenCols;
+boost::scoped_ptrScFlatBoolRowSegments  mpHiddenRows;
+boost::scoped_ptrScFlatBoolColSegments  mpFilteredCols;
+boost::scoped_ptrScFlatBoolRowSegments  mpFilteredRows;
 
 ::std::setSCROW  maRowPageBreaks;
 ::std::setSCROW  maRowManualBreaks;
@@ -153,7 +148,7 @@ private:
 
 mutable rtl::OUString aUpperName; // #i62977# filled only on 
demand, reset in SetName
 
-ScAddress2DVecPtr mxUninitNotes;
+boost::scoped_ptrScAddress2DVec mxUninitNotes;
 
 // sort parameter to minimize stack size of quicksort
 ScSortParam aSortParam;
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 9b0cbcc..21914d9 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -46,6 +46,7 @@
 #include queryentry.hxx
 #include postit.hxx
 #include attrib.hxx
+#include dbdata.hxx
 
 #include docsh.hxx
 #include docfunc.hxx
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 88fcbfd..9267133 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -53,6 +53,8 @@
 #include postit.hxx
 #include externalrefmgr.hxx
 #include macromgr.hxx
+#include dbdata.hxx
+
 #include editeng/editobj.hxx
 #include svl/intitem.hxx
 #include editeng/flditem.hxx
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 0505da7..e88fba6 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -55,6 +55,7 @@
 #include tabprotection.hxx
 #include sheetevents.hxx
 #include segmenttree.hxx
+#include dbdata.hxx
 
 #include vector
 
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index beb638b..75b5c44 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -62,6 +62,7 @@
 #include