한/컴 ActiveX Control 에서 누름틀의 내용 HTML export/import
한/컴 ActiveX Control 에서 HTML export/import 가 안 되는지 알고 멍 때리고 있다가 오늘에서야 확인을 하였습니다.
/**
* 누름틀에 HTML 태그로 구성된 데이터를 설정합니다.
*
* @param clickHereFieldName {String} 누름틀 필드명
* @param html {String} html 태그
*/
function SetClickHereHtml(clickHereFieldName, html) {
// 누름틀로 커서를 이동
if (HwpCtrl.MoveToField(clickHereFieldName, true, true, true)) {
// 누름틀 내용을 삭제
HwpCtrl.Run("Delete");
// 전체 선택을 해제
HwpCtrl.Run("Cancel");
PutClickHereHtml(clickHereFieldName, html);
}
}
/**
* 누름틀에 HTML 태그로 구성된 데이터를 추가합니다.
*
* @param clickHereFieldName {String} 누름틀 필드명
* @param html {String} html 태그
*/
function PutClickHereHtml(clickHereFieldName, html) {
// 누름틀로 커서를 이동
if (HwpCtrl.MoveToField(clickHereFieldName, true, true, false)) {
// 누름틀에 내용을 채우기
if (HwpCtrl.SetTextFile(html, "HTML", "insertfile") == 0) {
alert('누름틀 채우기가 실패하였습니다.');
return;
}
}
}
/**
* 누름틀에 HTML 태그로 구성된 데이터를 반환합니다.
*
* @param clickHereFieldName {String} 누름틀 필드명
* @return {String} html 태그
*/
function GetClickHereHtml(clickHereFieldName) {
// 누름틀을 전체 선택한 상태로 커서를 이동
if (HwpCtrl.MoveToField(clickHereFieldName, true, true, true)) {
// 누름틀의 내용을 선택하여 HTML로 반환받음
var html = HwpCtrl.GetTextFile("HTML", "saveblock");
// 히든 레이어를 추가
var hiddenLayer = document.getElementById('hiddenLayer');
if (hiddenLayer == null) {
hiddenLayer = document.createElement('DIV');
hiddenLayer.id = 'hiddenLayer';
hiddenLayer.style.display = 'none';
document.body.appendChild(hiddenLayer);
}
// 전체 선택을 해제
HwpCtrl.Run("Cancel");
// 실제로 필요한 HTML만 반환
hiddenLayer.innerHTML = html;
return hiddenLayer.innerHTML;
}
return null;
}
쩝;;; 처음 볼 때 재대로 볼껄... -_ㅜ...
댓글
댓글 쓰기