""" Presentation state management for PowerPoint MCP Server Handles presentation storage and current presentation tracking COMPLETE VERSION - compatible with existing utils/ structure """ import uuid from typing import Dict, Any, Optional # Global state to store presentations in memory (same as original) presentations = {} current_presentation_id = None def get_current_presentation(): """Get the current presentation object or raise an error if none is loaded.""" if current_presentation_id is None or current_presentation_id not in presentations: raise ValueError("No presentation is currently loaded. Please create or open a presentation first.") return presentations[current_presentation_id] def get_current_presentation_id(): """Get the current presentation ID.""" return current_presentation_id def set_current_presentation_id(pres_id): """Set the current presentation ID.""" global current_presentation_id current_presentation_id = pres_id # This class may already exist in utils/presentation_utils.py # If it does, the existing one will be used via imports class PresentationManager: """Wrapper to handle presentation state updates.""" def __init__(self, presentations_dict): self.presentations = presentations_dict def store_presentation(self, pres, pres_id=None): """Store a presentation and set it as current.""" if pres_id is None: pres_id = str(uuid.uuid4()) self.presentations[pres_id] = pres set_current_presentation_id(pres_id) return pres_id def remove_presentation(self, pres_id): """Remove a presentation from storage.""" if pres_id in self.presentations: del self.presentations[pres_id] # If this was the current presentation, clear current global current_presentation_id if current_presentation_id == pres_id: current_presentation_id = None return True return False def get_presentation_count(self): """Get the number of loaded presentations.""" return len(self.presentations) def get_presentation_list(self): """Get list of all presentation IDs.""" return list(self.presentations.keys()) # Export functions and variables for use in other modules __all__ = [ 'presentations', 'current_presentation_id', 'get_current_presentation', 'get_current_presentation_id', 'set_current_presentation_id', 'PresentationManager' ]