diff --git a/GreenshotOfficePlugin/Destinations/OutlookDestination.cs b/GreenshotOfficePlugin/Destinations/OutlookDestination.cs
index 4ee32bdc5..3e9ad5231 100644
--- a/GreenshotOfficePlugin/Destinations/OutlookDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/OutlookDestination.cs
@@ -186,7 +186,7 @@ namespace GreenshotOfficePlugin {
return ShowPickerMenu(false, surface, captureDetails, destinations);
}
} else {
- exportInformation.ExportMade = OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, FilenameHelper.FillPattern(conf.EmailSubjectPattern, captureDetails, false), attachmentName, conf.EmailTo, conf.EmailCC, conf.EmailBCC);
+ exportInformation.ExportMade = OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, FilenameHelper.FillPattern(conf.EmailSubjectPattern, captureDetails, false), attachmentName, conf.EmailTo, conf.EmailCC, conf.EmailBCC, null);
}
}
ProcessExport(exportInformation, surface);
diff --git a/GreenshotOfficePlugin/Destinations/WordDestination.cs b/GreenshotOfficePlugin/Destinations/WordDestination.cs
index 9a9ead70c..977ac087c 100644
--- a/GreenshotOfficePlugin/Destinations/WordDestination.cs
+++ b/GreenshotOfficePlugin/Destinations/WordDestination.cs
@@ -142,12 +142,12 @@ namespace GreenshotOfficePlugin {
}
}
try {
- WordExporter.InsertIntoNewDocument(tmpFile);
+ WordExporter.InsertIntoNewDocument(tmpFile, null);
exportInformation.ExportMade = true;
} catch(Exception) {
// Retry once, just in case
try {
- WordExporter.InsertIntoNewDocument(tmpFile);
+ WordExporter.InsertIntoNewDocument(tmpFile, null);
exportInformation.ExportMade = true;
} catch (Exception ex) {
LOG.Error(ex);
diff --git a/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs b/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs
index 389314578..238c78a6d 100644
--- a/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs
+++ b/GreenshotOfficePlugin/OfficeExport/OutlookEmailExporter.cs
@@ -289,7 +289,7 @@ namespace Greenshot.Interop.Office {
///
///
///
- private static void ExportToNewEmail(IOutlookApplication outlookApplication, EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string CC, string BCC) {
+ private static void ExportToNewEmail(IOutlookApplication outlookApplication, EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string CC, string BCC, string url) {
Item newItem = outlookApplication.CreateItem(OlItemType.olMailItem);
if (newItem == null) {
return;
@@ -342,7 +342,13 @@ namespace Greenshot.Interop.Office {
}
newMail.BodyFormat = OlBodyFormat.olFormatHTML;
- string htmlImgEmbedded = "

";
+ string href = "";
+ string hrefEnd = "";
+ if (!string.IsNullOrEmpty(url)) {
+ href = string.Format("", url);
+ hrefEnd = "";
+ }
+ string htmlImgEmbedded = string.Format("
{0}
", href, attachmentName, contentID, hrefEnd);
string fallbackBody = "
" + htmlImgEmbedded + "";
if (bodyString == null) {
bodyString = fallbackBody;
@@ -376,12 +382,12 @@ namespace Greenshot.Interop.Office {
///
/// The file to send, do not delete the file right away!
/// true if it worked, false if not
- public static bool ExportToOutlook(EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string CC, string BCC) {
+ public static bool ExportToOutlook(EmailFormat format, string tmpFile, string subject, string attachmentName, string to, string CC, string BCC, string url) {
bool exported = false;
try {
using (IOutlookApplication outlookApplication = GetOrCreateOutlookApplication()) {
if (outlookApplication != null) {
- ExportToNewEmail(outlookApplication, format, tmpFile, subject, attachmentName, to, CC, BCC);
+ ExportToNewEmail(outlookApplication, format, tmpFile, subject, attachmentName, to, CC, BCC, url);
exported = true;
}
}
diff --git a/GreenshotOfficePlugin/OfficeExport/WordExporter.cs b/GreenshotOfficePlugin/OfficeExport/WordExporter.cs
index 55eecf3d6..31b7b0228 100644
--- a/GreenshotOfficePlugin/OfficeExport/WordExporter.cs
+++ b/GreenshotOfficePlugin/OfficeExport/WordExporter.cs
@@ -62,10 +62,25 @@ namespace Greenshot.Interop.Office {
///
///
///
+ /// link for the image
+ /// tooltip of the image
///
- internal static bool InsertIntoExistingDocument(IWordApplication wordApplication, IWordDocument wordDocument, string tmpFile) {
+ internal static bool InsertIntoExistingDocument(IWordApplication wordApplication, IWordDocument wordDocument, string tmpFile, string address, string tooltip) {
if (wordApplication.Selection != null) {
- AddPictureToSelection(wordApplication.Selection, tmpFile);
+ // Add Picture
+ using (IInlineShape shape = AddPictureToSelection(wordApplication.Selection, tmpFile)) {
+ if (!string.IsNullOrEmpty(address)) {
+ object screentip = Type.Missing;
+ if (!string.IsNullOrEmpty(tooltip)) {
+ screentip = tooltip;
+ }
+ try {
+ wordDocument.Hyperlinks.Add(shape, screentip, Type.Missing, screentip, Type.Missing, Type.Missing);
+ } catch (Exception e) {
+ LOG.WarnFormat("Couldn't add hyperlink for image: {0}", e.Message);
+ }
+ }
+ }
try {
wordDocument.ActiveWindow.ActivePane.View.Zoom.Percentage = 100;
} catch (Exception e) {
@@ -89,12 +104,13 @@ namespace Greenshot.Interop.Office {
return false;
}
- private static void AddPictureToSelection(ISelection selection, string tmpFile) {
- selection.InlineShapes.AddPicture(tmpFile, false, true, Type.Missing);
+ private static IInlineShape AddPictureToSelection(ISelection selection, string tmpFile) {
+ IInlineShape shape = selection.InlineShapes.AddPicture(tmpFile, false, true, Type.Missing);
selection.InsertAfter("\r\n");
+ return shape;
}
- public static void InsertIntoNewDocument(string tmpFile) {
+ public static void InsertIntoNewDocument(string tmpFile, string address, string tooltip) {
using (IWordApplication wordApplication = COMWrapper.GetOrCreateInstance()) {
if (wordApplication != null) {
wordApplication.Visible = true;
@@ -106,7 +122,19 @@ namespace Greenshot.Interop.Office {
object documentVisible = true;
IWordDocument wordDocument = wordApplication.Documents.Add(ref template, ref newTemplate, ref documentType, ref documentVisible);
// Add Picture
- AddPictureToSelection(wordApplication.Selection, tmpFile);
+ using (IInlineShape shape = AddPictureToSelection(wordApplication.Selection, tmpFile)) {
+ if (!string.IsNullOrEmpty(address)) {
+ object screentip = Type.Missing;
+ if (!string.IsNullOrEmpty(tooltip)) {
+ screentip = tooltip;
+ }
+ try {
+ wordDocument.Hyperlinks.Add(shape, screentip, Type.Missing, screentip, Type.Missing, Type.Missing);
+ } catch (Exception e) {
+ LOG.WarnFormat("Couldn't add hyperlink for image: {0}", e.Message);
+ }
+ }
+ }
wordDocument.Activate();
wordDocument.ActiveWindow.Activate();
}
diff --git a/GreenshotOfficePlugin/OfficeInterop/WordInterop.cs b/GreenshotOfficePlugin/OfficeInterop/WordInterop.cs
index f20955400..cfa3b3e11 100644
--- a/GreenshotOfficePlugin/OfficeInterop/WordInterop.cs
+++ b/GreenshotOfficePlugin/OfficeInterop/WordInterop.cs
@@ -37,18 +37,23 @@ namespace Greenshot.Interop.Office {
IWordDocument item(int index);
}
- // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.document.aspx
+ ///
+ /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.document%28v=office.14%29.aspx
+ ///
public interface IWordDocument : Common {
void Activate();
IWordApplication Application { get; }
IWordWindow ActiveWindow { get; }
bool ReadOnly { get; }
+ IHyperlinks Hyperlinks { get; }
// Only 2007 and later!
bool Final { get; set; }
}
- // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.window_members.aspx
+ ///
+ /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.window_members.aspx
+ ///
public interface IWordWindow : Common {
IPane ActivePane { get; }
void Activate();
@@ -57,12 +62,16 @@ namespace Greenshot.Interop.Office {
}
}
- // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.pane_members.aspx
+ ///
+ /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.pane_members.aspx
+ ///
public interface IPane : Common {
IWordView View { get; }
}
- // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.view_members.aspx
+ ///
+ /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.view_members.aspx
+ ///
public interface IWordView : Common {
IZoom Zoom { get; }
}
@@ -72,13 +81,42 @@ namespace Greenshot.Interop.Office {
int Percentage { get; set; }
}
- // See: http://msdn.microsoft.com/de-de/library/microsoft.office.interop.word.selection_members(v=office.11).aspx
+ ///
+ /// 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);
}
+ ///
+ /// See: http://msdn.microsoft.com/en-us/library/ms263866%28v=office.14%29.aspx
+ ///
public interface IInlineShapes : Common {
- object AddPicture(string FileName, object LinkToFile, object SaveWithDocument, object Range);
+ IInlineShape AddPicture(string FileName, object LinkToFile, object SaveWithDocument, object Range);
+ }
+
+ ///
+ /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.inlineshape_members%28v=office.14%29.aspx
+ ///
+ public interface IInlineShape : Common {
+ IHyperlink Hyperlink { get; }
+ }
+
+ ///
+ /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.hyperlink_members%28v=office.14%29.aspx
+ ///
+ public interface IHyperlink : Common {
+ string Address {
+ get;
+ set;
+ }
+ }
+
+ ///
+ /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.hyperlinks%28v=office.14%29.aspx
+ ///
+ public interface IHyperlinks : Common, Collection {
+ IHyperlink Add(object Anchor, object Address, object SubAddress, object ScreenTip, object TextToDisplay, object Target);
}
}