summaryrefslogtreecommitdiff
path: root/xmlhelp/source
diff options
context:
space:
mode:
authorAndreas Bille <abi@openoffice.org>2001-06-22 09:12:51 +0000
committerAndreas Bille <abi@openoffice.org>2001-06-22 09:12:51 +0000
commit107e289cb2c8a829e86eead9aa6cd90795d1f2d4 (patch)
treeb3afeddf82c569eebd839919791703b6daad735d /xmlhelp/source
parent5b9785091c8d35df4515feee2862435ccaa6f85a (diff)
#88514#
Reading from LINKNAMES a serialized object. Hard coding the content of this object not permitted because it is index dependent.
Diffstat (limited to 'xmlhelp/source')
-rw-r--r--xmlhelp/source/cxxhelp/qe/ContextTables.cxx20
-rw-r--r--xmlhelp/source/cxxhelp/qe/XmlIndex.cxx89
2 files changed, 76 insertions, 33 deletions
diff --git a/xmlhelp/source/cxxhelp/qe/ContextTables.cxx b/xmlhelp/source/cxxhelp/qe/ContextTables.cxx
index 9f694f6b1d1d..2b7681fbc2bd 100644
--- a/xmlhelp/source/cxxhelp/qe/ContextTables.cxx
+++ b/xmlhelp/source/cxxhelp/qe/ContextTables.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ContextTables.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: abi $ $Date: 2001-06-19 13:41:05 $
+ * last change: $Author: abi $ $Date: 2001-06-22 10:12:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,18 +70,6 @@ using namespace xmlsearch::qe;
-// Tables::Tables(int[] initialWords,
-// int[] dests,
-// int[] linkTypes,
-// int[] seqNumbers)
-// {
-// _
-// _destsCached = dests;
-// _linkTypesCached = linkTypes;
-// _seqNumbersCached = seqNumbers;
-// }
-
-
Tables::Tables( ContextTables* p )
: initialWordsCached_( new sal_Int32[ initialWordsCachedL_ = p->initialWordsL_ ] ),
destsCached_( new sal_Int32[ destsCachedL_ = p->destsL_ ] ),
@@ -168,8 +156,8 @@ ContextTables::~ContextTables()
delete[] dests_;
delete[] initialWords_;
- for( sal_uInt32 i = 0; i < cache_.size(); ++i );
- // delete cache_[i];
+ for( sal_uInt32 i = 0; i < cache_.size(); ++i )
+ delete cache_[i];
}
diff --git a/xmlhelp/source/cxxhelp/qe/XmlIndex.cxx b/xmlhelp/source/cxxhelp/qe/XmlIndex.cxx
index b87b25970495..0cdbcac05dfe 100644
--- a/xmlhelp/source/cxxhelp/qe/XmlIndex.cxx
+++ b/xmlhelp/source/cxxhelp/qe/XmlIndex.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XmlIndex.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: abi $ $Date: 2001-06-19 13:41:05 $
+ * last change: $Author: abi $ $Date: 2001-06-22 10:12:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -76,7 +76,9 @@
#ifndef _XMLSEARCH_UTIL_DECOMPRESSOR_HXX_
#include <util/Decompressor.hxx>
#endif
-
+#ifndef _XMLSEARCH_QE_QUERY_HXX_
+#include <qe/Query.hxx>
+#endif
using namespace xmlsearch;
using namespace xmlsearch::excep;
@@ -222,18 +224,75 @@ XmlIndex::XmlIndex( const rtl::OUString& indexDir )
}
}
- // Hard coding linknames ( object serialization is hard to undo )
+ // reading linknames
{
+ util::RandomAccessStream* in =
+ indexAccessor_.getStream( rtl::OUString::createFromAscii( "LINKNAMES" ),
+ rtl::OUString::createFromAscii( "r" ) );
+ if( ! in )
+ {
+ delete[] allLists_;
+ delete[] contextsData_;
+ delete[] positions_;
+ delete positionsFile_;
+ throw IOException(
+ rtl::OUString::createFromAscii( "BtreeDict::BtreeDict -> no LINKNAMES/linknames" ) );
+ }
+
+ sal_Int32 len = in->length();
+ char* bff = new char[ 1 + len ], *bff1 = new char[ 1 + len ];
+ bff[ len ] = 0;
+ in->readBytes( reinterpret_cast<sal_Int8*>( bff ),len );
+ delete in;
+
+ // Now the buffer must be densified.
+ int i,len1 = 0;
+ for( i = 0; i < len; ++i )
+ {
+ if( bff[i] )
+ bff1[ len1++ ] = bff[i];
+ }
+ bff1[len] = 0;
+ delete[] bff;
+ rtl::OString aStr( bff1 ); // build a string from the densified buffer;
+ delete[] bff1;
+
+ // Now determine the order
+ rtl::OString LN[8];
+ LN[0] = "text:span";
+ LN[1] = "help:help-text";
+ LN[2] = "help:to-be-embedded";
+ LN[3] = "headingheading";
+ LN[4] = "office:body";
+ LN[5] = "text:p";
+ LN[6] = "office:document";
+ LN[7] = "help:link";
+
+ int idx[8];
+ idx[0] = aStr.indexOf( LN[0] );
+ idx[1] = aStr.indexOf( LN[1] );
+ idx[2] = aStr.indexOf( LN[2] );
+ idx[3] = aStr.indexOf( LN[3] );
+ idx[4] = aStr.indexOf( LN[4] );
+ idx[5] = aStr.indexOf( LN[5] );
+ idx[6] = aStr.indexOf( LN[6] );
+ idx[7] = aStr.indexOf( LN[7] );
+
linkNames_ = new rtl::OUString[ linkNamesL_ = 8 ];
- linkNames_[0] = rtl::OUString::createFromAscii( "help:link" );
- linkNames_[1] = rtl::OUString::createFromAscii( "help:help-text" );
- linkNames_[2] = rtl::OUString::createFromAscii( "text:p" );
- linkNames_[3] = rtl::OUString::createFromAscii( "text:span" );
- linkNames_[4] = rtl::OUString::createFromAscii( "headingheading" );
- linkNames_[5] = rtl::OUString::createFromAscii( "office:body" );
- linkNames_[6] = rtl::OUString::createFromAscii( "help:to-be-embedded" );
- linkNames_[7] = rtl::OUString::createFromAscii( "office:document" );
- }
+
+ for( i = 0; i < 8; ++i )
+ {
+ int first;
+ int Place = 100000;
+ for( int j = 0; j < 8; ++j )
+ {
+ if( idx[j] < Place )
+ Place = idx[ first = j];
+ }
+ idx[first] = 100000;
+ linkNames_[i] = rtl::OUString( LN[first].getStr(),LN[first].getLength(),RTL_TEXTENCODING_UTF8 );
+ }
+ } // end linknames
{
@@ -360,10 +419,6 @@ void XmlIndex::readMicroindexes( sal_Int32 docNo ) throw( xmlsearch::excep::IOEx
}
-#ifndef _XMLSEARCH_QE_QUERY_HXX_
-#include <qe/Query.hxx>
-#endif
-
QueryHitData* XmlIndex::hitToData( QueryHit* hit )
{
sal_Int32 termsL,matchesL;