1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_xmlhelp.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/ucb/Command.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandEnvironment.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/i18n/XExtendedTransliteration.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandProcessor.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/script/XInvocation.hpp> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #ifndef INCLUDED_STL_ALGORITHM 38*cdf0e10cSrcweir #include <algorithm> 39*cdf0e10cSrcweir #define INCLUDED_STL_ALGORITHM 40*cdf0e10cSrcweir #endif 41*cdf0e10cSrcweir #ifndef INCLUDED_STL_SET 42*cdf0e10cSrcweir #include <set> 43*cdf0e10cSrcweir #define INCLUDED_STL_SET 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <qe/Query.hxx> 47*cdf0e10cSrcweir #include <qe/DocGenerator.hxx> 48*cdf0e10cSrcweir #include "resultsetforquery.hxx" 49*cdf0e10cSrcweir #include "databases.hxx" 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir // For testing 52*cdf0e10cSrcweir // #define LOGGING 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir using namespace std; 55*cdf0e10cSrcweir using namespace chelp; 56*cdf0e10cSrcweir using namespace xmlsearch::excep; 57*cdf0e10cSrcweir using namespace xmlsearch::qe; 58*cdf0e10cSrcweir using namespace com::sun::star; 59*cdf0e10cSrcweir using namespace com::sun::star::ucb; 60*cdf0e10cSrcweir using namespace com::sun::star::i18n; 61*cdf0e10cSrcweir using namespace com::sun::star::uno; 62*cdf0e10cSrcweir using namespace com::sun::star::lang; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir struct HitItem 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir rtl::OUString m_aURL; 67*cdf0e10cSrcweir float m_fScore; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir HitItem( void ) {} 70*cdf0e10cSrcweir HitItem( const rtl::OUString& aURL, float fScore ) 71*cdf0e10cSrcweir : m_aURL( aURL ) 72*cdf0e10cSrcweir , m_fScore( fScore ) 73*cdf0e10cSrcweir {} 74*cdf0e10cSrcweir bool operator < ( const HitItem& rHitItem ) const 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir return rHitItem.m_fScore < m_fScore; 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir }; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir ResultSetForQuery::ResultSetForQuery( const uno::Reference< lang::XMultiServiceFactory >& xMSF, 81*cdf0e10cSrcweir const uno::Reference< XContentProvider >& xProvider, 82*cdf0e10cSrcweir sal_Int32 nOpenMode, 83*cdf0e10cSrcweir const uno::Sequence< beans::Property >& seq, 84*cdf0e10cSrcweir const uno::Sequence< NumberedSortingInfo >& seqSort, 85*cdf0e10cSrcweir URLParameter& aURLParameter, 86*cdf0e10cSrcweir Databases* pDatabases ) 87*cdf0e10cSrcweir : ResultSetBase( xMSF,xProvider,nOpenMode,seq,seqSort ), 88*cdf0e10cSrcweir m_pDatabases( pDatabases ), 89*cdf0e10cSrcweir m_aURLParameter( aURLParameter ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir Reference< XTransliteration > xTrans( 92*cdf0e10cSrcweir xMSF->createInstance( rtl::OUString::createFromAscii( "com.sun.star.i18n.Transliteration" ) ), 93*cdf0e10cSrcweir UNO_QUERY ); 94*cdf0e10cSrcweir Locale aLocale( aURLParameter.get_language(), 95*cdf0e10cSrcweir rtl::OUString(), 96*cdf0e10cSrcweir rtl::OUString() ); 97*cdf0e10cSrcweir if(xTrans.is()) 98*cdf0e10cSrcweir xTrans->loadModule(TransliterationModules_UPPERCASE_LOWERCASE, 99*cdf0e10cSrcweir aLocale ); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir // Access Lucene via XInvocation 102*cdf0e10cSrcweir Reference< script::XInvocation > xInvocation( 103*cdf0e10cSrcweir xMSF->createInstance( rtl::OUString::createFromAscii( "com.sun.star.help.HelpSearch" ) ), 104*cdf0e10cSrcweir UNO_QUERY ); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir vector< vector< rtl::OUString > > queryList; 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir sal_Int32 idx; 109*cdf0e10cSrcweir rtl::OUString query = m_aURLParameter.get_query(); 110*cdf0e10cSrcweir while( query.getLength() ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir idx = query.indexOf( sal_Unicode( ' ' ) ); 113*cdf0e10cSrcweir if( idx == -1 ) 114*cdf0e10cSrcweir idx = query.getLength(); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir vector< rtl::OUString > currentQuery; 117*cdf0e10cSrcweir rtl::OUString tmp(query.copy( 0,idx )); 118*cdf0e10cSrcweir rtl:: OUString toliterate = tmp; 119*cdf0e10cSrcweir if(xTrans.is()) { 120*cdf0e10cSrcweir Sequence<sal_Int32> aSeq; 121*cdf0e10cSrcweir toliterate = xTrans->transliterate( 122*cdf0e10cSrcweir tmp,0,tmp.getLength(),aSeq); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir currentQuery.push_back( toliterate ); 126*cdf0e10cSrcweir queryList.push_back( currentQuery ); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir int nCpy = 1 + idx; 129*cdf0e10cSrcweir if( nCpy >= query.getLength() ) 130*cdf0e10cSrcweir query = rtl::OUString(); 131*cdf0e10cSrcweir else 132*cdf0e10cSrcweir query = query.copy( 1 + idx ); 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir vector< rtl::OUString > aCompleteResultVector; 137*cdf0e10cSrcweir if( xInvocation.is() ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir rtl::OUString scope = m_aURLParameter.get_scope(); 140*cdf0e10cSrcweir bool bCaptionsOnly = ( scope.compareToAscii( "Heading" ) == 0 ); 141*cdf0e10cSrcweir sal_Int32 hitCount = m_aURLParameter.get_hitCount(); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir #ifdef LOGGING 144*cdf0e10cSrcweir FILE* pFile = fopen( "d:\\resultset_out.txt", "w" ); 145*cdf0e10cSrcweir #endif 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir IndexFolderIterator aIndexFolderIt( *pDatabases, m_aURLParameter.get_module(), m_aURLParameter.get_language() ); 148*cdf0e10cSrcweir rtl::OUString idxDir; 149*cdf0e10cSrcweir bool bExtension = false; 150*cdf0e10cSrcweir int iDir = 0; 151*cdf0e10cSrcweir vector< vector<HitItem>* > aIndexFolderResultVectorVector; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir bool bTemporary; 154*cdf0e10cSrcweir while( (idxDir = aIndexFolderIt.nextIndexFolder( bExtension, bTemporary )).getLength() > 0 ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir vector<HitItem> aIndexFolderResultVector; 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir try 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir vector< vector<HitItem>* > aQueryListResultVectorVector; 161*cdf0e10cSrcweir set< rtl::OUString > aSet,aCurrent,aResultSet; 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir int nQueryListSize = queryList.size(); 164*cdf0e10cSrcweir if( nQueryListSize > 1 ) 165*cdf0e10cSrcweir hitCount = 2000; 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir for( int i = 0; i < nQueryListSize; ++i ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir vector<HitItem>* pQueryResultVector; 170*cdf0e10cSrcweir if( nQueryListSize > 1 ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir pQueryResultVector = new vector<HitItem>(); 173*cdf0e10cSrcweir aQueryListResultVectorVector.push_back( pQueryResultVector ); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir else 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir pQueryResultVector = &aIndexFolderResultVector; 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir pQueryResultVector->reserve( hitCount ); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir int nParamCount = bCaptionsOnly ? 7 : 6; 182*cdf0e10cSrcweir Sequence<uno::Any> aParamsSeq( nParamCount ); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir aParamsSeq[0] = uno::makeAny( rtl::OUString::createFromAscii( "-lang" ) ); 185*cdf0e10cSrcweir aParamsSeq[1] = uno::makeAny( m_aURLParameter.get_language() ); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir aParamsSeq[2] = uno::makeAny( rtl::OUString::createFromAscii( "-index" ) ); 188*cdf0e10cSrcweir rtl::OUString aSystemPath; 189*cdf0e10cSrcweir osl::FileBase::getSystemPathFromFileURL( idxDir, aSystemPath ); 190*cdf0e10cSrcweir aParamsSeq[3] = uno::makeAny( aSystemPath ); 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir aParamsSeq[4] = uno::makeAny( rtl::OUString::createFromAscii( "-query" ) ); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir const std::vector< rtl::OUString >& aListItem = queryList[i]; 195*cdf0e10cSrcweir ::rtl::OUString aNewQueryStr = aListItem[0]; 196*cdf0e10cSrcweir aParamsSeq[5] = uno::makeAny( aNewQueryStr ); 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir if( bCaptionsOnly ) 199*cdf0e10cSrcweir aParamsSeq[6] = uno::makeAny( rtl::OUString::createFromAscii( "-caption" ) ); 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir Sequence< sal_Int16 > aOutParamIndex; 202*cdf0e10cSrcweir Sequence< uno::Any > aOutParam; 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir uno::Any aRet = xInvocation->invoke( rtl::OUString::createFromAscii( "search" ), 205*cdf0e10cSrcweir aParamsSeq, aOutParamIndex, aOutParam ); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir Sequence< float > aScoreSeq; 208*cdf0e10cSrcweir int nScoreCount = 0; 209*cdf0e10cSrcweir int nOutParamCount = aOutParam.getLength(); 210*cdf0e10cSrcweir if( nOutParamCount == 1 ) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir const uno::Any* pScoreAnySeq = aOutParam.getConstArray(); 213*cdf0e10cSrcweir if( pScoreAnySeq[0] >>= aScoreSeq ) 214*cdf0e10cSrcweir nScoreCount = aScoreSeq.getLength(); 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir Sequence<rtl::OUString> aRetSeq; 218*cdf0e10cSrcweir if( aRet >>= aRetSeq ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir if( nQueryListSize > 1 ) 221*cdf0e10cSrcweir aSet.clear(); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir const rtl::OUString* pRetSeq = aRetSeq.getConstArray(); 224*cdf0e10cSrcweir int nCount = aRetSeq.getLength(); 225*cdf0e10cSrcweir if( nCount > hitCount ) 226*cdf0e10cSrcweir nCount = hitCount; 227*cdf0e10cSrcweir for( int j = 0 ; j < nCount ; ++j ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir float fScore = 0.0; 230*cdf0e10cSrcweir if( j < nScoreCount ) 231*cdf0e10cSrcweir fScore = aScoreSeq[j]; 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir rtl::OUString aURL = pRetSeq[j]; 234*cdf0e10cSrcweir pQueryResultVector->push_back( HitItem( aURL, fScore ) ); 235*cdf0e10cSrcweir if( nQueryListSize > 1 ) 236*cdf0e10cSrcweir aSet.insert( aURL ); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir #ifdef LOGGING 239*cdf0e10cSrcweir if( pFile ) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir rtl::OString tmp(rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8)); 242*cdf0e10cSrcweir fprintf( pFile, "Dir %d, Query %d, Item: score=%f, URL=%s\n", iDir, i, fScore, tmp.getStr() ); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir #endif 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir // intersect 249*cdf0e10cSrcweir if( nQueryListSize > 1 ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir if( i == 0 ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir aResultSet = aSet; 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir else 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir aCurrent = aResultSet; 258*cdf0e10cSrcweir aResultSet.clear(); 259*cdf0e10cSrcweir set_intersection( aSet.begin(),aSet.end(), 260*cdf0e10cSrcweir aCurrent.begin(),aCurrent.end(), 261*cdf0e10cSrcweir inserter(aResultSet,aResultSet.begin())); 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir // Combine results in aIndexFolderResultVector 267*cdf0e10cSrcweir if( nQueryListSize > 1 ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir for( int n = 0 ; n < nQueryListSize ; ++n ) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir vector<HitItem>* pQueryResultVector = aQueryListResultVectorVector[n]; 272*cdf0e10cSrcweir vector<HitItem>& rQueryResultVector = *pQueryResultVector; 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir int nItemCount = rQueryResultVector.size(); 275*cdf0e10cSrcweir for( int i = 0 ; i < nItemCount ; ++i ) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir const HitItem& rItem = rQueryResultVector[ i ]; 278*cdf0e10cSrcweir set< rtl::OUString >::iterator it; 279*cdf0e10cSrcweir if( (it = aResultSet.find( rItem.m_aURL )) != aResultSet.end() ) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir HitItem aItemCopy( rItem ); 282*cdf0e10cSrcweir aItemCopy.m_fScore /= nQueryListSize; // To get average score 283*cdf0e10cSrcweir if( n == 0 ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir // Use first pass to create entry 286*cdf0e10cSrcweir aIndexFolderResultVector.push_back( aItemCopy ); 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir #ifdef LOGGING 289*cdf0e10cSrcweir if( pFile ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir rtl::OString tmp(rtl::OUStringToOString( aItemCopy.m_aURL, RTL_TEXTENCODING_UTF8)); 292*cdf0e10cSrcweir fprintf( pFile, "Combine: Query %d (first pass), Item %d: score=%f (%f), URL=%s\n", n, i, aItemCopy.m_fScore, rItem.m_fScore, tmp.getStr() ); 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir #endif 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir else 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir // Find entry in vector 299*cdf0e10cSrcweir int nCount = aIndexFolderResultVector.size(); 300*cdf0e10cSrcweir for( int j = 0 ; j < nCount ; ++j ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir HitItem& rFindItem = aIndexFolderResultVector[ j ]; 303*cdf0e10cSrcweir if( rFindItem.m_aURL.equals( aItemCopy.m_aURL ) ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir #ifdef LOGGING 306*cdf0e10cSrcweir if( pFile ) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir rtl::OString tmp(rtl::OUStringToOString( aItemCopy.m_aURL, RTL_TEXTENCODING_UTF8)); 309*cdf0e10cSrcweir fprintf( pFile, "Combine: Query %d, Item %d: score=%f + %f = %f, URL=%s\n", n, i, 310*cdf0e10cSrcweir rFindItem.m_fScore, aItemCopy.m_fScore, rFindItem.m_fScore + aItemCopy.m_fScore, tmp.getStr() ); 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir #endif 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir rFindItem.m_fScore += aItemCopy.m_fScore; 315*cdf0e10cSrcweir break; 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir delete pQueryResultVector; 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir sort( aIndexFolderResultVector.begin(), aIndexFolderResultVector.end() ); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir vector<HitItem>* pIndexFolderHitItemVector = new vector<HitItem>( aIndexFolderResultVector ); 329*cdf0e10cSrcweir aIndexFolderResultVectorVector.push_back( pIndexFolderHitItemVector ); 330*cdf0e10cSrcweir aIndexFolderResultVector.clear(); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir catch( const Exception& ) 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir ++iDir; 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir if( bTemporary ) 339*cdf0e10cSrcweir aIndexFolderIt.deleteTempIndexFolder( idxDir ); 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir } // Iterator 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir int nVectorCount = aIndexFolderResultVectorVector.size(); 345*cdf0e10cSrcweir vector<HitItem>::size_type* pCurrentVectorIndex = new vector<HitItem>::size_type[nVectorCount]; 346*cdf0e10cSrcweir for( int j = 0 ; j < nVectorCount ; ++j ) 347*cdf0e10cSrcweir pCurrentVectorIndex[j] = 0; 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir #ifdef LOGGING 350*cdf0e10cSrcweir if( pFile ) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir for( int k = 0 ; k < nVectorCount ; ++k ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir vector<HitItem>& rIndexFolderVector = *aIndexFolderResultVectorVector[k]; 355*cdf0e10cSrcweir int nItemCount = rIndexFolderVector.size(); 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir fprintf( pFile, "Vector %d, %d elements\n", k, nItemCount ); 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir for( int i = 0 ; i < nItemCount ; ++i ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir const HitItem& rItem = rIndexFolderVector[ i ]; 362*cdf0e10cSrcweir rtl::OString tmp(rtl::OUStringToOString(rItem.m_aURL, RTL_TEXTENCODING_UTF8)); 363*cdf0e10cSrcweir fprintf( pFile, " Item_vector%d, %d/%d: score=%f, URL=%s\n", k, i, nItemCount, rItem.m_fScore, tmp.getStr() ); 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir #endif 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir sal_Int32 nTotalHitCount = m_aURLParameter.get_hitCount(); 370*cdf0e10cSrcweir sal_Int32 nHitCount = 0; 371*cdf0e10cSrcweir while( nHitCount < nTotalHitCount ) 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir int iVectorWithBestScore = -1; 374*cdf0e10cSrcweir float fBestScore = 0.0; 375*cdf0e10cSrcweir for( int k = 0 ; k < nVectorCount ; ++k ) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir vector<HitItem>& rIndexFolderVector = *aIndexFolderResultVectorVector[k]; 378*cdf0e10cSrcweir if( pCurrentVectorIndex[k] < rIndexFolderVector.size() ) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir const HitItem& rItem = rIndexFolderVector[ pCurrentVectorIndex[k] ]; 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir if( fBestScore < rItem.m_fScore ) 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir fBestScore = rItem.m_fScore; 385*cdf0e10cSrcweir iVectorWithBestScore = k; 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir if( iVectorWithBestScore == -1 ) // No item left at all 391*cdf0e10cSrcweir break; 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir vector<HitItem>& rIndexFolderVector = *aIndexFolderResultVectorVector[iVectorWithBestScore]; 394*cdf0e10cSrcweir const HitItem& rItem = rIndexFolderVector[ pCurrentVectorIndex[iVectorWithBestScore] ]; 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir pCurrentVectorIndex[iVectorWithBestScore]++; 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir aCompleteResultVector.push_back( rItem.m_aURL ); 399*cdf0e10cSrcweir ++nHitCount; 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir delete[] pCurrentVectorIndex; 403*cdf0e10cSrcweir for( int n = 0 ; n < nVectorCount ; ++n ) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir vector<HitItem>* pIndexFolderVector = aIndexFolderResultVectorVector[n]; 406*cdf0e10cSrcweir delete pIndexFolderVector; 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir #ifdef LOGGING 410*cdf0e10cSrcweir fclose( pFile ); 411*cdf0e10cSrcweir #endif 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir sal_Int32 replIdx = rtl::OUString::createFromAscii( "#HLP#" ).getLength(); 415*cdf0e10cSrcweir rtl::OUString replWith = rtl::OUString::createFromAscii( "vnd.sun.star.help://" ); 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir int nResultCount = aCompleteResultVector.size(); 418*cdf0e10cSrcweir for( int r = 0 ; r < nResultCount ; ++r ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir rtl::OUString aURL = aCompleteResultVector[r]; 421*cdf0e10cSrcweir rtl::OUString aResultStr = replWith + aURL.copy(replIdx); 422*cdf0e10cSrcweir m_aPath.push_back( aResultStr ); 423*cdf0e10cSrcweir } 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir m_aItems.resize( m_aPath.size() ); 426*cdf0e10cSrcweir m_aIdents.resize( m_aPath.size() ); 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir Command aCommand; 429*cdf0e10cSrcweir aCommand.Name = rtl::OUString::createFromAscii( "getPropertyValues" ); 430*cdf0e10cSrcweir aCommand.Argument <<= m_sProperty; 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir for( m_nRow = 0; sal::static_int_cast<sal_uInt32>( m_nRow ) < m_aPath.size(); ++m_nRow ) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir m_aPath[m_nRow] = 435*cdf0e10cSrcweir m_aPath[m_nRow] + 436*cdf0e10cSrcweir rtl::OUString::createFromAscii( "?Language=" ) + 437*cdf0e10cSrcweir m_aURLParameter.get_language() + 438*cdf0e10cSrcweir rtl::OUString::createFromAscii( "&System=" ) + 439*cdf0e10cSrcweir m_aURLParameter.get_system(); 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir uno::Reference< XContent > content = queryContent(); 442*cdf0e10cSrcweir if( content.is() ) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir uno::Reference< XCommandProcessor > cmd( content,uno::UNO_QUERY ); 445*cdf0e10cSrcweir cmd->execute( aCommand,0,uno::Reference< XCommandEnvironment >( 0 ) ) >>= m_aItems[m_nRow]; //TODO: check return value of operator >>= 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir m_nRow = 0xffffffff; 449*cdf0e10cSrcweir } 450