From d602433c535dcb34dd1edfbffd2b6a0927e35b9d Mon Sep 17 00:00:00 2001 From: Robin Krom Date: Tue, 21 Jul 2020 12:56:02 +0200 Subject: [PATCH] Added additional guards and a configuration for the Win10 plugin, which disables the OCR by default. --- GreenshotPicasaPlugin/PicasaConfiguration.cs | 12 ++++++------ GreenshotPlugin/Core/AbstractProcessor.cs | 2 +- .../Processors/Win10OcrProcessor.cs | 13 ++++++++++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/GreenshotPicasaPlugin/PicasaConfiguration.cs b/GreenshotPicasaPlugin/PicasaConfiguration.cs index eb8eb7100..a1372f598 100644 --- a/GreenshotPicasaPlugin/PicasaConfiguration.cs +++ b/GreenshotPicasaPlugin/PicasaConfiguration.cs @@ -1,19 +1,19 @@ /* * A Picasa Plugin for Greenshot * Copyright (C) 2011 Francis Noel - * + * * For more information see: http://getgreenshot.org/ - * + * * 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 . */ @@ -42,13 +42,13 @@ namespace GreenshotPicasaPlugin { set; } - [IniProperty("UploadUser", Description = "The picasa user to upload to", DefaultValue = "default")] + [IniProperty("UploadUser", Description = "The Picasa user to upload to", DefaultValue = "default")] public string UploadUser { get; set; } - [IniProperty("UploadAlbum", Description = "The picasa album to upload to", DefaultValue = "default")] + [IniProperty("UploadAlbum", Description = "The Picasa album to upload to", DefaultValue = "default")] public string UploadAlbum { get; set; diff --git a/GreenshotPlugin/Core/AbstractProcessor.cs b/GreenshotPlugin/Core/AbstractProcessor.cs index 5e82b1d23..1dce1ab16 100644 --- a/GreenshotPlugin/Core/AbstractProcessor.cs +++ b/GreenshotPlugin/Core/AbstractProcessor.cs @@ -32,7 +32,7 @@ namespace GreenshotPlugin.Core { return 1; } if (Priority == other.Priority) { - return Description.CompareTo(other.Description); + return string.Compare(Description, other.Description, StringComparison.Ordinal); } return Priority - other.Priority; } diff --git a/GreenshotWin10Plugin/Processors/Win10OcrProcessor.cs b/GreenshotWin10Plugin/Processors/Win10OcrProcessor.cs index 3ed89b95d..6cab7b81d 100644 --- a/GreenshotWin10Plugin/Processors/Win10OcrProcessor.cs +++ b/GreenshotWin10Plugin/Processors/Win10OcrProcessor.cs @@ -21,6 +21,7 @@ using System.Threading.Tasks; using GreenshotPlugin.Core; +using GreenshotPlugin.IniFile; using GreenshotPlugin.Interfaces; using GreenshotPlugin.Interfaces.Ocr; @@ -29,13 +30,23 @@ namespace GreenshotWin10Plugin.Processors { /// This processor processes a capture to see if there is text on it /// public class Win10OcrProcessor : AbstractProcessor { + private static readonly Win10Configuration Win10Configuration = IniConfig.GetIniSection(); public override string Designation => "Windows10OcrProcessor"; public override string Description => Designation; public override bool ProcessCapture(ISurface surface, ICaptureDetails captureDetails) { - if (captureDetails.OcrInformation != null) + if (!Win10Configuration.AlwaysRunOCROnCapture) + { + return false; + } + + if (surface == null) + { + return false; + } + if (captureDetails == null || captureDetails.OcrInformation != null) { return false; }