summaryrefslogtreecommitdiff
path: root/xmlhelp
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2008-03-25 14:19:12 +0000
committerOliver Bolte <obo@openoffice.org>2008-03-25 14:19:12 +0000
commitddf5d8d556a445c942b520f709d98c18242f9577 (patch)
tree04a7f0f39f188c712e69522818ce498183168025 /xmlhelp
parent003d34e3c30c1e7dc1f08f7737cedef79be3b15f (diff)
INTEGRATION: CWS ucbfixes06 (1.1.2); FILE ADDED
2008/01/21 15:30:20 kso 1.1.2.1: #i85425# - cleanup of CVS module.
Diffstat (limited to 'xmlhelp')
-rw-r--r--xmlhelp/source/cxxhelp/inc/excep/XmlSearchExceptions.hxx117
-rw-r--r--xmlhelp/source/cxxhelp/inc/qe/ConceptData.hxx131
-rw-r--r--xmlhelp/source/cxxhelp/inc/qe/ContextTables.hxx157
-rw-r--r--xmlhelp/source/cxxhelp/inc/qe/DocGenerator.hxx303
-rw-r--r--xmlhelp/source/cxxhelp/inc/qe/Query.hxx346
-rw-r--r--xmlhelp/source/cxxhelp/inc/qe/QueryProcessor.hxx149
-rw-r--r--xmlhelp/source/cxxhelp/inc/qe/Search.hxx133
-rw-r--r--xmlhelp/source/cxxhelp/inc/qe/XmlIndex.hxx149
-rw-r--r--xmlhelp/source/cxxhelp/inc/util/CompressorIterator.hxx57
-rw-r--r--xmlhelp/source/cxxhelp/inc/util/ConceptList.hxx98
-rw-r--r--xmlhelp/source/cxxhelp/inc/util/DBEnvImpl.hxx86
-rw-r--r--xmlhelp/source/cxxhelp/inc/util/Decompressor.hxx181
12 files changed, 1907 insertions, 0 deletions
diff --git a/xmlhelp/source/cxxhelp/inc/excep/XmlSearchExceptions.hxx b/xmlhelp/source/cxxhelp/inc/excep/XmlSearchExceptions.hxx
new file mode 100644
index 000000000000..1c1f74b01fd7
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/excep/XmlSearchExceptions.hxx
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: XmlSearchExceptions.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:16:48 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_EXCEP_XMLSEARCHEXCEPTIONS_HXX_
+#define _XMLSEARCH_EXCEP_XMLSEARCHEXCEPTIONS_HXX_
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+
+namespace xmlsearch {
+
+ namespace excep {
+
+
+ class XmlSearchException
+ {
+ public:
+
+ XmlSearchException( const rtl::OUString& message )
+ : _message( message )
+ {
+ }
+
+ rtl::OUString getMessage() const
+ {
+ return _message;
+ }
+
+
+ private:
+
+ rtl::OUString _message;
+ };
+
+
+ class IOException
+ : public virtual XmlSearchException
+ {
+ public:
+
+ IOException( const rtl::OUString& message )
+ : XmlSearchException( message )
+ {
+ }
+ };
+
+
+ class NoFactoryException
+ : public virtual XmlSearchException
+ {
+ public:
+ NoFactoryException( const rtl::OUString& message )
+ : XmlSearchException( message )
+ {
+ }
+ };
+
+
+ class NoSuchBlock
+ : public virtual XmlSearchException
+ {
+ public:
+ NoSuchBlock( const rtl::OUString& message )
+ : XmlSearchException( message )
+ {
+ }
+ };
+
+
+ class IllegalIndexException
+ : public virtual XmlSearchException
+ {
+ public:
+ IllegalIndexException( const rtl::OUString& message )
+ : XmlSearchException( message )
+ {
+ }
+ };
+
+ }
+}
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/qe/ConceptData.hxx b/xmlhelp/source/cxxhelp/inc/qe/ConceptData.hxx
new file mode 100644
index 000000000000..f55f360c5650
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/qe/ConceptData.hxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ConceptData.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:16:59 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_QE_CONCEPTDATA_HXX_
+#define _XMLSEARCH_QE_CONCEPTDATA_HXX_
+
+#ifndef _RTL_REF_HXX_
+#include <rtl/ref.hxx>
+#endif
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef INCLUDED_STL_VECTOR
+#include <vector>
+#define INCLUDED_STL_VECTOR
+#endif
+
+
+namespace xmlsearch {
+
+ namespace qe {
+
+
+ class RoleFiller;
+ class Query;
+ class ContextTables;
+
+ class ConceptData
+ {
+ public:
+
+ ConceptData( sal_Int32 id = 0,
+ sal_Int32 role = 0,
+ double score = 0.0,
+ sal_Int32 queryNo = 0,
+ sal_Int32 nColumns = 0,
+ ContextTables* contextTables = 0 );
+
+ virtual ~ConceptData();
+
+ void acquire() { ++m_nRefcount; }
+ void release() { if( ! --m_nRefcount ) delete this; }
+
+ bool cEquals( ConceptData* r ) { return concept_ == r->concept_; }
+ bool crEquals( ConceptData* r ) { return cEquals( r ) && role_ == r->role_; }
+ bool crqEquals( ConceptData* r ) { return crEquals( r ) && queryNo_ == r->queryNo_; }
+ bool compareWith( ConceptData* r ) { return
+ concept_ < r->concept_ ||
+ cEquals( r ) && role_ < r->role_ ||
+ crEquals( r ) && penalty_ < r->penalty_; }
+
+ void addLast( ConceptData* r );
+
+ sal_Int32 getConcept() const { return concept_; }
+
+ sal_Int32 getQueryMask() const
+ {
+ return ( next_.is() ? next_->getQueryMask() : 0 ) | ( 1 << queryNo_ );
+ }
+
+ void runBy( std::vector< Query* >& queries );
+
+ virtual void generateFillers( std::vector< RoleFiller* >& array, sal_Int32 last );
+
+ sal_Int32 getConcept() { return concept_; }
+
+ sal_uInt8 getRole() { return role_; }
+
+ sal_uInt8 getQuery() { return queryNo_; }
+
+ double getScore() { return penalty_; }
+
+ double getPenalty() { return penalty_; }
+
+
+ protected:
+
+ static const sal_Int32 ProxPerTerm;
+
+ sal_uInt8 queryNo_,nColumns_,role_;
+
+ sal_Int32 concept_,proximity_;
+
+ double penalty_;
+
+ sal_uInt32 m_nRefcount;
+
+ ContextTables* ctx_;
+ rtl::Reference< ConceptData > next_;
+ std::vector< rtl::Reference< RoleFiller > > roleFillers_;
+ };
+
+
+
+ }
+
+}
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/qe/ContextTables.hxx b/xmlhelp/source/cxxhelp/inc/qe/ContextTables.hxx
new file mode 100644
index 000000000000..b14e18ba7500
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/qe/ContextTables.hxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ContextTables.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:17:16 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_QE_CONTEXTTABLES_HXX_
+#define _XMLSEARCH_QE_CONTEXTTABLES_HXX_
+
+#ifndef INCLUDED_STL_VECTOR
+#include <vector>
+#define INCLUDED_STL_VECTOR
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _XMLSEARCH_EXCEP_XMLSEARCHEXCEPTIONS_HXX_
+#include <excep/XmlSearchExceptions.hxx>
+#endif
+
+
+namespace xmlsearch {
+
+ namespace qe {
+
+ /* forward declaration */
+
+ class ContextTables;
+
+
+ /******************************************************************************/
+
+
+ class Tables
+ {
+ public:
+
+ Tables( ContextTables* p );
+
+ ~Tables();
+
+ void setTables( ContextTables* p );
+
+
+ private:
+
+ sal_Int32 initialWordsCachedL_,destsCachedL_,linkTypesCachedL_,seqNumbersCachedL_;
+ sal_Int32 *initialWordsCached_,*destsCached_,*linkTypesCached_,*seqNumbersCached_;
+
+ }; // end class Tables
+
+
+ /******************************************************************************/
+
+
+ class ContextTables
+ {
+ friend class Tables;
+
+ public:
+
+ ContextTables( const std::vector< sal_Int32 >& offsets,
+ sal_Int32 contextDataL,sal_Int8 *contextData,
+ sal_Int32 linkNamesL,rtl::OUString *linkNames );
+
+ ~ContextTables();
+
+ void setMicroindex( sal_Int32 docNo ) throw( xmlsearch::excep::XmlSearchException );
+
+ sal_Int32 parentContext( sal_Int32 context );
+
+ rtl::OUString linkName( sal_Int32 context );
+
+ sal_Int32 linkCode( const rtl::OUString& linkName_ );
+
+ bool* getIgnoredElementsSet( sal_Int32& len, /*out*/
+ const sal_Int32 ignoredElementsL,
+ const rtl::OUString* ignoredElements );
+
+ bool notIgnored( sal_Int32 ctx,
+ sal_Int32 ignoredElementsL,bool* ignoredElements );
+
+ sal_Int32 firstParentWithCode( const sal_Int32 pos,const sal_Int32 linkCode_ );
+
+ sal_Int32 firstParentWithCode2( sal_Int32 pos,const sal_Int32 linkCode_,const sal_Int32 parentCode );
+
+ sal_Int32 firstParentWithCode3( sal_Int32 pos,sal_Int32 linkCode_,sal_Int32 ancestorCode );
+
+ sal_Int32 firstParentWithCode4(sal_Int32 pos, sal_Int32 linkCodesL,sal_Int32* linkCodes );
+
+ sal_Int32 firstParentWithCode5(sal_Int32 pos,sal_Int32 pathCodesL,sal_Int32* pathCodes);
+
+ sal_Int32 firstParentWithCode7( const sal_Int32 pos,const sal_Int32 linkCode_,const sal_Int32 seq );
+
+ bool isGoverning( sal_Int32 context );
+
+ void resetContextSearch();
+
+ sal_Int32 wordContextLin(sal_Int32 wordNumber);
+
+ private:
+
+ sal_Int32 nTextNodes_,initialWordsIndex_,lastDocNo_;
+ sal_Int32 initialWordsL_,destsL_,linkTypesL_,seqNumbersL_,markersL_;
+ sal_Int32 *initialWords_,*dests_,*linkTypes_,*seqNumbers_,*markers_;
+
+ sal_Int32 contextDataL_;
+ sal_Int8 *contextData_; // no
+
+ sal_Int32 linkNamesL_;
+ rtl::OUString *linkNames_; // no
+
+ std::vector<Tables*> cache_;
+ std::vector< sal_Int32 > kTable_,auxArray_;
+
+ const std::vector< sal_Int32 >& offsets_;
+
+ }; // end class ContextTables
+
+
+ /******************************************************************************/
+
+ } // end namespace qe
+
+} // end namespace xmlsearch
+
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/qe/DocGenerator.hxx b/xmlhelp/source/cxxhelp/inc/qe/DocGenerator.hxx
new file mode 100644
index 000000000000..6dc138934c82
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/qe/DocGenerator.hxx
@@ -0,0 +1,303 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: DocGenerator.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:17:32 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_QE_DOCGENERATOR_HXX_
+#define _XMLSEARCH_QE_DOCGENERATOR_HXX_
+
+#ifndef _RTL_REF_HXX_
+#include <rtl/ref.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX__
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _XMLSEARCH_EXCEP_XMLSEARCHEXCEPTIONS_HXX_
+#include <excep/XmlSearchExceptions.hxx>
+#endif
+#ifndef _XMLSEARCH_QE_XMLINDEX_HXX_
+#include <qe/XmlIndex.hxx>
+#endif
+#ifndef _XMLSEARCH_QE_CONCEPTDATA_HXX_
+#include <qe/ConceptData.hxx>
+#endif
+#ifndef _XMLSEARCH_UTIL_COMPRESSORITERATOR_HXX_
+#include <util/CompressorIterator.hxx>
+#endif
+#ifndef _XMLSEARCH_UTIL_DECOMPRESSOR_HXX_
+#include <util/Decompressor.hxx>
+#endif
+
+
+namespace xmlsearch {
+
+ namespace qe {
+
+
+ class Query;
+
+
+ class NonnegativeIntegerGenerator
+ {
+ public:
+
+ static const sal_Int32 END;
+
+ virtual ~NonnegativeIntegerGenerator() { };
+ virtual sal_Int32 first() throw( xmlsearch::excep::XmlSearchException ) = 0;
+ virtual sal_Int32 next() throw( xmlsearch::excep::XmlSearchException ) = 0;
+ };
+
+
+ class NextDocGenerator
+ {
+ public:
+
+ NextDocGenerator( ConceptData* cd,XmlIndex* env );
+
+ ~NextDocGenerator() { delete iterator_; }
+
+ sal_Int32 first() throw( xmlsearch::excep::XmlSearchException )
+ {
+ return ( document_ = ( iterator_ ? iterator_->first() : NonnegativeIntegerGenerator::END ) );
+ }
+
+ sal_Int32 next() throw( xmlsearch::excep::XmlSearchException )
+ {
+ if( iterator_ )
+ return document_ = iterator_->next();
+
+ throw xmlsearch::excep::XmlSearchException( rtl::OUString::createFromAscii( "NextDocGenerator::next ->" ) );
+ }
+
+ sal_Int32 getDocument() { return document_; }
+
+ sal_Int32 getConcept() { return concept_; }
+
+ sal_Int32 getQueryMask() { return queryMask_; }
+
+ rtl::Reference< ConceptData > getTerms() { return terms_; }
+
+ bool smallerThan( NextDocGenerator* other )
+ {
+ return
+ document_ < other->document_
+ ||
+ document_ == other->document_ && concept_ < other->concept_;
+ }
+
+
+ private:
+
+ sal_Int32 document_,concept_,queryMask_;
+ rtl::Reference< ConceptData > terms_;
+ NonnegativeIntegerGenerator* iterator_;
+ };
+
+
+ class NextDocGeneratorHeap
+ {
+ public:
+
+ NextDocGeneratorHeap()
+ : nonEmpty_( false ),
+ heapSize_( 0 ),
+ free_( 0 )
+
+ {
+ }
+
+ ~NextDocGeneratorHeap()
+ {
+ reset();
+ }
+
+ void reset();
+
+ void addGenerator( NextDocGenerator* gen );
+
+ void start();
+
+ bool isNonEmpty() const { return nonEmpty_; }
+
+ void step() throw( xmlsearch::excep::XmlSearchException );
+
+ sal_Int32 getDocument() { return heap_[0]->getDocument(); }
+
+ sal_Int32 getConcept() { return heap_[0]->getConcept(); }
+
+ sal_Int32 getQueryMask() { return heap_[0]->getQueryMask(); }
+
+ rtl::Reference< ConceptData > getTerms() { return heap_[0]->getTerms(); }
+
+ bool atDocument( sal_Int32 document );
+
+
+ private:
+
+ bool nonEmpty_;
+
+ sal_Int32 heapSize_,free_;
+
+ std::vector< NextDocGenerator* > heap_;
+
+ void heapify( sal_Int32 i );
+ };
+
+
+
+ class RoleFiller
+ {
+ public:
+
+ static RoleFiller* STOP() { return &roleFiller_; }
+
+ RoleFiller();
+
+ RoleFiller( sal_Int32 nColumns,
+ ConceptData* first,
+ sal_Int32 role,
+ sal_Int32 pos,
+ sal_Int32 parentContext,
+ sal_Int32 limit );
+
+ ~RoleFiller();
+
+ void acquire() { ++m_nRefcount; }
+ void release() { if( ! --m_nRefcount ) delete this; }
+
+ void scoreList( Query* ,sal_Int32 );
+
+ sal_Int32 getConcept();
+
+ void use( std::vector< RoleFiller*>& place,sal_Int32 query );
+
+ private:
+
+ static RoleFiller roleFiller_;
+
+ sal_uInt32 m_nRefcount;
+ sal_uInt8 fixedRole_;
+ sal_Int16 filled_;
+ sal_Int32 begin_,end_,parentContext_,limit_;
+
+ RoleFiller* next_;
+ std::vector< RoleFiller* > fillers_;
+
+ ConceptData* conceptData_;
+
+ double penalty( Query* query,sal_Int32 nColumns );
+
+ void makeQueryHit( Query* query,sal_Int32 doc,double penalty_ );
+
+ void considerReplacementWith( RoleFiller* replacement );
+
+ double getScore() { return conceptData_->getScore(); }
+ };
+
+
+
+ class ConceptGroupGenerator
+ : public xmlsearch::util::CompressorIterator
+ {
+ public:
+
+ static const sal_Int32 NConceptsInGroup;
+
+ ConceptGroupGenerator();
+
+ ConceptGroupGenerator( sal_Int32 dataL,sal_Int8* data,sal_Int32 index,sal_Int32 k );
+
+ virtual ~ConceptGroupGenerator();
+
+ void init( sal_Int32 bytesL,sal_Int8* bytes,sal_Int32 index,sal_Int32 k );
+
+ bool next() throw( xmlsearch::excep::XmlSearchException );
+
+ void generateFillers( std::vector< RoleFiller* >& array );
+
+ sal_Int32 position() { return last_; }
+
+ void value( sal_Int32 value_ ) { last_ += value_; }
+
+ sal_Int32 decodeConcepts( sal_Int32 k, sal_Int32 shift, sal_Int32 *concepts ) throw( xmlsearch::excep::XmlSearchException );
+
+ void addTerms( sal_Int32 index, ConceptData* terms );
+
+ private:
+
+ static const sal_Int32 BitsInLabel;
+
+ sal_Int32 last_,k1_,k2_;
+ std::vector< rtl::Reference< ConceptData > > table_;
+ xmlsearch::util::Decompressor* bits_;
+ rtl::Reference< ConceptData> cData_;
+ };
+
+
+ class GeneratorHeap
+ {
+ public:
+
+ GeneratorHeap()
+ : heapSize_( 0 ),
+ free_( 0 )
+ { }
+
+ ~GeneratorHeap() { reset(); }
+
+ bool start( std::vector< RoleFiller* >& start ) throw( xmlsearch::excep::XmlSearchException );
+
+ bool next( std::vector< RoleFiller* >& start ) throw( xmlsearch::excep::XmlSearchException );
+
+ void reset();
+
+ void addGenerator( ConceptGroupGenerator* cd );
+
+ private:
+
+ sal_Int32 heapSize_,free_;
+
+ std::vector< ConceptGroupGenerator* > heap_;
+
+ void buildHeap();
+
+ void heapify( sal_Int32 root );
+
+ };
+
+
+
+ }
+}
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/qe/Query.hxx b/xmlhelp/source/cxxhelp/inc/qe/Query.hxx
new file mode 100644
index 000000000000..16a68da76d72
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/qe/Query.hxx
@@ -0,0 +1,346 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: Query.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:17:48 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_QE_QUERY_HXX_
+#define _XMLSEARCH_QE_QUERY_HXX_
+
+#ifndef _SAL_TYPES_H_
+#include <sal/types.h>
+#endif
+#ifndef _RTL_MEMORY_H_
+#include <rtl/memory.h>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _XMLSEARCH_QE_XMLINDEX_HXX_
+#include <qe/XmlIndex.hxx>
+#endif
+
+
+namespace xmlsearch {
+
+ namespace qe {
+
+ class QueryResults;
+ class Search;
+ class ConceptData;
+ class RoleFiller;
+ class ContextTables;
+
+
+ class QueryHit
+ {
+ public:
+
+ QueryHit( sal_Int32 nColumns,double penalty,sal_Int32 doc,sal_Int32 begin,sal_Int32 end )
+ : doc_( doc ),
+ begin_( begin ),
+ end_( end ),
+ matchesL_( 2*nColumns ),
+ matches_( new sal_Int32[ 2*nColumns ] ),
+ penalty_( penalty )
+ {
+ rtl_zeroMemory( matches_,sizeof( sal_Int32 ) * matchesL_ );
+ }
+
+ ~QueryHit() { delete[] matches_; }
+
+ sal_Int32 getDocument() const { return doc_; }
+
+ sal_Int32* getMatches( sal_Int32& matchesL );
+
+ sal_Int32 countOfMatches() const { return matchesL_; }
+
+ sal_Int32 getBegin() const { return begin_; }
+
+ sal_Int32 getEnd() const { return end_; }
+
+ double getPenalty() const { return penalty_; }
+
+ bool betterThan( const QueryHit* o )
+ {
+ if( penalty_ != o->penalty_ )
+ return penalty_ < o->penalty_;
+ else if( begin_ != o->begin_ )
+ return begin_ < o->begin_;
+ else if( end_ != o->end_ )
+ return end_ < o->end_;
+ else
+ return false;
+ }
+
+ bool worseThan( const QueryHit* o )
+ {
+ if( penalty_ != o->penalty_ )
+ return penalty_ > o->penalty_;
+ else if( begin_ != o->begin_ )
+ return begin_ > o->begin_;
+ else if( end_ != o->end_ )
+ return end_ > o->end_;
+ else
+ return false;
+ }
+
+ bool worseThan( double penalty,sal_Int32 begin,sal_Int32 end )
+ {
+ if( penalty_ != penalty )
+ return penalty_ > penalty;
+ else if( begin_ != begin )
+ return begin_ > begin;
+ else if( end_ != end )
+ return end_ > end;
+ else
+ return false;
+ }
+
+ bool compareTo( const QueryHit* o ) const
+ {
+ if( penalty_ != o->penalty_ )
+ return penalty_ < o->penalty_;
+ else if( begin_ != o->begin_ )
+ return begin_ < o->begin_;
+ else if( end_ != o->end_ )
+ return end_ < o->end_;
+ else
+ return false;
+ }
+
+
+ private:
+
+ sal_Int32 doc_,begin_,end_;
+
+ sal_Int32 matchesL_;
+ sal_Int32 *matches_; // ...concept, word number, ...
+
+ double penalty_;
+
+ }; // end class QueryHit
+
+
+
+ class QueryHitData
+ {
+ public:
+
+ QueryHitData( double penalty,const rtl::OUString& document,sal_Int32 termsL, rtl::OUString* terms )
+ : penalty_( penalty ),
+ document_( document ),
+ termsL_( termsL ),
+ terms_( terms ) { }
+
+ ~QueryHitData() { delete[] terms_; }
+
+ rtl::OUString getDocument() const { return document_; }
+
+ double getPenalty() const { return penalty_; }
+
+
+ private:
+
+ double penalty_;
+
+ const rtl::OUString document_;
+
+ sal_Int32 termsL_;
+ rtl::OUString* terms_;
+
+ }; // end class QueryHitData
+
+
+
+ class HitStore
+ {
+ public:
+
+ HitStore( double, sal_Int32,sal_Int32 );
+
+ ~HitStore();
+
+ QueryHit* firstBestQueryHit();
+
+ QueryHit* nextBestQueryHit();
+
+ bool goodEnough( double penalty,sal_Int32 begin,sal_Int32 end );
+
+ QueryHit* createQueryHit( double penalty,sal_Int32 doc,sal_Int32 begin,sal_Int32 end );
+
+ double getCurrentStandard() { return standard_; }
+
+
+ private:
+
+ const sal_Int32 limit_,nColumns_;
+
+ sal_Int32 index_,free_;
+
+ double standard_;
+
+ std::vector< QueryHit* > heap_;
+
+ void heapify( sal_Int32 );
+
+ void quicksort( sal_Int32 p,sal_Int32 r );
+
+ sal_Int32 partition( sal_Int32 p,sal_Int32 r );
+ };
+
+
+
+ class Query
+ {
+ public:
+
+ Query( XmlIndex* env,
+ sal_Int32 nColumns,
+ sal_Int32 nHits,
+ sal_Int32 missingPenaltiesL,
+ double* missingPenalties );
+
+ virtual ~Query();
+
+ void missingTerms( sal_Int32 nMissingTerms );
+
+ virtual void addControlConceptData( Search*,sal_Int32 ) { }
+
+ virtual bool zoned() const { return false; }
+
+ virtual ConceptData* makeConceptData( sal_Int32 col,sal_Int32 concept,double penalty,sal_Int32 queryNo );
+
+ void getHits( std::vector< QueryHitData* >& data,sal_Int32 nHits );
+
+ double lookupPenalty( sal_Int32 pattern ) { return penalties_[ pattern ]; }
+
+ RoleFiller* getRoleFillers() { return roleFillerList_; }
+
+ void resetForNextDocument();
+
+ void saveRoleFillers( RoleFiller* roleFillerList ) { roleFillerList_ = roleFillerList; }
+
+ bool vote();
+
+ sal_Int32 getNColumns() { return nColumns_; }
+
+ QueryHit* maybeCreateQueryHit( double penalty,
+ sal_Int32 doc, sal_Int32 begin, sal_Int32 end, sal_Int32 parentContext);
+
+ void setIgnoredElements( const sal_Int32 ignoredElementsL,const rtl::OUString* ignoredElements );
+
+ double getOutOufOrderPenalty() { return 0.25; }
+
+ double getGapPenalty() { return 0.005; }
+
+ void updateEstimate( sal_Int32 role,double penalty );
+
+
+ protected:
+
+ XmlIndex* env_;
+ ContextTables* ctx_;
+ HitStore store_;
+
+ sal_Int32 nHitsRequested_,nColumns_;
+ double currentStandard_;
+
+ sal_Int32 missingPenaltyL_,upperboundTemplateL_,penaltiesL_;
+ double *missingPenalty_,*upperboundTemplate_,*penalties_;
+
+ sal_Int32 ignoredElementsL_;
+ bool *ignoredElements_;
+
+
+ private:
+
+ bool vote_;
+ double missingTermsPenalty_;
+
+ // for use with Start/Stop
+
+ RoleFiller *roleFillerList_;
+
+ void makePenaltiesTable();
+
+ double computePenalty( sal_Int32 );
+
+ };
+
+
+
+ class PrefixTranslator
+ {
+ public:
+
+ static PrefixTranslator* makePrefixTranslator( const rtl::OUString*,sal_Int32 )
+ {
+ return 0;
+ }
+ };
+
+
+
+
+ class QueryResults;
+
+
+
+ class QueryHitIterator
+ {
+ public:
+
+ QueryHitIterator( const QueryResults* result );
+
+ ~QueryHitIterator();
+
+ bool next();
+
+ QueryHitData* getHit( const PrefixTranslator* ) const;
+
+ double getPenalty();
+
+
+ private:
+
+ bool accessible_;
+ sal_Int32 index_;
+ const QueryResults* result_;
+ };
+
+
+ }
+
+}
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/qe/QueryProcessor.hxx b/xmlhelp/source/cxxhelp/inc/qe/QueryProcessor.hxx
new file mode 100644
index 000000000000..4f1e85cc1fcd
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/qe/QueryProcessor.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: QueryProcessor.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:17:59 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_QE_QUERYPROCESSOR_HXX_
+#define _XMLSEARCH_QE_QUERYPROCESSOR_HXX_
+
+#ifndef INCLUDED_STL_VECTOR
+#include <vector>
+#define INCLUDED_STL_VECTOR
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _XMLSEARCH_EXCEP_XMLSEARCHEXCEPTIONS_HXX_
+#include <excep/XmlSearchExceptions.hxx>
+#endif
+#ifndef _XMLSEARCH_QE_QUERY_HXX_
+#include <qe/Query.hxx>
+#endif
+#ifndef _XMLSEARCH_QE_SEARCH_HXX_
+#include <qe/Search.hxx>
+#endif
+#ifndef _XMLSEARCH_QE_XMLINDEX_HXX_
+#include <xmlsearch/qe/XmlIndex.hxx>
+#endif
+
+
+namespace xmlsearch {
+
+ namespace qe {
+
+
+ class QueryStatement
+ {
+ public:
+
+ QueryStatement( sal_Int32 nHits,
+ const std::vector< rtl::OUString >& terms,
+ const rtl::OUString& scope )
+ : nHits_( nHits ),
+ terms_( terms ),
+ scope_( scope )
+ {
+ }
+
+ ~QueryStatement()
+ {
+ }
+
+
+ const sal_Int32 getHitCount() const { return nHits_; }
+
+ const std::vector< rtl::OUString >& getTerms() const { return terms_; }
+
+ const rtl::OUString getScope() const { return scope_; }
+
+
+ private:
+
+ sal_Int32 nHits_;
+ std::vector< rtl::OUString > terms_;
+ rtl::OUString scope_;
+
+ };
+
+
+
+ class QueryResults
+ {
+ friend class QueryHitIterator;
+
+ public:
+
+ QueryResults( Query*, sal_Int32 );
+
+ ~QueryResults();
+
+ QueryHitIterator* makeQueryHitIterator() const
+ {
+ return new QueryHitIterator( this );
+ }
+
+
+ private:
+
+ std::vector< QueryHitData* > queryHits_;
+ };
+
+
+
+ class QueryProcessor
+ {
+ public:
+
+ QueryProcessor( const rtl::OUString& installDir )
+ throw( xmlsearch::excep::IOException );
+
+ ~QueryProcessor();
+
+ QueryResults* processQuery( const QueryStatement& ment );
+
+ private:
+
+ static const double INFLpenalty;
+
+ Query* processQuery( Search&,const QueryStatement& );
+
+ QueryResults* makeQueryResults( Query*,sal_Int32 nHits );
+
+ XmlIndex env_;
+ };
+
+ }
+
+}
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/qe/Search.hxx b/xmlhelp/source/cxxhelp/inc/qe/Search.hxx
new file mode 100644
index 000000000000..1be2f3e28c15
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/qe/Search.hxx
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: Search.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:18:10 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_QE_SEARCH_HXX_
+#define _XMLSEARCH_QE_SEARCH_HXX_
+
+
+#ifndef INCLUDED_STL_VECTOR
+#include <vector>
+#define INCLUDED_STL_VECTOR
+#endif
+#ifndef _RTL_REF_HXX_
+#include <rtl/ref.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _XMLSEARCH_QE_QUERY_HXX_
+#include <qe/Query.hxx>
+#endif
+#ifndef _XMLSEARCH_QE_XMLINDEX_HXX_
+#include <qe/XmlIndex.hxx>
+#endif
+#ifndef _XMLSEARCH_DB_CONTEXTTABLES_HXX_
+#include <qe/ContextTables.hxx>
+#endif
+#ifndef _XMLSEARCH_QE_CONCEPTDATA_HXX_
+#include <qe/ConceptData.hxx>
+#endif
+#ifndef _XMLSEARCH_QE_DOCGENERATOR_HXX_
+#include <qe/DocGenerator.hxx>
+#endif
+
+
+class QueryFactoryImpl;
+
+
+namespace xmlsearch {
+
+ namespace qe {
+
+
+ class RoleFiller;
+
+
+ class Search
+ {
+ public:
+
+ Search( XmlIndex* env );
+ ~Search();
+
+ Query* addQuery( const rtl::OUString& context,
+ sal_Int32 nValidTerms,sal_Int32 nMissingTerms,sal_Int32 nHits,
+ double variantPenalty,
+ const std::vector< sal_Int32 >& primary,
+ const std::vector< std::vector< sal_Int32 > >& columns );
+
+ void startSearch();
+
+
+ private:
+
+ XmlIndex* env_;
+ QueryFactoryImpl* queryFactory_;
+ NextDocGeneratorHeap nextDocGenHeap_;
+ GeneratorHeap genHeap_;
+ ConceptGroupGenerator firstGenerator_;
+ std::vector< Query* > queries_;
+ ConceptData** conceptVisitor_;
+ std::vector< rtl::Reference< ConceptData > > conceptData_;
+ sal_Int32 free2_,limit_,document_,max_,base_,startingIndex_,nConcepts_;
+ sal_Int32 *concepts_;
+ std::vector<sal_Int32> docConcepts_,queryMasks_,maxConcepts_,kTable_,offsets_;
+
+ sal_Int32 dataL_;
+ sal_Int8 *data_;
+
+ void addTerm( sal_Int32 col,sal_Int32 concept,double score );
+
+ sal_Int32 partition( sal_Int32 p,sal_Int32 r );
+
+ void quicksort( sal_Int32 p,sal_Int32 r );
+
+ void searchDocument();
+
+ sal_Int32 nextDocument( std::vector< RoleFiller* >& start ) throw( xmlsearch::excep::XmlSearchException );
+
+ bool openDocumentIndex( sal_Int32 docNo ) throw( xmlsearch::excep::XmlSearchException );
+
+ ConceptGroupGenerator* makeGenerator( sal_Int32 group ) throw( xmlsearch::excep::XmlSearchException ); //t
+
+ sal_Int32 indexOf( sal_Int32 concept ) throw( xmlsearch::excep::XmlSearchException );
+ };
+
+
+ }
+
+}
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/qe/XmlIndex.hxx b/xmlhelp/source/cxxhelp/inc/qe/XmlIndex.hxx
new file mode 100644
index 000000000000..3963890e78d4
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/qe/XmlIndex.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: XmlIndex.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:18:21 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_QE_XMLINDEX_HXX_
+#define _XMLSEARCH_QE_XMLINDEX_HXX_
+
+#ifndef INCLUDED_STL_VECTOR
+#include <vector>
+#define INCLUDED_STL_VECTOR
+#endif
+#ifndef _RTL_USTRING_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _XMLSEARCH_EXCEP_XMLSEARCHEXCEPTIONS_HXX_
+#include <excep/XmlSearchExceptions.hxx>
+#endif
+#ifndef _XMLSEARCH_QE_CONTEXTTABLES_HXX_
+#include <qe/ContextTables.hxx>
+#endif
+#ifndef _XMLSEARCH_DB_BTREEDICT_HXX_
+#include <db/BtreeDict.hxx>
+#endif
+#ifndef _XMLSEARCH_UTIL_INDEXACCESSOR_HXX_
+#include <util/IndexAccessor.hxx>
+#endif
+
+
+namespace xmlsearch {
+
+ namespace qe {
+
+
+ class QueryHit;
+ class QueryHitData;
+ class NonnegativeIntegerGenerator;
+
+
+ class XmlIndex
+ {
+ public:
+
+ XmlIndex( const rtl::OUString& indexDir )
+ throw( xmlsearch::excep::IOException );
+
+ ~XmlIndex();
+
+ ContextTables* getContextInfo() { return contextTables_; }
+
+
+ sal_Int32 fetch( const rtl::OUString& key ) const throw( xmlsearch::excep::XmlSearchException )
+ {
+ return dict_.fetch( key );
+ }
+
+ rtl::OUString fetch( sal_Int32 key ) const throw( xmlsearch::excep::XmlSearchException )
+ {
+ return dict_.fetch( key );
+ }
+
+ std::vector< sal_Int32 > withPrefix( const rtl::OUString& prefix ) const throw( xmlsearch::excep::XmlSearchException )
+ {
+ return dict_.withPrefix( prefix );
+ }
+
+ bool occursInText( sal_Int32 concept );
+
+ void reset();
+
+ void resetContextSearch() { contextTables_->resetContextSearch(); }
+
+ NonnegativeIntegerGenerator* getDocumentIterator( sal_Int32 concept );
+
+ rtl::OUString documentName( sal_Int32 docNumber ) throw( xmlsearch::excep::XmlSearchException );
+
+ QueryHitData* hitToData( QueryHit* );
+
+ sal_Int8* getPositions( sal_Int32&,sal_Int32 docNo ) throw( xmlsearch::excep::XmlSearchException );
+
+ sal_Int32 getDocumentIndex( sal_Int32 docNo ) { return microIndexOffsets_[ docNo ] - currentBatchOffset_; }
+
+
+ private:
+
+ sal_Int32 currentBatchOffset_,maxDocNumberInCache_;
+
+ xmlsearch::util::IndexAccessor indexAccessor_;
+ xmlsearch::util::RandomAccessStream* positionsFile_;
+ xmlsearch::db::BtreeDict dict_;
+
+ ContextTables* contextTables_;
+
+ sal_Int32 allListsL_;
+ sal_Int8* allLists_;
+
+ bool allInCache_;
+ sal_Int32 positionsL_;
+ sal_Int8 *positions_;
+
+ sal_Int32 contextsDataL_;
+ sal_Int8 *contextsData_;
+
+ sal_Int32 linkNamesL_;
+ rtl::OUString* linkNames_;
+
+ std::vector< sal_Int32 > concepts_,offsets_,documents_,microIndexOffsets_,titles_,contextsOffsets_;
+
+ void readMicroindexes( sal_Int32 docNo ) throw( xmlsearch::excep::IOException );
+ };
+
+
+ }
+
+}
+
+
+
+#endif
+
diff --git a/xmlhelp/source/cxxhelp/inc/util/CompressorIterator.hxx b/xmlhelp/source/cxxhelp/inc/util/CompressorIterator.hxx
new file mode 100644
index 000000000000..9f1a9009f60d
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/util/CompressorIterator.hxx
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: CompressorIterator.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:18:33 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_UTIL_COMPRESSORITERATOR_HXX_
+#define _XMLSEARCH_UTIL_COMPRESSORITERATOR_HXX_
+
+
+namespace xmlsearch {
+
+ namespace util {
+
+ class CompressorIterator
+ {
+ public:
+
+ virtual void value( sal_Int32 ) = 0;
+
+ };
+
+
+ }
+
+}
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/util/ConceptList.hxx b/xmlhelp/source/cxxhelp/inc/util/ConceptList.hxx
new file mode 100644
index 000000000000..ccecd2dd1915
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/util/ConceptList.hxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ConceptList.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:18:44 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_UTIL_CONCEPTLIST_HXX_
+#define _XMLSEARCH_UTIL_CONCEPTLIST_HXX_
+
+#ifndef _XMLSEARCH_EXCEP_XMLSEARCHEXCEPTIONS_HXX_
+#include <excep/XmlSearchExceptions.hxx>
+#endif
+#ifndef _XMLSEARCH_QE_DOCGENERATOR_HXX_
+#include <qe/DocGenerator.hxx>
+#endif
+#ifndef _XMLSEARCH_UTIL_DECOMPRESSOR_HXX_
+#include <util/Decompressor.hxx>
+#endif
+#ifndef _XMLSEARCH_UTIL_COMPRESSORITERATOR_HXX_
+#include <util/CompressorIterator.hxx>
+#endif
+
+
+namespace xmlsearch {
+
+ namespace util {
+
+
+ class CompressorIterator;
+
+
+
+ class ConceptList
+ : public CompressorIterator,
+ public xmlsearch::qe::NonnegativeIntegerGenerator
+ {
+ public:
+
+ ConceptList( sal_Int8* array,sal_Int32 arrl,sal_Int32 index )
+ : k_( array[index] ),
+ value_( 0 ),
+ list_( arrl,array,index + 1 ) { }
+
+ void value( sal_Int32 val ) { value_ += val; }
+
+ sal_Int32 first() throw( xmlsearch::excep::XmlSearchException )
+ {
+ value_ = 0;
+ sal_Int32 ret = list_.readNext( k_,this ) ? value_ : END;
+ return ret;
+ }
+
+ sal_Int32 next() throw( xmlsearch::excep::XmlSearchException )
+ {
+ return list_.readNext( k_,this) ? value_ : END;
+ }
+
+ private:
+
+ sal_Int32 k_,value_;
+ ByteArrayDecompressor list_;
+
+ };
+
+ }
+
+}
+
+
+#endif
diff --git a/xmlhelp/source/cxxhelp/inc/util/DBEnvImpl.hxx b/xmlhelp/source/cxxhelp/inc/util/DBEnvImpl.hxx
new file mode 100644
index 000000000000..08d4ca28dbba
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/util/DBEnvImpl.hxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: DBEnvImpl.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:18:57 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_DB_DBENVIMPL_HXX_
+#define _XMLSEARCH_DB_DBENVIMPL_HXX_
+#endif
+
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+#ifndef _XMLSEARCH_DB_DBENV_HXX_
+#include <db/DBEnv.hxx>
+#endif
+#ifndef _XMLEARCH_UTIL_RANDOMACCESSSTREAM_HXX_
+#include <util/RandomAccessStream.hxx>
+#endif
+#ifndef _XMLSEARCH_DB_BLOCK_HXX_
+#include <db/Block.hxx>
+#endif
+#ifndef _XMLSEARCH_UTIL_INDEXACCESSOR_HXX_
+#include <util/IndexAccessor.hxx>
+#endif
+
+namespace xmlsearch {
+
+ namespace util {
+
+
+ class DBEnvImpl
+ : public xmlsearch::db::DBEnv
+ {
+ public:
+
+ DBEnvImpl( const IndexAccessor& indexDir );
+ virtual ~DBEnvImpl();
+
+ virtual sal_Int32 getEntryHeaderLen() const;
+ virtual sal_Int32 getBlockCount() const;
+ virtual sal_Int32 getMaximumBlockCount() const;
+ virtual sal_Int32 getDataLen() const;
+ virtual sal_Int32 getBlockLen() const;
+ virtual void read( sal_Int32 blNum,xmlsearch::db::Block*& block ) const;
+ virtual void write( sal_Int32 blNum,xmlsearch::db::Block* block );
+
+
+ private:
+
+ xmlsearch::util::RandomAccessStream* file_;
+ };
+
+
+ }
+
+}
diff --git a/xmlhelp/source/cxxhelp/inc/util/Decompressor.hxx b/xmlhelp/source/cxxhelp/inc/util/Decompressor.hxx
new file mode 100644
index 000000000000..5ec1bb0c4e73
--- /dev/null
+++ b/xmlhelp/source/cxxhelp/inc/util/Decompressor.hxx
@@ -0,0 +1,181 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: Decompressor.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: obo $ $Date: 2008-03-25 15:19:12 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef _XMLSEARCH_UTIL_DECOMPRESSOR_HXX_
+#define _XMLSEARCH_UTIL_DECOMPRESSOR_HXX_
+
+#ifndef INCLUDED_STL_VECTOR
+#include <vector>
+#define INCLUDED_STL_VECTOR
+#endif
+#ifndef _XMLSEARCH_EXCEP_XMLSEARCHEXCEPTIONS_HXX_
+#include <excep/XmlSearchExceptions.hxx>
+#endif
+#ifndef _XMLEARCH_UTIL_RANDOMACCESSSTREAM_HXX_
+#include <util/RandomAccessStream.hxx>
+#endif
+
+
+namespace xmlsearch {
+
+ namespace util {
+
+
+ class CompressorIterator;
+
+
+ class Decompressor
+ {
+ public:
+
+ Decompressor()
+ : toRead_( 0 ),
+ path_( 0 )
+ {
+ }
+
+ virtual ~Decompressor() { }
+
+ virtual sal_Int32 getNextByte() = 0;
+
+ sal_Int32 read( sal_Int32 kBits ) throw( xmlsearch::excep::XmlSearchException );
+
+ sal_Int32 ascendingDecode( sal_Int32 k,sal_Int32 start,sal_Int32 *concepts )
+ throw( xmlsearch::excep::XmlSearchException );
+
+ void ascDecode( sal_Int32 k,std::vector< sal_Int32 >& array) throw( xmlsearch::excep::XmlSearchException );
+
+ void decode(sal_Int32 k, sal_Int32* array ) throw( xmlsearch::excep::XmlSearchException );
+
+ void decode( sal_Int32 k,std::vector< sal_Int32 >& array) throw( xmlsearch::excep::XmlSearchException );
+
+ virtual void initReading()
+ {
+ toRead_ = 0;
+ }
+
+ bool readNext( sal_Int32 k,CompressorIterator* it) throw( xmlsearch::excep::XmlSearchException );
+
+ private:
+
+ static const sal_Int32 BitsInByte;
+ static const sal_Int32 NBits;
+
+ sal_Int32 readByte_, toRead_, path_;
+
+ sal_Int32 read() throw( xmlsearch::excep::XmlSearchException );
+
+ sal_Int32 countZeroes() throw( xmlsearch::excep::XmlSearchException );
+
+ };
+
+
+
+
+ class StreamDecompressor
+ : public Decompressor
+ {
+ public:
+
+ StreamDecompressor( RandomAccessStream* in )
+ : in_( in )
+ {
+ }
+
+ ~StreamDecompressor() { }
+
+
+ virtual sal_Int32 getNextByte();
+
+ private:
+
+ RandomAccessStream* in_;
+
+ };
+
+
+
+ class ByteArrayDecompressor
+ : public Decompressor
+ {
+ public:
+
+ ByteArrayDecompressor( sal_Int32 arrayL,sal_Int8* array,sal_Int32 index )
+ {
+ initReading(array,arrayL,index);
+ }
+
+
+ ~ByteArrayDecompressor() { }
+
+ sal_Int32 bytesRead()
+ {
+ return index_ - index0_;
+ }
+
+
+ sal_Int32 getNextByte() throw( xmlsearch::excep::XmlSearchException )
+ {
+ if( arrayL_ <= index_ )
+ throw xmlsearch::excep::XmlSearchException(
+ rtl::OUString::createFromAscii( "ByteArrayDecompressor->getNextByte()" ) );
+ return array_[index_++] & 0xFF;
+ }
+
+
+ private:
+
+ sal_Int32 arrayL_;
+ sal_Int8 *array_;
+
+ sal_Int32 index_,index0_;
+
+ using xmlsearch::util::Decompressor::initReading;
+ void initReading( sal_Int8* array,sal_Int32 arrayL,sal_Int32 index )
+ {
+ arrayL_ = arrayL;
+ array_ = array;
+ index_ = index0_ = index;
+ Decompressor::initReading();
+ }
+
+ };
+
+
+ }
+
+}
+
+
+#endif