1*89dcb3daSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*89dcb3daSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*89dcb3daSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*89dcb3daSAndrew Rist * distributed with this work for additional information 6*89dcb3daSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*89dcb3daSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*89dcb3daSAndrew Rist * "License"); you may not use this file except in compliance 9*89dcb3daSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*89dcb3daSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*89dcb3daSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*89dcb3daSAndrew Rist * software distributed under the License is distributed on an 15*89dcb3daSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*89dcb3daSAndrew Rist * KIND, either express or implied. See the License for the 17*89dcb3daSAndrew Rist * specific language governing permissions and limitations 18*89dcb3daSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*89dcb3daSAndrew Rist *************************************************************/ 21*89dcb3daSAndrew Rist 22*89dcb3daSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmlhelp.hxx" 26cdf0e10cSrcweir #include <rtl/string.hxx> 27cdf0e10cSrcweir #include <osl/file.hxx> 28cdf0e10cSrcweir #include <db/Block.hxx> 29cdf0e10cSrcweir #include <db/BtreeDictParameters.hxx> 30cdf0e10cSrcweir #include <db/BtreeDict.hxx> 31cdf0e10cSrcweir #include <util/RandomAccessStream.hxx> 32cdf0e10cSrcweir #include <db/DBEnv.hxx> 33cdf0e10cSrcweir #include <qe/QueryProcessor.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #ifdef ABIDEBUG 36cdf0e10cSrcweir #include <abidebug.hxx> 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir 39cdf0e10cSrcweir 40cdf0e10cSrcweir using namespace xmlsearch::util; 41cdf0e10cSrcweir using namespace xmlsearch::db; 42cdf0e10cSrcweir using namespace xmlsearch::qe; 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir 46cdf0e10cSrcweir extern RandomAccessStream* theFile(); 47cdf0e10cSrcweir 48cdf0e10cSrcweir 49cdf0e10cSrcweir 50cdf0e10cSrcweir void print_rtl_OUString( const rtl::OUString bla ) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir rtl::OString bluber = rtl::OString( bla.getStr(),bla.getLength(),RTL_TEXTENCODING_UTF8 ); 53cdf0e10cSrcweir char* bluberChr = new char[ 1+bluber.getLength() ]; 54cdf0e10cSrcweir const sal_Char* jux = bluber.getStr(); 55cdf0e10cSrcweir 56cdf0e10cSrcweir for( int i = 0; i < bluber.getLength(); ++i ) 57cdf0e10cSrcweir bluberChr[i] = jux[i]; 58cdf0e10cSrcweir 59cdf0e10cSrcweir bluberChr[ bluber.getLength() ] = 0; 60cdf0e10cSrcweir printf( "%s\n",bluberChr ); 61cdf0e10cSrcweir delete[] bluberChr; 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir 65cdf0e10cSrcweir extern void bla(); 66cdf0e10cSrcweir extern void blu(); 67cdf0e10cSrcweir 68cdf0e10cSrcweir 69cdf0e10cSrcweir int main( int argc,char* argv[] ) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir 72cdf0e10cSrcweir QueryResults* queryResults = 0; 73cdf0e10cSrcweir 74cdf0e10cSrcweir try 75cdf0e10cSrcweir { 76cdf0e10cSrcweir rtl::OUString installDir = rtl::OUString::createFromAscii( "//./e|/index/" ); 77cdf0e10cSrcweir QueryProcessor queryProcessor( installDir ); 78cdf0e10cSrcweir 79cdf0e10cSrcweir std::vector<rtl::OUString> Query(2); 80cdf0e10cSrcweir Query[0] = rtl::OUString::createFromAscii( "text*" ); 81cdf0e10cSrcweir Query[1] = rtl::OUString::createFromAscii( "abbildung" ); 82cdf0e10cSrcweir rtl::OUString Scope = rtl::OUString::createFromAscii( "headingheading" ); 83cdf0e10cSrcweir int HitCount = 40; 84cdf0e10cSrcweir 85cdf0e10cSrcweir QueryStatement queryStatement( HitCount,Query,Scope ); 86cdf0e10cSrcweir queryResults = queryProcessor.processQuery( queryStatement ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir rtl::OUString translations[2]; 89cdf0e10cSrcweir translations[0] = rtl::OUString::createFromAscii( "#HLP#" ); 90cdf0e10cSrcweir translations[1] = rtl::OUString::createFromAscii( "vnd.sun.star.help://" ); 91cdf0e10cSrcweir 92cdf0e10cSrcweir PrefixTranslator* translator = PrefixTranslator::makePrefixTranslator( translations,2 ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir QueryHitIterator* it = queryResults->makeQueryHitIterator(); 95cdf0e10cSrcweir sal_Int32 j = 0; 96cdf0e10cSrcweir while( j < 10 && it->next() ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir printf( "Ergebnis %2d ",j ); 99cdf0e10cSrcweir QueryHitData* qhd = it->getHit( translator ); 100cdf0e10cSrcweir printf( "Penalty = %10.4f ",qhd->getPenalty() ); 101cdf0e10cSrcweir print_rtl_OUString( qhd->getDocument() ); 102cdf0e10cSrcweir ++j; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir delete it; 106cdf0e10cSrcweir } 107cdf0e10cSrcweir catch( ... ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir printf( "catched exception" ); 110cdf0e10cSrcweir throw; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir return 0; 113cdf0e10cSrcweir } 114