Index: boost/prj/d.lst =================================================================== --- boost/prj/d.lst (revision 1381908) +++ boost/prj/d.lst (working copy) @@ -310,3 +310,11 @@ ..\%__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 + Index: sc/inc/cell.hxx =================================================================== --- sc/inc/cell.hxx (revision 1381841) +++ sc/inc/cell.hxx (working copy) @@ -38,6 +38,8 @@ #include #include "scdllapi.h" +#include + #define USE_MEMPOOL #define TEXTWIDTH_DIRTY 0xffff @@ -497,6 +499,38 @@ }; // ============================================================================ +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(pCell), nFormat, strResult, &pColor, *(pFormatter) ); + return strResult; + } + else + return String(); +} + #endif Index: sc/inc/column.hxx =================================================================== --- sc/inc/column.hxx (revision 1381841) +++ sc/inc/column.hxx (working copy) @@ -60,6 +60,7 @@ struct ScFunctionData; struct ScLineFlags; struct ScMergePatternState; +class ScDPTableDataCache; class ScFlatBoolRowSegments; #define COLUMN_DELTA 4 @@ -360,6 +361,9 @@ 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 ); Index: sc/inc/document.hxx =================================================================== --- sc/inc/document.hxx (revision 1381841) +++ sc/inc/document.hxx (working copy) @@ -1876,6 +1876,8 @@ 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 ) { Index: sc/inc/dpglobal.hxx =================================================================== --- sc/inc/dpglobal.hxx (revision 1381841) +++ sc/inc/dpglobal.hxx (working copy) @@ -196,4 +196,6 @@ bool ChkDPTableOverlap( ScDocument *pDestDoc, std::list & 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 Index: sc/inc/dptablecache.hxx =================================================================== --- sc/inc/dptablecache.hxx (revision 1381841) +++ sc/inc/dptablecache.hxx (working copy) @@ -107,8 +107,10 @@ 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 Index: sc/inc/table.hxx =================================================================== --- sc/inc/table.hxx (revision 1381841) +++ sc/inc/table.hxx (working copy) @@ -313,6 +313,7 @@ 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 { Index: sc/source/core/data/column3.cxx =================================================================== --- sc/source/core/data/column3.cxx (revision 1381908) +++ sc/source/core/data/column3.cxx (working copy) @@ -31,6 +31,11 @@ #include #include +#include "boost/tuple/tuple.hpp" +#include +#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 #include - using ::com::sun::star::i18n::LocaleDataItem; using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -1724,7 +1729,74 @@ rString.Erase(); } +template<> +void ScColumn::FillDPCacheT( long nDim, SCROW nStartRow, SCROW nEndRow, const boost::function & rAddLabel, const boost::function & 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 >( nDim, nStartRow, nEndRow, boost::bind( &ScDPTableDataCache::AddLabel, pCache, _1 ), boost::bind( (PFNAddData)&ScDPTableDataCache::AddData, pCache, _1, _2 ) ); +} + void ScColumn::GetInputString( SCROW nRow, String& rString ) const { SCSIZE nIndex; Index: sc/source/core/data/document.cxx =================================================================== --- sc/source/core/data/document.cxx (revision 1381908) +++ sc/source/core/data/document.cxx (working copy) @@ -2683,6 +2683,11 @@ 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 ) { Index: sc/source/core/data/dptablecache.cxx =================================================================== --- sc/source/core/data/dptablecache.cxx (revision 1381908) +++ sc/source/core/data/dptablecache.cxx (working copy) @@ -49,6 +49,7 @@ 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 @@ else { for ( sal_uInt16 i = 0; i < nCount && i < mnColumnCount; i ++ ) - AddData( i, new ScDPItemData( pRow[i] ) ); + AddData( i, new ScDPItemData( pRow[i] ) ); } } @@ -548,17 +549,7 @@ mpSourceData = new std::vector[ mnColumnCount ]; mpGlobalOrder = new std::vector[ mnColumnCount ]; mpIndexOrder = new std::vector[ 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 @@ { ScDPItemData * pNew = lcl_GetItemValue( xRow, aColTypes[nCol], nCol+1, rNullDate ); if ( pNew ) - AddData( nCol , pNew ); + AddData( nCol , pNew ); } } while (xRowSet->next()); @@ -872,6 +863,7 @@ 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 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 @@ } +void func_dummy() +{ + sal_Bool (ScDPTableDataCache::*pfnAddData)(long , ScDPItemData* ) + = &ScDPTableDataCache::AddData; + + pfnAddData = (sal_Bool (ScDPTableDataCache::*)(long , ScDPItemData* ))&ScDPTableDataCache::AddData; +} + String ScDPTableDataCache::GetDimensionName( sal_uInt16 nColumn ) const { DBG_ASSERT( /* nColumn>=0 && */ nColumn < mrLabelNames.size()-1 , "ScDPTableDataCache::GetDimensionName"); @@ -920,6 +921,7 @@ return String(); } + void ScDPTableDataCache::AddLabel(ScDPItemData *pData) { DBG_ASSERT( IsValid(), " IsValid() == false " ); @@ -1134,5 +1136,4 @@ long ScDPTableDataCache::GetId() const { return mnID; -} - +} \ No newline at end of file Index: sc/source/core/data/table2.cxx =================================================================== --- sc/source/core/data/table2.cxx (revision 1381908) +++ sc/source/core/data/table2.cxx (working copy) @@ -1054,7 +1054,14 @@ 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 ) { if (ValidColRow(nCol,nRow))