xref: /aoo41x/main/l10ntools/source/wtranode.cxx (revision 3cd96b95)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_l10ntools.hxx"
26 
27 
28 #include "wtranode.hxx"
29 
30 
31 // NOT FULLY DECLARED SERVICES
32 
33 
34 const ByteString	sEmptyString("");
35 
36 
WTT_Node(UINT8 i_nValue,WTT_Node * i_pDefaultBranch,WTT_Node * i_pDefaultBranchForAlphas)37 WTT_Node::WTT_Node( UINT8	   i_nValue,
38 					WTT_Node * i_pDefaultBranch,
39 					WTT_Node * i_pDefaultBranchForAlphas )
40 	:	nValue(i_nValue),
41 		eType(token_to_keep),
42 		sReplaceString(sEmptyString),
43 		// aBranches,
44 		bIsOnDeleting(char(0))
45 {
46 	int i = 0;
47 	for ( ; i < C_BR_ALPHABASE; i++ )
48 	{
49 		aBranches[i] = i_pDefaultBranch;
50 	}  // end for
51 	for ( ; i < C_NR_OF_BRANCHES; i++ )
52 	{
53 		aBranches[i] = i_pDefaultBranchForAlphas;
54 	}
55 }
56 
57 void
SetBranch(UINT8 i_cBranch,WTT_Node * i_pNode)58 WTT_Node::SetBranch( UINT8      i_cBranch,
59 					 WTT_Node *	i_pNode )
60 {
61 	if (i_cBranch < C_NR_OF_BRANCHES)
62 	{
63 		aBranches[i_cBranch] = i_pNode;
64 	}
65 }
66 
67 void
SetAsTokenToReplace(const ByteString & i_sReplaceString)68 WTT_Node::SetAsTokenToReplace(const ByteString & i_sReplaceString)
69 {
70 	sReplaceString = i_sReplaceString;
71 	eType = token_to_replace;
72 }
73 
~WTT_Node()74 WTT_Node::~WTT_Node()
75 {
76 	// Delete the tree hanging below this node:
77 
78 	bIsOnDeleting = sal_True;	// Avoid double deleting of multiple used nodes.
79 
80 	for (int i = 0; i < C_NR_OF_BRANCHES; i++)
81 	{
82 		if (aBranches[i] != 0 ? ! aBranches[i]->IsOnDeleting() : sal_False)
83 		{
84 			delete aBranches[i];
85 		}
86 	}  // end for
87 }
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105