[Libreoffice-commits] .: Branch 'feature/dp-named-range-source' - 4 commits - sc/inc sc/qa sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Jan 21 14:42:11 PST 2011
sc/inc/dpshttab.hxx | 16 +++--
sc/qa/unit/ucalc.cxx | 2
sc/source/core/data/dpobject.cxx | 10 +--
sc/source/core/data/dpshttab.cxx | 109 ++++++++++++++++++++++++-------------
sc/source/filter/excel/xipivot.cxx | 2
sc/source/filter/xml/xmldpimp.cxx | 2
sc/source/ui/dbgui/pvlaydlg.cxx | 42 +++++++++-----
sc/source/ui/inc/pvlaydlg.hxx | 1
sc/source/ui/unoobj/dapiuno.cxx | 4 -
sc/source/ui/unoobj/datauno.cxx | 2
sc/source/ui/view/cellsh2.cxx | 2
sc/source/ui/view/gridwin2.cxx | 2
sc/source/ui/view/pivotsh.cxx | 2
13 files changed, 125 insertions(+), 71 deletions(-)
New commits:
commit 6e6f818ebace4f62a82d3db3b2a5e541c6159613
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri Jan 21 17:41:08 2011 -0500
Get source range from range name if exists.
Now the data pilot table calculates result from a range name if
it's there.
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index 19d009e..c0fe2bd 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -77,11 +77,11 @@ public:
*/
ULONG CheckSourceRange() const;
ScDPTableDataCache* GetCache(long nID) const;
- ScDPTableDataCache* GetExistDPObjectCache () const;
+ ScDPTableDataCache* GetExistDPObjectCache() const;
long GetCacheId(long nID) const;
private:
- ScRange maSourceRange;
+ mutable ScRange maSourceRange;
::rtl::OUString maRangeName;
ScQueryParam maQueryParam;
ScDocument* mpDoc;
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 83c0dff..73d7b18 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -45,6 +45,8 @@
#include "dpobject.hxx"
#include "globstr.hrc"
#include "dpglobal.hxx"
+#include "rangenam.hxx"
+
#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
#include <vector>
@@ -61,7 +63,7 @@ using ::std::hash_set;
// -----------------------------------------------------------------------
ScSheetDPData::ScSheetDPData( ScDocument* pD, const ScSheetSourceDesc& rDesc , long nCacheId) :
- ScDPTableData(pD, rDesc.GetCacheId(nCacheId) ), // DataPilot Migration - Cache&&Performance
+ ScDPTableData(pD, rDesc.GetCacheId(nCacheId) ),
aQuery ( rDesc.GetQueryParam() ),
pSpecial(NULL),
bIgnoreEmptyRows( FALSE ),
@@ -247,7 +249,28 @@ const ScRange& ScSheetSourceDesc::GetSourceRange() const
if (maRangeName.getLength())
{
// Obtain the source range from the range name first.
-
+ maSourceRange = ScRange();
+ ScRangeName* pRangeName = mpDoc->GetRangeName();
+ do
+ {
+ if (!pRangeName)
+ break;
+
+ OUString aUpper = ScGlobal::pCharClass->upper(maRangeName);
+ USHORT n;
+ if (!pRangeName->SearchNameUpper(aUpper, n))
+ break;
+
+ // range name found. Fow now, we only use the first token and
+ // ignore the rest.
+ ScRangeData* pData = (*pRangeName)[n];
+ ScRange aRange;
+ if (!pData->IsReference(aRange))
+ break;
+
+ maSourceRange = aRange;
+ }
+ while (false);
}
return maSourceRange;
}
@@ -306,7 +329,7 @@ ScDPTableDataCache* ScSheetSourceDesc::CreateCache(long nID) const
return pCache;
}
-ScDPTableDataCache* ScSheetSourceDesc::GetExistDPObjectCache () const
+ScDPTableDataCache* ScSheetSourceDesc::GetExistDPObjectCache() const
{
return mpDoc->GetDPCollection()->GetUsedDPObjectCache( GetSourceRange() );
}
commit 7c67b616852a806d296d9a5866eb4c74ddcd1f66
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri Jan 21 16:56:06 2011 -0500
Several of its methods now don't need to take ScDocument* as an arg.
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index 748b29a..19d009e 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -65,7 +65,7 @@ public:
const ScQueryParam& GetQueryParam() const;
bool operator== ( const ScSheetSourceDesc& rOther ) const;
- ScDPTableDataCache* CreateCache( ScDocument* pDoc, long nID = -1) const;
+ ScDPTableDataCache* CreateCache(long nID = -1) const;
/**
* Check the sanity of the data source range.
@@ -75,10 +75,10 @@ public:
* @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;
+ ULONG CheckSourceRange() const;
+ ScDPTableDataCache* GetCache(long nID) const;
+ ScDPTableDataCache* GetExistDPObjectCache () const;
+ long GetCacheId(long nID) const;
private:
ScRange maSourceRange;
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 6167768..48295c6 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2585,7 +2585,7 @@ ULONG ScDPObject::RefreshCache()
CreateObjects();
ULONG nErrId = 0;
if ( pSheetDesc)
- nErrId = pSheetDesc->CheckSourceRange( pDoc );
+ nErrId = pSheetDesc->CheckSourceRange();
if ( nErrId == 0 )
{
// First remove the old cache if exists.
@@ -2598,9 +2598,9 @@ ULONG ScDPObject::RefreshCache()
// Create a new cache.
ScDPTableDataCache* pCache = NULL;
if ( pSheetDesc )
- pCache = pSheetDesc->CreateCache( pDoc, nNewId );
+ pCache = pSheetDesc->CreateCache(nNewId);
else if ( pImpDesc )
- pCache = pImpDesc->CreateCache( pDoc, nNewId );
+ pCache = pImpDesc->CreateCache(pDoc, nNewId);
if ( pCache == NULL )
{
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 91f3a44..83c0dff 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -61,12 +61,12 @@ using ::std::hash_set;
// -----------------------------------------------------------------------
ScSheetDPData::ScSheetDPData( ScDocument* pD, const ScSheetSourceDesc& rDesc , long nCacheId) :
- ScDPTableData(pD, rDesc.GetCacheId( pD, nCacheId) ), // DataPilot Migration - Cache&&Performance
+ ScDPTableData(pD, rDesc.GetCacheId(nCacheId) ), // DataPilot Migration - Cache&&Performance
aQuery ( rDesc.GetQueryParam() ),
pSpecial(NULL),
bIgnoreEmptyRows( FALSE ),
bRepeatIfEmpty(FALSE),
- aCacheTable( pD, rDesc.GetCacheId( pD, nCacheId))
+ aCacheTable( pD, rDesc.GetCacheId(nCacheId))
{
SCSIZE nEntryCount( aQuery.GetEntryCount());
pSpecial = new bool[nEntryCount];
@@ -279,65 +279,65 @@ bool ScSheetSourceDesc::operator== (const ScSheetSourceDesc& rOther) const
maQueryParam == rOther.maQueryParam;
}
-ScDPTableDataCache* ScSheetSourceDesc::CreateCache( ScDocument* pDoc , long nID ) const
+ScDPTableDataCache* ScSheetSourceDesc::CreateCache(long nID) const
{
- if (!pDoc)
+ if (!mpDoc)
return NULL;
- ScDPTableDataCache* pCache = GetExistDPObjectCache( pDoc );
+ ScDPTableDataCache* pCache = GetExistDPObjectCache();
if ( pCache && ( nID < 0 || nID == pCache->GetId() ) )
return pCache;
- ULONG nErrId = CheckSourceRange( pDoc );
+ ULONG nErrId = CheckSourceRange();
if (nErrId)
{
DBG_ERROR( "Error Create Cache\n" );
return NULL;
}
- pCache = new ScDPTableDataCache( pDoc );
+ pCache = new ScDPTableDataCache(mpDoc);
- pCache->InitFromDoc( pDoc, GetSourceRange() );
+ pCache->InitFromDoc(mpDoc, GetSourceRange());
pCache->SetId( nID );
- pDoc->GetDPCollection()->AddDPObjectCache( pCache );
+ mpDoc->GetDPCollection()->AddDPObjectCache(pCache);
- DBG_TRACE1("Create a cache id = %d \n", pCache->GetId() );
+ DBG_TRACE1("Create a cache id = %d \n", pCache->GetId());
return pCache;
}
-ScDPTableDataCache* ScSheetSourceDesc::GetExistDPObjectCache ( ScDocument* pDoc ) const
+ScDPTableDataCache* ScSheetSourceDesc::GetExistDPObjectCache () const
{
- return pDoc->GetDPCollection()->GetUsedDPObjectCache( GetSourceRange() );
+ return mpDoc->GetDPCollection()->GetUsedDPObjectCache( GetSourceRange() );
}
-ScDPTableDataCache* ScSheetSourceDesc::GetCache( ScDocument* pDoc, long nID ) const
+ScDPTableDataCache* ScSheetSourceDesc::GetCache(long nID) const
{
- if (!pDoc)
+ if (!mpDoc)
return NULL;
- ScDPTableDataCache* pCache = pDoc->GetDPCollection()->GetDPObjectCache( nID );
+ ScDPTableDataCache* pCache = mpDoc->GetDPCollection()->GetDPObjectCache(nID);
if (NULL == pCache)
- pCache = GetExistDPObjectCache( pDoc );
+ pCache = GetExistDPObjectCache();
if (NULL == pCache)
- pCache = CreateCache( pDoc );
+ pCache = CreateCache();
return pCache;
}
-long ScSheetSourceDesc::GetCacheId( ScDocument* pDoc, long nID ) const
+long ScSheetSourceDesc::GetCacheId(long nID) const
{
- ScDPTableDataCache* pCache = GetCache( pDoc, nID);
+ ScDPTableDataCache* pCache = GetCache(nID);
if ( NULL == pCache )
return -1;
else
return pCache->GetId();
}
-ULONG ScSheetSourceDesc::CheckSourceRange( ScDocument* pDoc ) const
+ULONG ScSheetSourceDesc::CheckSourceRange() const
{
- if (!pDoc)
+ if (!mpDoc)
return STR_ERR_DATAPILOTSOURCE;
const ScRange& aSrcRange = GetSourceRange();
@@ -345,11 +345,11 @@ ULONG ScSheetSourceDesc::CheckSourceRange( ScDocument* pDoc ) const
const ScAddress& e = aSrcRange.aEnd;
for (SCCOL nCol = aSrcRange.aStart.Col(); nCol <= e.Col(); ++nCol)
{
- if (pDoc->IsBlockEmpty(s.Tab(), nCol, s.Row(), nCol, s.Row()))
+ if (mpDoc->IsBlockEmpty(s.Tab(), nCol, s.Row(), nCol, s.Row()))
return STR_PIVOT_FIRSTROWEMPTYERR;
}
- if (pDoc->IsBlockEmpty(s.Tab(), s.Col(), s.Row()+1, e.Col(), e.Row()))
+ if (mpDoc->IsBlockEmpty(s.Tab(), s.Col(), s.Row()+1, e.Col(), e.Row()))
return STR_PIVOT_ONLYONEROWERR;
return 0;
commit 4176f290e0fcf5af57692498ddcfa5a405dc4846
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri Jan 21 16:46:47 2011 -0500
Let's store ScDocument* in ScSheetSourceDesc.
This class already uses ScDocument* a lot internally. Let's just
take the pointer to the document instance in the ctor and store it
inside.
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index 3f98e1c..748b29a 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -52,7 +52,10 @@ class ScDPItemData;
*/
class ScSheetSourceDesc
{
+ ScSheetSourceDesc(); // disabled
+
public:
+ SC_DLLPUBLIC ScSheetSourceDesc(ScDocument* pDoc);
SC_DLLPUBLIC void SetSourceRange(const ScRange& rRange);
SC_DLLPUBLIC const ScRange& GetSourceRange() const;
@@ -81,6 +84,7 @@ private:
ScRange maSourceRange;
::rtl::OUString maRangeName;
ScQueryParam maQueryParam;
+ ScDocument* mpDoc;
};
// --------------------------------------------------------------------
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 8132392..2417321 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -569,7 +569,7 @@ void Test::testDataPilot()
printer.print("Data sheet content");
printer.clear();
- ScSheetSourceDesc aSheetDesc;
+ ScSheetSourceDesc aSheetDesc(m_pDoc);
aSheetDesc.SetSourceRange(ScRange(nCol1, nRow1, 0, nCol2, nRow2, 0));
ScDPObject* pDPObj = new ScDPObject(m_pDoc);
pDPObj->SetSheetDesc(aSheetDesc);
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 9ad68b7..6167768 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -424,7 +424,7 @@ ScDPTableData* ScDPObject::GetTableData()
if (!pSheetDesc)
{
DBG_ERROR("no source descriptor");
- pSheetDesc = new ScSheetSourceDesc; // dummy defaults
+ pSheetDesc = new ScSheetSourceDesc(pDoc); // dummy defaults
}
pData.reset(new ScSheetDPData(pDoc, *pSheetDesc, GetCacheId()));
}
@@ -712,7 +712,7 @@ void ScDPObject::UpdateReference( UpdateRefMode eUpdateRefMode,
nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
if ( eRes != UR_NOTHING )
{
- ScSheetSourceDesc aNewDesc;
+ ScSheetSourceDesc aNewDesc(pDoc);
aNewDesc.SetSourceRange(ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2));
SCsCOL nDiffX = nCol1 - (SCsCOL) pSheetDesc->GetSourceRange().aStart.Col();
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index ee121a3..91f3a44 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -233,6 +233,9 @@ const ScDPCacheTable& ScSheetDPData::GetCacheTable() const
return aCacheTable;
}
+ScSheetSourceDesc::ScSheetSourceDesc(ScDocument* pDoc) :
+ mpDoc(pDoc) {}
+
void ScSheetSourceDesc::SetSourceRange(const ScRange& rRange)
{
maSourceRange = rRange;
@@ -241,6 +244,11 @@ void ScSheetSourceDesc::SetSourceRange(const ScRange& rRange)
const ScRange& ScSheetSourceDesc::GetSourceRange() const
{
+ if (maRangeName.getLength())
+ {
+ // Obtain the source range from the range name first.
+
+ }
return maSourceRange;
}
diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index daa19bd..16109c2 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -1395,7 +1395,7 @@ void XclImpPivotTable::Convert()
// *** insert into Calc document ***
// create source descriptor
- ScSheetSourceDesc aDesc;
+ ScSheetSourceDesc aDesc(GetDocPtr());
aDesc.SetSourceRange(mxPCache->GetSourceRange());
// adjust output range to include the page fields
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 1a746ce..09659e0 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -445,7 +445,7 @@ void ScXMLDataPilotTableContext::EndElement()
{
if (bSourceCellRange)
{
- ScSheetSourceDesc aSheetDesc;
+ ScSheetSourceDesc aSheetDesc(pDoc);
aSheetDesc.SetSourceRange(aSourceCellRangeAddress);
aSheetDesc.SetQueryParam(aSourceQueryParam);
pDPObject->SetSheetDesc(aSheetDesc);
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index e15a40d..d619c41 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -188,7 +188,6 @@ ScDPLayoutDlg::ScDPLayoutDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pPar
GetViewData() ),
pDoc ( ((ScTabViewShell*)SfxViewShell::Current())->
GetViewData()->GetDocument() ),
- meSrcType(SRC_INVALID),
bRefInputMode (false)
{
xDlgDPObject->SetAlive( TRUE ); // needed to get structure information
@@ -1419,20 +1418,20 @@ bool ScDPLayoutDlg::GetPivotArrays(
void ScDPLayoutDlg::UpdateSrcRange()
{
- String theCurPosStr = aEdInPos.GetText();
- USHORT nResult = ScRange().Parse(theCurPosStr, pDoc, pDoc->GetAddressConvention());
- meSrcType = SRC_INVALID;
-
+ String aSrcStr = aEdInPos.GetText();
+ USHORT nResult = ScRange().Parse(aSrcStr, pDoc, pDoc->GetAddressConvention());
+ DataSrcType eSrcType = SRC_INVALID;
ScRange aNewRange;
+
if (SCA_VALID == (nResult & SCA_VALID))
{
// Valid source range. Take it.
ScRefAddress start, end;
- ConvertDoubleRef(pDoc, theCurPosStr, 1, start, end, pDoc->GetAddressConvention());
+ ConvertDoubleRef(pDoc, aSrcStr, 1, start, end, pDoc->GetAddressConvention());
aNewRange.aStart = start.GetAddress();
aNewRange.aEnd = end.GetAddress();
aEdInPos.SetRefValid(true);
- meSrcType = SRC_REF;
+ eSrcType = SRC_REF;
}
else
{
@@ -1441,7 +1440,7 @@ void ScDPLayoutDlg::UpdateSrcRange()
ScRangeName* pRangeName = pDoc->GetRangeName();
if (pRangeName)
{
- OUString aUpper = ScGlobal::pCharClass->upper(theCurPosStr);
+ OUString aUpper = ScGlobal::pCharClass->upper(aSrcStr);
USHORT n;
bValid = pRangeName->SearchNameUpper(aUpper, n);
if (bValid)
@@ -1460,22 +1459,37 @@ void ScDPLayoutDlg::UpdateSrcRange()
return;
}
- meSrcType = SRC_NAME;
+ eSrcType = SRC_NAME;
}
aBtnOk.Enable();
+
+ // Now update the data src range or range name with the dp object.
ScSheetSourceDesc inSheet = *xDlgDPObject->GetSheetDesc();
- if (inSheet.GetSourceRange() == aNewRange)
- // new range is identical to the current range. Nothing to do.
- return;
+ switch (eSrcType)
+ {
+ case SRC_REF:
+ // data source is a range reference.
+ if (inSheet.GetSourceRange() == aNewRange)
+ // new range is identical to the current range. Nothing to do.
+ return;
+ inSheet.SetSourceRange(aNewRange);
+ break;
+ case SRC_NAME:
+ // data source is a range name.
+ inSheet.SetRangeName(aSrcStr);
+ break;
+ default:
+ OSL_ENSURE(false, "Unknown source type.");
+ return;
+ }
- ScTabViewShell * pTabViewShell = pViewData->GetViewShell();
- inSheet.SetSourceRange(aNewRange);
xDlgDPObject->SetSheetDesc(inSheet);
xDlgDPObject->FillOldParam( thePivotData, FALSE );
xDlgDPObject->FillLabelData(thePivotData);
+ ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
pTabViewShell->SetDialogDPObject(xDlgDPObject.get());
aLabelDataArr.clear();
aWndSelect.ClearFields();
diff --git a/sc/source/ui/inc/pvlaydlg.hxx b/sc/source/ui/inc/pvlaydlg.hxx
index 14b1b61..9d0e215 100644
--- a/sc/source/ui/inc/pvlaydlg.hxx
+++ b/sc/source/ui/inc/pvlaydlg.hxx
@@ -185,7 +185,6 @@ private:
ScPivotParam thePivotData;
ScViewData* pViewData;
ScDocument* pDoc;
- DataSrcType meSrcType;
bool bRefInputMode;
private:
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 76ef5b4..b9cb787 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -719,7 +719,7 @@ void SAL_CALL ScDataPilotDescriptorBase::setSourceRange( const CellRangeAddress&
if (!pDPObject)
throw RuntimeException();
- ScSheetSourceDesc aSheetDesc;
+ ScSheetSourceDesc aSheetDesc(pDocShell->GetDocument());
if (pDPObject->IsSheetData())
aSheetDesc = *pDPObject->GetSheetDesc();
@@ -1418,7 +1418,7 @@ ScDataPilotDescriptor::ScDataPilotDescriptor(ScDocShell* pDocSh) :
aSaveData.SetIgnoreEmptyRows( sal_False );
aSaveData.SetRepeatIfEmpty( sal_False );
mpDPObject->SetSaveData(aSaveData);
- ScSheetSourceDesc aSheetDesc;
+ ScSheetSourceDesc aSheetDesc(pDocSh ? pDocSh->GetDocument() : NULL);
mpDPObject->SetSheetDesc(aSheetDesc);
mpDPObject->GetSource();
}
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 7d95014..1cbaa7c 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -1599,7 +1599,7 @@ void ScDataPilotFilterDescriptor::PutData( const ScQueryParam& rParam )
ScDPObject* pDPObj = pParent->GetDPObject();
if (pDPObj)
{
- ScSheetSourceDesc aSheetDesc;
+ ScSheetSourceDesc aSheetDesc(pParent->GetDocShell()->GetDocument());
if (pDPObj->IsSheetData())
aSheetDesc = *pDPObj->GetSheetDesc();
aSheetDesc.SetQueryParam(rParam);
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 9d3db62..1b036a5 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -849,7 +849,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
}
if (bOK)
{
- ScSheetSourceDesc aShtDesc;
+ ScSheetSourceDesc aShtDesc(pDoc);
aShtDesc.SetSourceRange(aRange);
pNewDPObject = new ScDPObject( pDoc );
pNewDPObject->SetSheetDesc( aShtDesc );
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index aceda30..6a2a161 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -227,7 +227,7 @@ void ScGridWindow::DoPushButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt
DBG_ASSERT(pDlg, "Dialog create fail!");
if ( pDlg->Execute() == RET_OK )
{
- ScSheetSourceDesc aNewDesc;
+ ScSheetSourceDesc aNewDesc(pDoc);
if (pDesc)
aNewDesc = *pDesc;
diff --git a/sc/source/ui/view/pivotsh.cxx b/sc/source/ui/view/pivotsh.cxx
index c9d42a9..4bdfebe 100644
--- a/sc/source/ui/view/pivotsh.cxx
+++ b/sc/source/ui/view/pivotsh.cxx
@@ -134,7 +134,7 @@ void ScPivotShell::Execute( SfxRequest& rReq )
if( pDlg->Execute() == RET_OK )
{
- ScSheetSourceDesc aNewDesc;
+ ScSheetSourceDesc aNewDesc(pViewData->GetDocument());
if( pDesc )
aNewDesc = *pDesc;
commit 42caa46f5e05c138df0fd28f5f7e51cb909139e2
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri Jan 21 16:01:07 2011 -0500
Early bail out on error conditions, to reduce indent levels.
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 0c7d33d..ee121a3 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -273,28 +273,29 @@ bool ScSheetSourceDesc::operator== (const ScSheetSourceDesc& rOther) const
ScDPTableDataCache* ScSheetSourceDesc::CreateCache( ScDocument* pDoc , long nID ) const
{
- if ( pDoc )
+ if (!pDoc)
+ return NULL;
+
+ ScDPTableDataCache* pCache = GetExistDPObjectCache( pDoc );
+ if ( pCache && ( nID < 0 || nID == pCache->GetId() ) )
+ return pCache;
+
+ ULONG nErrId = CheckSourceRange( pDoc );
+ if (nErrId)
{
- ScDPTableDataCache* pCache = GetExistDPObjectCache( pDoc );
- if ( pCache && ( nID < 0 || nID == pCache->GetId() ) )
- return pCache;
+ DBG_ERROR( "Error Create Cache\n" );
+ return NULL;
+ }
- ULONG nErrId = CheckSourceRange( pDoc );
- if ( !nErrId )
- {
- pCache = new ScDPTableDataCache( pDoc );
+ pCache = new ScDPTableDataCache( pDoc );
- pCache->InitFromDoc( pDoc, GetSourceRange() );
- pCache->SetId( nID );
- pDoc->GetDPCollection()->AddDPObjectCache( pCache );
+ pCache->InitFromDoc( pDoc, GetSourceRange() );
+ pCache->SetId( nID );
+ pDoc->GetDPCollection()->AddDPObjectCache( pCache );
- DBG_TRACE1("Create a cache id = %d \n", pCache->GetId() );
- }
- else
- DBG_ERROR( "\n Error Create Cache" );
- return pCache;
- }
- return NULL;
+ DBG_TRACE1("Create a cache id = %d \n", pCache->GetId() );
+
+ return pCache;
}
ScDPTableDataCache* ScSheetSourceDesc::GetExistDPObjectCache ( ScDocument* pDoc ) const
@@ -304,15 +305,20 @@ ScDPTableDataCache* ScSheetSourceDesc::GetExistDPObjectCache ( ScDocument* pDoc
ScDPTableDataCache* ScSheetSourceDesc::GetCache( ScDocument* pDoc, long nID ) const
{
+ if (!pDoc)
+ return NULL;
+
ScDPTableDataCache* pCache = pDoc->GetDPCollection()->GetDPObjectCache( nID );
- if ( NULL == pCache && pDoc )
+ if (NULL == pCache)
pCache = GetExistDPObjectCache( pDoc );
- if ( NULL == pCache )
- pCache = CreateCache( pDoc );
+
+ if (NULL == pCache)
+ pCache = CreateCache( pDoc );
+
return pCache;
}
-long ScSheetSourceDesc:: GetCacheId( ScDocument* pDoc, long nID ) const
+long ScSheetSourceDesc::GetCacheId( ScDocument* pDoc, long nID ) const
{
ScDPTableDataCache* pCache = GetCache( pDoc, nID);
if ( NULL == pCache )
@@ -323,10 +329,10 @@ long ScSheetSourceDesc:: GetCacheId( ScDocument* pDoc, long nID ) const
ULONG ScSheetSourceDesc::CheckSourceRange( ScDocument* pDoc ) const
{
- const ScRange& aSrcRange = GetSourceRange();
if (!pDoc)
return STR_ERR_DATAPILOTSOURCE;
+ const ScRange& aSrcRange = GetSourceRange();
const ScAddress& s = aSrcRange.aStart;
const ScAddress& e = aSrcRange.aEnd;
for (SCCOL nCol = aSrcRange.aStart.Col(); nCol <= e.Col(); ++nCol)
More information about the Libreoffice-commits
mailing list