1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 : #ifndef nsILineBreaker_h__
38 : #define nsILineBreaker_h__
39 :
40 : #include "nsISupports.h"
41 :
42 : #include "nscore.h"
43 :
44 : #define NS_LINEBREAKER_NEED_MORE_TEXT -1
45 :
46 : // {5ae68851-d9a3-49fd-9388-58586dad8044}
47 : #define NS_ILINEBREAKER_IID \
48 : { 0x5ae68851, 0xd9a3, 0x49fd, \
49 : { 0x93, 0x88, 0x58, 0x58, 0x6d, 0xad, 0x80, 0x44 } }
50 :
51 : class nsILineBreaker : public nsISupports
52 1404 : {
53 : public:
54 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILINEBREAKER_IID)
55 : virtual PRInt32 Next( const PRUnichar* aText, PRUint32 aLen,
56 : PRUint32 aPos) = 0;
57 :
58 : virtual PRInt32 Prev( const PRUnichar* aText, PRUint32 aLen,
59 : PRUint32 aPos) = 0;
60 :
61 : // Call this on a word with whitespace at either end. We will apply JISx4501
62 : // rules to find breaks inside the word. aBreakBefore is set to the break-
63 : // before status of each character; aBreakBefore[0] will always be false
64 : // because we never return a break before the first character.
65 : // aLength is the length of the aText array and also the length of the aBreakBefore
66 : // output array.
67 : virtual void GetJISx4051Breaks(const PRUnichar* aText, PRUint32 aLength,
68 : PRUint8* aBreakBefore) = 0;
69 : virtual void GetJISx4051Breaks(const PRUint8* aText, PRUint32 aLength,
70 : PRUint8* aBreakBefore) = 0;
71 : };
72 :
73 : NS_DEFINE_STATIC_IID_ACCESSOR(nsILineBreaker, NS_ILINEBREAKER_IID)
74 :
75 : static inline bool
76 858 : NS_IsSpace(PRUnichar u)
77 : {
78 : return u == 0x0020 || // SPACE
79 : u == 0x0009 || // CHARACTER TABULATION
80 : u == 0x000D || // CARRIAGE RETURN
81 : (0x2000 <= u && u <= 0x2006) || // EN QUAD, EM QUAD, EN SPACE,
82 : // EM SPACE, THREE-PER-EM SPACE,
83 : // FOUR-PER-SPACE, SIX-PER-EM SPACE,
84 : (0x2008 <= u && u <= 0x200B) || // PUNCTUATION SPACE, THIN SPACE,
85 : // HAIR SPACE, ZERO WIDTH SPACE
86 858 : u == 0x3000; // IDEOGRAPHIC SPACE
87 : }
88 :
89 : static inline bool
90 850 : NS_NeedsPlatformNativeHandling(PRUnichar aChar)
91 : {
92 850 : return (0x0e01 <= aChar && aChar <= 0x0fff); // Thai, Lao, Tibetan
93 : }
94 :
95 : #endif /* nsILineBreaker_h__ */
|