merged tag ooo/OOO330_m14
[LibreOffice.git] / i18npool / inc / xdictionary.hxx
blob99a52b6ea1b03bea03a9726d7f004de861cdf978
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef _XDICTIONARY_H_
28 #define _XDICTIONARY_H_
30 #include <sal/types.h>
31 #include <osl/module.h>
33 #include <com/sun/star/i18n/Boundary.hpp>
35 namespace com { namespace sun { namespace star { namespace i18n {
37 // Whether to use cell boundary code, currently unused but prepared.
38 #define USE_CELL_BOUNDARY_CODE 0
40 #define CACHE_MAX 32 // max cache structure number
41 #define DEFAULT_SIZE 256 // for boundary size, to avoid alloc and release memory
43 // cache structure.
44 struct WordBreakCache {
45 sal_Int32 length; // contents length saved here.
46 sal_Unicode *contents; // seperated segment contents.
47 sal_Int32* wordboundary; // word boundaries in segments.
48 sal_Int32 size; // size of wordboundary
50 WordBreakCache();
51 sal_Bool equals(const sal_Unicode *str, Boundary& boundary); // checking cached string
54 class xdictionary
56 private:
57 const sal_uInt8 * existMark;
58 const sal_Int16 * index1;
59 const sal_Int32 * index2;
60 const sal_Int32 * lenArray;
61 const sal_Unicode* dataArea;
62 oslModule hModule;
63 Boundary boundary;
64 sal_Bool japaneseWordBreak;
66 #if USE_CELL_BOUNDARY_CODE
67 // For CTL breakiterator, where the word boundary should not be inside cell.
68 sal_Bool useCellBoundary;
69 sal_Int32* cellBoundary;
70 #endif
72 public:
73 xdictionary(const sal_Char *lang);
74 ~xdictionary();
75 Boundary nextWord( const rtl::OUString& rText, sal_Int32 nPos, sal_Int16 wordType);
76 Boundary previousWord( const rtl::OUString& rText, sal_Int32 nPos, sal_Int16 wordType);
77 Boundary getWordBoundary( const rtl::OUString& rText, sal_Int32 nPos, sal_Int16 wordType, sal_Bool bDirection );
78 void setJapaneseWordBreak();
80 #if USE_CELL_BOUNDARY_CODE
81 void setCellBoundary(sal_Int32* cellArray);
82 #endif
84 private:
85 WordBreakCache cache[CACHE_MAX];
87 sal_Bool seekSegment(const rtl::OUString& rText, sal_Int32 pos, Boundary& boundary);
88 WordBreakCache& getCache(const sal_Unicode *text, Boundary& boundary);
89 sal_Bool exists(const sal_uInt32 u);
90 sal_Int32 getLongestMatch(const sal_Unicode *text, sal_Int32 len);
93 } } } }
95 #endif