MCPcopy Create free account
hub / github.com/SpaceZephyr/myskill / __init__

Method __init__

pptx/scripts/inventory.py:388–466  ·  view source on GitHub ↗

Initialize from a PowerPoint shape object. Args: shape: The PowerPoint shape object (should be pre-validated) absolute_left: Absolute left position in EMUs (for shapes in groups) absolute_top: Absolute top position in EMUs (for shapes in groups)

(
        self,
        shape: BaseShape,
        absolute_left: Optional[int] = None,
        absolute_top: Optional[int] = None,
        slide: Optional[Any] = None,
    )

Source from the content-addressed store, hash-verified

386 return None
387
388 def __init__(
389 self,
390 shape: BaseShape,
391 absolute_left: Optional[int] = None,
392 absolute_top: Optional[int] = None,
393 slide: Optional[Any] = None,
394 ):
395 """Initialize from a PowerPoint shape object.
396
397 Args:
398 shape: The PowerPoint shape object (should be pre-validated)
399 absolute_left: Absolute left position in EMUs (for shapes in groups)
400 absolute_top: Absolute top position in EMUs (for shapes in groups)
401 slide: Optional slide object to get dimensions and layout information
402 """
403 self.shape = shape # Store reference to original shape
404 self.shape_id: str = "" # Will be set after sorting
405
406 # Get slide dimensions from slide object
407 self.slide_width_emu, self.slide_height_emu = (
408 self.get_slide_dimensions(slide) if slide else (None, None)
409 )
410
411 # Get placeholder type if applicable
412 self.placeholder_type: Optional[str] = None
413 self.default_font_size: Optional[float] = None
414 if hasattr(shape, "is_placeholder") and shape.is_placeholder: # type: ignore
415 if shape.placeholder_format and shape.placeholder_format.type: # type: ignore
416 self.placeholder_type = (
417 str(shape.placeholder_format.type).split(".")[-1].split(" ")[0] # type: ignore
418 )
419
420 # Get default font size from layout
421 if slide and hasattr(slide, "slide_layout"):
422 self.default_font_size = self.get_default_font_size(
423 shape, slide.slide_layout
424 )
425
426 # Get position information
427 # Use absolute positions if provided (for shapes in groups), otherwise use shape's position
428 left_emu = (
429 absolute_left
430 if absolute_left is not None
431 else (shape.left if hasattr(shape, "left") else 0)
432 )
433 top_emu = (
434 absolute_top
435 if absolute_top is not None
436 else (shape.top if hasattr(shape, "top") else 0)
437 )
438
439 self.left: float = round(self.emu_to_inches(left_emu), 2) # type: ignore
440 self.top: float = round(self.emu_to_inches(top_emu), 2) # type: ignore
441 self.width: float = round(
442 self.emu_to_inches(shape.width if hasattr(shape, "width") else 0),
443 2, # type: ignore
444 )
445 self.height: float = round(

Callers

nothing calls this directly

Calls 6

get_slide_dimensionsMethod · 0.95
get_default_font_sizeMethod · 0.95
emu_to_inchesMethod · 0.95
_detect_bullet_issuesMethod · 0.95

Tested by

no test coverage detected