한컴한글 파일 생성 처리방법 변경
parent
e64a95c3cd
commit
1a9fbb4aa6
@ -1,128 +0,0 @@
|
||||
package cokr.xit.base.file.hwp;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import cokr.xit.fims.cmmn.Print;
|
||||
import cokr.xit.fims.cmmn.PrintOption;
|
||||
import cokr.xit.fims.cmmn.hwp.AddUtil;
|
||||
import cokr.xit.fims.cmmn.hwp.format.HWPFormat;
|
||||
import cokr.xit.foundation.data.DataObject;
|
||||
import kr.dogfoot.hwplib.object.HWPFile;
|
||||
import kr.dogfoot.hwplib.reader.HWPReader;
|
||||
|
||||
public class HWPWriter {
|
||||
protected Print print;
|
||||
protected HWPFormat format;
|
||||
|
||||
public void setFormat(HWPFormat format) {
|
||||
this.format = format;
|
||||
};
|
||||
|
||||
public HWPFormat getFormat() {
|
||||
return this.format;
|
||||
};
|
||||
|
||||
public void setPrint(Print print) {
|
||||
this.print = print;
|
||||
};
|
||||
|
||||
public Map<String, Object> makeFileFromHwpFormat(String formatType, PrintOption printOption, List<DataObject> dataObjectList) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
this.format.setting(this.print);
|
||||
|
||||
|
||||
int totalDataCount = dataObjectList.size();
|
||||
List<String> partFileList = new ArrayList<>();
|
||||
this.format.calcTotalPartFileCount(totalDataCount);
|
||||
|
||||
|
||||
try {
|
||||
|
||||
int dataIndex = 0;
|
||||
for(int partFileIndex = 0; partFileIndex < this.format.getTotalPartFileCount(); partFileIndex++) {
|
||||
|
||||
//새 파일 생성
|
||||
String resultHwpPath = this.format.newFileFromFormatFile(this.print);
|
||||
HWPFile resultFile = HWPReader.fromFile(resultHwpPath);
|
||||
|
||||
//공통사항 세팅
|
||||
this.format.writeGlobalInfo(resultFile, dataObjectList, printOption, this.print);
|
||||
|
||||
kr.dogfoot.hwplib.writer.HWPWriter.toFile(resultFile, resultHwpPath);
|
||||
|
||||
//데이터 건별 처리
|
||||
for(int recordIndex = 0; recordIndex < this.format.getRecordPerPartFile(); recordIndex++) {
|
||||
if(dataIndex < dataObjectList.size()) {
|
||||
DataObject dataObject = dataObjectList.get(dataIndex);
|
||||
|
||||
if(formatType.equals("list")) {
|
||||
InputStream attachFormatIS = new ClassPathResource(this.format.getAttachFormatFilePath()).getInputStream();
|
||||
HWPFile attachFormatFile = HWPReader.fromInputStream(attachFormatIS);
|
||||
|
||||
this.format.writeSingleDataInfo(null, attachFormatFile, dataObject, this.print);
|
||||
|
||||
AddUtil.insertTableInCell(attachFormatFile, resultFile, "내부");
|
||||
|
||||
} else if(formatType.equals("info")){
|
||||
|
||||
this.format.writeSingleDataInfo(resultFile, null, dataObject, this.print);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(formatType.equals("list")) {
|
||||
dataIndex++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!formatType.equals("list")) {
|
||||
dataIndex++;
|
||||
}
|
||||
|
||||
kr.dogfoot.hwplib.writer.HWPWriter.toFile(resultFile, resultHwpPath);
|
||||
partFileList.add(resultHwpPath);
|
||||
}
|
||||
|
||||
//결과파일 병합
|
||||
if(partFileList.size() >= 2) {
|
||||
String basePath = partFileList.get(0);
|
||||
HWPFile baseFile = HWPReader.fromFile(basePath);
|
||||
|
||||
|
||||
for(int i=2; i <= partFileList.size();i++) {
|
||||
String attachPath = partFileList.get(i-1);
|
||||
HWPFile attachFile = HWPReader.fromFile(attachPath);
|
||||
AddUtil.appendToLast(attachFile, baseFile);
|
||||
}
|
||||
|
||||
kr.dogfoot.hwplib.writer.HWPWriter.toFile(baseFile, basePath);
|
||||
|
||||
for(int i=2; i <= partFileList.size();i++) {
|
||||
if(!(new File(partFileList.get(i-1))).delete()) {
|
||||
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String downlaodFileName = this.print.getFormatKorName()+"_"+this.print.getPrintRequestDt()+".hwp";
|
||||
result.put("filename", downlaodFileName);
|
||||
String filePath = partFileList.get(0);
|
||||
result.put("filePath", filePath);
|
||||
result.put("file", new File(filePath));
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("한글 파일 출력 중 오류가 발생하였습니다.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package cokr.xit.fims.cmmn.hwp;
|
||||
import kr.dogfoot.hwplib.object.HWPFile;
|
||||
import kr.dogfoot.hwplib.object.bodytext.ParagraphListInterface;
|
||||
import kr.dogfoot.hwplib.object.bodytext.paragraph.Paragraph;
|
||||
import kr.dogfoot.hwplib.object.bodytext.paragraph.ParagraphList;
|
||||
import kr.dogfoot.hwplib.tool.objectfinder.CellFinder;
|
||||
import kr.dogfoot.hwplib.tool.paragraphadder.ParagraphAdder;
|
||||
import kr.dogfoot.hwplib.tool.paragraphadder.ParagraphMerger;
|
||||
|
||||
public class AddUtil {
|
||||
|
||||
/**한글파일을 병합한다.
|
||||
* @param attachHWPFile 기준파일 마지막 페이지에 붙일 파일, baseHWPFile 기준 파일
|
||||
* @return
|
||||
*/
|
||||
public static void appendToLast(HWPFile attachHWPFile, HWPFile baseHWPFile) throws Exception {
|
||||
|
||||
if (attachHWPFile != null && baseHWPFile != null) {
|
||||
|
||||
Paragraph[] ps = attachHWPFile.getBodyText().getSectionList().get(0).getParagraphs();
|
||||
|
||||
ParagraphListInterface baseSection = baseHWPFile.getBodyText().getLastSection();
|
||||
|
||||
ParagraphAdder paraAdder = new ParagraphAdder(baseHWPFile, baseSection);
|
||||
|
||||
for(int i=0; i<ps.length; i++) {
|
||||
Paragraph p = ps[i];
|
||||
paraAdder.add(attachHWPFile, p);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** 외부 한글파일의 테이블을 기준파일의 특정 테이블셀에 삽입한다.
|
||||
* @param attachHWPFile 테이블을 가져올 외부파일, baseHWPFile 기준 파일, cell 기준 파일의 테이블셀
|
||||
* @return
|
||||
*/
|
||||
public static void insertTableInCell(HWPFile attachHWPFile, HWPFile baseHWPFile, String cellFieldName) throws Exception {
|
||||
|
||||
ParagraphList cpl = CellFinder.findAll(baseHWPFile, cellFieldName).get(0).getParagraphList();
|
||||
|
||||
Paragraph attachParagraph = attachHWPFile.getBodyText().getSectionList().get(0).getParagraph(0);
|
||||
|
||||
ParagraphAdder paraAdder = new ParagraphAdder(baseHWPFile, cpl);
|
||||
paraAdder.add(attachHWPFile, attachParagraph);
|
||||
|
||||
|
||||
ParagraphList cpl0 = CellFinder.findAll(baseHWPFile, cellFieldName).get(0).getParagraphList();
|
||||
ParagraphMerger paraMerger = new ParagraphMerger();
|
||||
paraMerger.merge(cpl0.getParagraph(1), cpl0.getParagraph(0));
|
||||
cpl0.deleteParagraph(1);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package cokr.xit.fims.cmmn.hwp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import kr.dogfoot.hwplib.object.HWPFile;
|
||||
import kr.dogfoot.hwplib.tool.objectfinder.FieldFinder;
|
||||
|
||||
public class ClickHereEditor {
|
||||
private HWPFile whpFile;
|
||||
|
||||
public ClickHereEditor(HWPFile whpFile){
|
||||
this.whpFile = whpFile;
|
||||
}
|
||||
|
||||
public void set(String clickHereName, String value) {
|
||||
try {
|
||||
ArrayList<String> strings = new ArrayList<String>();
|
||||
strings.add(value);
|
||||
FieldFinder.setClickHereText(whpFile, clickHereName, strings);
|
||||
} catch (Exception e){
|
||||
throw new RuntimeException("한글 문서 생성 중 오류가 발생하였습니다.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cokr.xit.fims.cmmn.hwp;
|
||||
import kr.dogfoot.hwplib.object.HWPFile;
|
||||
import kr.dogfoot.hwplib.object.bodytext.ParagraphListInterface;
|
||||
import kr.dogfoot.hwplib.object.bodytext.paragraph.Paragraph;
|
||||
import kr.dogfoot.hwplib.tool.paragraphadder.ParagraphAdder;
|
||||
|
||||
public class HwpMerge {
|
||||
|
||||
/**한글파일을 병합한다.
|
||||
* @param attachHWPFile 기준파일 마지막 페이지에 붙일 파일, baseHWPFile 기준 파일
|
||||
* @return
|
||||
*/
|
||||
public static void appendToLast(HWPFile attachHWPFile, HWPFile baseHWPFile) throws Exception {
|
||||
|
||||
if (attachHWPFile != null && baseHWPFile != null) {
|
||||
|
||||
Paragraph[] ps = attachHWPFile.getBodyText().getSectionList().get(0).getParagraphs();
|
||||
|
||||
ParagraphListInterface baseSection = baseHWPFile.getBodyText().getLastSection();
|
||||
|
||||
ParagraphAdder paraAdder = new ParagraphAdder(baseHWPFile, baseSection);
|
||||
|
||||
for(int i=0; i<ps.length; i++) {
|
||||
Paragraph p = ps[i];
|
||||
paraAdder.add(attachHWPFile, p);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,261 +0,0 @@
|
||||
package cokr.xit.fims.cmmn.hwp;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import kr.dogfoot.hwplib.object.HWPFile;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ctrlheader.CtrlHeaderGso;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ctrlheader.gso.GsoHeaderProperty;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ctrlheader.gso.HeightCriterion;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ctrlheader.gso.HorzRelTo;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ctrlheader.gso.ObjectNumberSort;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ctrlheader.gso.RelativeArrange;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ctrlheader.gso.TextFlowMethod;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ctrlheader.gso.TextHorzArrange;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ctrlheader.gso.VertRelTo;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ctrlheader.gso.WidthCriterion;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.gso.ControlRectangle;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.gso.GsoControlType;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.gso.shapecomponent.ShapeComponentNormal;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.gso.shapecomponent.lineinfo.LineArrowShape;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.gso.shapecomponent.lineinfo.LineArrowSize;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.gso.shapecomponent.lineinfo.LineEndShape;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.gso.shapecomponent.lineinfo.LineInfo;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.gso.shapecomponent.lineinfo.LineType;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.gso.shapecomponent.lineinfo.OutlineStyle;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.gso.shapecomponent.shadowinfo.ShadowInfo;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.gso.shapecomponent.shadowinfo.ShadowType;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.gso.shapecomponenteach.ShapeComponentRectangle;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.table.Cell;
|
||||
import kr.dogfoot.hwplib.object.bodytext.paragraph.Paragraph;
|
||||
import kr.dogfoot.hwplib.object.bodytext.paragraph.text.ParaText;
|
||||
import kr.dogfoot.hwplib.object.docinfo.BinData;
|
||||
import kr.dogfoot.hwplib.object.docinfo.bindata.BinDataCompress;
|
||||
import kr.dogfoot.hwplib.object.docinfo.bindata.BinDataState;
|
||||
import kr.dogfoot.hwplib.object.docinfo.bindata.BinDataType;
|
||||
import kr.dogfoot.hwplib.object.docinfo.borderfill.fillinfo.FillInfo;
|
||||
import kr.dogfoot.hwplib.object.docinfo.borderfill.fillinfo.ImageFill;
|
||||
import kr.dogfoot.hwplib.object.docinfo.borderfill.fillinfo.ImageFillType;
|
||||
import kr.dogfoot.hwplib.object.docinfo.borderfill.fillinfo.PictureEffect;
|
||||
import kr.dogfoot.hwplib.tool.objectfinder.CellFinder;
|
||||
|
||||
public class InsertingImageCell {
|
||||
|
||||
public static void IMPL_InsertPicture(HWPFile hwpFile, String fieldName, String imgFilePath) throws IOException {
|
||||
if(imgFilePath != null && !imgFilePath.equals("")) {
|
||||
File file = new File(imgFilePath);
|
||||
if(file.exists()) {
|
||||
InsertingImageCell tii = new InsertingImageCell();
|
||||
tii.insertShapeWithImage(hwpFile, fieldName, imgFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final String imageFileExt = "jpg";
|
||||
private final BinDataCompress compressMethod = BinDataCompress.ByStorageDefault;
|
||||
|
||||
private int instanceID = 0x5bb840e1;
|
||||
private HWPFile hwpFile;
|
||||
private String imageFilePath;
|
||||
private String fieldName;
|
||||
private int streamIndex;
|
||||
private int binDataID;
|
||||
|
||||
private ControlRectangle rectangle;
|
||||
private Rectangle shapePosition = new Rectangle(1, 1, 20, 20);
|
||||
|
||||
|
||||
private void insertShapeWithImage(HWPFile hwpFile, String fieldName, String imgFilePath) throws IOException {
|
||||
|
||||
this.hwpFile = hwpFile;
|
||||
this.fieldName = fieldName;
|
||||
this.imageFilePath = imgFilePath;
|
||||
|
||||
addBinData();
|
||||
binDataID = addBinDataInDocInfo(streamIndex);
|
||||
addGsoControl();
|
||||
}
|
||||
|
||||
private void addBinData() throws IOException {
|
||||
streamIndex = hwpFile.getBinData().getEmbeddedBinaryDataList().size() + 1;
|
||||
String streamName = getStreamName();
|
||||
byte[] fileBinary = loadFile();
|
||||
|
||||
hwpFile.getBinData().addNewEmbeddedBinaryData(streamName, fileBinary, compressMethod);
|
||||
}
|
||||
|
||||
private String getStreamName() {
|
||||
return "Bin" + String.format("%04X", streamIndex) + "." + imageFileExt;
|
||||
}
|
||||
|
||||
private byte[] loadFile() throws IOException {
|
||||
File file = new File(imageFilePath);
|
||||
byte[] buffer = new byte[(int) file.length()];
|
||||
InputStream ios = null;
|
||||
try {
|
||||
ios = new FileInputStream(file);
|
||||
int count = ios.read(buffer);
|
||||
if(count != file.length()) {
|
||||
throw new RuntimeException("[F]파일 로드 오류");
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (ios != null)
|
||||
ios.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private int addBinDataInDocInfo(int streamIndex) {
|
||||
BinData bd = new BinData();
|
||||
bd.getProperty().setType(BinDataType.Embedding);
|
||||
bd.getProperty().setCompress(compressMethod);
|
||||
bd.getProperty().setState(BinDataState.NotAccess);
|
||||
bd.setBinDataID(streamIndex);
|
||||
bd.setExtensionForEmbedding(imageFileExt);
|
||||
hwpFile.getDocInfo().getBinDataList().add(bd);
|
||||
return hwpFile.getDocInfo().getBinDataList().size();
|
||||
}
|
||||
|
||||
private void addGsoControl() {
|
||||
createRectangleControlAtCell();
|
||||
|
||||
setCtrlHeaderGso();
|
||||
setShapeComponent();
|
||||
setShapeComponentRectangle();
|
||||
}
|
||||
|
||||
private void createRectangleControlAtCell() {
|
||||
ArrayList<Cell> cellList = CellFinder.findAll(hwpFile, fieldName);
|
||||
if(cellList != null && !cellList.isEmpty()) {
|
||||
Cell c = cellList.get(0);
|
||||
int cellWidth = (int)c.getListHeader().getWidth();
|
||||
int cellHeight = (int)c.getListHeader().getHeight();
|
||||
shapePosition = new Rectangle(1, 1, cellWidth, cellHeight);
|
||||
|
||||
Paragraph firstPara = c.getParagraphList().getParagraph(0);
|
||||
ParaText paraText = firstPara.getText();
|
||||
if (paraText == null) {
|
||||
firstPara.createText();
|
||||
paraText = firstPara.getText();
|
||||
}
|
||||
|
||||
// 문단에서 사각형 컨트롤의 위치를 표현하기 위한 확장 문자를 넣는다.
|
||||
paraText.addExtendCharForGSO();
|
||||
|
||||
// 문단에 사각형 컨트롤 추가한다.
|
||||
rectangle = (ControlRectangle) firstPara.addNewGsoControl(GsoControlType.Rectangle);
|
||||
}
|
||||
}
|
||||
|
||||
private void setCtrlHeaderGso() {
|
||||
CtrlHeaderGso hdr = rectangle.getHeader();
|
||||
GsoHeaderProperty prop = hdr.getProperty();
|
||||
prop.setLikeWord(false);
|
||||
prop.setApplyLineSpace(false);
|
||||
prop.setVertRelTo(VertRelTo.Para);
|
||||
prop.setVertRelativeArrange(RelativeArrange.TopOrLeft);
|
||||
prop.setHorzRelTo(HorzRelTo.Para);
|
||||
prop.setHorzRelativeArrange(RelativeArrange.TopOrLeft);
|
||||
prop.setVertRelToParaLimit(true);
|
||||
prop.setAllowOverlap(true);
|
||||
prop.setWidthCriterion(WidthCriterion.Absolute);
|
||||
prop.setHeightCriterion(HeightCriterion.Absolute);
|
||||
prop.setProtectSize(false);
|
||||
prop.setTextFlowMethod(TextFlowMethod.FitWithText);
|
||||
prop.setTextHorzArrange(TextHorzArrange.BothSides);
|
||||
prop.setObjectNumberSort(ObjectNumberSort.Figure);
|
||||
|
||||
hdr.setyOffset(shapePosition.y);
|
||||
hdr.setxOffset(shapePosition.x);
|
||||
hdr.setWidth(shapePosition.width);
|
||||
hdr.setHeight(shapePosition.height);
|
||||
hdr.setzOrder(0);
|
||||
hdr.setOutterMarginLeft(0);
|
||||
hdr.setOutterMarginRight(0);
|
||||
hdr.setOutterMarginTop(0);
|
||||
hdr.setOutterMarginBottom(0);
|
||||
hdr.setInstanceId(instanceID);
|
||||
hdr.setPreventPageDivide(false);
|
||||
hdr.getExplanation().setBytes(null);
|
||||
}
|
||||
|
||||
public int fromMM(int mm) {
|
||||
if (mm == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (int) ((double) mm * 72000.0f / 254.0f + 0.5f);
|
||||
}
|
||||
|
||||
private void setShapeComponent() {
|
||||
ShapeComponentNormal sc = (ShapeComponentNormal) rectangle.getShapeComponent();
|
||||
sc.setOffsetX(0);
|
||||
sc.setOffsetY(0);
|
||||
sc.setGroupingCount(0);
|
||||
sc.setLocalFileVersion(1);
|
||||
sc.setWidthAtCreate(shapePosition.width);
|
||||
sc.setHeightAtCreate(shapePosition.height);
|
||||
sc.setWidthAtCurrent(shapePosition.width);
|
||||
sc.setHeightAtCurrent(shapePosition.height);
|
||||
sc.setRotateAngle(0);
|
||||
sc.setRotateXCenter((shapePosition.width / 2));
|
||||
sc.setRotateYCenter((shapePosition.height / 2));
|
||||
|
||||
sc.createLineInfo();
|
||||
LineInfo li = sc.getLineInfo();
|
||||
li.getProperty().setLineEndShape(LineEndShape.Flat);
|
||||
li.getProperty().setStartArrowShape(LineArrowShape.None);
|
||||
li.getProperty().setStartArrowSize(LineArrowSize.MiddleMiddle);
|
||||
li.getProperty().setEndArrowShape(LineArrowShape.None);
|
||||
li.getProperty().setEndArrowSize(LineArrowSize.MiddleMiddle);
|
||||
li.getProperty().setFillStartArrow(true);
|
||||
li.getProperty().setFillEndArrow(true);
|
||||
li.getProperty().setLineType(LineType.None);
|
||||
li.setOutlineStyle(OutlineStyle.Normal);
|
||||
li.setThickness(0);
|
||||
li.getColor().setValue(0);
|
||||
|
||||
sc.createFillInfo();
|
||||
FillInfo fi = sc.getFillInfo();
|
||||
fi.getType().setPatternFill(false);
|
||||
fi.getType().setImageFill(true);
|
||||
fi.getType().setGradientFill(false);
|
||||
fi.createImageFill();
|
||||
ImageFill imgF = fi.getImageFill();
|
||||
imgF.setImageFillType(ImageFillType.FitSize);
|
||||
imgF.getPictureInfo().setBrightness((byte) 0);
|
||||
imgF.getPictureInfo().setContrast((byte) 0);
|
||||
imgF.getPictureInfo().setEffect(PictureEffect.RealPicture);
|
||||
imgF.getPictureInfo().setBinItemID(binDataID);
|
||||
|
||||
sc.createShadowInfo();
|
||||
ShadowInfo si = sc.getShadowInfo();
|
||||
si.setType(ShadowType.None);
|
||||
si.getColor().setValue(0xc4c4c4);
|
||||
si.setOffsetX(283);
|
||||
si.setOffsetY(283);
|
||||
si.setTransparent((short) 0);
|
||||
|
||||
sc.setMatrixsNormal();
|
||||
}
|
||||
|
||||
private void setShapeComponentRectangle() {
|
||||
ShapeComponentRectangle scr = rectangle.getShapeComponentRectangle();
|
||||
scr.setRoundRate((byte) 0);
|
||||
scr.setX1(0);
|
||||
scr.setY1(0);
|
||||
scr.setX2(shapePosition.width);
|
||||
scr.setY2(0);
|
||||
scr.setX3(shapePosition.width);
|
||||
scr.setY3(shapePosition.height);
|
||||
scr.setX4(0);
|
||||
scr.setY4(shapePosition.height);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cokr.xit.fims.cmmn.hwp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cokr.xit.base.docs.hwp.HWPWriter;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.Control;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ControlTable;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.ControlType;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.table.Cell;
|
||||
import kr.dogfoot.hwplib.object.bodytext.control.table.Row;
|
||||
import kr.dogfoot.hwplib.tool.objectfinder.ControlFinder;
|
||||
|
||||
public class OffcsCellFinder {
|
||||
|
||||
|
||||
public static Cell find(HWPWriter writer) {
|
||||
ArrayList<Control> find = ControlFinder.find(writer.getFile(), (control, paragrpah, section) -> {
|
||||
if(control.getType().equals(ControlType.Table)) {
|
||||
ArrayList<Row> rl = ((ControlTable)control).getRowList();
|
||||
if(rl.size() == 1) {
|
||||
ArrayList<Cell> cl = rl.get(0).getCellList();
|
||||
if(cl.size() == 1) {
|
||||
String fn = cl.get(0).getListHeader().getFieldName();
|
||||
if(fn != null && !fn.equals("")) {
|
||||
if(fn.equals("직인")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if(find != null && !find.isEmpty()) {
|
||||
ControlTable tableForOffcs = (ControlTable) find.get(0);
|
||||
Cell cell = tableForOffcs.getRowList().get(0).getCellList().get(0);
|
||||
return cell;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,98 +1,130 @@
|
||||
package cokr.xit.fims.cmmn.hwp.format;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import cokr.xit.base.docs.hwp.HWPWriter;
|
||||
import cokr.xit.fims.cmmn.CmmnUtil;
|
||||
import cokr.xit.fims.cmmn.Print;
|
||||
import cokr.xit.fims.cmmn.PrintOption;
|
||||
import cokr.xit.fims.cmmn.hwp.AddUtil;
|
||||
import cokr.xit.fims.cmmn.hwp.ClickHereEditor;
|
||||
import cokr.xit.fims.cmmn.hwp.InsertingImageCell;
|
||||
import cokr.xit.foundation.data.DataFormat;
|
||||
import cokr.xit.foundation.data.DataObject;
|
||||
import kr.dogfoot.hwplib.object.HWPFile;
|
||||
import kr.dogfoot.hwplib.reader.HWPReader;
|
||||
|
||||
|
||||
public class CvlcptOrgn extends HWPFormat {
|
||||
private List<DataObject> data2 = null;
|
||||
|
||||
@Override
|
||||
public List<String> getDownloadDataNames() {
|
||||
return List.of("접수번호","신청자","접수일자","처리기한","민원목록번호","민원내용");
|
||||
}
|
||||
public CvlcptOrgn(PrintOption printOption, Print print, List<DataObject> dataObjectList) {
|
||||
super(printOption, print, dataObjectList);
|
||||
this.maxRunCount = 1;
|
||||
this.formatFilePath = "template/hwp/cvlcptOrgnl_text.hwp";
|
||||
this.print.setFormatKorName("민원원본내역");
|
||||
this.print.setFormatName("cvlcptOrgnl");
|
||||
|
||||
@Override
|
||||
public void setting(Print print) {
|
||||
print.setFormatName("cvlcptOrgn");
|
||||
print.setFormatKorName("민원원본내역");
|
||||
this.data2 = new ArrayList<DataObject>();
|
||||
if(!dataObjectList.get(0).string("PHOTO0").equals("")) {
|
||||
|
||||
this.setFormatType("info");
|
||||
this.setRecordPerPartFile(1);
|
||||
int photoCnt = dataObjectList.get(0).number("ORGN_PHOTO_CNT").intValue();
|
||||
int PHOTO_COUNT_PER_PAGE = 4;
|
||||
|
||||
for(int i=0; i < photoCnt; i += PHOTO_COUNT_PER_PAGE) {
|
||||
|
||||
this.setBaseFormatFilePath("template/hwp/cvlcptOrgnl_text.hwp");
|
||||
this.setAttachFormatFilePath("template/hwp/cvlcptOrgnl_photo.hwp");
|
||||
DataObject photoObj = new DataObject();
|
||||
|
||||
photoObj.set("PHOTO1", dataObjectList.get(0).string("PHOTO"+i));
|
||||
if(i+1 < photoCnt)
|
||||
photoObj.set("PHOTO2", dataObjectList.get(0).string("PHOTO"+(i+1)));
|
||||
if(i+2 < photoCnt)
|
||||
photoObj.set("PHOTO3", dataObjectList.get(0).string("PHOTO"+(i+2)));
|
||||
if(i+3 < photoCnt)
|
||||
photoObj.set("PHOTO4", dataObjectList.get(0).string("PHOTO"+(i+3)));
|
||||
|
||||
data2.add(photoObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setting(Print print, int cnt) {
|
||||
public List<String> getDownloadDataNames() {
|
||||
return List.of("접수번호","신청자","접수일자","처리기한","민원목록번호","민원내용");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGlobalInfo(HWPFile baseFile, List<DataObject> dataObjectList, PrintOption printOption,
|
||||
Print print) {
|
||||
public HashMap<String, Object> makeFile(){
|
||||
runAsWriter();
|
||||
writer = null;
|
||||
currentRunCount++;
|
||||
|
||||
if(data2 != null && data2.size() > 0) {
|
||||
|
||||
formatFilePath = "template/hwp/cvlcptOrgnl_photo.hwp";
|
||||
maxRunCount = data2.size()+1;
|
||||
while(currentRunCount != maxRunCount) {
|
||||
runAsWriter();
|
||||
writer = null;
|
||||
currentRunCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return getResult();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void writeSingleDataInfo(HWPFile baseFile, HWPFile attachFile, DataObject dataObject, Print print) {
|
||||
public void runAsWriter() {
|
||||
|
||||
HWPFile hwpFile = HWPWriter.classpath(this.formatFilePath);
|
||||
this.writer = new HWPWriter(hwpFile);
|
||||
|
||||
if(this.formatFilePath.equals("template/hwp/cvlcptOrgnl_text.hwp")) {
|
||||
|
||||
|
||||
ClickHereEditor baseFileEditor = new ClickHereEditor(baseFile);
|
||||
DataObject one = data.get(0);
|
||||
|
||||
baseFileEditor.set("신청자", dataObject.string("CVLCPT_APLCNT_NM"));
|
||||
baseFileEditor.set("접수일자", DataFormat.yyyy_mm_dd(dataObject.string("CVLCPT_RCPT_YMD")));
|
||||
writer.setValue("신청자", one.string("CVLCPT_APLCNT_NM"));
|
||||
writer.setValue("접수일자", DataFormat.yyyy_mm_dd(one.string("CVLCPT_RCPT_YMD")));
|
||||
|
||||
String cvlcptRrcsPrnmntDt = dataObject.string("CVLCPT_PRCS_PRNMNT_DT");
|
||||
String cvlcptRrcsPrnmntDt = one.string("CVLCPT_PRCS_PRNMNT_DT");
|
||||
if(cvlcptRrcsPrnmntDt.length() > 8) {
|
||||
cvlcptRrcsPrnmntDt = cvlcptRrcsPrnmntDt.substring(0, 8);
|
||||
}
|
||||
|
||||
baseFileEditor.set("처리기한", DataFormat.yyyy_mm_dd(cvlcptRrcsPrnmntDt));
|
||||
baseFileEditor.set("접수번호", dataObject.string("CVLCPT_RCPT_NO"));
|
||||
baseFileEditor.set("목록번호", dataObject.string("CVLCPT_LIST_NO"));
|
||||
writer.setValue("처리기한", DataFormat.yyyy_mm_dd(cvlcptRrcsPrnmntDt));
|
||||
writer.setValue("접수번호", one.string("CVLCPT_RCPT_NO"));
|
||||
writer.setValue("목록번호", one.string("CVLCPT_LIST_NO"));
|
||||
|
||||
String cvlcptAplyCn = dataObject.string("CVLCPT_APLY_CN");
|
||||
String cvlcptAplyCn = one.string("CVLCPT_APLY_CN");
|
||||
cvlcptAplyCn = CmmnUtil.escapeHTMLEntity(cvlcptAplyCn);
|
||||
baseFileEditor.set("민원내용", cvlcptAplyCn);
|
||||
|
||||
try {
|
||||
|
||||
if(dataObject.string("PHOTO0") != null && !dataObject.string("PHOTO0").equals("")) {
|
||||
|
||||
int photoCnt = dataObject.number("ORGN_PHOTO_CNT").intValue();
|
||||
int PHOTO_COUNT_PER_PAGE = 4;
|
||||
|
||||
for(int i=0; i < photoCnt; i += PHOTO_COUNT_PER_PAGE) {
|
||||
writer.setValue("민원내용", cvlcptAplyCn);
|
||||
|
||||
InputStream attachFormatIS = new ClassPathResource(this.attachFormatFilePath).getInputStream();
|
||||
HWPFile attachFormatFile = HWPReader.fromInputStream(attachFormatIS);
|
||||
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽위사진", dataObject.string("PHOTO"+i));
|
||||
if(i+1 < photoCnt)
|
||||
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽위사진", dataObject.string("PHOTO"+(i+1)));
|
||||
if(i+2 < photoCnt)
|
||||
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "왼쪽아래사진", dataObject.string("PHOTO"+(i+2)));
|
||||
if(i+3 < photoCnt)
|
||||
InsertingImageCell.IMPL_InsertPicture(attachFormatFile, "오른쪽아래사진", dataObject.string("PHOTO"+(i+3)));
|
||||
AddUtil.appendToLast(attachFormatFile, baseFile);
|
||||
} else {
|
||||
|
||||
DataObject one = data2.get(currentRunCount-1);
|
||||
DataObject newObj = new DataObject();
|
||||
if(!one.string("PHOTO1").equals("")) {
|
||||
newObj.set("왼쪽위사진", writer.image().add(one.string("PHOTO1")));
|
||||
}
|
||||
|
||||
if(!one.string("PHOTO2").equals("")) {
|
||||
newObj.set("오른쪽위사진", writer.image().add(one.string("PHOTO2")));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("[F]"+e);
|
||||
if(!one.string("PHOTO3").equals("")) {
|
||||
newObj.set("왼쪽아래사진", writer.image().add(one.string("PHOTO3")));
|
||||
}
|
||||
if(!one.string("PHOTO4").equals("")) {
|
||||
newObj.set("오른쪽아래사진", writer.image().add(one.string("PHOTO4")));
|
||||
}
|
||||
writer.table(0, 0, 2).setValues(List.of(newObj));
|
||||
|
||||
}
|
||||
|
||||
String tempPath = this.pathForNewFile(currentRunCount+1);
|
||||
writer.write(tempPath);
|
||||
resultFilesPath.add(tempPath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cokr.xit.fims.cmmn;
|
||||
package cokr.xit.fims.cmmn.xls;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue