diff --git a/GreenshotInterop/OfficeExport/PowerpointExporter.cs b/GreenshotInterop/OfficeExport/PowerpointExporter.cs index ec445bce1..6e6610332 100644 --- a/GreenshotInterop/OfficeExport/PowerpointExporter.cs +++ b/GreenshotInterop/OfficeExport/PowerpointExporter.cs @@ -28,7 +28,14 @@ using Greenshot.Interop; namespace Greenshot.Interop.Office { public class PowerpointExporter { private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PowerpointExporter)); + private static string version = null; + public static bool isAfter2003() { + if (version != null) { + return !version.StartsWith("11"); + } + return false; + } /// /// Get the captions of all the open powerpoint presentations /// @@ -38,10 +45,18 @@ namespace Greenshot.Interop.Office { try { using (IPowerpointApplication powerpointApplication = COMWrapper.GetInstance()) { if (powerpointApplication != null) { + if (version == null) { + version = powerpointApplication.Version; + } LOG.DebugFormat("Open Presentations: {0}", powerpointApplication.Presentations.Count); for (int i = 1; i <= powerpointApplication.Presentations.Count; i++) { IPresentation presentation = powerpointApplication.Presentations.item(i); - if (presentation != null) { + if (presentation != null && presentation.ReadOnly != MsoTriState.msoTrue) { + if (isAfter2003()) { + if (presentation.Final) { + continue; + } + } presentations.Add(presentation.Name); } } diff --git a/GreenshotInterop/OfficeExport/WordExporter.cs b/GreenshotInterop/OfficeExport/WordExporter.cs index ee9dccf79..dc3f32c45 100644 --- a/GreenshotInterop/OfficeExport/WordExporter.cs +++ b/GreenshotInterop/OfficeExport/WordExporter.cs @@ -27,7 +27,14 @@ using Greenshot.Interop; namespace Greenshot.Interop.Office { public class WordExporter { private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordExporter)); + private static string version = null; + public static bool isAfter2003() { + if (version != null) { + return !version.StartsWith("11"); + } + return false; + } /// /// Insert the bitmap stored under the tempfile path into the word document with the supplied caption /// @@ -101,9 +108,19 @@ namespace Greenshot.Interop.Office { try { using (IWordApplication wordApplication = COMWrapper.GetInstance()) { if (wordApplication != null) { - //documents.Add(wordApplication.ActiveDocument); + if (version == null) { + version = wordApplication.Version; + } for (int i = 1; i <= wordApplication.Documents.Count; i++) { IWordDocument document = wordApplication.Documents.item(i); + if (document.ReadOnly) { + continue; + } + if (isAfter2003()) { + if (document.Final) { + continue; + } + } documents.Add(document.ActiveWindow.Caption); } } diff --git a/GreenshotInterop/OfficeInterop/PowerpointInterop.cs b/GreenshotInterop/OfficeInterop/PowerpointInterop.cs index 296e2f5a1..a77ff335b 100644 --- a/GreenshotInterop/OfficeInterop/PowerpointInterop.cs +++ b/GreenshotInterop/OfficeInterop/PowerpointInterop.cs @@ -33,6 +33,7 @@ namespace Greenshot.Interop.Office { bool Visible { get; set; } void Activate(); IPowerpointWindow ActiveWindow { get; } + string Version { get; } } // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slides_members.aspx @@ -57,6 +58,8 @@ namespace Greenshot.Interop.Office { string Name { get; } ISlides Slides { get; } IPowerpointApplication Application { get; } + MsoTriState ReadOnly { get; } + bool Final { get; set; } } // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.presentations_members.aspx diff --git a/GreenshotInterop/OfficeInterop/WordInterop.cs b/GreenshotInterop/OfficeInterop/WordInterop.cs index d02b281c5..e863c2acd 100644 --- a/GreenshotInterop/OfficeInterop/WordInterop.cs +++ b/GreenshotInterop/OfficeInterop/WordInterop.cs @@ -31,6 +31,7 @@ namespace Greenshot.Interop.Office { IDocuments Documents { get; } bool Visible { get; set; } void Activate(); + string Version { get; } } // See: http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.documents_members(v=office.11).aspx @@ -44,6 +45,10 @@ namespace Greenshot.Interop.Office { void Activate(); IWordApplication Application { get; } IWordWindow ActiveWindow { get; } + bool ReadOnly { get; } + + // Only 2007 and later! + bool Final { get; set; } } // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.window_members.aspx