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