More stability fixes

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1902 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-05-23 15:35:58 +00:00
commit 9360232ea0
3 changed files with 25 additions and 14 deletions

View file

@ -192,7 +192,8 @@ namespace Greenshot.Interop.Office {
// 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)) {
try {
if (WordExporter.InsertIntoExistingDocument(inspector.WordEditor.Application, inspector.WordEditor, tmpFile)) {
LOG.Info("Inserted into Wordmail");
// check the format afterwards, otherwise we lose the selection
@ -202,6 +203,9 @@ namespace Greenshot.Interop.Office {
//}
return true;
}
} catch (Exception exportException) {
LOG.Error("Error exporting to the word editor, trying to do it via another method", exportException);
}
} else if (isAppointment) {
LOG.Info("Can't export to an appointment if no word editor is used");
return false;

View file

@ -47,7 +47,7 @@ namespace Greenshot.Interop.Office {
for (int i = 1; i <= wordApplication.Documents.Count; i++) {
using (IWordDocument wordDocument = wordApplication.Documents.item(i)) {
if (wordDocument.ActiveWindow.Caption.StartsWith(wordCaption)) {
return InsertIntoExistingDocument(wordDocument, tmpFile);
return InsertIntoExistingDocument(wordApplication, wordDocument, tmpFile);
}
}
}
@ -56,9 +56,16 @@ namespace Greenshot.Interop.Office {
return false;
}
internal static bool InsertIntoExistingDocument(IWordDocument wordDocument, string tmpFile) {
if (wordDocument.Application.Selection != null) {
AddPictureToSelection(wordDocument.Application.Selection, tmpFile);
/// <summary>
/// Internal method for the insert
/// </summary>
/// <param name="wordApplication"></param>
/// <param name="wordDocument"></param>
/// <param name="tmpFile"></param>
/// <returns></returns>
internal static bool InsertIntoExistingDocument(IWordApplication wordApplication, IWordDocument wordDocument, string tmpFile) {
if (wordApplication.Selection != null) {
AddPictureToSelection(wordApplication.Selection, tmpFile);
try {
wordDocument.ActiveWindow.ActivePane.View.Zoom.Percentage = 100;
} catch (Exception e) {
@ -69,7 +76,7 @@ namespace Greenshot.Interop.Office {
}
}
try {
wordDocument.Application.Activate();
wordApplication.Activate();
} catch {}
try {
wordDocument.Activate();

View file

@ -167,7 +167,7 @@ namespace GreenshotPlugin.Core {
try {
CultureInfo cultureInfo = new CultureInfo(culture);
rssFile.Language = cultureInfo.NativeName;
} catch (Exception ex) {
} catch (Exception) {
LOG.WarnFormat("Can't read the native name of the culture {0}", culture);
}
}