Creating a branch 1.1 where I will try to make the 1.1.7 build available, this means I need to merge some changes from 2.0 to here.

This commit is contained in:
RKrom 2013-12-04 17:46:02 +01:00
commit a03bc31aef
247 changed files with 6986 additions and 8233 deletions

View file

@ -28,6 +28,7 @@ using GreenshotPlugin.Core;
using Greenshot.Plugin;
using Greenshot.Interop.Office;
using Greenshot.IniFile;
using System.Text.RegularExpressions;
namespace GreenshotOfficePlugin {
/// <summary>
@ -109,17 +110,23 @@ namespace GreenshotOfficePlugin {
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
string tmpFile = captureDetails.Filename;
if (tmpFile == null || surface.Modified) {
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings(OutputFormat.png));
bool createdFile = false;
string imageFile = captureDetails.Filename;
if (imageFile == null || surface.Modified || !Regex.IsMatch(imageFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
imageFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
createdFile = true;
}
if (workbookName != null) {
ExcelExporter.InsertIntoExistingWorkbook(workbookName, tmpFile);
ExcelExporter.InsertIntoExistingWorkbook(workbookName, imageFile, surface.Image.Size);
} else {
ExcelExporter.InsertIntoNewWorkbook(tmpFile);
ExcelExporter.InsertIntoNewWorkbook(imageFile, surface.Image.Size);
}
exportInformation.ExportMade = true;
ProcessExport(exportInformation, surface);
// Cleanup imageFile if we created it here, so less tmp-files are generated and left
if (createdFile && File.Exists(imageFile)) {
File.Delete(imageFile);
}
return exportInformation;
}
}

View file

@ -152,8 +152,8 @@ namespace GreenshotOfficePlugin {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
// Outlook logic
string tmpFile = captureDetails.Filename;
if (tmpFile == null || surface.Modified) {
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings());
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
} else {
LOG.InfoFormat("Using already available file: {0}", tmpFile);
}

View file

@ -28,6 +28,7 @@ using GreenshotPlugin.Core;
using Greenshot.Plugin;
using Greenshot.Interop.Office;
using Greenshot.IniFile;
using System.Text.RegularExpressions;
namespace GreenshotOfficePlugin {
/// <summary>
@ -112,8 +113,8 @@ namespace GreenshotOfficePlugin {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
string tmpFile = captureDetails.Filename;
Size imageSize = Size.Empty;
if (tmpFile == null || surface.Modified) {
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings());
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
imageSize = surface.Image.Size;
}
if (presentationName != null) {

View file

@ -29,6 +29,7 @@ using GreenshotPlugin.Core;
using Greenshot.Plugin;
using Greenshot.Interop.Office;
using Greenshot.IniFile;
using System.Text.RegularExpressions;
namespace GreenshotOfficePlugin {
/// <summary>
@ -111,8 +112,8 @@ namespace GreenshotOfficePlugin {
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
string tmpFile = captureDetails.Filename;
if (tmpFile == null || surface.Modified) {
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings(OutputFormat.png));
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
}
if (documentCaption != null) {
try {

View file

@ -84,8 +84,6 @@
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<PropertyGroup>
<PreBuildEvent>"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs"
</PreBuildEvent>
<PostBuildEvent>mkdir "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)"
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)\"
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)\*.gsp"

View file

@ -24,10 +24,14 @@ using System.Text;
using System.Reflection;
using Greenshot.Interop;
using System.Drawing;
using GreenshotOfficePlugin;
using Greenshot.IniFile;
namespace Greenshot.Interop.Office {
public class ExcelExporter {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExcelExporter));
private static readonly OfficeConfiguration officeConfiguration = IniConfig.GetIniSection<OfficeConfiguration>();
public static List<string> GetWorkbooks() {
List<string> currentWorkbooks = new List<string>();
@ -49,37 +53,42 @@ namespace Greenshot.Interop.Office {
/// </summary>
/// <param name="workbookName"></param>
/// <param name="tmpFile"></param>
public static void InsertIntoExistingWorkbook(string workbookName, string tmpFile) {
public static void InsertIntoExistingWorkbook(string workbookName, string tmpFile, Size imageSize) {
using (IExcelApplication excelApplication = COMWrapper.GetInstance<IExcelApplication>()) {
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);
InsertIntoExistingWorkbook(workbook, tmpFile, imageSize);
}
}
}
}
}
private static void InsertIntoExistingWorkbook(IWorkbook workbook, string tmpFile) {
IWorksheet sheet = workbook.ActiveSheet;
if (sheet != null) {
if (sheet.Pictures != null) {
sheet.Pictures.Insert(tmpFile);
private static void InsertIntoExistingWorkbook(IWorkbook workbook, string tmpFile, Size imageSize) {
IWorksheet workSheet = workbook.ActiveSheet;
if (workSheet != null) {
if (workSheet.Shapes != null) {
IShape shape = workSheet.Shapes.AddPicture(tmpFile, MsoTriState.msoFalse, MsoTriState.msoTrue, 0, 0, imageSize.Width, imageSize.Height);
if (shape != null) {
shape.Top = 40;
shape.Left = 40;
shape.LockAspectRatio = MsoTriState.msoTrue;
shape.ScaleHeight(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromTopLeft);
shape.ScaleWidth(1, MsoTriState.msoTrue, MsoScaleFrom.msoScaleFromTopLeft);
}
}
} else {
LOG.Error("No pictures found");
}
}
public static void InsertIntoNewWorkbook(string tmpFile) {
public static void InsertIntoNewWorkbook(string tmpFile, Size imageSize) {
using (IExcelApplication excelApplication = COMWrapper.GetOrCreateInstance<IExcelApplication>()) {
if (excelApplication != null) {
excelApplication.Visible = true;
object template = Missing.Value;
IWorkbook workbook = excelApplication.Workbooks.Add(template);
InsertIntoExistingWorkbook(workbook, tmpFile);
InsertIntoExistingWorkbook(workbook, tmpFile, imageSize);
}
}
}

View file

@ -69,6 +69,12 @@ namespace Greenshot.Interop.Office {
/// <param name="tooltip">tooltip of the image</param>
/// <returns></returns>
internal static bool InsertIntoExistingDocument(IWordApplication wordApplication, IWordDocument wordDocument, string tmpFile, string address, string tooltip) {
// Bug #1517: image will be inserted into that document, where the focus was last. It will not inserted into the chosen one.
// Solution: Make sure the selected document is active, otherwise the insert will be made in a different document!
try {
wordApplication.Activate();
} catch {
}
if (wordApplication.Selection != null) {
// Add Picture
using (IInlineShape shape = AddPictureToSelection(wordApplication.Selection, tmpFile)) {

View file

@ -47,6 +47,7 @@ namespace Greenshot.Interop.Office {
// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._worksheet_members.aspx
public interface IWorksheet : Common {
IPictures Pictures { get; }
IShapes Shapes {get; }
string Name { get; }
}

View file

@ -46,10 +46,51 @@ namespace GreenshotOfficePlugin {
}
public IEnumerable<IDestination> Destinations() {
yield return new ExcelDestination();
yield return new PowerpointDestination();
yield return new WordDestination();
yield return new OutlookDestination();
IDestination destination = null;
try {
destination = new ExcelDestination();
} catch {
destination = null;
}
if (destination != null) {
yield return destination;
}
try {
destination = new PowerpointDestination();
} catch {
destination = null;
}
if (destination != null) {
yield return destination;
}
try {
destination = new WordDestination();
} catch {
destination = null;
}
if (destination != null) {
yield return destination;
}
try {
destination = new OutlookDestination();
} catch {
destination = null;
}
if (destination != null) {
yield return destination;
}
try {
destination = new OneNoteDestination();
} catch {
destination = null;
}
if (destination != null) {
yield return destination;
}
}
public IEnumerable<IProcessor> Processors() {

View file

@ -51,4 +51,4 @@ using Greenshot.Plugin;
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.1.4.$WCREV$")]
[assembly: AssemblyVersion("1.1.6.$WCREV$")]