Small tweaks for the export flow.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1752 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-04-04 15:23:45 +00:00
commit 33cabba52b
4 changed files with 34 additions and 35 deletions

View file

@ -110,16 +110,6 @@ namespace Greenshot.Destinations {
yield return new PowerpointDestination(presentationName); yield return new PowerpointDestination(presentationName);
} }
} }
/// <summary>
/// Helper method for adding the normal "empty" PowerpointDestination
/// </summary>
/// <returns></returns>
private IEnumerable<IDestination> AllDynamicDestinations() {
yield return new PowerpointDestination();
foreach (string presentationName in PowerpointExporter.GetPowerpointPresentations()) {
yield return new PowerpointDestination(presentationName);
}
}
public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) { public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
string tmpFile = captureDetails.Filename; string tmpFile = captureDetails.Filename;
@ -133,14 +123,21 @@ namespace Greenshot.Destinations {
if (presentationName != null) { if (presentationName != null) {
PowerpointExporter.ExportToPresentation(presentationName, tmpFile, imageSize, captureDetails.Title); PowerpointExporter.ExportToPresentation(presentationName, tmpFile, imageSize, captureDetails.Title);
} else { } else {
if (manuallyInitiated) { if (!manuallyInitiated) {
PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title); List<string> presentations = PowerpointExporter.GetPowerpointPresentations();
} else { if (presentations.Count > 0) {
ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, AllDynamicDestinations()); List<IDestination> destinations = new List<IDestination>();
destinations.Add(new PowerpointDestination());
foreach (string presentation in presentations) {
destinations.Add(new PowerpointDestination(presentation));
}
ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, destinations);
PickerDestination.ShowMenuAtCursor(menu); PickerDestination.ShowMenuAtCursor(menu);
return false; return false;
} }
} }
PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title);
}
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, lang.GetFormattedString(LangKey.exported_to, Description)); surface.SendMessageEvent(this, SurfaceMessageTyp.Info, lang.GetFormattedString(LangKey.exported_to, Description));
surface.Modified = false; surface.Modified = false;
return true; return true;

View file

@ -112,17 +112,6 @@ namespace Greenshot.Destinations {
} }
} }
/// <summary>
/// Helper method for adding the normal "empty" WordDestination
/// </summary>
/// <returns></returns>
private IEnumerable<IDestination> AllDynamicDestinations() {
yield return new WordDestination();
foreach (string wordCaption in WordExporter.GetWordDocuments()) {
yield return new WordDestination(wordCaption);
}
}
public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) { public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
string tmpFile = captureDetails.Filename; string tmpFile = captureDetails.Filename;
if (tmpFile == null || surface.Modified) { if (tmpFile == null || surface.Modified) {
@ -133,14 +122,21 @@ namespace Greenshot.Destinations {
if (documentCaption != null) { if (documentCaption != null) {
WordExporter.InsertIntoExistingDocument(documentCaption, tmpFile); WordExporter.InsertIntoExistingDocument(documentCaption, tmpFile);
} else { } else {
if (manuallyInitiated) { if (!manuallyInitiated) {
WordExporter.InsertIntoNewDocument(tmpFile); List<string> documents = WordExporter.GetWordDocuments();
} else { if (documents.Count > 0) {
ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, AllDynamicDestinations()); List<IDestination> destinations = new List<IDestination>();
destinations.Add(new WordDestination());
foreach (string document in documents) {
destinations.Add(new WordDestination(document));
}
ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, destinations);
PickerDestination.ShowMenuAtCursor(menu); PickerDestination.ShowMenuAtCursor(menu);
return false; return false;
} }
} }
WordExporter.InsertIntoNewDocument(tmpFile);
}
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, lang.GetFormattedString(LangKey.exported_to, Description)); surface.SendMessageEvent(this, SurfaceMessageTyp.Info, lang.GetFormattedString(LangKey.exported_to, Description));
surface.Modified = false; surface.Modified = false;

View file

@ -111,9 +111,13 @@ namespace Greenshot.Interop.Office {
if (isLayoutPictureWithCaption) { if (isLayoutPictureWithCaption) {
try { try {
// Using try/catch to make sure problems with the text range don't give an exception. // Using try/catch to make sure problems with the text range don't give an exception.
shape.TextFrame.TextRange.Text = title; ITextFrame textFrame = shape.TextFrame;
if (textFrame.HasText == MsoTriState.msoTrue) {
textFrame.TextRange.Text = title;
}
shape.AlternativeText = title;
} catch (Exception ex) { } catch (Exception ex) {
LOG.WarnFormat("Problem setting the title to a text-range: {0}", ex.Message); LOG.Warn("Problem setting the title to a text-range", ex);
} }
} }
presentation.Application.ActiveWindow.View.GotoSlide(slide.SlideNumber); presentation.Application.ActiveWindow.View.GotoSlide(slide.SlideNumber);

View file

@ -88,10 +88,12 @@ namespace Greenshot.Interop.Office {
ITextFrame TextFrame { get; } ITextFrame TextFrame { get; }
void ScaleWidth(float Factor, MsoTriState RelativeToOriginalSize, MsoScaleFrom fScale); void ScaleWidth(float Factor, MsoTriState RelativeToOriginalSize, MsoScaleFrom fScale);
void ScaleHeight(float Factor, MsoTriState RelativeToOriginalSize, MsoScaleFrom fScale); void ScaleHeight(float Factor, MsoTriState RelativeToOriginalSize, MsoScaleFrom fScale);
string AlternativeText { get; set; }
} }
public interface ITextFrame : Common { public interface ITextFrame : Common {
ITextRange TextRange { get; } ITextRange TextRange { get; }
MsoTriState HasText { get; }
} }
public interface ITextRange : Common { public interface ITextRange : Common {
string Text { get; set; } string Text { get; set; }