diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-04-27 17:21:25 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-04-28 15:35:54 -0400 |
commit | 60f355127fb93d574e30e590158fe867148762ea (patch) | |
tree | 16ab3e42b9789d8fd118458071fca42771c16372 /sc/source | |
parent | ca844d3bfc4fc379608a4856a9750af84e620953 (diff) |
Centrally manage cached grid data for data pilot tables.
This prevents cached data from getting re-generated everytime ScDPObject
gets copied, which happens quite often. Without this, the performance
of datapilot would really really suffer.
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/dpcachetable.cxx | 18 | ||||
-rw-r--r-- | sc/source/core/data/dpobject.cxx | 149 | ||||
-rw-r--r-- | sc/source/core/data/dpsdbtab.cxx | 116 | ||||
-rw-r--r-- | sc/source/core/data/dpshttab.cxx | 11 | ||||
-rw-r--r-- | sc/source/core/data/dptablecache.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xepivot.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLExportDataPilot.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/cctrl/dpcontrol.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/dbgui/dapidata.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/dbfunc3.cxx | 24 |
10 files changed, 206 insertions, 131 deletions
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx index 67b55e7f0155..263a698f88c0 100644 --- a/sc/source/core/data/dpcachetable.cxx +++ b/sc/source/core/data/dpcachetable.cxx @@ -158,14 +158,13 @@ ScDPCacheTable::Criterion::Criterion() : // ---------------------------------------------------------------------------- -ScDPCacheTable::ScDPCacheTable(ScDPCache* pCache) : +ScDPCacheTable::ScDPCacheTable(const ScDPCache* pCache) : mpCache(pCache) { } ScDPCacheTable::~ScDPCacheTable() { - delete mpCache; } sal_Int32 ScDPCacheTable::getRowSize() const @@ -181,9 +180,9 @@ sal_Int32 ScDPCacheTable::getColSize() const void ScDPCacheTable::fillTable( const ScQueryParam& rQuery, bool* pSpecial, bool bIgnoreEmptyRows, bool bRepeatIfEmpty) { - const SCROW nRowCount = getRowSize(); - const SCCOL nColCount = (SCCOL) getColSize(); - if ( nRowCount <= 0 || nColCount <= 0) + const SCROW nRowCount = getRowSize(); + const SCCOL nColCount = (SCCOL) getColSize(); + if ( nRowCount <= 0 || nColCount <= 0) return; maRowsVisible.clear(); @@ -402,7 +401,6 @@ void ScDPCacheTable::clear() { maFieldEntries.clear(); maRowsVisible.clear(); - delete mpCache; mpCache = NULL; } @@ -411,9 +409,8 @@ bool ScDPCacheTable::empty() const return mpCache == NULL || maFieldEntries.empty(); } -void ScDPCacheTable::setCache(ScDPCache* p) +void ScDPCacheTable::setCache(const ScDPCache* p) { - delete mpCache; mpCache = p; } @@ -448,9 +445,4 @@ const ScDPCache* ScDPCacheTable::getCache() const return mpCache; } -ScDPCache* ScDPCacheTable::getCache() -{ - return mpCache; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index 97e2f0db1bbc..e8d6a2334b23 100644 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -54,6 +54,7 @@ #include "dpglobal.hxx" #include "globstr.hrc" #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/sdb/XCompletedExecution.hpp> #include <com/sun/star/sheet/GeneralFunction.hpp> #include <com/sun/star/sheet/DataPilotFieldFilter.hpp> #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> @@ -70,13 +71,15 @@ #include <com/sun/star/sheet/XDrillDownDataSupplier.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/types.hxx> #include <sal/macros.h> #include <tools/debug.hxx> #include <tools/diagnose_ex.h> #include <svl/zforlist.hxx> // IsNumberFormat +#include <vcl/msgbox.hxx> #include <vector> -#include <stdio.h> +#include <memory> using namespace com::sun::star; using ::std::vector; @@ -95,6 +98,13 @@ using ::com::sun::star::sheet::XDimensionsSupplier; using ::com::sun::star::beans::XPropertySet; using ::rtl::OUString; +#define SC_SERVICE_ROWSET "com.sun.star.sdb.RowSet" +#define SC_SERVICE_INTHANDLER "com.sun.star.task.InteractionHandler" + +#define SC_DBPROP_DATASOURCENAME "DataSourceName" +#define SC_DBPROP_COMMAND "Command" +#define SC_DBPROP_COMMANDTYPE "CommandType" + // ----------------------------------------------------------------------- #define SCDPSOURCE_SERVICE "com.sun.star.sheet.DataPilotSource" @@ -417,7 +427,7 @@ ScDPTableData* ScDPObject::GetTableData() OSL_FAIL("no source descriptor"); pSheetDesc = new ScSheetSourceDesc(pDoc); // dummy defaults } - ScDPCache* pCache = pSheetDesc->CreateCache(); + const ScDPCache* pCache = pSheetDesc->CreateCache(); if (pCache) pData.reset(new ScSheetDPData(pDoc, *pSheetDesc, pCache)); } @@ -2383,15 +2393,123 @@ uno::Reference<sheet::XDimensionsSupplier> ScDPObject::CreateSource( const ScDPS return xRet; } -// ---------------------------------------------------------------------------- +ScDPCollection::SheetCaches::SheetCaches(ScDocument* pDoc) : mpDoc(pDoc) {} + +const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange& rRange) +{ + CachesType::const_iterator itr = maCaches.find(rRange); + if (itr != maCaches.end()) + // already cached. + return itr->second; + + ::std::auto_ptr<ScDPCache> pCache(new ScDPCache(mpDoc)); + pCache->InitFromDoc(mpDoc, rRange); + const ScDPCache* p = pCache.get(); + maCaches.insert(rRange, pCache); + return p; +} + +void ScDPCollection::SheetCaches::removeCache(const ScRange& rRange) +{ + CachesType::iterator itr = maCaches.find(rRange); + if (itr != maCaches.end()) + maCaches.erase(itr); +} + +ScDPCollection::DBType::DBType(sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand) : + mnSdbType(nSdbType), maDBName(rDBName), maCommand(rCommand) {} + +ScDPCollection::DBCaches::DBCaches(ScDocument* pDoc) : mpDoc(pDoc) {} + +const ScDPCache* ScDPCollection::DBCaches::getCache(sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand) +{ + DBType aType(nSdbType, rDBName, rCommand); + CachesType::const_iterator itr = maCaches.find(aType); + if (itr != maCaches.end()) + // already cached. + return itr->second; + + uno::Reference<sdbc::XRowSet> xRowSet ; + try + { + xRowSet = uno::Reference<sdbc::XRowSet>( + comphelper::getProcessServiceFactory()->createInstance( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_SERVICE_ROWSET )) ), + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xRowProp( xRowSet, uno::UNO_QUERY ); + DBG_ASSERT( xRowProp.is(), "can't get RowSet" ); + if ( xRowProp.is() ) + { + // + // set source parameters + // + uno::Any aAny; + aAny <<= rDBName; + xRowProp->setPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_DBPROP_DATASOURCENAME)), aAny ); + + aAny <<= rCommand; + xRowProp->setPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_DBPROP_COMMAND)), aAny ); + + aAny <<= nSdbType; + xRowProp->setPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_DBPROP_COMMANDTYPE)), aAny ); + + uno::Reference<sdb::XCompletedExecution> xExecute( xRowSet, uno::UNO_QUERY ); + if ( xExecute.is() ) + { + uno::Reference<task::XInteractionHandler> xHandler( + comphelper::getProcessServiceFactory()->createInstance( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_SERVICE_INTHANDLER )) ), + uno::UNO_QUERY); + xExecute->executeWithCompletion( xHandler ); + } + else + xRowSet->execute(); + } + } + catch ( sdbc::SQLException& rError ) + { + //! store error message + InfoBox aInfoBox( 0, String(rError.Message) ); + aInfoBox.Execute(); + return NULL; + } + catch ( uno::Exception& ) + { + OSL_FAIL("Unexpected exception in database"); + return NULL; + } + + ::std::auto_ptr<ScDPCache> pCache(new ScDPCache(mpDoc)); + SvNumberFormatter aFormat(mpDoc->GetServiceManager(), ScGlobal::eLnge); + pCache->InitFromDataBase(xRowSet, *aFormat.GetNullDate()); + ::comphelper::disposeComponent(xRowSet); + const ScDPCache* p = pCache.get(); + maCaches.insert(aType, pCache); + return p; +} + +void ScDPCollection::DBCaches::removeCache(sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand) +{ + DBType aType(nSdbType, rDBName, rCommand); + CachesType::iterator itr = maCaches.find(aType); + if (itr != maCaches.end()) + maCaches.erase(itr); +} ScDPCollection::ScDPCollection(ScDocument* pDocument) : - pDoc( pDocument ) + pDoc( pDocument ), + maSheetCaches(pDocument), + maDBCaches(pDocument) { } ScDPCollection::ScDPCollection(const ScDPCollection& r) : - pDoc(r.pDoc) + pDoc(r.pDoc), + maSheetCaches(r.pDoc), + maDBCaches(r.pDoc) { } @@ -2584,4 +2702,25 @@ bool ScDPCollection::HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const return pMergeAttr->HasDPTable(); } +ScDPCollection::SheetCaches& ScDPCollection::GetSheetCaches() +{ + return maSheetCaches; +} + +ScDPCollection::DBCaches& ScDPCollection::GetDBCaches() +{ + return maDBCaches; +} + +bool operator<(const ScDPCollection::DBType& left, const ScDPCollection::DBType& right) +{ + if (left.mnSdbType != right.mnSdbType) + return left.mnSdbType < right.mnSdbType; + + if (!left.maDBName.equals(right.maDBName)) + return left.maDBName < right.maDBName; + + return left.maCommand < right.maCommand; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx index 7eeb4b93e284..72c0f06911b1 100644 --- a/sc/source/core/data/dpsdbtab.cxx +++ b/sc/source/core/data/dpsdbtab.cxx @@ -33,23 +33,6 @@ // INCLUDE -------------------------------------------------------------- -#include <tools/debug.hxx> -#include <vcl/msgbox.hxx> -#include <svl/zforlist.hxx> -#include <comphelper/processfactory.hxx> -#include <comphelper/types.hxx> - -#include <com/sun/star/sheet/DataImportMode.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/sdb/CommandType.hpp> -#include <com/sun/star/sdb/XCompletedExecution.hpp> -#include <com/sun/star/sdbc/DataType.hpp> -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/sdbc/XRowSet.hpp> -#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/sheet/DataPilotFieldFilter.hpp> - #include "dpsdbtab.hxx" #include "collect.hxx" #include "global.hxx" @@ -59,100 +42,41 @@ #include "document.hxx" #include "dpobject.hxx" +#include <com/sun/star/sheet/DataImportMode.hpp> +#include <com/sun/star/sdb/CommandType.hpp> + using namespace com::sun::star; using ::std::vector; using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::UNO_QUERY; -#define SC_SERVICE_ROWSET "com.sun.star.sdb.RowSet" -#define SC_SERVICE_INTHANDLER "com.sun.star.task.InteractionHandler" - -//! move to a header file? -#define SC_DBPROP_DATASOURCENAME "DataSourceName" -#define SC_DBPROP_COMMAND "Command" -#define SC_DBPROP_COMMANDTYPE "CommandType" - -ScDPCache* ScImportSourceDesc::CreateCache() const +sal_Int32 ScImportSourceDesc::GetCommandType() const { - if (!mpDoc) - return NULL; - sal_Int32 nSdbType = -1; switch ( nType ) { - case sheet::DataImportMode_SQL: nSdbType = sdb::CommandType::COMMAND; break; - case sheet::DataImportMode_TABLE: nSdbType = sdb::CommandType::TABLE; break; - case sheet::DataImportMode_QUERY: nSdbType = sdb::CommandType::QUERY; break; - default: - return NULL; + case sheet::DataImportMode_SQL: nSdbType = sdb::CommandType::COMMAND; break; + case sheet::DataImportMode_TABLE: nSdbType = sdb::CommandType::TABLE; break; + case sheet::DataImportMode_QUERY: nSdbType = sdb::CommandType::QUERY; break; + default: + ; } + return nSdbType; +} - ScDPCache* pCache = new ScDPCache(mpDoc); - - uno::Reference<sdbc::XRowSet> xRowSet ; - try - { - xRowSet = uno::Reference<sdbc::XRowSet>( - comphelper::getProcessServiceFactory()->createInstance( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_SERVICE_ROWSET )) ), - uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xRowProp( xRowSet, uno::UNO_QUERY ); - DBG_ASSERT( xRowProp.is(), "can't get RowSet" ); - if ( xRowProp.is() ) - { - // - // set source parameters - // - uno::Any aAny; - aAny <<= rtl::OUString( aDBName ); - xRowProp->setPropertyValue( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_DBPROP_DATASOURCENAME)), aAny ); - - aAny <<= rtl::OUString( aObject ); - xRowProp->setPropertyValue( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_DBPROP_COMMAND)), aAny ); - - aAny <<= nSdbType; - xRowProp->setPropertyValue( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_DBPROP_COMMANDTYPE)), aAny ); - - uno::Reference<sdb::XCompletedExecution> xExecute( xRowSet, uno::UNO_QUERY ); - if ( xExecute.is() ) - { - uno::Reference<task::XInteractionHandler> xHandler( - comphelper::getProcessServiceFactory()->createInstance( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_SERVICE_INTHANDLER )) ), - uno::UNO_QUERY); - xExecute->executeWithCompletion( xHandler ); - } - else - xRowSet->execute(); - SvNumberFormatter aFormat(mpDoc->GetServiceManager(), ScGlobal::eLnge); - pCache->InitFromDataBase( xRowSet, *aFormat.GetNullDate() ); - } - } - catch ( sdbc::SQLException& rError ) - { - //! store error message - delete pCache; - pCache = NULL; - InfoBox aInfoBox( 0, String(rError.Message) ); - aInfoBox.Execute(); - } - catch ( uno::Exception& ) - { - delete pCache; - pCache = NULL; - OSL_FAIL("Unexpected exception in database"); - } +const ScDPCache* ScImportSourceDesc::CreateCache() const +{ + if (!mpDoc) + return NULL; + sal_Int32 nSdbType = GetCommandType(); + if (nSdbType < 0) + return NULL; - ::comphelper::disposeComponent( xRowSet ); - return pCache; + ScDPCollection::DBCaches& rCaches = mpDoc->GetDPCollection()->GetDBCaches(); + return rCaches.getCache(nSdbType, aDBName, aObject); } ScDatabaseDPData::ScDatabaseDPData(ScDocument* pDoc, const ScImportSourceDesc& rImport) : diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx index e4aca9a45253..c05d333f5ba6 100644 --- a/sc/source/core/data/dpshttab.cxx +++ b/sc/source/core/data/dpshttab.cxx @@ -60,7 +60,7 @@ using ::std::vector; // ----------------------------------------------------------------------- -ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, ScDPCache* pCache) : +ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, const ScDPCache* pCache) : ScDPTableData(pD), aQuery ( rDesc.GetQueryParam() ), pSpecial(NULL), @@ -307,7 +307,7 @@ bool ScSheetSourceDesc::operator== (const ScSheetSourceDesc& rOther) const maQueryParam == rOther.maQueryParam; } -ScDPCache* ScSheetSourceDesc::CreateCache() const +const ScDPCache* ScSheetSourceDesc::CreateCache() const { if (!mpDoc) return NULL; @@ -319,9 +319,10 @@ ScDPCache* ScSheetSourceDesc::CreateCache() const return NULL; } - ScDPCache* pCache = new ScDPCache(mpDoc); - pCache->InitFromDoc(mpDoc, GetSourceRange()); - return pCache; + // All cache instances are managed centrally by ScDPCollection. + ScDPCollection* pDPs = mpDoc->GetDPCollection(); + ScDPCollection::SheetCaches& rCaches = pDPs->GetSheetCaches(); + return rCaches.getCache(GetSourceRange()); } long ScSheetSourceDesc::GetCacheId() const diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx index 6039d87235c1..e5fcc9c9e680 100644 --- a/sc/source/core/data/dptablecache.cxx +++ b/sc/source/core/data/dptablecache.cxx @@ -565,7 +565,7 @@ sal_uLong ScDPCache::GetDimNumType( SCCOL nDim) const return GetNumType(maTableDataValues[nDim][0].nNumFormat); } -bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, bool *pSpecial) +bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam, bool *pSpecial) const { if (!rParam.GetEntry(0).bDoQuery) return true; diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx index 8139a25b8b08..be8557eac430 100644 --- a/sc/source/filter/excel/xepivot.cxx +++ b/sc/source/filter/excel/xepivot.cxx @@ -538,7 +538,7 @@ void XclExpPCField::InsertNumDateGroupItems( const ScDPObject& rDPObj, const ScD if( const ScSheetSourceDesc* pSrcDesc = rDPObj.GetSheetDesc() ) { // get the string collection with original source elements - ScDPCache* pCache = pSrcDesc->CreateCache(); + const ScDPCache* pCache = pSrcDesc->CreateCache(); if (!pCache) return; diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx index 968c37f0e1b5..d0071a9428b2 100644 --- a/sc/source/filter/xml/XMLExportDataPilot.cxx +++ b/sc/source/filter/xml/XMLExportDataPilot.cxx @@ -858,24 +858,24 @@ void ScXMLExportDataPilot::WriteDataPilots(const uno::Reference <sheet::XSpreads case sheet::DataImportMode_NONE : break; case sheet::DataImportMode_QUERY : { - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATABASE_NAME, rtl::OUString(pImpSource->aDBName)); - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_QUERY_NAME, rtl::OUString(pImpSource->aObject)); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATABASE_NAME, pImpSource->aDBName); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_QUERY_NAME, pImpSource->aObject); SvXMLElementExport aElemID(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_QUERY, sal_True, sal_True); rExport.CheckAttrList(); } break; case sheet::DataImportMode_TABLE : { - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATABASE_NAME, rtl::OUString(pImpSource->aDBName)); - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_NAME, rtl::OUString(pImpSource->aObject)); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATABASE_NAME, pImpSource->aDBName); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_TABLE_NAME, pImpSource->aObject); SvXMLElementExport aElemID(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_TABLE, sal_True, sal_True); rExport.CheckAttrList(); } break; case sheet::DataImportMode_SQL : { - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATABASE_NAME, rtl::OUString(pImpSource->aDBName)); - rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SQL_STATEMENT, rtl::OUString(pImpSource->aObject)); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATABASE_NAME, pImpSource->aDBName); + rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_SQL_STATEMENT, pImpSource->aObject); if (!pImpSource->bNative) rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_PARSE_SQL_STATEMENT, XML_TRUE); SvXMLElementExport aElemID(rExport, XML_NAMESPACE_TABLE, XML_DATABASE_SOURCE_SQL, sal_True, sal_True); diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx index 2a5d415410dc..380cdf9cfeef 100644 --- a/sc/source/ui/cctrl/dpcontrol.cxx +++ b/sc/source/ui/cctrl/dpcontrol.cxx @@ -1032,6 +1032,7 @@ ScDPFieldPopupWindow::ScDPFieldPopupWindow(Window* pParent, ScDocument* pDoc) : maChkToggleAll.SetPosSizePixel(aPos, aSize); maChkToggleAll.SetFont(getLabelFont()); maChkToggleAll.SetText(ScRscStrLoader(RID_POPUP_FILTER, STR_BTN_TOGGLE_ALL).GetString()); + maChkToggleAll.SetTextColor(rStyle.GetMenuTextColor()); maChkToggleAll.SetControlBackground(rStyle.GetMenuColor()); maChkToggleAll.SetClickHdl( LINK(this, ScDPFieldPopupWindow, TriStateHdl) ); maChkToggleAll.Show(); diff --git a/sc/source/ui/dbgui/dapidata.cxx b/sc/source/ui/dbgui/dapidata.cxx index 63d11e1141ae..c73d701a6eb9 100644 --- a/sc/source/ui/dbgui/dapidata.cxx +++ b/sc/source/ui/dbgui/dapidata.cxx @@ -130,7 +130,7 @@ void ScDataPilotDatabaseDlg::GetValues( ScImportSourceDesc& rDesc ) rDesc.aDBName = aLbDatabase.GetSelectEntry(); rDesc.aObject = aCbObject.GetText(); - if ( !rDesc.aDBName.Len() || !rDesc.aObject.Len() ) + if (rDesc.aDBName.isEmpty() || rDesc.aObject.isEmpty()) rDesc.nType = sheet::DataImportMode_NONE; else if ( nSelect == DP_TYPELIST_TABLE ) rDesc.nType = sheet::DataImportMode_TABLE; diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index d2e185d05b47..3ce6b978f1be 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -72,6 +72,8 @@ #include "dbdocfun.hxx" #include "dpoutput.hxx" #include "dptabsrc.hxx" +#include "dpshttab.hxx" +#include "dpsdbtab.hxx" #include "editable.hxx" #include "docpool.hxx" #include "patattr.hxx" @@ -697,13 +699,29 @@ void ScDBFunc::RecalcPivotTable() ScDocShell* pDocSh = GetViewData()->GetDocShell(); ScDocument* pDoc = GetViewData()->GetDocument(); - // old pivot not used any more - + ScDPCollection* pDPs = pDoc->GetDPCollection(); ScDPObject* pDPObj = pDoc->GetDPAtCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); - if ( pDPObj ) + if (pDPs && pDPObj) { + // Remove existing data cache for the data that this datapilot uses, + // to force re-build data cache. + if (pDPObj->IsSheetData()) + { + // data source is internal sheet. + ScDPCollection::SheetCaches& rCaches = pDPs->GetSheetCaches(); + const ScSheetSourceDesc* pDesc = pDPObj->GetSheetDesc(); + rCaches.removeCache(pDesc->GetSourceRange()); + } + else if (pDPObj->IsImportData()) + { + // data source is external database. + ScDPCollection::DBCaches& rCaches = pDPs->GetDBCaches(); + const ScImportSourceDesc* pDesc = pDPObj->GetImportSourceDesc(); + rCaches.removeCache(pDesc->GetCommandType(), pDesc->aDBName, pDesc->aObject); + } + ScDBDocFunc aFunc( *pDocSh ); aFunc.DataPilotUpdate( pDPObj, pDPObj, true, false ); CursorPosChanged(); // shells may be switched |