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/stmstarr.hxx> 30 31 32 // NOT FULLY DECLARED SERVICES 33 #include <x_parse.hxx> 34 35 36 37 StmArrayStatus::StmArrayStatus( intt i_nStatusSize, 38 const INT16 * in_aArrayModel, 39 F_CRTOK i_fTokenCreateFunction, 40 bool in_bIsDefault ) 41 : dpBranches(new StmStatus::Branch[i_nStatusSize]), 42 nNrOfBranches(i_nStatusSize), 43 fTokenCreateFunction(i_fTokenCreateFunction), 44 bIsADefault(in_bIsDefault) 45 { 46 if (in_aArrayModel != 0) 47 { 48 intt count = 0; 49 for (const INT16 * get = in_aArrayModel; count < nNrOfBranches; count++, get++) 50 dpBranches[count] = *get; 51 } 52 else // 53 { 54 memset(dpBranches, 0, nNrOfBranches); 55 } // endif 56 } 57 58 StmArrayStatus::~StmArrayStatus() 59 { 60 delete [] dpBranches; 61 } 62 63 bool 64 StmArrayStatus::SetBranch( intt in_nBranchIx, 65 StmStatus::Branch in_nBranch ) 66 { 67 if ( csv::in_range(intt(0), in_nBranchIx, intt(nNrOfBranches) ) ) 68 { 69 dpBranches[in_nBranchIx] = in_nBranch; 70 return true; 71 } 72 return false; 73 } 74 75 76 StmStatus::Branch 77 StmArrayStatus::NextBy(intt in_nIndex) const 78 { 79 if (in_nIndex < 0) 80 throw X_Parser(X_Parser::x_InvalidChar, "", String::Null_(), 0); 81 82 return in_nIndex < nNrOfBranches 83 ? dpBranches[in_nIndex] 84 : dpBranches[nNrOfBranches - 1]; 85 } 86 87 88 bool 89 StmArrayStatus::IsADefault() const 90 { 91 return bIsADefault; 92 } 93 94 StmArrayStatus * 95 StmArrayStatus::AsArray() 96 { 97 return this; 98 } 99 100