LCOV - code coverage report
Current view: top level - i18npool/inc - xdictionary.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 3 3 100.0 %
Date: 2014-11-03 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef INCLUDED_I18NPOOL_INC_XDICTIONARY_HXX
      20             : #define INCLUDED_I18NPOOL_INC_XDICTIONARY_HXX
      21             : 
      22             : #include <sal/types.h>
      23             : #include <osl/module.h>
      24             : 
      25             : #include <com/sun/star/i18n/Boundary.hpp>
      26             : 
      27             : namespace com { namespace sun { namespace star { namespace i18n {
      28             : 
      29             : #define CACHE_MAX 32        // max cache structure number
      30             : #define DEFAULT_SIZE 256    // for boundary size, to avoid alloc and release memory
      31             : 
      32             : // cache structure.
      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
      38             : 
      39             :     WordBreakCache();
      40             :     bool equals(const sal_Unicode *str, Boundary& boundary);    // checking cached string
      41             : };
      42             : 
      43             : struct xdictionarydata
      44             : {
      45             :     const sal_uInt8  * existMark;
      46             :     const sal_Int16  * index1;
      47             :     const sal_Int32  * index2;
      48             :     const sal_Int32  * lenArray;
      49             :     const sal_Unicode* dataArea;
      50         120 :     xdictionarydata() :
      51             :         existMark( NULL ),
      52             :         index1( NULL ),
      53             :         index2( NULL ),
      54             :         lenArray( NULL ),
      55         120 :         dataArea( NULL )
      56             :     {
      57         120 :     }
      58             : };
      59             : 
      60             : class xdictionary
      61             : {
      62             : private:
      63             :     xdictionarydata data;
      64             :     void initDictionaryData(const sal_Char *lang);
      65             : 
      66             :     Boundary boundary;
      67             :     bool japaneseWordBreak;
      68             : 
      69             : public:
      70             :     xdictionary(const sal_Char *lang);
      71             :     ~xdictionary();
      72             :     Boundary nextWord( const OUString& rText, sal_Int32 nPos, sal_Int16 wordType);
      73             :     Boundary previousWord( const OUString& rText, sal_Int32 nPos, sal_Int16 wordType);
      74             :     Boundary getWordBoundary( const OUString& rText, sal_Int32 nPos, sal_Int16 wordType, bool bDirection );
      75             :     void setJapaneseWordBreak();
      76             : 
      77             : private:
      78             :     WordBreakCache cache[CACHE_MAX];
      79             :     OUString segmentCachedString;
      80             :     Boundary segmentCachedBoundary;
      81             : 
      82             :     bool        seekSegment(const OUString& rText, sal_Int32 pos, Boundary& boundary);
      83             :     WordBreakCache& getCache(const sal_Unicode *text, Boundary& boundary);
      84             :     bool        exists(const sal_uInt32 u);
      85             :     sal_Int32       getLongestMatch(const sal_Unicode *text, sal_Int32 len);
      86             : };
      87             : 
      88             : } } } }
      89             : 
      90             : #endif
      91             : 
      92             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10