From 21d5ee25ea6bdc98ad4de06a207413e38d083515 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Fri, 1 May 2026 10:39:04 +0800 Subject: [PATCH] =?UTF-8?q?improve:ROT=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Helpers/ROTPPTManager.cs | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Ink Canvas/Helpers/ROTPPTManager.cs b/Ink Canvas/Helpers/ROTPPTManager.cs index f03ed564..034c0d5b 100644 --- a/Ink Canvas/Helpers/ROTPPTManager.cs +++ b/Ink Canvas/Helpers/ROTPPTManager.cs @@ -1254,6 +1254,42 @@ namespace Ink_Canvas.Helpers _pptSlideShowWindow = wn; _lastPolledSlideNumber = -1; // 重置页码跟踪 + // 兜底:ROT 路径下事件触发时 _pptActivePresentation 可能尚未绑定, + // 先从 SlideShowWindow.Presentation 取,再退回 PPTApplication.ActivePresentation, + // 保证后续 SlidesCount 在 UI 读取前一定有效。 + if (_pptActivePresentation == null) + { + try + { + if (wn != null) + { + dynamic ssw = wn; + dynamic presFromWindow = ssw.Presentation; + if (presFromWindow != null) + { + _pptActivePresentation = presFromWindow; + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"OnSlideShowBegin 从 SlideShowWindow 兜底获取演示文稿失败: {ex.Message}", LogHelper.LogType.Warning); + } + + if (_pptActivePresentation == null && PPTApplication != null) + { + try + { + dynamic app = PPTApplication; + _pptActivePresentation = app.ActivePresentation; + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"OnSlideShowBegin 从 PPTApplication 兜底获取演示文稿失败: {ex.Message}", LogHelper.LogType.Warning); + } + } + } + try { if (_pptActivePresentation != null)