[Libreoffice-commits] .: 3 commits - sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Wed Mar 23 14:20:52 PDT 2011
sc/inc/dpshttab.hxx | 6 ++----
sc/source/core/data/dpobject.cxx | 6 ++++--
sc/source/core/data/dpshttab.cxx | 4 ++--
sc/source/filter/excel/xepivot.cxx | 6 +++++-
sc/source/ui/src/globstr.src | 2 +-
sc/source/ui/view/cellsh1.cxx | 26 ++++++++++++++++++++++----
6 files changed, 36 insertions(+), 14 deletions(-)
New commits:
commit 00b879fbf8a33137ef28e90e0693c418979c013d
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Wed Mar 23 17:16:18 2011 -0400
Detect error conditions during initial datapilot construction.
Failure to do so would cause an segfault down the road.
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index 387b3ba..91ece56 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1805,7 +1805,7 @@ Resource RID_GLOBSTR
};
String STR_PIVOT_FIRSTROWEMPTYERR
{
- Text [ en-US ] = "The field name cannot be empty. Check the first row of data source to make sure there are no empty cells." ;
+ Text [ en-US ] = "One or more fields appear to have an empty name. Check the first row of the data source to ensure there are no empty cells." ;
};
String STR_PIVOT_ONLYONEROWERR
{
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index c65c54e..d474ed3 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2166,6 +2166,8 @@ void ScCellShell::ExecuteDataPilotDialog()
}
else // create new table
{
+ sal_uLong nSrcErrorId = 0;
+
// select database range or data
pTabViewShell->GetDBData( true, SC_DB_OLD );
ScMarkData& rMark = GetViewData()->GetMarkData();
@@ -2241,8 +2243,12 @@ void ScCellShell::ExecuteDataPilotDialog()
OUString aName = pTypeDlg->GetSelectedNamedRange();
ScSheetSourceDesc aShtDesc(pDoc);
aShtDesc.SetRangeName(aName);
- pNewDPObject.reset(new ScDPObject(pDoc));
- pNewDPObject->SetSheetDesc(aShtDesc);
+ nSrcErrorId = aShtDesc.CheckSourceRange();
+ if (!nSrcErrorId)
+ {
+ pNewDPObject.reset(new ScDPObject(pDoc));
+ pNewDPObject->SetSheetDesc(aShtDesc);
+ }
}
else // selection
{
@@ -2279,8 +2285,12 @@ void ScCellShell::ExecuteDataPilotDialog()
{
ScSheetSourceDesc aShtDesc(pDoc);
aShtDesc.SetSourceRange(aRange);
- pNewDPObject.reset(new ScDPObject(pDoc));
- pNewDPObject->SetSheetDesc( aShtDesc );
+ nSrcErrorId = aShtDesc.CheckSourceRange();
+ if (!nSrcErrorId)
+ {
+ pNewDPObject.reset(new ScDPObject(pDoc));
+ pNewDPObject->SetSheetDesc( aShtDesc );
+ }
// output below source data
if ( aRange.aEnd.Row()+2 <= MAXROW - 4 )
@@ -2292,6 +2302,14 @@ void ScCellShell::ExecuteDataPilotDialog()
}
}
+ if (nSrcErrorId)
+ {
+ // Error occurred during data creation. Launch an error and bail out.
+ InfoBox aBox(pTabViewShell->GetDialogParent(), ScGlobal::GetRscString(nSrcErrorId));
+ aBox.Execute();
+ return;
+ }
+
if ( pNewDPObject )
pNewDPObject->SetOutRange( aDestPos );
}
commit 035c05d27e544e5f2efe7534224cb97d6e44565c
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Wed Mar 23 16:43:28 2011 -0400
Updated doc.
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index 847776e..24d1d03 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -83,8 +83,6 @@ public:
/**
* 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.
*/
commit 983ca8104428a2c032a6a170cf249ff176722db5
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Wed Mar 23 16:38:27 2011 -0400
Create data cache outside of the ScSheetDPData.
This will create a hook where we can detect error conditions before
going too deep.
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index 731d8f1..847776e 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -78,7 +78,7 @@ public:
const ScQueryParam& GetQueryParam() const;
bool operator== ( const ScSheetSourceDesc& rOther ) const;
- ScDPCache* CreateCache() const;
+ SC_DLLPUBLIC ScDPCache* CreateCache() const;
/**
* Check the sanity of the data source range.
@@ -113,7 +113,7 @@ private:
ScDPCacheTable aCacheTable;
public:
- ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc);
+ ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, ScDPCache* pCache);
virtual ~ScSheetDPData();
virtual long GetColumnCount();
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 2292dcd..d1d9b5c 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -417,11 +417,13 @@ ScDPTableData* ScDPObject::GetTableData()
OSL_FAIL("no source descriptor");
pSheetDesc = new ScSheetSourceDesc(pDoc); // dummy defaults
}
- pData.reset(new ScSheetDPData(pDoc, *pSheetDesc));
+ ScDPCache* pCache = pSheetDesc->CreateCache();
+ if (pCache)
+ pData.reset(new ScSheetDPData(pDoc, *pSheetDesc, pCache));
}
// grouping (for cell or database data)
- if ( pSaveData && pSaveData->GetExistingDimensionData() )
+ if (pData && pSaveData && pSaveData->GetExistingDimensionData())
{
shared_ptr<ScDPGroupTableData> pGroupData(new ScDPGroupTableData(pData, pDoc));
pSaveData->GetExistingDimensionData()->WriteToData(*pGroupData);
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index c65202e..ca68c6c 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -60,14 +60,14 @@ using ::std::vector;
// -----------------------------------------------------------------------
-ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc) :
+ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, ScDPCache* pCache) :
ScDPTableData(pD),
aQuery ( rDesc.GetQueryParam() ),
pSpecial(NULL),
bIgnoreEmptyRows( false ),
bRepeatIfEmpty(false),
mrDesc(rDesc),
- aCacheTable(rDesc.CreateCache())
+ aCacheTable(pCache)
{
SCSIZE nEntryCount( aQuery.GetEntryCount());
pSpecial = new bool[nEntryCount];
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index f98276f..a3f3125 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -538,7 +538,11 @@ void XclExpPCField::InsertNumDateGroupItems( const ScDPObject& rDPObj, const ScD
if( const ScSheetSourceDesc* pSrcDesc = rDPObj.GetSheetDesc() )
{
// get the string collection with original source elements
- ScSheetDPData aDPData( GetDocPtr(), *pSrcDesc );
+ ScDPCache* pCache = pSrcDesc->CreateCache();
+ if (!pCache)
+ return;
+
+ ScSheetDPData aDPData(GetDocPtr(), *pSrcDesc, pCache);
const std::vector< SCROW > aOrignial = aDPData.GetColumnEntries( static_cast< long >( GetBaseFieldIndex() ) );
// get the string collection with generated grouping elements
ScDPNumGroupDimension aTmpDim( rNumInfo );
More information about the Libreoffice-commits
mailing list