diff -u ../src680-m79.bak/sc/inc/compiler.hrc sc/inc/compiler.hrc --- ../src680-m79.bak/sc/inc/compiler.hrc 2005-03-09 10:20:37.000000000 +0530 +++ sc/inc/compiler.hrc 2005-03-30 09:49:01.000000000 +0530 @@ -386,9 +386,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_GETPIVOTDATA 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 diff -u ../src680-m79.bak/sc/inc/dpobject.hxx sc/inc/dpobject.hxx --- ../src680-m79.bak/sc/inc/dpobject.hxx 2005-03-09 10:20:36.000000000 +0530 +++ sc/inc/dpobject.hxx 2005-04-06 17:39:37.000000000 +0530 @@ -165,6 +165,7 @@ void InvalidateSource(); void Output(); + double GetPivotData(const int nField); ScRange GetNewOutputRange( BOOL& rOverflow ); void SetSaveData(const ScDPSaveData& rData); diff -u ../src680-m79.bak/sc/inc/dpoutput.hxx sc/inc/dpoutput.hxx --- ../src680-m79.bak/sc/inc/dpoutput.hxx 2005-03-09 10:20:38.000000000 +0530 +++ sc/inc/dpoutput.hxx 2005-04-06 17:39:45.000000000 +0530 @@ -164,6 +164,7 @@ void SetPosition( const ScAddress& rPos ); void Output(); //! Refresh? + double GetPivotData(const int nField); ScRange GetOutputRange(); long GetHeaderRows(); BOOL HasError(); // range overflow or exception from source diff -u ../src680-m79.bak/sc/inc/opcode.hxx sc/inc/opcode.hxx --- ../src680-m79.bak/sc/inc/opcode.hxx 2005-03-09 10:20:38.000000000 +0530 +++ sc/inc/opcode.hxx 2005-03-30 11:40:11.000000000 +0530 @@ -414,7 +414,8 @@ // ab hier sind Extradaten drin ocDataToken1 = SC_OPCODE_DATA_TOKEN_1, // kein OpCode - ocNone = SC_OPCODE_NONE + ocNone = SC_OPCODE_NONE, + ocGetPivotData = SC_OPCODE_GETPIVOTDATA }; #ifdef PRODUCT diff -u ../src680-m79.bak/sc/inc/scfuncs.hrc sc/inc/scfuncs.hrc --- ../src680-m79.bak/sc/inc/scfuncs.hrc 2005-03-09 10:20:37.000000000 +0530 +++ sc/inc/scfuncs.hrc 2005-03-30 10:18:00.000000000 +0530 @@ -323,6 +323,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) diff -u -r ../src680-m79.bak/sc/source/core/data/dpobject.cxx sc/source/core/data/dpobject.cxx --- ../src680-m79.bak/sc/source/core/data/dpobject.cxx 2005-03-09 10:21:08.000000000 +0530 +++ sc/source/core/data/dpobject.cxx 2005-04-06 17:39:57.000000000 +0530 @@ -277,6 +277,7 @@ pSheetDesc->aQueryParam.nRow1 = pSheetDesc->aSourceRange.aStart.Row(); pSheetDesc->aQueryParam.nCol2 = pSheetDesc->aSourceRange.aEnd.Col(); pSheetDesc->aQueryParam.nRow2 = pSheetDesc->aSourceRange.aEnd.Row();; + pSheetDesc->aQueryParam.bHasHeader = TRUE; InvalidateSource(); // new source must be created @@ -508,6 +509,12 @@ aOutRange = pOutput->GetOutputRange(); } +double ScDPObject::GetPivotData(const int nField) +{ + CreateOutput(); + return pOutput->GetPivotData(nField); +} + BOOL lcl_HasButton( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab ) { return ((const ScMergeFlagAttr*)pDoc->GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->HasButton(); diff -u -r ../src680-m79.bak/sc/source/core/data/dpoutput.cxx sc/source/core/data/dpoutput.cxx --- ../src680-m79.bak/sc/source/core/data/dpoutput.cxx 2005-03-09 10:21:09.000000000 +0530 +++ sc/source/core/data/dpoutput.cxx 2005-04-07 12:34:03.916213498 +0530 @@ -878,6 +878,16 @@ lcl_SetFrame( pDoc,nTab, nTabStartCol,nTabStartRow, nTabEndCol,nTabEndRow, 40 ); } +double ScDPOutput::GetPivotData(const int nField) +{ + const uno::Sequence* pRowAry = aData.getConstArray(); + nRowCount = aData.getLength(); + if (nField > nRowCount) + return -1.0; // The columns are empty / No data for the given query. + const sheet::DataResult* pColAry = pRowAry[nRowCount-nField].getConstArray(); + long nColCount = pRowAry[nRowCount-nField].getLength(); + return pColAry[nColCount-1].Value; +} ScRange ScDPOutput::GetOutputRange() { CalcSizes(); diff -u -r ../src680-m79.bak/sc/source/core/inc/interpre.hxx sc/source/core/inc/interpre.hxx --- ../src680-m79.bak/sc/source/core/inc/interpre.hxx 2005-03-09 10:21:07.000000000 +0530 +++ sc/source/core/inc/interpre.hxx 2005-03-30 11:42:39.000000000 +0530 @@ -684,6 +684,7 @@ void ScSTEXY(); void ScSlope(); void ScTrend(); +void ScGetPivotData(); public: diff -u -r ../src680-m79.bak/sc/source/core/src/compiler.src sc/source/core/src/compiler.src --- ../src680-m79.bak/sc/source/core/src/compiler.src 2005-03-09 10:21:08.000000000 +0530 +++ sc/source/core/src/compiler.src 2005-03-30 11:09:55.000000000 +0530 @@ -1692,6 +1692,11 @@ Text [ de ] = "HYPERLINK"; Text[ en-US ] = "HYPERLINK"; }; + String SC_OPCODE_GETPIVOTDATA + { + Text [ de ] = ""; + Text [ en-US ] = "GETPIVOTDATA" ; + }; }; Resource RID_SC_FUNCTION_NAMES_ENGLISH { @@ -1987,5 +1992,6 @@ String SC_OPCODE_ROMAN { Text = "ROMAN" ; }; String SC_OPCODE_ARABIC { Text = "ARABIC" ; }; String SC_OPCODE_HYPERLINK { Text = "HYPERLINK" ; }; + String SC_OPCODE_GETPIVOTDATA { Text = "GETPIVOTDATA" ; }; }; diff -u -r ../src680-m79.bak/sc/source/core/tool/interpr2.cxx sc/source/core/tool/interpr2.cxx --- ../src680-m79.bak/sc/source/core/tool/interpr2.cxx 2005-03-09 10:21:12.000000000 +0530 +++ sc/source/core/tool/interpr2.cxx 2005-04-07 11:26:15.000000000 +0530 @@ -88,6 +88,12 @@ #include "unitconv.hxx" #include "globstr.hrc" #include "hints.hxx" +#include "dpshttab.hxx" +#include "dpobject.hxx" +#include "dpsave.hxx" +#include + +using namespace com::sun::star; // STATIC DATA ----------------------------------------------------------- @@ -2322,3 +2328,130 @@ PushMatrix(pResMat); } } + + +int lcl_FindIndex (String fieldnames[], String afield, int nCount) +{ + for ( int i=0; i= 2 && nParamCount <= 32) + { + ScBaseCell* pCell; + ScAddress aCellAddress; + String aField; + String aItem[15], aValue[15]; + int i; + + for (i=2; i < nParamCount ; i+=2) + { + aValue[nCount] = GetString(); + aItem[nCount] = GetString(); + nCount++; + } + PopSingleRef(aCellAddress); + if ( nParamCount -i -2 == 1 ) + return; + aField = GetString(); + + ScDPObject *pDPObj = pDok->GetDPAtCursor (aCellAddress.Col(), aCellAddress.Row(), aCellAddress.Tab()); + if (!pDPObj) + return; // FIXME: We need to fix up a error no and clean mem + + ScDPObject aNewObj( *pDPObj ); + + ScQueryParam aParam; + SCTAB nSrcTab = 0; + const ScSheetSourceDesc* pDesc = aNewObj.GetSheetDesc(); + DBG_ASSERT( pDesc, "no sheet source for DP filter dialog" ); + if( pDesc ) + { + aParam = ScQueryParam (pDesc->aQueryParam); + nSrcTab = pDesc->aSourceRange.aStart.Tab(); + } + + /* Get the number of columns */ + int nColumns = aParam.nCol2 - aParam.nCol1 + 1; + String aSourceNames[nColumns]; + + /* Get the column names */ + for (i=aParam.nCol1; i<= aParam.nCol2; i++) + { + pDok->GetString (i, aParam.nRow1, nSrcTab, aSourceNames[i] ); + } + + ScSheetSourceDesc aNewDesc; + if( pDesc ) + aNewDesc = *pDesc; + + aParam.Resize(nCount); + + ScDPSaveData *pData = aNewObj.GetSaveData(); + List aList = pData->GetDimensions(); + BOOL IsData = FALSE; + int nField = -1; + int nListCount = aList.Count(); + for (i=0;i< nListCount; i++) + { + ScDPSaveDimension *pDim = (ScDPSaveDimension* ) aList.GetObject(i); + + // sheet::DataPilotFieldOrientation_DATA states that it belongs to Data layout. + // It is possible in a DP that multiple Data fields are in Data Layout. + // So we are filtering the field we req/queried (first param of the fn) in the data layout. + + if ( !IsData && pDim->GetOrientation() == sheet::DataPilotFieldOrientation_DATA) + IsData = TRUE; + + if (IsData && pDim->GetName().Equals (aField) ) + { + // this nField is the offset from bottom to the multiple data fields. + nField = nListCount - i; + break; + } + } + if (nField == -1) + return; //FIXME: We need to fix up a error no and clean mem + + // Fill in the Field ID for the queried field and populate rEntry + for (i=0;i ; + < "" ; Default ; > ; + < "" ; Default ; > ; < "<" ; Default ; > ; < ">" ; Default ; > ; < "<=" ; Default ; > ; < ">=" ; Default ; > ; - < "<>" ; Default ; > ; + < "" ; Default ; > ; }; StringList [ en-US ] = { - < "=" ; Default ; > ; + < "Begins with" ; Default ; > ; + < "Ends with" ; Default ; > ; + < "Equals" ; Default ; > ; < "<" ; Default ; > ; < ">" ; Default ; > ; < "<=" ; Default ; > ; < ">=" ; Default ; > ; - < "<>" ; Default ; > ; + < "Not equals" ; Default ; > ; }; }; ListBox LB_COND2 @@ -733,24 +737,28 @@ Size = MAP_APPFONT ( 47 , 65 ) ; TabStop = TRUE ; DropDown = TRUE ; - StringList [ de ] = - { - < "=" ; Default ; > ; - < "<" ; Default ; > ; - < ">" ; Default ; > ; - < "<=" ; Default ; > ; - < ">=" ; Default ; > ; - < "<>" ; Default ; > ; - }; - StringList [ en-US ] = - { - < "=" ; Default ; > ; - < "<" ; Default ; > ; - < ">" ; Default ; > ; - < "<=" ; Default ; > ; - < ">=" ; Default ; > ; - < "<>" ; Default ; > ; - }; + StringList [ de ] = + { + < "" ; Default ; > ; + < "" ; Default ; > ; + < "" ; Default ; > ; + < "<" ; Default ; > ; + < ">" ; Default ; > ; + < "<=" ; Default ; > ; + < ">=" ; Default ; > ; + < "" ; Default ; > ; + }; + StringList [ en-US ] = + { + < "Begins with" ; Default ; > ; + < "Ends with" ; Default ; > ; + < "Equals" ; Default ; > ; + < "<" ; Default ; > ; + < ">" ; Default ; > ; + < "<=" ; Default ; > ; + < ">=" ; Default ; > ; + < "Not equals" ; Default ; > ; + }; }; ListBox LB_COND3 { @@ -759,24 +767,28 @@ Size = MAP_APPFONT ( 47 , 65 ) ; TabStop = TRUE ; DropDown = TRUE ; - StringList [ de ] = - { - < "=" ; Default ; > ; - < "<" ; Default ; > ; - < ">" ; Default ; > ; - < "<=" ; Default ; > ; - < ">=" ; Default ; > ; - < "<>" ; Default ; > ; - }; - StringList [ en-US ] = - { - < "=" ; Default ; > ; - < "<" ; Default ; > ; - < ">" ; Default ; > ; - < "<=" ; Default ; > ; - < ">=" ; Default ; > ; - < "<>" ; Default ; > ; - }; + StringList [ de ] = + { + < "" ; Default ; > ; + < "" ; Default ; > ; + < "" ; Default ; > ; + < "<" ; Default ; > ; + < ">" ; Default ; > ; + < "<=" ; Default ; > ; + < ">=" ; Default ; > ; + < "" ; Default ; > ; + }; + StringList [ en-US ] = + { + < "Begins with" ; Default ; > ; + < "Ends with" ; Default ; > ; + < "Equals" ; Default ; > ; + < "<" ; Default ; > ; + < ">" ; Default ; > ; + < "<=" ; Default ; > ; + < ">=" ; Default ; > ; + < "Not equals" ; Default ; > ; + }; }; ComboBox ED_VAL1 { diff -u -r ../src680-m79.bak/sc/source/ui/src/scfuncs.src sc/source/ui/src/scfuncs.src --- ../src680-m79.bak/sc/source/ui/src/scfuncs.src 2005-03-09 10:20:52.000000000 +0530 +++ sc/source/ui/src/scfuncs.src 2005-04-06 12:29:11.000000000 +0530 @@ -11015,6 +11015,54 @@ Text [ en-US ] = "The text that represents a Roman numeral."; }; }; + Resource SC_OPCODE_GETPIVOTDATA + { + String 1 // Description + { + Text [ de ] = "" ; + Text [ en-US ] = "Gets data from the pivot table."; + }; + ExtraData = + { + ID_FUNCTION_GRP_TABLE; + U2S( HID_FUNC_GETPIVOTDATA ); + VAR_ARGS+2; 0; 0; 1; + }; + String 2 // Name of Parameter 1 + { + Text [ de ] = "" ; + Text [ en-US ] = "Data Field"; + }; + String 3 // Description of Parameter 1 + { + Text [ de ] = "" ; + Text [ en-US ] = "The name of the field you want to retieve data from"; + }; + String 4 // Name of Parameter 2 + { + Text [ de ] = "" ; + Text [ en-US ] = "Pivot Table"; + }; + String 5 // Description of Parameter 2 + { + Text [ de ] = "" ; + Text [ en-US ] = "The reference to a cell in the Pivottable report that contains the data."; + }; + String 6 // Name of Parameter 3 + { + Text [ de ] = "" ; + Text [ en-US ] = "Field/Item "; + }; + String 7 // Description of Parameter 3 + { + Text [ de ] = "" ; + Text [ en-US ] = "Field name/value pair that filters the data you want to retrieve. "; + }; + + + + }; + }; #if defined(U2S)