mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 21:13:23 -07:00
Changed the Office Plugin to use existing libraries and PIA. This reduces the amount of code to maintain.
This commit is contained in:
parent
42cd533862
commit
efb4c997d4
104 changed files with 2144 additions and 3509 deletions
|
@ -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;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
using System.Collections.Generic;
|
||||
using Greenshot.Configuration;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.Helpers;
|
||||
using GreenshotPlugin.Interfaces;
|
||||
|
||||
namespace Greenshot.Destinations {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GreenshotPlugin.Core;
|
||||
using GreenshotPlugin.Interfaces;
|
||||
using log4net;
|
||||
|
|
26
GreenshotOfficePlugin/Com/DisposableCom.cs
Normal file
26
GreenshotOfficePlugin/Com/DisposableCom.cs
Normal file
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// A factory for IDisposableCom
|
||||
/// </summary>
|
||||
public static class DisposableCom
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a ComDisposable for the supplied type object
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type for the com object</typeparam>
|
||||
/// <param name="comObject">the com object itself</param>
|
||||
/// <returns>IDisposableCom of type T</returns>
|
||||
public static IDisposableCom<T> Create<T>(T comObject)
|
||||
{
|
||||
if (Equals(comObject, default(T)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DisposableComImplementation<T>(comObject);
|
||||
}
|
||||
}
|
||||
}
|
51
GreenshotOfficePlugin/Com/DisposableComImplementation.cs
Normal file
51
GreenshotOfficePlugin/Com/DisposableComImplementation.cs
Normal file
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of the IDisposableCom, this is internal to prevent other code to use it directly
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the com object</typeparam>
|
||||
internal class DisposableComImplementation<T> : IDisposableCom<T>
|
||||
{
|
||||
public DisposableComImplementation(T obj)
|
||||
{
|
||||
ComObject = obj;
|
||||
}
|
||||
|
||||
public T ComObject { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up the COM object.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Release the COM reference
|
||||
/// </summary>
|
||||
/// <param name="disposing"><see langword="true" /> if this was called from the<see cref="IDisposable" /> interface.</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
19
GreenshotOfficePlugin/Com/IDisposableCom.cs
Normal file
19
GreenshotOfficePlugin/Com/IDisposableCom.cs
Normal file
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple com wrapper which helps with "using"
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type to wrap</typeparam>
|
||||
public interface IDisposableCom<out T> : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The actual com object
|
||||
/// </summary>
|
||||
T ComObject { get; }
|
||||
}
|
||||
}
|
63
GreenshotOfficePlugin/Com/Ole32Api.cs
Normal file
63
GreenshotOfficePlugin/Com/Ole32Api.cs
Normal file
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// This provides an API for OLE32
|
||||
/// </summary>
|
||||
public static class Ole32Api
|
||||
{
|
||||
/// <summary>
|
||||
/// This converts a ProgID (program ID) into a Guid with the clsId
|
||||
/// </summary>
|
||||
/// <param name="programId">string with the program ID</param>
|
||||
/// <returns>Guid with the clsId</returns>
|
||||
public static Guid ClassIdFromProgId(string programId)
|
||||
{
|
||||
if (CLSIDFromProgID(programId, out Guid clsId).Succeeded())
|
||||
{
|
||||
return clsId;
|
||||
}
|
||||
return clsId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This converts a clsid (Class ID) into a ProgID (program ID)
|
||||
/// </summary>
|
||||
/// <param name="clsId">Guid with the clsid (Class ID)</param>
|
||||
/// <returns>string with the progid</returns>
|
||||
public static string ProgIdFromClassId(Guid clsId)
|
||||
{
|
||||
if (ProgIDFromCLSID(ref clsId, out string progId).Succeeded())
|
||||
{
|
||||
return progId;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See more <a href="https://docs.microsoft.com/en-us/windows/desktop/api/combaseapi/nf-combaseapi-clsidfromprogid">here</a>
|
||||
/// </summary>
|
||||
/// <param name="progId">string with the progId</param>
|
||||
/// <param name="clsId">Guid</param>
|
||||
/// <returns>HResult</returns>
|
||||
[DllImport("ole32.dll", ExactSpelling = true)]
|
||||
private static extern HResult CLSIDFromProgID([In] [MarshalAs(UnmanagedType.LPWStr)] string progId, [Out] out Guid clsId);
|
||||
|
||||
/// <summary>
|
||||
/// See more <a href="https://docs.microsoft.com/en-us/windows/desktop/api/combaseapi/nf-combaseapi-progidfromclsid">here</a>
|
||||
/// </summary>
|
||||
/// <param name="clsId">Guid The CLSID for which the ProgID is to be requested.</param>
|
||||
/// <param name="lplpszProgId">string the ProgID string. The string that represents clsid includes enclosing braces.</param>
|
||||
/// <returns>HResult</returns>
|
||||
[DllImport("ole32.dll")]
|
||||
private static extern HResult ProgIDFromCLSID([In] ref Guid clsId, [MarshalAs(UnmanagedType.LPWStr)] out string lplpszProgId);
|
||||
}
|
||||
}
|
54
GreenshotOfficePlugin/Com/OleAut32Api.cs
Normal file
54
GreenshotOfficePlugin/Com/OleAut32Api.cs
Normal file
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// API for OLEAUT32
|
||||
/// </summary>
|
||||
public static class OleAut32Api
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the active instance of the com object with the specified GUID
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type for the instance</typeparam>
|
||||
/// <param name="clsId">Guid</param>
|
||||
/// <returns>IDisposableCom of T</returns>
|
||||
public static IDisposableCom<T> GetActiveObject<T>(ref Guid clsId)
|
||||
{
|
||||
if (GetActiveObject(ref clsId, IntPtr.Zero, out object comObject).Succeeded())
|
||||
{
|
||||
return DisposableCom.Create((T)comObject);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the active instance of the com object with the specified progId
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type for the instance</typeparam>
|
||||
/// <param name="progId">string</param>
|
||||
/// <returns>IDisposableCom of T</returns>
|
||||
public static IDisposableCom<T> GetActiveObject<T>(string progId)
|
||||
{
|
||||
var clsId = Ole32Api.ClassIdFromProgId(progId);
|
||||
return GetActiveObject<T>(ref clsId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For more details read <a href="https://docs.microsoft.com/en-gb/windows/desktop/api/oleauto/nf-oleauto-getactiveobject">this</a>
|
||||
/// </summary>
|
||||
/// <param name="rclsId">The class identifier (CLSID) of the active object from the OLE registration database.</param>
|
||||
/// <param name="pvReserved">Reserved for future use. Must be null.</param>
|
||||
/// <param name="ppunk">The requested active object.</param>
|
||||
/// <returns></returns>
|
||||
[DllImport("oleaut32.dll")]
|
||||
private static extern HResult GetActiveObject(ref Guid rclsId, IntPtr pvReserved, [MarshalAs(UnmanagedType.IUnknown)] out object ppunk);
|
||||
}
|
||||
}
|
|
@ -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<IDestination> 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);
|
||||
|
|
|
@ -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 {
|
||||
/// <summary>
|
||||
|
@ -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<IDestination> DynamicDestinations() {
|
||||
IDictionary<string, OlObjectClass> inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets();
|
||||
IDictionary<string, OlObjectClass> 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<IDestination>
|
||||
{
|
||||
|
@ -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);
|
||||
|
|
|
@ -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<IDestination> 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<IDestination> {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);
|
||||
|
|
|
@ -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<IDestination> 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<IDestination>
|
||||
{
|
||||
|
@ -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);
|
||||
|
|
|
@ -46,4 +46,8 @@
|
|||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="CustomMarshalers" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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; }
|
||||
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeExport.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Container for transporting notebook information
|
||||
/// </summary>
|
||||
public class OneNoteNotebook
|
||||
{
|
||||
/// <summary>
|
||||
/// ID of the notebook
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the notebook
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
53
GreenshotOfficePlugin/OfficeExport/Entities/OneNotePage.cs
Normal file
53
GreenshotOfficePlugin/OfficeExport/Entities/OneNotePage.cs
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeExport.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Container for transporting Page information
|
||||
/// </summary>
|
||||
public class OneNotePage
|
||||
{
|
||||
/// <inherit />
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inherit />
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <inherit />
|
||||
public bool IsCurrentlyViewed { get; set; }
|
||||
|
||||
/// <inherit />
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <inherit />
|
||||
public OneNoteSection Parent { get; set; }
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeExport.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Container for transporting section information
|
||||
/// </summary>
|
||||
public class OneNoteSection
|
||||
{
|
||||
/// <summary>
|
||||
/// ID of the section
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the section
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Parent notebook
|
||||
/// </summary>
|
||||
public OneNoteNotebook Parent { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,62 +1,118 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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));
|
||||
namespace GreenshotOfficePlugin.OfficeExport
|
||||
{
|
||||
/// <summary>
|
||||
/// Excel exporter
|
||||
/// </summary>
|
||||
public static class ExcelExporter
|
||||
{
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExcelExporter));
|
||||
private static Version _excelVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Call this to get the running Excel application, returns null if there isn't any.
|
||||
/// </summary>
|
||||
/// <returns>ComDisposable for Excel.Application or null</returns>
|
||||
private static IDisposableCom<Application> GetExcelApplication()
|
||||
{
|
||||
IDisposableCom<Application> excelApplication;
|
||||
try
|
||||
{
|
||||
excelApplication = OleAut32Api.GetActiveObject<Application>("Excel.Application");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore, probably no excel running
|
||||
return null;
|
||||
}
|
||||
if (excelApplication?.ComObject != null)
|
||||
{
|
||||
InitializeVariables(excelApplication);
|
||||
}
|
||||
return excelApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this to get the running Excel application, or create a new instance
|
||||
/// </summary>
|
||||
/// <returns>ComDisposable for Excel.Application</returns>
|
||||
private static IDisposableCom<Application> GetOrCreateExcelApplication()
|
||||
{
|
||||
var excelApplication = GetExcelApplication();
|
||||
if (excelApplication == null)
|
||||
{
|
||||
excelApplication = DisposableCom.Create(new Application());
|
||||
}
|
||||
InitializeVariables(excelApplication);
|
||||
return excelApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all currently opened workbooks
|
||||
/// </summary>
|
||||
/// <returns>List of string with names of the workbooks</returns>
|
||||
public static List<string> GetWorkbooks() {
|
||||
List<string> currentWorkbooks = new List<string>();
|
||||
using (IExcelApplication excelApplication = GetExcelApplication()) {
|
||||
if (excelApplication == null) {
|
||||
return currentWorkbooks;
|
||||
/// <returns>IEnumerable with names of the workbooks</returns>
|
||||
public static IEnumerable<string> GetWorkbooks()
|
||||
{
|
||||
using var excelApplication = GetExcelApplication();
|
||||
if ((excelApplication == null) || (excelApplication.ComObject == null))
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
using IWorkbooks workbooks = excelApplication.Workbooks;
|
||||
for (int i = 1; i <= workbooks.Count; i++)
|
||||
using var workbooks = DisposableCom.Create(excelApplication.ComObject.Workbooks);
|
||||
for (int i = 1; i <= workbooks.ComObject.Count; i++)
|
||||
{
|
||||
using IWorkbook workbook = workbooks[i];
|
||||
if (workbook != null) {
|
||||
currentWorkbooks.Add(workbook.Name);
|
||||
using var workbook = DisposableCom.Create(workbooks.ComObject[i]);
|
||||
if (workbook != null)
|
||||
{
|
||||
yield return workbook.ComObject.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
currentWorkbooks.Sort();
|
||||
return currentWorkbooks;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize static excel variables like version and currentuser
|
||||
/// </summary>
|
||||
/// <param name="excelApplication"></param>
|
||||
private static void InitializeVariables(IDisposableCom<Application> excelApplication)
|
||||
{
|
||||
if ((excelApplication == null) || (excelApplication.ComObject == null) || (_excelVersion != null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Version.TryParse(excelApplication.ComObject.Version, out _excelVersion))
|
||||
{
|
||||
LOG.Warn("Assuming Excel version 1997.");
|
||||
_excelVersion = new Version((int)OfficeVersions.Office97, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -67,25 +123,22 @@ namespace GreenshotOfficePlugin.OfficeExport {
|
|||
/// <param name="imageSize"></param>
|
||||
public static void InsertIntoExistingWorkbook(string workbookName, string tmpFile, Size imageSize)
|
||||
{
|
||||
using IExcelApplication excelApplication = GetExcelApplication();
|
||||
if (excelApplication == null) {
|
||||
using var excelApplication = GetExcelApplication();
|
||||
if ((excelApplication == null) || (excelApplication.ComObject == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (IWorkbooks workbooks = excelApplication.Workbooks) {
|
||||
for (int i = 1; i <= workbooks.Count; i++)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
int hWnd = excelApplication.Hwnd;
|
||||
if (hWnd > 0)
|
||||
{
|
||||
WindowDetails.ToForeground(new IntPtr(hWnd));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert a file into an already created workbook
|
||||
|
@ -93,19 +146,34 @@ namespace GreenshotOfficePlugin.OfficeExport {
|
|||
/// <param name="workbook"></param>
|
||||
/// <param name="tmpFile"></param>
|
||||
/// <param name="imageSize"></param>
|
||||
private static void InsertIntoExistingWorkbook(IWorkbook workbook, string tmpFile, Size imageSize) {
|
||||
IWorksheet workSheet = workbook.ActiveSheet;
|
||||
private static void InsertIntoExistingWorkbook(IDisposableCom<_Workbook> workbook, string tmpFile, Size imageSize)
|
||||
{
|
||||
using var workSheet = DisposableCom.Create(workbook.ComObject.ActiveSheet as Worksheet);
|
||||
if (workSheet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using IShapes shapes = workSheet?.Shapes;
|
||||
using var shapes = DisposableCom.Create(workSheet.ComObject.Shapes);
|
||||
if (shapes == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using IShape shape = shapes?.AddPicture(tmpFile, MsoTriState.msoFalse, MsoTriState.msoTrue, 0, 0, imageSize.Width, imageSize.Height);
|
||||
if (shape == 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.Top = 40;
|
||||
shape.Left = 40;
|
||||
shape.LockAspectRatio = MsoTriState.msoTrue;
|
||||
shape.ScaleHeight(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromTopLeft);
|
||||
shape.ScaleWidth(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromTopLeft);
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -115,53 +183,17 @@ namespace GreenshotOfficePlugin.OfficeExport {
|
|||
/// <param name="imageSize"></param>
|
||||
public static void InsertIntoNewWorkbook(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);
|
||||
using var excelApplication = GetOrCreateExcelApplication();
|
||||
if (excelApplication == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Call this to get the running Excel application, returns null if there isn't any.
|
||||
/// </summary>
|
||||
/// <returns>IExcelApplication or null</returns>
|
||||
private static IExcelApplication GetExcelApplication() {
|
||||
IExcelApplication excelApplication = COMWrapper.GetInstance<IExcelApplication>();
|
||||
InitializeVariables(excelApplication);
|
||||
return excelApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this to get the running Excel application, or create a new instance
|
||||
/// </summary>
|
||||
/// <returns>IExcelApplication</returns>
|
||||
private static IExcelApplication GetOrCreateExcelApplication() {
|
||||
IExcelApplication excelApplication = COMWrapper.GetOrCreateInstance<IExcelApplication>();
|
||||
InitializeVariables(excelApplication);
|
||||
return excelApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize static outlook variables like version and currentuser
|
||||
/// </summary>
|
||||
/// <param name="excelApplication"></param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,64 +1,69 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 {
|
||||
|
||||
public class OneNoteExporter {
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(OneNoteExporter));
|
||||
namespace GreenshotOfficePlugin.OfficeExport
|
||||
{
|
||||
/// <summary>
|
||||
/// OneNote exporter
|
||||
/// More details about OneNote: http://msdn.microsoft.com/en-us/magazine/ff796230.aspx
|
||||
/// </summary>
|
||||
public class OneNoteExporter
|
||||
{
|
||||
private const string XmlImageContent = "<one:Image format=\"png\"><one:Size width=\"{1}.0\" height=\"{2}.0\" isSetByUser=\"true\" /><one:Data>{0}</one:Data></one:Image>";
|
||||
private const string XmlOutline = "<?xml version=\"1.0\"?><one:Page xmlns:one=\"{2}\" ID=\"{1}\"><one:Title><one:OE><one:T><![CDATA[{3}]]></one:T></one:OE></one:Title>{0}</one:Page>";
|
||||
private const string OnenoteNamespace2010 = "http://schemas.microsoft.com/office/onenote/2010/onenote";
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OneNoteExporter));
|
||||
|
||||
/// <summary>
|
||||
/// Create a new page in the "unfiled notes section", with the title of the capture, and export the capture there.
|
||||
/// </summary>
|
||||
/// <param name="surfaceToUpload">ISurface</param>
|
||||
/// <returns>bool true if export worked</returns>
|
||||
public static bool ExportToNewPage(ISurface surfaceToUpload) {
|
||||
using(IOneNoteApplication oneNoteApplication = COMWrapper.GetOrCreateInstance<IOneNoteApplication>()) {
|
||||
OneNotePage newPage = new OneNotePage();
|
||||
public bool ExportToNewPage(ISurface surfaceToUpload)
|
||||
{
|
||||
using var oneNoteApplication = GetOrCreateOneNoteApplication();
|
||||
var 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;
|
||||
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);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the capture to the specified page
|
||||
|
@ -66,9 +71,9 @@ namespace GreenshotOfficePlugin.OfficeExport {
|
|||
/// <param name="surfaceToUpload">ISurface</param>
|
||||
/// <param name="page">OneNotePage</param>
|
||||
/// <returns>bool true if everything worked</returns>
|
||||
public static bool ExportToPage(ISurface surfaceToUpload, OneNotePage page)
|
||||
public bool ExportToPage(ISurface surfaceToUpload, OneNotePage page)
|
||||
{
|
||||
using IOneNoteApplication oneNoteApplication = COMWrapper.GetOrCreateInstance<IOneNoteApplication>();
|
||||
using var oneNoteApplication = GetOrCreateOneNoteApplication();
|
||||
return ExportToPage(oneNoteApplication, surfaceToUpload, page);
|
||||
}
|
||||
|
||||
|
@ -79,150 +84,224 @@ namespace GreenshotOfficePlugin.OfficeExport {
|
|||
/// <param name="surfaceToUpload">ISurface</param>
|
||||
/// <param name="page">OneNotePage</param>
|
||||
/// <returns>bool true if everything worked</returns>
|
||||
private static bool ExportToPage(IOneNoteApplication oneNoteApplication, ISurface surfaceToUpload, OneNotePage page) {
|
||||
if(oneNoteApplication == null) {
|
||||
private bool ExportToPage(IDisposableCom<Application> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this to get the running Excel application, returns null if there isn't any.
|
||||
/// </summary>
|
||||
/// <returns>ComDisposable for Excel.Application or null</returns>
|
||||
private IDisposableCom<Application> GetOneNoteApplication()
|
||||
{
|
||||
IDisposableCom<Application> oneNoteApplication;
|
||||
try
|
||||
{
|
||||
oneNoteApplication = OleAut32Api.GetActiveObject<Application>("OneNote.Application");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore, probably no OneNote running
|
||||
return null;
|
||||
}
|
||||
return oneNoteApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this to get the running OneNote application, or create a new instance
|
||||
/// </summary>
|
||||
/// <returns>ComDisposable for OneNote.Application</returns>
|
||||
private IDisposableCom<Application> GetOrCreateOneNoteApplication()
|
||||
{
|
||||
var oneNoteApplication = GetOneNoteApplication();
|
||||
if (oneNoteApplication == null)
|
||||
{
|
||||
oneNoteApplication = DisposableCom.Create(new Application());
|
||||
}
|
||||
return oneNoteApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the captions of all the open word documents
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IList<OneNotePage> GetPages()
|
||||
{
|
||||
var pages = new List<OneNotePage>();
|
||||
try
|
||||
{
|
||||
using var oneNoteApplication = GetOrCreateOneNoteApplication();
|
||||
if (oneNoteApplication != null)
|
||||
{
|
||||
// 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);
|
||||
reader = null;
|
||||
OneNoteSection currentSection = null;
|
||||
OneNoteNotebook currentNotebook = null;
|
||||
while (xmlReader.Read())
|
||||
{
|
||||
if ("one:Notebook".Equals(xmlReader.Name))
|
||||
{
|
||||
string id = xmlReader.GetAttribute("ID");
|
||||
if ((id != null) && ((currentNotebook == null) || !id.Equals(currentNotebook.Id)))
|
||||
{
|
||||
currentNotebook = new OneNoteNotebook
|
||||
{
|
||||
Id = xmlReader.GetAttribute("ID"),
|
||||
Name = xmlReader.GetAttribute("name")
|
||||
};
|
||||
}
|
||||
}
|
||||
if ("one:Section".Equals(xmlReader.Name))
|
||||
{
|
||||
string id = xmlReader.GetAttribute("ID");
|
||||
if (id != null && (currentSection == null || !id.Equals(currentSection.Id)))
|
||||
{
|
||||
currentSection = new OneNoteSection
|
||||
{
|
||||
Id = xmlReader.GetAttribute("ID"),
|
||||
Name = xmlReader.GetAttribute("name"),
|
||||
Parent = currentNotebook
|
||||
};
|
||||
}
|
||||
}
|
||||
if ("one:Page".Equals(xmlReader.Name))
|
||||
{
|
||||
// Skip deleted items
|
||||
if ("true".Equals(xmlReader.GetAttribute("isInRecycleBin")))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var page = new OneNotePage
|
||||
{
|
||||
Parent = currentSection,
|
||||
Name = xmlReader.GetAttribute("name"),
|
||||
Id = xmlReader.GetAttribute("ID")
|
||||
};
|
||||
if ((page.Id == null) || (page.Name == null))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
page.IsCurrentlyViewed = "true".Equals(xmlReader.GetAttribute("isCurrentlyViewed"));
|
||||
pages.Add(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
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((page1, page2) =>
|
||||
{
|
||||
if (page1.IsCurrentlyViewed || page2.IsCurrentlyViewed)
|
||||
{
|
||||
return page2.IsCurrentlyViewed.CompareTo(page1.IsCurrentlyViewed);
|
||||
}
|
||||
return string.Compare(page1.DisplayName, page2.DisplayName, StringComparison.Ordinal);
|
||||
});
|
||||
return pages;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the Section ID for the specified special location
|
||||
/// </summary>
|
||||
/// <param name="oneNoteApplication"></param>
|
||||
/// <param name="specialLocation">SpecialLocation</param>
|
||||
/// <returns>string with section ID</returns>
|
||||
private static string GetSectionId(IOneNoteApplication oneNoteApplication, SpecialLocation specialLocation) {
|
||||
if(oneNoteApplication == null) {
|
||||
private string GetSectionId(IDisposableCom<Application> oneNoteApplication, SpecialLocation specialLocation)
|
||||
{
|
||||
if (oneNoteApplication == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// ReSharper disable once RedundantAssignment
|
||||
string unfiledNotesPath = string.Empty;
|
||||
oneNoteApplication.GetSpecialLocation(specialLocation, out unfiledNotesPath);
|
||||
string unfiledNotesPath = "";
|
||||
oneNoteApplication.ComObject.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);
|
||||
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);
|
||||
while(xmlReader.Read()) {
|
||||
if("one:Section".Equals(xmlReader.Name)) {
|
||||
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)) {
|
||||
if (unfiledNotesPath.Equals(path))
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally
|
||||
finally
|
||||
{
|
||||
reader?.Dispose();
|
||||
if (reader != null)
|
||||
{
|
||||
reader.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the captions of all the open word documents
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<OneNotePage> GetPages() {
|
||||
List<OneNotePage> pages = new List<OneNotePage>();
|
||||
try
|
||||
{
|
||||
using IOneNoteApplication oneNoteApplication = COMWrapper.GetOrCreateInstance<IOneNoteApplication>();
|
||||
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);
|
||||
StringReader reader = null;
|
||||
try {
|
||||
reader = new StringReader(notebookXml);
|
||||
using XmlTextReader xmlReader = new XmlTextReader(reader);
|
||||
reader = null;
|
||||
OneNoteSection currentSection = null;
|
||||
OneNoteNotebook currentNotebook = null;
|
||||
while (xmlReader.Read()) {
|
||||
if ("one:Notebook".Equals(xmlReader.Name)) {
|
||||
string id = xmlReader.GetAttribute("ID");
|
||||
if (id != null && (currentNotebook == null || !id.Equals(currentNotebook.ID))) {
|
||||
currentNotebook = new OneNoteNotebook
|
||||
{
|
||||
ID = xmlReader.GetAttribute("ID"),
|
||||
Name = xmlReader.GetAttribute("name")
|
||||
};
|
||||
}
|
||||
}
|
||||
if ("one:Section".Equals(xmlReader.Name)) {
|
||||
string id = xmlReader.GetAttribute("ID");
|
||||
if (id != null && (currentSection == null || !id.Equals(currentSection.ID))) {
|
||||
currentSection = new OneNoteSection
|
||||
{
|
||||
ID = xmlReader.GetAttribute("ID"),
|
||||
Name = xmlReader.GetAttribute("name"),
|
||||
Parent = currentNotebook
|
||||
};
|
||||
}
|
||||
}
|
||||
if ("one:Page".Equals(xmlReader.Name)) {
|
||||
// Skip deleted items
|
||||
if ("true".Equals(xmlReader.GetAttribute("isInRecycleBin"))) {
|
||||
continue;
|
||||
}
|
||||
OneNotePage page = new OneNotePage
|
||||
{
|
||||
Parent = currentSection,
|
||||
Name = xmlReader.GetAttribute("name"),
|
||||
ID = xmlReader.GetAttribute("ID")
|
||||
};
|
||||
if (page.ID == null || page.Name == null) {
|
||||
continue;
|
||||
}
|
||||
page.IsCurrentlyViewed = "true".Equals(xmlReader.GetAttribute("isCurrentlyViewed"));
|
||||
pages.Add(page);
|
||||
}
|
||||
}
|
||||
} finally
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,79 +1,171 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 {
|
||||
namespace GreenshotOfficePlugin.OfficeExport
|
||||
{
|
||||
/// <summary>
|
||||
/// Export logic for powerpoint
|
||||
/// </summary>
|
||||
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<OfficeConfiguration>();
|
||||
private static readonly OfficeConfiguration _officeConfiguration = IniConfig.GetIniSection<OfficeConfiguration>();
|
||||
|
||||
private static bool IsAfter2003() {
|
||||
return _powerpointVersion.Major > (int)OfficeVersion.OFFICE_2003;
|
||||
}
|
||||
private Version _powerpointVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Get the captions of all the open powerpoint presentations
|
||||
/// Internal method to add a picture to a presentation
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetPowerpointPresentations() {
|
||||
List<string> foundPresentations = new List<string>();
|
||||
/// <param name="presentation"></param>
|
||||
/// <param name="tmpFile"></param>
|
||||
/// <param name="imageSize"></param>
|
||||
/// <param name="title"></param>
|
||||
private void AddPictureToPresentation(IDisposableCom<Presentation> presentation, string tmpFile, Size imageSize, string title)
|
||||
{
|
||||
if (presentation != null)
|
||||
{
|
||||
//ISlide slide = presentation.Slides.AddSlide( presentation.Slides.Count + 1, PPSlideLayout.ppLayoutPictureWithCaption);
|
||||
IDisposableCom<Slide> slide = null;
|
||||
try
|
||||
{
|
||||
using IPowerpointApplication powerpointApplication = GetPowerpointApplication();
|
||||
if (powerpointApplication == null) {
|
||||
return foundPresentations;
|
||||
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;
|
||||
}
|
||||
float width = imageSize.Width;
|
||||
float height = imageSize.Height;
|
||||
IDisposableCom<Shape> 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 IPresentations presentations = powerpointApplication.Presentations;
|
||||
LOG.DebugFormat("Open Presentations: {0}", presentations.Count);
|
||||
for (int i = 1; i <= presentations.Count; i++)
|
||||
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)
|
||||
{
|
||||
using IPresentation presentation = presentations.item(i);
|
||||
if (presentation == null) {
|
||||
continue;
|
||||
width = shapeForLocation.ComObject.Width;
|
||||
left = shapeForLocation.ComObject.Left;
|
||||
hasScaledWidth = true;
|
||||
}
|
||||
if (presentation.ReadOnly == MsoTriState.msoTrue) {
|
||||
continue;
|
||||
else
|
||||
{
|
||||
shapeForLocation.ComObject.Left = left;
|
||||
}
|
||||
if (IsAfter2003()) {
|
||||
if (presentation.Final) {
|
||||
continue;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
foundPresentations.Add(presentation.Name);
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Warn("Problem setting the title to a text-range", ex);
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
slide?.Dispose();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.Warn("Problem retrieving word destinations, ignoring: ", ex);
|
||||
}
|
||||
foundPresentations.Sort();
|
||||
return foundPresentations;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -84,28 +176,36 @@ namespace GreenshotOfficePlugin.OfficeExport {
|
|||
/// <param name="imageSize">Size of the image</param>
|
||||
/// <param name="title">A string with the image title</param>
|
||||
/// <returns></returns>
|
||||
public static bool ExportToPresentation(string presentationName, string tmpFile, Size imageSize, string title) {
|
||||
using (IPowerpointApplication powerpointApplication = GetPowerpointApplication()) {
|
||||
if (powerpointApplication == null) {
|
||||
public bool ExportToPresentation(string presentationName, string tmpFile, Size imageSize, string title)
|
||||
{
|
||||
using (var 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++)
|
||||
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)
|
||||
{
|
||||
using IPresentation presentation = presentations.item(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,78 +213,93 @@ namespace GreenshotOfficePlugin.OfficeExport {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to add a picture to a presentation
|
||||
/// Call this to get the running PowerPoint application, or create a new instance
|
||||
/// </summary>
|
||||
/// <param name="presentation"></param>
|
||||
/// <param name="tmpFile"></param>
|
||||
/// <param name="imageSize"></param>
|
||||
/// <param name="title"></param>
|
||||
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);
|
||||
/// <returns>ComDisposable for PowerPoint.Application</returns>
|
||||
private IDisposableCom<Application> 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;
|
||||
/// <summary>
|
||||
/// Call this to get the running PowerPoint application, returns null if there isn't any.
|
||||
/// </summary>
|
||||
/// <returns>ComDisposable for PowerPoint.Application or null</returns>
|
||||
private IDisposableCom<Application> GetPowerPointApplication()
|
||||
{
|
||||
IDisposableCom<Application> powerPointApplication;
|
||||
try
|
||||
{
|
||||
powerPointApplication = OleAut32Api.GetActiveObject<Application>("PowerPoint.Application");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Ignore, probably no PowerPoint running
|
||||
return null;
|
||||
}
|
||||
if (powerPointApplication.ComObject != null)
|
||||
{
|
||||
InitializeVariables(powerPointApplication);
|
||||
}
|
||||
return powerPointApplication;
|
||||
}
|
||||
shapeForLocation.Width = imageSize.Width;
|
||||
|
||||
if (height > shapeForLocation.Height) {
|
||||
height = shapeForLocation.Height;
|
||||
top = shapeForLocation.Top;
|
||||
hasScaledHeight = true;
|
||||
} else {
|
||||
top = (shapeForLocation.Top + (shapeForLocation.Height / 2)) - (imageSize.Height / 2f);
|
||||
/// <summary>
|
||||
/// Get the captions of all the open powerpoint presentations
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<string> GetPowerpointPresentations()
|
||||
{
|
||||
using var powerpointApplication = GetPowerPointApplication();
|
||||
if (powerpointApplication == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
shapeForLocation.Height = imageSize.Height;
|
||||
} catch (Exception e) {
|
||||
LOG.Error(e);
|
||||
slide = presentation.Slides.Add(presentation.Slides.Count + 1, (int)PPSlideLayout.ppLayoutBlank);
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
if (presentation.ComObject.ReadOnly == MsoTriState.msoTrue)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
if (IsAfter2003())
|
||||
{
|
||||
if (presentation.ComObject.Final)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
presentation.Application.ActiveWindow.View.GotoSlide(slide.SlideNumber);
|
||||
presentation.Application.Activate();
|
||||
yield return presentation.ComObject.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize static powerpoint variables like version
|
||||
/// </summary>
|
||||
/// <param name="powerpointApplication">IPowerpointApplication</param>
|
||||
private void InitializeVariables(IDisposableCom<Application> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,61 +310,35 @@ namespace GreenshotOfficePlugin.OfficeExport {
|
|||
/// <param name="imageSize"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <returns></returns>
|
||||
public static bool InsertIntoNewPresentation(string tmpFile, Size imageSize, string title) {
|
||||
public 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 {
|
||||
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(e);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.Error("Powerpoint add picture to presentation failed", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return isPictureAdded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this to get the running powerpoint application, returns null if there isn't any.
|
||||
/// </summary>
|
||||
/// <returns>IPowerpointApplication or null</returns>
|
||||
private static IPowerpointApplication GetPowerpointApplication() {
|
||||
IPowerpointApplication powerpointApplication = COMWrapper.GetInstance<IPowerpointApplication>();
|
||||
InitializeVariables(powerpointApplication);
|
||||
return powerpointApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this to get the running powerpoint application, or create a new instance
|
||||
/// </summary>
|
||||
/// <returns>IPowerpointApplication</returns>
|
||||
private static IPowerpointApplication GetOrCreatePowerpointApplication() {
|
||||
IPowerpointApplication powerpointApplication = COMWrapper.GetOrCreateInstance<IPowerpointApplication>();
|
||||
InitializeVariables(powerpointApplication);
|
||||
return powerpointApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize static outlook variables like version and currentuser
|
||||
/// </summary>
|
||||
/// <param name="powerpointApplication">IPowerpointApplication</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,45 +1,149 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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));
|
||||
namespace GreenshotOfficePlugin.OfficeExport
|
||||
{
|
||||
/// <summary>
|
||||
/// This makes it possible to export to word
|
||||
/// </summary>
|
||||
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<OfficeConfiguration>();
|
||||
|
||||
private static readonly OfficeConfiguration _officeConfiguration = IniConfig.GetIniSection<OfficeConfiguration>();
|
||||
|
||||
/// <summary>
|
||||
/// Check if the used version is higher than Office 2003
|
||||
/// Helper method to add the file as image to the selection
|
||||
/// </summary>
|
||||
/// <param name="selection"></param>
|
||||
/// <param name="tmpFile"></param>
|
||||
/// <returns></returns>
|
||||
private IDisposableCom<InlineShape> AddPictureToSelection(IDisposableCom<Selection> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this to get the running Word application, or create a new instance
|
||||
/// </summary>
|
||||
/// <returns>ComDisposable for Word.Application</returns>
|
||||
private IDisposableCom<Application> GetOrCreateWordApplication()
|
||||
{
|
||||
var wordApplication = GetWordApplication();
|
||||
if (wordApplication == null)
|
||||
{
|
||||
wordApplication = DisposableCom.Create(new Application());
|
||||
}
|
||||
InitializeVariables(wordApplication);
|
||||
return wordApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this to get the running Word application, returns null if there isn't any.
|
||||
/// </summary>
|
||||
/// <returns>ComDisposable for Word.Application or null</returns>
|
||||
private IDisposableCom<Application> GetWordApplication()
|
||||
{
|
||||
IDisposableCom<Application> wordApplication;
|
||||
try
|
||||
{
|
||||
wordApplication = OleAut32Api.GetActiveObject<Application>("Word.Application");
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Ignore, probably no word running
|
||||
return null;
|
||||
}
|
||||
if ((wordApplication != null) && (wordApplication.ComObject != null))
|
||||
{
|
||||
InitializeVariables(wordApplication);
|
||||
}
|
||||
return wordApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the captions of all the open word documents
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static bool IsAfter2003() {
|
||||
return _wordVersion.Major > (int)OfficeVersion.OFFICE_2003;
|
||||
public IEnumerable<string> 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)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (IsAfter2003())
|
||||
{
|
||||
if (document.ComObject.Final)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
using var activeWindow = DisposableCom.Create(document.ComObject.ActiveWindow);
|
||||
yield return activeWindow.ComObject.Caption;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize static word variables like version
|
||||
/// </summary>
|
||||
/// <param name="wordApplication"></param>
|
||||
private void InitializeVariables(IDisposableCom<Application> 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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -47,19 +151,23 @@ namespace GreenshotOfficePlugin.OfficeExport {
|
|||
/// </summary>
|
||||
/// <param name="wordCaption"></param>
|
||||
/// <param name="tmpFile"></param>
|
||||
/// <returns></returns>
|
||||
public static bool InsertIntoExistingDocument(string wordCaption, string tmpFile) {
|
||||
using (IWordApplication wordApplication = GetWordApplication()) {
|
||||
if (wordApplication == null) {
|
||||
/// <returns>bool</returns>
|
||||
public bool InsertIntoExistingDocument(string wordCaption, string tmpFile)
|
||||
{
|
||||
using (var wordApplication = GetWordApplication())
|
||||
{
|
||||
if (wordApplication == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
using IDocuments documents = wordApplication.Documents;
|
||||
for (int i = 1; i <= documents.Count; i++)
|
||||
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))
|
||||
{
|
||||
using IWordDocument wordDocument = documents.item(i);
|
||||
using IWordWindow activeWindow = wordDocument.ActiveWindow;
|
||||
if (activeWindow.Caption.StartsWith(wordCaption)) {
|
||||
return InsertIntoExistingDocument(wordApplication, wordDocument, tmpFile, null, null);
|
||||
}
|
||||
}
|
||||
|
@ -70,225 +178,168 @@ namespace GreenshotOfficePlugin.OfficeExport {
|
|||
/// <summary>
|
||||
/// Internal method for the insert
|
||||
/// </summary>
|
||||
/// <param name="wordApplication"></param>
|
||||
/// <param name="wordDocument"></param>
|
||||
/// <param name="tmpFile"></param>
|
||||
/// <param name="address">link for the image</param>
|
||||
/// <param name="tooltip">tooltip of the image</param>
|
||||
/// <returns></returns>
|
||||
internal static bool InsertIntoExistingDocument(IWordApplication wordApplication, IWordDocument wordDocument, string tmpFile, string address, string tooltip) {
|
||||
/// <param name="wordApplication">IDisposableCom with Application</param>
|
||||
/// <param name="wordDocument">IDisposableCom with _Document</param>
|
||||
/// <param name="tmpFile">string</param>
|
||||
/// <param name="address">string</param>
|
||||
/// <param name="tooltip">string with the tooltip of the image</param>
|
||||
/// <returns>bool</returns>
|
||||
internal bool InsertIntoExistingDocument(IDisposableCom<Application> 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.Activate();
|
||||
}
|
||||
catch
|
||||
try
|
||||
{
|
||||
// ignored
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to add the file as image to the selection
|
||||
/// Insert a capture into a new document
|
||||
/// </summary>
|
||||
/// <param name="selection"></param>
|
||||
/// <param name="tmpFile"></param>
|
||||
/// <returns></returns>
|
||||
private static IInlineShape AddPictureToSelection(ISelection selection, string tmpFile)
|
||||
/// <param name="tmpFile">string</param>
|
||||
/// <param name="address">string</param>
|
||||
/// <param name="tooltip">string</param>
|
||||
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 var wordApplication = GetOrCreateWordApplication();
|
||||
if (wordApplication == null)
|
||||
{
|
||||
using IWordApplication 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
wordDocument.Activate();
|
||||
}
|
||||
catch
|
||||
using var hyperlinks = DisposableCom.Create(wordDocument.ComObject.Hyperlinks);
|
||||
using (DisposableCom.Create(hyperlinks.ComObject.Add(shape, screentip, Type.Missing, screentip, Type.Missing, Type.Missing)))
|
||||
{
|
||||
// ignored
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.WarnFormat("Couldn't add hyperlink for image: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the captions of all the open word documents
|
||||
/// Check if the used version is higher than Office 2003
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetWordDocuments() {
|
||||
List<string> openDocuments = new List<string>();
|
||||
try
|
||||
private bool IsAfter2003()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this to get the running outlook application, returns null if there isn't any.
|
||||
/// </summary>
|
||||
/// <returns>IWordApplication or null</returns>
|
||||
private static IWordApplication GetWordApplication() {
|
||||
IWordApplication wordApplication = COMWrapper.GetInstance<IWordApplication>();
|
||||
InitializeVariables(wordApplication);
|
||||
return wordApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this to get the running word application, or create a new instance
|
||||
/// </summary>
|
||||
/// <returns>IWordApplication</returns>
|
||||
private static IWordApplication GetOrCreateWordApplication() {
|
||||
IWordApplication wordApplication = COMWrapper.GetOrCreateInstance<IWordApplication>();
|
||||
InitializeVariables(wordApplication);
|
||||
return wordApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize static outlook variables like version and currentuser
|
||||
/// </summary>
|
||||
/// <param name="wordApplication"></param>
|
||||
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);
|
||||
}
|
||||
return _wordVersion.Major > (int)OfficeVersions.Office2003;
|
||||
}
|
||||
}
|
||||
}
|
36
GreenshotOfficePlugin/OfficeInterop/EmailFormat.cs
Normal file
36
GreenshotOfficePlugin/OfficeInterop/EmailFormat.cs
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies which EmailFormat the email needs to use
|
||||
/// </summary>
|
||||
public enum EmailFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// Use the plain text format
|
||||
/// </summary>
|
||||
Text,
|
||||
/// <summary>
|
||||
/// Use HTML format
|
||||
/// </summary>
|
||||
Html
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Excel {
|
||||
/// <summary>
|
||||
/// See http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.application.aspx
|
||||
/// </summary>
|
||||
[ComProgId("Excel.Application")]
|
||||
public interface IExcelApplication : ICommon {
|
||||
IWorkbook ActiveWorkbook {
|
||||
get;
|
||||
}
|
||||
|
||||
//ISelection Selection {get;}
|
||||
IWorkbooks Workbooks {
|
||||
get;
|
||||
}
|
||||
|
||||
bool Visible {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
string Version {
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an Integer indicating the top-level window handle of the Microsoft Excel window.
|
||||
/// </summary>
|
||||
int Hwnd
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.Excel
|
||||
{
|
||||
public interface IPictures : ICollection {
|
||||
// Use index + 1!!
|
||||
//IPicture this[object Index] { get; }
|
||||
void Insert(string file);
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Excel
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbook.aspx
|
||||
/// </summary>
|
||||
public interface IWorkbook : ICommon {
|
||||
IWorksheet ActiveSheet {
|
||||
get;
|
||||
}
|
||||
string Name {
|
||||
get;
|
||||
}
|
||||
void Activate();
|
||||
IWorksheets Worksheets {
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Excel
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.aspx
|
||||
/// </summary>
|
||||
public interface IWorkbooks : ICommon, ICollection {
|
||||
IWorkbook Add(object template);
|
||||
// Use index + 1!!
|
||||
IWorkbook this[object index] {
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
using GreenshotOfficePlugin.OfficeInterop.Powerpoint;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Excel
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._worksheet_members.aspx
|
||||
/// </summary>
|
||||
public interface IWorksheet : ICommon {
|
||||
IPictures Pictures {
|
||||
get;
|
||||
}
|
||||
IShapes Shapes {
|
||||
get;
|
||||
}
|
||||
string Name {
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.Excel
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.iworksheets_members.aspx
|
||||
/// </summary>
|
||||
public interface IWorksheets : ICollection {
|
||||
// Use index + 1!!
|
||||
IWorksheet this[object index] {
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Collections;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop {
|
||||
/// <summary>
|
||||
/// If the "type" this[object index] { get; } is implemented, use index + 1!!! (starts at 1)
|
||||
/// </summary>
|
||||
public interface ICollection : ICommon, IEnumerable {
|
||||
int Count {
|
||||
get;
|
||||
}
|
||||
void Remove(int index);
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop
|
||||
{
|
||||
public enum MsoScaleFrom {
|
||||
msoScaleFromTopLeft = 0,
|
||||
msoScaleFromMiddle = 1,
|
||||
msoScaleFromBottomRight = 2
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop
|
||||
{
|
||||
public enum MsoTriState {
|
||||
msoTrue = -1,
|
||||
msoFalse = 0,
|
||||
msoCTrue = 1,
|
||||
msoTriStateToggle = -3,
|
||||
msoTriStateMixed = -2
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
64
GreenshotOfficePlugin/OfficeInterop/OfficeVersions.cs
Normal file
64
GreenshotOfficePlugin/OfficeInterop/OfficeVersions.cs
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop
|
||||
{
|
||||
/// <summary>
|
||||
/// A mapping between the version and a usable name
|
||||
/// </summary>
|
||||
public enum OfficeVersions
|
||||
{
|
||||
/// <summary>
|
||||
/// Office 97
|
||||
/// </summary>
|
||||
Office97 = 8,
|
||||
/// <summary>
|
||||
/// Office 2000
|
||||
/// </summary>
|
||||
Office2000 = 9,
|
||||
/// <summary>
|
||||
/// Office 2002
|
||||
/// </summary>
|
||||
Office2002 = 10,
|
||||
/// <summary>
|
||||
/// Office 2003
|
||||
/// </summary>
|
||||
Office2003 = 11,
|
||||
/// <summary>
|
||||
/// Office 2007
|
||||
/// </summary>
|
||||
Office2007 = 12,
|
||||
/// <summary>
|
||||
/// Office 2010
|
||||
/// </summary>
|
||||
Office2010 = 14,
|
||||
/// <summary>
|
||||
/// Office 2013
|
||||
/// </summary>
|
||||
Office2013 = 15,
|
||||
/// <summary>
|
||||
/// Office 2016
|
||||
/// </summary>
|
||||
Office2016 = 16,
|
||||
/// <summary>
|
||||
/// Office 2019
|
||||
/// </summary>
|
||||
Office2019 = 17
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
using System;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.OneNote
|
||||
{
|
||||
[ComProgId("OneNote.Application")]
|
||||
public interface IOneNoteApplication : ICommon {
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.OneNote
|
||||
{
|
||||
public enum NewPageStyle {
|
||||
npsDefault = 0,
|
||||
npsBlankPageWithTitle = 1,
|
||||
npsBlankPageNoTitle = 2
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.OneNote
|
||||
{
|
||||
public class OneNoteNotebook {
|
||||
public string Name { get; set; }
|
||||
public string ID { get; set; }
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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; }
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.OneNote
|
||||
{
|
||||
public enum SpecialLocation : int {
|
||||
slBackupFolder = 0,
|
||||
slUnfiledNotesSection = 1,
|
||||
slDefaultNotebookFolder = 2
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.OneNote
|
||||
{
|
||||
public enum XMLSchema {
|
||||
xs2007 = 0,
|
||||
xs2010 = 1,
|
||||
xsCurrent= xs2010
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
using System;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/ff869026.aspx
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.appointmentitem.aspx
|
||||
/// </summary>
|
||||
public interface AppointmentItem : IItem, ICommon {
|
||||
string Organizer {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
string SendUsingAccount {
|
||||
get;
|
||||
}
|
||||
string Categories {
|
||||
get;
|
||||
}
|
||||
DateTime Start {
|
||||
get;
|
||||
}
|
||||
DateTime End {
|
||||
get;
|
||||
}
|
||||
OlReoccurenceState RecurrenceState {
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies which EmailFormat the email needs to use
|
||||
/// </summary>
|
||||
public enum EmailFormat {
|
||||
Text,
|
||||
HTML
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.attachment_members.aspx
|
||||
/// </summary>
|
||||
public interface IAttachment : ICommon {
|
||||
string DisplayName {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
string FileName {
|
||||
get;
|
||||
}
|
||||
OlAttachmentType Type {
|
||||
get;
|
||||
}
|
||||
IPropertyAccessor PropertyAccessor {
|
||||
get;
|
||||
}
|
||||
object MAPIOBJECT {
|
||||
get;
|
||||
}
|
||||
void SaveAsFile(string path);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// Is a joined interface of the Explorer an Inspector
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.contactitem.aspx
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
using GreenshotOfficePlugin.OfficeInterop.Word;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// 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
|
||||
///
|
||||
/// </summary>
|
||||
public interface IExplorer : ICommonExplorer {
|
||||
IItem ActiveInlineResponse {
|
||||
get;
|
||||
}
|
||||
IWordDocument ActiveInlineResponseWordEditor {
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
using System.Collections;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public interface IExplorers : ICommon, ICollection, IEnumerable {
|
||||
// Use index + 1!!
|
||||
IExplorer this[object Index] {
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/bb176362%28v=office.12%29.aspx
|
||||
/// </summary>
|
||||
public interface IFolder : ICommon {
|
||||
IItems Items {
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
using GreenshotOfficePlugin.OfficeInterop.Word;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.inspector_members.aspx
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
using System.Collections;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._application.inspectors.aspx
|
||||
/// </summary>
|
||||
public interface IInspectors : ICommon, ICollection, IEnumerable {
|
||||
// Use index + 1!!
|
||||
IInspector this[object Index] {
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
using System;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// Common attributes of all the Items (MailItem, AppointmentItem)
|
||||
/// See: http://msdn.microsoft.com/en-us/library/ff861252.aspx
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
using System.Collections;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/bb208387%28v=office.12%29.aspx
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/bb176693%28v=office.12%29.aspx
|
||||
/// </summary>
|
||||
public interface INameSpace : ICommon {
|
||||
IRecipient CurrentUser {
|
||||
get;
|
||||
}
|
||||
IFolder GetDefaultFolder(OlDefaultFolders defaultFolder);
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.propertyaccessor_members.aspx
|
||||
/// </summary>
|
||||
public interface IPropertyAccessor : ICommon {
|
||||
void SetProperty(string SchemaName, object Value);
|
||||
object GetProperty(string SchemaName);
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
public interface IRecipient : ICommon {
|
||||
string Name {
|
||||
get;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
using System;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/ff861252.aspx
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mailitem.aspx
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
public enum OlAttachmentType {
|
||||
// Fields
|
||||
olByReference = 4,
|
||||
olByValue = 1,
|
||||
olEmbeddeditem = 5,
|
||||
olOLE = 6
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
public enum OlBodyFormat {
|
||||
// Fields
|
||||
olFormatHTML = 2,
|
||||
olFormatPlain = 1,
|
||||
olFormatRichText = 3,
|
||||
olFormatUnspecified = 0
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
public enum OlEditorType {
|
||||
// Fields
|
||||
olEditorHTML = 2,
|
||||
olEditorRTF = 3,
|
||||
olEditorText = 1,
|
||||
olEditorWord = 4
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
public enum OlInspectorClose {
|
||||
// Fields
|
||||
olDiscard = 1,
|
||||
olPromptForSave = 2,
|
||||
olSave = 0
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/ff863329.aspx
|
||||
/// </summary>
|
||||
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.
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
public enum OlReoccurenceState {
|
||||
olApptException,
|
||||
olApptMaster,
|
||||
olApptNotRecurring,
|
||||
olApptOccurrence
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
public enum OlSensitivity {
|
||||
// Fields
|
||||
olConfidential = 3,
|
||||
olNormal = 0,
|
||||
olPersonal = 1,
|
||||
olPrivate = 2
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
public enum OlWindowState {
|
||||
// Fields
|
||||
olMaximized = 0,
|
||||
olMinimized = 1,
|
||||
olNormalWindow = 2
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to save the changes we just made
|
||||
/// </summary>
|
||||
/// <param name="mailItem"></param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uses the IMAPIPROP.SetProps to set the content ID
|
||||
/// </summary>
|
||||
/// <param name="attachment"></param>
|
||||
/// <param name="contentId"></param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use MAPI32.DLL "HrSetOneProp" from managed code
|
||||
/// </summary>
|
||||
/// <param name="attachment"></param>
|
||||
/// <param name="proptag"></param>
|
||||
/// <param name="propertyValue"></param>
|
||||
/// <returns></returns>
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook {
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public static class PropTag {
|
||||
public const string ATTACHMENT_CONTENT_ID = @"http://schemas.microsoft.com/mapi/proptag/0x3712001E";
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
namespace GreenshotOfficePlugin.OfficeInterop.Outlook
|
||||
{
|
||||
/// <summary>
|
||||
/// Units: http://msdn.microsoft.com/en-us/library/office/bb214015(v=office.12).aspx
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.pagesetup_members.aspx
|
||||
/// </summary>
|
||||
public interface IPageSetup : ICommon, ICollection {
|
||||
float SlideWidth { get; set; }
|
||||
float SlideHeight { get; set; }
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint {
|
||||
/// <summary>
|
||||
/// See http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.application_members.aspx
|
||||
/// </summary>
|
||||
[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; }
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
using GreenshotOfficePlugin.OfficeInterop.Word;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.view_members.aspx
|
||||
/// </summary>
|
||||
public interface IPowerpointView : ICommon {
|
||||
IZoom Zoom { get; }
|
||||
void GotoSlide(int index);
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.documentwindow.view.aspx
|
||||
/// </summary>
|
||||
public interface IPowerpointWindow : ICommon {
|
||||
void Activate();
|
||||
IPowerpointView View { get; }
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
using GreenshotOfficePlugin.OfficeInterop.Outlook;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.presentation_members.aspx
|
||||
/// </summary>
|
||||
public interface IPresentation : ICommon {
|
||||
string Name { get; }
|
||||
ISlides Slides { get; }
|
||||
IPowerpointApplication Application { get; }
|
||||
MsoTriState ReadOnly { get; }
|
||||
bool Final { get; set; }
|
||||
IPageSetup PageSetup { get; }
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
using GreenshotOfficePlugin.OfficeInterop.Outlook;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.presentations_members.aspx
|
||||
/// </summary>
|
||||
public interface IPresentations : ICommon, ICollection {
|
||||
IPresentation Add(MsoTriState WithWindow);
|
||||
IPresentation item(int index);
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
using GreenshotOfficePlugin.OfficeInterop.Outlook;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shape_members.aspx
|
||||
/// </summary>
|
||||
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; }
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
using System.Collections;
|
||||
using GreenshotOfficePlugin.OfficeInterop.Outlook;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shapes_members.aspx
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slide_members.aspx
|
||||
/// </summary>
|
||||
public interface ISlide : ICommon {
|
||||
IShapes Shapes { get; }
|
||||
void Select();
|
||||
int SlideNumber { get; }
|
||||
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slides_members.aspx
|
||||
/// </summary>
|
||||
public interface ISlides : ICommon {
|
||||
int Count { get; }
|
||||
ISlide Add(int Index, int layout);
|
||||
}
|
||||
}
|
|
@ -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; }
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Powerpoint
|
||||
{
|
||||
public interface ITextRange : ICommon {
|
||||
string Text { get; set; }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Word
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.documents_members(v=office.11).aspx
|
||||
/// </summary>
|
||||
public interface IDocuments : ICommon, ICollection {
|
||||
IWordDocument Add(ref object Template, ref object NewTemplate, ref object DocumentType, ref object Visible);
|
||||
IWordDocument item(int index);
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Word
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.hyperlink_members%28v=office.14%29.aspx
|
||||
/// </summary>
|
||||
public interface IHyperlink : ICommon {
|
||||
string Address {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Word
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.hyperlinks%28v=office.14%29.aspx
|
||||
/// </summary>
|
||||
public interface IHyperlinks : ICommon, ICollection {
|
||||
IHyperlink Add(object Anchor, object Address, object SubAddress, object ScreenTip, object TextToDisplay, object Target);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
using GreenshotOfficePlugin.OfficeInterop.Outlook;
|
||||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Word
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.inlineshape_members%28v=office.14%29.aspx
|
||||
/// </summary>
|
||||
public interface IInlineShape : ICommon {
|
||||
IHyperlink Hyperlink { get; }
|
||||
MsoTriState LockAspectRatio {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Word
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/ms263866%28v=office.14%29.aspx
|
||||
/// </summary>
|
||||
public interface IInlineShapes : ICommon {
|
||||
IInlineShape AddPicture(string FileName, object LinkToFile, object SaveWithDocument, object Range);
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Word
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.pane_members.aspx
|
||||
/// </summary>
|
||||
public interface IPane : ICommon {
|
||||
IWordView View { get; }
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Word
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.selection_members(v=office.11).aspx
|
||||
/// </summary>
|
||||
public interface ISelection : ICommon {
|
||||
IInlineShapes InlineShapes { get; }
|
||||
void InsertAfter(string text);
|
||||
int MoveDown(object Unit, object Count, object Extend);
|
||||
}
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Word
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.document%28v=office.14%29.aspx
|
||||
/// </summary>
|
||||
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; }
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Word
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.view_members.aspx
|
||||
/// </summary>
|
||||
public interface IWordView : ICommon {
|
||||
IZoom Zoom { get; }
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Word
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.window_members.aspx
|
||||
/// </summary>
|
||||
public interface IWordWindow : ICommon {
|
||||
IPane ActivePane { get; }
|
||||
void Activate();
|
||||
string Caption {
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an Integer (int in C#) that indicates the window handle of the specified window
|
||||
/// </summary>
|
||||
int Hwnd { get; }
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
using GreenshotPlugin.Interop;
|
||||
|
||||
namespace GreenshotOfficePlugin.OfficeInterop.Word
|
||||
{
|
||||
/// <summary>
|
||||
/// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.zoom_members.aspx
|
||||
/// </summary>
|
||||
public interface IZoom : ICommon {
|
||||
int Percentage { get; set; }
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue