1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: searchdemo.cxx,v $
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>
43 #include <abidebug.hxx>
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
);
76 int main( int argc
,char* argv
[] )
79 QueryResults
* queryResults
= 0;
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" );
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();
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() );
116 printf( "catched exception" );