34 lines
3.6 KiB
Markdown
34 lines
3.6 KiB
Markdown
# Specialized native objects
|
|
|
|
The maintained SVG compiler creates native tables and charts from explicit group markers. Start with [table.svg](../assets/native-objects/table.svg) or [chart.svg](../assets/native-objects/chart.svg). These are isolated compiler examples, not selected-template pages. Their Arial font, colors and geometry are explicit sample values; rebind them to the selected style/theme and fit the chosen content region. SVG coordinates and `font_size` are pixels: 24px means 18pt at 96dpi.
|
|
|
|
Each example contains a visible fallback plus a `<g data-pptx-replace-with="table|chart">` with `<metadata type="application/json">`. Both must come from the same data. The compiler replaces the group with an editable native object, rather than keeping the visible fallback as the result. Preserve explicit bounds, rows/columns, series/categories, font and colors. Escape JSON when inserting it in XML. Do not edit only the fallback or only the metadata. Marker transforms support translate/scale, not rotation/skew.
|
|
|
|
## Validate the marker and result
|
|
|
|
Bundled Python modules are under `runtime/ppt-master/scripts/`. Add that directory to `sys.path` in a project-local helper, then import:
|
|
|
|
```python
|
|
from svg_to_pptx.native_objects import (
|
|
stamp_native_fallback_baseline,
|
|
validate_native_object_marker_with_warnings,
|
|
)
|
|
```
|
|
|
|
After updating and reviewing both metadata and fallback, call `stamp_native_fallback_baseline(marker, document_root=root)` and serialize the SVG. Use `validate_native_object_marker_with_warnings(marker, document_root=root)` and inspect every warning before compiling the page with `native_export.py`. Do not stamp merely to suppress a stale-fallback error. For a marker inside transformed groups, also supply the actual ancestor context to validation; see the function signature. Sources without a baseline remain compatible but lose the freshness check.
|
|
|
|
Check the resulting PPTX for `a:tbl` or chart graphicFrames, chart XML/relationships and embedded workbook data as applicable. Confirm data cache and workbook agree with author data; charts drawn from shapes alone are not data-backed chart objects. Application opening, rendering and actual data editing require their own checks.
|
|
|
|
Implementation entry points:
|
|
|
|
- [marker loading and supported kinds](../runtime/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.py).
|
|
- [table grid, cells and native XML](../runtime/ppt-master/scripts/svg_to_pptx/native_objects/table.py).
|
|
- [chart data normalization](../runtime/ppt-master/scripts/svg_to_pptx/native_objects/chart_data.py) and [chart style](../runtime/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.py).
|
|
- [fallback freshness](../runtime/ppt-master/scripts/svg_to_pptx/native_objects/fallback_hash.py) and [validation/conversion](../runtime/ppt-master/scripts/svg_to_pptx/native_objects/__init__.py).
|
|
|
|
## Formula boundary
|
|
|
|
This maintained native SVG route has no authoring interface that creates Office Math equations: its native replacement kinds are table and chart. Simple mathematical Unicode may remain editable ordinary text, but that is not an editable equation object. Raster formulas and vector outlines must be disclosed as pictures/paths. The bundled optional LaTeX rendering utility produces PNG and can use external services; it is not a mandatory self-contained compiler capability. Do not invoke a network provider implicitly.
|
|
|
|
If truly editable equations are required, agree an additional host or project-local authoring route and verify its output before promising that result. Input OMML extraction does not establish native equation output support.
|