You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by le...@apache.org on 2012/09/07 11:27:05 UTC
svn commit: r1381946 - in /incubator/ooo/trunk/main: boost/prj/ sc/inc/
sc/source/core/data/
Author: leiw
Date: Fri Sep 7 09:27:03 2012
New Revision: 1381946
URL: http://svn.apache.org/viewvc?rev=1381946&view=rev
Log:
#i120847 Optimizing algorithm of creating pivot table cache when loading a xls file with pivot table
Patch by: Tan Li(litan.test@gmail.com)
Review by: Wang Lei
Modified:
incubator/ooo/trunk/main/boost/prj/d.lst
incubator/ooo/trunk/main/sc/inc/cell.hxx
incubator/ooo/trunk/main/sc/inc/column.hxx
incubator/ooo/trunk/main/sc/inc/document.hxx
incubator/ooo/trunk/main/sc/inc/dpglobal.hxx
incubator/ooo/trunk/main/sc/inc/dptablecache.hxx
incubator/ooo/trunk/main/sc/inc/table.hxx
incubator/ooo/trunk/main/sc/source/core/data/column3.cxx
incubator/ooo/trunk/main/sc/source/core/data/document.cxx
incubator/ooo/trunk/main/sc/source/core/data/dptablecache.cxx
incubator/ooo/trunk/main/sc/source/core/data/table2.cxx
Modified: incubator/ooo/trunk/main/boost/prj/d.lst
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/boost/prj/d.lst?rev=1381946&r1=1381945&r2=1381946&view=diff
==============================================================================
--- incubator/ooo/trunk/main/boost/prj/d.lst (original)
+++ incubator/ooo/trunk/main/boost/prj/d.lst Fri Sep 7 09:27:03 2012
@@ -310,3 +310,11 @@ mkdir: %_DEST%\inc%_EXT%\boost\variant\d
..\%__SRC%\inc\boost\utility\detail\* %_DEST%\inc%_EXT%\boost\utility\detail
..\%__SRC%\inc\boost\variant\* %_DEST%\inc%_EXT%\boost\variant
..\%__SRC%\inc\boost\variant\detail\* %_DEST%\inc%_EXT%\boost\variant\detail
+
+mkdir: %_DEST%\inc%_EXT%\boost\lambda
+..\%__SRC%\misc\build\boost-1.30.2\boost\lambda\*.*pp %_DEST%\inc%_EXT%\boost\lambda\*.*pp
+..\%__SRC%\misc\build\boost_1_39_0\boost\lambda\* %_DEST%\inc%_EXT%\boost\lambda
+mkdir: %_DEST%\inc%_EXT%\boost\lambda\detail
+..\%__SRC%\misc\build\boost-1.30.2\boost\lambda\detail\*.*pp %_DEST%\inc%_EXT%\boost\lambda\detail\*.*pp
+..\%__SRC%\misc\build\boost_1_39_0\boost\lambda\detail\* %_DEST%\inc%_EXT%\boost\lambda\detail
+
Modified: incubator/ooo/trunk/main/sc/inc/cell.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/cell.hxx?rev=1381946&r1=1381945&r2=1381946&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/cell.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/cell.hxx Fri Sep 7 09:27:03 2012
@@ -38,6 +38,8 @@
#include <unotools/fontcvt.hxx>
#include "scdllapi.h"
+#include <cellform.hxx>
+
#define USE_MEMPOOL
#define TEXTWIDTH_DIRTY 0xffff
@@ -497,6 +499,38 @@ public:
};
// ============================================================================
+inline double GetValueFromCell( const ScBaseCell * pCell )
+{
+ switch (pCell->GetCellType())
+ {
+ case CELLTYPE_VALUE:
+ return ((ScValueCell*)pCell)->GetValue();
+ case CELLTYPE_FORMULA:
+ {
+ if (((ScFormulaCell*)pCell)->IsValue())
+ return ((ScFormulaCell*)pCell)->GetValue();
+ else
+ return 0.0;
+ }
+ default:
+ return 0.0;
+ }
+}
+// ============================================================================
+
+
+inline String GetStringFromCell( const ScBaseCell * pCell, sal_uLong nFormat, SvNumberFormatter* pFormatter )
+{
+ if (pCell->GetCellType() != CELLTYPE_NOTE)
+ {
+ String strResult;
+ Color* pColor = NULL;
+ ScCellFormat::GetString( const_cast<ScBaseCell*>(pCell), nFormat, strResult, &pColor, *(pFormatter) );
+ return strResult;
+ }
+ else
+ return String();
+}
#endif
Modified: incubator/ooo/trunk/main/sc/inc/column.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/column.hxx?rev=1381946&r1=1381945&r2=1381946&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/column.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/column.hxx Fri Sep 7 09:27:03 2012
@@ -60,6 +60,7 @@ class ScPostIt;
struct ScFunctionData;
struct ScLineFlags;
struct ScMergePatternState;
+class ScDPTableDataCache;
class ScFlatBoolRowSegments;
#define COLUMN_DELTA 4
@@ -360,6 +361,9 @@ public:
double nPPTX, double nPPTY,
const Fraction& rZoomX, const Fraction& rZoomY,
sal_Bool bShrink, sal_uInt16 nMinHeight, SCROW nMinStart );
+ template< typename TAddLebal, typename TAddData >
+ void FillDPCacheT( long nDim, SCROW nStartRow, SCROW nEndRow, const TAddLebal & , const TAddData & );
+ void FillDPCache( ScDPTableDataCache * pCache, long nDim, SCROW nStartRow, SCROW nEndRow );
private:
long GetSimpleTextNeededSize( SCSIZE nIndex, OutputDevice* pDev,
sal_Bool bWidth );
Modified: incubator/ooo/trunk/main/sc/inc/document.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/document.hxx?rev=1381946&r1=1381945&r2=1381946&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/document.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/document.hxx Fri Sep 7 09:27:03 2012
@@ -1876,6 +1876,8 @@ private: // CLOOK-Impl-Methoden
std::map< SCTAB, ScSortParam > mSheetSortParams;
+public:
+ void FillDPCache( ScDPTableDataCache * pCache, SCTAB nDocTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
};
inline void ScDocument::GetSortParam( ScSortParam& rParam, SCTAB nTab )
{
Modified: incubator/ooo/trunk/main/sc/inc/dpglobal.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/dpglobal.hxx?rev=1381946&r1=1381945&r2=1381946&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/dpglobal.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/dpglobal.hxx Fri Sep 7 09:27:03 2012
@@ -196,4 +196,6 @@ namespace ScDPGlobal
bool ChkDPTableOverlap( ScDocument *pDestDoc, std::list<ScDPObject> & rClipboard, SCCOL nClipStartCol, SCROW nClipStartRow, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, sal_uInt16 nEndTab, sal_Bool bExcludeClip = sal_False );
}
+#define isDateFormat( nNumType ) (!!((nNumType) & NUMBERFORMAT_DATE) )
+
#endif
Modified: incubator/ooo/trunk/main/sc/inc/dptablecache.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/dptablecache.hxx?rev=1381946&r1=1381945&r2=1381946&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/dptablecache.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/dptablecache.hxx Fri Sep 7 09:27:03 2012
@@ -107,8 +107,10 @@ public:
protected:
private:
+public:
void AddLabel( ScDPItemData* pData);
- sal_Bool AddData( long nDim, ScDPItemData* itemData );
+ template< bool bCheckDate >
+ sal_Bool AddData( long nDim, ScDPItemData* itemData );
};
#endif //DPTABLECACHE_HXX
Modified: incubator/ooo/trunk/main/sc/inc/table.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/inc/table.hxx?rev=1381946&r1=1381945&r2=1381946&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/inc/table.hxx (original)
+++ incubator/ooo/trunk/main/sc/inc/table.hxx Fri Sep 7 09:27:03 2012
@@ -313,6 +313,7 @@ public:
void SetError( SCCOL nCol, SCROW nRow, sal_uInt16 nError);
void GetString( SCCOL nCol, SCROW nRow, String& rString );
+ void FillDPCache( ScDPTableDataCache * pCache, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
void GetInputString( SCCOL nCol, SCROW nRow, String& rString );
double GetValue( const ScAddress& rPos ) const
{
Modified: incubator/ooo/trunk/main/sc/source/core/data/column3.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/column3.cxx?rev=1381946&r1=1381945&r2=1381946&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/column3.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/column3.cxx Fri Sep 7 09:27:03 2012
@@ -31,6 +31,11 @@
#include <svl/zforlist.hxx>
#include <svl/zformat.hxx>
+#include "boost/tuple/tuple.hpp"
+#include <boost/function.hpp>
+#include "boost/lambda/bind.hpp"
+#include "boost/bind.hpp"
+#include "boost/lambda/lambda.hpp"
#include "scitems.hxx"
#include "column.hxx"
#include "cell.hxx"
@@ -48,9 +53,9 @@
#include "detfunc.hxx" // fuer Notizen bei DeleteRange
#include "postit.hxx"
#include "stringutil.hxx"
-
+#include "dpglobal.hxx"
+#include <dptablecache.hxx>
#include <com/sun/star/i18n/LocaleDataItem.hpp>
-
using ::com::sun::star::i18n::LocaleDataItem;
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
@@ -1724,6 +1729,73 @@ void ScColumn::GetString( SCROW nRow, St
rString.Erase();
}
+template<>
+void ScColumn::FillDPCacheT( long nDim, SCROW nStartRow, SCROW nEndRow, const boost::function<void(ScDPItemData*)> & rAddLabel, const boost::function<sal_Bool(long,ScDPItemData*)> & rAddData )
+{
+ SCROW nPattenRowStart = -1, nPatternRowEnd = -1;
+ SvNumberFormatter* pFormatter = pDocument->GetFormatTable();
+ sal_uLong nNumberFormat = 0;
+ sal_uLong nNumberFormatType = NUMBERFORMAT_NUMBER;
+ SCROW nCurRow = nStartRow;
+ ScDPItemData * pDPItemData = NULL;
+
+ if ( pItems )
+ {
+ SCSIZE nIndex;
+
+ for ( Search( nStartRow, nIndex ) ? void( ) : void(nIndex = nCount); nIndex < nCount && pItems[nIndex].nRow <= nEndRow; ++nIndex, ++nCurRow )
+ {
+ for( ; nCurRow < pItems[nIndex].nRow; nCurRow++ )
+ if( nCurRow == nStartRow )
+ rAddLabel( new ScDPItemData() );
+ else
+ rAddData( nDim, new ScDPItemData() );
+
+ if( nCurRow > nPatternRowEnd )
+ if( const ScPatternAttr* pPattern = pAttrArray ? pAttrArray->GetPatternRange( nPattenRowStart, nPatternRowEnd, nCurRow ) : NULL )
+ nNumberFormatType = pFormatter->GetType( nNumberFormat = pPattern->GetNumberFormat( pFormatter ) );
+ else
+ nNumberFormatType = NUMBERFORMAT_NUMBER, nNumberFormat = 0;
+
+ if( ScBaseCell* pCell = pItems[nIndex].pCell )
+ if( pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetErrCode() )
+ {
+ String str( GetStringFromCell( pCell, nNumberFormat, pFormatter ) );
+ sal_uInt8 bFlag = ScDPItemData::MK_ERR;
+ pDPItemData = new ScDPItemData( 0, str, 0.0, bFlag );
+ }
+ else if( pCell->HasValueData() )
+ {
+ double fVal = GetValueFromCell( pCell );
+ String str( GetStringFromCell( pCell, nNumberFormat, pFormatter ) );
+ sal_uInt8 bFlag = ScDPItemData::MK_VAL|ScDPItemData::MK_DATA|(ScDPItemData::MK_DATE * isDateFormat( nNumberFormatType ));
+ pDPItemData = new ScDPItemData( nNumberFormat, str, fVal, bFlag );
+ }
+ else if( !pCell->IsBlank() )
+ pDPItemData = new ScDPItemData( GetStringFromCell( pCell, nNumberFormat, pFormatter ) );
+ else
+ pDPItemData = new ScDPItemData();
+ else
+ pDPItemData = new ScDPItemData();
+
+ if( nCurRow == nStartRow )
+ rAddLabel( pDPItemData );
+ else
+ rAddData( nDim, pDPItemData );
+ }
+ }
+
+ for( ; nCurRow <= nEndRow; nCurRow++ )
+ if( nCurRow == nStartRow )
+ rAddLabel( new ScDPItemData() );
+ else
+ rAddData( nDim, new ScDPItemData() );
+}
+void ScColumn::FillDPCache( ScDPTableDataCache * pCache, long nDim, SCROW nStartRow, SCROW nEndRow )
+{
+ typedef sal_Bool(ScDPTableDataCache::*PFNAddData)( long, ScDPItemData* );
+ FillDPCacheT<boost::function<void(ScDPItemData*)>, boost::function<sal_Bool(long,ScDPItemData*)> >( nDim, nStartRow, nEndRow, boost::bind( &ScDPTableDataCache::AddLabel, pCache, _1 ), boost::bind( (PFNAddData)&ScDPTableDataCache::AddData<false>, pCache, _1, _2 ) );
+}
void ScColumn::GetInputString( SCROW nRow, String& rString ) const
{
Modified: incubator/ooo/trunk/main/sc/source/core/data/document.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/document.cxx?rev=1381946&r1=1381945&r2=1381946&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/document.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/document.cxx Fri Sep 7 09:27:03 2012
@@ -2683,6 +2683,11 @@ void ScDocument::GetString( SCCOL nCol,
rString.Erase();
}
+void ScDocument::FillDPCache( ScDPTableDataCache * pCache, SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow )
+{
+ if ( VALIDTAB(nTab) && pTab[nTab] )
+ pTab[nTab]->FillDPCache( pCache, nStartCol, nEndCol, nStartRow, nEndRow );
+}
void ScDocument::GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rString )
{
Modified: incubator/ooo/trunk/main/sc/source/core/data/dptablecache.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/dptablecache.cxx?rev=1381946&r1=1381945&r2=1381946&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/dptablecache.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/dptablecache.cxx Fri Sep 7 09:27:03 2012
@@ -49,6 +49,7 @@ using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::UNO_QUERY_THROW;
+
// -----------------------------------------------------------------------
namespace
{
@@ -474,7 +475,7 @@ void ScDPTableDataCache::AddRow( ScDPIte
else
{
for ( sal_uInt16 i = 0; i < nCount && i < mnColumnCount; i ++ )
- AddData( i, new ScDPItemData( pRow[i] ) );
+ AddData<true>( i, new ScDPItemData( pRow[i] ) );
}
}
@@ -548,17 +549,7 @@ bool ScDPTableDataCache::InitFromDoc( S
mpSourceData = new std::vector<SCROW>[ mnColumnCount ];
mpGlobalOrder = new std::vector<SCROW>[ mnColumnCount ];
mpIndexOrder = new std::vector<SCROW>[ mnColumnCount ];
- //check valid
- for ( SCROW nRow = nStartRow; nRow <= nEndRow; nRow ++ )
- {
- for ( sal_uInt16 nCol = nStartCol; nCol <= nEndCol; nCol++ )
- {
- if ( nRow == nStartRow )
- AddLabel( new ScDPItemData( pDoc, nRow, nCol, nDocTab ) );
- else
- AddData( nCol - nStartCol, new ScDPItemData( pDoc, nRow, nCol, nDocTab ) );
- }
- }
+ pDoc->FillDPCache( this, nDocTab, nStartCol, nEndCol, nStartRow, nEndRow );
return sal_True;
}
@@ -616,7 +607,7 @@ bool ScDPTableDataCache::InitFromDataBas
{
ScDPItemData * pNew = lcl_GetItemValue( xRow, aColTypes[nCol], nCol+1, rNullDate );
if ( pNew )
- AddData( nCol , pNew );
+ AddData<true>( nCol , pNew );
}
}
while (xRowSet->next());
@@ -872,6 +863,7 @@ bool ScDPTableDataCache::IsEmptyMember(
return !GetItemDataById( nColumn, GetItemDataId( nColumn, nRow, sal_False ) )->IsHasData();
}
+template< bool bCheckDate >
sal_Bool ScDPTableDataCache::AddData(long nDim, ScDPItemData* pitemData)
{
DBG_ASSERT( IsValid(), " IsValid() == false " );
@@ -880,8 +872,9 @@ sal_Bool ScDPTableDataCache::AddData(lon
sal_Bool bInserted = sal_False;
+ if( bCheckDate )
pitemData->SetDate( lcl_isDate( GetNumType( pitemData->nNumFormat ) ) );
-
+
if ( !lcl_Search( mpTableDataValues[nDim], mpGlobalOrder[nDim], *pitemData, nIndex ) )
{
mpTableDataValues[nDim].push_back( pitemData );
@@ -908,6 +901,14 @@ sal_Bool ScDPTableDataCache::AddData(lon
}
+void func_dummy()
+{
+ sal_Bool (ScDPTableDataCache::*pfnAddData)(long , ScDPItemData* )
+ = &ScDPTableDataCache::AddData<false>;
+
+ pfnAddData = (sal_Bool (ScDPTableDataCache::*)(long , ScDPItemData* ))&ScDPTableDataCache::AddData<true>;
+}
+
String ScDPTableDataCache::GetDimensionName( sal_uInt16 nColumn ) const
{
DBG_ASSERT( /* nColumn>=0 && */ nColumn < mrLabelNames.size()-1 , "ScDPTableDataCache::GetDimensionName");
@@ -920,6 +921,7 @@ String ScDPTableDataCache::GetDimensionN
return String();
}
+
void ScDPTableDataCache::AddLabel(ScDPItemData *pData)
{
DBG_ASSERT( IsValid(), " IsValid() == false " );
@@ -1135,4 +1137,3 @@ long ScDPTableDataCache::GetId() const
{
return mnID;
}
-
Modified: incubator/ooo/trunk/main/sc/source/core/data/table2.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/core/data/table2.cxx?rev=1381946&r1=1381945&r2=1381946&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/core/data/table2.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/core/data/table2.cxx Fri Sep 7 09:27:03 2012
@@ -1054,6 +1054,13 @@ void ScTable::GetString( SCCOL nCol, SCR
rString.Erase();
}
+void ScTable::FillDPCache( ScDPTableDataCache * pCache, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow )
+{
+ for ( sal_uInt16 nCol = nStartCol; nCol <= nEndCol; nCol++ )
+ if( ValidCol( nCol ) )
+ aCol[nCol].FillDPCache( pCache, nCol - nStartCol, nStartRow, nEndRow );
+}
+
void ScTable::GetInputString( SCCOL nCol, SCROW nRow, String& rString )
{