improve:PPT模块
This commit is contained in:
@@ -94,21 +94,18 @@ namespace Ink_Canvas.Helpers
|
|||||||
catch (COMException comEx)
|
catch (COMException comEx)
|
||||||
{
|
{
|
||||||
var hr = (uint)comEx.HResult;
|
var hr = (uint)comEx.HResult;
|
||||||
if (hr == 0x8001010E || hr == 0x80004005)
|
if (!IsPptBusyHResult(hr) && (hr == 0x8001010E || hr == 0x80004005))
|
||||||
{
|
|
||||||
DisconnectFromPPT();
|
DisconnectFromPPT();
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (COMException comEx)
|
catch (COMException comEx)
|
||||||
{
|
{
|
||||||
var hr = (uint)comEx.HResult;
|
var hr = (uint)comEx.HResult;
|
||||||
if (hr == 0x8001010E || hr == 0x80004005)
|
if (!IsPptBusyHResult(hr) && (hr == 0x8001010E || hr == 0x80004005))
|
||||||
{
|
|
||||||
DisconnectFromPPT();
|
DisconnectFromPPT();
|
||||||
}
|
if (!IsPptBusyHResult(hr))
|
||||||
LogHelper.WriteLogToFile($"检查PPT放映状态失败: {comEx.Message} (HR: 0x{hr:X8})", LogHelper.LogType.Warning);
|
LogHelper.WriteLogToFile($"检查PPT放映状态失败: {comEx.Message} (HR: 0x{hr:X8})", LogHelper.LogType.Warning);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -145,6 +142,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
private bool _lastSlideShowState;
|
private bool _lastSlideShowState;
|
||||||
private readonly object _lockObject = new object();
|
private readonly object _lockObject = new object();
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
private static bool IsPptBusyHResult(uint hr) => hr == 0x80010001 || hr == 0x8001010A;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructor & Initialization
|
#region Constructor & Initialization
|
||||||
@@ -885,8 +883,6 @@ namespace Ink_Canvas.Helpers
|
|||||||
if (slideShowWindow != null)
|
if (slideShowWindow != null)
|
||||||
{
|
{
|
||||||
dynamic sswObj = slideShowWindow;
|
dynamic sswObj = slideShowWindow;
|
||||||
if (!SkipAnimationsWhenNavigating)
|
|
||||||
sswObj.Activate();
|
|
||||||
view = sswObj.View;
|
view = sswObj.View;
|
||||||
if (view != null)
|
if (view != null)
|
||||||
{
|
{
|
||||||
@@ -901,10 +897,8 @@ namespace Ink_Canvas.Helpers
|
|||||||
catch (COMException comEx)
|
catch (COMException comEx)
|
||||||
{
|
{
|
||||||
var hr = (uint)comEx.HResult;
|
var hr = (uint)comEx.HResult;
|
||||||
if (hr == 0x8001010E || hr == 0x80004005)
|
if (!IsPptBusyHResult(hr) && (hr == 0x8001010E || hr == 0x80004005))
|
||||||
{
|
|
||||||
DisconnectFromPPT();
|
DisconnectFromPPT();
|
||||||
}
|
|
||||||
LogHelper.WriteLogToFile($"切换到下一页失败: {comEx.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"切换到下一页失败: {comEx.Message}", LogHelper.LogType.Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -939,8 +933,6 @@ namespace Ink_Canvas.Helpers
|
|||||||
if (slideShowWindow != null)
|
if (slideShowWindow != null)
|
||||||
{
|
{
|
||||||
dynamic sswObj = slideShowWindow;
|
dynamic sswObj = slideShowWindow;
|
||||||
if (!SkipAnimationsWhenNavigating)
|
|
||||||
sswObj.Activate();
|
|
||||||
view = sswObj.View;
|
view = sswObj.View;
|
||||||
if (view != null)
|
if (view != null)
|
||||||
{
|
{
|
||||||
@@ -955,10 +947,8 @@ namespace Ink_Canvas.Helpers
|
|||||||
catch (COMException comEx)
|
catch (COMException comEx)
|
||||||
{
|
{
|
||||||
var hr = (uint)comEx.HResult;
|
var hr = (uint)comEx.HResult;
|
||||||
if (hr == 0x8001010E || hr == 0x80004005)
|
if (!IsPptBusyHResult(hr) && (hr == 0x8001010E || hr == 0x80004005))
|
||||||
{
|
|
||||||
DisconnectFromPPT();
|
DisconnectFromPPT();
|
||||||
}
|
|
||||||
LogHelper.WriteLogToFile($"切换到上一页失败: {comEx.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"切换到上一页失败: {comEx.Message}", LogHelper.LogType.Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1078,10 +1068,8 @@ namespace Ink_Canvas.Helpers
|
|||||||
catch (COMException comEx)
|
catch (COMException comEx)
|
||||||
{
|
{
|
||||||
var hr = (uint)comEx.HResult;
|
var hr = (uint)comEx.HResult;
|
||||||
if (hr == 0x80048240)
|
if (hr == 0x80048240 || IsPptBusyHResult(hr))
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1096,11 +1084,10 @@ namespace Ink_Canvas.Helpers
|
|||||||
catch (COMException comEx)
|
catch (COMException comEx)
|
||||||
{
|
{
|
||||||
var hr = (uint)comEx.HResult;
|
var hr = (uint)comEx.HResult;
|
||||||
if (hr == 0x8001010E || hr == 0x80004005)
|
if (!IsPptBusyHResult(hr) && (hr == 0x8001010E || hr == 0x80004005))
|
||||||
{
|
|
||||||
DisconnectFromPPT();
|
DisconnectFromPPT();
|
||||||
}
|
if (!IsPptBusyHResult(hr))
|
||||||
LogHelper.WriteLogToFile($"获取当前活跃演示文稿失败: {comEx.Message}", LogHelper.LogType.Warning);
|
LogHelper.WriteLogToFile($"获取当前活跃演示文稿失败: {comEx.Message}", LogHelper.LogType.Warning);
|
||||||
return CurrentPresentation;
|
return CurrentPresentation;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1180,10 +1167,8 @@ namespace Ink_Canvas.Helpers
|
|||||||
catch (COMException comEx)
|
catch (COMException comEx)
|
||||||
{
|
{
|
||||||
var hr = (uint)comEx.HResult;
|
var hr = (uint)comEx.HResult;
|
||||||
if (hr == 0x8001010E || hr == 0x80004005)
|
if (!IsPptBusyHResult(hr) && (hr == 0x8001010E || hr == 0x80004005))
|
||||||
{
|
|
||||||
DisconnectFromPPT();
|
DisconnectFromPPT();
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@@ -1212,12 +1197,10 @@ namespace Ink_Canvas.Helpers
|
|||||||
catch (COMException comEx)
|
catch (COMException comEx)
|
||||||
{
|
{
|
||||||
var hr = (uint)comEx.HResult;
|
var hr = (uint)comEx.HResult;
|
||||||
if (hr == 0x8001010E || hr == 0x80004005)
|
if (!IsPptBusyHResult(hr) && (hr == 0x8001010E || hr == 0x80004005))
|
||||||
{
|
|
||||||
// COM对象已失效,触发断开连接
|
|
||||||
DisconnectFromPPT();
|
DisconnectFromPPT();
|
||||||
}
|
if (!IsPptBusyHResult(hr))
|
||||||
LogHelper.WriteLogToFile($"获取演示文稿名称失败: {comEx.Message}", LogHelper.LogType.Warning);
|
LogHelper.WriteLogToFile($"获取演示文稿名称失败: {comEx.Message}", LogHelper.LogType.Warning);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user