summaryrefslogtreecommitdiff
path: root/i18nutil/inc
diff options
context:
space:
mode:
Diffstat (limited to 'i18nutil/inc')
-rw-r--r--i18nutil/inc/i18nutil/casefolding.hxx84
-rw-r--r--i18nutil/inc/i18nutil/oneToOneMapping.hxx100
-rw-r--r--i18nutil/inc/i18nutil/unicode.hxx67
-rw-r--r--i18nutil/inc/i18nutil/widthfolding.hxx59
-rw-r--r--i18nutil/inc/i18nutil/x_rtl_ustring.h78
5 files changed, 388 insertions, 0 deletions
diff --git a/i18nutil/inc/i18nutil/casefolding.hxx b/i18nutil/inc/i18nutil/casefolding.hxx
new file mode 100644
index 000000000000..4a8030557b4d
--- /dev/null
+++ b/i18nutil/inc/i18nutil/casefolding.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef INCLUDED_I18NUTIL_CASEFOLDING_HXX
+#define INCLUDED_I18NUTIL_CASEFOLDING_HXX
+
+#include <sal/types.h>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+
+namespace com { namespace sun { namespace star { namespace i18n {
+
+#define MappingTypeLowerToUpper (1 << 0) // Upper to Lower mapping
+#define MappingTypeUpperToLower (1 << 1) // Lower to Upper mapping
+#define MappingTypeToUpper (1 << 2) // to Upper mapping
+#define MappingTypeToLower (1 << 3) // to Lower mapping
+#define MappingTypeToTitle (1 << 4) // to Title mapping
+#define MappingTypeSimpleFolding (1 << 5) // Simple Case Folding
+#define MappingTypeFullFolding (1 << 6) // Full Case Folding
+#define MappingTypeMask (MappingTypeLowerToUpper|MappingTypeUpperToLower|\
+ MappingTypeToUpper|MappingTypeToLower|MappingTypeToTitle|\
+ MappingTypeSimpleFolding|MappingTypeFullFolding)
+
+#define ValueTypeNotValue (1 << 7) // Value field is an address
+
+#define CasedLetter (MappingTypeMask) // for final sigmar
+
+struct Value
+{
+ sal_uInt8 type;
+ sal_uInt16 value; // value or address, depend on the type
+};
+
+struct Mapping
+{
+ sal_uInt8 type;
+ sal_Int8 nmap;
+#define NMAPPINGMAX 3
+ sal_Unicode map[NMAPPINGMAX];
+}; // for Unconditional mapping
+
+struct MappingElement
+{
+ MappingElement() {element.nmap = current = 0;}
+ Mapping element;
+ sal_Int8 current;
+};
+
+class casefolding
+{
+public:
+ static Mapping& getValue(const sal_Unicode* str, sal_Int32 pos, sal_Int32 len, com::sun::star::lang::Locale& aLocale, sal_uInt8 nMappingType) throw (com::sun::star::uno::RuntimeException);
+ static Mapping& getConditionalValue(const sal_Unicode* str, sal_Int32 pos, sal_Int32 len, com::sun::star::lang::Locale& aLocale, sal_uInt8 nMappingType) throw (com::sun::star::uno::RuntimeException);
+ static sal_Unicode getNextChar(const sal_Unicode *str, sal_Int32& idx, sal_Int32 len, MappingElement& e, com::sun::star::lang::Locale& aLocale,sal_uInt8 nMappingtype, TransliterationModules moduleLoaded) throw (com::sun::star::uno::RuntimeException);
+
+};
+
+} } } }
+
+#endif
diff --git a/i18nutil/inc/i18nutil/oneToOneMapping.hxx b/i18nutil/inc/i18nutil/oneToOneMapping.hxx
new file mode 100644
index 000000000000..53d4285d31af
--- /dev/null
+++ b/i18nutil/inc/i18nutil/oneToOneMapping.hxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef INCLUDED_I18NUTIL_TRANSLITERATION_ONETOONEMAPPING_HXX
+#define INCLUDED_I18NUTIL_TRANSLITERATION_ONETOONEMAPPING_HXX
+
+#include <utility>
+#include <rtl/ustring.hxx>
+
+namespace com { namespace sun { namespace star { namespace i18n {
+
+class widthfolding;
+
+typedef std::pair< sal_Unicode, sal_Unicode > OneToOneMappingTable_t;
+
+#define MAKE_PAIR(item1,item2) std::make_pair< sal_Unicode, sal_Unicode >((sal_Unicode)item1,(sal_Unicode)item2)
+
+typedef sal_Int8 UnicodePairFlag;
+typedef struct _UnicodePairWithFlag
+{
+ sal_Unicode first;
+ sal_Unicode second;
+ UnicodePairFlag flag;
+} UnicodePairWithFlag;
+
+class oneToOneMapping
+{
+private:
+ // no copy, no substitution
+ oneToOneMapping( const oneToOneMapping& );
+ oneToOneMapping& operator=( const oneToOneMapping& );
+public:
+ oneToOneMapping( OneToOneMappingTable_t *rpTable, const size_t rnSize, const size_t rnUnitSize = sizeof(OneToOneMappingTable_t) );
+ virtual ~oneToOneMapping();
+
+ // make index for fast search
+ // bluedawrf: not used
+// void makeIndex();
+
+ // binary search
+ virtual sal_Unicode find( const sal_Unicode nKey ) const;
+
+ // translator
+ sal_Unicode operator[] ( const sal_Unicode nKey ) const { return find( nKey ); };
+
+protected:
+ OneToOneMappingTable_t *mpTable;
+ size_t mnSize;
+};
+
+class oneToOneMappingWithFlag : public oneToOneMapping
+{
+ friend class widthfolding;
+
+private:
+ // no copy, no substitution
+ oneToOneMappingWithFlag( const oneToOneMappingWithFlag& );
+ oneToOneMappingWithFlag& operator=( const oneToOneMappingWithFlag& );
+public:
+ oneToOneMappingWithFlag( UnicodePairWithFlag *rpTableWF, const size_t rnSize, const UnicodePairFlag rnFlag );
+ virtual ~oneToOneMappingWithFlag();
+
+ // make index for fast search
+ void makeIndex();
+
+ // index search
+ virtual sal_Unicode find( const sal_Unicode nKey ) const;
+protected:
+ UnicodePairWithFlag *mpTableWF;
+ UnicodePairFlag mnFlag;
+ UnicodePairWithFlag **mpIndex[256];
+ sal_Bool mbHasIndex;
+};
+
+} } } }
+
+#endif // _I18N_TRANSLITERATION_ONETOONEMAPPING_HXX_
diff --git a/i18nutil/inc/i18nutil/unicode.hxx b/i18nutil/inc/i18nutil/unicode.hxx
new file mode 100644
index 000000000000..bd52ed5a46dd
--- /dev/null
+++ b/i18nutil/inc/i18nutil/unicode.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef INCLUDED_I18NUTIL_UNICODE_HXX
+#define INCLUDED_I18NUTIL_UNICODE_HXX
+
+#include <com/sun/star/i18n/UnicodeScript.hpp>
+#include <sal/types.h>
+
+typedef struct _ScriptTypeList {
+ sal_Int16 from;
+ sal_Int16 to;
+ sal_Int16 value;
+} ScriptTypeList;
+
+class unicode
+{
+public:
+
+ static sal_Int16 SAL_CALL getUnicodeType( const sal_Unicode ch );
+ static sal_Bool SAL_CALL isUnicodeScriptType( const sal_Unicode ch, sal_Int16 type);
+ static sal_Int16 SAL_CALL getUnicodeScriptType( const sal_Unicode ch, ScriptTypeList *typeList = NULL, sal_Int16 unknownType = 0 );
+ static sal_Unicode SAL_CALL getUnicodeScriptStart(com::sun::star::i18n::UnicodeScript type);
+ static sal_Unicode SAL_CALL getUnicodeScriptEnd(com::sun::star::i18n::UnicodeScript type);
+ static sal_uInt8 SAL_CALL getUnicodeDirection( const sal_Unicode ch );
+ static sal_Int32 SAL_CALL getCharType( const sal_Unicode ch );
+ static sal_Bool SAL_CALL isUpper( const sal_Unicode ch);
+ static sal_Bool SAL_CALL isLower( const sal_Unicode ch);
+ static sal_Bool SAL_CALL isTitle( const sal_Unicode ch);
+ static sal_Bool SAL_CALL isDigit( const sal_Unicode ch);
+ static sal_Bool SAL_CALL isControl( const sal_Unicode ch);
+ static sal_Bool SAL_CALL isPrint( const sal_Unicode ch);
+ static sal_Bool SAL_CALL isBase( const sal_Unicode ch);
+ static sal_Bool SAL_CALL isAlpha( const sal_Unicode ch);
+ static sal_Bool SAL_CALL isSpace( const sal_Unicode ch);
+ static sal_Bool SAL_CALL isWhiteSpace( const sal_Unicode ch);
+ static sal_Bool SAL_CALL isAlphaDigit( const sal_Unicode ch);
+ static sal_Bool SAL_CALL isPunctuation( const sal_Unicode ch);
+};
+
+#endif
+
+
+
diff --git a/i18nutil/inc/i18nutil/widthfolding.hxx b/i18nutil/inc/i18nutil/widthfolding.hxx
new file mode 100644
index 000000000000..556a4a319975
--- /dev/null
+++ b/i18nutil/inc/i18nutil/widthfolding.hxx
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef INCLUDED_I18NUTIL_WIDTHFOLDING_HXX
+#define INCLUDED_I18NUTIL_WIDTHFOLDING_HXX
+
+#include <sal/types.h>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <i18nutil/oneToOneMapping.hxx>
+
+namespace com { namespace sun { namespace star { namespace i18n {
+
+#define WIDTHFOLDNIG_DONT_USE_COMBINED_VU 0x01
+
+class widthfolding
+{
+public:
+ static oneToOneMapping& getfull2halfTable();
+ static oneToOneMapping& gethalf2fullTable();
+
+ static oneToOneMapping& getfull2halfTableForASC();
+ static oneToOneMapping& gethalf2fullTableForJIS();
+
+ static oneToOneMapping& getfullKana2halfKanaTable();
+ static oneToOneMapping& gethalfKana2fullKanaTable();
+
+ static rtl::OUString decompose_ja_voiced_sound_marks(const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, com::sun::star::uno::Sequence< sal_Int32 >& offset, sal_Bool useOffset);
+ static sal_Unicode decompose_ja_voiced_sound_marksChar2Char (sal_Unicode inChar);
+ static rtl::OUString compose_ja_voiced_sound_marks(const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, com::sun::star::uno::Sequence< sal_Int32 >& offset, sal_Bool useOffset, sal_Int32 nFlags = 0 );
+ static sal_Unicode getCompositionChar(sal_Unicode c1, sal_Unicode c2);
+};
+
+
+} } } }
+
+#endif
diff --git a/i18nutil/inc/i18nutil/x_rtl_ustring.h b/i18nutil/inc/i18nutil/x_rtl_ustring.h
new file mode 100644
index 000000000000..028f9718b213
--- /dev/null
+++ b/i18nutil/inc/i18nutil/x_rtl_ustring.h
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef INCLUDED_I18NUTIL_X_RTL_USTRING_H
+#define INCLUDED_I18NUTIL_X_RTL_USTRING_H
+
+#ifndef _RTL_STRING_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+#include <rtl/memory.h>
+#include <rtl/alloc.h>
+
+
+/**
+ * Allocates a new <code>rtl_uString</code> which can hold nLen + 1 characters.
+ * The reference count is 0. The characters of room is not cleared.
+ * This method is similar to rtl_uString_new_WithLength in rtl/ustring.h, but
+ * can allocate a new string more efficiently. You need to "acquire" by such as
+ * OUString( rtl_uString * value ) if you intend to use it for a while.
+ * @param [output] newStr
+ * @param [input] nLen
+ */
+inline void SAL_CALL x_rtl_uString_new_WithLength( rtl_uString ** newStr, sal_Int32 nLen, sal_Int32 _refCount = 0 )
+{
+ *newStr = (rtl_uString*) rtl_allocateMemory ( sizeof(rtl_uString) + sizeof(sal_Unicode) * nLen);
+ (*newStr)->refCount = _refCount;
+ (*newStr)->length = nLen;
+
+ // rtl_uString is defined in rtl/ustring.h as below:
+ //typedef struct _rtl_uString
+ //{
+ // sal_Int32 refCount;
+ // sal_Int32 length;
+ // sal_Unicode buffer[1];
+ //} rtl_uString;
+}
+
+inline rtl_uString * SAL_CALL x_rtl_uString_new_WithLength( sal_Int32 nLen, sal_Int32 _refCount = 0 )
+{
+ rtl_uString *newStr = (rtl_uString*) rtl_allocateMemory ( sizeof(rtl_uString) + sizeof(sal_Unicode) * nLen);
+ newStr->refCount = _refCount;
+ newStr->length = nLen;
+ return newStr;
+}
+
+/**
+ * Release <code>rtl_uString</code> regardless its reference count.
+ */
+inline void SAL_CALL x_rtl_uString_release( rtl_uString * value )
+{
+ rtl_freeMemory(value);
+}
+
+
+#endif // #ifndef _I18N_X_RTL_USTRING_H_