summaryrefslogtreecommitdiff
path: root/xmlhelp
diff options
context:
space:
mode:
authorAndreas Bille <abi@openoffice.org>2001-06-18 11:10:12 +0000
committerAndreas Bille <abi@openoffice.org>2001-06-18 11:10:12 +0000
commit2d04b18766cc488fe1f1a0dc501c86115235d166 (patch)
tree3af33b8159c14a1029fb0841598fefb7469f3910 /xmlhelp
parent3800e373d88909e0c0aa53c33e5ab805597ca63b (diff)
#87762#
Sorting of keywords now uses XCollator. New style stl-header includes.
Diffstat (limited to 'xmlhelp')
-rw-r--r--xmlhelp/source/cxxhelp/db/BtreeDict.cxx15
-rw-r--r--xmlhelp/source/cxxhelp/provider/contentcaps.cxx5
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.cxx96
-rw-r--r--xmlhelp/source/cxxhelp/provider/services.cxx5
-rw-r--r--xmlhelp/source/cxxhelp/qe/ConceptData.cxx14
-rw-r--r--xmlhelp/source/cxxhelp/util/Decompressor.cxx27
-rw-r--r--xmlhelp/source/cxxhelp/util/IndexAccessor.cxx20
7 files changed, 118 insertions, 64 deletions
diff --git a/xmlhelp/source/cxxhelp/db/BtreeDict.cxx b/xmlhelp/source/cxxhelp/db/BtreeDict.cxx
index c6e9164d5c7e..4818f48733a9 100644
--- a/xmlhelp/source/cxxhelp/db/BtreeDict.cxx
+++ b/xmlhelp/source/cxxhelp/db/BtreeDict.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: BtreeDict.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: abi $ $Date: 2001-06-06 14:48:47 $
+ * last change: $Author: abi $ $Date: 2001-06-18 12:10:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,12 +58,13 @@
*
*
************************************************************************/
+#ifndef INCLUDED_STL_VECTOR
+#include <vector>
+#define INCLUDED_STL_VECTOR
+#endif
#ifndef _RTL_USTRING_HXX_
#include <rtl/ustring.hxx>
#endif
-#ifndef __SGI_STL_VECTOR
-#include <stl/vector>
-#endif
#ifndef _XMLSEARCH_DB_BTREEDICT_HXX_
#include <db/BtreeDict.hxx>
#endif
@@ -94,8 +95,8 @@
const sal_Int32 xmlsearch::db::BtreeDict::ENTHEADERLEN = 6;
const sal_Int32 xmlsearch::db::BtreeDict::BLOCKSIZE = 2048;
const sal_Int32 xmlsearch::db::BtreeDict::HEADERLEN = 8;
-const sal_Int32 xmlsearch::db::BtreeDict::DATALEN
-= xmlsearch::db::BtreeDict::BLOCKSIZE - xmlsearch::db::BtreeDict::HEADERLEN;
+const sal_Int32 xmlsearch::db::BtreeDict::DATALEN =
+xmlsearch::db::BtreeDict::BLOCKSIZE - xmlsearch::db::BtreeDict::HEADERLEN;
const sal_Int32 xmlsearch::db::BtreeDict::nBlocksLimit = 64;
const sal_Int32 xmlsearch::db::BtreeDict::MaxKeyLength = 255;
diff --git a/xmlhelp/source/cxxhelp/provider/contentcaps.cxx b/xmlhelp/source/cxxhelp/provider/contentcaps.cxx
index ad54ec544f96..7adc517a2fbd 100644
--- a/xmlhelp/source/cxxhelp/provider/contentcaps.cxx
+++ b/xmlhelp/source/cxxhelp/provider/contentcaps.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: contentcaps.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: abi $ $Date: 2001-05-16 14:53:27 $
+ * last change: $Author: abi $ $Date: 2001-06-18 12:10:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -77,7 +77,6 @@
#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
#include <com/sun/star/uno/Sequence.hxx>
#endif
-
#ifndef _CONTENT_HXX
#include <provider/content.hxx>
#endif
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index 22420c9b2907..e46795d475b9 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: databases.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: abi $ $Date: 2001-06-13 13:16:11 $
+ * last change: $Author: abi $ $Date: 2001-06-18 12:10:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,6 +59,7 @@
*
************************************************************************/
+#include <berkeleydb/db_cxx.h>
#ifndef _VOS_DIAGNOSE_HXX_
#include <vos/diagnose.hxx>
#endif
@@ -74,13 +75,17 @@
#ifndef _URLPARAMETER_HXX_
#include <provider/urlparameter.hxx>
#endif
-#include <berkeleydb/db_cxx.h>
+#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
+#include <com/sun/star/lang/Locale.hpp>
+#endif
+
using namespace chelp;
using namespace com::sun::star::uno;
using namespace com::sun::star::io;
using namespace com::sun::star::container;
-
+using namespace com::sun::star::i18n;
+using namespace com::sun::star::lang;
Databases::Databases( const rtl::OUString& instPath,
@@ -326,6 +331,30 @@ rtl::OUString Databases::lang( const rtl::OUString& Language )
}
+
+rtl::OUString Databases::country( const rtl::OUString& Language )
+{
+ sal_Int32 idx;
+ if( ( idx = Language.indexOf( '-' ) ) != -1 ||
+ ( idx = Language.indexOf( '_' ) ) != -1 )
+ return Language.copy( 1+idx );
+
+ return rtl::OUString();
+}
+
+
+
+rtl::OUString Databases::variant( const rtl::OUString& System )
+{
+ if( System.compareToAscii( "WIN" ) == 0 ||
+ System.compareToAscii( "MAC" ) )
+ return System;
+ else
+ return rtl::OUString::createFromAscii( "POSIX" );
+}
+
+
+
Db* Databases::getBerkeley( const rtl::OUString& Database,
const rtl::OUString& Language,
bool helpText )
@@ -363,6 +392,35 @@ Db* Databases::getBerkeley( const rtl::OUString& Database,
+Reference< XCollator >
+Databases::getCollator( const rtl::OUString& Language,
+ const rtl::OUString& System )
+{
+ rtl::OUString key = Language;
+
+ osl::MutexGuard aGuard( m_aMutex );
+
+ CollatorTable::iterator it =
+ m_aCollatorTable.insert( CollatorTable::value_type( key,0 ) ).first;
+
+ if( ! it->second.is() )
+ {
+ it->second =
+ Reference< XCollator > (
+ m_xSMgr->createInstance( rtl::OUString::createFromAscii( "com.sun.star.i18n.Collator" ) ),
+ UNO_QUERY );
+
+ it->second->loadDefaultCollator( Locale( lang( Language ),
+ country( Language ),
+ rtl::OUString() ),
+ 0 );
+ }
+
+ return it->second;
+}
+
+
+
KeywordInfo::KeywordInfo()
: pos( 0 ),
@@ -406,21 +464,26 @@ Sequence< rtl::OUString >& KeywordInfo::insertId( sal_Int32 index,rtl::OUString
}
-struct comp
+
+KeywordInfo::Compare::Compare( const Reference< XCollator >& xCollator )
+ : m_xCollator( xCollator )
+{
+}
+
+
+int KeywordInfo::Compare::operator()( const rtl::OUString& l,const rtl::OUString& r )
{
- int operator()( const rtl::OUString& l,const rtl::OUString& r )
- {
- if( l <= r )
- return 1;
- else
- return 0;
- }
-};
+ if( m_xCollator.is() )
+ return ( m_xCollator->compareString( l,r ) <= 0 ) ? 1 : 0;
+ else
+ return ( l <= r ) ? 1 : 0;
+}
+
-void KeywordInfo::sort( std::vector< rtl::OUString >& listKey_ )
+void KeywordInfo::sort( std::vector< rtl::OUString >& listKey_,Compare& comp )
{
- std::sort( listKey_.begin(),listKey_.end(),comp() );
+ std::sort( listKey_.begin(),listKey_.end(),comp );
listKey.realloc( listKey_.size() );
listId.realloc( listKey_.size() );
listAnchor.realloc( listKey_.size() );
@@ -486,7 +549,8 @@ KeywordInfo* Databases::getKeyword( const rtl::OUString& Database,
}
}
- info->sort( listKey_ );
+ info->sort( listKey_,KeywordInfo::Compare( getCollator( Language,
+ rtl::OUString() ) ) );
cursor->close();
table.close( 0 );
diff --git a/xmlhelp/source/cxxhelp/provider/services.cxx b/xmlhelp/source/cxxhelp/provider/services.cxx
index 9f3b3639bdfd..3618a7323f85 100644
--- a/xmlhelp/source/cxxhelp/provider/services.cxx
+++ b/xmlhelp/source/cxxhelp/provider/services.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: services.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: abi $ $Date: 2001-05-16 07:36:23 $
+ * last change: $Author: abi $ $Date: 2001-06-18 12:10:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,7 +68,6 @@
#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
#include <com/sun/star/registry/XRegistryKey.hpp>
#endif
-
#ifndef _PROVIDER_HXX
#include <provider/provider.hxx>
#endif
diff --git a/xmlhelp/source/cxxhelp/qe/ConceptData.cxx b/xmlhelp/source/cxxhelp/qe/ConceptData.cxx
index cabaab328a48..81c7dd6e57ab 100644
--- a/xmlhelp/source/cxxhelp/qe/ConceptData.cxx
+++ b/xmlhelp/source/cxxhelp/qe/ConceptData.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ConceptData.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: abi $ $Date: 2001-05-10 15:25:32 $
+ * last change: $Author: abi $ $Date: 2001-06-18 12:10:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,7 +64,10 @@
#ifndef _XMLSEARCH_QE_QUERY_HXX_
#include <qe/Query.hxx>
#endif
-#include <stdio.h>
+#ifndef _XMLSEARCH_QE_DOCGENERATOR_HXX_
+#include <qe/DocGenerator.hxx>
+#endif
+
using namespace xmlsearch::qe;
@@ -111,11 +114,6 @@ void ConceptData::addLast( ConceptData* r )
}
-#ifndef _XMLSEARCH_QE_DOCGENERATOR_HXX_
-#include <qe/DocGenerator.hxx>
-#endif
-
-
void ConceptData::generateFillers( std::vector< RoleFiller* >& array, sal_Int32 pos )
{
if( array[ queryNo_ ] != RoleFiller::STOP() ) // not 'prohibited'
diff --git a/xmlhelp/source/cxxhelp/util/Decompressor.cxx b/xmlhelp/source/cxxhelp/util/Decompressor.cxx
index d422450baa90..62cf1f76a6b4 100644
--- a/xmlhelp/source/cxxhelp/util/Decompressor.cxx
+++ b/xmlhelp/source/cxxhelp/util/Decompressor.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Decompressor.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: abi $ $Date: 2001-05-08 12:05:06 $
+ * last change: $Author: abi $ $Date: 2001-06-18 12:10:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,9 +58,17 @@
*
*
************************************************************************/
+#ifndef _XMLSEARCH_DB_BLOCK_HXX_
+#include <db/Block.hxx>
+#endif
#ifndef _XMLSEARCH_UTIL_DECOMPRESSOR_HXX_
#include <util/Decompressor.hxx>
#endif
+#ifndef _XMLSEARCH_UTIL_COMPRESSORITERATOR_HXX_
+#include <util/CompressorIterator.hxx>
+#endif
+
+
using namespace xmlsearch;
using namespace xmlsearch::util;
@@ -200,11 +208,6 @@ sal_Int32 Decompressor::countZeroes() throw( excep::XmlSearchException )
}
-#ifndef _XMLSEARCH_UTIL_COMPRESSORITERATOR_HXX_
-#include <util/CompressorIterator.hxx>
-#endif
-
-
bool Decompressor::readNext( sal_Int32 k,CompressorIterator* it) throw( excep::XmlSearchException )
{
if( read() != 0 )
@@ -232,16 +235,6 @@ bool Decompressor::readNext( sal_Int32 k,CompressorIterator* it) throw( excep::X
}
-
-
-// extern sal_Int32 getInteger_( const sal_Int8* );
-
-
-#ifndef _XMLSEARCH_DB_BLOCK_HXX_
-#include <db/Block.hxx>
-#endif
-
-
sal_Int32 StreamDecompressor::getNextByte()
{
sal_Int8 a[4];
diff --git a/xmlhelp/source/cxxhelp/util/IndexAccessor.cxx b/xmlhelp/source/cxxhelp/util/IndexAccessor.cxx
index 6d82293be023..c8aff0d65913 100644
--- a/xmlhelp/source/cxxhelp/util/IndexAccessor.cxx
+++ b/xmlhelp/source/cxxhelp/util/IndexAccessor.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: IndexAccessor.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: abi $ $Date: 2001-05-22 14:57:13 $
+ * last change: $Author: abi $ $Date: 2001-06-18 12:10:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -58,19 +58,20 @@
*
*
************************************************************************/
-#ifdef ABIDEBUG
-#include <abidebug.hxx>
-#endif
-#ifndef _XMLSEARCH_UTIL_INDEXACCESSOR_HXX_
-#include <util/IndexAccessor.hxx>
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
#endif
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif
+#ifndef _XMLSEARCH_UTIL_INDEXACCESSOR_HXX_
+#include <util/IndexAccessor.hxx>
+#endif
#ifndef _XMLEARCH_UTIL_RANDOMACCESSSTREAM_HXX_
#include <util/RandomAccessStream.hxx>
#endif
+
using namespace xmlsearch::util;
@@ -96,8 +97,7 @@ public:
sal_uInt64 nbytesread;
osl::FileBase::RC err = file_.read( (void*)(data), sal_uInt64(num),nbytesread );
- if( err != osl::FileBase::E_None )
- printf( "Bytes requested = %d, Bytes read = %d\n",num,sal_Int32( nbytesread ) );
+ OSL_ASSERT( err == osl::FileBase::E_None );
return sal_Int32( nbytesread );
}
@@ -148,8 +148,8 @@ RandomAccessStreamImpl::RandomAccessStreamImpl( const rtl::OUString& aPath,const
if( file_.open( flags ) != osl::FileBase::E_None )
{
- printf( "RandomAccessStreamImpl closed" );
file_.close();
+ OSL_ASSERT( false );
}
}