Refactoring the interop code to a separate project. Still need to add the interop DLL to the final exe... or maybe I want to use references inside the projects...

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1688 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-03-06 17:41:19 +00:00
commit 7666127106
43 changed files with 51 additions and 4752 deletions

View file

@ -321,9 +321,9 @@ namespace Greenshot.Helpers {
}
}
public void AddEmptyFrame() {
public void AddEmptyFrames(int frames) {
lock (this) {
position++;
position += frames;
}
}

View file

@ -35,7 +35,7 @@ using Greenshot.Helpers;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using GreenshotPlugin.UnmanagedHelpers;
using IniFile;
using Greenshot.IniFile;
namespace Greenshot.Helpers {
/// <summary>

View file

@ -31,7 +31,7 @@ using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.UnmanagedHelpers;
using GreenshotPlugin.Core;
using IniFile;
using Greenshot.IniFile;
namespace Greenshot.Helpers {
/// <summary>

View file

@ -27,7 +27,7 @@ using System.Windows.Forms;
using GreenshotPlugin.UnmanagedHelpers;
using GreenshotPlugin.Core;
using IniFile;
using Greenshot.IniFile;
namespace Greenshot.Helpers {
/// <summary>

View file

@ -26,7 +26,7 @@ using System.Windows.Forms;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using IniFile;
using Greenshot.IniFile;
namespace Greenshot.Helpers {
public static class FilenameHelper {

View file

@ -26,11 +26,13 @@ using System.Drawing.Imaging;
using Greenshot.Configuration;
using Greenshot.Drawing.Filters;
using Greenshot.Helpers.IEInterop;
using Greenshot.Interop;
using Greenshot.Interop.IE;
using Greenshot.Plugin;
using GreenshotPlugin.UnmanagedHelpers;
using GreenshotPlugin.Controls;
using GreenshotPlugin.Core;
using IniFile;
using Greenshot.IniFile;
namespace Greenshot.Helpers {
/// <summary>

View file

@ -26,7 +26,9 @@ using System.Runtime.InteropServices;
using GreenshotPlugin.Core;
using Greenshot.Plugin;
using IniFile;
using Greenshot.Interop;
using Greenshot.Interop.IE;
using Greenshot.IniFile;
namespace Greenshot.Helpers.IEInterop {
public class ElementContainer {
@ -302,7 +304,7 @@ namespace Greenshot.Helpers.IEInterop {
// IE tries to prevent a cross frame scripting security issue.
try {
// Convert IHTMLWindow2 to IWebBrowser2 using IServiceProvider.
IServiceProvider sp = (IServiceProvider)htmlWindow;
Interop.IServiceProvider sp = (Interop.IServiceProvider)htmlWindow;
// Use IServiceProvider.QueryService to get IWebBrowser2 object.
Object brws = null;

View file

@ -1,35 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComImport, Guid("3050F1D8-98B5-11CF-BB82-00AA00BDCE0B"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLBodyElement {
string scroll {
set;
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
}
}

View file

@ -1,67 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComImport, Guid("3050f3db-98b5-11cf-bb82-00aa00bdce0b"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLCurrentStyle {
/// <summary><para><c>styleFloat</c> property of <c>IHTMLStyle</c> interface.</para></summary>
string styleFloat {
[DispId(-2147413042)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
string left {
[DispId(-2147418112 + 3)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
string top {
[DispId(-2147418112 + 4)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
string width {
[DispId(-2147418112 + 5)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
string height {
[DispId(-2147418112 + 6)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
string right {
[DispId(-2147418112 + 0x4d)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
string bottom {
[DispId(-2147418112 + 0x4e)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
}
}

View file

@ -1,36 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
/// <summary><para><c>IHTMLDocument</c> interface.</para></summary>
[Guid("626FC520-A41E-11CF-A731-00A0C9082637")]
[ComImport]
[TypeLibType(TypeLibTypeFlags.FDual)]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLDocument {
object Script {
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
}
}

View file

@ -1,77 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
/// <summary><para><c>IHTMLDocument2</c> interface.</para></summary>
[Guid("332C4425-26CB-11D0-B483-00C04FD90119")]
[ComImport]
[TypeLibType(TypeLibTypeFlags.FDual)]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLDocument2 {
IHTMLElement body {
[DispId(1004)]
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
string title {
[DispId(1012)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
object frames {
[DispId(1019)]
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
string url {
[DispId(1025)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
IHTMLWindow2 parentWindow {
[DispId(1034)]
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
object bgColor {
[DispId(-501)]
get;
}
IHTMLSelectionObject selection {
[DispId(1017)]
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
string designMode {
[DispId(1014)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
[DispId(1014)]
set;
}
}
}

View file

@ -1,47 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
/// <summary><para><c>IHTMLDocument3</c> interface.</para></summary>
[Guid("3050F485-98B5-11CF-BB82-00AA00BDCE0B")]
[ComImport]
[TypeLibType(TypeLibTypeFlags.FDual)]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLDocument3 {
IHTMLElement documentElement {
[DispId(1075)]
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
[DispId(1086)]
[return: MarshalAs(UnmanagedType.IDispatch)]
IHTMLElementCollection getElementsByName([MarshalAs(UnmanagedType.BStr)] string v);
[DispId(1088)]
IHTMLElement getElementById([MarshalAs(UnmanagedType.BStr)] string v);
[DispId(1087)]
IHTMLElementCollection getElementsByTagName([MarshalAs(UnmanagedType.BStr)] string v);
}
}

View file

@ -1,33 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComVisible(true), Guid("3050f69a-98b5-11cf-bb82-00aa00bdce0b"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch),
TypeLibType(TypeLibTypeFlags.FDual)]
public interface IHTMLDocument4 {
[DispId(1090)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool hasFocus();
}
}

View file

@ -1,34 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComImport, ComVisible(true), Guid("3050f80c-98b5-11cf-bb82-00aa00bdce0b"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch),
TypeLibType(TypeLibTypeFlags.FDual)]
public interface IHTMLDocument5 {
[DispId(1102)]
string compatMode {
[return: MarshalAs(UnmanagedType.BStr)] get;
}
}
}

View file

@ -1,117 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComImport, Guid("3050F1FF-98B5-11CF-BB82-00AA00BDCE0B"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLElement {
[DispId(-2147417611)]
void setAttribute([MarshalAs(UnmanagedType.BStr)] string strAttributeName, object AttributeValue, int lFlags);
[DispId(-2147417610)]
object getAttribute([MarshalAs(UnmanagedType.BStr)] string strAttributeName, int lFlags);
long offsetLeft {
[DispId(-2147417104)]
get;
}
long offsetTop {
[DispId(-2147417103)]
get;
}
long offsetWidth {
[DispId(-2147417102)]
get;
}
long offsetHeight {
[DispId(-2147417101)]
get;
}
IHTMLElement offsetParent {
[DispId(-2147417100)]
get;
}
string className {
[DispId(-2147417111)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
IHTMLDocument2 document {
[DispId(-2147417094)]
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
string id {
[DispId(-2147417110)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
string innerHTML {
[DispId(-2147417086)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
string innerText {
[DispId(-2147417085)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
IHTMLStyle style {
[DispId(-2147418038)]
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
string tagName {
[DispId(-2147417108)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
string title {
[DispId(-2147418043)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
[DispId(-2147417093)]
void scrollIntoView(bool varargStart);
IHTMLElementCollection children {
[DispId(-2147417075)]
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
}
}

View file

@ -1,39 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComImport, Guid("3050F434-98B5-11CF-BB82-00AA00BDCE0B"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLElement2 {
[DispId(-2147417067)]
[return: MarshalAs(UnmanagedType.IDispatch)]
IHTMLRect getBoundingClientRect();
IHTMLCurrentStyle currentStyle {
[DispId(-2147417105)]
[return: MarshalAs(UnmanagedType.Interface)] //IHTMLCurrentStyle
get;
}
}
}

View file

@ -1,33 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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;
using System.Runtime.InteropServices;
namespace Greenshot.Helpers.IEInterop {
[ComImport(), ComVisible(true),
Guid("3050F21F-98B5-11CF-BB82-00AA00BDCE0B"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch),
TypeLibType(TypeLibTypeFlags.FDispatchable)]
public interface IHTMLElementCollection : IEnumerable {
new IEnumerator GetEnumerator();
}
}

View file

@ -1,104 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComVisible(true), ComImport(), Guid("3050f311-98b5-11cf-bb82-00aa00bdce0b"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLFrameBase {
//dispinterface IHTMLFrameBase {
// properties:
// methods:
// [id(0x80010bb8), propput]
// void src([in] BSTR rhs);
// [id(0x80010bb8), propget]
// BSTR src();
// [id(0x80010000), propput]
// void name([in] BSTR rhs);
// [id(0x80010000), propget]
// BSTR name();
// [id(0x80010bba), propput]
// void border([in] VARIANT rhs);
// [id(0x80010bba), propget]
// VARIANT border();
// [id(0x80010bbb), propput]
// void frameBorder([in] BSTR rhs);
// [id(0x80010bbb), propget]
// BSTR frameBorder();
// [id(0x80010bbc), propput]
// void frameSpacing([in] VARIANT rhs);
// [id(0x80010bbc), propget]
// VARIANT frameSpacing();
// [id(0x80010bbd), propput]
// void marginWidth([in] VARIANT rhs);
// [id(0x80010bbd), propget]
// VARIANT marginWidth();
// [id(0x80010bbe), propput]
// void marginHeight([in] VARIANT rhs);
// [id(0x80010bbe), propget]
// VARIANT marginHeight();
// [id(0x80010bbf), propput]
// void noResize([in] VARIANT_BOOL rhs);
// [id(0x80010bbf), propget]
// VARIANT_BOOL noResize();
// [id(0x80010bc0), propput]
// void scrolling([in] BSTR rhs);
// [id(0x80010bc0), propget]
// BSTR scrolling();
//};
// [DispId(HTMLDispIDs.DISPID_IHTMLFRAMEBASE_SRC)]
string src {
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
string name {
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
object border {
get;
}
string frameBorder {
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
object frameSpacing {
get;
}
object marginWidth {
get;
}
object marginHeight {
get;
}
bool noResize {
[return: MarshalAs(UnmanagedType.VariantBool)]
get;
}
string scrolling {
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
}
}

View file

@ -1,39 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComImport(), ComVisible(true),
Guid("332C4426-26CB-11D0-B483-00C04FD90119"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch),
TypeLibType(TypeLibTypeFlags.FDispatchable)]
public interface IHTMLFramesCollection2 {
[DispId(0)]
[return: MarshalAs(UnmanagedType.IDispatch)]
IHTMLWindow2 item(int pvarIndex);
long length {
[DispId(1001)]
get;
}
}
}

View file

@ -1,49 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComImport, Guid("3050F4A3-98B5-11CF-BB82-00AA00BDCE0B"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLRect {
int bottom {
[DispId(1004)]
get;
}
int left {
[DispId(1001)]
get;
}
int right {
[DispId(1003)]
get;
}
int top {
[DispId(1002)]
get;
}
}
}

View file

@ -1,38 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComImport, Guid("3050F35C-98B5-11CF-BB82-00AA00BDCE0B"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLScreen {
[DispId(1003)]
int width {
get;
}
[DispId(1004)]
int height {
get;
}
}
}

View file

@ -1,49 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComImport, Guid("3050F84A-98B5-11CF-BB82-00AA00BDCE0B"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLScreen2 {
int logicalXDPI {
[DispId(1009)]
get;
}
int logicalYDPI {
[DispId(1010)]
get;
}
int deviceXDPI {
[DispId(1011)]
get;
}
int deviceYDPI {
[DispId(1012)]
get;
}
};
}

View file

@ -1,40 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
// See: http://msdn.microsoft.com/en-us/library/aa768849%28v=vs.85%29.aspx
[ComImport, Guid("3050f25A-98b5-11cf-bb82-00aa00bdce0b"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLSelectionObject {
[return: MarshalAs(UnmanagedType.IDispatch)]
[DispId(1001)]
IHTMLTxtRange createRange();
[DispId(1002)]
void empty();
[DispId(1003)]
void clear();
[DispId(1004)]
string EventType { [return: MarshalAs(UnmanagedType.BStr)] get;}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,138 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
// See: http://msdn.microsoft.com/en-us/library/aa741548%28v=vs.85%29.aspx
[ComImport, Guid("3050F220-98B5-11CF-BB82-00AA00BDCE0B"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLTxtRange {
[DispId(1006)]
IHTMLElement parentElement();
[DispId(1008)]
IHTMLTxtRange duplicate();
[DispId(1010)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool inRange(IHTMLTxtRange range);
[DispId(1011)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool isEqual(IHTMLTxtRange range);
[DispId(1012)]
void scrollIntoView([MarshalAs(UnmanagedType.VariantBool)] bool fStart);
[DispId(1013)]
void collapse([MarshalAs(UnmanagedType.VariantBool)] bool Start);
[DispId(1014)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool expand([MarshalAs(UnmanagedType.BStr)] string Unit);
[DispId(1015)]
int move([MarshalAs(UnmanagedType.BStr)] string Unit, int Count);
[DispId(1016)]
int moveStart([MarshalAs(UnmanagedType.BStr)] string Unit, int Count);
[DispId(1017)]
int moveEnd([MarshalAs(UnmanagedType.BStr)] string Unit, int Count);
[DispId(1024)]
void select();
[DispId(1026)]
void pasteHTML([MarshalAs(UnmanagedType.BStr)] string html);
[DispId(1001)]
void moveToElementText(IHTMLElement element);
[DispId(1025)]
void setEndPoint([MarshalAs(UnmanagedType.BStr)] string how, IHTMLTxtRange SourceRange);
[DispId(1018)]
int compareEndPoints([MarshalAs(UnmanagedType.BStr)] string how, IHTMLTxtRange SourceRange);
[DispId(1019)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool findText([MarshalAs(UnmanagedType.BStr)] string String, int Count, int Flags);
[DispId(1020)]
void moveToPoint(int x, int y);
[DispId(1021)]
[return: MarshalAs(UnmanagedType.BStr)]
string getBookmark();
[DispId(1009)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool moveToBookmark([MarshalAs(UnmanagedType.BStr)] string Bookmark);
[DispId(1027)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool queryCommandSupported([MarshalAs(UnmanagedType.BStr)] string cmdID);
[DispId(1028)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool queryCommandEnabled([MarshalAs(UnmanagedType.BStr)] string cmdID);
[DispId(1029)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool queryCommandState([MarshalAs(UnmanagedType.BStr)] string cmdID);
[DispId(1030)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool queryCommandIndeterm([MarshalAs(UnmanagedType.BStr)] string cmdID);
[DispId(1031)]
[return: MarshalAs(UnmanagedType.BStr)]
string queryCommandText([MarshalAs(UnmanagedType.BStr)] string cmdID);
[DispId(1032)]
object queryCommandValue([MarshalAs(UnmanagedType.BStr)] string cmdID);
[DispId(1033)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool execCommand([MarshalAs(UnmanagedType.BStr)] string cmdID, [MarshalAs(UnmanagedType.VariantBool)] bool showUI, object value);
[DispId(1034)]
[return: MarshalAs(UnmanagedType.VariantBool)]
bool execCommandShowHelp([MarshalAs(UnmanagedType.BStr)] string cmdID);
string htmlText {
[DispId(1003)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
string text {
[DispId(1004)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
[DispId(1004)]
set;
}
}
}

View file

@ -1,46 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComVisible(true), ComImport(), Guid("332c4427-26cb-11d0-b483-00c04fd90119"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLWindow2 {
[DispId(1156)]
IHTMLScreen screen {
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
[DispId(1151)]
IHTMLDocument2 document {
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
[DispId(11)]
string name {
[return: MarshalAs(UnmanagedType.BStr)] get;
}
}
}

View file

@ -1,35 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComVisible(true), ComImport(), Guid("3050f4ae-98b5-11cf-bb82-00aa00bdce0b"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLWindow3 {
[DispId(1170)]
int screenLeft { get;}
[DispId(1171)]
int screenTop { get;}
}
}

View file

@ -1,35 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
[ComVisible(true), ComImport(), Guid("3050f6cf-98b5-11cf-bb82-00aa00bdce0b"),
TypeLibType(TypeLibTypeFlags.FDual),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface IHTMLWindow4 {
[DispId(1181)]
IHTMLFrameBase frameElement {
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
}
}
}

View file

@ -1,32 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
// Needed to get the Window handle from the IDocument2
// See: http://msdn.microsoft.com/en-us/library/ms680102%28v=vs.85%29.aspx
[ComImport, Guid("00000114-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleWindow {
void GetWindow(out IntPtr phwnd);
void ContextSensitiveHelp([In, MarshalAs(UnmanagedType.Bool)] bool fEnterMode);
}
}

View file

@ -1,32 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
// This is the COM IServiceProvider interface, not System.IServiceProvider .Net interface!
[ComImport(), ComVisible(true), Guid("6D5140C1-7436-11CE-8034-00AA006009FA"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IServiceProvider {
[return: MarshalAs(UnmanagedType.I4)][PreserveSig]
int QueryService(ref Guid guidService, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppvObject);
}
}

View file

@ -1,154 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.IEInterop {
// IWebBrowser: EAB22AC1-30C1-11CF-A7EB-0000C05BAE0B
// [ComVisible(true), ComImport(), Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E"),
// TypeLibType(TypeLibTypeFlags.FDual),
// InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
// public interface IWebBrowser2 {
// [DispId(203)]
// object Document {
// [return: MarshalAs(UnmanagedType.IDispatch)]
// get;
// }
// }
[ComImport, /*SuppressUnmanagedCodeSecurity,*/
TypeLibType(TypeLibTypeFlags.FOleAutomation |
TypeLibTypeFlags.FDual |
TypeLibTypeFlags.FHidden),
Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E")]
public interface IWebBrowser2 {
[DispId(100)]
void GoBack();
[DispId(0x65)]
void GoForward();
[DispId(0x66)]
void GoHome();
[DispId(0x67)]
void GoSearch();
[DispId(0x68)]
void Navigate([In] string Url,
[In] ref object flags,
[In] ref object targetFrameName,
[In] ref object postData,
[In] ref object headers);
[DispId(-550)]
void Refresh();
[DispId(0x69)]
void Refresh2([In] ref object level);
[DispId(0x6a)]
void Stop();
[DispId(200)]
object Application {
[return:
MarshalAs(UnmanagedType.IDispatch)]
get;
}
[DispId(0xc9)]
object Parent {
[return:
MarshalAs(UnmanagedType.IDispatch)]
get;
}
[DispId(0xca)]
object Container {
[return:
MarshalAs(UnmanagedType.IDispatch)]
get;
}
[DispId(0xcb)]
object Document {
[return:
MarshalAs(UnmanagedType.IDispatch)]
get;
}
[DispId(0xcc)]
bool TopLevelContainer { get; }
[DispId(0xcd)]
string Type { get; }
[DispId(0xce)]
int Left { get; set; }
[DispId(0xcf)]
int Top { get; set; }
[DispId(0xd0)]
int Width { get; set; }
[DispId(0xd1)]
int Height { get; set; }
[DispId(210)]
string LocationName { get; }
[DispId(0xd3)]
string LocationURL { get; }
[DispId(0xd4)]
bool Busy { get; }
[DispId(300)]
void Quit();
[DispId(0x12d)]
void ClientToWindow(out int pcx, out int pcy);
[DispId(0x12e)]
void PutProperty([In] string property, [In] object vtValue);
[DispId(0x12f)]
object GetProperty([In] string property);
[DispId(0)]
string Name { get; }
[DispId(-515)]
int HWND { get; }
[DispId(400)]
string FullName { get; }
[DispId(0x191)]
string Path { get; }
[DispId(0x192)]
bool Visible { get; set; }
[DispId(0x193)]
bool StatusBar { get; set; }
[DispId(0x194)]
string StatusText { get; set; }
[DispId(0x195)]
int ToolBar { get; set; }
[DispId(0x196)]
bool MenuBar { get; set; }
[DispId(0x197)]
bool FullScreen { get; set; }
[DispId(500)]
void Navigate2([In] ref object URL,
[In] ref object flags,
[In] ref object targetFrameName,
[In] ref object postData,
[In] ref object headers);
[DispId(550)]
bool Offline { get; set; }
[DispId(0x227)]
bool Silent { get; set; }
[DispId(0x228)]
bool RegisterAsBrowser { get; set; }
[DispId(0x229)]
bool RegisterAsDropTarget { get; set; }
[DispId(0x22a)]
bool TheaterMode { get; set; }
[DispId(0x22b)]
bool AddressBar { get; set; }
[DispId(0x22c)]
bool Resizable { get; set; }
}
}

View file

@ -30,7 +30,7 @@ using Greenshot.Configuration;
using Greenshot.Forms;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using IniFile;
using Greenshot.IniFile;
namespace Greenshot.Helpers {
/// <summary>

View file

@ -28,10 +28,10 @@ using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using Greenshot.Helpers.OfficeInterop;
using Greenshot.Interop.Office;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using IniFile;
using Greenshot.IniFile;
/// <summary>
/// Author: Andrew Baker

View file

@ -1,131 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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.Reflection;
using Greenshot.Interop;
namespace Greenshot.Helpers.OfficeInterop {
// See http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.application.aspx
[ComProgId("Excel.Application")]
public interface IExcelApplication : Common {
IWorkbook ActiveWorkbook { get; }
//ISelection Selection {get;}
IWorkbooks Workbooks {get;}
bool Visible {get; set;}
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.aspx
public interface IWorkbooks : Common, Collection {
IWorkbook Add(object template);
IWorkbook this[object Index] { get; }
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbook.aspx
public interface IWorkbook : Common {
IWorksheet ActiveSheet {get;}
string Name { get; }
void Activate();
IWorksheets Worksheets { get; }
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._worksheet_members.aspx
public interface IWorksheet : Common {
IPictures Pictures {get;}
string Name { get; }
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.iworksheets_members.aspx
public interface IWorksheets : Common, Collection {
Object this[object Index] { get; }
}
public interface IPictures : Common, Collection {
void Insert(string file);
}
public class ExcelExporter {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExcelExporter));
private static IExcelApplication GetOrCreateExcelApplication() {
return (IExcelApplication)COMWrapper.GetOrCreateInstance(typeof(IExcelApplication));
}
private static IExcelApplication GetExcelApplication() {
return (IExcelApplication)COMWrapper.GetInstance(typeof(IExcelApplication));
}
public static List<string> GetWorkbooks() {
List<string> currentWorkbooks = new List<string>();
using( IExcelApplication excelApplication = GetExcelApplication() ) {
if (excelApplication != null) {
for(int i = 1; i <= excelApplication.Workbooks.Count ; i ++) {
IWorkbook workbook = excelApplication.Workbooks[i];
if (workbook != null) {
currentWorkbooks.Add(workbook.Name);
}
}
}
}
return currentWorkbooks;
}
/// <summary>
/// Insert image from supplied tmp file into the give excel workbook
/// </summary>
/// <param name="workbookName"></param>
/// <param name="tmpFile"></param>
public static void InsertIntoExistingWorkbook(string workbookName, string tmpFile) {
using( IExcelApplication excelApplication = GetExcelApplication() ) {
if (excelApplication != null) {
for(int i = 1; i <= excelApplication.Workbooks.Count ; i ++) {
IWorkbook workbook = excelApplication.Workbooks[i];
if (workbook != null && workbook.Name.StartsWith(workbookName)) {
InsertIntoExistingWorkbook(workbook, tmpFile);
}
}
}
}
}
private static void InsertIntoExistingWorkbook(IWorkbook workbook, string tmpFile) {
IWorksheet sheet = workbook.ActiveSheet;
if (sheet != null) {
if (sheet.Pictures != null) {
sheet.Pictures.Insert(tmpFile);
}
} else {
LOG.Error("No pictures found");
}
}
public static void InsertIntoNewWorkbook(string tmpFile) {
using( IExcelApplication excelApplication = GetOrCreateExcelApplication() ) {
if (excelApplication != null) {
excelApplication.Visible = true;
object template = Missing.Value;
IWorkbook workbook = excelApplication.Workbooks.Add(template);
InsertIntoExistingWorkbook(workbook, tmpFile);
}
}
}
}
}

View file

@ -1,325 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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;
namespace Greenshot.Helpers.OfficeInterop {
/// <summary>
/// Common properties that has appreared in almost all objects
/// </summary>
public interface Common : IDisposable {
}
public interface Collection : Common, IEnumerable {
int Count { get; }
void Remove( int index );
}
public interface Items : Collection, IEnumerable
{
Item this[ object index ] { get; }
object GetFirst();
object GetLast();
// Actual definition is "object Add( object )", just making it convenient
object Add( OlItemType type );
}
// See: http://msdn.microsoft.com/en-us/library/ff861252.aspx
public interface Item : Common {
Attachments 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(object Modal);
void Save();
DateTime ExpiryTime { get; set; }
string HTMLBody { get; set; }
DateTime ReceivedTime { get; }
string SenderName { get; }
DateTime SentOn { get; }
OlBodyFormat BodyFormat { get; set; }
PropertyAccessor PropertyAccessor { get; }
// MailItem
bool Sent { get; }
object MAPIOBJECT { get; }
// AppointmentItem
string Organizer { get; set; }
string SendUsingAccount { get; }
}
public interface Attachments : Collection {
Attachment Add( object source, object type, object position, object displayName );
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.attachment_members.aspx
public interface Attachment : Common {
string DisplayName { get;set; }
string FileName { get; }
OlAttachmentType Type { get; }
PropertyAccessor PropertyAccessor { get; }
object MAPIOBJECT { get; }
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.propertyaccessor_members.aspx
public interface PropertyAccessor : Common {
void SetProperty(string SchemaName, Object Value);
Object GetProperty(string SchemaName);
}
public enum OlBodyFormat {
// Fields
olFormatHTML = 2,
olFormatPlain = 1,
olFormatRichText = 3,
olFormatUnspecified = 0
}
public enum OlAttachmentType {
// Fields
olByReference = 4,
olByValue = 1,
olEmbeddeditem = 5,
olOLE = 6
}
public enum OlSensitivity {
// Fields
olConfidential = 3,
olNormal = 0,
olPersonal = 1,
olPrivate = 2
}
// See: http://msdn.microsoft.com/en-us/library/ff863329.aspx
public enum OlObjectClass {
olAccount = 105 , // Represents an Account object.
olAccountRuleCondition = 135 , // Represents an AccountRuleCondition object.
olAccounts = 106 , // Represents an Accounts object.
olAction = 32 , // Represents an Action object.
olActions = 33 , // Represents an Actions object.
olAddressEntries = 21 , // Represents an AddressEntries object.
olAddressEntry = 8 , // Represents an AddressEntry object.
olAddressList = 7 , // Represents an AddressList object.
olAddressLists = 20 , // Represents an AddressLists object.
olAddressRuleCondition = 170 , // Represents an AddressRuleCondition object.
olApplication = 0 , // Represents an Application object.
olAppointment = 26 , // Represents an AppointmentItem object.
olAssignToCategoryRuleAction = 122 , // Represents an AssignToCategoryRuleAction object.
olAttachment = 5 , // Represents an Attachment object.
olAttachments = 18 , // Represents an Attachments object.
olAttachmentSelection = 169 , // Represents an AttachmentSelection object.
olAutoFormatRule = 147 , // Represents an AutoFormatRule object.
olAutoFormatRules = 148 , // Represents an AutoFormatRules object.
olCalendarModule = 159 , // Represents a CalendarModule object.
olCalendarSharing = 151 , // Represents a CalendarSharing object.
olCategories = 153 , // Represents a Categories object.
olCategory = 152 , // Represents a Category object.
olCategoryRuleCondition = 130 , // Represents a CategoryRuleCondition object.
olClassBusinessCardView = 168 , // Represents a BusinessCardView object.
olClassCalendarView = 139 , // Represents a CalendarView object.
olClassCardView = 138 , // Represents a CardView object.
olClassIconView = 137 , // Represents a IconView object.
olClassNavigationPane = 155 , // Represents a NavigationPane object.
olClassTableView = 136 , // Represents a TableView object.
olClassTimeLineView = 140 , // Represents a TimelineView object.
olClassTimeZone = 174 , // Represents a TimeZone object.
olClassTimeZones = 175 , // Represents a TimeZones object.
olColumn = 154 , // Represents a Column object.
olColumnFormat = 149 , // Represents a ColumnFormat object.
olColumns = 150 , // Represents a Columns object.
olConflict = 102 , // Represents a Conflict object.
olConflicts = 103 , // Represents a Conflicts object.
olContact = 40 , // Represents a ContactItem object.
olContactsModule = 160 , // Represents a ContactsModule object.
olDistributionList = 69 , // Represents a ExchangeDistributionList object.
olDocument = 41 , // Represents a DocumentItem object.
olException = 30 , // Represents an Exception object.
olExceptions = 29 , // Represents an Exceptions object.
olExchangeDistributionList = 111 , // Represents an ExchangeDistributionList object.
olExchangeUser = 110 , // Represents an ExchangeUser object.
olExplorer = 34 , // Represents an Explorer object.
olExplorers = 60 , // Represents an Explorers object.
olFolder = 2 , // Represents a Folder object.
olFolders = 15 , // Represents a Folders object.
olFolderUserProperties = 172 , // Represents a UserDefinedProperties object.
olFolderUserProperty = 171 , // Represents a UserDefinedProperty object.
olFormDescription = 37 , // Represents a FormDescription object.
olFormNameRuleCondition = 131 , // Represents a FormNameRuleCondition object.
olFormRegion = 129 , // Represents a FormRegion object.
olFromRssFeedRuleCondition = 173 , // Represents a FromRssFeedRuleCondition object.
olFromRuleCondition = 132 , // Represents a ToOrFromRuleCondition object.
olImportanceRuleCondition = 128 , // Represents an ImportanceRuleCondition object.
olInspector = 35 , // Represents an Inspector object.
olInspectors = 61 , // Represents an Inspectors object.
olItemProperties = 98 , // Represents an ItemProperties object.
olItemProperty = 99 , // Represents an ItemProperty object.
olItems = 16 , // Represents an Items object.
olJournal = 42 , // Represents a JournalItem object.
olJournalModule = 162 , // Represents a JournalModule object.
olLink = 75 , // Represents a Link object.
olLinks = 76 , // Represents a Links object.
olMail = 43 , // Represents a MailItem object.
olMailModule = 158 , // Represents a MailModule object.
olMarkAsTaskRuleAction = 124 , // Represents a MarkAsTaskRuleAction object.
olMeetingCancellation = 54 , // Represents a MeetingItem object that is a meeting cancellation notice.
olMeetingRequest = 53 , // Represents a MeetingItem object that is a meeting request.
olMeetingResponseNegative = 55 , // Represents a MeetingItem object that is a refusal of a meeting request.
olMeetingResponsePositive = 56 , // Represents a MeetingItem object that is an acceptance of a meeting request.
olMeetingResponseTentative = 57 , // Represents a MeetingItem object that is a tentative acceptance of a meeting request.
olMoveOrCopyRuleAction = 118 , // Represents a MoveOrCopyRuleAction object.
olNamespace = 1 , // Represents a NameSpace object.
olNavigationFolder = 167 , // Represents a NavigationFolder object.
olNavigationFolders = 166 , // Represents a NavigationFolders object.
olNavigationGroup = 165 , // Represents a NavigationGroup object.
olNavigationGroups = 164 , // Represents a NavigationGroups object.
olNavigationModule = 157 , // Represents a NavigationModule object.
olNavigationModules = 156 , // Represents a NavigationModules object.
olNewItemAlertRuleAction = 125 , // Represents a NewItemAlertRuleAction object.
olNote = 44 , // Represents a NoteItem object.
olNotesModule = 163 , // Represents a NotesModule object.
olOrderField = 144 , // Represents an OrderField object.
olOrderFields = 145 , // Represents an OrderFields object.
olOutlookBarGroup = 66 , // Represents an OutlookBarGroup object.
olOutlookBarGroups = 65 , // Represents an OutlookBarGroups object.
olOutlookBarPane = 63 , // Represents an OutlookBarPane object.
olOutlookBarShortcut = 68 , // Represents an OutlookBarShortcut object.
olOutlookBarShortcuts = 67 , // Represents an OutlookBarShortcuts object.
olOutlookBarStorage = 64 , // Represents an OutlookBarStorage object.
olPages = 36 , // Represents a Pages object.
olPanes = 62 , // Represents a Panes object.
olPlaySoundRuleAction = 123 , // Represents a PlaySoundRuleAction object.
olPost = 45 , // Represents a PostItem object.
olPropertyAccessor = 112 , // Represents a PropertyAccessor object.
olPropertyPages = 71 , // Represents a PropertyPages object.
olPropertyPageSite = 70 , // Represents a PropertyPageSite object.
olRecipient = 4 , // Represents a Recipient object.
olRecipients = 17 , // Represents a Recipients object.
olRecurrencePattern = 28 , // Represents a RecurrencePattern object.
olReminder = 101 , // Represents a Reminder object.
olReminders = 100 , // Represents a Reminders object.
olRemote = 47 , // Represents a RemoteItem object.
olReport = 46 , // Represents a ReportItem object.
olResults = 78 , // Represents a Results object.
olRow = 121 , // Represents a Row object.
olRule = 115 , // Represents a Rule object.
olRuleAction = 117 , // Represents a RuleAction object.
olRuleActions = 116 , // Represents a RuleAction object.
olRuleCondition = 127 , // Represents a RuleCondition object.
olRuleConditions = 126 , // Represents a RuleConditions object.
olRules = 114 , // Represents a Rules object.
olSearch = 77 , // Represents a Search object.
olSelection = 74 , // Represents a Selection object.
olSelectNamesDialog = 109 , // Represents a SelectNamesDialog object.
olSenderInAddressListRuleCondition = 133 , // Represents a SenderInAddressListRuleCondition object.
olSendRuleAction = 119 , // Represents a SendRuleAction object.
olSharing = 104 , // Represents a SharingItem object.
olStorageItem = 113 , // Represents a StorageItem object.
olStore = 107 , // Represents a Store object.
olStores = 108 , // Represents a Stores object.
olSyncObject = 72 , // Represents a SyncObject object.
olSyncObjects = 73 , // Represents a SyncObject object.
olTable = 120 , // Represents a Table object.
olTask = 48 , // Represents a TaskItem object.
olTaskRequest = 49 , // Represents a TaskRequestItem object.
olTaskRequestAccept = 51 , // Represents a TaskRequestAcceptItem object.
olTaskRequestDecline = 52 , // Represents a TaskRequestDeclineItem object.
olTaskRequestUpdate = 50 , // Represents a TaskRequestUpdateItem object.
olTasksModule = 161 , // Represents a TasksModule object.
olTextRuleCondition = 134 , // Represents a TextRuleCondition object.
olUserDefinedProperties = 172 , // Represents a UserDefinedProperties object.
olUserDefinedProperty = 171 , // Represents a UserDefinedProperty object.
olUserProperties = 38 , // Represents a UserProperties object.
olUserProperty = 39 , // Represents a UserProperty object.
olView = 80 , // Represents a View object.
olViewField = 142 , // Represents a ViewField object.
olViewFields = 141 , // Represents a ViewFields object.
olViewFont = 146 , // Represents a ViewFont object.
olViews = 79 // Represents a Views object.
}
public enum OlItemType {
// Fields
olAppointmentItem = 1,
olContactItem = 2,
olDistributionListItem = 7,
olJournalItem = 4,
olMailItem = 0,
olNoteItem = 5,
olPostItem = 6,
olTaskItem = 3
}
public enum OlEditorType {
// Fields
olEditorHTML = 2,
olEditorRTF = 3,
olEditorText = 1,
olEditorWord = 4
}
public enum OlWindowState {
// Fields
olMaximized = 0,
olMinimized = 1,
olNormalWindow = 2
}
public enum OlInspectorClose {
// Fields
olDiscard = 1,
olPromptForSave = 2,
olSave = 0
}
public enum MsoTriState {
msoTrue = -1,
msoFalse = 0,
msoCTrue = 1,
msoTriStateToggle = -3,
msoTriStateMixed = -2
}
public enum MsoScaleFrom {
msoScaleFromTopLeft = 0,
msoScaleFromMiddle = 1,
msoScaleFromBottomRight = 2
}
// Schema definitions for the MAPI properties
// See: http://msdn.microsoft.com/en-us/library/aa454438.aspx
// and see: http://msdn.microsoft.com/en-us/library/bb446117.aspx
public static class PropTag {
public const string ATTACHMENT_CONTENT_ID = @"http://schemas.microsoft.com/mapi/proptag/0x3712001E";
}
}

View file

@ -1,854 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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 Greenshot.Helpers.OfficeInterop {
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,
};
public class OutlookUtils {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OutlookUtils));
private const uint KEEP_OPEN_READONLY = 0x00000001;
private const uint KEEP_OPEN_READWRITE = 0x00000002;
private const uint FORCE_SAVE = 0x00000004;
#region MAPI Interface ID'S
// 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";
#endregion
[ComVisible(false)]
[ComImport()]
[Guid(IID_IMAPIProp)]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
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)]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
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 uint alignPad;
[FieldOffset(8)]
public IntPtr Value;
[FieldOffset(8)]
public long filler;
}
/// <summary>
/// Use MAPI32.DLL "HrGetOneProp" from managed code
/// </summary>
/// <param name="attachment"></param>
/// <param name="proptag"></param>
/// <returns></returns>
public static string GetMAPIProperty(Attachment attachment, PropTags proptag) {
object mapiObject = attachment.MAPIOBJECT;
if (mapiObject == null) {
return "";
}
string sProperty = "";
IntPtr pPropValue = IntPtr.Zero;
IntPtr IUnknown = IntPtr.Zero;
IntPtr IMAPIProperty = IntPtr.Zero;
try {
MAPIInitialize(IntPtr.Zero);
IUnknown = Marshal.GetIUnknownForObject(mapiObject);
Guid guidMAPIProp = new Guid(IID_IMAPIProp);
if (Marshal.QueryInterface(IUnknown, ref guidMAPIProp, out IMAPIProperty) != 0) {
return "";
}
try {
HrGetOneProp(IMAPIProperty, (uint)proptag, out pPropValue);
if (pPropValue == IntPtr.Zero) {
return "";
}
SPropValue propValue = (SPropValue)Marshal.PtrToStructure(pPropValue, typeof(SPropValue));
sProperty = Marshal.PtrToStringUni(propValue.Value);
} catch (System.Exception ex) {
throw ex;
}
} finally {
if (pPropValue != IntPtr.Zero) {
MAPIFreeBuffer(pPropValue);
}
if (IMAPIProperty != IntPtr.Zero) {
Marshal.Release(IMAPIProperty);
}
if (IUnknown != IntPtr.Zero) {
Marshal.Release(IUnknown);
}
MAPIUninitialize();
}
return sProperty;
}
/// <summary>
/// Tries to save the changes we just made
/// </summary>
/// <param name="mailItem"></param>
/// <returns></returns>
public static bool SaveChanges(Item 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(Attachment 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();
propValue.propTag = (uint)PropTags.PR_ATTACH_CONTENT_ID;
//propValue.propTag = 0x3712001E;
// Create Ansi string
propValue.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(Attachment 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();
propValue.propTag = (uint)proptag;
// Create Ansi string
propValue.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 (System.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();
}
}
#region MAPI DLL Imports
[DllImport("MAPI32.DLL", CharSet = CharSet.Ansi, EntryPoint = "HrGetOneProp@12")]
private static extern void HrGetOneProp(IntPtr pmp, uint ulPropTag, out IntPtr ppProp);
[DllImport("MAPI32.DLL", CharSet = CharSet.Ansi, EntryPoint = "HrSetOneProp@8")]
private static extern void HrSetOneProp(IntPtr pmp, IntPtr pprop);
[DllImport("MAPI32.DLL", CharSet = CharSet.Ansi, EntryPoint = "MAPIFreeBuffer@4")]
private static extern void MAPIFreeBuffer(IntPtr lpBuffer);
[DllImport("MAPI32.DLL", CharSet = CharSet.Ansi)]
private static extern int MAPIInitialize(IntPtr lpMapiInit);
[DllImport("MAPI32.DLL", CharSet = CharSet.Ansi)]
private static extern void MAPIUninitialize();
#endregion
}
}

View file

@ -1,510 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Greenshot.Helpers.IEInterop;
using Greenshot.Interop;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using IniFile;
using Microsoft.Win32;
/// <summary>
/// This utils class should help setting the content-id on the attachment for Outlook < 2007
/// But this somehow doesn't work yet
/// </summary>
namespace Greenshot.Helpers.OfficeInterop {
/// <summary>
/// Wrapper for Outlook.Application, see: http://msdn.microsoft.com/en-us/library/aa210897%28v=office.11%29.aspx
/// </summary>
[ComProgId("Outlook.Application")]
public interface IOutlookApplication : Common {
string Name { get; }
string Version { get; }
Item CreateItem(OlItemType ItemType);
object CreateItemFromTemplate(string TemplatePath, object InFolder);
object CreateObject(string ObjectName);
Inspector ActiveInspector();
Inspectors Inspectors { get; }
INameSpace GetNameSpace(string type);
}
public interface INameSpace : Common {
IRecipient CurrentUser { get; }
}
public interface IRecipient : Common {
string Name { get; }
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.inspector_members.aspx
public interface Inspector : Common {
Item 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; }
string Caption { get; }
int Height { get; set; }
int Left { get; set; }
int Top { get; set; }
int Width { get; set; }
OlWindowState WindowState { get; set; }
void Activate();
void SetControlItemProperty(object Control, string PropertyName);
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._application.inspectors.aspx
public interface Inspectors : Common, Collection, IEnumerable {
Inspector this[Object Index] { get; }
}
/// <summary>
/// Outlook exporter has all the functionality to export to outlook
/// </summary>
public class OutlookExporter {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OutlookExporter));
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
private static readonly string SIGNATURE_PATH = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Microsoft\Signatures");
private static Version outlookVersion = new Version(1,1,1,1);
private static string currentUser = null;
// The signature key can be found at:
// HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\<DefaultProfile>\9375CFF0413111d3B88A00104B2A6676\<xxxx> [New Signature]
private const string PROFILES_KEY = @"Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\";
private const string ACCOUNT_KEY = "9375CFF0413111d3B88A00104B2A6676";
private const string NEW_SIGNATURE_VALUE = "New Signature";
private const string DEFAULT_PROFILE_VALUE = "DefaultProfile";
/// <summary>
/// A method to retrieve all inspectors which can act as an export target
/// </summary>
/// <param name="outlookApplication">IOutlookApplication</param>
/// <returns>List<string> with inspector captions (window title)</returns>
public static Dictionary<string, OlObjectClass> RetrievePossibleTargets() {
Dictionary<string, OlObjectClass> inspectorCaptions = new Dictionary<string, OlObjectClass>();
try {
using ( IOutlookApplication outlookApplication = GetOutlookApplication()) {
if (outlookApplication == null) {
return null;
}
Inspectors inspectors = outlookApplication.Inspectors;
if (inspectors != null && inspectors.Count > 0) {
for(int i=1; i <= inspectors.Count; i++) {
Inspector inspector = outlookApplication.Inspectors[i];
if (canExportToInspector(inspector)) {
Item currentItem = inspector.CurrentItem;
OlObjectClass currentItemClass = currentItem.Class;
inspectorCaptions.Add(inspector.Caption, currentItemClass);
}
}
}
}
} catch (Exception ex) {
LOG.Warn("Problem retrieving word destinations, ignoring: ", ex);
}
return inspectorCaptions;
}
/// <summary>
/// Return true if we can export to the supplied inspector
/// </summary>
/// <param name="inspector"></param>
/// <returns></returns>
private static bool canExportToInspector(Inspector inspector) {
try {
Item currentItem = inspector.CurrentItem;
if (currentItem != null) {
OlObjectClass currentItemClass = currentItem.Class;
if (OlObjectClass.olMail.Equals(currentItemClass)) {
if (!currentItem.Sent) {
return true;
}
} else if (outlookVersion.Major >= 12 && conf.OutlookAllowExportInMeetings && OlObjectClass.olAppointment.Equals(currentItemClass)) {
if (string.IsNullOrEmpty(currentItem.Organizer) || (currentUser == null && currentUser.Equals(currentItem.Organizer))) {
return true;
} else {
LOG.DebugFormat("Not exporting to {0}, as organizer is {1} and currentuser {2}", inspector.Caption, currentItem.Organizer, currentUser);
}
}
}
} catch (Exception ex) {
LOG.WarnFormat("Couldn't process item due to: {0}", ex.Message);
}
return false;
}
/// <summary>
/// Export the image stored in tmpFile to the Inspector with the caption
/// </summary>
/// <param name="inspectorCaption">Caption of the inspector</param>
/// <param name="tmpFile">Path to image file</param>
/// <param name="attachmentName">name of the attachment (used as the tooltip of the image)</param>
/// <returns>true if it worked</returns>
public static bool ExportToInspector(string inspectorCaption, string tmpFile, string attachmentName) {
using ( IOutlookApplication outlookApplication = GetOrCreateOutlookApplication()) {
if (outlookApplication != null) {
Inspectors inspectors = outlookApplication.Inspectors;
if (inspectors != null && inspectors.Count > 0) {
LOG.DebugFormat("Got {0} inspectors to check", inspectors.Count);
for(int i=1; i <= inspectors.Count; i++) {
Inspector inspector = outlookApplication.Inspectors[i];
string currentCaption = inspector.Caption;
if (currentCaption.StartsWith(inspectorCaption)) {
if (canExportToInspector(inspector)) {
try {
return ExportToInspector(inspector, tmpFile, attachmentName);
} catch (Exception exExport) {
LOG.Error("Export to " + currentCaption + " failed.", exExport);
}
}
}
}
}
}
}
return false;
}
/// <summary>
/// Export the file to the supplied inspector
/// </summary>
/// <param name="inspector"></param>
/// <param name="tmpFile"></param>
/// <param name="attachmentName"></param>
/// <returns></returns>
private static bool ExportToInspector(Inspector inspector, string tmpFile, string attachmentName) {
Item currentItem = inspector.CurrentItem;
if (currentItem == null) {
LOG.Warn("No current item.");
return false;
}
OlObjectClass itemClass = currentItem.Class;
bool isMail = OlObjectClass.olMail.Equals(itemClass);
bool isAppointment = OlObjectClass.olAppointment.Equals(itemClass);
if (!isMail && !isAppointment) {
LOG.Warn("Item is no mail or appointment.");
return false;
}
try {
if (isMail && currentItem.Sent) {
LOG.WarnFormat("Item already sent, can't export to {0}", currentItem.Subject);
return false;
}
// Make sure the inspector is activated, only this way the word editor is active!
// This also ensures that the window is visible!
inspector.Activate();
// Check for wordmail, if so use the wordexporter
// http://msdn.microsoft.com/en-us/library/dd492012%28v=office.12%29.aspx
// Earlier versions of Outlook also supported an Inspector.HTMLEditor object property, but since Internet Explorer is no longer the rendering engine for HTML messages and posts, HTMLEditor is no longer supported.
if (inspector.IsWordMail() && inspector.WordEditor != null) {
if (WordExporter.InsertIntoExistingDocument(inspector.WordEditor, tmpFile)) {
LOG.Info("Inserted into Wordmail");
// check the format afterwards, otherwise we lose the selection
//if (!OlBodyFormat.olFormatHTML.Equals(currentMail.BodyFormat)) {
// LOG.Info("Changing format to HTML.");
// currentMail.BodyFormat = OlBodyFormat.olFormatHTML;
//}
return true;
}
} else if (isAppointment) {
LOG.Info("Can't export to an appointment if no word editor is used");
return false;
} else {
LOG.Info("Trying export for word < 2007.");
}
LOG.InfoFormat("Item '{0}' has format: {1}", currentItem.Subject, currentItem.BodyFormat);
string contentID;
if (outlookVersion.Major >=12 ) {
contentID = Guid.NewGuid().ToString();
} else {
LOG.Info("Older Outlook (<2007) found, using filename as contentid.");
contentID = Path.GetFileName(tmpFile);
}
// Use this to change the format, it will probably lose the current selection.
//if (!OlBodyFormat.olFormatHTML.Equals(currentMail.BodyFormat)) {
// LOG.Info("Changing format to HTML.");
// currentMail.BodyFormat = OlBodyFormat.olFormatHTML;
//}
bool inlinePossible = false;
if (OlBodyFormat.olFormatHTML.Equals(currentItem.BodyFormat)) {
// if html we can try to inline it
// The following might cause a security popup... can't ignore it.
try {
IHTMLDocument2 document2 = inspector.HTMLEditor as IHTMLDocument2;
if (document2 != null) {
IHTMLSelectionObject selection = document2.selection;
if (selection != null) {
IHTMLTxtRange range = selection.createRange();
if (range != null) {
// First paste, than attach (otherwise the range is wrong!)
range.pasteHTML("<BR/><IMG border=0 hspace=0 alt=\"" + attachmentName + "\" align=baseline src=\"cid:"+ contentID +"\"><BR/>");
inlinePossible = true;
} else {
LOG.DebugFormat("No range for '{0}'", inspector.Caption);
}
} else {
LOG.DebugFormat("No selection for '{0}'", inspector.Caption);
}
} else {
LOG.DebugFormat("No HTML editor for '{0}'", inspector.Caption);
}
} catch (Exception e) {
// Continue with non inline image
LOG.Warn("Error pasting HTML, most likely due to an ACCESS_DENIED as the user clicked no.", e);
}
}
// Create the attachment (if inlined the attachment isn't visible as attachment!)
Attachment attachment = currentItem.Attachments.Add(tmpFile, OlAttachmentType.olByValue, inlinePossible?0:1, attachmentName);
if (outlookVersion.Major >=12) {
// Add the content id to the attachment, this only works for Outlook >= 2007
try {
PropertyAccessor propertyAccessor = attachment.PropertyAccessor;
propertyAccessor.SetProperty(PropTag.ATTACHMENT_CONTENT_ID, contentID);
} catch {
}
}
} catch (Exception ex) {
LOG.WarnFormat("Problem while trying to add attachment to Item '{0}' : {1}", inspector.Caption, ex);
return false;
}
LOG.Debug("Finished!");
return true;
}
/// <summary>
/// Export image to a new email
/// </summary>
/// <param name="outlookApplication"></param>
/// <param name="tmpFile"></param>
/// <param name="captureDetails"></param>
private static void ExportToNewEmail(IOutlookApplication outlookApplication, string tmpFile, string subject, string attachmentName) {
Item newMail = outlookApplication.CreateItem( OlItemType.olMailItem );
if (newMail == null) {
return;
}
newMail.Subject = subject;
newMail.BodyFormat = OlBodyFormat.olFormatHTML;
string bodyString = null;
// Read the default signature, if nothing found use empty email
try {
bodyString = GetOutlookSignature();
} catch (Exception e) {
LOG.Error("Problem reading signature!", e);
}
switch(conf.OutlookEmailFormat) {
case EmailFormat.Text:
newMail.Attachments.Add(tmpFile, OlAttachmentType.olByValue, 1, attachmentName);
newMail.BodyFormat = OlBodyFormat.olFormatPlain;
if (bodyString == null) {
bodyString = "";
}
newMail.Body = bodyString;
break;
case EmailFormat.HTML:
default:
// Create the attachment
Attachment attachment = newMail.Attachments.Add(tmpFile, OlAttachmentType.olByValue, 0, attachmentName);
// add content ID to the attachment
string contentID = Path.GetFileName(tmpFile);
if (outlookVersion.Major >=12) {
// Add the content id to the attachment
try {
contentID = Guid.NewGuid().ToString();
PropertyAccessor propertyAccessor = attachment.PropertyAccessor;
propertyAccessor.SetProperty(PropTag.ATTACHMENT_CONTENT_ID, contentID);
} catch {
LOG.Info("Error working with the PropertyAccessor, using filename as contentid");
contentID = Path.GetFileName(tmpFile);
}
}
newMail.BodyFormat = OlBodyFormat.olFormatHTML;
string htmlImgEmbedded = "<BR/><IMG border=0 hspace=0 alt=\"" + attachmentName + "\" align=baseline src=\"cid:"+ contentID +"\"><BR/>";
string fallbackBody = "<HTML><BODY>" + htmlImgEmbedded + "</BODY></HTML>";
if (bodyString == null) {
bodyString = fallbackBody;
} else {
int bodyIndex = bodyString.IndexOf("<body", StringComparison.CurrentCultureIgnoreCase);
if (bodyIndex >= 0) {
bodyIndex = bodyString.IndexOf(">", bodyIndex) + 1;
if (bodyIndex >= 0) {
bodyString = bodyString.Insert(bodyIndex, htmlImgEmbedded);
} else {
bodyString = fallbackBody;
}
} else {
bodyString = fallbackBody;
}
}
newMail.HTMLBody = bodyString;
break;
}
// So not save, otherwise the email is always stored in Draft folder.. (newMail.Save();)
newMail.Display(false);
}
private static bool ExportToMail(IOutlookApplication outlookApplication, string tmpFile, string subject, string attachmentName) {
bool exported = false;
if (outlookApplication != null) {
ExportToNewEmail(outlookApplication, tmpFile, subject, attachmentName);
exported = true;
}
return exported;
}
/// <summary>
/// Helper method to create the outlook mail item with attachment
/// </summary>
/// <param name="tmpfile">The file to send</param>
/// <returns>true if it worked, false if not</returns>
public static bool ExportToOutlook(string tmpFile, string subject, string attachmentName) {
try {
bool exported = false;
using ( IOutlookApplication outlookApplication = GetOrCreateOutlookApplication()) {
if (outlookApplication != null) {
exported = ExportToMail(outlookApplication, tmpFile, subject, attachmentName);
}
}
// assuming that the file isn't deleted right away...
// there used to be a sleep here
return exported;
} catch(Exception e) {
LOG.Error("Error while creating an outlook mail item: ", e);
}
return false;
}
/// <summary>
/// Helper method to get the Outlook signature
/// </summary>
/// <returns></returns>
private static string GetOutlookSignature() {
using (RegistryKey profilesKey = Registry.CurrentUser.OpenSubKey(PROFILES_KEY, false)) {
if (profilesKey == null) {
return null;
}
string defaultProfile = (string)profilesKey.GetValue(DEFAULT_PROFILE_VALUE);
LOG.DebugFormat("defaultProfile={0}",defaultProfile);
using (RegistryKey profileKey = profilesKey.OpenSubKey(defaultProfile + @"\" + ACCOUNT_KEY, false)) {
if (profilesKey == null) {
return null;
}
string [] numbers = profileKey.GetSubKeyNames();
foreach(string number in numbers) {
LOG.DebugFormat("Found subkey {0}", number);
using (RegistryKey numberKey = profileKey.OpenSubKey(number, false)) {
byte[] val = (byte[])numberKey.GetValue(NEW_SIGNATURE_VALUE);
if (val == null) {
continue;
}
string signatureName = "";
foreach(byte b in val) {
if (b != 0) {
signatureName += (char) b;
}
}
LOG.DebugFormat("Found email signature: {0}", signatureName);
string extension;
switch(conf.OutlookEmailFormat) {
case EmailFormat.Text:
extension = ".txt";
break;
case EmailFormat.HTML:
default:
extension = ".htm";
break;
}
string signatureFile = Path.Combine(SIGNATURE_PATH, signatureName + extension);
if (File.Exists(signatureFile)) {
LOG.DebugFormat("Found email signature file: {0}", signatureFile);
return File.ReadAllText(signatureFile, Encoding.Default);
}
}
}
}
}
return null;
}
/// <summary>
/// Initialize static outlook variables like version and currentuser
/// </summary>
/// <param name="outlookApplication"></param>
private static void InitializeVariables(IOutlookApplication outlookApplication) {
try {
outlookVersion = new Version(outlookApplication.Version);
LOG.InfoFormat("Using Outlook {0}", outlookVersion);
} catch (Exception exVersion) {
LOG.Error(exVersion);
}
try {
INameSpace mapiNamespace = outlookApplication.GetNameSpace("MAPI");
currentUser = mapiNamespace.CurrentUser.Name;
LOG.InfoFormat("Current user: {0}", currentUser);
} catch (Exception exNS) {
LOG.Error(exNS);
}
}
/// <summary>
/// Call this to get the running outlook application, returns null if there isn't any.
/// </summary>
/// <returns>IOutlookApplication or null</returns>
private static IOutlookApplication GetOutlookApplication() {
IOutlookApplication outlookApplication = (IOutlookApplication)COMWrapper.GetInstance(typeof(IOutlookApplication));
InitializeVariables(outlookApplication);
return outlookApplication;
}
/// <summary>
/// Call this to get the running outlook application, or create a new instance
/// </summary>
/// <returns>IOutlookApplication</returns>
private static IOutlookApplication GetOrCreateOutlookApplication() {
IOutlookApplication outlookApplication = (IOutlookApplication)COMWrapper.GetOrCreateInstance(typeof(IOutlookApplication));
InitializeVariables(outlookApplication);
return outlookApplication;
}
}
}

View file

@ -1,236 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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;
using System.Drawing;
using System.Runtime.Remoting.Messaging;
using Greenshot.Interop;
using Greenshot.Plugin;
namespace Greenshot.Helpers.OfficeInterop {
// See http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.application_members.aspx
[ComProgId("Powerpoint.Application")]
public interface IPowerpointApplication : Common {
IPresentation ActivePresentation { get; }
IPresentations Presentations {get;}
bool Visible {get; set;}
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slides_members.aspx
public interface ISlides : Common {
int Count {get;}
ISlide Add(int Index, int layout);
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.presentation_members.aspx
public interface IPresentation : Common {
string Name { get; }
ISlides Slides{ get;}
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.presentations_members.aspx
public interface IPresentations : Common, Collection {
IPresentation Add(MsoTriState WithWindow);
IPresentation item(int index);
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slide_members.aspx
public interface ISlide : Common {
IShapes Shapes {get;}
void Select();
int SlideNumber { get; }
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shapes_members.aspx
public interface IShapes : Common, IEnumerable {
int Count {get;}
IShape item(int index);
IShape AddPicture(string FileName, MsoTriState LinkToFile, MsoTriState SaveWithDocument, float Left, float Top, float Width, float Height);
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shape_members.aspx
public interface IShape : Common {
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);
}
public interface ITextFrame : Common {
ITextRange TextRange {get;}
}
public interface ITextRange : Common {
string Text { get; set; }
}
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
}
public class PowerpointExporter {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PowerpointExporter));
private static IPowerpointApplication GetOrCreatePowerpointApplication() {
return (IPowerpointApplication)COMWrapper.GetOrCreateInstance(typeof(IPowerpointApplication));
}
private static IPowerpointApplication GetPowerpointApplication() {
return (IPowerpointApplication)COMWrapper.GetInstance(typeof(IPowerpointApplication));
}
/// <summary>
/// Get the captions of all the open powerpoint presentations
/// </summary>
/// <returns></returns>
public static System.Collections.Generic.List<string> GetPowerpointPresentations() {
System.Collections.Generic.List<string> presentations = new System.Collections.Generic.List<string>();
try {
using( IPowerpointApplication powerpointApplication = GetPowerpointApplication() ) {
if (powerpointApplication != null) {
LOG.DebugFormat("Open Presentations: {0}", powerpointApplication.Presentations.Count);
for(int i = 1; i <= powerpointApplication.Presentations.Count ; i ++) {
IPresentation presentation = powerpointApplication.Presentations.item(i);
if (presentation != null) {
presentations.Add(presentation.Name);
}
}
}
}
} catch (Exception ex) {
LOG.Warn("Problem retrieving word destinations, ignoring: ", ex);
}
return presentations;
}
/// <summary>
/// Export the image from the tmpfile to the presentation with the supplied name
/// </summary>
/// <param name="presentationName"></param>
/// <param name="tmpFile"></param>
/// <param name="imageSize"></param>
/// <param name="captureDetails"></param>
/// <returns></returns>
public static bool ExportToPresentation(string presentationName, string tmpFile, Size imageSize, ICaptureDetails captureDetails) {
using( IPowerpointApplication powerpointApplication = GetPowerpointApplication() ) {
if (powerpointApplication != null) {
LOG.DebugFormat("Open Presentations: {0}", powerpointApplication.Presentations.Count);
for(int i = 1; i <= powerpointApplication.Presentations.Count ; i ++) {
IPresentation presentation = powerpointApplication.Presentations.item(i);
if (presentation != null && presentation.Name.StartsWith(presentationName)) {
try {
AddPictureToPresentation(presentation, tmpFile, imageSize, captureDetails);
return true;
} catch (Exception e){
LOG.Error(e);
}
}
}
}
}
return false;
}
private static void AddPictureToPresentation(IPresentation presentation, string tmpFile, Size imageSize, ICaptureDetails captureDetails) {
if (presentation != null) {
//ISlide slide = presentation.Slides.AddSlide( presentation.Slides.Count + 1, PPSlideLayout.ppLayoutPictureWithCaption);
ISlide slide;
float left = 0;
float top = 0;
bool isLayoutPictureWithCaption = false;
try {
slide = presentation.Slides.Add( presentation.Slides.Count + 1, (int)PPSlideLayout.ppLayoutPictureWithCaption);
isLayoutPictureWithCaption = true;
// Shapes[2] is the image shape on this layout.
IShape shapeForLocation = slide.Shapes.item(2);
shapeForLocation.Width = imageSize.Width;
shapeForLocation.Height = imageSize.Height;
left = shapeForLocation.Left;
top = shapeForLocation.Top;
LOG.DebugFormat("Shape {0},{1},{2},{3}", shapeForLocation.Left, shapeForLocation.Top, imageSize.Width, imageSize.Height);
} catch (Exception e) {
LOG.Error(e);
slide = presentation.Slides.Add( presentation.Slides.Count + 1, (int)PPSlideLayout.ppLayoutBlank);
}
IShape shape = slide.Shapes.AddPicture(tmpFile, MsoTriState.msoFalse, MsoTriState.msoTrue, left, top, imageSize.Width, imageSize.Height);
shape.Width = imageSize.Width;
shape.Height = imageSize.Height;
shape.ScaleWidth(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromMiddle);
shape.ScaleHeight(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromMiddle);
if (isLayoutPictureWithCaption) {
try {
// Using try/catch to make sure problems with the text range don't give an exception.
shape.TextFrame.TextRange.Text = captureDetails.Title;
} catch {};
}
}
}
public static void InsertIntoNewPresentation(string tmpFile, Size imageSize, ICaptureDetails captureDetails) {
using( IPowerpointApplication powerpointApplication = GetOrCreatePowerpointApplication() ) {
if (powerpointApplication != null) {
powerpointApplication.Visible = true;
IPresentation presentation = powerpointApplication.Presentations.Add(MsoTriState.msoTrue);
AddPictureToPresentation(presentation, tmpFile, imageSize, captureDetails);
}
}
}
}
}

View file

@ -1,171 +0,0 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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;
using Greenshot.Interop;
namespace Greenshot.Helpers.OfficeInterop {
// 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 : Common {
IWordDocument ActiveDocument { get; }
ISelection Selection { get; }
IDocuments Documents { get; }
bool Visible { get; set; }
}
// See: http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.documents_members(v=office.11).aspx
public interface IDocuments : Common, Collection {
void Add(ref object Template, ref object NewTemplate, ref object DocumentType, ref object Visible);
IWordDocument item(int index);
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.document.aspx
public interface IWordDocument : Common {
IWordApplication Application { get; }
Window ActiveWindow { get; }
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.window_members.aspx
public interface Window : Common {
Pane ActivePane { get; }
string Caption {
get;
}
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.pane_members.aspx
public interface Pane : Common {
View View { get; }
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.view_members.aspx
public interface View : Common {
Zoom Zoom { get; }
}
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.zoom_members.aspx
public interface Zoom : Common {
int Percentage { get; set; }
}
// See: http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.selection_members(v=office.11).aspx
public interface ISelection : Common {
IInlineShapes InlineShapes { get; }
void InsertAfter(string text);
}
public interface IInlineShapes : Common {
object AddPicture(string FileName, object LinkToFile, object SaveWithDocument, object Range);
}
public class WordExporter {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordExporter));
private static IWordApplication GetOrCreateWordApplication() {
return (IWordApplication)COMWrapper.GetOrCreateInstance(typeof(IWordApplication));
}
private static IWordApplication GetWordApplication() {
return (IWordApplication)COMWrapper.GetInstance(typeof(IWordApplication));
}
/// <summary>
/// Insert the bitmap stored under the tempfile path into the word document with the supplied caption
/// </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) {
for(int i = 1; i <= wordApplication.Documents.Count ; i ++) {
IWordDocument wordDocument = wordApplication.Documents.item(i);
if (wordDocument.ActiveWindow.Caption.StartsWith(wordCaption)) {
return InsertIntoExistingDocument(wordDocument, tmpFile);
}
}
}
}
return false;
}
internal static bool InsertIntoExistingDocument(IWordDocument wordDocument, string tmpFile) {
if (wordDocument.Application.Selection != null) {
AddPictureToSelection(wordDocument.Application.Selection, tmpFile);
try {
wordDocument.ActiveWindow.ActivePane.View.Zoom.Percentage = 100;
} catch(Exception e) {
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);
}
}
return true;
}
return false;
}
private static void AddPictureToSelection(ISelection selection, string tmpFile) {
selection.InlineShapes.AddPicture(tmpFile, Type.Missing, Type.Missing, Type.Missing);
//selection.InsertAfter("blablub\r\n");
}
public static void InsertIntoNewDocument(string tmpFile) {
using( IWordApplication wordApplication = GetOrCreateWordApplication() ) {
if (wordApplication != null) {
wordApplication.Visible = true;
// Create new Document
object template = string.Empty;
object newTemplate = false;
object documentType = 0;
object documentVisible = true;
wordApplication.Documents.Add(ref template, ref newTemplate, ref documentType, ref documentVisible);
// Add Picture
AddPictureToSelection(wordApplication.Selection, tmpFile);
}
}
}
/// <summary>
/// Get the captions of all the open word documents
/// </summary>
/// <returns></returns>
public static System.Collections.Generic.List<string> GetWordDocuments() {
System.Collections.Generic.List<string> documents = new System.Collections.Generic.List<string>();
try {
using(IWordApplication wordApplication = GetWordApplication()) {
if (wordApplication != null) {
//documents.Add(wordApplication.ActiveDocument);
for(int i = 1; i <= wordApplication.Documents.Count ; i ++) {
IWordDocument document = wordApplication.Documents.item(i);
documents.Add(document.ActiveWindow.Caption);
}
}
}
} catch (Exception ex) {
LOG.Warn("Problem retrieving word destinations, ignoring: ", ex);
}
return documents;
}
}
}

View file

@ -28,7 +28,7 @@ using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using IniFile;
using Greenshot.IniFile;
namespace Greenshot.Helpers {
/// <summary>

View file

@ -28,7 +28,7 @@ using Greenshot.Drawing;
using Greenshot.Forms;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using IniFile;
using Greenshot.IniFile;
namespace Greenshot.Helpers {
/// <summary>

View file

@ -35,7 +35,7 @@ using Greenshot.Configuration;
using Greenshot.Plugin;
using GreenshotPlugin.UnmanagedHelpers;
using GreenshotPlugin.Core;
using IniFile;
using Greenshot.IniFile;
namespace Greenshot.Helpers {
/// <summary>
@ -62,6 +62,7 @@ namespace Greenshot.Helpers {
private IntPtr bits0 = IntPtr.Zero; //pointer to the raw bits that make up the bitmap.
private Bitmap GDIBitmap;
private string filename = null;
private Stopwatch stopwatch = new Stopwatch();
public ScreenCaptureHelper(Rectangle recordingRectangle) {
this.recordingRectangle = recordingRectangle;
@ -190,8 +191,9 @@ namespace Greenshot.Helpers {
private void CaptureFrame() {
int MSBETWEENCAPTURES = 1000/framesPerSecond;
int msToNextCapture = MSBETWEENCAPTURES;
stopwatch.Reset();
while (!stop) {
DateTime nextCapture = DateTime.Now.AddMilliseconds(msToNextCapture);
stopwatch.Start();
Point captureLocation;
if (recordingWindow != null) {
recordingWindow.Reset();
@ -219,18 +221,35 @@ namespace Greenshot.Helpers {
LOG.Error("Error adding frame to avi, stopping capturing.");
break;
}
int sleeptime = (int)(nextCapture.Subtract(DateTime.Now).Ticks / TimeSpan.TicksPerMillisecond);
if (sleeptime > 0) {
Thread.Sleep(sleeptime);
msToNextCapture = MSBETWEENCAPTURES;
} else {
// Compensating
do {
aviWriter.AddEmptyFrame();
sleeptime += MSBETWEENCAPTURES;
} while (sleeptime < 0);
msToNextCapture = sleeptime;
int restTime = (int)(msToNextCapture - stopwatch.ElapsedMilliseconds);
// Set time to next capture, we correct it if needed later.
msToNextCapture = MSBETWEENCAPTURES;
if (restTime > 0) {
// We were fast enough, we wait for next capture
Thread.Sleep(restTime);
} else if (restTime < 0) {
// Compensating, as we took to long
int framesToSkip = ((-restTime) / MSBETWEENCAPTURES);
int leftoverMillis = (-restTime) % MSBETWEENCAPTURES;
//LOG.InfoFormat("Adding {0} empty frames to avi, leftover millis is {1}, sleeping {2} (of {3} total)", framesToSkip, leftover, sleepMillis, MSBETWEENCAPTURES);
aviWriter.AddEmptyFrames(framesToSkip);
// check how bad it is, if we only missed our target by a few millis we hope the next capture corrects this
if (leftoverMillis > 0 && leftoverMillis <= 2) {
// subtract the leftover from the millis to next capture, do nothing else
msToNextCapture -= leftoverMillis;
} else if (leftoverMillis > 0) {
// it's more, we add an empty frame
aviWriter.AddEmptyFrames(1);
// we sleep to the next time and
int sleepMillis = MSBETWEENCAPTURES - leftoverMillis;
// Sleep to next capture
Thread.Sleep(sleepMillis);
}
}
stopwatch.Reset();
}
Cleanup();
}

View file

@ -29,7 +29,7 @@ using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
using IniFile;
using Greenshot.IniFile;
namespace Greenshot.Experimental {
/// <summary>