Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

charShpae이 비어있어서 문서가 깨짐을 유추되는 현상 문의드립니다. #217

Closed
tjguswns33 opened this issue May 8, 2023 · 4 comments

Comments

@tjguswns33
Copy link

안녕하세요

문서를 읽고 닫는 과정중 문제가 발생하여 문의드립니다.

찾아본 내용또한 공유드립니다.
해당원인이 아닐 수 있어서 계속 찾아보는데로 공유드리겠습니다..
image

감사합니다.

@neolord0
Copy link
Owner

neolord0 commented May 8, 2023

안녕하세요.. 그렇군요.
다른 일때문에 늦어졌습니다.
님이 분석하신대로 ParaCharShape의 크기가 0일떄 처리가 미흡했던 거 같습니다.
수정하여 업데이트 했습니다.
받아서 테스트 해보세요.

@tjguswns33
Copy link
Author

안녕하세요 받아서 테스트 해보았는데 동일하게 파일이 깨지는 현상이 있습니다.

아래와 같이 비어있는 경우에 추가해주니까 오류가 발생안하고 있습니다.
Paragraph.charShape이 항상 존재해야 하는 것 같은데 검토 부탁드립니다.

	public static void main(String[] args) throws Exception {
		File f = new File("C:\\Users\\hjseo\\Desktop\\a.hwp");
		File f2 = new File("C:\\Users\\hjseo\\Desktop\\b.hwp");
		File dest = new File(f.getParentFile(), "_" + f.getName());
		File dest2 = new File(f2.getParentFile(), "_" + f2.getName());
		HWPFile hf = HWPReader.fromFile(f.getPath());
		test2(hf);

		HWPFile hf2 = HWPReader.fromFile(f2.getPath());
		test2(hf2);

		HWPWriter.toFile(hf, dest.getAbsolutePath());
		HWPWriter.toFile(hf2, dest2.getAbsolutePath());
	}

	public static void test2(HWPFile file) {
		List<Section> list = file.getBodyText().getSectionList();

		for (Section s : list) {
			for (Paragraph p : s.getParagraphs()) {
				if (p.getCharShape() == null) {
					p.createCharShape();
				}
				System.out.println(p.getCharShape());
			}
		}
	}

감사합니다

@neolord0
Copy link
Owner

neolord0 commented May 8, 2023

위의 예제에서 "a.hwp", "b.hwp" 파일은 한글 프로그램에서 만든 건가요?? 아니면 님이 라이브러리로 만든 건 가요?
제가 테스트 해보니, 한글 프로그램에서 만든 파일은 Paragraph.charShape()을 "null"로 설정되지 않던데요.

@tjguswns33
Copy link
Author

엇 죄송합니다

이전에 오류로 만들어진 문서를 테스트 했네요

패치해주신 내용으로 정상작동 확인하였습니다.

감사합니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants