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

Method from_slide

utils/src/presentation.py:996–1052  ·  view source on GitHub ↗

Create a SlidePage from a PPTXSlide. Args: slide (PPTXSlide): The slide object. slide_idx (int): The index of the slide. real_idx (int): The real index of the slide. slide_width (int): The width of the slide. slide_height

(
        cls,
        slide: PPTXSlide,
        slide_idx: int,
        real_idx: int,
        slide_width: int,
        slide_height: int,
        config: Config,
    )

Source from the content-addressed store, hash-verified

994
995 @classmethod
996 def from_slide(
997 cls,
998 slide: PPTXSlide,
999 slide_idx: int,
1000 real_idx: int,
1001 slide_width: int,
1002 slide_height: int,
1003 config: Config,
1004 ):
1005 """
1006 Create a SlidePage from a PPTXSlide.
1007
1008 Args:
1009 slide (PPTXSlide): The slide object.
1010 slide_idx (int): The index of the slide.
1011 real_idx (int): The real index of the slide.
1012 slide_width (int): The width of the slide.
1013 slide_height (int): The height of the slide.
1014 config (Config): The configuration object.
1015
1016 Returns:
1017 SlidePage: The created SlidePage.
1018 """
1019 shapes = []
1020 for i, shape in enumerate(slide.shapes):
1021 try:
1022 if shape.visible:
1023 shape_element = ShapeElement.from_shape(
1024 slide_idx, i, shape, config, slide_width * slide_height
1025 )
1026 shapes.append(shape_element)
1027 except:
1028 shape_element = ShapeElement.from_shape(
1029 slide_idx, i, shape, config, slide_width * slide_height
1030 )
1031
1032
1033
1034 background_xml = extract_fill(slide.background)
1035 slide_layout_name = slide.slide_layout.name if slide.slide_layout else None
1036 slide_title = slide.shapes.title.text if slide.shapes.title else None
1037 slide_notes = (
1038 slide.notes_slide.notes_text_frame.text
1039 if slide.has_notes_slide and slide.notes_slide.notes_text_frame
1040 else None
1041 )
1042 return cls(
1043 shapes,
1044 slide_idx,
1045 real_idx,
1046 background_xml,
1047 slide_notes,
1048 slide_layout_name,
1049 slide_title,
1050 slide_width,
1051 slide_height,
1052 )
1053

Callers 1

from_fileMethod · 0.45

Calls 2

extract_fillFunction · 0.90
from_shapeMethod · 0.45

Tested by

no test coverage detected