1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
29 #ifndef TX3_WTRATREE_HXX
30 #define TX3_WTRATREE_HXX
36 #include <tools/string.hxx>
38 const INT16 C_NR_OF_WTT_RESULTS
= 5;
39 const INT16 C_NR_OF_POSSIBLE_CHARS
= 256;
42 typedef unsigned char u_char
;
43 typedef const char * constr
;
50 This class implements the functionality, that class WordTransformer
52 WordTransformer is dependant of this class, but NOT the other way!
67 CharSet i_nWorkingCharSet
= RTL_TEXTENCODING_MS_1252
);
69 CharSet i_nWorkingCharSet
);
73 const ByteString
& i_sOldString
,
74 const ByteString
& i_sReplaceString
);
77 void InitTransformation(
78 const char * i_sInput
, /// [!=0], a range of i_nInputLength must be valid memory for read.
79 UINT32 i_nInputLength
,
80 UINT32 i_nOutputMaxLength
= STRING_MAXLEN
- 12 );
81 E_Result
TransformNextToken();
84 BOOL
TextEndReached() const;
85 const char * Output() const;
87 // These 3 functions are valid between two calls of
88 // TransformNextToken():
89 E_Result
CurResult() const;
90 ByteString
CurReplacedString() const;
91 ByteString
CurReplacingString() const;
92 char CurHotkey() const;
96 UINT8
CalculateBranch(
97 u_char i_cInputChar
) const;
100 void Handle_TokenToKeep();
101 void Handle_TokenToTransform();
105 const u_char
* sInput
;
107 const u_char
* pInputEnd
;
109 u_char
* sOutput
; // DYN
110 UINT32 nOutputMaxLength
;
112 WTT_Node
* dpParsingTreeTop
; // DYN
113 WTT_Node
* pUnknownAlpha
;
114 u_char cChar2Branch
[C_NR_OF_POSSIBLE_CHARS
];
115 u_char c_AE
, c_OE
, c_UE
, c_ae
, c_oe
, c_ue
;
118 const u_char
* pInputCurTokenStart
;
119 const u_char
* pInputPosition
;
120 u_char
* pOutputPosition
;
121 WTT_Node
* pCurParseNode
;
123 // Data which are valid only after a completed call to TransformNextToken()
125 u_char cCurHotkey
; // Letter wich is used as hotkey
126 u_char cCurHotkeySign
; // Letter which is used to assign hotkey ('~'or '&') .
136 WordTransTree::TextEndReached() const
137 { return pInputPosition
== pInputEnd
; }
139 WordTransTree::Output() const
140 { return TextEndReached() ? (constr
) sOutput
: ""; }
141 inline WordTransTree::E_Result
142 WordTransTree::CurResult() const
143 { return eCurResult
; }
145 WordTransTree::CurReplacedString() const
146 { return ByteString((constr
) pInputCurTokenStart
,pInputPosition
-pInputCurTokenStart
); }
148 WordTransTree::CurHotkey() const
149 { return cCurHotkey
; }
151 WordTransTree::CalculateBranch(u_char i_cInputChar
) const
152 { return cChar2Branch
[i_cInputChar
]; }