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