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 #include <precomp.h>
29 #include <tokens/stmstar2.hxx>
30 
31 
32 // NOT FULLY DECLARED SERVICES
33 #include <x_parse2.hxx>
34 
35 
36 
37 StmArrayStatu2::StmArrayStatu2( intt			i_nStatusSize,
38 								const INT16 * 	in_aArrayModel,
39 								uintt			i_nTokenId,
40 							    bool			in_bIsDefault )
41 	:	dpBranches(new StmStatu2::Branch[i_nStatusSize]),
42 		nNrOfBranches(i_nStatusSize),
43 		nTokenId(UINT16(i_nTokenId)),
44 		bIsADefault(in_bIsDefault)
45 {
46 	// KORR_FUTURE: Interface of StmArrayStatu2() has to be changed.
47 	csv_assert(i_nTokenId < 64536);
48 
49 	if (in_aArrayModel != 0)
50 	{
51 		intt count = 0;
52 		for (const INT16 * get = in_aArrayModel; count < nNrOfBranches; count++, get++)
53 			dpBranches[count] = *get;
54 	}
55 	else //
56 	{
57 		memset(dpBranches, 0, nNrOfBranches);
58 	}  // endif
59 }
60 
61 StmArrayStatu2::~StmArrayStatu2()
62 {
63 	delete [] dpBranches;
64 }
65 
66 bool
67 StmArrayStatu2::SetBranch( intt    		 	 in_nBranchIx,
68 						   StmStatu2::Branch in_nBranch )
69 {
70 	if ( csv::in_range(intt(0), in_nBranchIx, intt(nNrOfBranches) ) )
71 	{
72 		dpBranches[in_nBranchIx] = in_nBranch;
73 		return true;
74 	}
75 	return false;
76 }
77 
78 
79 StmStatu2::Branch
80 StmArrayStatu2::NextBy(intt in_nIndex) const
81 {
82 	if (in_nIndex < 0)
83 		throw X_AutodocParser(X_AutodocParser::x_InvalidChar);
84 
85 	return in_nIndex < nNrOfBranches
86 				?	dpBranches[in_nIndex]
87 				:   dpBranches[nNrOfBranches - 1];
88 }
89 
90 
91 bool
92 StmArrayStatu2::IsADefault() const
93 {
94 	return bIsADefault;
95 }
96 
97 StmArrayStatu2 *
98 StmArrayStatu2::AsArray()
99 {
100 	return this;
101 }
102 
103