xref: /aoo42x/main/l10ntools/source/wtranode.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_l10ntools.hxx"
30 
31 
32 #include "wtranode.hxx"
33 
34 
35 // NOT FULLY DECLARED SERVICES
36 
37 
38 const ByteString	sEmptyString("");
39 
40 
41 WTT_Node::WTT_Node( UINT8	   i_nValue,
42 					WTT_Node * i_pDefaultBranch,
43 					WTT_Node * i_pDefaultBranchForAlphas )
44 	:	nValue(i_nValue),
45 		eType(token_to_keep),
46 		sReplaceString(sEmptyString),
47 		// aBranches,
48 		bIsOnDeleting(char(0))
49 {
50 	int i = 0;
51 	for ( ; i < C_BR_ALPHABASE; i++ )
52 	{
53 		aBranches[i] = i_pDefaultBranch;
54 	}  // end for
55 	for ( ; i < C_NR_OF_BRANCHES; i++ )
56 	{
57 		aBranches[i] = i_pDefaultBranchForAlphas;
58 	}
59 }
60 
61 void
62 WTT_Node::SetBranch( UINT8      i_cBranch,
63 					 WTT_Node *	i_pNode )
64 {
65 	if (i_cBranch < C_NR_OF_BRANCHES)
66 	{
67 		aBranches[i_cBranch] = i_pNode;
68 	}
69 }
70 
71 void
72 WTT_Node::SetAsTokenToReplace(const ByteString & i_sReplaceString)
73 {
74 	sReplaceString = i_sReplaceString;
75 	eType = token_to_replace;
76 }
77 
78 WTT_Node::~WTT_Node()
79 {
80 	// Delete the tree hanging below this node:
81 
82 	bIsOnDeleting = sal_True;	// Avoid double deleting of multiple used nodes.
83 
84 	for (int i = 0; i < C_NR_OF_BRANCHES; i++)
85 	{
86 		if (aBranches[i] != 0 ? ! aBranches[i]->IsOnDeleting() : sal_False)
87 		{
88 			delete aBranches[i];
89 		}
90 	}  // end for
91 }
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109