diff --git a/Greenshot/Configuration/EditorConfiguration.cs b/Greenshot/Configuration/EditorConfiguration.cs
index ae033f401..61bdc0733 100644
--- a/Greenshot/Configuration/EditorConfiguration.cs
+++ b/Greenshot/Configuration/EditorConfiguration.cs
@@ -23,7 +23,6 @@ using System.Collections.Generic;
using System.Drawing;
using Greenshot.Drawing.Fields;
-using GreenshotPlugin.UnmanagedHelpers;
using GreenshotPlugin.Effects;
using GreenshotPlugin.IniFile;
using GreenshotPlugin.Interfaces.Drawing;
diff --git a/Greenshot/Destinations/PickerDestination.cs b/Greenshot/Destinations/PickerDestination.cs
index c0f577b9c..26f8fbfb5 100644
--- a/Greenshot/Destinations/PickerDestination.cs
+++ b/Greenshot/Destinations/PickerDestination.cs
@@ -22,7 +22,6 @@
using System.Collections.Generic;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
-using Greenshot.Helpers;
using GreenshotPlugin.Interfaces;
namespace Greenshot.Destinations {
diff --git a/Greenshot/Forms/SettingsForm.cs b/Greenshot/Forms/SettingsForm.cs
index 2df5b4acd..e1243cf67 100644
--- a/Greenshot/Forms/SettingsForm.cs
+++ b/Greenshot/Forms/SettingsForm.cs
@@ -33,7 +33,6 @@ using Greenshot.Destinations;
using Greenshot.Helpers;
using GreenshotPlugin.Controls;
using GreenshotPlugin.Core;
-using GreenshotPlugin.UnmanagedHelpers;
using System.Text.RegularExpressions;
using GreenshotPlugin.IniFile;
using GreenshotPlugin.Interfaces;
diff --git a/Greenshot/Helpers/ProcessorHelper.cs b/Greenshot/Helpers/ProcessorHelper.cs
index fc2e7197b..0ccf0fbe6 100644
--- a/Greenshot/Helpers/ProcessorHelper.cs
+++ b/Greenshot/Helpers/ProcessorHelper.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
using System;
-using System.Collections.Generic;
using GreenshotPlugin.Core;
using GreenshotPlugin.Interfaces;
using log4net;
diff --git a/GreenshotOfficePlugin/Com/DisposableCom.cs b/GreenshotOfficePlugin/Com/DisposableCom.cs
new file mode 100644
index 000000000..1fc17a78b
--- /dev/null
+++ b/GreenshotOfficePlugin/Com/DisposableCom.cs
@@ -0,0 +1,26 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+namespace GreenshotOfficePlugin.Com
+{
+ ///
+ /// A factory for IDisposableCom
+ ///
+ public static class DisposableCom
+ {
+ ///
+ /// Create a ComDisposable for the supplied type object
+ ///
+ /// Type for the com object
+ /// the com object itself
+ /// IDisposableCom of type T
+ public static IDisposableCom Create(T comObject)
+ {
+ if (Equals(comObject, default(T)))
+ {
+ return null;
+ }
+
+ return new DisposableComImplementation(comObject);
+ }
+ }
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/Com/DisposableComImplementation.cs b/GreenshotOfficePlugin/Com/DisposableComImplementation.cs
new file mode 100644
index 000000000..e7a52baac
--- /dev/null
+++ b/GreenshotOfficePlugin/Com/DisposableComImplementation.cs
@@ -0,0 +1,51 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace GreenshotOfficePlugin.Com
+{
+ ///
+ /// Implementation of the IDisposableCom, this is internal to prevent other code to use it directly
+ ///
+ /// Type of the com object
+ internal class DisposableComImplementation : IDisposableCom
+ {
+ public DisposableComImplementation(T obj)
+ {
+ ComObject = obj;
+ }
+
+ public T ComObject { get; private set; }
+
+ ///
+ /// Cleans up the COM object.
+ ///
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ ///
+ /// Release the COM reference
+ ///
+ /// if this was called from the interface.
+ private void Dispose(bool disposing)
+ {
+ if (!disposing)
+ {
+ return;
+ }
+ // Do not catch an exception from this.
+ // You may want to remove these guards depending on
+ // what you think the semantics should be.
+ if (!Equals(ComObject, default(T)) && Marshal.IsComObject(ComObject))
+ {
+ Marshal.ReleaseComObject(ComObject);
+ }
+ ComObject = default;
+ }
+ }
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/Com/IDisposableCom.cs b/GreenshotOfficePlugin/Com/IDisposableCom.cs
new file mode 100644
index 000000000..6bf1327c7
--- /dev/null
+++ b/GreenshotOfficePlugin/Com/IDisposableCom.cs
@@ -0,0 +1,19 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+
+namespace GreenshotOfficePlugin.Com
+{
+ ///
+ /// A simple com wrapper which helps with "using"
+ ///
+ /// Type to wrap
+ public interface IDisposableCom : IDisposable
+ {
+ ///
+ /// The actual com object
+ ///
+ T ComObject { get; }
+ }
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/Com/Ole32Api.cs b/GreenshotOfficePlugin/Com/Ole32Api.cs
new file mode 100644
index 000000000..783f48d0d
--- /dev/null
+++ b/GreenshotOfficePlugin/Com/Ole32Api.cs
@@ -0,0 +1,63 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.Runtime.InteropServices;
+using GreenshotPlugin.Core;
+using GreenshotPlugin.Core.Enums;
+
+namespace GreenshotOfficePlugin.Com
+{
+ ///
+ /// This provides an API for OLE32
+ ///
+ public static class Ole32Api
+ {
+ ///
+ /// This converts a ProgID (program ID) into a Guid with the clsId
+ ///
+ /// string with the program ID
+ /// Guid with the clsId
+ public static Guid ClassIdFromProgId(string programId)
+ {
+ if (CLSIDFromProgID(programId, out Guid clsId).Succeeded())
+ {
+ return clsId;
+ }
+ return clsId;
+ }
+
+ ///
+ /// This converts a clsid (Class ID) into a ProgID (program ID)
+ ///
+ /// Guid with the clsid (Class ID)
+ /// string with the progid
+ public static string ProgIdFromClassId(Guid clsId)
+ {
+ if (ProgIDFromCLSID(ref clsId, out string progId).Succeeded())
+ {
+ return progId;
+ }
+
+ return null;
+ }
+
+ ///
+ /// See more here
+ ///
+ /// string with the progId
+ /// Guid
+ /// HResult
+ [DllImport("ole32.dll", ExactSpelling = true)]
+ private static extern HResult CLSIDFromProgID([In] [MarshalAs(UnmanagedType.LPWStr)] string progId, [Out] out Guid clsId);
+
+ ///
+ /// See more here
+ ///
+ /// Guid The CLSID for which the ProgID is to be requested.
+ /// string the ProgID string. The string that represents clsid includes enclosing braces.
+ /// HResult
+ [DllImport("ole32.dll")]
+ private static extern HResult ProgIDFromCLSID([In] ref Guid clsId, [MarshalAs(UnmanagedType.LPWStr)] out string lplpszProgId);
+ }
+}
diff --git a/GreenshotOfficePlugin/Com/OleAut32Api.cs b/GreenshotOfficePlugin/Com/OleAut32Api.cs
new file mode 100644
index 000000000..6a3e4284c
--- /dev/null
+++ b/GreenshotOfficePlugin/Com/OleAut32Api.cs
@@ -0,0 +1,54 @@
+// Copyright (c) Dapplo and contributors. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.Runtime.InteropServices;
+using GreenshotPlugin.Core;
+using GreenshotPlugin.Core.Enums;
+
+namespace GreenshotOfficePlugin.Com
+{
+ ///
+ /// API for OLEAUT32
+ ///
+ public static class OleAut32Api
+ {
+ ///
+ /// Get the active instance of the com object with the specified GUID
+ ///
+ /// Type for the instance
+ /// Guid
+ /// IDisposableCom of T
+ public static IDisposableCom GetActiveObject(ref Guid clsId)
+ {
+ if (GetActiveObject(ref clsId, IntPtr.Zero, out object comObject).Succeeded())
+ {
+ return DisposableCom.Create((T)comObject);
+ }
+
+ return null;
+ }
+
+ ///
+ /// Get the active instance of the com object with the specified progId
+ ///
+ /// Type for the instance
+ /// string
+ /// IDisposableCom of T
+ public static IDisposableCom GetActiveObject(string progId)
+ {
+ var clsId = Ole32Api.ClassIdFromProgId(progId);
+ return GetActiveObject(ref clsId);
+ }
+
+ ///
+ /// For more details read this
+ ///
+ /// The class identifier (CLSID) of the active object from the OLE registration database.
+ /// Reserved for future use. Must be null.
+ /// The requested active object.
+ ///
+ [DllImport("oleaut32.dll")]
+ private static extern HResult GetActiveObject(ref Guid rclsId, IntPtr pvReserved, [MarshalAs(UnmanagedType.IUnknown)] out object ppunk);
+ }
+}
diff --git a/GreenshotOfficePlugin/Destinations/OneNoteDestination.cs b/GreenshotOfficePlugin/Destinations/OneNoteDestination.cs
index ce24b2862..77d3c0a03 100644
--- a/GreenshotOfficePlugin/Destinations/OneNoteDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/OneNoteDestination.cs
@@ -24,7 +24,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.IO;
using GreenshotOfficePlugin.OfficeExport;
-using GreenshotOfficePlugin.OfficeInterop.OneNote;
+using GreenshotOfficePlugin.OfficeExport.Entities;
using GreenshotPlugin.Core;
using GreenshotPlugin.Interfaces;
@@ -35,6 +35,7 @@ namespace GreenshotOfficePlugin.Destinations {
public const string DESIGNATION = "OneNote";
private static readonly string exePath;
private readonly OneNotePage page;
+ private readonly OneNoteExporter _oneNoteExporter = new OneNoteExporter();
static OneNoteDestination() {
exePath = PluginUtils.GetExePath("ONENOTE.EXE");
@@ -94,7 +95,7 @@ namespace GreenshotOfficePlugin.Destinations {
}
public override IEnumerable DynamicDestinations() {
- foreach (OneNotePage page in OneNoteExporter.GetPages()) {
+ foreach (OneNotePage page in _oneNoteExporter.GetPages()) {
yield return new OneNoteDestination(page);
}
}
@@ -104,14 +105,14 @@ namespace GreenshotOfficePlugin.Destinations {
if (page == null) {
try {
- exportInformation.ExportMade = OneNoteExporter.ExportToNewPage(surface);
+ exportInformation.ExportMade = _oneNoteExporter.ExportToNewPage(surface);
} catch(Exception ex) {
exportInformation.ErrorMessage = ex.Message;
LOG.Error(ex);
}
} else {
try {
- exportInformation.ExportMade = OneNoteExporter.ExportToPage(surface, page);
+ exportInformation.ExportMade = _oneNoteExporter.ExportToPage(surface, page);
} catch(Exception ex) {
exportInformation.ErrorMessage = ex.Message;
LOG.Error(ex);
diff --git a/GreenshotOfficePlugin/Destinations/OutlookDestination.cs b/GreenshotOfficePlugin/Destinations/OutlookDestination.cs
index 48590a6da..91e58b273 100644
--- a/GreenshotOfficePlugin/Destinations/OutlookDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/OutlookDestination.cs
@@ -25,11 +25,11 @@ using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using GreenshotOfficePlugin.OfficeExport;
-using GreenshotOfficePlugin.OfficeInterop.Outlook;
using GreenshotPlugin.Core;
using GreenshotPlugin.IniFile;
using GreenshotPlugin.Interfaces;
using GreenshotPlugin.Interfaces.Plugin;
+using Microsoft.Office.Interop.Outlook;
namespace GreenshotOfficePlugin.Destinations {
///
@@ -47,6 +47,7 @@ namespace GreenshotOfficePlugin.Destinations {
private const string MapiClient = "Microsoft Outlook";
private readonly string _outlookInspectorCaption;
private readonly OlObjectClass _outlookInspectorType;
+ private readonly OutlookEmailExporter _outlookEmailExporter = new OutlookEmailExporter();
static OutlookDestination() {
if (EmailConfigHelper.HasOutlook()) {
@@ -99,7 +100,7 @@ namespace GreenshotOfficePlugin.Destinations {
}
public override IEnumerable DynamicDestinations() {
- IDictionary inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets();
+ IDictionary inspectorCaptions = _outlookEmailExporter.RetrievePossibleTargets();
if (inspectorCaptions != null) {
foreach (string inspectorCaption in inspectorCaptions.Keys) {
yield return new OutlookDestination(inspectorCaption, inspectorCaptions[inspectorCaption]);
@@ -137,11 +138,11 @@ namespace GreenshotOfficePlugin.Destinations {
attachmentName = Regex.Replace(attachmentName, @"[^\x20\d\w]", string.Empty);
if (_outlookInspectorCaption != null) {
- OutlookEmailExporter.ExportToInspector(_outlookInspectorCaption, tmpFile, attachmentName);
+ _outlookEmailExporter.ExportToInspector(_outlookInspectorCaption, tmpFile, attachmentName);
exportInformation.ExportMade = true;
} else {
if (!manuallyInitiated) {
- var inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets();
+ var inspectorCaptions = _outlookEmailExporter.RetrievePossibleTargets();
if (inspectorCaptions != null && inspectorCaptions.Count > 0) {
var destinations = new List
{
@@ -154,7 +155,7 @@ namespace GreenshotOfficePlugin.Destinations {
return ShowPickerMenu(false, surface, captureDetails, destinations);
}
} else {
- exportInformation.ExportMade = OutlookEmailExporter.ExportToOutlook(OfficeConfig.OutlookEmailFormat, tmpFile, FilenameHelper.FillPattern(OfficeConfig.EmailSubjectPattern, captureDetails, false), attachmentName, OfficeConfig.EmailTo, OfficeConfig.EmailCC, OfficeConfig.EmailBCC, null);
+ exportInformation.ExportMade = _outlookEmailExporter.ExportToOutlook(OfficeConfig.OutlookEmailFormat, tmpFile, FilenameHelper.FillPattern(OfficeConfig.EmailSubjectPattern, captureDetails, false), attachmentName, OfficeConfig.EmailTo, OfficeConfig.EmailCC, OfficeConfig.EmailBCC, null);
}
}
ProcessExport(exportInformation, surface);
diff --git a/GreenshotOfficePlugin/Destinations/PowerpointDestination.cs b/GreenshotOfficePlugin/Destinations/PowerpointDestination.cs
index bdb8bad6d..1000fb7d9 100644
--- a/GreenshotOfficePlugin/Destinations/PowerpointDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/PowerpointDestination.cs
@@ -22,6 +22,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.IO;
+using System.Linq;
using System.Text.RegularExpressions;
using GreenshotOfficePlugin.OfficeExport;
using GreenshotPlugin.Core;
@@ -38,6 +39,7 @@ namespace GreenshotOfficePlugin.Destinations {
private static readonly string ExePath;
private readonly string _presentationName;
+ private readonly PowerpointExporter _powerpointExporter = new PowerpointExporter();
static PowerpointDestination() {
ExePath = PluginUtils.GetExePath("POWERPNT.EXE");
@@ -84,7 +86,7 @@ namespace GreenshotOfficePlugin.Destinations {
}
public override IEnumerable DynamicDestinations() {
- foreach (string presentationName in PowerpointExporter.GetPowerpointPresentations()) {
+ foreach (string presentationName in _powerpointExporter.GetPowerpointPresentations()) {
yield return new PowerpointDestination(presentationName);
}
}
@@ -98,10 +100,10 @@ namespace GreenshotOfficePlugin.Destinations {
imageSize = surface.Image.Size;
}
if (_presentationName != null) {
- exportInformation.ExportMade = PowerpointExporter.ExportToPresentation(_presentationName, tmpFile, imageSize, captureDetails.Title);
+ exportInformation.ExportMade = _powerpointExporter.ExportToPresentation(_presentationName, tmpFile, imageSize, captureDetails.Title);
} else {
if (!manuallyInitiated) {
- var presentations = PowerpointExporter.GetPowerpointPresentations();
+ var presentations = _powerpointExporter.GetPowerpointPresentations().ToList();
if (presentations != null && presentations.Count > 0) {
var destinations = new List {new PowerpointDestination()};
foreach (string presentation in presentations) {
@@ -111,7 +113,7 @@ namespace GreenshotOfficePlugin.Destinations {
return ShowPickerMenu(false, surface, captureDetails, destinations);
}
} else if (!exportInformation.ExportMade) {
- exportInformation.ExportMade = PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title);
+ exportInformation.ExportMade = _powerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title);
}
}
ProcessExport(exportInformation, surface);
diff --git a/GreenshotOfficePlugin/Destinations/WordDestination.cs b/GreenshotOfficePlugin/Destinations/WordDestination.cs
index c9148c408..a8a80893d 100644
--- a/GreenshotOfficePlugin/Destinations/WordDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/WordDestination.cs
@@ -23,6 +23,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
+using System.Linq;
using System.Text.RegularExpressions;
using GreenshotOfficePlugin.OfficeExport;
using GreenshotPlugin.Core;
@@ -39,7 +40,7 @@ namespace GreenshotOfficePlugin.Destinations {
private const int IconDocument = 1;
private static readonly string ExePath;
private readonly string _documentCaption;
-
+ private readonly WordExporter _wordExporter = new WordExporter();
static WordDestination() {
ExePath = PluginUtils.GetExePath("WINWORD.EXE");
if (ExePath != null && !File.Exists(ExePath)) {
@@ -68,7 +69,7 @@ namespace GreenshotOfficePlugin.Destinations {
public override Image DisplayIcon => PluginUtils.GetCachedExeIcon(ExePath, !string.IsNullOrEmpty(_documentCaption) ? IconDocument : IconApplication);
public override IEnumerable DynamicDestinations() {
- foreach (string wordCaption in WordExporter.GetWordDocuments()) {
+ foreach (string wordCaption in _wordExporter.GetWordDocuments()) {
yield return new WordDestination(wordCaption);
}
}
@@ -81,11 +82,11 @@ namespace GreenshotOfficePlugin.Destinations {
}
if (_documentCaption != null) {
try {
- WordExporter.InsertIntoExistingDocument(_documentCaption, tmpFile);
+ _wordExporter.InsertIntoExistingDocument(_documentCaption, tmpFile);
exportInformation.ExportMade = true;
} catch (Exception) {
try {
- WordExporter.InsertIntoExistingDocument(_documentCaption, tmpFile);
+ _wordExporter.InsertIntoExistingDocument(_documentCaption, tmpFile);
exportInformation.ExportMade = true;
} catch (Exception ex) {
Log.Error(ex);
@@ -95,7 +96,7 @@ namespace GreenshotOfficePlugin.Destinations {
}
} else {
if (!manuallyInitiated) {
- var documents = WordExporter.GetWordDocuments();
+ var documents = _wordExporter.GetWordDocuments().ToList();
if (documents != null && documents.Count > 0) {
var destinations = new List
{
@@ -109,12 +110,12 @@ namespace GreenshotOfficePlugin.Destinations {
}
}
try {
- WordExporter.InsertIntoNewDocument(tmpFile, null, null);
+ _wordExporter.InsertIntoNewDocument(tmpFile, null, null);
exportInformation.ExportMade = true;
} catch(Exception) {
// Retry once, just in case
try {
- WordExporter.InsertIntoNewDocument(tmpFile, null, null);
+ _wordExporter.InsertIntoNewDocument(tmpFile, null, null);
exportInformation.ExportMade = true;
} catch (Exception ex) {
Log.Error(ex);
diff --git a/GreenshotOfficePlugin/GreenshotOfficePlugin.csproj b/GreenshotOfficePlugin/GreenshotOfficePlugin.csproj
index b5e4884bc..aea84a07e 100644
--- a/GreenshotOfficePlugin/GreenshotOfficePlugin.csproj
+++ b/GreenshotOfficePlugin/GreenshotOfficePlugin.csproj
@@ -46,4 +46,8 @@
+
+
+
+
diff --git a/GreenshotOfficePlugin/OfficeConfiguration.cs b/GreenshotOfficePlugin/OfficeConfiguration.cs
index 2401e782d..3971e5cd4 100644
--- a/GreenshotOfficePlugin/OfficeConfiguration.cs
+++ b/GreenshotOfficePlugin/OfficeConfiguration.cs
@@ -19,9 +19,9 @@
* along with this program. If not, see .
*/
-using GreenshotOfficePlugin.OfficeInterop.Outlook;
-using GreenshotOfficePlugin.OfficeInterop.Powerpoint;
+using GreenshotOfficePlugin.OfficeInterop;
using GreenshotPlugin.IniFile;
+using Microsoft.Office.Interop.PowerPoint;
namespace GreenshotOfficePlugin {
@@ -48,7 +48,7 @@ namespace GreenshotOfficePlugin {
[IniProperty("PowerpointLockAspectRatio", Description = "For Powerpoint: Lock the aspect ratio of the image", DefaultValue = "True")]
public bool PowerpointLockAspectRatio { get; set; }
[IniProperty("PowerpointSlideLayout", Description = "For Powerpoint: Slide layout, changing this to a wrong value will fallback on ppLayoutBlank!!", DefaultValue = "ppLayoutPictureWithCaption")]
- public PPSlideLayout PowerpointSlideLayout { get; set; }
+ public PpSlideLayout PowerpointSlideLayout { get; set; }
}
}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeExport/Entities/OneNoteNotebook.cs b/GreenshotOfficePlugin/OfficeExport/Entities/OneNoteNotebook.cs
new file mode 100644
index 000000000..75c2f23d3
--- /dev/null
+++ b/GreenshotOfficePlugin/OfficeExport/Entities/OneNoteNotebook.cs
@@ -0,0 +1,37 @@
+// Greenshot - a free and open source screenshot tool
+// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
+//
+// For more information see: http://getgreenshot.org/
+// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 1 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+namespace GreenshotOfficePlugin.OfficeExport.Entities
+{
+ ///
+ /// Container for transporting notebook information
+ ///
+ public class OneNoteNotebook
+ {
+ ///
+ /// ID of the notebook
+ ///
+ public string Id { get; set; }
+
+ ///
+ /// Name of the notebook
+ ///
+ public string Name { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeExport/Entities/OneNotePage.cs b/GreenshotOfficePlugin/OfficeExport/Entities/OneNotePage.cs
new file mode 100644
index 000000000..b9fd2c4a9
--- /dev/null
+++ b/GreenshotOfficePlugin/OfficeExport/Entities/OneNotePage.cs
@@ -0,0 +1,53 @@
+// Greenshot - a free and open source screenshot tool
+// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
+//
+// For more information see: http://getgreenshot.org/
+// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 1 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+namespace GreenshotOfficePlugin.OfficeExport.Entities
+{
+ ///
+ /// Container for transporting Page information
+ ///
+ public class OneNotePage
+ {
+ ///
+ public string DisplayName
+ {
+ get
+ {
+ var notebook = Parent.Parent;
+ if (string.IsNullOrEmpty(notebook.Name))
+ {
+ return string.Format("{0} / {1}", Parent.Name, Name);
+ }
+ return string.Format("{0} / {1} / {2}", Parent.Parent.Name, Parent.Name, Name);
+ }
+ }
+
+ ///
+ public string Id { get; set; }
+
+ ///
+ public bool IsCurrentlyViewed { get; set; }
+
+ ///
+ public string Name { get; set; }
+
+ ///
+ public OneNoteSection Parent { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeExport/Entities/OneNoteSection.cs b/GreenshotOfficePlugin/OfficeExport/Entities/OneNoteSection.cs
new file mode 100644
index 000000000..e02908c11
--- /dev/null
+++ b/GreenshotOfficePlugin/OfficeExport/Entities/OneNoteSection.cs
@@ -0,0 +1,42 @@
+// Greenshot - a free and open source screenshot tool
+// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
+//
+// For more information see: http://getgreenshot.org/
+// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 1 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+namespace GreenshotOfficePlugin.OfficeExport.Entities
+{
+ ///
+ /// Container for transporting section information
+ ///
+ public class OneNoteSection
+ {
+ ///
+ /// ID of the section
+ ///
+ public string Id { get; set; }
+
+ ///
+ /// Name of the section
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// Parent notebook
+ ///
+ public OneNoteNotebook Parent { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs b/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs
index 2610ab564..71939296e 100644
--- a/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs
+++ b/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs
@@ -1,167 +1,199 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// Greenshot - a free and open source screenshot tool
+// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
+//
+// For more information see: http://getgreenshot.org/
+// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 1 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
using System;
using System.Collections.Generic;
using System.Drawing;
-using System.Reflection;
+using GreenshotOfficePlugin.Com;
using GreenshotOfficePlugin.OfficeInterop;
-using GreenshotOfficePlugin.OfficeInterop.Excel;
-using GreenshotOfficePlugin.OfficeInterop.Outlook;
-using GreenshotOfficePlugin.OfficeInterop.Powerpoint;
-using GreenshotPlugin.Core;
-using GreenshotPlugin.Interop;
+using GreenshotPlugin.UnmanagedHelpers;
+using Microsoft.Office.Core;
+using Microsoft.Office.Interop.Excel;
+using Version = System.Version;
-namespace GreenshotOfficePlugin.OfficeExport {
- public class ExcelExporter {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ExcelExporter));
- private static Version _excelVersion;
+namespace GreenshotOfficePlugin.OfficeExport
+{
+ ///
+ /// Excel exporter
+ ///
+ public static class ExcelExporter
+ {
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExcelExporter));
+ private static Version _excelVersion;
- ///
- /// Get all currently opened workbooks
- ///
- /// List of string with names of the workbooks
- public static List GetWorkbooks() {
- List currentWorkbooks = new List();
- using (IExcelApplication excelApplication = GetExcelApplication()) {
- if (excelApplication == null) {
- return currentWorkbooks;
- }
+ ///
+ /// Call this to get the running Excel application, returns null if there isn't any.
+ ///
+ /// ComDisposable for Excel.Application or null
+ private static IDisposableCom GetExcelApplication()
+ {
+ IDisposableCom excelApplication;
+ try
+ {
+ excelApplication = OleAut32Api.GetActiveObject("Excel.Application");
+ }
+ catch
+ {
+ // Ignore, probably no excel running
+ return null;
+ }
+ if (excelApplication?.ComObject != null)
+ {
+ InitializeVariables(excelApplication);
+ }
+ return excelApplication;
+ }
- using IWorkbooks workbooks = excelApplication.Workbooks;
- for (int i = 1; i <= workbooks.Count; i++)
+ ///
+ /// Call this to get the running Excel application, or create a new instance
+ ///
+ /// ComDisposable for Excel.Application
+ private static IDisposableCom GetOrCreateExcelApplication()
+ {
+ var excelApplication = GetExcelApplication();
+ if (excelApplication == null)
+ {
+ excelApplication = DisposableCom.Create(new Application());
+ }
+ InitializeVariables(excelApplication);
+ return excelApplication;
+ }
+
+ ///
+ /// Get all currently opened workbooks
+ ///
+ /// IEnumerable with names of the workbooks
+ public static IEnumerable GetWorkbooks()
+ {
+ using var excelApplication = GetExcelApplication();
+ if ((excelApplication == null) || (excelApplication.ComObject == null))
+ {
+ yield break;
+ }
+
+ using var workbooks = DisposableCom.Create(excelApplication.ComObject.Workbooks);
+ for (int i = 1; i <= workbooks.ComObject.Count; i++)
+ {
+ using var workbook = DisposableCom.Create(workbooks.ComObject[i]);
+ if (workbook != null)
{
- using IWorkbook workbook = workbooks[i];
- if (workbook != null) {
- currentWorkbooks.Add(workbook.Name);
- }
+ yield return workbook.ComObject.Name;
}
}
- currentWorkbooks.Sort();
- return currentWorkbooks;
- }
+ }
- ///
- /// Insert image from supplied tmp file into the give excel workbook
- ///
- ///
- ///
- ///
- public static void InsertIntoExistingWorkbook(string workbookName, string tmpFile, Size imageSize)
+ ///
+ /// Initialize static excel variables like version and currentuser
+ ///
+ ///
+ private static void InitializeVariables(IDisposableCom excelApplication)
{
- using IExcelApplication excelApplication = GetExcelApplication();
- if (excelApplication == null) {
+ if ((excelApplication == null) || (excelApplication.ComObject == null) || (_excelVersion != null))
+ {
return;
}
- using (IWorkbooks workbooks = excelApplication.Workbooks) {
- for (int i = 1; i <= workbooks.Count; i++)
+ if (!Version.TryParse(excelApplication.ComObject.Version, out _excelVersion))
+ {
+ LOG.Warn("Assuming Excel version 1997.");
+ _excelVersion = new Version((int)OfficeVersions.Office97, 0, 0, 0);
+ }
+ }
+
+ ///
+ /// Insert image from supplied tmp file into the give excel workbook
+ ///
+ ///
+ ///
+ ///
+ public static void InsertIntoExistingWorkbook(string workbookName, string tmpFile, Size imageSize)
+ {
+ using var excelApplication = GetExcelApplication();
+ if ((excelApplication == null) || (excelApplication.ComObject == null))
+ {
+ return;
+ }
+
+ using var workbooks = DisposableCom.Create(excelApplication.ComObject.Workbooks);
+ for (int i = 1; i <= workbooks.ComObject.Count; i++)
+ {
+ using var workbook = DisposableCom.Create((_Workbook)workbooks.ComObject[i]);
+ if ((workbook != null) && workbook.ComObject.Name.StartsWith(workbookName))
{
- using IWorkbook workbook = workbooks[i];
- if (workbook != null && workbook.Name.StartsWith(workbookName)) {
- InsertIntoExistingWorkbook(workbook, tmpFile, imageSize);
- }
+ InsertIntoExistingWorkbook(workbook, tmpFile, imageSize);
}
}
- int hWnd = excelApplication.Hwnd;
- if (hWnd > 0)
- {
- WindowDetails.ToForeground(new IntPtr(hWnd));
- }
}
- ///
- /// Insert a file into an already created workbook
- ///
- ///
- ///
- ///
- private static void InsertIntoExistingWorkbook(IWorkbook workbook, string tmpFile, Size imageSize) {
- IWorksheet workSheet = workbook.ActiveSheet;
-
- using IShapes shapes = workSheet?.Shapes;
-
- using IShape shape = shapes?.AddPicture(tmpFile, MsoTriState.msoFalse, MsoTriState.msoTrue, 0, 0, imageSize.Width, imageSize.Height);
- if (shape == null) return;
-
- shape.Top = 40;
- shape.Left = 40;
- shape.LockAspectRatio = MsoTriState.msoTrue;
- shape.ScaleHeight(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromTopLeft);
- shape.ScaleWidth(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromTopLeft);
- }
-
- ///
- /// Add an image-file to a newly created workbook
- ///
- ///
- ///
- public static void InsertIntoNewWorkbook(string tmpFile, Size imageSize)
+ ///
+ /// Insert a file into an already created workbook
+ ///
+ ///
+ ///
+ ///
+ private static void InsertIntoExistingWorkbook(IDisposableCom<_Workbook> workbook, string tmpFile, Size imageSize)
{
- using IExcelApplication excelApplication = GetOrCreateExcelApplication();
- if (excelApplication != null) {
- excelApplication.Visible = true;
- object template = Missing.Value;
- using IWorkbooks workbooks = excelApplication.Workbooks;
- IWorkbook workbook = workbooks.Add(template);
- InsertIntoExistingWorkbook(workbook, tmpFile, imageSize);
+ using var workSheet = DisposableCom.Create(workbook.ComObject.ActiveSheet as Worksheet);
+ if (workSheet == null)
+ {
+ return;
}
+
+ using var shapes = DisposableCom.Create(workSheet.ComObject.Shapes);
+ if (shapes == null)
+ {
+ return;
+ }
+
+ using var shape = DisposableCom.Create(shapes.ComObject.AddPicture(tmpFile, MsoTriState.msoFalse, MsoTriState.msoTrue, 0, 0, imageSize.Width, imageSize.Height));
+ if (shape == null)
+ {
+ return;
+ }
+
+ shape.ComObject.Top = 40;
+ shape.ComObject.Left = 40;
+ shape.ComObject.LockAspectRatio = MsoTriState.msoTrue;
+ shape.ComObject.ScaleHeight(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromTopLeft);
+ shape.ComObject.ScaleWidth(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromTopLeft);
+ workbook.ComObject.Activate();
+ using var application = DisposableCom.Create(workbook.ComObject.Application);
+ User32.SetForegroundWindow((IntPtr) application.ComObject.Hwnd);
}
+ ///
+ /// Add an image-file to a newly created workbook
+ ///
+ ///
+ ///
+ public static void InsertIntoNewWorkbook(string tmpFile, Size imageSize)
+ {
+ using var excelApplication = GetOrCreateExcelApplication();
+ if (excelApplication == null)
+ {
+ return;
+ }
- ///
- /// Call this to get the running Excel application, returns null if there isn't any.
- ///
- /// IExcelApplication or null
- private static IExcelApplication GetExcelApplication() {
- IExcelApplication excelApplication = COMWrapper.GetInstance();
- InitializeVariables(excelApplication);
- return excelApplication;
- }
+ excelApplication.ComObject.Visible = true;
+ using var workbooks = DisposableCom.Create(excelApplication.ComObject.Workbooks);
+ using var workbook = DisposableCom.Create((_Workbook)workbooks.ComObject.Add());
+ InsertIntoExistingWorkbook(workbook, tmpFile, imageSize);
+ }
+ }
- ///
- /// Call this to get the running Excel application, or create a new instance
- ///
- /// IExcelApplication
- private static IExcelApplication GetOrCreateExcelApplication() {
- IExcelApplication excelApplication = COMWrapper.GetOrCreateInstance();
- InitializeVariables(excelApplication);
- return excelApplication;
- }
-
- ///
- /// Initialize static outlook variables like version and currentuser
- ///
- ///
- private static void InitializeVariables(IExcelApplication excelApplication) {
- if (excelApplication == null || _excelVersion != null) {
- return;
- }
- try {
- _excelVersion = new Version(excelApplication.Version);
- Log.InfoFormat("Using Excel {0}", _excelVersion);
- } catch (Exception exVersion) {
- Log.Error(exVersion);
- Log.Warn("Assuming Excel version 1997.");
- _excelVersion = new Version((int)OfficeVersion.OFFICE_97, 0, 0, 0);
- }
- }
- }
-}
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeExport/OneNoteExporter.cs b/GreenshotOfficePlugin/OfficeExport/OneNoteExporter.cs
index 80934900e..23525b608 100644
--- a/GreenshotOfficePlugin/OfficeExport/OneNoteExporter.cs
+++ b/GreenshotOfficePlugin/OfficeExport/OneNoteExporter.cs
@@ -1,228 +1,307 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// Greenshot - a free and open source screenshot tool
+// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
+//
+// For more information see: http://getgreenshot.org/
+// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 1 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Xml;
-using GreenshotOfficePlugin.OfficeInterop.OneNote;
+using GreenshotOfficePlugin.Com;
+using GreenshotOfficePlugin.OfficeExport.Entities;
using GreenshotPlugin.Core;
using GreenshotPlugin.Interfaces;
using GreenshotPlugin.Interfaces.Plugin;
-using GreenshotPlugin.Interop;
+using Microsoft.Office.Interop.OneNote;
-namespace GreenshotOfficePlugin.OfficeExport {
+namespace GreenshotOfficePlugin.OfficeExport
+{
+ ///
+ /// OneNote exporter
+ /// More details about OneNote: http://msdn.microsoft.com/en-us/magazine/ff796230.aspx
+ ///
+ public class OneNoteExporter
+ {
+ private const string XmlImageContent = "{0}";
+ private const string XmlOutline = "{0}";
+ private const string OnenoteNamespace2010 = "http://schemas.microsoft.com/office/onenote/2010/onenote";
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OneNoteExporter));
- public class OneNoteExporter {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(OneNoteExporter));
- private const string XmlImageContent = "{0}";
- private const string XmlOutline = "{0}";
- private const string OnenoteNamespace2010 = "http://schemas.microsoft.com/office/onenote/2010/onenote";
-
- ///
- /// Create a new page in the "unfiled notes section", with the title of the capture, and export the capture there.
- ///
- /// ISurface
- /// bool true if export worked
- public static bool ExportToNewPage(ISurface surfaceToUpload) {
- using(IOneNoteApplication oneNoteApplication = COMWrapper.GetOrCreateInstance()) {
- OneNotePage newPage = new OneNotePage();
- string unfiledNotesSectionId = GetSectionId(oneNoteApplication, SpecialLocation.slUnfiledNotesSection);
- if(unfiledNotesSectionId != null) {
- // ReSharper disable once RedundantAssignment
- string pageId = string.Empty;
- oneNoteApplication.CreateNewPage(unfiledNotesSectionId, out pageId, NewPageStyle.npsDefault);
- newPage.ID = pageId;
- // Set the new name, this is automatically done in the export to page
- newPage.Name = surfaceToUpload.CaptureDetails.Title;
- return ExportToPage(oneNoteApplication, surfaceToUpload, newPage);
- }
- }
- return false;
- }
-
- ///
- /// Export the capture to the specified page
- ///
- /// ISurface
- /// OneNotePage
- /// bool true if everything worked
- public static bool ExportToPage(ISurface surfaceToUpload, OneNotePage page)
+ ///
+ /// Create a new page in the "unfiled notes section", with the title of the capture, and export the capture there.
+ ///
+ /// ISurface
+ /// bool true if export worked
+ public bool ExportToNewPage(ISurface surfaceToUpload)
{
- using IOneNoteApplication oneNoteApplication = COMWrapper.GetOrCreateInstance();
+ using var oneNoteApplication = GetOrCreateOneNoteApplication();
+ var newPage = new OneNotePage();
+ string unfiledNotesSectionId = GetSectionId(oneNoteApplication, SpecialLocation.slUnfiledNotesSection);
+ if (unfiledNotesSectionId == null)
+ {
+ return false;
+ }
+
+ string pageId;
+ oneNoteApplication.ComObject.CreateNewPage(unfiledNotesSectionId, out pageId, NewPageStyle.npsDefault);
+ newPage.Id = pageId;
+ // Set the new name, this is automatically done in the export to page
+ newPage.Name = surfaceToUpload.CaptureDetails.Title;
+ return ExportToPage(oneNoteApplication, surfaceToUpload, newPage);
+ }
+
+ ///
+ /// Export the capture to the specified page
+ ///
+ /// ISurface
+ /// OneNotePage
+ /// bool true if everything worked
+ public bool ExportToPage(ISurface surfaceToUpload, OneNotePage page)
+ {
+ using var oneNoteApplication = GetOrCreateOneNoteApplication();
return ExportToPage(oneNoteApplication, surfaceToUpload, page);
}
- ///
- /// Export the capture to the specified page
- ///
- /// IOneNoteApplication
- /// ISurface
- /// OneNotePage
- /// bool true if everything worked
- private static bool ExportToPage(IOneNoteApplication oneNoteApplication, ISurface surfaceToUpload, OneNotePage page) {
- if(oneNoteApplication == null) {
- return false;
- }
+ ///
+ /// Export the capture to the specified page
+ ///
+ /// IOneNoteApplication
+ /// ISurface
+ /// OneNotePage
+ /// bool true if everything worked
+ private bool ExportToPage(IDisposableCom oneNoteApplication, ISurface surfaceToUpload, OneNotePage page)
+ {
+ if (oneNoteApplication == null)
+ {
+ return false;
+ }
- using MemoryStream pngStream = new MemoryStream();
- SurfaceOutputSettings pngOutputSettings = new SurfaceOutputSettings(OutputFormat.png, 100, false);
+ using var pngStream = new MemoryStream();
+ var pngOutputSettings = new SurfaceOutputSettings(OutputFormat.png, 100, false);
ImageOutput.SaveToStream(surfaceToUpload, pngStream, pngOutputSettings);
- string base64String = Convert.ToBase64String(pngStream.GetBuffer());
- string imageXmlStr = string.Format(XmlImageContent, base64String, surfaceToUpload.Image.Width, surfaceToUpload.Image.Height);
- string pageChangesXml = string.Format(XmlOutline, imageXmlStr, page.ID, OnenoteNamespace2010, page.Name);
- Log.InfoFormat("Sending XML: {0}", pageChangesXml);
- oneNoteApplication.UpdatePageContent(pageChangesXml, DateTime.MinValue, XMLSchema.xs2010, false);
- try {
- oneNoteApplication.NavigateTo(page.ID, null, false);
- } catch(Exception ex) {
- Log.Warn("Unable to navigate to the target page", ex);
+ var base64String = Convert.ToBase64String(pngStream.GetBuffer());
+ var imageXmlStr = string.Format(XmlImageContent, base64String, surfaceToUpload.Width, surfaceToUpload.Height);
+ var pageChangesXml = string.Format(XmlOutline, imageXmlStr, page.Id, OnenoteNamespace2010, page.Name);
+ LOG.InfoFormat("Sending XML: {0}", pageChangesXml);
+ oneNoteApplication.ComObject.UpdatePageContent(pageChangesXml, DateTime.MinValue, XMLSchema.xs2010, false);
+ try
+ {
+ oneNoteApplication.ComObject.NavigateTo(page.Id, null, false);
+ }
+ catch (Exception ex)
+ {
+ LOG.Warn("Unable to navigate to the target page", ex);
}
return true;
}
- ///
- /// Retrieve the Section ID for the specified special location
- ///
- ///
- /// SpecialLocation
- /// string with section ID
- private static string GetSectionId(IOneNoteApplication oneNoteApplication, SpecialLocation specialLocation) {
- if(oneNoteApplication == null) {
- return null;
- }
- // ReSharper disable once RedundantAssignment
- string unfiledNotesPath = string.Empty;
- oneNoteApplication.GetSpecialLocation(specialLocation, out unfiledNotesPath);
-
- // ReSharper disable once RedundantAssignment
- string notebookXml = string.Empty;
- oneNoteApplication.GetHierarchy(string.Empty, HierarchyScope.hsPages, out notebookXml, XMLSchema.xs2010);
- if(!string.IsNullOrEmpty(notebookXml)) {
- Log.Debug(notebookXml);
- StringReader reader = null;
- try {
- reader = new StringReader(notebookXml);
- using XmlTextReader xmlReader = new XmlTextReader(reader);
- while(xmlReader.Read()) {
- if("one:Section".Equals(xmlReader.Name)) {
- string id = xmlReader.GetAttribute("ID");
- string path = xmlReader.GetAttribute("path");
- if(unfiledNotesPath.Equals(path)) {
- return id;
- }
- }
- }
- } finally
- {
- reader?.Dispose();
- }
- }
- return null;
- }
-
- ///
- /// Get the captions of all the open word documents
- ///
- ///
- public static List GetPages() {
- List pages = new List();
- try
+ ///
+ /// Call this to get the running Excel application, returns null if there isn't any.
+ ///
+ /// ComDisposable for Excel.Application or null
+ private IDisposableCom GetOneNoteApplication()
+ {
+ IDisposableCom oneNoteApplication;
+ try
{
- using IOneNoteApplication oneNoteApplication = COMWrapper.GetOrCreateInstance();
- if (oneNoteApplication != null) {
+ oneNoteApplication = OleAut32Api.GetActiveObject("OneNote.Application");
+ }
+ catch
+ {
+ // Ignore, probably no OneNote running
+ return null;
+ }
+ return oneNoteApplication;
+ }
+
+ ///
+ /// Call this to get the running OneNote application, or create a new instance
+ ///
+ /// ComDisposable for OneNote.Application
+ private IDisposableCom GetOrCreateOneNoteApplication()
+ {
+ var oneNoteApplication = GetOneNoteApplication();
+ if (oneNoteApplication == null)
+ {
+ oneNoteApplication = DisposableCom.Create(new Application());
+ }
+ return oneNoteApplication;
+ }
+
+ ///
+ /// Get the captions of all the open word documents
+ ///
+ ///
+ public IList GetPages()
+ {
+ var pages = new List();
+ try
+ {
+ using var oneNoteApplication = GetOrCreateOneNoteApplication();
+ if (oneNoteApplication != null)
+ {
// ReSharper disable once RedundantAssignment
- string notebookXml = string.Empty;
- oneNoteApplication.GetHierarchy(string.Empty, HierarchyScope.hsPages, out notebookXml, XMLSchema.xs2010);
- if (!string.IsNullOrEmpty(notebookXml)) {
- Log.Debug(notebookXml);
+ string notebookXml = "";
+ oneNoteApplication.ComObject.GetHierarchy("", HierarchyScope.hsPages, out notebookXml, XMLSchema.xs2010);
+ if (!string.IsNullOrEmpty(notebookXml))
+ {
+ LOG.Debug(notebookXml);
StringReader reader = null;
- try {
+ try
+ {
reader = new StringReader(notebookXml);
- using XmlTextReader xmlReader = new XmlTextReader(reader);
+ using var xmlReader = new XmlTextReader(reader);
reader = null;
OneNoteSection currentSection = null;
OneNoteNotebook currentNotebook = null;
- while (xmlReader.Read()) {
- if ("one:Notebook".Equals(xmlReader.Name)) {
+ while (xmlReader.Read())
+ {
+ if ("one:Notebook".Equals(xmlReader.Name))
+ {
string id = xmlReader.GetAttribute("ID");
- if (id != null && (currentNotebook == null || !id.Equals(currentNotebook.ID))) {
+ if ((id != null) && ((currentNotebook == null) || !id.Equals(currentNotebook.Id)))
+ {
currentNotebook = new OneNoteNotebook
{
- ID = xmlReader.GetAttribute("ID"),
+ Id = xmlReader.GetAttribute("ID"),
Name = xmlReader.GetAttribute("name")
};
}
}
- if ("one:Section".Equals(xmlReader.Name)) {
+ if ("one:Section".Equals(xmlReader.Name))
+ {
string id = xmlReader.GetAttribute("ID");
- if (id != null && (currentSection == null || !id.Equals(currentSection.ID))) {
+ if (id != null && (currentSection == null || !id.Equals(currentSection.Id)))
+ {
currentSection = new OneNoteSection
{
- ID = xmlReader.GetAttribute("ID"),
+ Id = xmlReader.GetAttribute("ID"),
Name = xmlReader.GetAttribute("name"),
Parent = currentNotebook
};
}
}
- if ("one:Page".Equals(xmlReader.Name)) {
+ if ("one:Page".Equals(xmlReader.Name))
+ {
// Skip deleted items
- if ("true".Equals(xmlReader.GetAttribute("isInRecycleBin"))) {
+ if ("true".Equals(xmlReader.GetAttribute("isInRecycleBin")))
+ {
continue;
}
- OneNotePage page = new OneNotePage
+
+ var page = new OneNotePage
{
Parent = currentSection,
Name = xmlReader.GetAttribute("name"),
- ID = xmlReader.GetAttribute("ID")
+ Id = xmlReader.GetAttribute("ID")
};
- if (page.ID == null || page.Name == null) {
+ if ((page.Id == null) || (page.Name == null))
+ {
continue;
}
page.IsCurrentlyViewed = "true".Equals(xmlReader.GetAttribute("isCurrentlyViewed"));
pages.Add(page);
}
}
- } finally
+ }
+ finally
{
- reader?.Dispose();
+ if (reader != null)
+ {
+ reader.Dispose();
+ }
}
}
}
- } catch (COMException cEx) {
- if (cEx.ErrorCode == unchecked((int)0x8002801D)) {
- Log.Warn("Wrong registry keys, to solve this remove the OneNote key as described here: http://microsoftmercenary.com/wp/outlook-excel-interop-calls-breaking-solved/");
- }
- Log.Warn("Problem retrieving onenote destinations, ignoring: ", cEx);
- } catch (Exception ex) {
- Log.Warn("Problem retrieving onenote destinations, ignoring: ", ex);
- }
- pages.Sort(delegate(OneNotePage p1, OneNotePage p2) {
- if(p1.IsCurrentlyViewed || p2.IsCurrentlyViewed) {
- return p2.IsCurrentlyViewed.CompareTo(p1.IsCurrentlyViewed);
- }
- return string.Compare(p1.DisplayName, p2.DisplayName, StringComparison.Ordinal);
- });
- return pages;
- }
- }
-}
+ }
+ catch (COMException cEx)
+ {
+ if (cEx.ErrorCode == unchecked((int)0x8002801D))
+ {
+ LOG.Warn("Wrong registry keys, to solve this remove the OneNote key as described here: http://microsoftmercenary.com/wp/outlook-excel-interop-calls-breaking-solved/");
+ }
+ LOG.Warn("Problem retrieving onenote destinations, ignoring: ", cEx);
+ }
+ catch (Exception ex)
+ {
+ LOG.Warn("Problem retrieving onenote destinations, ignoring: ", ex);
+ }
+ pages.Sort((page1, page2) =>
+ {
+ if (page1.IsCurrentlyViewed || page2.IsCurrentlyViewed)
+ {
+ return page2.IsCurrentlyViewed.CompareTo(page1.IsCurrentlyViewed);
+ }
+ return string.Compare(page1.DisplayName, page2.DisplayName, StringComparison.Ordinal);
+ });
+ return pages;
+ }
+
+ ///
+ /// Retrieve the Section ID for the specified special location
+ ///
+ ///
+ /// SpecialLocation
+ /// string with section ID
+ private string GetSectionId(IDisposableCom oneNoteApplication, SpecialLocation specialLocation)
+ {
+ if (oneNoteApplication == null)
+ {
+ return null;
+ }
+ // ReSharper disable once RedundantAssignment
+ string unfiledNotesPath = "";
+ oneNoteApplication.ComObject.GetSpecialLocation(specialLocation, out unfiledNotesPath);
+
+ // ReSharper disable once RedundantAssignment
+ string notebookXml = "";
+ oneNoteApplication.ComObject.GetHierarchy("", HierarchyScope.hsPages, out notebookXml, XMLSchema.xs2010);
+ if (!string.IsNullOrEmpty(notebookXml))
+ {
+ LOG.Debug(notebookXml);
+ StringReader reader = null;
+ try
+ {
+ reader = new StringReader(notebookXml);
+ using var xmlReader = new XmlTextReader(reader);
+ while (xmlReader.Read())
+ {
+ if (!"one:Section".Equals(xmlReader.Name))
+ {
+ continue;
+ }
+ string id = xmlReader.GetAttribute("ID");
+ string path = xmlReader.GetAttribute("path");
+ if (unfiledNotesPath.Equals(path))
+ {
+ return id;
+ }
+ }
+ }
+ finally
+ {
+ if (reader != null)
+ {
+ reader.Dispose();
+ }
+ }
+ }
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs b/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs
index 9c0b51f1f..a0d0f54e0 100644
--- a/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs
+++ b/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs
@@ -1,417 +1,484 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// Greenshot - a free and open source screenshot tool
+// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
+//
+// For more information see: http://getgreenshot.org/
+// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 1 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
+using GreenshotOfficePlugin.Com;
using GreenshotOfficePlugin.OfficeInterop;
-using GreenshotOfficePlugin.OfficeInterop.Outlook;
-using GreenshotOfficePlugin.OfficeInterop.Word;
-using GreenshotPlugin.IEInterop;
using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interop;
+using Microsoft.Office.Interop.Outlook;
+using Microsoft.Office.Interop.Word;
using Microsoft.Win32;
+using mshtml;
+using Application = Microsoft.Office.Interop.Outlook.Application;
+using Exception = System.Exception;
+using Version = System.Version;
-namespace GreenshotOfficePlugin.OfficeExport {
- ///
- /// Outlook exporter has all the functionality to export to outlook
- ///
- public class OutlookEmailExporter {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(OutlookEmailExporter));
- private static readonly OfficeConfiguration OfficeConfig = IniConfig.GetIniSection();
- private static readonly string SignaturePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Microsoft\Signatures");
- private static Version _outlookVersion;
- private static string _currentUser;
+namespace GreenshotOfficePlugin.OfficeExport
+{
+ ///
+ /// Outlook exporter has all the functionality to export to outlook
+ ///
+ public class OutlookEmailExporter
+ {
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OutlookEmailExporter));
+ private static readonly OfficeConfiguration _officeConfiguration = IniConfig.GetIniSection();
- // The signature key can be found at:
- // HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\\9375CFF0413111d3B88A00104B2A6676\ [New Signature]
- private const string ProfilesKey = @"Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\";
- private const string AccountKey = "9375CFF0413111d3B88A00104B2A6676";
- private const string NewSignatureValue = "New Signature";
- private const string DefaultProfileValue = "DefaultProfile";
+ // The signature key can be found at:
+ // HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\\9375CFF0413111d3B88A00104B2A6676\ [New Signature]
+ private const string ProfilesKey = @"Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\";
+ private const string AccountKey = "9375CFF0413111d3B88A00104B2A6676";
+ private const string NewSignatureValue = "New Signature";
+ private const string DefaultProfileValue = "DefaultProfile";
+ // Schema definitions for the MAPI properties, see: http://msdn.microsoft.com/en-us/library/aa454438.aspx and: http://msdn.microsoft.com/en-us/library/bb446117.aspx
+ private const string AttachmentContentId = @"http://schemas.microsoft.com/mapi/proptag/0x3712001E";
- ///
- /// A method to retrieve all inspectors which can act as an export target
- ///
- /// List of strings with inspector captions (window title)
- public static IDictionary RetrievePossibleTargets() {
- IDictionary inspectorCaptions = new SortedDictionary();
- try
+ private static readonly string SignaturePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Microsoft\Signatures");
+ private static Version _outlookVersion;
+ private static string _currentUser;
+ private readonly WordExporter _wordExporter = new WordExporter();
+
+ ///
+ /// Export the image stored in tmpFile to the Inspector with the caption
+ ///
+ /// Caption of the inspector
+ /// Path to image file
+ /// name of the attachment (used as the tooltip of the image)
+ /// true if it worked
+ public bool ExportToInspector(string inspectorCaption, string tmpFile, string attachmentName)
+ {
+ using (var outlookApplication = GetOrCreateOutlookApplication())
{
- using IOutlookApplication outlookApplication = GetOutlookApplication();
- if (outlookApplication == null) {
- return null;
- }
-
- if (_outlookVersion.Major >= (int)OfficeVersion.OFFICE_2013)
+ if (outlookApplication == null)
{
- // Check inline "panel" for Outlook 2013
- using var activeExplorer = outlookApplication.ActiveExplorer();
- if (activeExplorer != null)
- {
- using var inlineResponse = activeExplorer.ActiveInlineResponse;
- if (CanExportToInspector(inlineResponse)) {
- OlObjectClass currentItemClass = inlineResponse.Class;
- inspectorCaptions.Add(activeExplorer.Caption, currentItemClass);
- }
- }
- }
-
- using IInspectors inspectors = outlookApplication.Inspectors;
- if (inspectors != null && inspectors.Count > 0) {
- for (int i = 1; i <= inspectors.Count; i++)
- {
- using IInspector inspector = outlookApplication.Inspectors[i];
- using IItem currentItem = inspector.CurrentItem;
- if (CanExportToInspector(currentItem)) {
- OlObjectClass currentItemClass = currentItem.Class;
- inspectorCaptions.Add(inspector.Caption, currentItemClass);
- }
- }
- }
- } catch (Exception ex) {
- Log.Warn("Problem retrieving word destinations, ignoring: ", ex);
- }
- return inspectorCaptions;
- }
-
- ///
- /// Return true if we can export to the supplied inspector
- ///
- /// the Item to check
- ///
- private static bool CanExportToInspector(IItem currentItem) {
- try {
- if (currentItem != null) {
- OlObjectClass currentItemClass = currentItem.Class;
- if (OlObjectClass.olMail.Equals(currentItemClass)) {
- MailItem mailItem = (MailItem)currentItem;
- //MailItem mailItem = COMWrapper.Cast(currentItem);
- Log.DebugFormat("Mail sent: {0}", mailItem.Sent);
- if (!mailItem.Sent) {
- return true;
- }
- } else if (_outlookVersion.Major >= (int)OfficeVersion.OFFICE_2010 && OfficeConfig.OutlookAllowExportInMeetings && OlObjectClass.olAppointment.Equals(currentItemClass)) {
- //AppointmentItem appointmentItem = COMWrapper.Cast(currentItem);
- AppointmentItem appointmentItem = (AppointmentItem)currentItem;
- if (string.IsNullOrEmpty(appointmentItem.Organizer) || (_currentUser != null && _currentUser.Equals(appointmentItem.Organizer))) {
- return true;
- }
- Log.DebugFormat("Not exporting, as organizer is {0} and currentuser {1}", appointmentItem.Organizer, _currentUser);
- }
- }
- } catch (Exception ex) {
- Log.WarnFormat("Couldn't process item due to: {0}", ex.Message);
- }
- return false;
- }
-
-
- ///
- /// Export the image stored in tmpFile to the Inspector with the caption
- ///
- /// Caption of the inspector
- /// Path to image file
- /// name of the attachment (used as the tooltip of the image)
- /// true if it worked
- public static bool ExportToInspector(string inspectorCaption, string tmpFile, string attachmentName) {
- using (IOutlookApplication outlookApplication = GetOrCreateOutlookApplication()) {
- if (outlookApplication == null) {
- return false;
- }
- if (_outlookVersion.Major >= (int)OfficeVersion.OFFICE_2013)
- {
- // Check inline "panel" for Outlook 2013
- using var activeExplorer = outlookApplication.ActiveExplorer();
- if (activeExplorer == null) {
- return false;
- }
- var currentCaption = activeExplorer.Caption;
- if (currentCaption.StartsWith(inspectorCaption))
- {
- using var inlineResponse = activeExplorer.ActiveInlineResponse;
- using IItem currentItem = activeExplorer.ActiveInlineResponse;
- if (CanExportToInspector(inlineResponse)) {
- try {
- return ExportToInspector(activeExplorer, currentItem, tmpFile, attachmentName);
- } catch (Exception exExport) {
- Log.Error("Export to " + currentCaption + " failed.", exExport);
- }
- }
- }
- }
-
- using IInspectors inspectors = outlookApplication.Inspectors;
- if (inspectors == null || inspectors.Count == 0) {
return false;
}
- Log.DebugFormat("Got {0} inspectors to check", inspectors.Count);
- for (int i = 1; i <= inspectors.Count; i++)
+
+ // The activeexplorer inline response only works with >= 2013, Microsoft Outlook 15.0 Object Library
+ if (_outlookVersion.Major >= (int)OfficeVersions.Office2013)
{
- using IInspector inspector = outlookApplication.Inspectors[i];
- string currentCaption = inspector.Caption;
- if (currentCaption.StartsWith(inspectorCaption))
+ // Check inline "panel" for Outlook 2013
+ using var activeExplorer = DisposableCom.Create((_Explorer)outlookApplication.ComObject.ActiveExplorer());
+ // Only if we have one and if the capture is the one we selected
+ if ((activeExplorer != null) && activeExplorer.ComObject.Caption.StartsWith(inspectorCaption))
{
- using IItem currentItem = inspector.CurrentItem;
- if (CanExportToInspector(currentItem)) {
- try {
- return ExportToInspector(inspector, currentItem, tmpFile, attachmentName);
- } catch (Exception exExport) {
- Log.Error("Export to " + currentCaption + " failed.", exExport);
+ var untypedInlineResponse = activeExplorer.ComObject.ActiveInlineResponse;
+ using (DisposableCom.Create(untypedInlineResponse))
+ {
+ switch (untypedInlineResponse)
+ {
+ case MailItem mailItem:
+ if (!mailItem.Sent)
+ {
+ return ExportToInspector(null, activeExplorer, mailItem.Class, mailItem, tmpFile, attachmentName);
+ }
+ break;
+ case AppointmentItem appointmentItem:
+ if ((_outlookVersion.Major >= (int)OfficeVersions.Office2010) && _officeConfiguration.OutlookAllowExportInMeetings)
+ {
+ if (!string.IsNullOrEmpty(appointmentItem.Organizer) && appointmentItem.Organizer.Equals(_currentUser))
+ {
+ return ExportToInspector(null, activeExplorer, appointmentItem.Class, null, tmpFile, attachmentName);
+ }
+ }
+ break;
}
}
}
}
+
+ using var inspectors = DisposableCom.Create(outlookApplication.ComObject.Inspectors);
+ if ((inspectors == null) || (inspectors.ComObject.Count == 0))
+ {
+ return false;
+ }
+ LOG.DebugFormat("Got {0} inspectors to check", inspectors.ComObject.Count);
+ for (int i = 1; i <= inspectors.ComObject.Count; i++)
+ {
+ using var inspector = DisposableCom.Create((_Inspector)inspectors.ComObject[i]);
+ string currentCaption = inspector.ComObject.Caption;
+ if (!currentCaption.StartsWith(inspectorCaption))
+ {
+ continue;
+ }
+
+ var currentItemUntyped = inspector.ComObject.CurrentItem;
+ using (DisposableCom.Create(currentItemUntyped))
+ {
+ switch (currentItemUntyped)
+ {
+ case MailItem mailItem:
+ if (mailItem.Sent)
+ {
+ continue;
+ }
+ try
+ {
+ return ExportToInspector(inspector, null, mailItem.Class, mailItem, tmpFile, attachmentName);
+ }
+ catch (Exception exExport)
+ {
+ LOG.Error($"Export to {currentCaption} failed.", exExport);
+ }
+ break;
+ case AppointmentItem appointmentItem:
+ if ((_outlookVersion.Major >= (int)OfficeVersions.Office2010) && _officeConfiguration.OutlookAllowExportInMeetings)
+ {
+ if (!string.IsNullOrEmpty(appointmentItem.Organizer) && !appointmentItem.Organizer.Equals(_currentUser))
+ {
+ LOG.DebugFormat("Not exporting, as organizer is set to {0} and currentuser {1} is not him.", appointmentItem.Organizer, _currentUser);
+ continue;
+ }
+ }
+ else
+ {
+ // skip, can't export to olAppointment
+ continue;
+ }
+ try
+ {
+ return ExportToInspector(inspector, null, appointmentItem.Class, null, tmpFile, attachmentName);
+ }
+ catch (Exception exExport)
+ {
+ LOG.Error($"Export to {currentCaption} failed.", exExport);
+ }
+ break;
+ default:
+ continue;
+ }
+ }
+ }
}
- return false;
- }
+ return false;
+ }
- ///
- /// Export the file to the supplied inspector
- ///
- /// ICommonExplorer
- /// Item
- ///
- ///
- ///
- private static bool ExportToInspector(ICommonExplorer inspectorOrExplorer, IItem currentItem, string tmpFile, string attachmentName) {
- if (currentItem == null) {
- Log.Warn("No current item.");
- return false;
- }
- OlObjectClass itemClass = currentItem.Class;
- bool isMail = OlObjectClass.olMail.Equals(itemClass);
- bool isAppointment = OlObjectClass.olAppointment.Equals(itemClass);
- if (!isMail && !isAppointment) {
- Log.Warn("Item is no mail or appointment.");
- return false;
- }
- MailItem mailItem = null;
- try {
- if (isMail) {
- //mailItem = COMWrapper.Cast(currentItem);
- mailItem = (MailItem)currentItem;
- if (mailItem.Sent) {
- Log.WarnFormat("Item already sent, can't export to {0}", currentItem.Subject);
- return false;
- }
- }
+ ///
+ /// Export the file to the supplied inspector
+ ///
+ /// Inspector
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private bool ExportToInspector(IDisposableCom<_Inspector> inspector, IDisposableCom<_Explorer> explorer, OlObjectClass itemClass, MailItem mailItem, string tmpFile, string attachmentName)
+ {
+ bool isMail = OlObjectClass.olMail.Equals(itemClass);
+ bool isAppointment = OlObjectClass.olAppointment.Equals(itemClass);
+ if (!isMail && !isAppointment)
+ {
+ LOG.Warn("Item is no mail or appointment.");
+ return false;
+ }
+ try
+ {
+ // Make sure the inspector is activated, only this way the word editor is active!
+ // This also ensures that the window is visible!
+ inspector?.ComObject.Activate();
+ bool isTextFormat = false;
+ if (isMail)
+ {
+ isTextFormat = OlBodyFormat.olFormatPlain.Equals(mailItem.BodyFormat);
+ }
+ if (isAppointment || !isTextFormat)
+ {
+ // Check for wordmail, if so use the wordexporter
+ // http://msdn.microsoft.com/en-us/library/dd492012%28v=office.12%29.aspx
+ // Earlier versions of Outlook also supported an Inspector.HTMLEditor object property, but since Internet Explorer is no longer the rendering engine for HTML messages and posts, HTMLEditor is no longer supported.
+ IDisposableCom<_Document> wordDocument = null;
+ if ((explorer != null) && (_outlookVersion.Major >= (int)OfficeVersions.Office2013))
+ {
+ // TODO: Needs to have the Microsoft Outlook 15.0 Object Library installed
+ wordDocument = DisposableCom.Create((_Document)explorer.ComObject.ActiveInlineResponseWordEditor);
+ }
+ else if (inspector != null)
+ {
+ if (inspector.ComObject.IsWordMail() && (inspector.ComObject.EditorType == OlEditorType.olEditorWord))
+ {
+ var tmpWordDocument = (_Document)inspector.ComObject.WordEditor;
+ wordDocument = DisposableCom.Create(tmpWordDocument);
+ }
+ }
+ if (wordDocument != null)
+ {
+ using (wordDocument)
+ {
+ using var application = DisposableCom.Create(wordDocument.ComObject.Application);
+ try
+ {
+ if (_wordExporter.InsertIntoExistingDocument(application, wordDocument, tmpFile, null, null))
+ {
+ LOG.Info("Inserted into Wordmail");
+ return true;
+ }
+ }
+ catch (Exception exportException)
+ {
+ LOG.Error("Error exporting to the word editor, trying to do it via another method", exportException);
+ }
+ }
+ }
+ else if (isAppointment)
+ {
+ LOG.Info("Can't export to an appointment if no word editor is used");
+ return false;
+ }
+ else
+ {
+ LOG.Info("Trying export for outlook < 2007.");
+ }
+ }
+ // Only use mailitem as it should be filled!!
+ if (mailItem != null)
+ {
+ LOG.InfoFormat("Item '{0}' has format: {1}", mailItem.Subject, mailItem.BodyFormat);
+ }
- // Make sure the inspector is activated, only this way the word editor is active!
- // This also ensures that the window is visible!
- inspectorOrExplorer.Activate();
- bool isTextFormat = false;
- if (isMail) {
- isTextFormat = OlBodyFormat.olFormatPlain.Equals(mailItem.BodyFormat);
- }
- if (isAppointment || !isTextFormat) {
- // Check for wordmail, if so use the wordexporter
- // http://msdn.microsoft.com/en-us/library/dd492012%28v=office.12%29.aspx
- // Earlier versions of Outlook also supported an Inspector.HTMLEditor object property, but since Internet Explorer is no longer the rendering engine for HTML messages and posts, HTMLEditor is no longer supported.
- IWordDocument wordDocument = null;
- if (inspectorOrExplorer is IExplorer explorer) {
- wordDocument = explorer.ActiveInlineResponseWordEditor;
- }
- else
- {
- if (inspectorOrExplorer is IInspector inspector1) {
- var inspector = inspector1;
- if (inspector.IsWordMail()) {
- wordDocument = inspector.WordEditor;
- }
- }
- }
- if (wordDocument != null) {
- try {
- if (WordExporter.InsertIntoExistingDocument(wordDocument.Application, wordDocument, tmpFile, null, null)) {
- Log.Info("Inserted into Wordmail");
- wordDocument.Dispose();
- return true;
- }
- } catch (Exception exportException) {
- Log.Error("Error exporting to the word editor, trying to do it via another method", exportException);
- }
- } else if (isAppointment) {
- Log.Info("Can't export to an appointment if no word editor is used");
- return false;
- } else {
- Log.Info("Trying export for outlook < 2007.");
- }
- }
- // Only use mailitem as it should be filled!!
- Log.InfoFormat("Item '{0}' has format: {1}", mailItem?.Subject, mailItem?.BodyFormat);
+ string contentId;
+ if (_outlookVersion.Major >= (int)OfficeVersions.Office2007)
+ {
+ contentId = Guid.NewGuid().ToString();
+ }
+ else
+ {
+ LOG.Info("Older Outlook (<2007) found, using filename as contentid.");
+ contentId = Path.GetFileName(tmpFile);
+ }
- string contentId;
- if (_outlookVersion.Major >= (int)OfficeVersion.OFFICE_2007) {
- contentId = Guid.NewGuid().ToString();
- } else {
- Log.Info("Older Outlook (<2007) found, using filename as contentid.");
- contentId = Path.GetFileName(tmpFile);
- }
+ // Use this to change the format, it will probably lose the current selection.
+ //if (!OlBodyFormat.olFormatHTML.Equals(currentMail.BodyFormat)) {
+ // Log.Info().WriteLine("Changing format to HTML.");
+ // currentMail.BodyFormat = OlBodyFormat.olFormatHTML;
+ //}
- // Use this to change the format, it will probably lose the current selection.
- //if (!OlBodyFormat.olFormatHTML.Equals(currentMail.BodyFormat)) {
- // LOG.Info("Changing format to HTML.");
- // currentMail.BodyFormat = OlBodyFormat.olFormatHTML;
- //}
+ bool inlinePossible = false;
+ if ((mailItem != null) && (inspector != null) && OlBodyFormat.olFormatHTML.Equals(mailItem.BodyFormat))
+ {
+ // if html we can try to inline it
+ // The following might cause a security popup... can't ignore it.
+ try
+ {
+ if (inspector.ComObject.HTMLEditor is IHTMLDocument2 document2)
+ {
+ var selection = document2.selection;
+ if (selection != null)
+ {
+ var range = (IHTMLTxtRange)selection.createRange();
+ if (range != null)
+ {
+ // First paste, than attach (otherwise the range is wrong!)
+ range.pasteHTML("

");
+ inlinePossible = true;
+ }
+ else
+ {
+ LOG.DebugFormat("No range for '{0}'", inspector.ComObject.Caption);
+ }
+ }
+ else
+ {
+ LOG.DebugFormat("No selection for '{0}'", inspector.ComObject.Caption);
+ }
+ }
+ else
+ {
+ LOG.DebugFormat("No HTML editor for '{0}'", inspector.ComObject.Caption);
+ }
+ }
+ catch (Exception e)
+ {
+ // Continue with non inline image
+ LOG.Warn("Error pasting HTML, most likely due to an ACCESS_DENIED as the user clicked no.", e);
+ }
+ }
- bool inlinePossible = false;
- if (inspectorOrExplorer is IInspector && OlBodyFormat.olFormatHTML.Equals(mailItem?.BodyFormat)) {
- // if html we can try to inline it
- // The following might cause a security popup... can't ignore it.
- try {
- if ((inspectorOrExplorer as IInspector).HTMLEditor is IHTMLDocument2 document2) {
- IHTMLSelectionObject selection = document2.selection;
- if (selection != null) {
- IHTMLTxtRange range = selection.createRange();
- if (range != null) {
- // First paste, than attach (otherwise the range is wrong!)
- range.pasteHTML("

");
- inlinePossible = true;
- } else {
- Log.DebugFormat("No range for '{0}'", inspectorOrExplorer.Caption);
- }
- } else {
- Log.DebugFormat("No selection for '{0}'", inspectorOrExplorer.Caption);
- }
- } else {
- Log.DebugFormat("No HTML editor for '{0}'", inspectorOrExplorer.Caption);
- }
- } catch (Exception e) {
- // Continue with non inline image
- Log.Warn("Error pasting HTML, most likely due to an ACCESS_DENIED as the user clicked no.", e);
- }
- }
-
- // Create the attachment (if inlined the attachment isn't visible as attachment!)
- using IAttachment attachment = mailItem.Attachments.Add(tmpFile, OlAttachmentType.olByValue, inlinePossible ? 0 : 1, attachmentName);
- if (_outlookVersion.Major >= (int)OfficeVersion.OFFICE_2007) {
+ // Create the attachment (if inlined the attachment isn't visible as attachment!)
+ using var attachments = DisposableCom.Create(mailItem.Attachments);
+ using var attachment = DisposableCom.Create(attachments.ComObject.Add(tmpFile, OlAttachmentType.olByValue, inlinePossible ? 0 : 1, attachmentName));
+ if (_outlookVersion.Major >= (int)OfficeVersions.Office2007)
+ {
// Add the content id to the attachment, this only works for Outlook >= 2007
- try {
- IPropertyAccessor propertyAccessor = attachment.PropertyAccessor;
- propertyAccessor.SetProperty(PropTag.ATTACHMENT_CONTENT_ID, contentId);
- } catch {
+ try
+ {
+ var propertyAccessor = attachment.ComObject.PropertyAccessor;
+ propertyAccessor.SetProperty(AttachmentContentId, contentId);
+ }
+ // ReSharper disable once EmptyGeneralCatchClause
+ catch
+ {
// Ignore
}
}
- } catch (Exception ex) {
- Log.WarnFormat("Problem while trying to add attachment to Item '{0}' : {1}", inspectorOrExplorer.Caption, ex);
- return false;
- }
- try {
- inspectorOrExplorer.Activate();
- } catch (Exception ex) {
- Log.Warn("Problem activating inspector/explorer: ", ex);
- return false;
- }
- Log.Debug("Finished!");
- return true;
- }
+ }
+ catch (Exception ex)
+ {
+ string caption = "n.a.";
+ if (inspector != null)
+ {
+ caption = inspector.ComObject.Caption;
+ }
+ else if (explorer != null)
+ {
+ caption = explorer.ComObject.Caption;
+ }
+ LOG.Warn($"Problem while trying to add attachment to Item '{caption}'", ex);
+ return false;
+ }
+ try
+ {
+ if (inspector != null)
+ {
+ inspector.ComObject.Activate();
+ }
+ else
+ {
+ explorer?.ComObject.Activate();
+ }
+ }
+ catch (Exception ex)
+ {
+ LOG.Warn("Problem activating inspector/explorer: ", ex);
+ return false;
+ }
+ LOG.Debug("Finished!");
+ return true;
+ }
- ///
- /// Export image to a new email
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- private static void ExportToNewEmail(IOutlookApplication outlookApplication, EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string cc, string bcc, string url)
+ ///
+ /// Export image to a new email
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void ExportToNewEmail(IDisposableCom outlookApplication, EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string cc, string bcc, string url)
{
- using IItem newItem = outlookApplication.CreateItem(OlItemType.olMailItem);
- if (newItem == null) {
+ using var newItem = DisposableCom.Create((MailItem)outlookApplication.ComObject.CreateItem(OlItemType.olMailItem));
+ if (newItem == null)
+ {
return;
}
- //MailItem newMail = COMWrapper.Cast(newItem);
- MailItem newMail = (MailItem)newItem;
+ var newMail = newItem.ComObject;
newMail.Subject = subject;
- if (!string.IsNullOrEmpty(to)) {
+ if (!string.IsNullOrEmpty(to))
+ {
newMail.To = to;
}
- if (!string.IsNullOrEmpty(cc)) {
+ if (!string.IsNullOrEmpty(cc))
+ {
newMail.CC = cc;
}
- if (!string.IsNullOrEmpty(bcc)) {
+ if (!string.IsNullOrEmpty(bcc))
+ {
newMail.BCC = bcc;
}
newMail.BodyFormat = OlBodyFormat.olFormatHTML;
string bodyString = null;
// Read the default signature, if nothing found use empty email
- try {
+ try
+ {
bodyString = GetOutlookSignature(format);
- } catch (Exception e) {
- Log.Error("Problem reading signature!", e);
}
- switch (format) {
+ catch (Exception e)
+ {
+ LOG.Error("Problem reading signature!", e);
+ }
+ switch (format)
+ {
case EmailFormat.Text:
// Create the attachment (and dispose the COM object after using)
- using (newMail.Attachments.Add(tmpFile, OlAttachmentType.olByValue, 1, attachmentName))
+ using (var attachments = DisposableCom.Create(newMail.Attachments))
{
- newMail.BodyFormat = OlBodyFormat.olFormatPlain;
- if (bodyString == null) {
- bodyString = string.Empty;
+ using (DisposableCom.Create(attachments.ComObject.Add(tmpFile, OlAttachmentType.olByValue, 1, attachmentName)))
+ {
+ newMail.BodyFormat = OlBodyFormat.olFormatPlain;
+ if (bodyString == null)
+ {
+ bodyString = "";
+ }
+ newMail.Body = bodyString;
}
- newMail.Body = bodyString;
}
break;
default:
string contentId = Path.GetFileName(tmpFile);
// Create the attachment (and dispose the COM object after using)
- using (IAttachment attachment = newMail.Attachments.Add(tmpFile, OlAttachmentType.olByValue, 0, attachmentName)) {
+ using (var attachments = DisposableCom.Create(newMail.Attachments))
+ {
+ using var attachment = DisposableCom.Create(attachments.ComObject.Add(tmpFile, OlAttachmentType.olByValue, 0, attachmentName));
// add content ID to the attachment
- if (_outlookVersion.Major >= (int)OfficeVersion.OFFICE_2007) {
- try {
+ if (_outlookVersion.Major >= (int)OfficeVersions.Office2007)
+ {
+ try
+ {
contentId = Guid.NewGuid().ToString();
- IPropertyAccessor propertyAccessor = attachment.PropertyAccessor;
- propertyAccessor.SetProperty(PropTag.ATTACHMENT_CONTENT_ID, contentId);
- } catch {
- Log.Info("Error working with the PropertyAccessor, using filename as contentid");
+ using var propertyAccessor = DisposableCom.Create(attachment.ComObject.PropertyAccessor);
+ propertyAccessor.ComObject.SetProperty(AttachmentContentId, contentId);
+ }
+ catch
+ {
+ LOG.Info("Error working with the PropertyAccessor, using filename as contentid");
contentId = Path.GetFileName(tmpFile);
}
}
}
newMail.BodyFormat = OlBodyFormat.olFormatHTML;
- string href = string.Empty;
- string hrefEnd = string.Empty;
- if (!string.IsNullOrEmpty(url)) {
+ string href = "";
+ string hrefEnd = "";
+ if (!string.IsNullOrEmpty(url))
+ {
href = $"";
hrefEnd = "";
}
string htmlImgEmbedded = $"
{href}
{hrefEnd}
";
string fallbackBody = $"{htmlImgEmbedded}";
- if (bodyString == null) {
+ if (bodyString == null)
+ {
bodyString = fallbackBody;
- } else {
+ }
+ else
+ {
int bodyIndex = bodyString.IndexOf("= 0)
{
bodyIndex = bodyString.IndexOf(">", bodyIndex, StringComparison.Ordinal) + 1;
- bodyString = bodyIndex >= 0 ? bodyString.Insert(bodyIndex, htmlImgEmbedded) : fallbackBody;
- } else {
+ if (bodyIndex >= 0)
+ {
+ bodyString = bodyString.Insert(bodyIndex, htmlImgEmbedded);
+ }
+ else
+ {
+ bodyString = fallbackBody;
+ }
+ }
+ else
+ {
bodyString = fallbackBody;
}
}
@@ -421,139 +488,288 @@ namespace GreenshotOfficePlugin.OfficeExport {
// So not save, otherwise the email is always stored in Draft folder.. (newMail.Save();)
newMail.Display(false);
- using IInspector inspector = newMail.GetInspector();
- if (inspector != null) {
- try {
- inspector.Activate();
- } catch {
+ using var inspector = DisposableCom.Create((_Inspector)newMail.GetInspector);
+ if (inspector != null)
+ {
+ try
+ {
+ inspector.ComObject.Activate();
+ }
+ // ReSharper disable once EmptyGeneralCatchClause
+ catch
+ {
// Ignore
}
}
}
- ///
- /// Helper method to create an outlook mail item with attachment
- ///
- ///
- /// The file to send, do not delete the file right away!
- ///
- ///
- ///
- ///
- ///
- ///
- /// true if it worked, false if not
- public static bool ExportToOutlook(EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string cc, string bcc, string url) {
- bool exported = false;
- try {
- using (IOutlookApplication outlookApplication = GetOrCreateOutlookApplication()) {
- if (outlookApplication != null) {
- ExportToNewEmail(outlookApplication, format, tmpFile, subject, attachmentName, to, cc, bcc, url);
- exported = true;
- }
- }
- return exported;
- } catch (Exception e) {
- Log.Error("Error while creating an outlook mail item: ", e);
- }
- return exported;
- }
+ ///
+ /// Helper method to create an outlook mail item with attachment
+ ///
+ ///
+ /// The file to send, do not delete the file right away!
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// true if it worked, false if not
+ public bool ExportToOutlook(EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string cc, string bcc, string url)
+ {
+ bool exported = false;
+ try
+ {
+ using (var outlookApplication = GetOrCreateOutlookApplication())
+ {
+ if (outlookApplication != null)
+ {
+ ExportToNewEmail(outlookApplication, format, tmpFile, subject, attachmentName, to, cc, bcc, url);
+ exported = true;
+ }
+ }
+ return exported;
+ }
+ catch (Exception e)
+ {
+ LOG.Error("Error while creating an outlook mail item: ", e);
+ }
+ return exported;
+ }
- ///
- /// Helper method to get the Outlook signature
- ///
- ///
- private static string GetOutlookSignature(EmailFormat format) {
- using (RegistryKey profilesKey = Registry.CurrentUser.OpenSubKey(ProfilesKey, false)) {
- if (profilesKey == null) {
- return null;
- }
- string defaultProfile = (string)profilesKey.GetValue(DefaultProfileValue);
- Log.DebugFormat("defaultProfile={0}", defaultProfile);
- using RegistryKey profileKey = profilesKey.OpenSubKey(defaultProfile + @"\" + AccountKey, false);
+ ///
+ /// Call this to get the running Outlook application, or create a new instance
+ ///
+ /// IDisposableCom for Outlook.Application
+ private IDisposableCom GetOrCreateOutlookApplication()
+ {
+ var outlookApplication = GetOutlookApplication();
+ if (outlookApplication == null)
+ {
+ outlookApplication = DisposableCom.Create(new Application());
+ }
+ InitializeVariables(outlookApplication);
+ return outlookApplication;
+ }
+
+ ///
+ /// Call this to get the running Outlook application, returns null if there isn't any.
+ ///
+ /// IDisposableCom for Outlook.Application or null
+ private IDisposableCom GetOutlookApplication()
+ {
+ IDisposableCom outlookApplication;
+ try
+ {
+ outlookApplication = OleAut32Api.GetActiveObject("Outlook.Application");
+ }
+ catch (Exception)
+ {
+ // Ignore, probably no outlook running
+ return null;
+ }
+ if ((outlookApplication != null) && (outlookApplication.ComObject != null))
+ {
+ InitializeVariables(outlookApplication);
+ }
+ return outlookApplication;
+ }
+
+ ///
+ /// Helper method to get the Outlook signature
+ ///
+ ///
+ private string GetOutlookSignature(EmailFormat format)
+ {
+ using (var profilesKey = Registry.CurrentUser.OpenSubKey(ProfilesKey, false))
+ {
+ if (profilesKey == null)
+ {
+ return null;
+ }
+ string defaultProfile = (string)profilesKey.GetValue(DefaultProfileValue);
+ LOG.DebugFormat("defaultProfile={0}", defaultProfile);
+ using var profileKey = profilesKey.OpenSubKey(defaultProfile + @"\" + AccountKey, false);
if (profileKey != null)
{
string[] numbers = profileKey.GetSubKeyNames();
- foreach (string number in numbers) {
- Log.DebugFormat("Found subkey {0}", number);
- using RegistryKey numberKey = profileKey.OpenSubKey(number, false);
+ foreach (string number in numbers)
+ {
+ LOG.DebugFormat("Found subkey {0}", number);
+ using var numberKey = profileKey.OpenSubKey(number, false);
if (numberKey != null)
{
byte[] val = (byte[])numberKey.GetValue(NewSignatureValue);
- if (val == null) {
+ if (val == null)
+ {
continue;
}
- string signatureName = string.Empty;
- foreach (byte b in val) {
- if (b != 0) {
+ string signatureName = "";
+ foreach (byte b in val)
+ {
+ if (b != 0)
+ {
signatureName += (char)b;
}
}
- Log.DebugFormat("Found email signature: {0}", signatureName);
+ LOG.DebugFormat("Found email signature: {0}", signatureName);
var extension = format switch
{
EmailFormat.Text => ".txt",
_ => ".htm"
};
string signatureFile = Path.Combine(SignaturePath, signatureName + extension);
- if (File.Exists(signatureFile)) {
- Log.DebugFormat("Found email signature file: {0}", signatureFile);
+ if (File.Exists(signatureFile))
+ {
+ LOG.DebugFormat("Found email signature file: {0}", signatureFile);
return File.ReadAllText(signatureFile, Encoding.Default);
}
}
}
}
}
- return null;
- }
+ return null;
+ }
- ///
- /// Initialize static outlook variables like version and currentuser
- ///
- ///
- private static void InitializeVariables(IOutlookApplication outlookApplication) {
- if (outlookApplication == null || _outlookVersion != null) {
- return;
- }
- try {
- _outlookVersion = new Version(outlookApplication.Version);
- Log.InfoFormat("Using Outlook {0}", _outlookVersion);
- } catch (Exception exVersion) {
- Log.Error(exVersion);
- Log.Warn("Assuming outlook version 1997.");
- _outlookVersion = new Version((int)OfficeVersion.OFFICE_97, 0, 0, 0);
- }
- // Preventing retrieval of currentUser if Outlook is older than 2007
- if (_outlookVersion.Major >= (int)OfficeVersion.OFFICE_2007) {
- try {
- INameSpace mapiNamespace = outlookApplication.GetNameSpace("MAPI");
- _currentUser = mapiNamespace.CurrentUser.Name;
- Log.InfoFormat("Current user: {0}", _currentUser);
- } catch (Exception exNs) {
- Log.Error(exNs);
- }
- }
- }
- ///
- /// Call this to get the running outlook application, returns null if there isn't any.
- ///
- /// IOutlookApplication or null
- private static IOutlookApplication GetOutlookApplication() {
- IOutlookApplication outlookApplication = COMWrapper.GetInstance();
- InitializeVariables(outlookApplication);
- return outlookApplication;
- }
+ ///
+ /// Initialize static outlook variables like version and currentuser
+ ///
+ ///
+ private void InitializeVariables(IDisposableCom outlookApplication)
+ {
+ if ((outlookApplication == null) || (outlookApplication.ComObject == null) || (_outlookVersion != null))
+ {
+ return;
+ }
+ if (!Version.TryParse(outlookApplication.ComObject.Version, out _outlookVersion))
+ {
+ LOG.Warn("Assuming outlook version 1997.");
+ _outlookVersion = new Version((int)OfficeVersions.Office97, 0, 0, 0);
+ }
+ // Preventing retrieval of currentUser if Outlook is older than 2007
+ if (_outlookVersion.Major >= (int)OfficeVersions.Office2007)
+ {
+ try
+ {
+ using (var mapiNamespace = DisposableCom.Create(outlookApplication.ComObject.GetNamespace("MAPI")))
+ {
+ using var currentUser = DisposableCom.Create(mapiNamespace.ComObject.CurrentUser);
+ _currentUser = currentUser.ComObject.Name;
+ }
+ LOG.InfoFormat("Current user: {0}", _currentUser);
+ }
+ catch (Exception exNs)
+ {
+ LOG.Error("Reading Outlook currentuser failed", exNs);
+ }
+ }
+ }
- ///
- /// Call this to get the running outlook application, or create a new instance
- ///
- /// IOutlookApplication
- private static IOutlookApplication GetOrCreateOutlookApplication() {
- IOutlookApplication outlookApplication = COMWrapper.GetOrCreateInstance();
- InitializeVariables(outlookApplication);
- return outlookApplication;
- }
- }
+ ///
+ /// A method to retrieve all inspectors which can act as an export target
+ ///
+ /// IDictionary with inspector captions (window title) and object class
+ public IDictionary RetrievePossibleTargets()
+ {
+ IDictionary inspectorCaptions = new SortedDictionary();
+ try
+ {
+ using var outlookApplication = GetOutlookApplication();
+ if (outlookApplication == null)
+ {
+ return inspectorCaptions;
+ }
-}
+ // The activeexplorer inline response only works with >= 2013, Microsoft Outlook 15.0 Object Library
+ if (_outlookVersion.Major >= (int)OfficeVersions.Office2013)
+ {
+ // Check inline "panel" for Outlook 2013
+ using var activeExplorer = DisposableCom.Create(outlookApplication.ComObject.ActiveExplorer());
+ if (activeExplorer != null)
+ {
+ var untypedInlineResponse = activeExplorer.ComObject.ActiveInlineResponse;
+ if (untypedInlineResponse != null)
+ {
+ string caption = activeExplorer.ComObject.Caption;
+ using (DisposableCom.Create(untypedInlineResponse))
+ {
+ switch (untypedInlineResponse)
+ {
+ case MailItem mailItem:
+ if (!mailItem.Sent)
+ {
+ inspectorCaptions.Add(caption, mailItem.Class);
+ }
+ break;
+ case AppointmentItem appointmentItem:
+ if ((_outlookVersion.Major >= (int)OfficeVersions.Office2010) && _officeConfiguration.OutlookAllowExportInMeetings)
+ {
+ if (!string.IsNullOrEmpty(appointmentItem.Organizer) && appointmentItem.Organizer.Equals(_currentUser))
+ {
+ inspectorCaptions.Add(caption, appointmentItem.Class);
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ using var inspectors = DisposableCom.Create(outlookApplication.ComObject.Inspectors);
+ if ((inspectors != null) && (inspectors.ComObject.Count > 0))
+ {
+ for (int i = 1; i <= inspectors.ComObject.Count; i++)
+ {
+ using var inspector = DisposableCom.Create(inspectors.ComObject[i]);
+ string caption = inspector.ComObject.Caption;
+ // Fix double entries in the directory, TODO: store on something uniq
+ if (inspectorCaptions.ContainsKey(caption))
+ {
+ continue;
+ }
+
+ var currentItemUntyped = inspector.ComObject.CurrentItem;
+ using (DisposableCom.Create(currentItemUntyped))
+ {
+ switch (currentItemUntyped)
+ {
+ case MailItem mailItem:
+ if (mailItem.Sent)
+ {
+ continue;
+ }
+ inspectorCaptions.Add(caption, mailItem.Class);
+ break;
+ case AppointmentItem appointmentItem:
+ if ((_outlookVersion.Major >= (int)OfficeVersions.Office2010) && _officeConfiguration.OutlookAllowExportInMeetings)
+ {
+ if (!string.IsNullOrEmpty(appointmentItem.Organizer) && !appointmentItem.Organizer.Equals(_currentUser))
+ {
+ LOG.DebugFormat("Not exporting, as organizer is set to {0} and currentuser {1} is not him.", appointmentItem.Organizer, _currentUser);
+ continue;
+ }
+ }
+ else
+ {
+ // skip, can't export to olAppointment
+ continue;
+ }
+ inspectorCaptions.Add(caption, appointmentItem.Class);
+ break;
+ default:
+ continue;
+ }
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LOG.Warn("Problem retrieving word destinations, ignoring: ", ex);
+ }
+ return inspectorCaptions;
+ }
+ }
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeExport/PowerpointExporter.cs b/GreenshotOfficePlugin/OfficeExport/PowerpointExporter.cs
index e749ec846..237fea1f9 100644
--- a/GreenshotOfficePlugin/OfficeExport/PowerpointExporter.cs
+++ b/GreenshotOfficePlugin/OfficeExport/PowerpointExporter.cs
@@ -1,255 +1,344 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// Greenshot - a free and open source screenshot tool
+// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
+//
+// For more information see: http://getgreenshot.org/
+// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 1 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
using System;
using System.Collections.Generic;
using System.Drawing;
+using GreenshotOfficePlugin.Com;
using GreenshotOfficePlugin.OfficeInterop;
-using GreenshotOfficePlugin.OfficeInterop.Outlook;
-using GreenshotOfficePlugin.OfficeInterop.Powerpoint;
using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interop;
+using Microsoft.Office.Core;
+using Microsoft.Office.Interop.PowerPoint;
+using Shape = Microsoft.Office.Interop.PowerPoint.Shape;
-namespace GreenshotOfficePlugin.OfficeExport {
- public class PowerpointExporter {
- private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PowerpointExporter));
- private static Version _powerpointVersion;
- private static readonly OfficeConfiguration officeConfiguration = IniConfig.GetIniSection();
+namespace GreenshotOfficePlugin.OfficeExport
+{
+ ///
+ /// Export logic for powerpoint
+ ///
+ public class PowerpointExporter
+ {
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PowerpointExporter));
+ private static readonly OfficeConfiguration _officeConfiguration = IniConfig.GetIniSection();
- private static bool IsAfter2003() {
- return _powerpointVersion.Major > (int)OfficeVersion.OFFICE_2003;
- }
+ private Version _powerpointVersion;
- ///
- /// Get the captions of all the open powerpoint presentations
- ///
- ///
- public static List GetPowerpointPresentations() {
- List foundPresentations = new List();
- try
+ ///
+ /// Internal method to add a picture to a presentation
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void AddPictureToPresentation(IDisposableCom presentation, string tmpFile, Size imageSize, string title)
+ {
+ if (presentation != null)
{
- using IPowerpointApplication powerpointApplication = GetPowerpointApplication();
- if (powerpointApplication == null) {
- return foundPresentations;
- }
-
- using IPresentations presentations = powerpointApplication.Presentations;
- LOG.DebugFormat("Open Presentations: {0}", presentations.Count);
- for (int i = 1; i <= presentations.Count; i++)
+ //ISlide slide = presentation.Slides.AddSlide( presentation.Slides.Count + 1, PPSlideLayout.ppLayoutPictureWithCaption);
+ IDisposableCom slide = null;
+ try
{
- using IPresentation presentation = presentations.item(i);
- if (presentation == null) {
- continue;
+ float left, top;
+ using (var pageSetup = DisposableCom.Create(presentation.ComObject.PageSetup))
+ {
+ left = pageSetup.ComObject.SlideWidth / 2 - imageSize.Width / 2f;
+ top = pageSetup.ComObject.SlideHeight / 2 - imageSize.Height / 2f;
}
- if (presentation.ReadOnly == MsoTriState.msoTrue) {
- continue;
+ float width = imageSize.Width;
+ float height = imageSize.Height;
+ IDisposableCom shapeForCaption = null;
+ bool hasScaledWidth = false;
+ bool hasScaledHeight = false;
+ try
+ {
+ using (var slides = DisposableCom.Create(presentation.ComObject.Slides))
+ {
+ slide = DisposableCom.Create(slides.ComObject.Add(slides.ComObject.Count + 1, _officeConfiguration.PowerpointSlideLayout));
+ }
+
+ using var shapes = DisposableCom.Create(slide.ComObject.Shapes);
+ using var shapeForLocation = DisposableCom.Create(shapes.ComObject[2]);
+ // Shapes[2] is the image shape on this layout.
+ shapeForCaption = DisposableCom.Create(shapes.ComObject[1]);
+ if (width > shapeForLocation.ComObject.Width)
+ {
+ width = shapeForLocation.ComObject.Width;
+ left = shapeForLocation.ComObject.Left;
+ hasScaledWidth = true;
+ }
+ else
+ {
+ shapeForLocation.ComObject.Left = left;
+ }
+ shapeForLocation.ComObject.Width = imageSize.Width;
+
+ if (height > shapeForLocation.ComObject.Height)
+ {
+ height = shapeForLocation.ComObject.Height;
+ top = shapeForLocation.ComObject.Top;
+ hasScaledHeight = true;
+ }
+ else
+ {
+ top = shapeForLocation.ComObject.Top + shapeForLocation.ComObject.Height / 2 - imageSize.Height / 2f;
+ }
+ shapeForLocation.ComObject.Height = imageSize.Height;
}
- if (IsAfter2003()) {
- if (presentation.Final) {
- continue;
+ catch (Exception e)
+ {
+ LOG.Error("Powerpoint shape creating failed", e);
+ using var slides = DisposableCom.Create(presentation.ComObject.Slides);
+ slide = DisposableCom.Create(slides.ComObject.Add(slides.ComObject.Count + 1, PpSlideLayout.ppLayoutBlank));
+ }
+ using (var shapes = DisposableCom.Create(slide.ComObject.Shapes))
+ {
+ using var shape = DisposableCom.Create(shapes.ComObject.AddPicture(tmpFile, MsoTriState.msoFalse, MsoTriState.msoTrue, 0, 0, width, height));
+ if (_officeConfiguration.PowerpointLockAspectRatio)
+ {
+ shape.ComObject.LockAspectRatio = MsoTriState.msoTrue;
+ }
+ else
+ {
+ shape.ComObject.LockAspectRatio = MsoTriState.msoFalse;
+ }
+ shape.ComObject.ScaleHeight(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromMiddle);
+ shape.ComObject.ScaleWidth(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromMiddle);
+ if (hasScaledWidth)
+ {
+ shape.ComObject.Width = width;
+ }
+ if (hasScaledHeight)
+ {
+ shape.ComObject.Height = height;
+ }
+ shape.ComObject.Left = left;
+ shape.ComObject.Top = top;
+ shape.ComObject.AlternativeText = title;
+ }
+ if (shapeForCaption != null)
+ {
+ try
+ {
+ using (shapeForCaption)
+ {
+ // Using try/catch to make sure problems with the text range don't give an exception.
+ using var textFrame = DisposableCom.Create(shapeForCaption.ComObject.TextFrame);
+ using var textRange = DisposableCom.Create(textFrame.ComObject.TextRange);
+ textRange.ComObject.Text = title;
+ }
+ }
+ catch (Exception ex)
+ {
+ LOG.Warn("Problem setting the title to a text-range", ex);
}
}
- foundPresentations.Add(presentation.Name);
+ // Activate/Goto the slide
+ try
+ {
+ using var application = DisposableCom.Create(presentation.ComObject.Application);
+ using var activeWindow = DisposableCom.Create(application.ComObject.ActiveWindow);
+ using var view = DisposableCom.Create(activeWindow.ComObject.View);
+ view.ComObject.GotoSlide(slide.ComObject.SlideNumber);
+ }
+ catch (Exception ex)
+ {
+ LOG.Warn("Problem going to the slide", ex);
+ }
}
- } catch (Exception ex) {
- LOG.Warn("Problem retrieving word destinations, ignoring: ", ex);
- }
- foundPresentations.Sort();
- return foundPresentations;
- }
-
- ///
- /// Export the image from the tmpfile to the presentation with the supplied name
- ///
- /// Name of the presentation to insert to
- /// Filename of the image file to insert
- /// Size of the image
- /// A string with the image title
- ///
- public static bool ExportToPresentation(string presentationName, string tmpFile, Size imageSize, string title) {
- using (IPowerpointApplication powerpointApplication = GetPowerpointApplication()) {
- if (powerpointApplication == null) {
- return false;
- }
-
- using IPresentations presentations = powerpointApplication.Presentations;
- LOG.DebugFormat("Open Presentations: {0}", presentations.Count);
- for (int i = 1; i <= presentations.Count; i++)
+ finally
{
- using IPresentation presentation = presentations.item(i);
- if (presentation == null) {
+ slide?.Dispose();
+ }
+ }
+ }
+
+ ///
+ /// Export the image from the tmpfile to the presentation with the supplied name
+ ///
+ /// Name of the presentation to insert to
+ /// Filename of the image file to insert
+ /// Size of the image
+ /// A string with the image title
+ ///
+ public bool ExportToPresentation(string presentationName, string tmpFile, Size imageSize, string title)
+ {
+ using (var powerpointApplication = GetPowerPointApplication())
+ {
+ if (powerpointApplication == null)
+ {
+ return false;
+ }
+
+ using var presentations = DisposableCom.Create(powerpointApplication.ComObject.Presentations);
+ LOG.DebugFormat("Open Presentations: {0}", presentations.ComObject.Count);
+ for (int i = 1; i <= presentations.ComObject.Count; i++)
+ {
+ using var presentation = DisposableCom.Create(presentations.ComObject[i]);
+ if (presentation == null)
+ {
continue;
}
- if (!presentation.Name.StartsWith(presentationName)) {
+ if (!presentation.ComObject.Name.StartsWith(presentationName))
+ {
continue;
}
- try {
+ try
+ {
AddPictureToPresentation(presentation, tmpFile, imageSize, title);
return true;
- } catch (Exception e) {
- LOG.Error(e);
+ }
+ catch (Exception e)
+ {
+ LOG.Error("Adding picture to powerpoint failed", e);
}
}
}
- return false;
- }
+ return false;
+ }
- ///
- /// Internal method to add a picture to a presentation
- ///
- ///
- ///
- ///
- ///
- private static void AddPictureToPresentation(IPresentation presentation, string tmpFile, Size imageSize, string title) {
- if (presentation != null) {
- //ISlide slide = presentation.Slides.AddSlide( presentation.Slides.Count + 1, PPSlideLayout.ppLayoutPictureWithCaption);
- ISlide slide;
- float left = (presentation.PageSetup.SlideWidth / 2) - (imageSize.Width / 2f);
- float top = (presentation.PageSetup.SlideHeight / 2) - (imageSize.Height / 2f);
- float width = imageSize.Width;
- float height = imageSize.Height;
- IShape shapeForCaption = null;
- bool hasScaledWidth = false;
- bool hasScaledHeight = false;
- try {
- slide = presentation.Slides.Add(presentation.Slides.Count + 1, (int)officeConfiguration.PowerpointSlideLayout);
- // Shapes[2] is the image shape on this layout.
- shapeForCaption = slide.Shapes.item(1);
- IShape shapeForLocation = slide.Shapes.item(2);
+ ///
+ /// Call this to get the running PowerPoint application, or create a new instance
+ ///
+ /// ComDisposable for PowerPoint.Application
+ private IDisposableCom GetOrCreatePowerPointApplication()
+ {
+ var powerPointApplication = GetPowerPointApplication();
+ if (powerPointApplication == null)
+ {
+ powerPointApplication = DisposableCom.Create(new Application());
+ }
+ InitializeVariables(powerPointApplication);
+ return powerPointApplication;
+ }
- if (width > shapeForLocation.Width) {
- width = shapeForLocation.Width;
- left = shapeForLocation.Left;
- hasScaledWidth = true;
- } else {
- shapeForLocation.Left = left;
- }
- shapeForLocation.Width = imageSize.Width;
+ ///
+ /// Call this to get the running PowerPoint application, returns null if there isn't any.
+ ///
+ /// ComDisposable for PowerPoint.Application or null
+ private IDisposableCom GetPowerPointApplication()
+ {
+ IDisposableCom powerPointApplication;
+ try
+ {
+ powerPointApplication = OleAut32Api.GetActiveObject("PowerPoint.Application");
+ }
+ catch (Exception)
+ {
+ // Ignore, probably no PowerPoint running
+ return null;
+ }
+ if (powerPointApplication.ComObject != null)
+ {
+ InitializeVariables(powerPointApplication);
+ }
+ return powerPointApplication;
+ }
- if (height > shapeForLocation.Height) {
- height = shapeForLocation.Height;
- top = shapeForLocation.Top;
- hasScaledHeight = true;
- } else {
- top = (shapeForLocation.Top + (shapeForLocation.Height / 2)) - (imageSize.Height / 2f);
- }
- shapeForLocation.Height = imageSize.Height;
- } catch (Exception e) {
- LOG.Error(e);
- slide = presentation.Slides.Add(presentation.Slides.Count + 1, (int)PPSlideLayout.ppLayoutBlank);
- }
- IShape shape = slide.Shapes.AddPicture(tmpFile, MsoTriState.msoFalse, MsoTriState.msoTrue, 0, 0, width, height);
- if (officeConfiguration.PowerpointLockAspectRatio) {
- shape.LockAspectRatio = MsoTriState.msoTrue;
- } else {
- shape.LockAspectRatio = MsoTriState.msoFalse;
- }
- shape.ScaleHeight(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromMiddle);
- shape.ScaleWidth(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromMiddle);
- if (hasScaledWidth) {
- shape.Width = width;
- }
- if (hasScaledHeight) {
- shape.Height = height;
- }
- shape.Left = left;
- shape.Top = top;
- shape.AlternativeText = title;
- if (shapeForCaption != null) {
- try {
- // Using try/catch to make sure problems with the text range don't give an exception.
- ITextFrame textFrame = shapeForCaption.TextFrame;
- textFrame.TextRange.Text = title;
- } catch (Exception ex) {
- LOG.Warn("Problem setting the title to a text-range", ex);
- }
- }
- presentation.Application.ActiveWindow.View.GotoSlide(slide.SlideNumber);
- presentation.Application.Activate();
- }
- }
+ ///
+ /// Get the captions of all the open powerpoint presentations
+ ///
+ ///
+ public IEnumerable GetPowerpointPresentations()
+ {
+ using var powerpointApplication = GetPowerPointApplication();
+ if (powerpointApplication == null)
+ {
+ yield break;
+ }
- ///
- /// Insert a capture into a new presentation
- ///
- ///
- ///
- ///
- ///
- public static bool InsertIntoNewPresentation(string tmpFile, Size imageSize, string title) {
- bool isPictureAdded = false;
- using (IPowerpointApplication powerpointApplication = GetOrCreatePowerpointApplication()) {
- if (powerpointApplication != null) {
- powerpointApplication.Visible = true;
- using IPresentations presentations = powerpointApplication.Presentations;
- using IPresentation presentation = presentations.Add(MsoTriState.msoTrue);
- try {
- AddPictureToPresentation(presentation, tmpFile, imageSize, title);
- isPictureAdded = true;
- } catch (Exception e) {
- LOG.Error(e);
+ using var presentations = DisposableCom.Create(powerpointApplication.ComObject.Presentations);
+ LOG.DebugFormat("Open Presentations: {0}", presentations.ComObject.Count);
+ for (int i = 1; i <= presentations.ComObject.Count; i++)
+ {
+ using var presentation = DisposableCom.Create(presentations.ComObject[i]);
+ if (presentation == null)
+ {
+ continue;
+ }
+ if (presentation.ComObject.ReadOnly == MsoTriState.msoTrue)
+ {
+ continue;
+ }
+ if (IsAfter2003())
+ {
+ if (presentation.ComObject.Final)
+ {
+ continue;
}
}
- }
- return isPictureAdded;
- }
+ yield return presentation.ComObject.Name;
+ }
+ }
- ///
- /// Call this to get the running powerpoint application, returns null if there isn't any.
- ///
- /// IPowerpointApplication or null
- private static IPowerpointApplication GetPowerpointApplication() {
- IPowerpointApplication powerpointApplication = COMWrapper.GetInstance();
- InitializeVariables(powerpointApplication);
- return powerpointApplication;
- }
+ ///
+ /// Initialize static powerpoint variables like version
+ ///
+ /// IPowerpointApplication
+ private void InitializeVariables(IDisposableCom powerpointApplication)
+ {
+ if ((powerpointApplication == null) || (powerpointApplication.ComObject == null) || (_powerpointVersion != null))
+ {
+ return;
+ }
+ if (!Version.TryParse(powerpointApplication.ComObject.Version, out _powerpointVersion))
+ {
+ LOG.Warn("Assuming Powerpoint version 1997.");
+ _powerpointVersion = new Version((int)OfficeVersions.Office97, 0, 0, 0);
+ }
+ }
- ///
- /// Call this to get the running powerpoint application, or create a new instance
- ///
- /// IPowerpointApplication
- private static IPowerpointApplication GetOrCreatePowerpointApplication() {
- IPowerpointApplication powerpointApplication = COMWrapper.GetOrCreateInstance();
- InitializeVariables(powerpointApplication);
- return powerpointApplication;
- }
+ ///
+ /// Insert a capture into a new presentation
+ ///
+ ///
+ ///
+ ///
+ ///
+ public bool InsertIntoNewPresentation(string tmpFile, Size imageSize, string title)
+ {
+ bool isPictureAdded = false;
+ using (var powerpointApplication = GetOrCreatePowerPointApplication())
+ {
+ if (powerpointApplication != null)
+ {
+ powerpointApplication.ComObject.Activate();
+ powerpointApplication.ComObject.Visible = MsoTriState.msoTrue;
+ using var presentations = DisposableCom.Create(powerpointApplication.ComObject.Presentations);
+ using var presentation = DisposableCom.Create(presentations.ComObject.Add());
+ try
+ {
+ AddPictureToPresentation(presentation, tmpFile, imageSize, title);
+ isPictureAdded = true;
+ }
+ catch (Exception e)
+ {
+ LOG.Error("Powerpoint add picture to presentation failed", e);
+ }
+ }
+ }
+ return isPictureAdded;
+ }
- ///
- /// Initialize static outlook variables like version and currentuser
- ///
- /// IPowerpointApplication
- private static void InitializeVariables(IPowerpointApplication powerpointApplication) {
- if (powerpointApplication == null || _powerpointVersion != null) {
- return;
- }
- try {
- _powerpointVersion = new Version(powerpointApplication.Version);
- LOG.InfoFormat("Using Powerpoint {0}", _powerpointVersion);
- } catch (Exception exVersion) {
- LOG.Error(exVersion);
- LOG.Warn("Assuming Powerpoint version 1997.");
- _powerpointVersion = new Version((int)OfficeVersion.OFFICE_97, 0, 0, 0);
- }
- }
+ private bool IsAfter2003()
+ {
+ return _powerpointVersion.Major > (int)OfficeVersions.Office2003;
+ }
+ }
- }
-}
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeExport/WordExporter.cs b/GreenshotOfficePlugin/OfficeExport/WordExporter.cs
index 96250fe59..9b08a9114 100644
--- a/GreenshotOfficePlugin/OfficeExport/WordExporter.cs
+++ b/GreenshotOfficePlugin/OfficeExport/WordExporter.cs
@@ -1,294 +1,345 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// Greenshot - a free and open source screenshot tool
+// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
+//
+// For more information see: http://getgreenshot.org/
+// The Greenshot project is hosted on GitHub: https://github.com/greenshot
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 1 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
using System;
using System.Collections.Generic;
+using GreenshotOfficePlugin.Com;
using GreenshotOfficePlugin.OfficeInterop;
-using GreenshotOfficePlugin.OfficeInterop.Outlook;
-using GreenshotOfficePlugin.OfficeInterop.Word;
-using GreenshotPlugin.Core;
using GreenshotPlugin.IniFile;
-using GreenshotPlugin.Interop;
+using Microsoft.Office.Core;
+using Microsoft.Office.Interop.Word;
+using Version = System.Version;
-namespace GreenshotOfficePlugin.OfficeExport {
- public class WordExporter {
- private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(WordExporter));
- private static Version _wordVersion;
- private static readonly OfficeConfiguration OfficeConfig = IniConfig.GetIniSection();
+namespace GreenshotOfficePlugin.OfficeExport
+{
+ ///
+ /// This makes it possible to export to word
+ ///
+ public class WordExporter
+ {
+ private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordExporter));
+ private static Version _wordVersion;
- ///
- /// Check if the used version is higher than Office 2003
- ///
- ///
- private static bool IsAfter2003() {
- return _wordVersion.Major > (int)OfficeVersion.OFFICE_2003;
- }
+ private static readonly OfficeConfiguration _officeConfiguration = IniConfig.GetIniSection();
- ///
- /// Insert the bitmap stored under the tempfile path into the word document with the supplied caption
- ///
- ///
- ///
- ///
- public static bool InsertIntoExistingDocument(string wordCaption, string tmpFile) {
- using (IWordApplication wordApplication = GetWordApplication()) {
- if (wordApplication == null) {
- return false;
- }
+ ///
+ /// Helper method to add the file as image to the selection
+ ///
+ ///
+ ///
+ ///
+ private IDisposableCom AddPictureToSelection(IDisposableCom selection, string tmpFile)
+ {
+ using var shapes = DisposableCom.Create(selection.ComObject.InlineShapes);
+ var shape = DisposableCom.Create(shapes.ComObject.AddPicture(tmpFile, false, true, Type.Missing));
+ // Lock aspect ratio
+ if (_officeConfiguration.WordLockAspectRatio)
+ {
+ shape.ComObject.LockAspectRatio = MsoTriState.msoTrue;
+ }
+ selection.ComObject.InsertAfter("\r\n");
+ selection.ComObject.MoveDown(WdUnits.wdLine, 1, Type.Missing);
+ return shape;
+ }
- using IDocuments documents = wordApplication.Documents;
- for (int i = 1; i <= documents.Count; i++)
+ ///
+ /// Call this to get the running Word application, or create a new instance
+ ///
+ /// ComDisposable for Word.Application
+ private IDisposableCom GetOrCreateWordApplication()
+ {
+ var wordApplication = GetWordApplication();
+ if (wordApplication == null)
+ {
+ wordApplication = DisposableCom.Create(new Application());
+ }
+ InitializeVariables(wordApplication);
+ return wordApplication;
+ }
+
+ ///
+ /// Call this to get the running Word application, returns null if there isn't any.
+ ///
+ /// ComDisposable for Word.Application or null
+ private IDisposableCom GetWordApplication()
+ {
+ IDisposableCom wordApplication;
+ try
+ {
+ wordApplication = OleAut32Api.GetActiveObject("Word.Application");
+ }
+ catch (Exception)
+ {
+ // Ignore, probably no word running
+ return null;
+ }
+ if ((wordApplication != null) && (wordApplication.ComObject != null))
+ {
+ InitializeVariables(wordApplication);
+ }
+ return wordApplication;
+ }
+
+ ///
+ /// Get the captions of all the open word documents
+ ///
+ ///
+ public IEnumerable GetWordDocuments()
+ {
+ using var wordApplication = GetWordApplication();
+ if (wordApplication == null)
+ {
+ yield break;
+ }
+
+ using var documents = DisposableCom.Create(wordApplication.ComObject.Documents);
+ for (int i = 1; i <= documents.ComObject.Count; i++)
+ {
+ using var document = DisposableCom.Create(documents.ComObject[i]);
+ if (document.ComObject.ReadOnly)
{
- using IWordDocument wordDocument = documents.item(i);
- using IWordWindow activeWindow = wordDocument.ActiveWindow;
- if (activeWindow.Caption.StartsWith(wordCaption)) {
+ continue;
+ }
+ if (IsAfter2003())
+ {
+ if (document.ComObject.Final)
+ {
+ continue;
+ }
+ }
+
+ using var activeWindow = DisposableCom.Create(document.ComObject.ActiveWindow);
+ yield return activeWindow.ComObject.Caption;
+ }
+ }
+
+ ///
+ /// Initialize static word variables like version
+ ///
+ ///
+ private void InitializeVariables(IDisposableCom wordApplication)
+ {
+ if ((wordApplication == null) || (wordApplication.ComObject == null) || (_wordVersion != null))
+ {
+ return;
+ }
+ if (!Version.TryParse(wordApplication.ComObject.Version, out _wordVersion))
+ {
+ LOG.Warn("Assuming Word version 1997.");
+ _wordVersion = new Version((int)OfficeVersions.Office97, 0, 0, 0);
+ }
+ }
+
+ ///
+ /// Insert the bitmap stored under the tempfile path into the word document with the supplied caption
+ ///
+ ///
+ ///
+ /// bool
+ public bool InsertIntoExistingDocument(string wordCaption, string tmpFile)
+ {
+ using (var wordApplication = GetWordApplication())
+ {
+ if (wordApplication == null)
+ {
+ return false;
+ }
+
+ using var documents = DisposableCom.Create(wordApplication.ComObject.Documents);
+ for (int i = 1; i <= documents.ComObject.Count; i++)
+ {
+ using var wordDocument = DisposableCom.Create((_Document)documents.ComObject[i]);
+ using var activeWindow = DisposableCom.Create(wordDocument.ComObject.ActiveWindow);
+ if (activeWindow.ComObject.Caption.StartsWith(wordCaption))
+ {
return InsertIntoExistingDocument(wordApplication, wordDocument, tmpFile, null, null);
}
}
}
- return false;
- }
+ return false;
+ }
- ///
- /// Internal method for the insert
- ///
- ///
- ///
- ///
- /// link for the image
- /// tooltip of the image
- ///
- internal static bool InsertIntoExistingDocument(IWordApplication wordApplication, IWordDocument wordDocument, string tmpFile, string address, string tooltip) {
- // Bug #1517: image will be inserted into that document, where the focus was last. It will not inserted into the chosen one.
- // Solution: Make sure the selected document is active, otherwise the insert will be made in a different document!
- try {
- wordDocument.Activate();
- }
- catch
- {
- // ignored
- }
+ ///
+ /// Internal method for the insert
+ ///
+ /// IDisposableCom with Application
+ /// IDisposableCom with _Document
+ /// string
+ /// string
+ /// string with the tooltip of the image
+ /// bool
+ internal bool InsertIntoExistingDocument(IDisposableCom wordApplication, IDisposableCom<_Document> wordDocument, string tmpFile, string address, string tooltip)
+ {
+ // Bug #1517: image will be inserted into that document, where the focus was last. It will not inserted into the chosen one.
+ // Solution: Make sure the selected document is active, otherwise the insert will be made in a different document!
+ try
+ {
+ wordDocument.ComObject.Activate();
+ // ReSharper disable once EmptyGeneralCatchClause
+ }
+ catch (Exception ex)
+ {
+ LOG.Warn("Error activating worddocument", ex);
+ }
- using ISelection selection = wordApplication.Selection;
- if (selection == null) {
- Log.InfoFormat("No selection to insert {0} into found.", tmpFile);
+ using var selection = DisposableCom.Create(wordApplication.ComObject.Selection);
+ if (selection == null)
+ {
+ LOG.InfoFormat("No selection to insert {0} into found.", tmpFile);
return false;
}
// Add Picture
- using (IInlineShape shape = AddPictureToSelection(selection, tmpFile)) {
- if (!string.IsNullOrEmpty(address)) {
+ using (var shape = AddPictureToSelection(selection, tmpFile))
+ {
+ if (!string.IsNullOrEmpty(address))
+ {
object screentip = Type.Missing;
- if (!string.IsNullOrEmpty(tooltip)) {
+ if (!string.IsNullOrEmpty(tooltip))
+ {
screentip = tooltip;
}
try
{
- using IHyperlinks hyperlinks = wordDocument.Hyperlinks;
- hyperlinks.Add(shape, screentip, Type.Missing, screentip, Type.Missing, Type.Missing);
- } catch (Exception e) {
- Log.WarnFormat("Couldn't add hyperlink for image: {0}", e.Message);
+ using var hyperlinks = DisposableCom.Create(wordDocument.ComObject.Hyperlinks);
+ hyperlinks.ComObject.Add(shape, screentip, Type.Missing, screentip, Type.Missing, Type.Missing);
+ }
+ catch (Exception e)
+ {
+ LOG.WarnFormat("Couldn't add hyperlink for image: {0}", e.Message);
}
}
}
try
{
- using IWordWindow activeWindow = wordDocument.ActiveWindow;
- activeWindow.Activate();
- using IPane activePane = activeWindow.ActivePane;
- using IWordView view = activePane.View;
- view.Zoom.Percentage = 100;
- } catch (Exception e) {
- Log.WarnFormat("Couldn't set zoom to 100, error: {0}", e.InnerException?.Message ?? e.Message);
+ using var activeWindow = DisposableCom.Create(wordDocument.ComObject.ActiveWindow);
+ activeWindow.ComObject.Activate();
+ using var activePane = DisposableCom.Create(activeWindow.ComObject.ActivePane);
+ using var view = DisposableCom.Create(activePane.ComObject.View);
+ view.ComObject.Zoom.Percentage = 100;
}
- try {
- wordApplication.Activate();
- }
- catch
+ catch (Exception e)
{
- // ignored
+ if (e.InnerException != null)
+ {
+ LOG.WarnFormat("Couldn't set zoom to 100, error: {0}", e.InnerException.Message);
+ }
+ else
+ {
+ LOG.WarnFormat("Couldn't set zoom to 100, error: {0}", e.Message);
+ }
}
try
{
- using var activeWindow = wordDocument.ActiveWindow;
- activeWindow.Activate();
- int hWnd = activeWindow.Hwnd;
- if (hWnd > 0)
- {
- WindowDetails.ToForeground(new IntPtr(hWnd));
- }
+ wordApplication.ComObject.Activate();
+ // ReSharper disable once EmptyGeneralCatchClause
}
- catch
+ catch (Exception ex)
{
- // ignored
+ LOG.Warn("Error activating word application", ex);
+ }
+ try
+ {
+ wordDocument.ComObject.Activate();
+ // ReSharper disable once EmptyGeneralCatchClause
+ }
+ catch (Exception ex)
+ {
+ LOG.Warn("Error activating word document", ex);
}
return true;
}
- ///
- /// Helper method to add the file as image to the selection
- ///
- ///
- ///
- ///
- private static IInlineShape AddPictureToSelection(ISelection selection, string tmpFile)
+ ///
+ /// Insert a capture into a new document
+ ///
+ /// string
+ /// string
+ /// string
+ public void InsertIntoNewDocument(string tmpFile, string address, string tooltip)
{
- using IInlineShapes shapes = selection.InlineShapes;
- IInlineShape shape = shapes.AddPicture(tmpFile, false, true, Type.Missing);
- // Lock aspect ratio
- if (OfficeConfig.WordLockAspectRatio) {
- shape.LockAspectRatio = MsoTriState.msoTrue;
- }
- selection.InsertAfter("\r\n");
- selection.MoveDown(WdUnits.wdLine, 1, Type.Missing);
- return shape;
- }
-
- public static void InsertIntoNewDocument(string tmpFile, string address, string tooltip)
- {
- using IWordApplication wordApplication = GetOrCreateWordApplication();
- if (wordApplication == null) {
+ using var wordApplication = GetOrCreateWordApplication();
+ if (wordApplication == null)
+ {
return;
}
- wordApplication.Visible = true;
- wordApplication.Activate();
+ wordApplication.ComObject.Visible = true;
+ wordApplication.ComObject.Activate();
// Create new Document
object template = string.Empty;
object newTemplate = false;
object documentType = 0;
object documentVisible = true;
- using IDocuments documents = wordApplication.Documents;
- using IWordDocument wordDocument = documents.Add(ref template, ref newTemplate, ref documentType, ref documentVisible);
- using (ISelection selection = wordApplication.Selection)
+ using var documents = DisposableCom.Create(wordApplication.ComObject.Documents);
+ using var wordDocument = DisposableCom.Create(documents.ComObject.Add(template, newTemplate, documentType, documentVisible));
+ using (var selection = DisposableCom.Create(wordApplication.ComObject.Selection))
{
// Add Picture
- using IInlineShape shape = AddPictureToSelection(selection, tmpFile);
- if (!string.IsNullOrEmpty(address)) {
+ using var shape = AddPictureToSelection(selection, tmpFile);
+ if (!string.IsNullOrEmpty(address))
+ {
object screentip = Type.Missing;
- if (!string.IsNullOrEmpty(tooltip)) {
+ if (!string.IsNullOrEmpty(tooltip))
+ {
screentip = tooltip;
}
try
{
- using IHyperlinks hyperlinks = wordDocument.Hyperlinks;
- hyperlinks.Add(shape, screentip, Type.Missing, screentip, Type.Missing, Type.Missing);
- } catch (Exception e) {
- Log.WarnFormat("Couldn't add hyperlink for image: {0}", e.Message);
+ using var hyperlinks = DisposableCom.Create(wordDocument.ComObject.Hyperlinks);
+ using (DisposableCom.Create(hyperlinks.ComObject.Add(shape, screentip, Type.Missing, screentip, Type.Missing, Type.Missing)))
+ {
+ // Do nothing
+ }
+ }
+ catch (Exception e)
+ {
+ LOG.WarnFormat("Couldn't add hyperlink for image: {0}", e.Message);
}
}
}
- try {
- wordDocument.Activate();
- }
- catch
- {
- // ignored
- }
try
{
- using var activeWindow = wordDocument.ActiveWindow;
- activeWindow.Activate();
- int hWnd = activeWindow.Hwnd;
- if (hWnd > 0)
- {
- WindowDetails.ToForeground(new IntPtr(hWnd));
- }
+ wordDocument.ComObject.Activate();
+ // ReSharper disable once EmptyGeneralCatchClause
}
- catch
+ catch (Exception ex)
{
- // ignored
+ LOG.Warn("Error activating word document", ex);
+ }
+ try
+ {
+ using var activeWindow = DisposableCom.Create(wordDocument.ComObject.ActiveWindow);
+ activeWindow.ComObject.Activate();
+ // ReSharper disable once EmptyGeneralCatchClause
+ }
+ catch (Exception ex)
+ {
+ LOG.Warn("Error activating window", ex);
}
}
- ///
- /// Get the captions of all the open word documents
- ///
- ///
- public static List GetWordDocuments() {
- List openDocuments = new List();
- try
- {
- using IWordApplication wordApplication = GetWordApplication();
- if (wordApplication == null) {
- return openDocuments;
- }
-
- using IDocuments documents = wordApplication.Documents;
- for (int i = 1; i <= documents.Count; i++)
- {
- using IWordDocument document = documents.item(i);
- if (document.ReadOnly) {
- continue;
- }
- if (IsAfter2003()) {
- if (document.Final) {
- continue;
- }
- }
-
- using IWordWindow activeWindow = document.ActiveWindow;
- openDocuments.Add(activeWindow.Caption);
- }
- } catch (Exception ex) {
- Log.Warn("Problem retrieving word destinations, ignoring: ", ex);
- }
- openDocuments.Sort();
- return openDocuments;
- }
-
- ///
- /// Call this to get the running outlook application, returns null if there isn't any.
- ///
- /// IWordApplication or null
- private static IWordApplication GetWordApplication() {
- IWordApplication wordApplication = COMWrapper.GetInstance();
- InitializeVariables(wordApplication);
- return wordApplication;
- }
-
- ///
- /// Call this to get the running word application, or create a new instance
- ///
- /// IWordApplication
- private static IWordApplication GetOrCreateWordApplication() {
- IWordApplication wordApplication = COMWrapper.GetOrCreateInstance();
- InitializeVariables(wordApplication);
- return wordApplication;
- }
-
- ///
- /// Initialize static outlook variables like version and currentuser
- ///
- ///
- private static void InitializeVariables(IWordApplication wordApplication) {
- if (wordApplication == null || _wordVersion != null) {
- return;
- }
- try {
- _wordVersion = new Version(wordApplication.Version);
- Log.InfoFormat("Using Word {0}", _wordVersion);
- } catch (Exception exVersion) {
- Log.Error(exVersion);
- Log.Warn("Assuming Word version 1997.");
- _wordVersion = new Version((int)OfficeVersion.OFFICE_97, 0, 0, 0);
- }
- }
- }
-}
+ ///
+ /// Check if the used version is higher than Office 2003
+ ///
+ ///
+ private bool IsAfter2003()
+ {
+ return _wordVersion.Major > (int)OfficeVersions.Office2003;
+ }
+ }
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/EmailFormat.cs b/GreenshotOfficePlugin/OfficeInterop/EmailFormat.cs
new file mode 100644
index 000000000..98969057f
--- /dev/null
+++ b/GreenshotOfficePlugin/OfficeInterop/EmailFormat.cs
@@ -0,0 +1,36 @@
+// Greenshot - a free and open source screenshot tool
+// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
+//
+// For more information see: http://getgreenshot.org/
+// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 1 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+namespace GreenshotOfficePlugin.OfficeInterop
+{
+ ///
+ /// Specifies which EmailFormat the email needs to use
+ ///
+ public enum EmailFormat
+ {
+ ///
+ /// Use the plain text format
+ ///
+ Text,
+ ///
+ /// Use HTML format
+ ///
+ Html
+ }
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Excel/IExcelApplication.cs b/GreenshotOfficePlugin/OfficeInterop/Excel/IExcelApplication.cs
deleted file mode 100644
index 6d831b328..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Excel/IExcelApplication.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Excel {
- ///
- /// See http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.application.aspx
- ///
- [ComProgId("Excel.Application")]
- public interface IExcelApplication : ICommon {
- IWorkbook ActiveWorkbook {
- get;
- }
-
- //ISelection Selection {get;}
- IWorkbooks Workbooks {
- get;
- }
-
- bool Visible {
- get;
- set;
- }
-
- string Version {
- get;
- }
-
- ///
- /// Returns an Integer indicating the top-level window handle of the Microsoft Excel window.
- ///
- int Hwnd
- {
- get;
- }
- }
-}
diff --git a/GreenshotOfficePlugin/OfficeInterop/Excel/IPictures.cs b/GreenshotOfficePlugin/OfficeInterop/Excel/IPictures.cs
deleted file mode 100644
index d64cac671..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Excel/IPictures.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Excel
-{
- public interface IPictures : ICollection {
- // Use index + 1!!
- //IPicture this[object Index] { get; }
- void Insert(string file);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Excel/IWorkbook.cs b/GreenshotOfficePlugin/OfficeInterop/Excel/IWorkbook.cs
deleted file mode 100644
index 2beca0e2b..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Excel/IWorkbook.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Excel
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbook.aspx
- ///
- public interface IWorkbook : ICommon {
- IWorksheet ActiveSheet {
- get;
- }
- string Name {
- get;
- }
- void Activate();
- IWorksheets Worksheets {
- get;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Excel/IWorkbooks.cs b/GreenshotOfficePlugin/OfficeInterop/Excel/IWorkbooks.cs
deleted file mode 100644
index 9d459e44a..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Excel/IWorkbooks.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Excel
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.aspx
- ///
- public interface IWorkbooks : ICommon, ICollection {
- IWorkbook Add(object template);
- // Use index + 1!!
- IWorkbook this[object index] {
- get;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Excel/IWorksheet.cs b/GreenshotOfficePlugin/OfficeInterop/Excel/IWorksheet.cs
deleted file mode 100644
index d40c9a676..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Excel/IWorksheet.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using GreenshotOfficePlugin.OfficeInterop.Powerpoint;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Excel
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._worksheet_members.aspx
- ///
- public interface IWorksheet : ICommon {
- IPictures Pictures {
- get;
- }
- IShapes Shapes {
- get;
- }
- string Name {
- get;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Excel/IWorksheets.cs b/GreenshotOfficePlugin/OfficeInterop/Excel/IWorksheets.cs
deleted file mode 100644
index f8aac3bed..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Excel/IWorksheets.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Excel
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.iworksheets_members.aspx
- ///
- public interface IWorksheets : ICollection {
- // Use index + 1!!
- IWorksheet this[object index] {
- get;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/ICollection.cs b/GreenshotOfficePlugin/OfficeInterop/ICollection.cs
deleted file mode 100644
index 3f8577cc5..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/ICollection.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System.Collections;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop {
- ///
- /// If the "type" this[object index] { get; } is implemented, use index + 1!!! (starts at 1)
- ///
- public interface ICollection : ICommon, IEnumerable {
- int Count {
- get;
- }
- void Remove(int index);
- }
-}
diff --git a/GreenshotOfficePlugin/OfficeInterop/MsoScaleFrom.cs b/GreenshotOfficePlugin/OfficeInterop/MsoScaleFrom.cs
deleted file mode 100644
index ad8a534a5..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/MsoScaleFrom.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop
-{
- public enum MsoScaleFrom {
- msoScaleFromTopLeft = 0,
- msoScaleFromMiddle = 1,
- msoScaleFromBottomRight = 2
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/MsoTriState.cs b/GreenshotOfficePlugin/OfficeInterop/MsoTriState.cs
deleted file mode 100644
index f13e86050..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/MsoTriState.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop
-{
- public enum MsoTriState {
- msoTrue = -1,
- msoFalse = 0,
- msoCTrue = 1,
- msoTriStateToggle = -3,
- msoTriStateMixed = -2
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/OfficeVersion.cs b/GreenshotOfficePlugin/OfficeInterop/OfficeVersion.cs
deleted file mode 100644
index 0d8e846c8..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/OfficeVersion.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop
-{
- public enum OfficeVersion : int {
- OFFICE_97 = 8,
- OFFICE_2000 = 9,
- OFFICE_2002 = 10,
- OFFICE_2003 = 11,
- OFFICE_2007 = 12,
- OFFICE_2010 = 14,
- OFFICE_2013 = 15
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/OfficeVersions.cs b/GreenshotOfficePlugin/OfficeInterop/OfficeVersions.cs
new file mode 100644
index 000000000..6d8a992ba
--- /dev/null
+++ b/GreenshotOfficePlugin/OfficeInterop/OfficeVersions.cs
@@ -0,0 +1,64 @@
+// Greenshot - a free and open source screenshot tool
+// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
+//
+// For more information see: http://getgreenshot.org/
+// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 1 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
+namespace GreenshotOfficePlugin.OfficeInterop
+{
+ ///
+ /// A mapping between the version and a usable name
+ ///
+ public enum OfficeVersions
+ {
+ ///
+ /// Office 97
+ ///
+ Office97 = 8,
+ ///
+ /// Office 2000
+ ///
+ Office2000 = 9,
+ ///
+ /// Office 2002
+ ///
+ Office2002 = 10,
+ ///
+ /// Office 2003
+ ///
+ Office2003 = 11,
+ ///
+ /// Office 2007
+ ///
+ Office2007 = 12,
+ ///
+ /// Office 2010
+ ///
+ Office2010 = 14,
+ ///
+ /// Office 2013
+ ///
+ Office2013 = 15,
+ ///
+ /// Office 2016
+ ///
+ Office2016 = 16,
+ ///
+ /// Office 2019
+ ///
+ Office2019 = 17
+ }
+}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/OneNote/HierarchyScope.cs b/GreenshotOfficePlugin/OfficeInterop/OneNote/HierarchyScope.cs
deleted file mode 100644
index da9ceda0e..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/OneNote/HierarchyScope.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.OneNote
-{
- public enum HierarchyScope {
- hsSelf = 0, // Gets just the start node specified and no descendants.
- hsChildren = 1, //Gets the immediate child nodes of the start node, and no descendants in higher or lower subsection groups.
- hsNotebooks = 2, // Gets all notebooks below the start node, or root.
- hsSections = 3, //Gets all sections below the start node, including sections in section groups and subsection groups.
- hsPages = 4 //Gets all pages below the start node, including all pages in section groups and subsection groups.
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/OneNote/IOneNoteApplication.cs b/GreenshotOfficePlugin/OfficeInterop/OneNote/IOneNoteApplication.cs
deleted file mode 100644
index 817ee8189..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/OneNote/IOneNoteApplication.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.OneNote
-{
- [ComProgId("OneNote.Application")]
- public interface IOneNoteApplication : ICommon {
- ///
- /// Make sure that the out variables are filled with a string, e.g. "", otherwise a type error occurs.
- /// For more info on the methods: http://msdn.microsoft.com/en-us/library/gg649853.aspx
- ///
- void GetHierarchy(string startNode, HierarchyScope scope, out string notebookXml, XMLSchema schema);
- void GetSpecialLocation(SpecialLocation specialLocation, out string specialLocationPath);
- void UpdatePageContent(string pageChangesXml, DateTime dateExpectedLastModified, XMLSchema schema, bool force);
- void GetPageContent(string pageId, out string pageXml, PageInfo pageInfoToExport, XMLSchema schema);
- void NavigateTo(string hierarchyObjectID, string objectId, bool newWindow);
- void CreateNewPage(string sectionID, out string pageID, NewPageStyle newPageStyle);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/OneNote/NewPageStyle.cs b/GreenshotOfficePlugin/OfficeInterop/OneNote/NewPageStyle.cs
deleted file mode 100644
index a5f14ed5c..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/OneNote/NewPageStyle.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.OneNote
-{
- public enum NewPageStyle {
- npsDefault = 0,
- npsBlankPageWithTitle = 1,
- npsBlankPageNoTitle = 2
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/OneNote/OneNoteNotebook.cs b/GreenshotOfficePlugin/OfficeInterop/OneNote/OneNoteNotebook.cs
deleted file mode 100644
index daa2840e6..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/OneNote/OneNoteNotebook.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.OneNote
-{
- public class OneNoteNotebook {
- public string Name { get; set; }
- public string ID { get; set; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/OneNote/OneNotePage.cs b/GreenshotOfficePlugin/OfficeInterop/OneNote/OneNotePage.cs
deleted file mode 100644
index 198c1b237..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/OneNote/OneNotePage.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-namespace GreenshotOfficePlugin.OfficeInterop.OneNote {
- // More details about OneNote: http://msdn.microsoft.com/en-us/magazine/ff796230.aspx
-
- // See http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.applicationclass_members%28v=Office.11%29.aspx
-
- public class OneNotePage {
- public OneNoteSection Parent { get; set; }
- public string Name { get; set; }
- public string ID { get; set; }
- public bool IsCurrentlyViewed { get; set; }
- public string DisplayName {
- get {
- OneNoteNotebook notebook = Parent.Parent;
- if(string.IsNullOrEmpty(notebook.Name)) {
- return $"{Parent.Name} / {Name}";
- }
-
- return $"{Parent.Parent.Name} / {Parent.Name} / {Name}";
- }
- }
- }
-}
diff --git a/GreenshotOfficePlugin/OfficeInterop/OneNote/OneNoteSection.cs b/GreenshotOfficePlugin/OfficeInterop/OneNote/OneNoteSection.cs
deleted file mode 100644
index c7af1a908..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/OneNote/OneNoteSection.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.OneNote
-{
- public class OneNoteSection {
- public OneNoteNotebook Parent { get; set; }
- public string Name { get; set; }
- public string ID { get; set; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/OneNote/PageInfo.cs b/GreenshotOfficePlugin/OfficeInterop/OneNote/PageInfo.cs
deleted file mode 100644
index b4cbc5aba..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/OneNote/PageInfo.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.OneNote
-{
- public enum PageInfo {
- piBasic = 0, // Returns only basic page content, without selection markup and binary data objects. This is the standard value to pass.
- piBinaryData = 1, // Returns page content with no selection markup, but with all binary data.
- piSelection = 2, // Returns page content with selection markup, but no binary data.
- piBinaryDataSelection = 3, // Returns page content with selection markup and all binary data.
- piAll = 3 // Returns all page content.
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/OneNote/SpecialLocation.cs b/GreenshotOfficePlugin/OfficeInterop/OneNote/SpecialLocation.cs
deleted file mode 100644
index 38afca532..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/OneNote/SpecialLocation.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.OneNote
-{
- public enum SpecialLocation : int {
- slBackupFolder = 0,
- slUnfiledNotesSection = 1,
- slDefaultNotebookFolder = 2
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/OneNote/XMLSchema.cs b/GreenshotOfficePlugin/OfficeInterop/OneNote/XMLSchema.cs
deleted file mode 100644
index bce52c20f..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/OneNote/XMLSchema.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.OneNote
-{
- public enum XMLSchema {
- xs2007 = 0,
- xs2010 = 1,
- xsCurrent= xs2010
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/AppointmentItem.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/AppointmentItem.cs
deleted file mode 100644
index 17e94d841..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/AppointmentItem.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/ff869026.aspx
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.appointmentitem.aspx
- ///
- public interface AppointmentItem : IItem, ICommon {
- string Organizer {
- get;
- set;
- }
- string SendUsingAccount {
- get;
- }
- string Categories {
- get;
- }
- DateTime Start {
- get;
- }
- DateTime End {
- get;
- }
- OlReoccurenceState RecurrenceState {
- get;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/EmailFormat.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/EmailFormat.cs
deleted file mode 100644
index a105a0dd9..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/EmailFormat.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// Specifies which EmailFormat the email needs to use
- ///
- public enum EmailFormat {
- Text,
- HTML
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IAttachment.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IAttachment.cs
deleted file mode 100644
index 073aca660..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IAttachment.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.attachment_members.aspx
- ///
- public interface IAttachment : ICommon {
- string DisplayName {
- get;
- set;
- }
- string FileName {
- get;
- }
- OlAttachmentType Type {
- get;
- }
- IPropertyAccessor PropertyAccessor {
- get;
- }
- object MAPIOBJECT {
- get;
- }
- void SaveAsFile(string path);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IAttachments.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IAttachments.cs
deleted file mode 100644
index 64df07e5a..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IAttachments.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- public interface IAttachments : ICollection {
- IAttachment Add(object source, object type, object position, object displayName);
- // Use index+1!!!!
- IAttachment this[object index] {
- get;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/ICommonExplorer.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/ICommonExplorer.cs
deleted file mode 100644
index e8e41368d..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/ICommonExplorer.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// Is a joined interface of the Explorer an Inspector
- ///
- public interface ICommonExplorer : ICommon {
- void Activate();
- string Caption {
- get;
- }
- int Height {
- get;
- set;
- }
- int Left {
- get;
- set;
- }
- int Top {
- get;
- set;
- }
- int Width {
- get;
- set;
- }
- OlWindowState WindowState {
- get;
- set;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IContactItem.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IContactItem.cs
deleted file mode 100644
index e4a900770..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IContactItem.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.contactitem.aspx
- ///
- public interface IContactItem : IItem, ICommon {
- bool HasPicture {
- get;
- }
- void SaveBusinessCardImage(string path);
- void AddPicture(string path);
- void RemovePicture();
- string FirstName {
- get;
- set;
- }
- string LastName {
- get;
- set;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IExplorer.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IExplorer.cs
deleted file mode 100644
index 001f0fca0..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IExplorer.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using GreenshotOfficePlugin.OfficeInterop.Word;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// Since Outlook 2010, but since 2013 one can edit inside an explorer
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.explorer_members(v=office.15).aspx
- ///
- ///
- public interface IExplorer : ICommonExplorer {
- IItem ActiveInlineResponse {
- get;
- }
- IWordDocument ActiveInlineResponseWordEditor {
- get;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IExplorers.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IExplorers.cs
deleted file mode 100644
index b0d6d1b05..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IExplorers.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.Collections;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// Since Outlook 2010, but since 2013 one can edit inside an explorer
- /// See: http://msdn.microsoft.com/en-us/library/office/ff867227(v=office.15).aspx
- ///
- public interface IExplorers : ICommon, ICollection, IEnumerable {
- // Use index + 1!!
- IExplorer this[object Index] {
- get;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IFolder.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IFolder.cs
deleted file mode 100644
index fb3fd03ec..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IFolder.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/bb176362%28v=office.12%29.aspx
- ///
- public interface IFolder : ICommon {
- IItems Items {
- get;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IInspector.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IInspector.cs
deleted file mode 100644
index 211152fa9..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IInspector.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using GreenshotOfficePlugin.OfficeInterop.Word;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.inspector_members.aspx
- ///
- public interface IInspector : ICommonExplorer {
- IItem CurrentItem {
- get;
- }
- OlEditorType EditorType {
- get;
- }
- object ModifiedFormPages {
- get;
- }
- void Close(OlInspectorClose SaveMode);
- void Display(object Modal);
- void HideFormPage(string PageName);
- bool IsWordMail();
- void SetCurrentFormPage(string PageName);
- void ShowFormPage(string PageName);
- object HTMLEditor {
- get;
- }
- IWordDocument WordEditor {
- get;
- }
- void SetControlItemProperty(object Control, string PropertyName);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IInspectors.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IInspectors.cs
deleted file mode 100644
index e38d249cc..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IInspectors.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.Collections;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._application.inspectors.aspx
- ///
- public interface IInspectors : ICommon, ICollection, IEnumerable {
- // Use index + 1!!
- IInspector this[object Index] {
- get;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IItem.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IItem.cs
deleted file mode 100644
index 625aa5750..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IItem.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using System;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// Common attributes of all the Items (MailItem, AppointmentItem)
- /// See: http://msdn.microsoft.com/en-us/library/ff861252.aspx
- ///
- public interface IItem : ICommon {
- IAttachments Attachments {
- get;
- }
- string Body {
- get;
- set;
- }
- OlObjectClass Class {
- get;
- }
- DateTime CreationTime {
- get;
- }
- string EntryID {
- get;
- }
- DateTime LastModificationTime {
- get;
- }
- string MessageClass {
- get;
- set;
- }
- bool NoAging {
- get;
- set;
- }
- int OutlookInternalVersion {
- get;
- }
- string OutlookVersion {
- get;
- }
- bool Saved {
- get;
- }
- OlSensitivity Sensitivity {
- get;
- set;
- }
- int Size {
- get;
- }
- string Subject {
- get;
- set;
- }
- bool UnRead {
- get;
- set;
- }
- object Copy();
- void Display(bool Modal);
- void Save();
- IPropertyAccessor PropertyAccessor {
- get;
- }
- IInspector GetInspector();
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IItems.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IItems.cs
deleted file mode 100644
index 8a6214cd6..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IItems.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System.Collections;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/bb208387%28v=office.12%29.aspx
- ///
- public interface IItems : ICollection, IEnumerable {
- IItem this[object index] {
- get;
- }
- IItem GetFirst();
- IItem GetNext();
- IItem GetLast();
- IItem GetPrevious();
-
- bool IncludeRecurrences {
- get;
- set;
- }
-
- IItems Restrict(string filter);
- void Sort(string property, object descending);
-
- // Actual definition is "object Add( object )", just making it convenient
- object Add(OlItemType type);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/INameSpace.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/INameSpace.cs
deleted file mode 100644
index 97b2ac2b8..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/INameSpace.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/bb176693%28v=office.12%29.aspx
- ///
- public interface INameSpace : ICommon {
- IRecipient CurrentUser {
- get;
- }
- IFolder GetDefaultFolder(OlDefaultFolders defaultFolder);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IOutlookApplication.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IOutlookApplication.cs
deleted file mode 100644
index ea2f1cc90..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IOutlookApplication.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// Wrapper for Outlook.Application, see: http://msdn.microsoft.com/en-us/library/aa210897%28v=office.11%29.aspx
- /// This is the initial COM-Object which is created/retrieved
- ///
- [ComProgId("Outlook.Application")]
- public interface IOutlookApplication : ICommon {
- string Name {
- get;
- }
- string Version {
- get;
- }
- IItem CreateItem(OlItemType ItemType);
- object CreateItemFromTemplate(string TemplatePath, object InFolder);
- object CreateObject(string ObjectName);
- IInspector ActiveInspector();
- IInspectors Inspectors {
- get;
- }
- INameSpace GetNameSpace(string type);
- IExplorer ActiveExplorer();
- IExplorers Explorers {
- get;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IPropertyAccessor.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IPropertyAccessor.cs
deleted file mode 100644
index 3a396752f..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IPropertyAccessor.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.propertyaccessor_members.aspx
- ///
- public interface IPropertyAccessor : ICommon {
- void SetProperty(string SchemaName, object Value);
- object GetProperty(string SchemaName);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/IRecipient.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/IRecipient.cs
deleted file mode 100644
index 9d4c0b641..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/IRecipient.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- public interface IRecipient : ICommon {
- string Name {
- get;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/MailItem.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/MailItem.cs
deleted file mode 100644
index fb63fe740..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/MailItem.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/ff861252.aspx
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mailitem.aspx
- ///
- public interface MailItem : IItem, ICommon {
- bool Sent {
- get;
- }
- object MAPIOBJECT {
- get;
- }
- string HTMLBody {
- get;
- set;
- }
- DateTime ExpiryTime {
- get;
- set;
- }
- DateTime ReceivedTime {
- get;
- }
- string SenderName {
- get;
- }
- DateTime SentOn {
- get;
- }
- OlBodyFormat BodyFormat {
- get;
- set;
- }
- string To {
- get;
- set;
- }
- string CC {
- get;
- set;
- }
- string BCC {
- get;
- set;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlAttachmentType.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/OlAttachmentType.cs
deleted file mode 100644
index ee92fe506..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlAttachmentType.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- public enum OlAttachmentType {
- // Fields
- olByReference = 4,
- olByValue = 1,
- olEmbeddeditem = 5,
- olOLE = 6
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlBodyFormat.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/OlBodyFormat.cs
deleted file mode 100644
index ca65b0e66..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlBodyFormat.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- public enum OlBodyFormat {
- // Fields
- olFormatHTML = 2,
- olFormatPlain = 1,
- olFormatRichText = 3,
- olFormatUnspecified = 0
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlDefaultFolders.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/OlDefaultFolders.cs
deleted file mode 100644
index 867f636f8..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlDefaultFolders.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- public enum OlDefaultFolders {
- olFolderCalendar = 9, // The Calendar folder.
- olFolderConflicts = 19, // The Conflicts folder (subfolder of Sync Issues folder). Only available for an Exchange account.
- olFolderContacts = 10, // The Contacts folder.
- olFolderDeletedItems = 3, // The Deleted Items folder.
- olFolderDrafts = 16, // The Drafts folder.
- olFolderInbox = 6, // The Inbox folder.
- olFolderJournal = 11, // The Journal folder.
- olFolderJunk = 23, // The Junk E-Mail folder.
- olFolderLocalFailures = 21, // The Local Failures folder (subfolder of Sync Issues folder). Only available for an Exchange account.
- olFolderManagedEmail = 29, // The top-level folder in the Managed Folders group. For more information on Managed Folders, see Help in Microsoft Outlook. Only available for an Exchange account.
- olFolderNotes = 12, // The Notes folder.
- olFolderOutbox = 4, // The Outbox folder.
- olFolderSentMail = 5, // The Sent Mail folder.
- olFolderServerFailures = 22, // The Server Failures folder (subfolder of Sync Issues folder). Only available for an Exchange account.
- olFolderSyncIssues = 20, // The Sync Issues folder. Only available for an Exchange account.
- olFolderTasks = 13, // The Tasks folder.
- olFolderToDo = 28, // The To Do folder.
- olPublicFoldersAllPublicFolders = 18, // The All Public Folders folder in the Exchange Public Folders store. Only available for an Exchange account.
- olFolderRssFeeds = 25 // The RSS Feeds folder.
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlEditorType.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/OlEditorType.cs
deleted file mode 100644
index ca4e94d07..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlEditorType.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- public enum OlEditorType {
- // Fields
- olEditorHTML = 2,
- olEditorRTF = 3,
- olEditorText = 1,
- olEditorWord = 4
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlInspectorClose.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/OlInspectorClose.cs
deleted file mode 100644
index 54fe65594..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlInspectorClose.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- public enum OlInspectorClose {
- // Fields
- olDiscard = 1,
- olPromptForSave = 2,
- olSave = 0
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlItemType.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/OlItemType.cs
deleted file mode 100644
index 269a78582..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlItemType.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- public enum OlItemType {
- // Fields
- olAppointmentItem = 1,
- olContactItem = 2,
- olDistributionListItem = 7,
- olJournalItem = 4,
- olMailItem = 0,
- olNoteItem = 5,
- olPostItem = 6,
- olTaskItem = 3
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlObjectClass.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/OlObjectClass.cs
deleted file mode 100644
index 197dc8774..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlObjectClass.cs
+++ /dev/null
@@ -1,151 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/ff863329.aspx
- ///
- public enum OlObjectClass {
- olAccount = 105, // Represents an Account object.
- olAccountRuleCondition = 135, // Represents an AccountRuleCondition object.
- olAccounts = 106, // Represents an Accounts object.
- olAction = 32, // Represents an Action object.
- olActions = 33, // Represents an Actions object.
- olAddressEntries = 21, // Represents an AddressEntries object.
- olAddressEntry = 8, // Represents an AddressEntry object.
- olAddressList = 7, // Represents an AddressList object.
- olAddressLists = 20, // Represents an AddressLists object.
- olAddressRuleCondition = 170, // Represents an AddressRuleCondition object.
- olApplication = 0, // Represents an Application object.
- olAppointment = 26, // Represents an AppointmentItem object.
- olAssignToCategoryRuleAction = 122, // Represents an AssignToCategoryRuleAction object.
- olAttachment = 5, // Represents an Attachment object.
- olAttachments = 18, // Represents an Attachments object.
- olAttachmentSelection = 169, // Represents an AttachmentSelection object.
- olAutoFormatRule = 147, // Represents an AutoFormatRule object.
- olAutoFormatRules = 148, // Represents an AutoFormatRules object.
- olCalendarModule = 159, // Represents a CalendarModule object.
- olCalendarSharing = 151, // Represents a CalendarSharing object.
- olCategories = 153, // Represents a Categories object.
- olCategory = 152, // Represents a Category object.
- olCategoryRuleCondition = 130, // Represents a CategoryRuleCondition object.
- olClassBusinessCardView = 168, // Represents a BusinessCardView object.
- olClassCalendarView = 139, // Represents a CalendarView object.
- olClassCardView = 138, // Represents a CardView object.
- olClassIconView = 137, // Represents a IconView object.
- olClassNavigationPane = 155, // Represents a NavigationPane object.
- olClassTableView = 136, // Represents a TableView object.
- olClassTimeLineView = 140, // Represents a TimelineView object.
- olClassTimeZone = 174, // Represents a TimeZone object.
- olClassTimeZones = 175, // Represents a TimeZones object.
- olColumn = 154, // Represents a Column object.
- olColumnFormat = 149, // Represents a ColumnFormat object.
- olColumns = 150, // Represents a Columns object.
- olConflict = 102, // Represents a Conflict object.
- olConflicts = 103, // Represents a Conflicts object.
- olContact = 40, // Represents a ContactItem object.
- olContactsModule = 160, // Represents a ContactsModule object.
- olDistributionList = 69, // Represents a ExchangeDistributionList object.
- olDocument = 41, // Represents a DocumentItem object.
- olException = 30, // Represents an Exception object.
- olExceptions = 29, // Represents an Exceptions object.
- olExchangeDistributionList = 111, // Represents an ExchangeDistributionList object.
- olExchangeUser = 110, // Represents an ExchangeUser object.
- olExplorer = 34, // Represents an Explorer object.
- olExplorers = 60, // Represents an Explorers object.
- olFolder = 2, // Represents a Folder object.
- olFolders = 15, // Represents a Folders object.
- olFolderUserProperties = 172, // Represents a UserDefinedProperties object.
- olFolderUserProperty = 171, // Represents a UserDefinedProperty object.
- olFormDescription = 37, // Represents a FormDescription object.
- olFormNameRuleCondition = 131, // Represents a FormNameRuleCondition object.
- olFormRegion = 129, // Represents a FormRegion object.
- olFromRssFeedRuleCondition = 173, // Represents a FromRssFeedRuleCondition object.
- olFromRuleCondition = 132, // Represents a ToOrFromRuleCondition object.
- olImportanceRuleCondition = 128, // Represents an ImportanceRuleCondition object.
- olInspector = 35, // Represents an Inspector object.
- olInspectors = 61, // Represents an Inspectors object.
- olItemProperties = 98, // Represents an ItemProperties object.
- olItemProperty = 99, // Represents an ItemProperty object.
- olItems = 16, // Represents an Items object.
- olJournal = 42, // Represents a JournalItem object.
- olJournalModule = 162, // Represents a JournalModule object.
- olLink = 75, // Represents a Link object.
- olLinks = 76, // Represents a Links object.
- olMail = 43, // Represents a MailItem object.
- olMailModule = 158, // Represents a MailModule object.
- olMarkAsTaskRuleAction = 124, // Represents a MarkAsTaskRuleAction object.
- olMeetingCancellation = 54, // Represents a MeetingItem object that is a meeting cancellation notice.
- olMeetingRequest = 53, // Represents a MeetingItem object that is a meeting request.
- olMeetingResponseNegative = 55, // Represents a MeetingItem object that is a refusal of a meeting request.
- olMeetingResponsePositive = 56, // Represents a MeetingItem object that is an acceptance of a meeting request.
- olMeetingResponseTentative = 57, // Represents a MeetingItem object that is a tentative acceptance of a meeting request.
- olMoveOrCopyRuleAction = 118, // Represents a MoveOrCopyRuleAction object.
- olNamespace = 1, // Represents a NameSpace object.
- olNavigationFolder = 167, // Represents a NavigationFolder object.
- olNavigationFolders = 166, // Represents a NavigationFolders object.
- olNavigationGroup = 165, // Represents a NavigationGroup object.
- olNavigationGroups = 164, // Represents a NavigationGroups object.
- olNavigationModule = 157, // Represents a NavigationModule object.
- olNavigationModules = 156, // Represents a NavigationModules object.
- olNewItemAlertRuleAction = 125, // Represents a NewItemAlertRuleAction object.
- olNote = 44, // Represents a NoteItem object.
- olNotesModule = 163, // Represents a NotesModule object.
- olOrderField = 144, // Represents an OrderField object.
- olOrderFields = 145, // Represents an OrderFields object.
- olOutlookBarGroup = 66, // Represents an OutlookBarGroup object.
- olOutlookBarGroups = 65, // Represents an OutlookBarGroups object.
- olOutlookBarPane = 63, // Represents an OutlookBarPane object.
- olOutlookBarShortcut = 68, // Represents an OutlookBarShortcut object.
- olOutlookBarShortcuts = 67, // Represents an OutlookBarShortcuts object.
- olOutlookBarStorage = 64, // Represents an OutlookBarStorage object.
- olPages = 36, // Represents a Pages object.
- olPanes = 62, // Represents a Panes object.
- olPlaySoundRuleAction = 123, // Represents a PlaySoundRuleAction object.
- olPost = 45, // Represents a PostItem object.
- olPropertyAccessor = 112, // Represents a PropertyAccessor object.
- olPropertyPages = 71, // Represents a PropertyPages object.
- olPropertyPageSite = 70, // Represents a PropertyPageSite object.
- olRecipient = 4, // Represents a Recipient object.
- olRecipients = 17, // Represents a Recipients object.
- olRecurrencePattern = 28, // Represents a RecurrencePattern object.
- olReminder = 101, // Represents a Reminder object.
- olReminders = 100, // Represents a Reminders object.
- olRemote = 47, // Represents a RemoteItem object.
- olReport = 46, // Represents a ReportItem object.
- olResults = 78, // Represents a Results object.
- olRow = 121, // Represents a Row object.
- olRule = 115, // Represents a Rule object.
- olRuleAction = 117, // Represents a RuleAction object.
- olRuleActions = 116, // Represents a RuleAction object.
- olRuleCondition = 127, // Represents a RuleCondition object.
- olRuleConditions = 126, // Represents a RuleConditions object.
- olRules = 114, // Represents a Rules object.
- olSearch = 77, // Represents a Search object.
- olSelection = 74, // Represents a Selection object.
- olSelectNamesDialog = 109, // Represents a SelectNamesDialog object.
- olSenderInAddressListRuleCondition = 133, // Represents a SenderInAddressListRuleCondition object.
- olSendRuleAction = 119, // Represents a SendRuleAction object.
- olSharing = 104, // Represents a SharingItem object.
- olStorageItem = 113, // Represents a StorageItem object.
- olStore = 107, // Represents a Store object.
- olStores = 108, // Represents a Stores object.
- olSyncObject = 72, // Represents a SyncObject object.
- olSyncObjects = 73, // Represents a SyncObject object.
- olTable = 120, // Represents a Table object.
- olTask = 48, // Represents a TaskItem object.
- olTaskRequest = 49, // Represents a TaskRequestItem object.
- olTaskRequestAccept = 51, // Represents a TaskRequestAcceptItem object.
- olTaskRequestDecline = 52, // Represents a TaskRequestDeclineItem object.
- olTaskRequestUpdate = 50, // Represents a TaskRequestUpdateItem object.
- olTasksModule = 161, // Represents a TasksModule object.
- olTextRuleCondition = 134, // Represents a TextRuleCondition object.
- olUserDefinedProperties = 172, // Represents a UserDefinedProperties object.
- olUserDefinedProperty = 171, // Represents a UserDefinedProperty object.
- olUserProperties = 38, // Represents a UserProperties object.
- olUserProperty = 39, // Represents a UserProperty object.
- olView = 80, // Represents a View object.
- olViewField = 142, // Represents a ViewField object.
- olViewFields = 141, // Represents a ViewFields object.
- olViewFont = 146, // Represents a ViewFont object.
- olViews = 79 // Represents a Views object.
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlReoccurenceState.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/OlReoccurenceState.cs
deleted file mode 100644
index 9ca79ce3a..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlReoccurenceState.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- public enum OlReoccurenceState {
- olApptException,
- olApptMaster,
- olApptNotRecurring,
- olApptOccurrence
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlSensitivity.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/OlSensitivity.cs
deleted file mode 100644
index 84206c0ac..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlSensitivity.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- public enum OlSensitivity {
- // Fields
- olConfidential = 3,
- olNormal = 0,
- olPersonal = 1,
- olPrivate = 2
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlWindowState.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/OlWindowState.cs
deleted file mode 100644
index 732717d82..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/OlWindowState.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- public enum OlWindowState {
- // Fields
- olMaximized = 0,
- olMinimized = 1,
- olNormalWindow = 2
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/OutlookUtils.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/OutlookUtils.cs
deleted file mode 100644
index 37fed0720..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/OutlookUtils.cs
+++ /dev/null
@@ -1,797 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook {
- internal enum PT : uint {
- PT_UNSPECIFIED = 0, /* (Reserved for interface use) type doesn't matter to caller */
- PT_NULL = 1, /* NULL property value */
- PT_I2 = 2, /* Signed 16-bit value */
- PT_LONG = 3, /* Signed 32-bit value */
- PT_R4 = 4, /* 4-byte floating point */
- PT_DOUBLE = 5, /* Floating point double */
- PT_CURRENCY = 6, /* Signed 64-bit int (decimal w/ 4 digits right of decimal pt) */
- PT_APPTIME = 7, /* Application time */
- PT_ERROR = 10, /* 32-bit error value */
- PT_BOOLEAN = 11, /* 16-bit boolean (non-zero true, */
- // Use PT_BOOLEAN_DESKTOP to be specific instead of using PT_BOOLEAN which is mapped to 2 in addrmapi.h
- PT_BOOLEAN_DESKTOP = 11, /* 16-bit boolean (non-zero true) */
- PT_OBJECT = 13, /* Embedded object in a property */
- PT_I8 = 20, /* 8-byte signed integer */
- PT_STRING8 = 30, /* Null terminated 8-bit character string */
- PT_UNICODE = 31, /* Null terminated Unicode string */
- PT_SYSTIME = 64, /* FILETIME 64-bit int w/ number of 100ns periods since Jan 1,1601 */
- PT_CLSID = 72, /* OLE GUID */
- PT_BINARY = 258, /* Uninterpreted (counted byte array) */
-
- PT_TSTRING = PT_UNICODE
- };
-
- public enum PropTags : uint {
- PR_ERROR = 10,
-
- // Common non-transmittable
- PR_ENTRYID = PT.PT_BINARY | 0x0FFF << 16,
- PR_OBJECT_TYPE = PT.PT_LONG | 0x0FFE << 16,
- PR_ICON = PT.PT_BINARY | 0x0FFD << 16,
- PR_MINI_ICON = PT.PT_BINARY | 0x0FFC << 16,
- PR_STORE_ENTRYID = PT.PT_BINARY | 0x0FFB << 16,
- PR_STORE_RECORD_KEY = PT.PT_BINARY | 0x0FFA << 16,
- PR_RECORD_KEY = PT.PT_BINARY | 0x0FF9 << 16,
- PR_MAPPING_SIGNATURE = PT.PT_BINARY | 0x0FF8 << 16,
- PR_ACCESS_LEVEL = PT.PT_LONG | 0x0FF7 << 16,
- PR_INSTANCE_KEY = PT.PT_BINARY | 0x0FF6 << 16,
- PR_ROW_TYPE = PT.PT_LONG | 0x0FF5 << 16,
- PR_ACCESS = PT.PT_LONG | 0x0FF4 << 16,
-
- // Common transmittable
- PR_ROWID = PT.PT_LONG | 0x3000 << 16,
- PR_DISPLAY_NAME = PT.PT_TSTRING | 0x3001 << 16,
- PR_DISPLAY_NAME_W = PT.PT_UNICODE | 0x3001 << 16,
- PR_DISPLAY_NAME_A = PT.PT_STRING8 | 0x3001 << 16,
- PR_ADDRTYPE = PT.PT_TSTRING | 0x3002 << 16,
- PR_ADDRTYPE_W = PT.PT_UNICODE | 0x3002 << 16,
- PR_ADDRTYPE_A = PT.PT_STRING8 | 0x3002 << 16,
- PR_EMAIL_ADDRESS = PT.PT_TSTRING | 0x3003 << 16,
- PR_EMAIL_ADDRESS_W = PT.PT_UNICODE | 0x3003 << 16,
- PR_EMAIL_ADDRESS_A = PT.PT_STRING8 | 0x3003 << 16,
- PR_COMMENT = PT.PT_TSTRING | 0x3004 << 16,
- PR_COMMENT_W = PT.PT_UNICODE | 0x3004 << 16,
- PR_COMMENT_A = PT.PT_STRING8 | 0x3004 << 16,
- PR_DEPTH = PT.PT_LONG | 0x3005 << 16,
- PR_PROVIDER_DISPLAY = PT.PT_TSTRING | 0x3006 << 16,
- PR_PROVIDER_DISPLAY_W = PT.PT_UNICODE | 0x3006 << 16,
- PR_PROVIDER_DISPLAY_A = PT.PT_STRING8 | 0x3006 << 16,
- PR_CREATION_TIME = PT.PT_SYSTIME | 0x3007 << 16,
- PR_LAST_MODIFICATION_TIME = PT.PT_SYSTIME | 0x3008 << 16,
- PR_RESOURCE_FLAGS = PT.PT_LONG | 0x3009 << 16,
- PR_PROVIDER_DLL_NAME = PT.PT_TSTRING | 0x300A << 16,
- PR_PROVIDER_DLL_NAME_W = PT.PT_UNICODE | 0x300A << 16,
- PR_PROVIDER_DLL_NAME_A = PT.PT_STRING8 | 0x300A << 16,
- PR_SEARCH_KEY = PT.PT_BINARY | 0x300B << 16,
- PR_PROVIDER_UID = PT.PT_BINARY | 0x300C << 16,
- PR_PROVIDER_ORDINAL = PT.PT_LONG | 0x300D << 16,
-
- // Message store specific
- PR_DEFAULT_STORE = PT.PT_BOOLEAN | 0x3400 << 16,
- PR_STORE_SUPPORT_MASK = PT.PT_LONG | 0x340D << 16,
- PR_STORE_STATE = PT.PT_LONG | 0x340E << 16,
-
- PR_IPM_SUBTREE_SEARCH_KEY = PT.PT_BINARY | 0x3410 << 16,
- PR_IPM_OUTBOX_SEARCH_KEY = PT.PT_BINARY | 0x3411 << 16,
- PR_IPM_WASTEBASKET_SEARCH_KEY = PT.PT_BINARY | 0x3412 << 16,
- PR_IPM_SENTMAIL_SEARCH_KEY = PT.PT_BINARY | 0x3413 << 16,
- PR_MDB_PROVIDER = PT.PT_BINARY | 0x3414 << 16,
- PR_RECEIVE_FOLDER_SETTINGS = PT.PT_OBJECT | 0x3415 << 16,
-
- PR_VALID_FOLDER_MASK = PT.PT_LONG | 0x35DF << 16,
- PR_IPM_SUBTREE_ENTRYID = PT.PT_BINARY | 0x35E0 << 16,
-
- PR_IPM_OUTBOX_ENTRYID = PT.PT_BINARY | 0x35E2 << 16,
- PR_IPM_WASTEBASKET_ENTRYID = PT.PT_BINARY | 0x35E3 << 16,
- PR_IPM_SENTMAIL_ENTRYID = PT.PT_BINARY | 0x35E4 << 16,
- PR_VIEWS_ENTRYID = PT.PT_BINARY | 0x35E5 << 16,
- PR_COMMON_VIEWS_ENTRYID = PT.PT_BINARY | 0x35E6 << 16,
- PR_FINDER_ENTRYID = PT.PT_BINARY | 0x35E7 << 16,
- PR_ATTACH_CONTENT_ID = PT.PT_TSTRING | (0x3712 << 16),
- PR_ATTACH_CONTENT_ID_A = PT.PT_STRING8 | (0x3712 << 16),
- PR_ATTACH_CONTENT_ID_W = PT.PT_TSTRING | (0x3712 << 16),
- PR_ATTACH_CONTENT_LOCATION = PT.PT_TSTRING | (0x3713 << 16),
- PR_ATTACH_CONTENT_LOCATION_A = PT.PT_STRING8 | (0x3713 << 16),
- PR_ATTACH_CONTENT_LOCATION_W = PT.PT_TSTRING | (0x3713 << 16),
-
- // Message non-transmittable properties
- PR_CURRENT_VERSION = PT.PT_I8 | 0x0E00 << 16,
- PR_DELETE_AFTER_SUBMIT = PT.PT_BOOLEAN | 0x0E01 << 16,
- PR_DISPLAY_BCC = PT.PT_TSTRING | 0x0E02 << 16,
- PR_DISPLAY_BCC_W = PT.PT_UNICODE | 0x0E02 << 16,
- PR_DISPLAY_BCC_A = PT.PT_STRING8 | 0x0E02 << 16,
- PR_DISPLAY_CC = PT.PT_TSTRING | 0x0E03 << 16,
- PR_DISPLAY_CC_W = PT.PT_UNICODE | 0x0E03 << 16,
- PR_DISPLAY_CC_A = PT.PT_STRING8 | 0x0E03 << 16,
- PR_DISPLAY_TO = PT.PT_TSTRING | 0x0E04 << 16,
- PR_DISPLAY_TO_W = PT.PT_UNICODE | 0x0E04 << 16,
- PR_DISPLAY_TO_A = PT.PT_STRING8 | 0x0E04 << 16,
- PR_PARENT_DISPLAY = PT.PT_TSTRING | 0x0E05 << 16,
- PR_PARENT_DISPLAY_W = PT.PT_UNICODE | 0x0E05 << 16,
- PR_PARENT_DISPLAY_A = PT.PT_STRING8 | 0x0E05 << 16,
- PR_MESSAGE_DELIVERY_TIME = PT.PT_SYSTIME | 0x0E06 << 16,
- PR_MESSAGE_FLAGS = PT.PT_LONG | 0x0E07 << 16,
- PR_MESSAGE_SIZE = PT.PT_LONG | 0x0E08 << 16,
- PR_PARENT_ENTRYID = PT.PT_BINARY | 0x0E09 << 16,
- PR_SENTMAIL_ENTRYID = PT.PT_BINARY | 0x0E0A << 16,
- PR_CORRELATE = PT.PT_BOOLEAN | 0x0E0C << 16,
- PR_CORRELATE_MTSID = PT.PT_BINARY | 0x0E0D << 16,
- PR_DISCRETE_VALUES = PT.PT_BOOLEAN | 0x0E0E << 16,
- PR_RESPONSIBILITY = PT.PT_BOOLEAN | 0x0E0F << 16,
- PR_SPOOLER_STATUS = PT.PT_LONG | 0x0E10 << 16,
- PR_TRANSPORT_STATUS = PT.PT_LONG | 0x0E11 << 16,
- PR_MESSAGE_RECIPIENTS = PT.PT_OBJECT | 0x0E12 << 16,
- PR_MESSAGE_ATTACHMENTS = PT.PT_OBJECT | 0x0E13 << 16,
- PR_SUBMIT_FLAGS = PT.PT_LONG | 0x0E14 << 16,
- PR_RECIPIENT_STATUS = PT.PT_LONG | 0x0E15 << 16,
- PR_TRANSPORT_KEY = PT.PT_LONG | 0x0E16 << 16,
- PR_MSG_STATUS = PT.PT_LONG | 0x0E17 << 16,
- PR_MESSAGE_DOWNLOAD_TIME = PT.PT_LONG | 0x0E18 << 16,
- PR_CREATION_VERSION = PT.PT_I8 | 0x0E19 << 16,
- PR_MODIFY_VERSION = PT.PT_I8 | 0x0E1A << 16,
- PR_HASATTACH = PT.PT_BOOLEAN | 0x0E1B << 16,
- PR_BODY_CRC = PT.PT_LONG | 0x0E1C << 16,
- PR_NORMALIZED_SUBJECT = PT.PT_TSTRING | 0x0E1D << 16,
- PR_NORMALIZED_SUBJECT_W = PT.PT_UNICODE | 0x0E1D << 16,
- PR_NORMALIZED_SUBJECT_A = PT.PT_STRING8 | 0x0E1D << 16,
- PR_RTF_IN_SYNC = PT.PT_BOOLEAN | 0x0E1F << 16,
- PR_ATTACH_SIZE = PT.PT_LONG | 0x0E20 << 16,
- PR_ATTACH_NUM = PT.PT_LONG | 0x0E21 << 16,
- PR_PREPROCESS = PT.PT_BOOLEAN | 0x0E22 << 16,
-
- // Message recipient properties
- PR_CONTENT_INTEGRITY_CHECK = PT.PT_BINARY | 0x0C00 << 16,
- PR_EXPLICIT_CONVERSION = PT.PT_LONG | 0x0C01 << 16,
- PR_IPM_RETURN_REQUESTED = PT.PT_BOOLEAN | 0x0C02 << 16,
- PR_MESSAGE_TOKEN = PT.PT_BINARY | 0x0C03 << 16,
- PR_NDR_REASON_CODE = PT.PT_LONG | 0x0C04 << 16,
- PR_NDR_DIAG_CODE = PT.PT_LONG | 0x0C05 << 16,
- PR_NON_RECEIPT_NOTIFICATION_REQUESTED = PT.PT_BOOLEAN | 0x0C06 << 16,
- PR_DELIVERY_POINT = PT.PT_LONG | 0x0C07 << 16,
-
- PR_ORIGINATOR_NON_DELIVERY_REPORT_REQUESTED = PT.PT_BOOLEAN | 0x0C08 << 16,
- PR_ORIGINATOR_REQUESTED_ALTERNATE_RECIPIENT = PT.PT_BINARY | 0x0C09 << 16,
- PR_PHYSICAL_DELIVERY_BUREAU_FAX_DELIVERY = PT.PT_BOOLEAN | 0x0C0A << 16,
- PR_PHYSICAL_DELIVERY_MODE = PT.PT_LONG | 0x0C0B << 16,
- PR_PHYSICAL_DELIVERY_REPORT_REQUEST = PT.PT_LONG | 0x0C0C << 16,
- PR_PHYSICAL_FORWARDING_ADDRESS = PT.PT_BINARY | 0x0C0D << 16,
- PR_PHYSICAL_FORWARDING_ADDRESS_REQUESTED = PT.PT_BOOLEAN | 0x0C0E << 16,
- PR_PHYSICAL_FORWARDING_PROHIBITED = PT.PT_BOOLEAN | 0x0C0F << 16,
- PR_PHYSICAL_RENDITION_ATTRIBUTES = PT.PT_BINARY | 0x0C10 << 16,
- PR_PROOF_OF_DELIVERY = PT.PT_BINARY | 0x0C11 << 16,
- PR_PROOF_OF_DELIVERY_REQUESTED = PT.PT_BOOLEAN | 0x0C12 << 16,
- PR_RECIPIENT_CERTIFICATE = PT.PT_BINARY | 0x0C13 << 16,
- PR_RECIPIENT_NUMBER_FOR_ADVICE = PT.PT_TSTRING | 0x0C14 << 16,
- PR_RECIPIENT_NUMBER_FOR_ADVICE_W = PT.PT_UNICODE | 0x0C14 << 16,
- PR_RECIPIENT_NUMBER_FOR_ADVICE_A = PT.PT_STRING8 | 0x0C14 << 16,
- PR_RECIPIENT_TYPE = PT.PT_LONG | 0x0C15 << 16,
- PR_REGISTERED_MAIL_TYPE = PT.PT_LONG | 0x0C16 << 16,
- PR_REPLY_REQUESTED = PT.PT_BOOLEAN | 0x0C17 << 16,
- //PR_REQUESTED_DELIVERY_METHOD = PT.PT_LONG | 0x0C18 << 16,
- PR_SENDER_ENTRYID = PT.PT_BINARY | 0x0C19 << 16,
- PR_SENDER_NAME = PT.PT_TSTRING | 0x0C1A << 16,
- PR_SENDER_NAME_W = PT.PT_UNICODE | 0x0C1A << 16,
- PR_SENDER_NAME_A = PT.PT_STRING8 | 0x0C1A << 16,
- PR_SUPPLEMENTARY_INFO = PT.PT_TSTRING | 0x0C1B << 16,
- PR_SUPPLEMENTARY_INFO_W = PT.PT_UNICODE | 0x0C1B << 16,
- PR_SUPPLEMENTARY_INFO_A = PT.PT_STRING8 | 0x0C1B << 16,
- PR_TYPE_OF_MTS_USER = PT.PT_LONG | 0x0C1C << 16,
- PR_SENDER_SEARCH_KEY = PT.PT_BINARY | 0x0C1D << 16,
- PR_SENDER_ADDRTYPE = PT.PT_TSTRING | 0x0C1E << 16,
- PR_SENDER_ADDRTYPE_W = PT.PT_UNICODE | 0x0C1E << 16,
- PR_SENDER_ADDRTYPE_A = PT.PT_STRING8 | 0x0C1E << 16,
- PR_SENDER_EMAIL_ADDRESS = PT.PT_TSTRING | 0x0C1F << 16,
- PR_SENDER_EMAIL_ADDRESS_W = PT.PT_UNICODE | 0x0C1F << 16,
- PR_SENDER_EMAIL_ADDRESS_A = PT.PT_STRING8 | 0x0C1F << 16,
-
- // Message envelope properties
- PR_ACKNOWLEDGEMENT_MODE = PT.PT_LONG | 0x0001 << 16,
- PR_ALTERNATE_RECIPIENT_ALLOWED = PT.PT_BOOLEAN | 0x0002 << 16,
- PR_AUTHORIZING_USERS = PT.PT_BINARY | 0x0003 << 16,
- PR_AUTO_FORWARD_COMMENT = PT.PT_TSTRING | 0x0004 << 16,
- PR_AUTO_FORWARD_COMMENT_W = PT.PT_UNICODE | 0x0004 << 16,
- PR_AUTO_FORWARD_COMMENT_A = PT.PT_STRING8 | 0x0004 << 16,
- PR_AUTO_FORWARDED = PT.PT_BOOLEAN | 0x0005 << 16,
- PR_CONTENT_CONFIDENTIALITY_ALGORITHM_ID = PT.PT_BINARY | 0x0006 << 16,
- PR_CONTENT_CORRELATOR = PT.PT_BINARY | 0x0007 << 16,
- PR_CONTENT_IDENTIFIER = PT.PT_TSTRING | 0x0008 << 16,
- PR_CONTENT_IDENTIFIER_W = PT.PT_UNICODE | 0x0008 << 16,
- PR_CONTENT_IDENTIFIER_A = PT.PT_STRING8 | 0x0008 << 16,
- PR_CONTENT_LENGTH = PT.PT_LONG | 0x0009 << 16,
- PR_CONTENT_RETURN_REQUESTED = PT.PT_BOOLEAN | 0x000A << 16,
-
- // Message envelope properties
- PR_CONVERSATION_KEY = PT.PT_BINARY | 0x000B << 16,
-
- PR_CONVERSION_EITS = PT.PT_BINARY | 0x000C << 16,
- PR_CONVERSION_WITH_LOSS_PROHIBITED = PT.PT_BOOLEAN | 0x000D << 16,
- PR_CONVERTED_EITS = PT.PT_BINARY | 0x000E << 16,
- PR_DEFERRED_DELIVERY_TIME = PT.PT_SYSTIME | 0x000F << 16,
- PR_DELIVER_TIME = PT.PT_SYSTIME | 0x0010 << 16,
- PR_DISCARD_REASON = PT.PT_LONG | 0x0011 << 16,
- PR_DISCLOSURE_OF_RECIPIENTS = PT.PT_BOOLEAN | 0x0012 << 16,
- PR_DL_EXPANSION_HISTORY = PT.PT_BINARY | 0x0013 << 16,
- PR_DL_EXPANSION_PROHIBITED = PT.PT_BOOLEAN | 0x0014 << 16,
- PR_EXPIRY_TIME = PT.PT_SYSTIME | 0x0015 << 16,
- PR_IMPLICIT_CONVERSION_PROHIBITED = PT.PT_BOOLEAN | 0x0016 << 16,
- PR_IMPORTANCE = PT.PT_LONG | 0x0017 << 16,
- PR_IPM_ID = PT.PT_BINARY | 0x0018 << 16,
- PR_LATEST_DELIVERY_TIME = PT.PT_SYSTIME | 0x0019 << 16,
- PR_MESSAGE_CLASS = PT.PT_TSTRING | 0x001A << 16,
- PR_MESSAGE_CLASS_W = PT.PT_UNICODE | 0x001A << 16,
- PR_MESSAGE_CLASS_A = PT.PT_STRING8 | 0x001A << 16,
- PR_MESSAGE_DELIVERY_ID = PT.PT_BINARY | 0x001B << 16,
-
- PR_MESSAGE_SECURITY_LABEL = PT.PT_BINARY | 0x001E << 16,
- PR_OBSOLETED_IPMS = PT.PT_BINARY | 0x001F << 16,
- PR_ORIGINALLY_INTENDED_RECIPIENT_NAME = PT.PT_BINARY | 0x0020 << 16,
- PR_ORIGINAL_EITS = PT.PT_BINARY | 0x0021 << 16,
- PR_ORIGINATOR_CERTIFICATE = PT.PT_BINARY | 0x0022 << 16,
- PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED = PT.PT_BOOLEAN | 0x0023 << 16,
- PR_ORIGINATOR_RETURN_ADDRESS = PT.PT_BINARY | 0x0024 << 16,
-
- PR_PARENT_KEY = PT.PT_BINARY | 0x0025 << 16,
- PR_PRIORITY = PT.PT_LONG | 0x0026 << 16,
-
- PR_ORIGIN_CHECK = PT.PT_BINARY | 0x0027 << 16,
- PR_PROOF_OF_SUBMISSION_REQUESTED = PT.PT_BOOLEAN | 0x0028 << 16,
- PR_READ_RECEIPT_REQUESTED = PT.PT_BOOLEAN | 0x0029 << 16,
- PR_RECEIPT_TIME = PT.PT_SYSTIME | 0x002A << 16,
- PR_RECIPIENT_REASSIGNMENT_PROHIBITED = PT.PT_BOOLEAN | 0x002B << 16,
- PR_REDIRECTION_HISTORY = PT.PT_BINARY | 0x002C << 16,
- PR_RELATED_IPMS = PT.PT_BINARY | 0x002D << 16,
- PR_ORIGINAL_SENSITIVITY = PT.PT_LONG | 0x002E << 16,
- PR_LANGUAGES = PT.PT_TSTRING | 0x002F << 16,
- PR_LANGUAGES_W = PT.PT_UNICODE | 0x002F << 16,
- PR_LANGUAGES_A = PT.PT_STRING8 | 0x002F << 16,
- PR_REPLY_TIME = PT.PT_SYSTIME | 0x0030 << 16,
- PR_REPORT_TAG = PT.PT_BINARY | 0x0031 << 16,
- PR_REPORT_TIME = PT.PT_SYSTIME | 0x0032 << 16,
- PR_RETURNED_IPM = PT.PT_BOOLEAN | 0x0033 << 16,
- PR_SECURITY = PT.PT_LONG | 0x0034 << 16,
- PR_INCOMPLETE_COPY = PT.PT_BOOLEAN | 0x0035 << 16,
- PR_SENSITIVITY = PT.PT_LONG | 0x0036 << 16,
- PR_SUBJECT = PT.PT_TSTRING | 0x0037 << 16,
- PR_SUBJECT_W = PT.PT_UNICODE | 0x0037 << 16,
- PR_SUBJECT_A = PT.PT_STRING8 | 0x0037 << 16,
- PR_SUBJECT_IPM = PT.PT_BINARY | 0x0038 << 16,
- PR_CLIENT_SUBMIT_TIME = PT.PT_SYSTIME | 0x0039 << 16,
- PR_REPORT_NAME = PT.PT_TSTRING | 0x003A << 16,
- PR_REPORT_NAME_W = PT.PT_UNICODE | 0x003A << 16,
- PR_REPORT_NAME_A = PT.PT_STRING8 | 0x003A << 16,
- PR_SENT_REPRESENTING_SEARCH_KEY = PT.PT_BINARY | 0x003B << 16,
- PR_X400_CONTENT_TYPE = PT.PT_BINARY | 0x003C << 16,
- PR_SUBJECT_PREFIX = PT.PT_TSTRING | 0x003D << 16,
- PR_SUBJECT_PREFIX_W = PT.PT_UNICODE | 0x003D << 16,
- PR_SUBJECT_PREFIX_A = PT.PT_STRING8 | 0x003D << 16,
- PR_NON_RECEIPT_REASON = PT.PT_LONG | 0x003E << 16,
- PR_RECEIVED_BY_ENTRYID = PT.PT_BINARY | 0x003F << 16,
- PR_RECEIVED_BY_NAME = PT.PT_TSTRING | 0x0040 << 16,
- PR_RECEIVED_BY_NAME_W = PT.PT_UNICODE | 0x0040 << 16,
- PR_RECEIVED_BY_NAME_A = PT.PT_STRING8 | 0x0040 << 16,
- PR_SENT_REPRESENTING_ENTRYID = PT.PT_BINARY | 0x0041 << 16,
- PR_SENT_REPRESENTING_NAME = PT.PT_TSTRING | 0x0042 << 16,
- PR_SENT_REPRESENTING_NAME_W = PT.PT_UNICODE | 0x0042 << 16,
- PR_SENT_REPRESENTING_NAME_A = PT.PT_STRING8 | 0x0042 << 16,
- PR_RCVD_REPRESENTING_ENTRYID = PT.PT_BINARY | 0x0043 << 16,
- PR_RCVD_REPRESENTING_NAME = PT.PT_TSTRING | 0x0044 << 16,
- PR_RCVD_REPRESENTING_NAME_W = PT.PT_UNICODE | 0x0044 << 16,
- PR_RCVD_REPRESENTING_NAME_A = PT.PT_STRING8 | 0x0044 << 16,
- PR_REPORT_ENTRYID = PT.PT_BINARY | 0x0045 << 16,
- PR_READ_RECEIPT_ENTRYID = PT.PT_BINARY | 0x0046 << 16,
- PR_MESSAGE_SUBMISSION_ID = PT.PT_BINARY | 0x0047 << 16,
- PR_PROVIDER_SUBMIT_TIME = PT.PT_SYSTIME | 0x0048 << 16,
- PR_ORIGINAL_SUBJECT = PT.PT_TSTRING | 0x0049 << 16,
- PR_ORIGINAL_SUBJECT_W = PT.PT_UNICODE | 0x0049 << 16,
- PR_ORIGINAL_SUBJECT_A = PT.PT_STRING8 | 0x0049 << 16,
- PR_DISC_VAL = PT.PT_BOOLEAN | 0x004A << 16,
- PR_ORIG_MESSAGE_CLASS = PT.PT_TSTRING | 0x004B << 16,
- PR_ORIG_MESSAGE_CLASS_W = PT.PT_UNICODE | 0x004B << 16,
- PR_ORIG_MESSAGE_CLASS_A = PT.PT_STRING8 | 0x004B << 16,
- PR_ORIGINAL_AUTHOR_ENTRYID = PT.PT_BINARY | 0x004C << 16,
- PR_ORIGINAL_AUTHOR_NAME = PT.PT_TSTRING | 0x004D << 16,
- PR_ORIGINAL_AUTHOR_NAME_W = PT.PT_UNICODE | 0x004D << 16,
- PR_ORIGINAL_AUTHOR_NAME_A = PT.PT_STRING8 | 0x004D << 16,
- PR_ORIGINAL_SUBMIT_TIME = PT.PT_SYSTIME | 0x004E << 16,
- PR_REPLY_RECIPIENT_ENTRIES = PT.PT_BINARY | 0x004F << 16,
- PR_REPLY_RECIPIENT_NAMES = PT.PT_TSTRING | 0x0050 << 16,
- PR_REPLY_RECIPIENT_NAMES_W = PT.PT_UNICODE | 0x0050 << 16,
- PR_REPLY_RECIPIENT_NAMES_A = PT.PT_STRING8 | 0x0050 << 16,
-
- PR_RECEIVED_BY_SEARCH_KEY = PT.PT_BINARY | 0x0051 << 16,
- PR_RCVD_REPRESENTING_SEARCH_KEY = PT.PT_BINARY | 0x0052 << 16,
- PR_READ_RECEIPT_SEARCH_KEY = PT.PT_BINARY | 0x0053 << 16,
- PR_REPORT_SEARCH_KEY = PT.PT_BINARY | 0x0054 << 16,
- PR_ORIGINAL_DELIVERY_TIME = PT.PT_SYSTIME | 0x0055 << 16,
- PR_ORIGINAL_AUTHOR_SEARCH_KEY = PT.PT_BINARY | 0x0056 << 16,
-
- PR_MESSAGE_TO_ME = PT.PT_BOOLEAN | 0x0057 << 16,
- PR_MESSAGE_CC_ME = PT.PT_BOOLEAN | 0x0058 << 16,
- PR_MESSAGE_RECIP_ME = PT.PT_BOOLEAN | 0x0059 << 16,
-
- PR_ORIGINAL_SENDER_NAME = PT.PT_TSTRING | 0x005A << 16,
- PR_ORIGINAL_SENDER_NAME_W = PT.PT_UNICODE | 0x005A << 16,
- PR_ORIGINAL_SENDER_NAME_A = PT.PT_STRING8 | 0x005A << 16,
- PR_ORIGINAL_SENDER_ENTRYID = PT.PT_BINARY | 0x005B << 16,
- PR_ORIGINAL_SENDER_SEARCH_KEY = PT.PT_BINARY | 0x005C << 16,
- PR_ORIGINAL_SENT_REPRESENTING_NAME = PT.PT_TSTRING | 0x005D << 16,
- PR_ORIGINAL_SENT_REPRESENTING_NAME_W = PT.PT_UNICODE | 0x005D << 16,
- PR_ORIGINAL_SENT_REPRESENTING_NAME_A = PT.PT_STRING8 | 0x005D << 16,
- PR_ORIGINAL_SENT_REPRESENTING_ENTRYID = PT.PT_BINARY | 0x005E << 16,
- PR_ORIGINAL_SENT_REPRESENTING_SEARCH_KEY = PT.PT_BINARY | 0x005F << 16,
-
- PR_START_DATE = PT.PT_SYSTIME | 0x0060 << 16,
- PR_END_DATE = PT.PT_SYSTIME | 0x0061 << 16,
- PR_OWNER_APPT_ID = PT.PT_LONG | 0x0062 << 16,
- //PR_RESPONSE_REQUESTED = PT.PT_BOOLEAN | 0x0063 << 16,
-
- PR_SENT_REPRESENTING_ADDRTYPE = PT.PT_TSTRING | 0x0064 << 16,
- PR_SENT_REPRESENTING_ADDRTYPE_W = PT.PT_UNICODE | 0x0064 << 16,
- PR_SENT_REPRESENTING_ADDRTYPE_A = PT.PT_STRING8 | 0x0064 << 16,
- PR_SENT_REPRESENTING_EMAIL_ADDRESS = PT.PT_TSTRING | 0x0065 << 16,
- PR_SENT_REPRESENTING_EMAIL_ADDRESS_W = PT.PT_UNICODE | 0x0065 << 16,
- PR_SENT_REPRESENTING_EMAIL_ADDRESS_A = PT.PT_STRING8 | 0x0065 << 16,
-
- PR_ORIGINAL_SENDER_ADDRTYPE = PT.PT_TSTRING | 0x0066 << 16,
- PR_ORIGINAL_SENDER_ADDRTYPE_W = PT.PT_UNICODE | 0x0066 << 16,
- PR_ORIGINAL_SENDER_ADDRTYPE_A = PT.PT_STRING8 | 0x0066 << 16,
- PR_ORIGINAL_SENDER_EMAIL_ADDRESS = PT.PT_TSTRING | 0x0067 << 16,
- PR_ORIGINAL_SENDER_EMAIL_ADDRESS_W = PT.PT_UNICODE | 0x0067 << 16,
- PR_ORIGINAL_SENDER_EMAIL_ADDRESS_A = PT.PT_STRING8 | 0x0067 << 16,
-
- PR_ORIGINAL_SENT_REPRESENTING_ADDRTYPE = PT.PT_TSTRING | 0x0068 << 16,
- PR_ORIGINAL_SENT_REPRESENTING_ADDRTYPE_W = PT.PT_UNICODE | 0x0068 << 16,
- PR_ORIGINAL_SENT_REPRESENTING_ADDRTYPE_A = PT.PT_STRING8 | 0x0068 << 16,
- PR_ORIGINAL_SENT_REPRESENTING_EMAIL_ADDRESS = PT.PT_TSTRING | 0x0069 << 16,
- PR_ORIGINAL_SENT_REPRESENTING_EMAIL_ADDRESS_W = PT.PT_UNICODE | 0x0069 << 16,
- PR_ORIGINAL_SENT_REPRESENTING_EMAIL_ADDRESS_A = PT.PT_STRING8 | 0x0069 << 16,
-
- PR_CONVERSATION_TOPIC = PT.PT_TSTRING | 0x0070 << 16,
- PR_CONVERSATION_TOPIC_W = PT.PT_UNICODE | 0x0070 << 16,
- PR_CONVERSATION_TOPIC_A = PT.PT_STRING8 | 0x0070 << 16,
- PR_CONVERSATION_INDEX = PT.PT_BINARY | 0x0071 << 16,
-
- PR_ORIGINAL_DISPLAY_BCC = PT.PT_TSTRING | 0x0072 << 16,
- PR_ORIGINAL_DISPLAY_BCC_W = PT.PT_UNICODE | 0x0072 << 16,
- PR_ORIGINAL_DISPLAY_BCC_A = PT.PT_STRING8 | 0x0072 << 16,
- PR_ORIGINAL_DISPLAY_CC = PT.PT_TSTRING | 0x0073 << 16,
- PR_ORIGINAL_DISPLAY_CC_W = PT.PT_UNICODE | 0x0073 << 16,
- PR_ORIGINAL_DISPLAY_CC_A = PT.PT_STRING8 | 0x0073 << 16,
- PR_ORIGINAL_DISPLAY_TO = PT.PT_TSTRING | 0x0074 << 16,
- PR_ORIGINAL_DISPLAY_TO_W = PT.PT_UNICODE | 0x0074 << 16,
- PR_ORIGINAL_DISPLAY_TO_A = PT.PT_STRING8 | 0x0074 << 16,
-
- PR_RECEIVED_BY_ADDRTYPE = PT.PT_TSTRING | 0x0075 << 16,
- PR_RECEIVED_BY_ADDRTYPE_W = PT.PT_UNICODE | 0x0075 << 16,
- PR_RECEIVED_BY_ADDRTYPE_A = PT.PT_STRING8 | 0x0075 << 16,
- PR_RECEIVED_BY_EMAIL_ADDRESS = PT.PT_TSTRING | 0x0076 << 16,
- PR_RECEIVED_BY_EMAIL_ADDRESS_W = PT.PT_UNICODE | 0x0076 << 16,
- PR_RECEIVED_BY_EMAIL_ADDRESS_A = PT.PT_STRING8 | 0x0076 << 16,
-
- PR_RCVD_REPRESENTING_ADDRTYPE = PT.PT_TSTRING | 0x0077 << 16,
- PR_RCVD_REPRESENTING_ADDRTYPE_W = PT.PT_UNICODE | 0x0077 << 16,
- PR_RCVD_REPRESENTING_ADDRTYPE_A = PT.PT_STRING8 | 0x0077 << 16,
- PR_RCVD_REPRESENTING_EMAIL_ADDRESS = PT.PT_TSTRING | 0x0078 << 16,
- PR_RCVD_REPRESENTING_EMAIL_ADDRESS_W = PT.PT_UNICODE | 0x0078 << 16,
- PR_RCVD_REPRESENTING_EMAIL_ADDRESS_A = PT.PT_STRING8 | 0x0078 << 16,
-
- PR_ORIGINAL_AUTHOR_ADDRTYPE = PT.PT_TSTRING | 0x0079 << 16,
- PR_ORIGINAL_AUTHOR_ADDRTYPE_W = PT.PT_UNICODE | 0x0079 << 16,
- PR_ORIGINAL_AUTHOR_ADDRTYPE_A = PT.PT_STRING8 | 0x0079 << 16,
- PR_ORIGINAL_AUTHOR_EMAIL_ADDRESS = PT.PT_TSTRING | 0x007A << 16,
- PR_ORIGINAL_AUTHOR_EMAIL_ADDRESS_W = PT.PT_UNICODE | 0x007A << 16,
- PR_ORIGINAL_AUTHOR_EMAIL_ADDRESS_A = PT.PT_STRING8 | 0x007A << 16,
-
- PR_ORIGINALLY_INTENDED_RECIP_ADDRTYPE = PT.PT_TSTRING | 0x007B << 16,
- PR_ORIGINALLY_INTENDED_RECIP_ADDRTYPE_W = PT.PT_UNICODE | 0x007B << 16,
- PR_ORIGINALLY_INTENDED_RECIP_ADDRTYPE_A = PT.PT_STRING8 | 0x007B << 16,
- PR_ORIGINALLY_INTENDED_RECIP_EMAIL_ADDRESS = PT.PT_TSTRING | 0x007C << 16,
- PR_ORIGINALLY_INTENDED_RECIP_EMAIL_ADDRESS_W = PT.PT_UNICODE | 0x007C << 16,
- PR_ORIGINALLY_INTENDED_RECIP_EMAIL_ADDRESS_A = PT.PT_STRING8 | 0x007C << 16,
-
- PR_TRANSPORT_MESSAGE_HEADERS = PT.PT_TSTRING | 0x007D << 16,
- PR_TRANSPORT_MESSAGE_HEADERS_W = PT.PT_UNICODE | 0x007D << 16,
- PR_TRANSPORT_MESSAGE_HEADERS_A = PT.PT_STRING8 | 0x007D << 16,
-
- PR_DELEGATION = PT.PT_BINARY | 0x007E << 16,
-
- PR_TNEF_CORRELATION_KEY = PT.PT_BINARY | 0x007F << 16,
-
- // Message content properties
- PR_BODY = PT.PT_TSTRING | 0x1000 << 16,
- PR_BODY_W = PT.PT_UNICODE | 0x1000 << 16,
- PR_BODY_A = PT.PT_STRING8 | 0x1000 << 16,
- PR_REPORT_TEXT = PT.PT_TSTRING | 0x1001 << 16,
- PR_REPORT_TEXT_W = PT.PT_UNICODE | 0x1001 << 16,
- PR_REPORT_TEXT_A = PT.PT_STRING8 | 0x1001 << 16,
- PR_ORIGINATOR_AND_DL_EXPANSION_HISTORY = PT.PT_BINARY | 0x1002 << 16,
- PR_REPORTING_DL_NAME = PT.PT_BINARY | 0x1003 << 16,
- PR_REPORTING_MTA_CERTIFICATE = PT.PT_BINARY | 0x1004 << 16,
- };
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Interoperability", "CA1401:PInvokesShouldNotBeVisible")]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
- public class OutlookUtils {
- private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OutlookUtils));
- private const uint KEEP_OPEN_READWRITE = 0x00000002;
-
- // The Interface ID's are used to retrieve the specific MAPI Interfaces from the IUnknown Object
- public const string IID_IMAPISession = "00020300-0000-0000-C000-000000000046";
- public const string IID_IMAPIProp = "00020303-0000-0000-C000-000000000046";
- public const string IID_IMAPITable = "00020301-0000-0000-C000-000000000046";
- public const string IID_IMAPIMsgStore = "00020306-0000-0000-C000-000000000046";
- public const string IID_IMAPIFolder = "0002030C-0000-0000-C000-000000000046";
- public const string IID_IMAPISpoolerService = "0002031E-0000-0000-C000-000000000046";
- public const string IID_IMAPIStatus = "0002031E-0000-0000-C000-000000000046";
- public const string IID_IMessage = "00020307-0000-0000-C000-000000000046";
- public const string IID_IAddrBook = "00020309-0000-0000-C000-000000000046";
- public const string IID_IProfSect = "00020304-0000-0000-C000-000000000046";
- public const string IID_IMAPIContainer = "0002030B-0000-0000-C000-000000000046";
- public const string IID_IABContainer = "0002030D-0000-0000-C000-000000000046";
- public const string IID_IMsgServiceAdmin = "0002031D-0000-0000-C000-000000000046";
- public const string IID_IProfAdmin = "0002031C-0000-0000-C000-000000000046";
- public const string IID_IMailUser = "0002030A-0000-0000-C000-000000000046";
- public const string IID_IDistList = "0002030E-0000-0000-C000-000000000046";
- public const string IID_IAttachment = "00020308-0000-0000-C000-000000000046";
- public const string IID_IMAPIControl = "0002031B-0000-0000-C000-000000000046";
- public const string IID_IMAPILogonRemote = "00020346-0000-0000-C000-000000000046";
- public const string IID_IMAPIForm = "00020327-0000-0000-C000-000000000046";
-
- [ComVisible(false)]
- [ComImport()]
- [Guid(IID_IMAPIProp)]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- private interface IMessage : IMAPIProp {
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int GetAttachmentTable();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int OpenAttach();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int CreateAttach();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int DeleteAttach();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int GetRecipientTable();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int ModifyRecipients();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int SubmitMessage();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int SetReadFlag();
- }
- // [ComVisible(false)]
- // [ComImport()]
- // [Guid(IID_IMAPIFolder)]
- // [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- // interface IMAPIFolder : IMAPIContainer {
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int CreateMessage(IntPtr interf, uint uFlags, [MarshalAs(UnmanagedType.Interface)] ref IMessage pMsg);
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int CopyMessages();
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int CreateFolder();
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int CopyFolder();
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int DeleteFolder();
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int SetReadFlags();
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int GetMessageStatus();
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int SetMessageStatus();
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int SaveContentsSort();
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int EmptyFolder();
- // }
- // [ComVisible(false)]
- // [ComImport()]
- // [Guid(IID_IMAPIContainer)]
- // [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- // interface IMAPIContainer : IMAPIProp {
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int GetContentsTable(uint uFlags, [MarshalAs(UnmanagedType.Interface), Out] out outlook.Table tbl);
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int GetHierarchyTable();
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int OpenEntry();
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int SetSearchCriteria();
- // [return: MarshalAs(UnmanagedType.I4)]
- // [PreserveSig]
- // int GetSearchCriteria();
- // }
-
- [ComVisible(false)]
- [ComImport()]
- [Guid(IID_IMAPIProp)]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- private interface IMAPIProp {
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int GetLastError();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int SaveChanges(
- uint uFlags
- );
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int GetProps();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int GetPropList();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int OpenProperty();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int SetProps(uint values, IntPtr propArray, IntPtr problems);
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int DeleteProps();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int CopyTo();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int CopyProps();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int GetNamesFromIDs();
- [return: MarshalAs(UnmanagedType.I4)]
- [PreserveSig]
- int GetIDsFromNames();
- }
-
- [StructLayout(LayoutKind.Explicit)]
- private struct SPropValue {
- [FieldOffset(0)]
- public uint propTag;
- [FieldOffset(4)]
- public readonly uint alignPad;
- [FieldOffset(8)]
- public IntPtr Value;
- [FieldOffset(8)]
- public readonly long filler;
- }
-
- ///
- /// Tries to save the changes we just made
- ///
- ///
- ///
- public static bool SaveChanges(MailItem mailItem) {
- // Pointer to IUnknown Interface
- IntPtr IUnknown = IntPtr.Zero;
- // Pointer to IMAPIProp Interface
- IntPtr IMAPIProp = IntPtr.Zero;
- // if we have no MAPIObject everything is senseless...
- if (mailItem == null) {
- return false;
- }
-
- try {
- // We can pass NULL here as parameter, so we do it.
- MAPIInitialize(IntPtr.Zero);
- // retrive the IUnknon Interface from our MAPIObject comming from Outlook.
- IUnknown = Marshal.GetIUnknownForObject(mailItem.MAPIOBJECT);
-
- // create a Guid that we pass to retreive the IMAPIProp Interface.
- Guid guidIMAPIProp = new Guid(IID_IMAPIProp);
-
- // try to retrieve the IMAPIProp interface from IMessage Interface, everything else is sensless.
- if (Marshal.QueryInterface(IUnknown, ref guidIMAPIProp, out IMAPIProp) != 0) {
- return false;
- }
- IMAPIProp mapiProp = (IMAPIProp)Marshal.GetTypedObjectForIUnknown(IUnknown, typeof(IMAPIProp));
- return (mapiProp.SaveChanges(KEEP_OPEN_READWRITE) == 0);
- } catch (Exception ex) {
- LOG.Error(ex);
- return false;
- } finally {
- // cleanup all references to COM Objects
- if (IMAPIProp != IntPtr.Zero) Marshal.Release(IMAPIProp);
- //if (IMessage != IntPtr.Zero) Marshal.Release(IMessage);
- if (IUnknown != IntPtr.Zero) Marshal.Release(IUnknown);
- }
- }
-
- ///
- /// Uses the IMAPIPROP.SetProps to set the content ID
- ///
- ///
- ///
- public static void SetContentID(IAttachment attachment, string contentId) {
- // Pointer to IUnknown Interface
- IntPtr IUnknown = IntPtr.Zero;
- // Pointer to IMAPIProp Interface
- IntPtr IMAPIProp = IntPtr.Zero;
- // A pointer that points to the SPropValue structure
- IntPtr ptrPropValue = IntPtr.Zero;
- // Structure that will hold the Property Value
- SPropValue propValue;
- // if we have no MAPIObject everything is senseless...
- if (attachment == null) {
- return;
- }
-
- try {
- // We can pass NULL here as parameter, so we do it.
- MAPIInitialize(IntPtr.Zero);
-
- // retrive the IUnknon Interface from our MAPIObject comming from Outlook.
- IUnknown = Marshal.GetIUnknownForObject(attachment.MAPIOBJECT);
- IMAPIProp mapiProp = (IMAPIProp)Marshal.GetTypedObjectForIUnknown(IUnknown, typeof(IMAPIProp));
-
- // Create structure
- propValue = new SPropValue
- {
- propTag = (uint)PropTags.PR_ATTACH_CONTENT_ID,
- //propValue.propTag = 0x3712001E;
- // Create Ansi string
- Value = Marshal.StringToHGlobalUni(contentId)
- };
-
- // Create unmanaged memory for structure
- ptrPropValue = Marshal.AllocHGlobal(Marshal.SizeOf(propValue));
- // Copy structure to unmanged memory
- Marshal.StructureToPtr(propValue, ptrPropValue, false);
- mapiProp.SetProps(1, ptrPropValue, IntPtr.Zero);
-
- propValue.propTag = (uint)PropTags.PR_ATTACH_CONTENT_LOCATION;
- // Copy structure to unmanged memory
- Marshal.StructureToPtr(propValue, ptrPropValue, false);
- mapiProp.SetProps(1, ptrPropValue, IntPtr.Zero);
-
-
- // Free string
- Marshal.FreeHGlobal(propValue.Value);
- mapiProp.SaveChanges(KEEP_OPEN_READWRITE);
- } catch (Exception ex) {
- LOG.Error(ex);
- } finally {
- // Free used Memory structures
- if (ptrPropValue != IntPtr.Zero) Marshal.FreeHGlobal(ptrPropValue);
- // cleanup all references to COM Objects
- if (IMAPIProp != IntPtr.Zero) Marshal.Release(IMAPIProp);
- //if (IMessage != IntPtr.Zero) Marshal.Release(IMessage);
- if (IUnknown != IntPtr.Zero) Marshal.Release(IUnknown);
- }
- }
-
- ///
- /// Use MAPI32.DLL "HrSetOneProp" from managed code
- ///
- ///
- ///
- ///
- ///
- public static bool SetMAPIProperty(IAttachment attachment, PropTags proptag, string propertyValue) {
- // Pointer to IUnknown Interface
- IntPtr IUnknown = IntPtr.Zero;
- // Pointer to IMAPIProp Interface
- IntPtr IMAPIProp = IntPtr.Zero;
- // Structure that will hold the Property Value
- SPropValue propValue;
- // A pointer that points to the SPropValue structure
- IntPtr ptrPropValue = IntPtr.Zero;
- object mapiObject = attachment.MAPIOBJECT;
- // if we have no MAPIObject everything is senseless...
- if (mapiObject == null) {
- return false;
- }
-
- try {
- // We can pass NULL here as parameter, so we do it.
- MAPIInitialize(IntPtr.Zero);
-
- // retrive the IUnknon Interface from our MAPIObject comming from Outlook.
- IUnknown = Marshal.GetIUnknownForObject(mapiObject);
-
- // create a Guid that we pass to retreive the IMAPIProp Interface.
- Guid guidIMAPIProp = new Guid(IID_IMAPIProp);
-
- // try to retrieve the IMAPIProp interface from IMessage Interface, everything else is sensless.
- if (Marshal.QueryInterface(IUnknown, ref guidIMAPIProp, out IMAPIProp) != 0) {
- return false;
- }
-
- // double check, if we wave no pointer, exit...
- if (IMAPIProp == IntPtr.Zero) {
- return false;
- }
-
- // Create structure
- propValue = new SPropValue
- {
- propTag = (uint)proptag,
- // Create Ansi string
- Value = Marshal.StringToHGlobalUni(propertyValue)
- };
-
- // Create unmanaged memory for structure
- ptrPropValue = Marshal.AllocHGlobal(Marshal.SizeOf(propValue));
- // Copy structure to unmanged memory
- Marshal.StructureToPtr(propValue, ptrPropValue, false);
-
- // Set the property
- HrSetOneProp(IMAPIProp, ptrPropValue);
-
- // Free string
- Marshal.FreeHGlobal(propValue.Value);
- IMAPIProp mapiProp = (IMAPIProp)Marshal.GetTypedObjectForIUnknown(IUnknown, typeof(IMAPIProp));
- return mapiProp.SaveChanges(4) == 0;
- } catch (Exception ex) {
- LOG.Error(ex);
- return false;
- } finally {
- // Free used Memory structures
- if (ptrPropValue != IntPtr.Zero) Marshal.FreeHGlobal(ptrPropValue);
- // cleanup all references to COM Objects
- if (IMAPIProp != IntPtr.Zero) Marshal.Release(IMAPIProp);
- //if (IMessage != IntPtr.Zero) Marshal.Release(IMessage);
- if (IUnknown != IntPtr.Zero) Marshal.Release(IUnknown);
- MAPIUninitialize();
- }
- }
-
- [DllImport("MAPI32.DLL", EntryPoint = "HrSetOneProp@8")]
- private static extern void HrSetOneProp(IntPtr pmp, IntPtr pprop);
-
- [DllImport("MAPI32.DLL")]
- private static extern int MAPIInitialize(IntPtr lpMapiInit);
-
- [DllImport("MAPI32.DLL")]
- private static extern void MAPIUninitialize();
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/PropTag.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/PropTag.cs
deleted file mode 100644
index 4e7ccd37c..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/PropTag.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook {
- ///
- /// Schema definitions for the MAPI properties
- /// See: http://msdn.microsoft.com/en-us/library/aa454438.aspx
- /// and see: http://msdn.microsoft.com/en-us/library/bb446117.aspx
- ///
- public static class PropTag {
- public const string ATTACHMENT_CONTENT_ID = @"http://schemas.microsoft.com/mapi/proptag/0x3712001E";
- }
-}
diff --git a/GreenshotOfficePlugin/OfficeInterop/Outlook/WdUnits.cs b/GreenshotOfficePlugin/OfficeInterop/Outlook/WdUnits.cs
deleted file mode 100644
index 31fd6f018..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Outlook/WdUnits.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Outlook
-{
- ///
- /// Units: http://msdn.microsoft.com/en-us/library/office/bb214015(v=office.12).aspx
- ///
- public enum WdUnits {
- wdCell = 12,
- wdCharacter = 1,
- wdCharacterFormatting = 13,
- wdColumn = 9,
- wdItem = 16,
- wdLine = 5,
- wdParagraph = 4,
- wdParagraphFormatting = 14,
- wdRow = 10,
- wdScreen = 7,
- wdSection = 8,
- wdSentence = 3,
- wdStory = 6,
- wdTable = 15,
- wdWindow = 11,
- wdWord = 2
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPageSetup.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPageSetup.cs
deleted file mode 100644
index 8edaf679f..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPageSetup.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.pagesetup_members.aspx
- ///
- public interface IPageSetup : ICommon, ICollection {
- float SlideWidth { get; set; }
- float SlideHeight { get; set; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPowerpointApplication.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPowerpointApplication.cs
deleted file mode 100644
index b79583e3f..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPowerpointApplication.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint {
- ///
- /// See http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.application_members.aspx
- ///
- [ComProgId("Powerpoint.Application")]
- public interface IPowerpointApplication : ICommon {
- IPresentation ActivePresentation { get; }
- IPresentations Presentations { get; }
- bool Visible { get; set; }
- void Activate();
- IPowerpointWindow ActiveWindow { get; }
- string Version { get; }
- }
-}
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPowerpointView.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPowerpointView.cs
deleted file mode 100644
index 59e066b7f..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPowerpointView.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using GreenshotOfficePlugin.OfficeInterop.Word;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.view_members.aspx
- ///
- public interface IPowerpointView : ICommon {
- IZoom Zoom { get; }
- void GotoSlide(int index);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPowerpointWindow.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPowerpointWindow.cs
deleted file mode 100644
index f26a882bd..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPowerpointWindow.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.documentwindow.view.aspx
- ///
- public interface IPowerpointWindow : ICommon {
- void Activate();
- IPowerpointView View { get; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPresentation.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPresentation.cs
deleted file mode 100644
index 6f63e3bcf..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPresentation.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using GreenshotOfficePlugin.OfficeInterop.Outlook;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.presentation_members.aspx
- ///
- public interface IPresentation : ICommon {
- string Name { get; }
- ISlides Slides { get; }
- IPowerpointApplication Application { get; }
- MsoTriState ReadOnly { get; }
- bool Final { get; set; }
- IPageSetup PageSetup { get; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPresentations.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPresentations.cs
deleted file mode 100644
index 473d7361b..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IPresentations.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using GreenshotOfficePlugin.OfficeInterop.Outlook;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.presentations_members.aspx
- ///
- public interface IPresentations : ICommon, ICollection {
- IPresentation Add(MsoTriState WithWindow);
- IPresentation item(int index);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IShape.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IShape.cs
deleted file mode 100644
index 0dc25adbe..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IShape.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using GreenshotOfficePlugin.OfficeInterop.Outlook;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shape_members.aspx
- ///
- public interface IShape : ICommon {
- float Left { get; set; }
- float Top { get; set; }
- float Width { get; set; }
- float Height { get; set; }
- ITextFrame TextFrame { get; }
- void ScaleWidth(float Factor, MsoTriState RelativeToOriginalSize, MsoScaleFrom fScale);
- void ScaleHeight(float Factor, MsoTriState RelativeToOriginalSize, MsoScaleFrom fScale);
- string AlternativeText { get; set; }
- MsoTriState LockAspectRatio { get; set; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IShapes.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IShapes.cs
deleted file mode 100644
index c0dcbe469..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/IShapes.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.Collections;
-using GreenshotOfficePlugin.OfficeInterop.Outlook;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shapes_members.aspx
- ///
- public interface IShapes : ICommon, IEnumerable {
- int Count { get; }
- IShape item(int index);
- IShape AddPicture(string FileName, MsoTriState LinkToFile, MsoTriState SaveWithDocument, float Left, float Top, float Width, float Height);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/ISlide.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/ISlide.cs
deleted file mode 100644
index d50b2797b..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/ISlide.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slide_members.aspx
- ///
- public interface ISlide : ICommon {
- IShapes Shapes { get; }
- void Select();
- int SlideNumber { get; }
-
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/ISlides.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/ISlides.cs
deleted file mode 100644
index 8bcfa35c7..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/ISlides.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slides_members.aspx
- ///
- public interface ISlides : ICommon {
- int Count { get; }
- ISlide Add(int Index, int layout);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/ITextFrame.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/ITextFrame.cs
deleted file mode 100644
index fe3f0b5bc..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/ITextFrame.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using GreenshotOfficePlugin.OfficeInterop.Outlook;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
-{
- public interface ITextFrame : ICommon {
- ITextRange TextRange { get; }
- MsoTriState HasText { get; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/ITextRange.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/ITextRange.cs
deleted file mode 100644
index df11cf3a9..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/ITextRange.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
-{
- public interface ITextRange : ICommon {
- string Text { get; set; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/PPSlideLayout.cs b/GreenshotOfficePlugin/OfficeInterop/Powerpoint/PPSlideLayout.cs
deleted file mode 100644
index 371b749c7..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Powerpoint/PPSlideLayout.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
-{
- public enum PPSlideLayout : int {
- ppLayoutMixed = -2,
- ppLayoutTitle = 1,
- ppLayoutText = 2,
- ppLayoutTwoColumnText = 3,
- ppLayoutTable = 4,
- ppLayoutTextAndChart = 5,
- ppLayoutChartAndText = 6,
- ppLayoutOrgchart = 7,
- ppLayoutChart = 8,
- ppLayoutTextAndClipart = 9,
- ppLayoutClipartAndText = 10,
- ppLayoutTitleOnly = 11,
- ppLayoutBlank = 12,
- ppLayoutTextAndObject = 13,
- ppLayoutObjectAndText = 14,
- ppLayoutLargeObject = 15,
- ppLayoutObject = 16,
- ppLayoutTextAndMediaClip = 17,
- ppLayoutMediaClipAndText = 18,
- ppLayoutObjectOverText = 19,
- ppLayoutTextOverObject = 20,
- ppLayoutTextAndTwoObjects = 21,
- ppLayoutTwoObjectsAndText = 22,
- ppLayoutTwoObjectsOverText = 23,
- ppLayoutFourObjects = 24,
- ppLayoutVerticalText = 25,
- ppLayoutClipArtAndVerticalText = 26,
- ppLayoutVerticalTitleAndText = 27,
- ppLayoutVerticalTitleAndTextOverChart = 28,
- ppLayoutTwoObjects = 29,
- ppLayoutObjectAndTwoObjects = 30,
- ppLayoutTwoObjectsAndObject = 31,
- ppLayoutCustom = 32,
- ppLayoutSectionHeader = 33,
- ppLayoutComparison = 34,
- ppLayoutContentWithCaption = 35,
- ppLayoutPictureWithCaption = 36
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Word/IDocuments.cs b/GreenshotOfficePlugin/OfficeInterop/Word/IDocuments.cs
deleted file mode 100644
index 12abf919c..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Word/IDocuments.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Word
-{
- ///
- /// See: http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.documents_members(v=office.11).aspx
- ///
- public interface IDocuments : ICommon, ICollection {
- IWordDocument Add(ref object Template, ref object NewTemplate, ref object DocumentType, ref object Visible);
- IWordDocument item(int index);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Word/IHyperlink.cs b/GreenshotOfficePlugin/OfficeInterop/Word/IHyperlink.cs
deleted file mode 100644
index 9a2bc5cc2..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Word/IHyperlink.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Word
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.hyperlink_members%28v=office.14%29.aspx
- ///
- public interface IHyperlink : ICommon {
- string Address {
- get;
- set;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Word/IHyperlinks.cs b/GreenshotOfficePlugin/OfficeInterop/Word/IHyperlinks.cs
deleted file mode 100644
index 285154d85..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Word/IHyperlinks.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Word
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.hyperlinks%28v=office.14%29.aspx
- ///
- public interface IHyperlinks : ICommon, ICollection {
- IHyperlink Add(object Anchor, object Address, object SubAddress, object ScreenTip, object TextToDisplay, object Target);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Word/IInlineShape.cs b/GreenshotOfficePlugin/OfficeInterop/Word/IInlineShape.cs
deleted file mode 100644
index 5011821e2..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Word/IInlineShape.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using GreenshotOfficePlugin.OfficeInterop.Outlook;
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Word
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.inlineshape_members%28v=office.14%29.aspx
- ///
- public interface IInlineShape : ICommon {
- IHyperlink Hyperlink { get; }
- MsoTriState LockAspectRatio {
- get;
- set;
- }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Word/IInlineShapes.cs b/GreenshotOfficePlugin/OfficeInterop/Word/IInlineShapes.cs
deleted file mode 100644
index 7d9c7c003..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Word/IInlineShapes.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Word
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/ms263866%28v=office.14%29.aspx
- ///
- public interface IInlineShapes : ICommon {
- IInlineShape AddPicture(string FileName, object LinkToFile, object SaveWithDocument, object Range);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Word/IPane.cs b/GreenshotOfficePlugin/OfficeInterop/Word/IPane.cs
deleted file mode 100644
index f90808cb1..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Word/IPane.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Word
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.pane_members.aspx
- ///
- public interface IPane : ICommon {
- IWordView View { get; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Word/ISelection.cs b/GreenshotOfficePlugin/OfficeInterop/Word/ISelection.cs
deleted file mode 100644
index 4ddbe749d..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Word/ISelection.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Word
-{
- ///
- /// See: http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.selection_members(v=office.11).aspx
- ///
- public interface ISelection : ICommon {
- IInlineShapes InlineShapes { get; }
- void InsertAfter(string text);
- int MoveDown(object Unit, object Count, object Extend);
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Word/IWordApplication.cs b/GreenshotOfficePlugin/OfficeInterop/Word/IWordApplication.cs
deleted file mode 100644
index 2bc1fffdd..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Word/IWordApplication.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
- *
- * For more information see: http://getgreenshot.org/
- * The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Word {
- // See http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.applicationclass_members%28v=Office.11%29.aspx
- [ComProgId("Word.Application")]
- public interface IWordApplication : ICommon {
- IWordDocument ActiveDocument { get; }
- ISelection Selection { get; }
- IDocuments Documents { get; }
- bool Visible { get; set; }
- void Activate();
- string Version { get; }
- }
-}
diff --git a/GreenshotOfficePlugin/OfficeInterop/Word/IWordDocument.cs b/GreenshotOfficePlugin/OfficeInterop/Word/IWordDocument.cs
deleted file mode 100644
index ad9e31a34..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Word/IWordDocument.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Word
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.document%28v=office.14%29.aspx
- ///
- public interface IWordDocument : ICommon {
- void Activate();
- IWordApplication Application { get; }
- IWordWindow ActiveWindow { get; }
- bool ReadOnly { get; }
- IHyperlinks Hyperlinks { get; }
-
- // Only 2007 and later!
- bool Final { get; set; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Word/IWordView.cs b/GreenshotOfficePlugin/OfficeInterop/Word/IWordView.cs
deleted file mode 100644
index 14d825555..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Word/IWordView.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Word
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.view_members.aspx
- ///
- public interface IWordView : ICommon {
- IZoom Zoom { get; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Word/IWordWindow.cs b/GreenshotOfficePlugin/OfficeInterop/Word/IWordWindow.cs
deleted file mode 100644
index 4b0441510..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Word/IWordWindow.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Word
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.window_members.aspx
- ///
- public interface IWordWindow : ICommon {
- IPane ActivePane { get; }
- void Activate();
- string Caption {
- get;
- }
-
- ///
- /// Returns an Integer (int in C#) that indicates the window handle of the specified window
- ///
- int Hwnd { get; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotOfficePlugin/OfficeInterop/Word/IZoom.cs b/GreenshotOfficePlugin/OfficeInterop/Word/IZoom.cs
deleted file mode 100644
index f6e2eb3db..000000000
--- a/GreenshotOfficePlugin/OfficeInterop/Word/IZoom.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using GreenshotPlugin.Interop;
-
-namespace GreenshotOfficePlugin.OfficeInterop.Word
-{
- ///
- /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.zoom_members.aspx
- ///
- public interface IZoom : ICommon {
- int Percentage { get; set; }
- }
-}
\ No newline at end of file
diff --git a/GreenshotPlugin/Core/WmInputLangChangeRequestFilter.cs b/GreenshotPlugin/Core/WmInputLangChangeRequestFilter.cs
index 7e1507e16..755854616 100644
--- a/GreenshotPlugin/Core/WmInputLangChangeRequestFilter.cs
+++ b/GreenshotPlugin/Core/WmInputLangChangeRequestFilter.cs
@@ -19,7 +19,6 @@
* along with this program. If not, see .
*/
-using GreenshotPlugin.UnmanagedHelpers;
using System.Windows.Forms;
using GreenshotPlugin.UnmanagedHelpers.Enums;
using log4net;
diff --git a/GreenshotPlugin/Hooking/WindowsEventHook.cs b/GreenshotPlugin/Hooking/WindowsEventHook.cs
index 2abe9edb4..2b838008b 100644
--- a/GreenshotPlugin/Hooking/WindowsEventHook.cs
+++ b/GreenshotPlugin/Hooking/WindowsEventHook.cs
@@ -22,7 +22,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
-using GreenshotPlugin.UnmanagedHelpers;
using GreenshotPlugin.UnmanagedHelpers.Enums;
namespace GreenshotPlugin.Hooking
diff --git a/GreenshotPlugin/Hooking/WindowsOpenCloseMonitor.cs b/GreenshotPlugin/Hooking/WindowsOpenCloseMonitor.cs
index 7f0943ae6..088b045e3 100644
--- a/GreenshotPlugin/Hooking/WindowsOpenCloseMonitor.cs
+++ b/GreenshotPlugin/Hooking/WindowsOpenCloseMonitor.cs
@@ -21,7 +21,6 @@
using System;
using GreenshotPlugin.Core;
-using GreenshotPlugin.UnmanagedHelpers;
using GreenshotPlugin.UnmanagedHelpers.Enums;
namespace GreenshotPlugin.Hooking
diff --git a/GreenshotPlugin/Hooking/WindowsTitleMonitor.cs b/GreenshotPlugin/Hooking/WindowsTitleMonitor.cs
index 998da7079..2fbda9dce 100644
--- a/GreenshotPlugin/Hooking/WindowsTitleMonitor.cs
+++ b/GreenshotPlugin/Hooking/WindowsTitleMonitor.cs
@@ -21,7 +21,6 @@
using System;
using GreenshotPlugin.Core;
-using GreenshotPlugin.UnmanagedHelpers;
using GreenshotPlugin.UnmanagedHelpers.Enums;
namespace GreenshotPlugin.Hooking