创建DrawIO基础XML结构
(self, canvas_width: int, canvas_height: int)
| 414 | return None |
| 415 | |
| 416 | def _create_base_xml(self, canvas_width: int, canvas_height: int) -> ET.Element: |
| 417 | """创建DrawIO基础XML结构""" |
| 418 | mxfile = ET.Element("mxfile", {"host": "app.diagrams.net", "type": "device"}) |
| 419 | diagram = ET.SubElement(mxfile, "diagram", {"id": "merged", "name": "Page-1"}) |
| 420 | |
| 421 | mx_graph_model = ET.SubElement(diagram, "mxGraphModel", { |
| 422 | "dx": str(canvas_width), |
| 423 | "dy": str(canvas_height), |
| 424 | "grid": "1", |
| 425 | "gridSize": "10", |
| 426 | "guides": "1", |
| 427 | "tooltips": "1", |
| 428 | "connect": "1", |
| 429 | "arrows": "1", |
| 430 | "fold": "1", |
| 431 | "page": "1", |
| 432 | "pageScale": "1", |
| 433 | "pageWidth": str(canvas_width), |
| 434 | "pageHeight": str(canvas_height), |
| 435 | "math": "0", |
| 436 | "shadow": "0", |
| 437 | "background": "#ffffff" |
| 438 | }) |
| 439 | |
| 440 | root = ET.SubElement(mx_graph_model, "root") |
| 441 | ET.SubElement(root, "mxCell", {"id": "0"}) |
| 442 | ET.SubElement(root, "mxCell", {"id": "1", "parent": "0"}) |
| 443 | |
| 444 | return mxfile |
| 445 | |
| 446 | def _prettify_xml(self, elem: ET.Element) -> str: |
| 447 | """格式化XML输出(移除版本声明,过滤空行)""" |
no outgoing calls
no test coverage detected