1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #ifndef TX3_WTRATREE_HXX
31 #define TX3_WTRATREE_HXX
37 #include <tools/string.hxx>
39 const INT16 C_NR_OF_WTT_RESULTS
= 5;
40 const INT16 C_NR_OF_POSSIBLE_CHARS
= 256;
43 typedef unsigned char u_char
;
44 typedef const char * constr
;
51 This class implements the functionality, that class WordTransformer
53 WordTransformer is dependant of this class, but NOT the other way!
68 CharSet i_nWorkingCharSet
= RTL_TEXTENCODING_MS_1252
);
70 CharSet i_nWorkingCharSet
);
74 const ByteString
& i_sOldString
,
75 const ByteString
& i_sReplaceString
);
78 void InitTransformation(
79 const char * i_sInput
, /// [!=0], a range of i_nInputLength must be valid memory for read.
80 UINT32 i_nInputLength
,
81 UINT32 i_nOutputMaxLength
= STRING_MAXLEN
- 12 );
82 E_Result
TransformNextToken();
85 sal_Bool
TextEndReached() const;
86 const char * Output() const;
88 // These 3 functions are valid between two calls of
89 // TransformNextToken():
90 E_Result
CurResult() const;
91 ByteString
CurReplacedString() const;
92 ByteString
CurReplacingString() const;
93 char CurHotkey() const;
97 UINT8
CalculateBranch(
98 u_char i_cInputChar
) const;
100 void Handle_Hotkey();
101 void Handle_TokenToKeep();
102 void Handle_TokenToTransform();
106 const u_char
* sInput
;
108 const u_char
* pInputEnd
;
110 u_char
* sOutput
; // DYN
111 UINT32 nOutputMaxLength
;
113 WTT_Node
* dpParsingTreeTop
; // DYN
114 WTT_Node
* pUnknownAlpha
;
115 u_char cChar2Branch
[C_NR_OF_POSSIBLE_CHARS
];
116 u_char c_AE
, c_OE
, c_UE
, c_ae
, c_oe
, c_ue
;
119 const u_char
* pInputCurTokenStart
;
120 const u_char
* pInputPosition
;
121 u_char
* pOutputPosition
;
122 WTT_Node
* pCurParseNode
;
124 // Data which are valid only after a completed call to TransformNextToken()
126 u_char cCurHotkey
; // Letter wich is used as hotkey
127 u_char cCurHotkeySign
; // Letter which is used to assign hotkey ('~'or '&') .
137 WordTransTree::TextEndReached() const
138 { return pInputPosition
== pInputEnd
; }
140 WordTransTree::Output() const
141 { return TextEndReached() ? (constr
) sOutput
: ""; }
142 inline WordTransTree::E_Result
143 WordTransTree::CurResult() const
144 { return eCurResult
; }
146 WordTransTree::CurReplacedString() const
147 { return ByteString((constr
) pInputCurTokenStart
,pInputPosition
-pInputCurTokenStart
); }
149 WordTransTree::CurHotkey() const
150 { return cCurHotkey
; }
152 WordTransTree::CalculateBranch(u_char i_cInputChar
) const
153 { return cChar2Branch
[i_cInputChar
]; }
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */