Index: sc/inc/compiler.hrc
===================================================================
RCS file: /cvs/sc/sc/inc/compiler.hrc,v
retrieving revision 1.10.38.5
diff -u -w -p -r1.10.38.5 compiler.hrc
--- sc/inc/compiler.hrc	28 Nov 2005 16:45:45 -0000	1.10.38.5
+++ sc/inc/compiler.hrc	16 Feb 2006 20:05:08 -0000
@@ -363,9 +363,10 @@
 #define	SC_OPCODE_CELL				385
 #define	SC_OPCODE_ISPMT				386
 #define	SC_OPCODE_HYPERLINK			387
-#define	SC_OPCODE_END_2_PAR			388
+#define SC_OPCODE_GET_PIVOT_DATA	388
+#define	SC_OPCODE_END_2_PAR			389
 
-#define SC_OPCODE_LAST_OPCODE_ID    387      /* letzter OpCode */
+#define SC_OPCODE_LAST_OPCODE_ID    388      /* letzter OpCode */
 
 /*** Interna ***/
 #define	SC_OPCODE_INTERNAL_BEGIN   9995
Index: sc/inc/document.hxx
===================================================================
RCS file: /cvs/sc/sc/inc/document.hxx,v
retrieving revision 1.88.22.5
diff -u -w -p -r1.88.22.5 document.hxx
--- sc/inc/document.hxx	1 Dec 2005 19:52:17 -0000	1.88.22.5
+++ sc/inc/document.hxx	16 Feb 2006 20:05:08 -0000
@@ -471,6 +471,7 @@ SC_DLLPUBLIC	ScDBCollection*	GetDBCollec
 
 	ScDPCollection*		GetDPCollection();
 	ScDPObject*			GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
+	ScDPObject*			GetDPAtBlock( const ScRange & rBlock ) const;
 
 	ScPivotCollection*	GetPivotCollection() const;
 	void				SetPivotCollection(ScPivotCollection* pNewPivotCollection);
Index: sc/inc/dpobject.hxx
===================================================================
RCS file: /cvs/sc/sc/inc/dpobject.hxx,v
retrieving revision 1.11.22.2
diff -u -w -p -r1.11.22.2 dpobject.hxx
--- sc/inc/dpobject.hxx	2 Nov 2005 02:41:33 -0000	1.11.22.2
+++ sc/inc/dpobject.hxx	16 Feb 2006 20:05:08 -0000
@@ -52,11 +52,14 @@
 #include "collect.hxx"
 #endif
 
+#ifndef SC_DPOUTPUT_HXX
+#include "dpoutput.hxx"
+#endif
+
 #ifndef _COM_SUN_STAR_SHEET_XDIMENSIONSSUPPLIER_HPP_
 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
 #endif
 
-
 //------------------------------------------------------------------
 
 
@@ -173,6 +176,8 @@ public:
     BOOL                IsDuplicated( long nDim );
     long                GetDimCount();
 	void				GetPositionData( ScDPPositionData& rData, const ScAddress& rPos );
+	BOOL				GetPivotData( ScDPGetPivotDataField& rTarget, /* returns result */
+									  const std::vector< ScDPGetPivotDataField >& rFilters );
 	long				GetHeaderDim( const ScAddress& rPos, USHORT& rOrient );
 	BOOL				GetHeaderDrag( const ScAddress& rPos, BOOL bMouseLeft, BOOL bMouseTop,
 										long nDragDim,
Index: sc/inc/dpoutput.hxx
===================================================================
RCS file: /cvs/sc/sc/inc/dpoutput.hxx,v
retrieving revision 1.7
diff -u -w -p -r1.7 dpoutput.hxx
--- sc/inc/dpoutput.hxx	8 Sep 2005 17:35:15 -0000	1.7
+++ sc/inc/dpoutput.hxx	16 Feb 2006 20:05:08 -0000
@@ -56,6 +56,10 @@
 #include "address.hxx"
 #endif
 
+#ifndef __SGI_STL_VECTOR
+#include <vector>
+#endif
+
 class Rectangle;
 class SvStream;
 class ScDocument;
@@ -77,6 +81,15 @@ struct ScDPPositionData
 	ScDPPositionData() { nDimension = nHierarchy = nLevel = -1; nFlags = 0; }	// invalid
 };
 
+struct ScDPGetPivotDataField
+{
+	String maFieldName;
+
+	bool   mbValIsStr;
+	String maValStr;
+	double mnValNum;
+};
+
 
 
 class ScDPOutput			//! name???
@@ -143,6 +156,8 @@ public:
 	BOOL			HasError();			// range overflow or exception from source
 
 	void			GetPositionData( ScDPPositionData& rData, const ScAddress& rPos );
+	BOOL			GetPivotData( ScDPGetPivotDataField& rTarget, /* returns result */
+								  const std::vector< ScDPGetPivotDataField >& rFilters );
 	long			GetHeaderDim( const ScAddress& rPos, USHORT& rOrient );
 	BOOL			GetHeaderDrag( const ScAddress& rPos, BOOL bMouseLeft, BOOL bMouseTop,
 									long nDragDim,
Index: sc/inc/opcode.hxx
===================================================================
RCS file: /cvs/sc/sc/inc/opcode.hxx,v
retrieving revision 1.12.38.4
diff -u -w -p -r1.12.38.4 opcode.hxx
--- sc/inc/opcode.hxx	28 Nov 2005 16:01:33 -0000	1.12.38.4
+++ sc/inc/opcode.hxx	16 Feb 2006 20:05:08 -0000
@@ -377,6 +377,7 @@ enum OpCodeEnum
 		ocDecimal			= SC_OPCODE_DECIMAL,
 		ocConvert			= SC_OPCODE_CONVERT,
 		ocRoman				= SC_OPCODE_ROMAN,
+        ocGetPivotData      = SC_OPCODE_GET_PIVOT_DATA,
         ocHyperLink         = SC_OPCODE_HYPERLINK,
         ocBahtText          = SC_OPCODE_BAHTTEXT,
 		ocEnd2Par			= SC_OPCODE_END_2_PAR,
Index: sc/inc/scfuncs.hrc
===================================================================
RCS file: /cvs/sc/sc/inc/scfuncs.hrc,v
retrieving revision 1.8.38.4
diff -u -w -p -r1.8.38.4 scfuncs.hrc
--- sc/inc/scfuncs.hrc	28 Nov 2005 16:00:48 -0000	1.8.38.4
+++ sc/inc/scfuncs.hrc	16 Feb 2006 20:05:09 -0000
@@ -299,6 +299,7 @@
 #define HID_FUNC_TABELLE			(HID_SC_FUNC_DUMMY+(ID_FUNCTION_GRP_TABLE*ID_FUNCTION_OFFSET)+18)
 #define HID_FUNC_TABELLEN			(HID_SC_FUNC_DUMMY+(ID_FUNCTION_GRP_TABLE*ID_FUNCTION_OFFSET)+19)
 #define HID_FUNC_HYPERLINK			(HID_SC_FUNC_DUMMY+(ID_FUNCTION_GRP_TABLE*ID_FUNCTION_OFFSET)+20)
+#define HID_FUNC_GETPIVOTDATA		(HID_SC_FUNC_DUMMY+(ID_FUNCTION_GRP_TABLE*ID_FUNCTION_OFFSET)+21)
 
 #define HID_FUNC_CODE				(HID_SC_FUNC_DUMMY+(ID_FUNCTION_GRP_TEXT*ID_FUNCTION_OFFSET)+1)
 #define HID_FUNC_DM					(HID_SC_FUNC_DUMMY+(ID_FUNCTION_GRP_TEXT*ID_FUNCTION_OFFSET)+2)
Index: sc/source/core/data/documen3.cxx
===================================================================
RCS file: /cvs/sc/sc/source/core/data/documen3.cxx,v
retrieving revision 1.29.22.3
diff -u -w -p -r1.29.22.3 documen3.cxx
--- sc/source/core/data/documen3.cxx	1 Dec 2005 19:52:19 -0000	1.29.22.3
+++ sc/source/core/data/documen3.cxx	16 Feb 2006 20:05:10 -0000
@@ -271,6 +271,21 @@ ScDPObject* ScDocument::GetDPAtCursor(SC
 	return NULL;
 }
 
+ScDPObject*	ScDocument::GetDPAtBlock( const ScRange & rBlock ) const
+{
+	if (!pDPCollection)
+		return NULL;
+
+	/* Walk the collection in reverse order to get something of an
+	 * approximation of MS Excels 'most recent' effect. */
+	USHORT i = pDPCollection->GetCount();
+	while ( i-- > 0 )
+		if ( (*pDPCollection)[i]->GetOutRange().In( rBlock ) )
+			return (*pDPCollection)[i];
+
+	return NULL;
+}
+
 ScPivotCollection* ScDocument::GetPivotCollection() const
 {
 	return pPivotCollection;
Index: sc/source/core/data/dpobject.cxx
===================================================================
RCS file: /cvs/sc/sc/source/core/data/dpobject.cxx,v
retrieving revision 1.17
diff -u -w -p -r1.17 dpobject.cxx
--- sc/source/core/data/dpobject.cxx	28 Sep 2005 11:32:07 -0000	1.17
+++ sc/source/core/data/dpobject.cxx	16 Feb 2006 20:05:10 -0000
@@ -800,6 +800,15 @@ void ScDPObject::GetPositionData( ScDPPo
 	pOutput->GetPositionData( rData, rPos );
 }
 
+// Returns TRUE on success and stores the result in rTarget
+BOOL ScDPObject::GetPivotData( ScDPGetPivotDataField& rTarget,
+							   const std::vector< ScDPGetPivotDataField >& rFilters )
+{
+	CreateOutput();				// create xSource and pOutput if not already done
+
+	return pOutput->GetPivotData( rTarget, rFilters );
+}
+
 BOOL ScDPObject::IsFilterButton( const ScAddress& rPos )
 {
 	CreateOutput();				// create xSource and pOutput if not already done
Index: sc/source/core/data/dpoutput.cxx
===================================================================
RCS file: /cvs/sc/sc/source/core/data/dpoutput.cxx,v
retrieving revision 1.11
diff -u -w -p -r1.11 dpoutput.cxx
--- sc/source/core/data/dpoutput.cxx	8 Sep 2005 18:23:13 -0000	1.11
+++ sc/source/core/data/dpoutput.cxx	16 Feb 2006 20:05:10 -0000
@@ -986,6 +986,221 @@ void ScDPOutput::GetPositionData( ScDPPo
 	}
 }
 
+#undef DEBUG_GETPIVOTTABLE
+#ifdef DEBUG_GETPIVOTTABLE
+#include <stdio.h>
+static const sal_Char* dbg_dump( const ByteString& rStr)
+{
+	static ByteString aStr;
+	aStr = rStr;
+	aStr.Append(static_cast< char >(0));
+	return aStr.GetBuffer();
+}
+static const sal_Char* dbg_dump( const UniString& rStr)
+{
+	return dbg_dump(ByteString(rStr, RTL_TEXTENCODING_UTF8));
+}
+
+static void lcl_dumpOutputLevel( const char* name, char id_char,
+								 long n, const ScDPOutLevelData* pFields )
+{
+	fprintf(stderr, "=================================\n");
+	fprintf(stderr, "#%s = %03ld\n", name, n);
+	for (long i=0; i<n; i++)
+	{
+		fprintf(stderr, "\t%c%03ld) : %s\n", id_char, i,
+				dbg_dump( pFields[i].aCaption ));
+
+		const uno::Sequence<sheet::MemberResult> rSequence = pFields[i].aResult;
+		const sheet::MemberResult* pArray = rSequence.getConstArray();
+		for (long j = 0 ; j < rSequence.getLength(); j++)
+		{
+			fprintf(stderr, "\t\t%3ld) : \'%s\' %lx\n", j,
+					dbg_dump( pArray[j].Name ), rSequence[j].Flags );
+		}
+	}
+}
+#endif
+
+// Returns TRUE if the filter matched
+static BOOL lcl_getPivotDataApplyFilter( const ScDPGetPivotDataField & rFilter,
+										 long n, const ScDPOutLevelData* pFields,
+										 std::vector< BOOL >& rResult )
+{
+	for( long int i=0 ; i < n ; i++ )
+	{
+		// WORRY : Can Caption be different from Name ?
+		if( rFilter.maFieldName == pFields[i].aCaption)
+		{
+			BOOL	bPrev = FALSE;
+
+			const uno::Sequence<sheet::MemberResult> rSequence = pFields[i].aResult;
+			const sheet::MemberResult* pArray = rSequence.getConstArray();
+
+			DBG_ASSERT( rResult.size() == rSequence.getLength(),
+						"Number of fields do not match result count" );
+
+			for( signed long int j=0 ; j < rResult.size(); j++ )
+			{
+				if( rResult[j] )
+				{
+					if( rSequence[j].Flags & sheet::MemberResultFlags::SUBTOTAL )
+						rResult[j] = FALSE;
+					else if( rSequence[j].Flags & sheet::MemberResultFlags::CONTINUE )
+						rResult[j] = bPrev;
+					else if( rSequence[j].Flags & sheet::MemberResultFlags::HASMEMBER )
+						rResult[j] = bPrev =
+							( String( pArray[j].Name ) == rFilter.maValStr );
+				}
+			}
+			return TRUE;
+		}
+	}
+
+	return FALSE;
+}
+
+// Returns TRUE on success and stores the result in rTarget
+// Returns FALSE if rFilters or rTarget describes something that is not visible
+BOOL ScDPOutput::GetPivotData( ScDPGetPivotDataField& rTarget,
+							   const std::vector< ScDPGetPivotDataField >& rFilters )
+{
+	CalcSizes();
+
+#ifdef DEBUG_GETPIVOTTABLE
+	{
+		lcl_dumpOutputLevel ("PageHeaders", 'P', nPageFieldCount, pPageFields);
+		lcl_dumpOutputLevel ("ColHeaders", 'C', nColFieldCount, pColFields);
+		lcl_dumpOutputLevel ("RowHeaders", 'R', nRowFieldCount, pRowFields);
+
+		fprintf(stderr, "=================================\n");
+		fprintf(stderr, "#Rows = %03ld\n", nRowCount);
+		const uno::Sequence<sheet::DataResult>* pRowAry = aData.getConstArray();
+		for (long nRow=0; nRow<nRowCount; nRow++)
+		{
+			const sheet::DataResult* pColAry = pRowAry[nRow].getConstArray();
+			long nThisColCount = pRowAry[nRow].getLength();
+			fprintf(stderr, "R %03ld\n", nRow);
+			for (long nCol=0; nCol<nThisColCount; nCol++)
+			{
+				const sheet::DataResult& rData = pColAry[nCol];
+				const long nFlags = rData.Flags;
+
+				fprintf(stderr, "\tC%03ld) %4lx ->", nCol, nFlags);
+
+				if ( nFlags & sheet::DataResultFlags::ERROR )
+				{
+					fprintf(stderr, "ERR" );
+				}
+				else if ( nFlags & (sheet::DataResultFlags::HASDATA |
+									sheet::DataResultFlags::SUBTOTAL ))
+				{
+					fprintf(stderr, "%g", rData.Value );
+				}
+				fprintf(stderr, "\n" );
+			}
+		}
+	}
+#endif
+
+	std::vector< BOOL >	aIncludeCol( nColCount, TRUE );
+	std::vector< BOOL >	aIncludeRow( nRowCount, TRUE );
+	BOOL aFilterApplied;
+	signed long int i;
+
+	for( long int nFilter=0 ; nFilter < rFilters.size() ; nFilter++ )
+	{
+		aFilterApplied = FALSE;
+		for( long int i=0 ; i < nPageFieldCount ; i++ )
+		{
+			// WORRY : Can Caption be different from Name ?
+			if( rFilters[nFilter].maFieldName == pPageFields[i].aCaption )
+			{
+				signed long int j;
+
+				DBG_ASSERT( aFilters[i].mbValIsStr , "Numeric Page filter ?" );
+
+				const uno::Sequence<sheet::MemberResult> rSequence = pPageFields[i].aResult;
+				const sheet::MemberResult* pArray = rSequence.getConstArray();
+				for( j = rSequence.getLength(); j-- > 0 ; )
+				{
+					if( String( pArray[j].Name) == rFilters[nFilter].maValStr )
+						break;
+				}
+
+				// We operate on VISIBLE data only.
+				// Selecting a hidden page is an error
+				if( j < 0 )
+					return FALSE;
+				aFilterApplied = TRUE;
+				break;
+			}
+		}
+		if( aFilterApplied )
+			continue;
+
+		if( !lcl_getPivotDataApplyFilter( rFilters[nFilter], nColFieldCount,
+										 pColFields, aIncludeCol ) &&
+			!lcl_getPivotDataApplyFilter( rFilters[nFilter], nRowFieldCount,
+										 pRowFields, aIncludeRow ) )
+		{
+			// All filter fields must be used
+			return FALSE;
+		}
+	}
+
+	// ensure that at least 1 col is visible
+	for( i = aIncludeCol.size() ; i-- > 0 ; )
+	{
+		if( aIncludeCol[i] )
+			break;
+	}
+	if( i < 0 )
+		return FALSE;
+
+	// ensure that at least 1 row is visible
+	for( i = aIncludeRow.size() ; i-- > 0 ; )
+	{
+		if( aIncludeRow[i] )
+			break;
+	}
+	if( i < 0 )
+		return FALSE;
+
+	double accum = 0.;
+	std::vector< BOOL >	aRowPrev( nRowFieldCount, TRUE );
+
+	const uno::Sequence<sheet::DataResult>* pRowAry = aData.getConstArray();
+	for (long nRow=0; nRow<nRowCount; nRow++)
+	{
+		if( aIncludeRow[nRow] )
+		{
+			const sheet::DataResult* pColAry = pRowAry[nRow].getConstArray();
+			long nThisColCount = pRowAry[nRow].getLength();
+			for (long nCol=0; nCol<nThisColCount; nCol++)
+			{
+				if( aIncludeCol[nCol] )
+				{
+					const sheet::DataResult& rData = pColAry[nCol];
+
+					// If there are no filters for cols or no filters for rows
+					// then subtotals still appear
+					if( (rData.Flags & (sheet::DataResultFlags::HASDATA|
+										sheet::DataResultFlags::SUBTOTAL|
+										sheet::DataResultFlags::ERROR)) == sheet::DataResultFlags::HASDATA )
+					{
+						accum += rData.Value;
+					}
+				}
+			}
+		}
+	}
+
+	rTarget.mbValIsStr = FALSE;
+	rTarget.mnValNum = accum;
+	return TRUE;
+}
+
 BOOL ScDPOutput::IsFilterButton( const ScAddress& rPos )
 {
 	SCCOL nCol = rPos.Col();
Index: sc/source/core/inc/interpre.hxx
===================================================================
RCS file: /cvs/sc/sc/source/core/inc/interpre.hxx,v
retrieving revision 1.23.20.2
diff -u -w -p -r1.23.20.2 interpre.hxx
--- sc/source/core/inc/interpre.hxx	28 Nov 2005 16:13:29 -0000	1.23.20.2
+++ sc/source/core/inc/interpre.hxx	16 Feb 2006 20:05:10 -0000
@@ -452,6 +452,7 @@ BOOL SetSbxVariable( SbxVariable* pVar, 
 void ScErrorType();
 void ScDBArea();
 void ScColRowNameAuto();
+void ScGetPivotData();
 void ScHyperLink();
 void ScBahtText();
 void ScCalcTeam();
Index: sc/source/core/src/compiler.src
===================================================================
RCS file: /cvs/sc/sc/source/core/src/compiler.src,v
retrieving revision 1.47.22.2
diff -u -w -p -r1.47.22.2 compiler.src
--- sc/source/core/src/compiler.src	28 Nov 2005 16:14:14 -0000	1.47.22.2
+++ sc/source/core/src/compiler.src	16 Feb 2006 20:05:10 -0000
@@ -1673,6 +1673,11 @@ Resource RID_SC_FUNCTION_NAMES
 		Text [ de ] = "RÖMISCH";
 		Text [ en-US ] = "ROMAN";
 	};
+	String SC_OPCODE_GET_PIVOT_DATA
+	{
+		Text [ de ] = "GETPIVOTDATA";
+		Text [ en-US ] = "GETPIVOTDATA" ;
+	};
 	String SC_OPCODE_HYPERLINK
 	{
 		Text [ de ] = "HYPERLINK";
@@ -1979,6 +1984,7 @@ Resource RID_SC_FUNCTION_NAMES_ENGLISH
 	String SC_OPCODE_CONVERT { Text = "CONVERT" ; };
 	String SC_OPCODE_ROMAN { Text = "ROMAN" ; };
 	String SC_OPCODE_ARABIC { Text = "ARABIC" ; };
+	String SC_OPCODE_GET_PIVOT_DATA { Text = "GETPIVOTDATA" ; };
 	String SC_OPCODE_HYPERLINK { Text = "HYPERLINK" ; };
     String SC_OPCODE_BAHTTEXT { Text = "BAHTTEXT" ; };
 };
Index: sc/source/core/tool/interpr2.cxx
===================================================================
RCS file: /cvs/sc/sc/source/core/tool/interpr2.cxx,v
retrieving revision 1.25
diff -u -w -p -r1.25 interpr2.cxx
--- sc/source/core/tool/interpr2.cxx	21 Oct 2005 11:53:56 -0000	1.25
+++ sc/source/core/tool/interpr2.cxx	16 Feb 2006 20:05:10 -0000
@@ -62,6 +62,7 @@
 #include "unitconv.hxx"
 #include "globstr.hrc"
 #include "hints.hxx"
+#include "dpobject.hxx"
 
 // STATIC DATA -----------------------------------------------------------
 
@@ -2282,6 +2283,109 @@ void ScInterpreter::ScArabic()
 	}
 }
 
+// TODO
+// 	1) check need for array iteration in filter name/values
+// 	2) check error when passing double as target field (GetString converts double -> str
+// 	3) check handling of names as src pivot range
+void ScInterpreter::ScGetPivotData()
+{
+	BYTE nParamCount = GetByte();
+
+    if ( MustHaveParamCount( nParamCount, 2, 30 ) )
+	{
+		// there must be an even number of args
+		// 		target, ref, then field/item pairs
+		if( (nParamCount % 2) == 1)
+			goto failed;
+
+		unsigned int i = nParamCount / 2 - 1;
+		std::vector< ScDPGetPivotDataField > aFilters( i );
+
+		while( i-- > 0 )
+		{
+			switch (GetStackType())
+			{
+			case svDouble :
+#if 0
+				// Force everything to strings for now because the DPOutput
+				// uses pure strings
+				aFilters[i].mbValIsStr = FALSE;
+				aFilters[i].mnValNum = GetDouble();
+				break;
+#endif
+				// FALL THROUGH
+
+			case svString:
+				aFilters[i].mbValIsStr = TRUE;
+				aFilters[i].maValStr = GetString();
+				break;
+
+			case svSingleRef :
+				{
+					ScAddress aAddr;
+					PopSingleRef( aAddr );
+					const ScBaseCell* pCell = GetCell( aAddr );
+#if 0
+					if ( (aFilters[i].mbValIsStr = !HasCellValueData(pCell)) )
+						GetCellString(aFilters[i].maValStr, pCell);
+					else
+						aFilters[i].mnValNum = GetCellValue( aAddr, pCell );
+#else
+					aFilters[i].mbValIsStr = TRUE;
+					GetCellString(aFilters[i].maValStr, pCell);
+#endif
+				}
+				break;
+
+			// case svDoubleRef : TODO ?? Do we need implicit iteration support ?
+			default :
+				SetError( errIllegalParameter );
+				return;
+			}
+			aFilters[i].maFieldName = GetString();
+		}
+
+		ScDPGetPivotDataField aTarget; /* returns result */
+		ScRange aBlock;
+
+		switch ( GetStackType() )
+		{
+		case svDoubleRef :
+			PopDoubleRef( aBlock );
+			break;
+
+		case svSingleRef :
+			{
+				ScAddress aAddr;
+				PopSingleRef( aAddr );
+				aBlock = aAddr;
+				break;
+			}
+		default:
+			goto failed;
+		}
+		// NOTE : MS Excel docs claim to use the 'most recent' which is not
+		// exactly the same as what we do in ScDocument::GetDPAtBlock
+		// However we do need to use GetDPABlock
+		ScDPObject *pSource = pDok->GetDPAtBlock ( aBlock );
+		if( NULL == pSource)
+			goto failed;
+ 
+        aTarget.maFieldName = GetString();
+
+		if(	pSource->GetPivotData( aTarget, aFilters ) )
+		{
+			if( aTarget.mbValIsStr )
+				PushString( aTarget.maValStr );
+			else
+				PushDouble( aTarget.mnValNum );
+			return;
+		}
+	}
+
+failed :
+	SetError( errNoRef );
+}
 
 void ScInterpreter::ScHyperLink()
 {
Index: sc/source/core/tool/interpr4.cxx
===================================================================
RCS file: /cvs/sc/sc/source/core/tool/interpr4.cxx,v
retrieving revision 1.38.36.2
diff -u -w -p -r1.38.36.2 interpr4.cxx
--- sc/source/core/tool/interpr4.cxx	28 Nov 2005 16:17:20 -0000	1.38.36.2
+++ sc/source/core/tool/interpr4.cxx	16 Feb 2006 20:05:11 -0000
@@ -3510,6 +3510,7 @@ StackVar ScInterpreter::Interpret()
                 case ocRoman            : ScRoman();                    break;
                 case ocArabic           : ScArabic();                   break;
                 case ocInfo             : ScInfo();                     break;
+                case ocGetPivotData     : ScGetPivotData();             break;
                 case ocHyperLink        : ScHyperLink();                break;
                 case ocBahtText         : ScBahtText();                 break;
                 case ocAnswer           : ScAnswer();                   break;
Index: sc/source/filter/excel/xlformula.cxx
===================================================================
RCS file: /cvs/sc/sc/source/filter/excel/xlformula.cxx,v
retrieving revision 1.10.20.5
diff -u -w -p -r1.10.20.5 xlformula.cxx
--- sc/source/filter/excel/xlformula.cxx	28 Nov 2005 18:01:08 -0000	1.10.20.5
+++ sc/source/filter/excel/xlformula.cxx	16 Feb 2006 20:05:11 -0000
@@ -318,7 +318,8 @@ static const XclFunctionInfo saFuncTable
     { ocCountIf,            346,    2,  2,  V, { R, V } },
     { ocCountEmptyCells,    347,    1,  1,  V, { R } },
     { ocISPMT,              350,    4,  4,  V, { V } },
-    { ocRoman,              354,    1,  2,  V, { V } }
+    { ocRoman,              354,    1,  2,  V, { V } },
+    { ocGetPivotData,       358,    2,  30, V, { V, R, V } }
 };
 
 #define EXC_FUNCNAME_PREFIX "_xlfn."
Index: sc/source/ui/src/scfuncs.src
===================================================================
RCS file: /cvs/sc/sc/source/ui/src/scfuncs.src,v
retrieving revision 1.84.22.2
diff -u -w -p -r1.84.22.2 scfuncs.src
--- sc/source/ui/src/scfuncs.src	28 Nov 2005 16:06:41 -0000	1.84.22.2
+++ sc/source/ui/src/scfuncs.src	16 Feb 2006 20:05:13 -0000
@@ -9957,6 +9957,100 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
 			Text [ x-comment ] = " ";
 		};
 	};
+    Resource SC_OPCODE_GET_PIVOT_DATA
+	{
+		String 1 // Description
+		{
+			Text [ en-US ] = "Extracts value(s) from a DataPilot.";
+		Text[ de ] = "Werte aus DataPilot extrahieren.";
+		Text[ es ] = "Extrae valores de un piloto de datos.";
+		Text[ fr ] = "Extrait les valeurs d'un pilote de données.";
+		Text[ it ] = "Estrai valore/i da un DataPilot.";
+		Text[ ja ] = "データパイロットから値を抽出します。";
+		Text[ pt-BR ] = "Extrai valor(es) de um DataPilot.";
+		Text[ zh-CN ] = "从 DataPilot 中抽取值。";
+		Text[ zh-TW ] = "擷取 DataPilot 的值。";
+		};
+		ExtraData =
+		{
+			ID_FUNCTION_GRP_TABLE;
+			U2S( HID_FUNC_GETPIVOTDATA );
+			VAR_ARGS+2;      0;	0;	1;
+		};
+		String 2 // Name of Parameter 1
+		{
+			Text [ en-US ] = "Target Field";
+		Text[ de ] = "Zielfeld";
+		Text[ es ] = "Campo de destino";
+		Text[ fr ] = "Champ cible";
+		Text[ it ] = "Campo di destinazione";
+		Text[ ja ] = "ターゲットフィールド";
+		Text[ pt-BR ] = "Campo de Destino";
+		Text[ zh-CN ] = "目标字段";
+		Text[ zh-TW ] = "目標欄位";
+		};
+		String 3 // Description of Parameter 1
+		{
+			Text [ en-US ] = "The name of the data pilot field to extract.";
+		Text[ de ] = "Der Name des zu extrahierenden DataPilot-Felds.";
+		Text[ es ] = "Nombre del campo del piloto de datos que se debe extraer.";
+		Text[ fr ] = "Nom du champ de pilote de données à extraire.";
+		Text[ it ] = "Nome del campo data pilot da estrarre.";
+		Text[ ja ] = "抽出するデータパイロットフィールドの名前。";
+		Text[ pt-BR ] = "Nome do campo do data pilot a extrair.";
+		Text[ zh-CN ] = "要抽取的 Data Pilot 字段的名称";
+		Text[ zh-TW ] = "進行擷取的 Data Pilot 欄位名稱。";
+		};
+		String 4 // Name of Parameter 2
+		{
+			Text [ en-US ] = "Data Pilot";
+		Text[ de ] = "DataPilot";
+		Text[ es ] = "Piloto de datos";
+		Text[ fr ] = "Pilote de données";
+		Text[ it ] = "Data Pilot";
+		Text[ ja ] = "データパイロット";
+		Text[ pt-BR ] = "Data Pilot";
+		Text[ zh-CN ] = "Data Pilot";
+		Text[ zh-TW ] = "Data Pilot";
+		};
+		String 5 // Description of Parameter 2
+		{
+			Text [ en-US ] = "a reference to a cell or range in Data Pilot with the source data.";
+		Text[ de ] = "eine Referenz auf eine Zelle oder einen Bereich in DataPilot mit den Quelldaten.";
+		Text[ es ] = "referencia a una celda o rango en el piloto de datos con los datos de origen.";
+		Text[ fr ] = "référence à une cellule ou à une plage du pilote contenant les données sources.";
+		Text[ it ] = "Riferiento a una cella o a un intervallo di celle in Data Pilot con i dati di origine.";
+		Text[ ja ] = "ソースデータが記戴されているデータパイロットのセルまたは範囲への参照";
+		Text[ pt-BR ] = "uma referência a uma célula ou faixa do Data Pilot com os dados de origem.";
+		Text[ zh-CN ] = "用源数据引用 Data Pilot 中的单元或范围。";
+		Text[ zh-TW ] = "包含來源資料之 Data Pilot 儲存格或範圍的參考。";
+		};
+		String 6 // Name of Parameter 3
+		{
+			Text [ en-US ] = "Field Name / Item";
+		Text[ de ] = "Feldname/Element";
+		Text[ es ] = "Nombre de campo / elemento";
+		Text[ fr ] = "Nom du champ/élément";
+		Text[ it ] = "Nome/elemento campo";
+		Text[ ja ] = "フィールド名/項目";
+		Text[ pt-BR ] = "Item/Nome do Campo";
+		Text[ zh-CN ] = "字段名称/项 ";
+		Text[ zh-TW ] = "欄位名稱 / 項目";
+		};
+		String 7 // Description of Parameter 3
+		{
+			Text [ en-US ] = "Field name/value pair to filter the target data.";
+		Text[ de ] = "Feldname-/Werte-Paar zur Filterung der Zieldaten.";
+		Text[ es ] = "Par de nombre de campo y valor para filtrar los datos de destino.";
+		Text[ fr ] = "Nom du champ/paire de valeurs pour filtrer les données cibles.";
+		Text[ it ] = "Coppia nome/valore campo da utilizzare come filtro per i dati di destinazione.";
+		Text[ ja ] = "ターゲットデータをフィルタリングするフィールド名/値のペア。";
+		Text[ pt-BR ] = "Par de valores/nome do campo para filtrar os dados de destino.";
+		Text[ zh-CN ] = "过滤目标数据的字段名/值对。";
+		Text[ zh-TW ] = "過濾目標資料的欄位名稱/值成對資料。";
+		};
+	};
+
 	 // -=*# Resource for function HYPERLINK #*=-
 	Resource SC_OPCODE_HYPERLINK
 	{
Index: sc/source/filter/excel/xipivot.cxx
===================================================================
RCS file: /cvs/sc/sc/source/filter/excel/xipivot.cxx,v
retrieving revision 1.10
diff -u -w -p -r1.10 xipivot.cxx
--- sc/source/filter/excel/xipivot.cxx	28 Sep 2005 11:49:40 -0000	1.10
+++ sc/source/filter/excel/xipivot.cxx	22 Feb 2006 21:32:57 -0000
@@ -1225,6 +1225,14 @@ void XclImpPivotTable::Apply() const
     pDPObj->SetOutRange( aOutRange );
     pDPObj->SetAlive( TRUE );
     GetDoc().GetDPCollection()->Insert( pDPObj );
+    if( pDPObj )
+    {
+	// THINK ABOUT THIS
+	// ScDPObject::Output is quite heavy.  The xml importer uses
+	// RefreshAfterLoad instead but that does not generate the in sheet
+	// controls.
+	pDPObj->Output(); // force the creation of the sheet controls
+    }
 }
 
 // ============================================================================
