package com.wmyun.farmwork.word.deprecated.core.utils;

import org.apache.poi.xwpf.usermodel.XWPFTableCell;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description: TODO
 * @Date: 2025/3/1 11:03
 * @Created: by ZZSLL
 */


public class WPUtils {

    public static int getTemplateRowIndex(XWPFTableCell tagCell, boolean onSameLine) {
        XWPFTableRow tagRow = tagCell.getTableRow();
        return onSameLine ? getRowIndex(tagRow) : (getRowIndex(tagRow) + 1);
    }

    private static int getRowIndex(XWPFTableRow row) {
        List<XWPFTableRow> rows = row.getTable().getRows();
        return rows.indexOf(row);
    }
}
