1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xdictionary.hxx,v $
10 * $Revision: 1.7.24.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _XDICTIONARY_H_
31 #define _XDICTIONARY_H_
33 #include <sal/types.h>
34 #include <osl/module.h>
36 #include <com/sun/star/i18n/Boundary.hpp>
38 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{
40 // Whether to use cell boundary code, currently unused but prepared.
41 #define USE_CELL_BOUNDARY_CODE 0
43 #define CACHE_MAX 32 // max cache structure number
44 #define DEFAULT_SIZE 256 // for boundary size, to avoid alloc and release memory
47 struct WordBreakCache
{
48 sal_Int32 length
; // contents length saved here.
49 sal_Unicode
*contents
; // seperated segment contents.
50 sal_Int32
* wordboundary
; // word boundaries in segments.
51 sal_Int32 size
; // size of wordboundary
54 sal_Bool
equals(const sal_Unicode
*str
, Boundary
& boundary
); // checking cached string
60 const sal_uInt8
* existMark
;
61 const sal_Int16
* index1
;
62 const sal_Int32
* index2
;
63 const sal_Int32
* lenArray
;
64 const sal_Unicode
* dataArea
;
67 sal_Bool japaneseWordBreak
;
69 #if USE_CELL_BOUNDARY_CODE
70 // For CTL breakiterator, where the word boundary should not be inside cell.
71 sal_Bool useCellBoundary
;
72 sal_Int32
* cellBoundary
;
76 xdictionary(const sal_Char
*lang
);
78 Boundary
nextWord( const rtl::OUString
& rText
, sal_Int32 nPos
, sal_Int16 wordType
);
79 Boundary
previousWord( const rtl::OUString
& rText
, sal_Int32 nPos
, sal_Int16 wordType
);
80 Boundary
getWordBoundary( const rtl::OUString
& rText
, sal_Int32 nPos
, sal_Int16 wordType
, sal_Bool bDirection
);
81 void setJapaneseWordBreak();
83 #if USE_CELL_BOUNDARY_CODE
84 void setCellBoundary(sal_Int32
* cellArray
);
88 WordBreakCache cache
[CACHE_MAX
];
90 sal_Bool
seekSegment(const sal_Unicode
*text
, sal_Int32 pos
, sal_Int32 len
, Boundary
& boundary
);
91 WordBreakCache
& getCache(const sal_Unicode
*text
, Boundary
& boundary
);
92 sal_Bool
exists(const sal_Unicode u
);
93 sal_Int32
getLongestMatch(const sal_Unicode
*text
, sal_Int32 len
);