LibreOffice Module i18npool (master) 1
xdictionary.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
21#include <osl/file.h>
22#include <sal/types.h>
23
24#include <com/sun/star/i18n/Boundary.hpp>
25
26namespace i18npool {
27
28#define CACHE_MAX 32 // max cache structure number
29#define DEFAULT_SIZE 256 // for boundary size, to avoid alloc and release memory
30
31// cache structure.
33 sal_Unicode *contents; // separated segment contents.
34 sal_Int32* wordboundary; // word boundaries in segments.
35 sal_Int32 length; // contents length saved here.
36 sal_Int32 size; // size of wordboundary
37
39 bool equals(const sal_Unicode *str, css::i18n::Boundary const & boundary) const; // checking cached string
40};
41
43{
45 const sal_Int16 * index1;
46 const sal_Int32 * index2;
47 const sal_Int32 * lenArray;
50 existMark( nullptr ),
51 index1( nullptr ),
52 index2( nullptr ),
53 lenArray( nullptr ),
54 dataArea( nullptr )
55 {
56 }
57};
58
60{
61private:
63 void initDictionaryData(const char *lang);
64
65 css::i18n::Boundary boundary;
67#ifdef DICT_JA_ZH_IN_DATAFILE
68 oslFileHandle m_aFileHandle;
69 sal_uInt64 m_nFileSize;
70 char* m_pMapping;
71#endif
72
73public:
74 xdictionary(const char *lang);
76 css::i18n::Boundary nextWord( const OUString& rText, sal_Int32 nPos, sal_Int16 wordType);
77 css::i18n::Boundary previousWord( const OUString& rText, sal_Int32 nPos, sal_Int16 wordType);
78 css::i18n::Boundary const & getWordBoundary( const OUString& rText, sal_Int32 nPos, sal_Int16 wordType, bool bDirection );
80
81private:
84 css::i18n::Boundary segmentCachedBoundary;
85
86 bool seekSegment(const OUString& rText, sal_Int32 pos, css::i18n::Boundary& boundary);
87 WordBreakCache& getCache(const sal_Unicode *text, css::i18n::Boundary const & boundary);
88 bool exists(const sal_uInt32 u) const;
89 sal_Int32 getLongestMatch(const sal_Unicode *text, sal_Int32 len) const;
90};
91
92}
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::i18n::Boundary nextWord(const OUString &rText, sal_Int32 nPos, sal_Int16 wordType)
css::i18n::Boundary boundary
Definition: xdictionary.hxx:65
sal_Int32 getLongestMatch(const sal_Unicode *text, sal_Int32 len) const
void initDictionaryData(const char *lang)
css::i18n::Boundary previousWord(const OUString &rText, sal_Int32 nPos, sal_Int16 wordType)
WordBreakCache cache[CACHE_MAX]
Definition: xdictionary.hxx:82
css::i18n::Boundary const & getWordBoundary(const OUString &rText, sal_Int32 nPos, sal_Int16 wordType, bool bDirection)
bool seekSegment(const OUString &rText, sal_Int32 pos, css::i18n::Boundary &boundary)
WordBreakCache & getCache(const sal_Unicode *text, css::i18n::Boundary const &boundary)
css::i18n::Boundary segmentCachedBoundary
Definition: xdictionary.hxx:84
OUString segmentCachedString
Definition: xdictionary.hxx:83
xdictionarydata data
Definition: xdictionary.hxx:62
bool exists(const sal_uInt32 u) const
xdictionary(const char *lang)
Definition: xdictionary.cxx:63
Constant values shared between i18npool and, for example, the number formatter.
bool equals(const sal_Unicode *str, css::i18n::Boundary const &boundary) const
const sal_Unicode * dataArea
Definition: xdictionary.hxx:48
const sal_Int32 * index2
Definition: xdictionary.hxx:46
const sal_Int32 * lenArray
Definition: xdictionary.hxx:47
const sal_uInt8 * existMark
Definition: xdictionary.hxx:44
const sal_Int16 * index1
Definition: xdictionary.hxx:45
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
#define CACHE_MAX
Definition: xdictionary.hxx:28