diff -uPr old/sc/source/ui/view/gridwin.cxx new/sc/source/ui/view/gridwin.cxx --- old/sc/source/ui/view/gridwin.cxx 2009-03-11 09:50:51.000000000 +0800 +++ new/sc/source/ui/view/gridwin.cxx 2009-04-03 10:28:48.000000000 +0800 @@ -140,6 +140,7 @@ #include "drwlayer.hxx" #include "attrib.hxx" #include "validat.hxx" +#include "rangenam.hxx" // #114409# #include // FRound @@ -982,8 +983,106 @@ if (bWait) EnterWait(); - for (i=0; iInsertEntry( aStrings[i]->GetString() ); + } + else + { + BOOL bRef = FALSE; + ScRange aRange; + ULONG nIndex = ((SfxUInt32Item*)pDoc->GetAttr(nCol, nRow, nTab, ATTR_VALIDDATA ))->GetValue(); + if ( nIndex ) + { + const ScValidationData* pData = pDoc->GetValidationEntry( nIndex ); + if ( pData && pData->GetDataMode()==SC_VALID_LIST ) + { + ::std::auto_ptr< ScTokenArray > xScTokArr( pData->CreateTokenArry( 0 ) ); + bRef = xScTokArr->IsReference(aRange); + if (!bRef) + { + xScTokArr->Reset(); + for( ScToken* t = xScTokArr->Next(); t && !bRef; t = xScTokArr->Next() ) + { + if( t->GetOpCode() == ocDBArea ) + { + if( ScDBData* pDBData = pDoc->GetDBCollection()->FindIndex( t->GetIndex() ) ) + { + pDBData->GetArea(aRange); + bRef = TRUE; + } + } + } + } + if ( bRef ) + { + SCCOL nStartCol = aRange.aStart.Col(); + SCROW nStartRow = aRange.aStart.Row(); + SCCOL nEndCol = aRange.aEnd.Col(); + SCROW nEndRow = aRange.aEnd.Row(); + SCTAB nStartTab = aRange.aStart.Tab(); + USHORT nRows = (USHORT)(nEndRow-nStartRow)+1; + USHORT nCols = (USHORT)(nEndCol-nStartCol)+1; + + bool bSortList = ( pData->GetListType() == ValidListType::SORTEDASCENDING); + if ( !bSortList ) + { + for( USHORT nR = 0; nR < nRows ; nR++ ) + { + for( USHORT nC = 0; nC < nCols ; nC++ ) + { + String aDocStr; + pDoc->GetString( (SCCOL)(nC+nStartCol), + (SCROW)(nR+nStartRow), nStartTab , aDocStr ); + pFilterBox->InsertEntry(aDocStr); + } + } + } + else + { + TypedStrData* pNew = NULL; + + for (i=0; iGetValue() != 0.0 ) + { + bool bmatch = false; + for( SCROW nR = nStartRow; nR <= nEndRow && !bmatch ; nR++ ) + { + for( SCCOL nC = nStartCol; nC <= nEndCol && !bmatch; nC++ ) + { + String aDocStr; + pDoc->GetString( nC, nR, nStartTab, aDocStr ); + if ( pDoc->HasValueData( nC, nR, nStartTab ) ) + { + double fVal = pDoc->GetValue(ScAddress(nC, nR, nStartTab)); + pNew = new TypedStrData( aDocStr, fVal, SC_STRTYPE_VALUE ); + if ( aStrings.Compare(aStrings[i], pNew)==0 ) + { + pFilterBox->InsertEntry( aDocStr ); + bmatch = true; + } + } + } + } + if (!bmatch) + pFilterBox->InsertEntry( aStrings[i]->GetString() ); + } + else + pFilterBox->InsertEntry( aStrings[i]->GetString() ); + } + delete pNew; + } + } + } + } + if ( !bRef ) + { + for (i=0; iInsertEntry( aStrings[i]->GetString() ); + } + } if (bWait) LeaveWait(); @@ -1132,9 +1231,16 @@ SCCOL nCol = pFilterBox->GetCol(); SCROW nRow = pFilterBox->GetRow(); + SCTAB nTab = pViewData->GetTabNo(); + ScDocument* pDoc = pViewData->GetDocument(); + TypedStrCollection aStrings( 128, 128 ); + aStrings.SetCaseSensitive( TRUE ); switch ( pFilterBox->GetMode() ) { case SC_FILTERBOX_DATASELECT: + pDoc->GetDataEntries( nCol, nRow, nTab, aStrings ); + if ( aStrings.GetCount() > 0 ) + aString=aStrings[nSel]->GetString(); ExecDataSelect( nCol, nRow, aString ); break; case SC_FILTERBOX_FILTER: