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: wtratree.hxx,v $
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 ************************************************************************/
32 #ifndef TX3_WTRATREE_HXX
33 #define TX3_WTRATREE_HXX
39 #include <tools/string.hxx>
41 const INT16 C_NR_OF_WTT_RESULTS
= 5;
42 const INT16 C_NR_OF_POSSIBLE_CHARS
= 256;
45 typedef unsigned char u_char
;
46 typedef const char * constr
;
53 This class implements the functionality, that class WordTransformer
55 WordTransformer is dependant of this class, but NOT the other way!
70 CharSet i_nWorkingCharSet
= RTL_TEXTENCODING_MS_1252
);
72 CharSet i_nWorkingCharSet
);
76 const ByteString
& i_sOldString
,
77 const ByteString
& i_sReplaceString
);
80 void InitTransformation(
81 const char * i_sInput
, /// [!=0], a range of i_nInputLength must be valid memory for read.
82 UINT32 i_nInputLength
,
83 UINT32 i_nOutputMaxLength
= STRING_MAXLEN
- 12 );
84 E_Result
TransformNextToken();
87 BOOL
TextEndReached() const;
88 const char * Output() const;
90 // These 3 functions are valid between two calls of
91 // TransformNextToken():
92 E_Result
CurResult() const;
93 ByteString
CurReplacedString() const;
94 ByteString
CurReplacingString() const;
95 char CurHotkey() const;
99 UINT8
CalculateBranch(
100 u_char i_cInputChar
) const;
102 void Handle_Hotkey();
103 void Handle_TokenToKeep();
104 void Handle_TokenToTransform();
108 const u_char
* sInput
;
110 const u_char
* pInputEnd
;
112 u_char
* sOutput
; // DYN
113 UINT32 nOutputMaxLength
;
115 WTT_Node
* dpParsingTreeTop
; // DYN
116 WTT_Node
* pUnknownAlpha
;
117 u_char cChar2Branch
[C_NR_OF_POSSIBLE_CHARS
];
118 u_char c_AE
, c_OE
, c_UE
, c_ae
, c_oe
, c_ue
;
121 const u_char
* pInputCurTokenStart
;
122 const u_char
* pInputPosition
;
123 u_char
* pOutputPosition
;
124 WTT_Node
* pCurParseNode
;
126 // Data which are valid only after a completed call to TransformNextToken()
128 u_char cCurHotkey
; // Letter wich is used as hotkey
129 u_char cCurHotkeySign
; // Letter which is used to assign hotkey ('~'or '&') .
139 WordTransTree::TextEndReached() const
140 { return pInputPosition
== pInputEnd
; }
142 WordTransTree::Output() const
143 { return TextEndReached() ? (constr
) sOutput
: ""; }
144 inline WordTransTree::E_Result
145 WordTransTree::CurResult() const
146 { return eCurResult
; }
148 WordTransTree::CurReplacedString() const
149 { return ByteString((constr
) pInputCurTokenStart
,pInputPosition
-pInputCurTokenStart
); }
151 WordTransTree::CurHotkey() const
152 { return cCurHotkey
; }
154 WordTransTree::CalculateBranch(u_char i_cInputChar
) const
155 { return cChar2Branch
[i_cInputChar
]; }