Commits

Anonymous committed b4bf1a1

calc62: #i115431# treat DataPilot filter field numbers as relative to the sheet, set MK_ERR bit for errors

  • Participants
  • Parent commits 34ed029

Comments (0)

Files changed (1)

sc/source/core/data/dptablecache.cxx

 	ScBaseCell* pCell = pDoc->GetCell( aPos );
 
 	if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetErrCode() )
+    {
         SetString ( aDocStr );      //[SODC_19347] add liyi
         //bErr = TRUE;              //[SODC_19347] del liyi
+        mbFlag |= MK_ERR;
+    }
 	else if ( pDoc->HasValueData( nCol, nRow, nDocTab ) )
 	{
 		double fVal = pDoc->GetValue(ScAddress(nCol, nRow, nDocTab));
 		{
 			ScQueryEntry& rEntry = rParam.GetEntry(i);
 			// we can only handle one single direct query
-			SCROW nId = GetItemDataId( (SCCOL)rEntry.nField, nRow, FALSE ); 
-			const ScDPItemData* pCellData = GetItemDataById(  (SCCOL)rEntry.nField, nId); 
+            // #i115431# nField in QueryParam is the sheet column, not the field within the source range
+            SCCOL nQueryCol = (SCCOL)rEntry.nField;
+            if ( nQueryCol < rParam.nCol1 )
+                nQueryCol = rParam.nCol1;
+            if ( nQueryCol > rParam.nCol2 )
+                nQueryCol = rParam.nCol2;
+            SCCOL nSourceField = nQueryCol - rParam.nCol1;
+            SCROW nId = GetItemDataId( nSourceField, nRow, FALSE ); 
+            const ScDPItemData* pCellData = GetItemDataById( nSourceField, nId ); 
 
 			BOOL bOk = FALSE;
 			BOOL bTestEqual = FALSE;