update dev300-m58
[ooovba.git] / xmlhelp / source / cxxhelp / test / searchdemo.cxx
blob719aee78a39ed8a55d014a13c6e90e0eca70d1a9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: searchdemo.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlhelp.hxx"
33 #include <rtl/ustring.hxx>
34 #include <osl/file.hxx>
35 #include <db/Block.hxx>
36 #include <db/BtreeDictParameters.hxx>
37 #include <db/BtreeDict.hxx>
38 #include <util/RandomAccessStream.hxx>
39 #include <db/DBEnv.hxx>
40 #include <qe/QueryProcessor.hxx>
42 #ifdef ABIDEBUG
43 #include <abidebug.hxx>
44 #endif
47 using namespace xmlsearch::util;
48 using namespace xmlsearch::db;
49 using namespace xmlsearch::qe;
53 extern RandomAccessStream* theFile();
57 void print_rtl_OUString( const rtl::OUString bla )
59 rtl::OString bluber = rtl::OString( bla.getStr(),bla.getLength(),RTL_TEXTENCODING_UTF8 );
60 char* bluberChr = new char[ 1+bluber.getLength() ];
61 const sal_Char* jux = bluber.getStr();
63 for( int i = 0; i < bluber.getLength(); ++i )
64 bluberChr[i] = jux[i];
66 bluberChr[ bluber.getLength() ] = 0;
67 printf( "%s\n",bluberChr );
68 delete[] bluberChr;
72 extern void bla();
73 extern void blu();
76 int main( int argc,char* argv[] )
79 QueryResults* queryResults = 0;
81 try
83 rtl::OUString installDir = rtl::OUString::createFromAscii( "//./e|/index/" );
84 QueryProcessor queryProcessor( installDir );
86 std::vector<rtl::OUString> Query(2);
87 Query[0] = rtl::OUString::createFromAscii( "text*" );
88 Query[1] = rtl::OUString::createFromAscii( "abbildung" );
89 rtl::OUString Scope = rtl::OUString::createFromAscii( "headingheading" );
90 int HitCount = 40;
92 QueryStatement queryStatement( HitCount,Query,Scope );
93 queryResults = queryProcessor.processQuery( queryStatement );
95 rtl::OUString translations[2];
96 translations[0] = rtl::OUString::createFromAscii( "#HLP#" );
97 translations[1] = rtl::OUString::createFromAscii( "vnd.sun.star.help://" );
99 PrefixTranslator* translator = PrefixTranslator::makePrefixTranslator( translations,2 );
101 QueryHitIterator* it = queryResults->makeQueryHitIterator();
102 sal_Int32 j = 0;
103 while( j < 10 && it->next() )
105 printf( "Ergebnis %2d ",j );
106 QueryHitData* qhd = it->getHit( translator );
107 printf( "Penalty = %10.4f ",qhd->getPenalty() );
108 print_rtl_OUString( qhd->getDocument() );
109 ++j;
112 delete it;
114 catch( ... )
116 printf( "catched exception" );
117 throw;
119 return 0;