MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / from_shape

Method from_shape

demo/Paper2Poster/utils/src/presentation.py:865–903  ·  view source on GitHub ↗

Extract table data (rows, columns, text in each cell, etc.) from the table shape.

(
        cls,
        slide_idx: int,
        shape_idx: int,
        shape: TablePlaceholder,  # or the actual shape holding the table
        style: dict,
        text_frame: TextFrame,
        config: Config,
        slide_area: float,
        level: int,
    )

Source from the content-addressed store, hash-verified

863class Table(ShapeElement):
864 @classmethod
865 def from_shape(
866 cls,
867 slide_idx: int,
868 shape_idx: int,
869 shape: TablePlaceholder, # or the actual shape holding the table
870 style: dict,
871 text_frame: TextFrame,
872 config: Config,
873 slide_area: float,
874 level: int,
875 ):
876 """
877 Extract table data (rows, columns, text in each cell, etc.) from the table shape.
878 """
879 pptx_table = shape.table # Adjust as needed if you'll need shape.table differently
880
881 # Gather all cell text in a list-of-lists
882 content = []
883 for row in pptx_table.rows:
884 row_cells = []
885 for cell in row.cells:
886 row_cells.append(cell.text)
887 content.append(row_cells)
888
889 data = {
890 "rows": len(pptx_table.rows),
891 "cols": len(pptx_table.columns),
892 "content": content,
893 }
894
895 return cls(
896 slide_idx,
897 shape_idx,
898 style,
899 data,
900 text_frame, # Typically unused for tables, but included for consistency
901 slide_area,
902 level=level,
903 )
904
905 def build(self, slide: PPTXSlide):
906 """

Callers 4

from_shapeMethod · 0.45
from_shapeMethod · 0.45
from_shapeMethod · 0.45
from_slideMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected