/************************************************************************************************* * 프로그램명 : MTableAnalysis.java 프로그램설명 : 집계문서 등록시 표의 각각의 셀을 분석해줌 작성자 : 강원중 작성일 : 2003.12.03 변경일 : 2004.09.16 **************************************************************************************************/ package kr.co.kihyun.moumi.doc.table; import kr.co.kihyun.moumi.doc.table.item.MItem; import kr.co.kihyun.text.html.Html; public class MTableAnalysis { /** * 0. 나누는 기준 동적표가 기준임 1. 보기 titleForm 추출 => ~ * * * * * 까지 2. 보기 dataForm 추출 => (문서 양식의 data가 시작되는 첫번째 * * * * 까지 3. 보기 tailForm 추출 => 마지막 *
~ (문서 양식의 title의 마지막) ~
~~
* ~~ ㄲ지 **/ /**************** 표 타이틀 폼 ***************/ StringBuilder titleFormBuf = new StringBuilder(); StringBuilder dataFormBuf = new StringBuilder(); StringBuilder tailFormBuf = new StringBuilder(); public MTableAnalysis() { } public MTableAnalysis(String form, int[] itemTypeList) { analysis(form, itemTypeList); } // 등적표 입력 TR에 title이 들어와도 됨 public void analysis(String form, final int[] itemTypeList) { if (form == null) return; int stTBIndex = 0; int edTBIndex = 0; int stTRIndex = 0; int edTRIndex = 0; int stTDIndex = 0; String edTB = ""; String stTR = " MItem.TITLE) isTitle = false; stTDIndex = form.indexOf(stTD, stTDIndex + stTD.length()); tdIndex++; } if (isTitle) { // titleFormBuf.append(titleBGColorInsert(form.substring(stTRIndex, edTRIndex+edTR.length()))); titleFormBuf.append(form.substring(stTRIndex, edTRIndex + edTR.length())); } else { dataFormBuf.append(form.substring(stTRIndex, edTRIndex + edTR.length())); } stTRIndex = form.indexOf(stTR, edTRIndex); if (stTRIndex == -1) break; edTRIndex = form.indexOf(edTR, stTRIndex); if (edTRIndex == -1) break; } edTBIndex = form.lastIndexOf(edTB); if (edTBIndex == -1) return; tailFormBuf.append(form.substring(edTBIndex, form.length())); } // title의 사이의 에 BGColor을 집어 넣어주는 옵션 public String titleBGColorInsert(String rowStr) { return titleBGColorInsert(rowStr, Html.titleBGColor); } public String titleBGColorInsert(String rowStr, String bgcolor) { if (rowStr == null) return null; StringBuffer rowBuf = new StringBuffer(); int stTDIndex = 0; int edTDIndex = 0; while (true) { stTDIndex = rowStr.indexOf("", stTDIndex + 1); if (edTDIndex == -1) break; /****/ rowBuf.append(rowStr.substring(0, edTDIndex) + " bgcolor='" + bgcolor + "' align=center>"); rowStr = rowStr.substring(edTDIndex + 1, rowStr.length()); /****/ /*** * rowBuf.append(rowStr.substring(0, edTDIndex)+ ">"); rowStr = rowStr.substring(edTDIndex+1, * rowStr.length()); ***/ } rowBuf.append(rowStr); return rowBuf.toString(); } // 동적인 표에서 data입력 라인에 title이 들어오면 안됨 public void analysis2(String form, int[] itemTypeList) { if (form == null) return; int stTDIndex; int edTDIndex; int stTRIndex; int edTRIndex; int itemAllCount = itemTypeList.length - 1; // 0부터 시작한 index의 마지막 값을 위해 -1를 적용함 for (int i = 0; i <= itemAllCount; i++) { stTDIndex = form.indexOf("", stTDIndex + 1); if (edTDIndex == -1) break; if (itemTypeList[i] == MItem.TITLE) { // 타이틀일때 titleFormBuf.append(form.substring(0, edTDIndex)); titleFormBuf.append(" bgcolor='"); titleFormBuf.append(Html.titleBGColor); titleFormBuf.append("' align=center>"); } else if (itemTypeList[i] > MItem.TITLE) { // 타이틀일때 if (i > 0 && itemTypeList[i - 1] == MItem.TITLE) { stTRIndex = form.indexOf(""); dataFormBuf.append(form.substring(0, edTRIndex + 5)); tailFormBuf.append(form.substring(edTRIndex + 5, form.length())); } else { dataFormBuf.append(form.substring(0, edTDIndex + 1)); // 출력되는 값들이 생성되는 곳 } } } form = form.substring(edTDIndex + 1, form.length()); } } // data가 입력되는 cell들(form) public String getTitleForm() { return titleFormBuf.toString(); } // data가 입력되는 cell들(form) public String getDataForm() { return dataFormBuf.toString(); } // 마지막 의 끝부터 마지막 까지 public String getTailForm() { return tailFormBuf.toString(); } }