미주에 있는 글상자 속 수식

현재 매크로를 이용하여 수식의 크기를 수정하려 하는데

미주 또는 미주에 있는 글상자 속 수식은 수정하지 않고,

미주 밖에 있는 수식, 미주 밖에 있는 표, 글상자 속 수식만 수정하려 합니다.

미주 또는 미주에 있는 글상자 속 수식을 패스 하는 방법이 있을까요?

안녕하세요

ParentCtrl API를 활용해서 CtrlCode가 미주가 아닐 때로 처리하면 좋을 것 같습니다.

감사합니다.

if(ParentCtrl != null && ParentCtrl.CtrlID == "en")
{
	HAction.Run("CloseEx");
	HAction.Run("MoveRight");
}

이렇게 하면 미주에 있는 수식은 패스하지만 미주에 있는 글상자 속 수식은 패스하지 않습니다.

현재까지 그나마 가장 유사하게 행동하는 코드가

입니다만 바탕글에 있는 글상자 처리가 문제네요
function OnScriptMacro_script14()
{
수식찾기();

if(ParentCtrl != null && ParentCtrl.CtrlID == "en")
{
	HAction.Run("CloseEx");
	HAction.Run("MoveRight");
	수식찾기();
	}else{
	if(GetPosBySet().Item("List") !=0)
	{
		HAction.Run("CloseEx");

		if(ParentCtrl != null && ParentCtrl.CtrlID == "en")
		{
			HAction.Run("CloseEx");
			HAction.Run("MoveRight");
			수식찾기();
		}
	}
}
	HAction.GetDefault("InsertText", HParameterSet.HInsertText.HSet);
	HParameterSet.HInsertText.Text = GetPosBySet().Item("List");
	HAction.Execute("InsertText", HParameterSet.HInsertText.HSet);

	HAction.Run("MoveRight");

}

function 수식찾기()
{
HAction.GetDefault(“Goto”, HParameterSet.HGotoE.HSet);
with (HParameterSet.HGotoE)
{
HSet.SetItem(“DialogResult”, 37);
SetSelectionIndex = 5;
}
HAction.Execute(“Goto”, HParameterSet.HGotoE.HSet);
}

수식으로 이동 후
movePos로 moveParentList 옵션을 줘서 상위 리스트로 이동 후
미주를 찾는 동작을 하면 될 것 같은데 한 번 해보시면 좋을 것 같습니다.

다음과 같이 해결하였습니다.
function OnScriptMacro_바탕글만속도개선()
{
// [핵심] 현재 작업 중인 표들의 ID를 기억하는 캐시 (본문 나오면 초기화됨)
var CurrentSafeZone = new Array();

// 루프 종료 확인용 변수
var S_Pos_List = -1; S_Pos_Para = -1; S_Pos_Pos = -1;

// 1. 수식 찾기 설정
HAction.GetDefault("Goto", HParameterSet.HGotoE.HSet);
with (HParameterSet.HGotoE)
{
	HSet.SetItem("DialogResult", 37); // 수식
	SetSelectionIndex = 5;            // 조판 부호
}

while (HAction.Execute("Goto", HParameterSet.HGotoE.HSet))
{
	var Origin_Pos = GetPosBySet();
	var CurListID = Origin_Pos.Item("List");

	// 2. 종료 조건 체크 (한 바퀴 돌았는지)
	if (S_Pos_List == -1 && S_Pos_Para == -1 && S_Pos_Pos == -1) {
		S_Pos_List = CurListID; 
		S_Pos_Para = Origin_Pos.Item("Para"); 
		S_Pos_Pos = Origin_Pos.Item("Pos");
	} else if (S_Pos_List == CurListID && 
			   S_Pos_Para == Origin_Pos.Item("Para") && 
			   S_Pos_Pos == Origin_Pos.Item("Pos")) {
		break;
	}

	// ==========================================================
	// [Fast Track 1] 본문(List 0)인 경우
	// ==========================================================
	if (CurListID == 0) {
		// 본문으로 나왔으므로, 이전 표들에 대한 기억(캐시)을 비움
		if (CurrentSafeZone.length > 0) {
			CurrentSafeZone = new Array(); 
		}
		// 본문 수식은 무조건 수정
		수식문법통일();
		continue;
	}
	
	// ==========================================================
	// [Fast Track 2] 이미 검증된 안전한 표(List ID)인 경우
	// ==========================================================
	if (Contains(CurrentSafeZone, CurListID)) {
		// 묻지도 따지지도 않고 바로 수정
		수식문법통일();
		continue;
	}

	// ==========================================================
	// [검증 시작] 처음 만난 구역 -> 경로 추적(Path Tracking)
	// ==========================================================
	var PathStack = new Array(); // 경로상의 ID를 담을 임시 저장소
	PathStack.push(CurListID);   // 현재 ID 담기

	var tempPos = GetPosBySet();
	var safetyBreak = 0;

	// 본문(0)이 나올 때까지 밖으로 나가면서 거치는 모든 표 ID 수집
	while (tempPos.Item("List") != 0) {
		HAction.Run("MoveParentList");
		tempPos = GetPosBySet();
		
		var pid = tempPos.Item("List");
		// 본문(0)이 아니면 경로에 추가 (중첩 표 대응)
		if (pid != 0) {
			PathStack.push(pid); 
		}

		safetyBreak++;
		if (safetyBreak > 20) break; // 무한루프 방지
	}

	// ==========================================================
	// [최종 판정] 표(진입) vs 주석(패스)
	// ==========================================================
	HAction.Run("MoveRight"); // 오른쪽으로 이동 테스트

	// 리스트 ID가 0이 아님 = 표나 글상자 내부로 들어감 (수정 대상)
	if (GetPosBySet().Item("List") != 0) 
	{
		// 검증 성공! 지금까지 거쳐온 모든 표 ID를 안전 구역에 등록
		for (var i = 0; i < PathStack.length; i++) {
			CurrentSafeZone.push(PathStack[i]);
		}
		// 원래 수식 위치로 복귀하여 수정
		SetPosBySet(Origin_Pos);
		수식문법통일();
	}
}

}

// [유틸리티] 배열 내 값 존재 여부 확인 함수
function Contains(arr, val) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] == val) return true;
}
return false;
}

function 수식문법통일()
{
FindCtrl(); // 수식 개체 선택

HAction.GetDefault("EquationPropertyDialog", HParameterSet.HShapeObject.HSet);
with (HParameterSet.HShapeObject)
{
	EqFontName = "HancomEQN";
	BaseUnit = PointToHwpUnit(10);
	OutsideMarginBottom = MiliToHwpUnit(0.0);
	OutsideMarginTop = MiliToHwpUnit(0.0);
}
HAction.Execute("EquationPropertyDialog", HParameterSet.HShapeObject.HSet);

HAction.Run("Cancel");
HAction.Run("MoveRight"); // 다음 수식 검색을 위해 이동

}