%
/************************************************************@@
* Program Name : doc_regist.jsp
* Description : /집계자/내문서함/등록함/문서 등록
* Author : 강원중
* Create Date : 2004.10.11
* History :
@@************************************************************/
%>
<%@ page contentType="text/html; charset=UTF-8"
import="java.net.URLEncoder"
import="kr.co.kihyun.beans.user.HttpSSOLogin" import="java.util.*"
import="java.net.URLDecoder" import="java.io.StringReader"
import="javax.swing.text.html.parser.ParserDelegator"
import="kr.co.kihyun.lang.MString" import="kr.co.kihyun.lang.MInteger"
import="kr.co.kihyun.lang.Encoder" import="kr.co.kihyun.util.Stopwatch"
import="kr.co.kihyun.text.html.HtmlUtil"
import="kr.co.kihyun.text.excel.CalculationForm"
import="kr.co.kihyun.text.html.TagFilter"
import="kr.co.kihyun.text.html.ServletUtil"
import="kr.co.kihyun.text.html.CallbackHandler"
import="kr.co.kihyun.lang.MLong" import="kr.co.kihyun.moumi.Moumi"
import="kr.co.kihyun.moumi.doc.MDoc"
import="kr.co.kihyun.moumi.doc.table.MTable"
import="kr.co.kihyun.moumi.doc.table.MTableType"
import="kr.co.kihyun.moumi.doc.table.TableDefine"
import="kr.co.kihyun.moumi.doc.table.TableCreation"
import="kr.co.kihyun.moumi.doc.table.item.MItem"
import="kr.co.kihyun.moumi.doc.table.item.MItemInfo"
import="kr.co.kihyun.lang.MInteger"
import="kr.co.kihyun.beans.totsys.doc.table.item.ItemList"%>
<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>
<%
try{
/*********** 소요시간 체크 ***********/
Stopwatch stopwatch = new Stopwatch();
long startTime = stopwatch.start();
/********** session내의 userId **********/
String usID = HttpSSOLogin.getLoginID(request);
/********** parameter **********/
Long docID = MLong.parseLong(request.getParameter("docID"),null);
String docName = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("docName")), "UTF-8"),"");
String accAuth = clearXSS(request.getParameter("accAuth"),"");
String stDate = clearXSS(request.getParameter("stDate"),"");
String edDate = clearXSS(request.getParameter("edDate"),"");
String deptIDs = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("deptIDs")), "UTF-8"),"");
String deptCount = clearXSS(request.getParameter("deptCount"),"");
String userIDs = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("userIDs")), "UTF-8"),"");
String userCount = clearXSS(request.getParameter("userCount"),"");
String repDocID = clearXSS(request.getParameter("repDocID"),"");
String docGroupID = clearXSS(request.getParameter("docGroupID"),"");
String isFromFormBox = request.getParameter("isFromFormBox");
String choice = clearXSS(request.getParameter("choice"),"");
String deptNames = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("deptNames")), "UTF-8"),"");
String userNames = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("userNames")), "UTF-8"),"");
//String tableCount = clearXSS(request.getParameter("tableCount"),"");
String confirmDynaTable = clearXSS(request.getParameter("isDynaTable"),"");
String mode = clearXSS(request.getParameter("mode"),"");
String tableDefines = clearXSS(request.getParameter("tableDefines"),"");
String tableTypes = clearXSS(request.getParameter("tableTypes"),"");
String itemNames = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("itemNames")), "UTF-8"),"");
String tableNums = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("tableNums")), "UTF-8"),"");
String colNums = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("colNums")), "UTF-8"),"");
String rowNums = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("rowNums")), "UTF-8"),"");
String itemSizes = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("itemSizes")), "UTF-8"),"");
String itemDescs = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("itemDescs")), "UTF-8"),"");
String itemExprs = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("itemExprs")), "UTF-8"),"");
String itemTypes = clearXSS(URLDecoder.decode(MString.checkNull(request.getParameter("itemTypes")), "UTF-8"),"");
String backDash = clearXSS(request.getParameter("backDash"),"");
String docForm = HtmlUtil.toLowerCase((String)session.getAttribute("docForm"));
String origTableForm = MTable.getTables(docForm); //대문자 살림
String tableForm = docForm;
tableForm = tableForm.replaceAll("
","");
/********** 파싱 **********/
//올린 파일을 String Reader를 이용해서 읽는다.
StringReader strReader = new StringReader(origTableForm);
CallbackHandler cbHandler = new CallbackHandler();
new ParserDelegator().parse(strReader, cbHandler, true);
List> tdList = cbHandler.getTDs();
int tdCount = tdList.size();
//표가 존재 하지 않을때..
if(tdCount < 1 ){
out.println("");
return;
}
//생성할 배열의 사이즈 계산
int allRowCount = 0;
int allColCount = 0;
int rowCount = 0;
int colCount = 0;
for(int i=0; i < tdCount; i++){
rowCount = Integer.parseInt(tdList.get(i).get("row"));
colCount = Integer.parseInt(tdList.get(i).get("col"));
if(allRowCount < rowCount) allRowCount = rowCount;
if(allColCount < colCount) allColCount = colCount;
}
++ allRowCount; //배열이라 0부터 시작 한다.
++ allColCount; //배열이라 0부터 시작 한다.
//각각의 셀에 있는 Text 를 tdTextList 라는 배열에 저장한다.
boolean isDynaTable = true;
String tdName = "";
String tableNumList = "";
String tdText = "";
String tdTextList[][] = new String[allRowCount][allColCount];
StringBuffer itemValueListBuff = new StringBuffer();
MTableType tableType = new MTableType(allRowCount); //table type value
Long reuseDocID = (Long)session.getAttribute("reuseDocID");
int[] itemNumList = null;
String[] itemNameList = null;
String[] itemExprList = null;
int[] itemSizeList = null;
String[] itemDescList = null;
int[] itemTypeList = null;
int[] intTableNumList = null;
int[] rowNumList = null;
int[] colNumList = null;
if(!MString.isNull(itemTypes) && !itemTypes.equals("")) {
if(confirmDynaTable.equals("false")){
isDynaTable = false;
}else{
isDynaTable = true;
}
MItemInfo itemInfo = new MItemInfo();
itemInfo.itemInfo(itemNames, itemSizes, itemExprs, itemDescs, itemTypes, tableNums, colNums, rowNums, 10);
itemNumList = itemInfo.getItemNumList();
itemNameList = itemInfo.getItemNameList();
itemExprList = itemInfo.getItemExprList();
itemSizeList = itemInfo.getItemSizeList();
itemDescList = itemInfo.getItemDescList();
itemTypeList = itemInfo.getItemTypeList();
intTableNumList = itemInfo.getTableNumList();
rowNumList = itemInfo.getRowNumList();
colNumList = itemInfo.getColNumList();
if(backDash.equals("back")){ //make by 구경모 #이전단계로 이동시 수식값 변환내용을 유지
itemExprs = clearXSS(URLDecoder.decode(request.getParameter("itemExprs"), "UTF-8"),"");
//step 1. 앞글자 0: 를 없앤다.
itemExprs = itemExprs.substring(2,itemExprs.length());
//step 2. 번호: 를 없앤다. (step 1,2를 하는이유는 0: 과 100: 에서 0:가 공통으로 들어가는문제가 있기때문.)
for(int i=0; i< itemNameList.length; i++){
itemExprs = itemExprs.replaceAll(MItem.LIST_DELIM+i+":",MItem.LIST_DELIM);
}
//step 3. 특수문자 MItem.LIST_DELIM 기준으로 배열에 넣는다. 이때, itemTypeNameList 배열을 사용한다는것에 주의.
itemExprList = itemExprs.split(MItem.LIST_DELIM);
//step 4. 마지막 수식적용한 번지~배열끝까지 사이가 모두 null일때 배열이 중간에 끊기는현상 보완
String[] itemExprList_temp = itemExprList;
itemExprList = new String[itemNameList.length];
for(int i=0; i< itemNameList.length; i++){
if(i0 || tdText.indexOf("/>") >0 ){
itemValueListBuff.append("itemDescList["+i+"] = 'empty';\n");
}else{
itemValueListBuff.append("itemDescList["+i+"] = '"+tdText+"';\n");
}
}
//itemValueListBuff.append("itemTypeList["+i+"] = '"+MItem.getTypeName(MItem.CHAR)+"';\n");
itemValueListBuff.append("itemTypeList["+i+"] = '"+ (reuseDocID == null ? MItem.getTypeName(MItem.INT) : MItem.getTypeName(itemTypeList[i]))+"';\n");
itemValueListBuff.append("itemExprList["+i+"] = '"+ (reuseDocID == null ? "" : itemExprList[i].replaceAll("'","\\'"))+"';\n");
}
//양식이 동적인 표인지 정적인 표인지 파악
isDynaTable = tableType.isDynaTable();
}
/********** form 필터링 **********/
int sumSusig = TagFilter.getSumSusig(tableForm);
int comboBox = TagFilter.getComboBox(tableForm);
if(!backDash.equals("back")){//이전단계 돌아온것 아닐때만 실행함.
if(sumSusig != -1 ) itemValueListBuff.append(CalculationForm.getCalculationForms(tableForm));
}
if(comboBox != -1) itemValueListBuff.append(TagFilter.excelComboBoxImport(tableForm));
int tableCount = HtmlUtil.getTableCount(tableForm);
tableForm = TagFilter.tdTextToSpace(tableForm);
byte[] formBytes = docForm.getBytes();
session.setAttribute("docForm", tableForm);
TableDefine tableDefine = new TableDefine();
String strTableInfo = tableDefine.insertDiv(tableForm, tdList, cbHandler.getTRCount());
//out.print(itemValueListBuff.toString()); //최종점검
session.setAttribute("modifySuccTargetURI", "/totsys/sysadm/prssbox/doc_form_view.jsp");
%>
|
|
|
|
<%= TableCreation.insertChartOrNumber(strTableInfo, tableTypes) %>
|
|
|
|
<%
}catch(Exception ex){ex.printStackTrace();
out.println(kr.co.kihyun.text.html.ServletUtil.getJavaScript("location='/servlet/kr.co.kihyun.beans.user.HttpSSOLogin?mode=logout';"));
}finally{
}
%>