1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _XDICTIONARY_H_
20 #define _XDICTIONARY_H_
22 #include <sal/types.h>
23 #include <osl/module.h>
25 #include <com/sun/star/i18n/Boundary.hpp>
27 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{
29 #define CACHE_MAX 32 // max cache structure number
30 #define DEFAULT_SIZE 256 // for boundary size, to avoid alloc and release memory
33 struct WordBreakCache
{
34 sal_Int32 length
; // contents length saved here.
35 sal_Unicode
*contents
; // separated segment contents.
36 sal_Int32
* wordboundary
; // word boundaries in segments.
37 sal_Int32 size
; // size of wordboundary
40 sal_Bool
equals(const sal_Unicode
*str
, Boundary
& boundary
); // checking cached string
46 const sal_uInt8
* existMark
;
47 const sal_Int16
* index1
;
48 const sal_Int32
* index2
;
49 const sal_Int32
* lenArray
;
50 const sal_Unicode
* dataArea
;
51 #ifndef DISABLE_DYNLOADING
55 sal_Bool japaneseWordBreak
;
58 xdictionary(const sal_Char
*lang
);
60 Boundary
nextWord( const OUString
& rText
, sal_Int32 nPos
, sal_Int16 wordType
);
61 Boundary
previousWord( const OUString
& rText
, sal_Int32 nPos
, sal_Int16 wordType
);
62 Boundary
getWordBoundary( const OUString
& rText
, sal_Int32 nPos
, sal_Int16 wordType
, sal_Bool bDirection
);
63 void setJapaneseWordBreak();
66 WordBreakCache cache
[CACHE_MAX
];
68 sal_Bool
seekSegment(const OUString
& rText
, sal_Int32 pos
, Boundary
& boundary
);
69 WordBreakCache
& getCache(const sal_Unicode
*text
, Boundary
& boundary
);
70 sal_Bool
exists(const sal_uInt32 u
);
71 sal_Int32
getLongestMatch(const sal_Unicode
*text
, sal_Int32 len
);
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */