生成mxCell XML字符串 - 供子模块使用 Args: cell_id: 临时ID(合并时会被重新分配) style: DrawIO样式字符串 x, y: 位置 width, height: 尺寸 value: 单元格值(通常为空或文本内容) parent: 父元素ID Returns: mxCell XML字符串
(self,
cell_id: int,
style: str,
x: int,
y: int,
width: int,
height: int,
value: str = "",
parent: str = "1")
| 148 | # ======================== XML生成辅助方法 ======================== |
| 149 | |
| 150 | def _create_mxcell_xml(self, |
| 151 | cell_id: int, |
| 152 | style: str, |
| 153 | x: int, |
| 154 | y: int, |
| 155 | width: int, |
| 156 | height: int, |
| 157 | value: str = "", |
| 158 | parent: str = "1") -> str: |
| 159 | """ |
| 160 | 生成mxCell XML字符串 - 供子模块使用 |
| 161 | |
| 162 | Args: |
| 163 | cell_id: 临时ID(合并时会被重新分配) |
| 164 | style: DrawIO样式字符串 |
| 165 | x, y: 位置 |
| 166 | width, height: 尺寸 |
| 167 | value: 单元格值(通常为空或文本内容) |
| 168 | parent: 父元素ID |
| 169 | |
| 170 | Returns: |
| 171 | mxCell XML字符串 |
| 172 | """ |
| 173 | # 转义特殊字符 |
| 174 | value = value.replace('&', '&').replace('<', '<').replace('>', '>') |
| 175 | style = style.replace('"', '"') |
| 176 | |
| 177 | xml = f'''<mxCell id="{cell_id}" parent="{parent}" vertex="1" value="{value}" style="{style}"> |
| 178 | <mxGeometry x="{x}" y="{y}" width="{width}" height="{height}" as="geometry"/> |
| 179 | </mxCell>''' |
| 180 | |
| 181 | return xml |
| 182 | |
| 183 | |
| 184 | class ModelWrapper: |
nothing calls this directly
no outgoing calls
no test coverage detected