[Libreoffice-commits] .: Branch 'feature/dp-named-range-source' - sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Jan 21 11:45:39 PST 2011
sc/inc/dpshttab.hxx | 11 ++++++++++-
sc/source/core/data/dpobject.cxx | 10 ++++++----
sc/source/core/data/dpshttab.cxx | 33 ++++++++++++++-------------------
3 files changed, 30 insertions(+), 24 deletions(-)
New commits:
commit cb3527334ebdb0f5d8b265a7335f17f37902d04b
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri Jan 21 14:45:11 2011 -0500
renamed CheckValidate() to CheckSourceRange(), and cleaned it up.
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index 105a237..4b2d4df 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -65,7 +65,16 @@ struct ScSheetSourceDesc
bool operator== ( const ScSheetSourceDesc& rOther ) const;
ScDPTableDataCache* CreateCache( ScDocument* pDoc, long nID = -1) const;
- ULONG CheckValidate( ScDocument* pDoc ) const;
+
+ /**
+ * Check the sanity of the data source range.
+ *
+ * @param pDoc document instance.
+ *
+ * @return 0 if the source range is sane, otherwise an error message ID is
+ * returned.
+ */
+ ULONG CheckSourceRange( ScDocument* pDoc ) const;
ScDPTableDataCache* GetCache( ScDocument* pDoc, long nID ) const;
ScDPTableDataCache* GetExistDPObjectCache ( ScDocument* pDoc ) const;
long GetCacheId( ScDocument* pDoc, long nID ) const;
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 5e1a43f..d5d7a3a 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2580,16 +2580,18 @@ ULONG ScDPObject::RefreshCache()
CreateObjects();
ULONG nErrId = 0;
if ( pSheetDesc)
- nErrId = pSheetDesc->CheckValidate( pDoc );
+ nErrId = pSheetDesc->CheckSourceRange( pDoc );
if ( nErrId == 0 )
{
+ // First remove the old cache if exists.
ScDPCollection* pDPCollection = pDoc->GetDPCollection();
long nOldId = GetCacheId();
long nNewId = pDPCollection->GetNewDPObjectCacheId();
if ( nOldId >= 0 )
pDPCollection->RemoveDPObjectCache( nOldId );
- ScDPTableDataCache* pCache = NULL;
+ // Create a new cache.
+ ScDPTableDataCache* pCache = NULL;
if ( pSheetDesc )
pCache = pSheetDesc->CreateCache( pDoc, nNewId );
else if ( pImpDesc )
@@ -2598,7 +2600,7 @@ ULONG ScDPObject::RefreshCache()
if ( pCache == NULL )
{
//cache failed
- DBG_ASSERT( pCache , " pCache == NULL" );
+ DBG_ASSERT( pCache , "pCache == NULL" );
return STR_ERR_DATAPILOTSOURCE;
}
@@ -2608,7 +2610,7 @@ ULONG ScDPObject::RefreshCache()
size_t nCount = pDPCollection->GetCount();
for (size_t i=0; i<nCount; ++i)
{ //set new cache id
- if ( (*pDPCollection)[i]->GetCacheId() == nOldId )
+ if ( (*pDPCollection)[i]->GetCacheId() == nOldId )
{
(*pDPCollection)[i]->SetCacheId( nNewId );
(*pDPCollection)[i]->SetRefresh();
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 0e9a57e..dbb6cd2 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -279,7 +279,7 @@ ScDPTableDataCache* ScSheetSourceDesc::CreateCache( ScDocument* pDoc , long nID
if ( pCache && ( nID < 0 || nID == pCache->GetId() ) )
return pCache;
- ULONG nErrId = CheckValidate( pDoc );
+ ULONG nErrId = CheckSourceRange( pDoc );
if ( !nErrId )
{
pCache = new ScDPTableDataCache( pDoc );
@@ -301,6 +301,7 @@ ScDPTableDataCache* ScSheetSourceDesc::GetExistDPObjectCache ( ScDocument* pDoc
{
return pDoc->GetDPCollection()->GetUsedDPObjectCache( aSourceRange );
}
+
ScDPTableDataCache* ScSheetSourceDesc::GetCache( ScDocument* pDoc, long nID ) const
{
ScDPTableDataCache* pCache = pDoc->GetDPCollection()->GetDPObjectCache( nID );
@@ -320,30 +321,24 @@ long ScSheetSourceDesc:: GetCacheId( ScDocument* pDoc, long nID ) const
return pCache->GetId();
}
-ULONG ScSheetSourceDesc::CheckValidate( ScDocument* pDoc ) const
+ULONG ScSheetSourceDesc::CheckSourceRange( ScDocument* pDoc ) const
{
- ScRange aSrcRange( aSourceRange);
- if ( !pDoc )
+ const ScRange& aSrcRange = GetSourceRange();
+ if (!pDoc)
return STR_ERR_DATAPILOTSOURCE;
- for(USHORT i= aSrcRange.aStart.Col();i <= aSrcRange.aEnd.Col();i++)
+
+ const ScAddress& s = aSrcRange.aStart();
+ const ScAddress& e = aSrcRange.aEnd();
+ for (SCCOL nCol = aSrcRange.aStart.Col(); nCol <= e.Col(); ++nCol)
{
- if ( pDoc->IsBlockEmpty( aSrcRange.aStart.Tab(),
- i, aSrcRange.aStart.Row(),i, aSrcRange.aStart.Row()))
+ if (pDoc->IsBlockEmpty(s.Tab(), nCol, s.Row(), nCol, s.Row()))
return STR_PIVOT_FIRSTROWEMPTYERR;
}
- if( pDoc->IsBlockEmpty( aSrcRange.aStart.Tab(), aSrcRange.aStart.Col(), aSrcRange.aStart.Row()+1, aSrcRange.aEnd.Col(), aSrcRange.aEnd.Row() ) )
- {
- return STR_PIVOT_ONLYONEROWERR;
- }
- return 0;
-}
-
-// -----------------------------------------------------------------------
-
-
-
-
+ if (pDoc->IsBlockEmpty(s.Tab(), s.Col(), s.Row()+1, e.Col(), e.Row()))
+ return STR_PIVOT_ONLYONEROWERR;
+ return 0;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list