diff --git a/src/managed/OpenLiveWriter.HtmlEditor/Controls/TextBoxEditorControl.cs b/src/managed/OpenLiveWriter.HtmlEditor/Controls/TextBoxEditorControl.cs index 93559511..7dadb9bf 100644 --- a/src/managed/OpenLiveWriter.HtmlEditor/Controls/TextBoxEditorControl.cs +++ b/src/managed/OpenLiveWriter.HtmlEditor/Controls/TextBoxEditorControl.cs @@ -11,7 +11,6 @@ using OpenLiveWriter.CoreServices; using OpenLiveWriter.HtmlEditor.Controls; using OpenLiveWriter.HtmlParser.Parser; using OpenLiveWriter.Interop.Windows; -//using OpenLiveWriter.SpellChecker; namespace OpenLiveWriter.HtmlEditor.Controls { diff --git a/src/managed/OpenLiveWriter.HtmlEditor/HtmlEditorControl.cs b/src/managed/OpenLiveWriter.HtmlEditor/HtmlEditorControl.cs index ffcc1a8d..c9cf60a6 100644 --- a/src/managed/OpenLiveWriter.HtmlEditor/HtmlEditorControl.cs +++ b/src/managed/OpenLiveWriter.HtmlEditor/HtmlEditorControl.cs @@ -29,7 +29,7 @@ using OpenLiveWriter.Interop.Windows; using OpenLiveWriter.Localization; using OpenLiveWriter.Mshtml; using OpenLiveWriter.Mshtml.Mshtml_Interop; -//using OpenLiveWriter.SpellChecker; +using OpenLiveWriter.SpellChecker; using IDataObject = System.Windows.Forms.IDataObject; namespace OpenLiveWriter.HtmlEditor @@ -37,7 +37,7 @@ namespace OpenLiveWriter.HtmlEditor public abstract class HtmlEditorControl : IHtmlEditor, IHtmlEditorCommandSource, IHtmlEditorComponentContext, IHtmlMarshallingTarget, IHTMLEditHostRaw, IElementBehaviorFactoryRaw, IServiceProviderRaw, IWordBasedEditor, IDisposable { #region Construction/Disposal - public HtmlEditorControl(IMainFrameWindow mainFrameWindow, IStatusBar statusBar, MshtmlOptions options, IInternetSecurityManager internetSecurityManager, CommandManager commandManager) + public HtmlEditorControl(IMainFrameWindow mainFrameWindow, IStatusBar statusBar, MshtmlOptions options, ISpellingChecker spellingChecker, IInternetSecurityManager internetSecurityManager, CommandManager commandManager) { _commandManager = commandManager; @@ -45,8 +45,7 @@ namespace OpenLiveWriter.HtmlEditor _mainFrameWindow = mainFrameWindow; _statusBar = statusBar; - //ToDo: OLW Spell Checker - //_spellingChecker = spellingChecker; + _spellingChecker = spellingChecker; // This call is required by the Windows.Forms Form Designer. InitializeComponent(); @@ -1580,18 +1579,17 @@ namespace OpenLiveWriter.HtmlEditor #region Spell Checking Helpers - //ToDo: OLW Spell Checker /// /// Get the spelling-checker (demand-create and cache/re-use) /// - //protected ISpellingChecker SpellingChecker - //{ - // get - // { - // return _spellingChecker; - // } - //} - //private ISpellingChecker _spellingChecker; + protected ISpellingChecker SpellingChecker + { + get + { + return _spellingChecker; + } + } + private ISpellingChecker _spellingChecker; #endregion @@ -3478,57 +3476,56 @@ namespace OpenLiveWriter.HtmlEditor // check spelling bool fCompleted = false; - //ToDo: OLW Spell Checker - //using (SpellCheckerForm spellCheckerForm = new SpellCheckerForm(SpellingChecker, EditorControl.FindForm(), ignoreOnceSupported)) - //{ - // center the spell-checking form over the document body - //spellCheckerForm.StartPosition = FormStartPosition.CenterParent; - - // determine whether we are checking a selection or the whole document - // get selection - IHTMLSelectionObject selection = HTMLDocument.selection; - bool checkSelection = (selection != null) && (selection.type.ToLower(CultureInfo.InvariantCulture) == "text"); - - // get the word range to check - // MshtmlWordRange wordRange = new MshtmlWordRange(HTMLDocument, checkSelection, IgnoreRangeForSpellChecking, new DamageFunction(_damageServices.AddDamage)); - - //spellCheckerForm.WordIgnored += (sender, args) => OnSpellCheckWordIgnored(wordRange.CurrentWordRange); - - // check spelling - using (undoUnit) + using (SpellCheckerForm spellCheckerForm = new SpellCheckerForm(SpellingChecker, EditorControl.FindForm(), ignoreOnceSupported)) { - //spellCheckerForm.CheckSpelling(wordRange, contextDictionaryPath); - undoUnit.Commit(); + // center the spell-checking form over the document body + spellCheckerForm.StartPosition = FormStartPosition.CenterParent; + + // determine whether we are checking a selection or the whole document + // get selection + IHTMLSelectionObject selection = HTMLDocument.selection; + bool checkSelection = (selection != null) && (selection.type.ToLower(CultureInfo.InvariantCulture) == "text"); + + // get the word range to check + MshtmlWordRange wordRange = new MshtmlWordRange(HTMLDocument, checkSelection, IgnoreRangeForSpellChecking, new DamageFunction(_damageServices.AddDamage)); + + spellCheckerForm.WordIgnored += (sender, args) => OnSpellCheckWordIgnored(wordRange.CurrentWordRange); + + // check spelling + using (undoUnit) + { + spellCheckerForm.CheckSpelling(wordRange, contextDictionaryPath); + undoUnit.Commit(); + } + + // reselect what was selected previous to spell-checking + if (previousMarkupRange != null) + { + if (previousMarkupRangeCollapsed) + previousMarkupRange.Collapse(true); + + previousMarkupRange.ToTextRange().select(); + } + + // return completed status + fCompleted = spellCheckerForm.Completed; } - // reselect what was selected previous to spell-checking - if (previousMarkupRange != null) - { - if (previousMarkupRangeCollapsed) - previousMarkupRange.Collapse(true); - - previousMarkupRange.ToTextRange().select(); - } - - // return completed status - fCompleted = true; // spellCheckerForm.Completed; - //} - - if (fCompleted && (_mainFrameWindow != null)) // && (_mainFrameWindow is IWordRangeProvider)) + if (fCompleted && _mainFrameWindow != null && _mainFrameWindow is IWordRangeProvider) { // Spell check the subject, it doesn't support the "ignore once" feature - //using (SpellCheckerForm spellCheckerForm = new SpellCheckerForm(SpellingChecker, EditorControl.FindForm(), false)) + using (SpellCheckerForm spellCheckerForm = new SpellCheckerForm(SpellingChecker, EditorControl.FindForm(), false)) { // center the spell-checking form over the document body - //spellCheckerForm.StartPosition = FormStartPosition.CenterParent; + spellCheckerForm.StartPosition = FormStartPosition.CenterParent; - //IWordRangeProvider wordRangeProvider = (IWordRangeProvider)_mainFrameWindow; - //IWordRange wordRangeSubject = wordRangeProvider.GetSubjectSpellcheckWordRange(); + IWordRangeProvider wordRangeProvider = (IWordRangeProvider)_mainFrameWindow; + IWordRange wordRangeSubject = wordRangeProvider.GetSubjectSpellcheckWordRange(); - //spellCheckerForm.CheckSpelling(wordRangeSubject, contextDictionaryPath); + spellCheckerForm.CheckSpelling(wordRangeSubject, contextDictionaryPath); - //wordRangeProvider.CloseSubjectSpellcheckWordRange(); - fCompleted = true; // spellCheckerForm.Completed; + wordRangeProvider.CloseSubjectSpellcheckWordRange(); + fCompleted = spellCheckerForm.Completed; } } diff --git a/src/managed/OpenLiveWriter.HtmlEditor/HtmlSourceEditorControl.cs b/src/managed/OpenLiveWriter.HtmlEditor/HtmlSourceEditorControl.cs index 072d3709..657b7044 100644 --- a/src/managed/OpenLiveWriter.HtmlEditor/HtmlSourceEditorControl.cs +++ b/src/managed/OpenLiveWriter.HtmlEditor/HtmlSourceEditorControl.cs @@ -20,7 +20,7 @@ using OpenLiveWriter.HtmlParser.Parser; using OpenLiveWriter.Interop.Windows; using OpenLiveWriter.Localization; using OpenLiveWriter.Mshtml; -//using OpenLiveWriter.SpellChecker; +using OpenLiveWriter.SpellChecker; namespace OpenLiveWriter.HtmlEditor { public class HtmlSourceEditorControl : IHtmlEditor, IHtmlEditorCommandSource @@ -36,12 +36,10 @@ namespace OpenLiveWriter.HtmlEditor } } - //ToDo: OLW Spell Checker - //public HtmlSourceEditorControl(ISpellingChecker spellingChecker, CommandManager commandManager) - public HtmlSourceEditorControl(CommandManager commandManager) + public HtmlSourceEditorControl(ISpellingChecker spellingChecker, CommandManager commandManager) { _commandManager = commandManager; - //_spellingChecker = spellingChecker; + _spellingChecker = spellingChecker; contextMenu.Entries.Add(CommandId.Cut, false, false); contextMenu.Entries.Add(CommandId.CopyCommand, false, false); @@ -280,38 +278,36 @@ namespace OpenLiveWriter.HtmlEditor public bool CheckSpelling(string contextDictionaryPath) { - //ToDo: OLW Spell Checker // check spelling - //using (SpellCheckerForm spellCheckerForm = new SpellCheckerForm(SpellingChecker, EditorControl.FindForm(), false)) - //{ - // center the spell-checking form over the document body - //spellCheckerForm.StartPosition = FormStartPosition.CenterParent; + using (SpellCheckerForm spellCheckerForm = new SpellCheckerForm(SpellingChecker, EditorControl.FindForm(), false)) + { + // center the spell-checking form over the document body + spellCheckerForm.StartPosition = FormStartPosition.CenterParent; - // create word range - // TODO: smarter word range for html - //TextBoxWordRange wordRange = new TextBoxWordRange(_textBox, _textBox.SelectionLength > 0); - //HtmlTextBoxWordRange wordRange = new HtmlTextBoxWordRange(_textBox); + // create word range + // TODO: smarter word range for html + //TextBoxWordRange wordRange = new TextBoxWordRange(_textBox, _textBox.SelectionLength > 0); + HtmlTextBoxWordRange wordRange = new HtmlTextBoxWordRange(_textBox); - // check spelling - //spellCheckerForm.CheckSpelling(wordRange, contextDictionaryPath); + // check spelling + spellCheckerForm.CheckSpelling(wordRange, contextDictionaryPath); - // return completed status - return true; // spellCheckerForm.Completed; - //} + // return completed status + return spellCheckerForm.Completed; + } } - //ToDo: OLW Spell Checker /// /// Get the spelling-checker (demand-create and cache/re-use) /// - //public ISpellingChecker SpellingChecker - //{ - // get - // { - // return _spellingChecker; - // } - //} - //private ISpellingChecker _spellingChecker; + public ISpellingChecker SpellingChecker + { + get + { + return _spellingChecker; + } + } + private ISpellingChecker _spellingChecker; #endregion diff --git a/src/managed/OpenLiveWriter.HtmlEditor/OpenLiveWriter.HtmlEditor.csproj b/src/managed/OpenLiveWriter.HtmlEditor/OpenLiveWriter.HtmlEditor.csproj index 0db087ec..52df6af8 100644 --- a/src/managed/OpenLiveWriter.HtmlEditor/OpenLiveWriter.HtmlEditor.csproj +++ b/src/managed/OpenLiveWriter.HtmlEditor/OpenLiveWriter.HtmlEditor.csproj @@ -7,6 +7,10 @@ {6A6872BC-67EF-4A42-A21A-30ECED376923} + + {2db3a424-0f1e-44ac-ae01-5454586ce769} + OpenLiveWriter.SpellChecker + @@ -234,4 +238,4 @@ - + \ No newline at end of file diff --git a/src/managed/OpenLiveWriter.PostEditor/BlogPostSupportingFileStorage.cs b/src/managed/OpenLiveWriter.PostEditor/BlogPostSupportingFileStorage.cs index da93f814..614ef3fe 100644 --- a/src/managed/OpenLiveWriter.PostEditor/BlogPostSupportingFileStorage.cs +++ b/src/managed/OpenLiveWriter.PostEditor/BlogPostSupportingFileStorage.cs @@ -7,7 +7,7 @@ using System.Diagnostics; using System.Globalization; using System.IO; using OpenLiveWriter.HtmlParser.Parser; -//using OpenLiveWriter.SpellChecker; +using OpenLiveWriter.SpellChecker; using OpenLiveWriter.CoreServices; using OpenLiveWriter.CoreServices.HTML; using OpenLiveWriter.Interop.Windows; @@ -139,9 +139,8 @@ namespace OpenLiveWriter.PostEditor return null; } - //ToDo: OLW Spell Checker // NOTE: hardcode to sentry spelling engine -- need to unroll this if we switch engines - private static readonly string CONTEXT_DICTIONARY_FILE = "context.tlx"; + private static readonly string CONTEXT_DICTIONARY_FILE = SentrySpellingChecker.ContextDictionaryFileName; private DirectoryInfo _storageDirectory; } diff --git a/src/managed/OpenLiveWriter.PostEditor/ContentEditor/ContentEditor.cs b/src/managed/OpenLiveWriter.PostEditor/ContentEditor/ContentEditor.cs index 8b3612bd..7180b3ce 100644 --- a/src/managed/OpenLiveWriter.PostEditor/ContentEditor/ContentEditor.cs +++ b/src/managed/OpenLiveWriter.PostEditor/ContentEditor/ContentEditor.cs @@ -35,7 +35,7 @@ using OpenLiveWriter.PostEditor.Tables; using OpenLiveWriter.PostEditor.ContentSources; using OpenLiveWriter.PostEditor.PostHtmlEditing.Sidebar; using OpenLiveWriter.PostEditor.Tagging; -//using OpenLiveWriter.SpellChecker; +using OpenLiveWriter.SpellChecker; using OpenLiveWriter.InternalWriterPlugin; using Timer = System.Windows.Forms.Timer; using OpenLiveWriter.PostEditor.WordCount; @@ -49,9 +49,7 @@ using OpenLiveWriter.PostEditor.Commands; namespace OpenLiveWriter.PostEditor { - //ToDo: OLW Spell Checker - //internal class ContentEditor : IBlogPostContentEditor, IContentSourceSite, IDisposable, IHtmlEditorCommandSource, IHtmlEditorHost, IBlogPostImageEditingContext, IBlogPostSidebarContext, IContentSourceSidebarContext, IBlogPostSpellCheckingContext, ICommandManagerHost, IEditingMode, IInternalSmartContentContextSource - internal class ContentEditor : IBlogPostContentEditor, IContentSourceSite, IDisposable, IHtmlEditorCommandSource, IHtmlEditorHost, IBlogPostImageEditingContext, IBlogPostSidebarContext, IContentSourceSidebarContext, ICommandManagerHost, IEditingMode, IInternalSmartContentContextSource + internal class ContentEditor : IBlogPostContentEditor, IContentSourceSite, IDisposable, IHtmlEditorCommandSource, IHtmlEditorHost, IBlogPostImageEditingContext, IBlogPostSidebarContext, IContentSourceSidebarContext, IBlogPostSpellCheckingContext, ICommandManagerHost, IEditingMode, IInternalSmartContentContextSource { public ContentEditor(IMainFrameWindow mainFrameWindow, Control editorContainer, IBlogPostEditingSite postEditingSite, IInternetSecurityManager internetSecurityManager, BlogPostHtmlEditorControl.TemplateStrategy templateStrategy, int dlControlFlags) { @@ -146,7 +144,7 @@ namespace OpenLiveWriter.PostEditor _mshtmlOptions.DocHostUIOptionKeyPath = GlobalEditorOptions.GetSetting(ContentEditorSetting.MshtmlOptionKeyPath); // create the editor - _normalHtmlContentEditor = new BlogPostHtmlEditorControl(_mainFrameWindow, StatusBar, _mshtmlOptions, this, this, this, new SmartContentResizedListener(ResizedListener), new SharedCanvasImageReferenceFixer(ReferenceFixer), internetSecurityManager, CommandManager, templateStrategy, this); + _normalHtmlContentEditor = new BlogPostHtmlEditorControl(_mainFrameWindow, StatusBar, _mshtmlOptions, this, this, this, new SmartContentResizedListener(ResizedListener), this, new SharedCanvasImageReferenceFixer(ReferenceFixer), internetSecurityManager, CommandManager, templateStrategy, this); _normalHtmlContentEditor.PostBodyInlineStyle = GetPostBodyInlineStyleOverrides(); // hookup services and events _normalHtmlContentEditor.HtmlGenerationService = new HtmlGenerator(this); @@ -209,8 +207,7 @@ namespace OpenLiveWriter.PostEditor private void InitializeSourceEditor() { // create the source code editor control - //_codeHtmlContentEditor = new BlogPostHtmlSourceEditorControl(this, CommandManager, this); - _codeHtmlContentEditor = new BlogPostHtmlSourceEditorControl(CommandManager, this); + _codeHtmlContentEditor = new BlogPostHtmlSourceEditorControl(this, CommandManager, this); _codeHtmlContentEditor.AccessibleName = "Source Editor"; @@ -729,12 +726,11 @@ namespace OpenLiveWriter.PostEditor ContentSourceManager.GlobalContentSourceListChanged -= new EventHandler(ContentSourceManager_GlobalContentSourceListChanged); CommandManager.CommandStateChanged -= new EventHandler(CommandManager_CommandStateChanged); - //ToDo: OLW Spell Checker - //if (_spellingChecker != null) - //{ - // _spellingChecker.Dispose(); - // _spellingChecker = null; - //} + if (_spellingChecker != null) + { + _spellingChecker.Dispose(); + _spellingChecker = null; + } if (_insertImageDialogWin7 != null) { @@ -2407,7 +2403,7 @@ namespace OpenLiveWriter.PostEditor { get { - return true; // _spellingChecker.IsInitialized; + return _spellingChecker.IsInitialized; } } @@ -2421,12 +2417,11 @@ namespace OpenLiveWriter.PostEditor get { return _autoCorrectLexiconFile; } } - //ToDo: OLW Spell Checker - //public ISpellingChecker SpellingChecker - //{ - // get { return _spellingChecker; } - //} - //private NlgSpellingChecker _spellingChecker = new NlgSpellingChecker(); + public ISpellingChecker SpellingChecker + { + get { return _spellingChecker; } + } + private WinSpellingChecker _spellingChecker = new WinSpellingChecker(); public void SetSpellingOptions(string dllName, ushort lcid, string[] mainLexFiles, string userLexFile, uint sobitOptions, bool useAutoCorrect) { @@ -2438,17 +2433,16 @@ namespace OpenLiveWriter.PostEditor return; } - //ToDo: OLW Spell Checker - //_spellingChecker.StopChecking(); - //_spellingChecker.SetOptions(dllName, lcid, mainLexFiles, userLexFile, sobitOptions); - //_spellingChecker.StartChecking(_supportingFileStorage != null ? PostSpellingContextDirectory : null); + _spellingChecker.StopChecking(); + _spellingChecker.SetOptions(dllName, lcid, mainLexFiles, userLexFile, sobitOptions); + _spellingChecker.StartChecking(_supportingFileStorage != null ? PostSpellingContextDirectory : null); // Get autocorrect file if needed, mso.acl ships with Writer/Shared Canvas _autoCorrectLexiconFile = null; - //if (useAutoCorrect && lcid == 1033 /* en-us */ && File.Exists(Path.Combine(SpellingSettings.DictionaryPath, "mso.acl"))) - //{ - // _autoCorrectLexiconFile = Path.Combine(SpellingSettings.DictionaryPath, "mso.acl"); - //} + if (useAutoCorrect && lcid == 1033 /* en-us */ && File.Exists(Path.Combine(SpellingSettings.DictionaryPath, "mso.acl"))) + { + _autoCorrectLexiconFile = Path.Combine(SpellingSettings.DictionaryPath, "mso.acl"); + } if (SpellingOptionsChanged != null) { @@ -2458,8 +2452,8 @@ namespace OpenLiveWriter.PostEditor public void DisableSpelling() { - //_spellingChecker.StopChecking(); - //_spellingChecker.SetOptions(null, 0, null, null, 0); + _spellingChecker.StopChecking(); + _spellingChecker.SetOptions(null, 0, null, null, 0); if (SpellingOptionsChanged != null) SpellingOptionsChanged(this, EventArgs.Empty); } diff --git a/src/managed/OpenLiveWriter.PostEditor/ContentEditor/MainFrameWindowAdapter.cs b/src/managed/OpenLiveWriter.PostEditor/ContentEditor/MainFrameWindowAdapter.cs index b1df2524..fedafcd6 100644 --- a/src/managed/OpenLiveWriter.PostEditor/ContentEditor/MainFrameWindowAdapter.cs +++ b/src/managed/OpenLiveWriter.PostEditor/ContentEditor/MainFrameWindowAdapter.cs @@ -10,7 +10,7 @@ using OpenLiveWriter.HtmlEditor; using OpenLiveWriter.HtmlEditor.Controls; using OpenLiveWriter.Interop.Com.Ribbon; using OpenLiveWriter.Interop.Windows; -//using OpenLiveWriter.SpellChecker; +using OpenLiveWriter.SpellChecker; namespace OpenLiveWriter.PostEditor { @@ -19,9 +19,7 @@ namespace OpenLiveWriter.PostEditor /// IMainFrameWindow and IBlogPostEditingSite which are used by the ContentEditor. It's general functions /// are to act as a middle man to the window that is holding the canvas. /// - //ToDo: OLW Spell Checker - //internal class MainFrameWindowAdapter : IMainFrameWindow, IBlogPostEditingSite, IBlogContext, OpenLiveWriter.Interop.Com.IDropTarget, IDisposable, IETWProvider, IWordRangeProvider - internal class MainFrameWindowAdapter : IMainFrameWindow, IBlogPostEditingSite, IBlogContext, OpenLiveWriter.Interop.Com.IDropTarget, IDisposable, IETWProvider + internal class MainFrameWindowAdapter : IMainFrameWindow, IBlogPostEditingSite, IBlogContext, OpenLiveWriter.Interop.Com.IDropTarget, IDisposable, IETWProvider, IWordRangeProvider { private readonly IntPtr _parentWindowHandle; private readonly Control _editorHostPanel; @@ -68,16 +66,15 @@ namespace OpenLiveWriter.PostEditor #region IWordRangeProvider Members - //ToDo: OLW Spell Checker - //public IWordRange GetSubjectSpellcheckWordRange() - //{ - // return ((IWordRangeProvider)_contentEditorSite).GetSubjectSpellcheckWordRange(); - //} + public IWordRange GetSubjectSpellcheckWordRange() + { + return ((IWordRangeProvider)_contentEditorSite).GetSubjectSpellcheckWordRange(); + } - //public void CloseSubjectSpellcheckWordRange() - //{ - // ((IWordRangeProvider)_contentEditorSite).CloseSubjectSpellcheckWordRange(); - //} + public void CloseSubjectSpellcheckWordRange() + { + ((IWordRangeProvider)_contentEditorSite).CloseSubjectSpellcheckWordRange(); + } #endregion diff --git a/src/managed/OpenLiveWriter.PostEditor/EditingPreferencesPanel.cs b/src/managed/OpenLiveWriter.PostEditor/EditingPreferencesPanel.cs index b156e2e7..55c2e3e4 100644 --- a/src/managed/OpenLiveWriter.PostEditor/EditingPreferencesPanel.cs +++ b/src/managed/OpenLiveWriter.PostEditor/EditingPreferencesPanel.cs @@ -13,7 +13,6 @@ using OpenLiveWriter.Localization; using OpenLiveWriter.Localization.Bidi; using OpenLiveWriter.PostEditor.Autoreplace; using OpenLiveWriter.PostEditor.WordCount; -//using OpenLiveWriter.SpellChecker; namespace OpenLiveWriter.PostEditor { diff --git a/src/managed/OpenLiveWriter.PostEditor/LiveClipboard/LiveClipboardPreferencesPanel.cs b/src/managed/OpenLiveWriter.PostEditor/LiveClipboard/LiveClipboardPreferencesPanel.cs index a01d67ea..c384b60f 100644 --- a/src/managed/OpenLiveWriter.PostEditor/LiveClipboard/LiveClipboardPreferencesPanel.cs +++ b/src/managed/OpenLiveWriter.PostEditor/LiveClipboard/LiveClipboardPreferencesPanel.cs @@ -14,7 +14,6 @@ using OpenLiveWriter.Localization; using OpenLiveWriter.Localization.Bidi; using OpenLiveWriter.PostEditor.ContentSources; using OpenLiveWriter.PostEditor.LiveClipboard; -//using OpenLiveWriter.SpellChecker; using OpenLiveWriter.ApplicationFramework; using OpenLiveWriter.ApplicationFramework.Preferences; diff --git a/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj b/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj index feca8301..3afb39f9 100644 --- a/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj +++ b/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj @@ -11,6 +11,10 @@ + + {2db3a424-0f1e-44ac-ae01-5454586ce769} + OpenLiveWriter.SpellChecker + ..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.dll diff --git a/src/managed/OpenLiveWriter.PostEditor/PluginsPreferencesPanel.cs b/src/managed/OpenLiveWriter.PostEditor/PluginsPreferencesPanel.cs index 0d535982..c5f4e423 100644 --- a/src/managed/OpenLiveWriter.PostEditor/PluginsPreferencesPanel.cs +++ b/src/managed/OpenLiveWriter.PostEditor/PluginsPreferencesPanel.cs @@ -14,7 +14,6 @@ using OpenLiveWriter.CoreServices.Layout; using OpenLiveWriter.CoreServices.Marketization; using OpenLiveWriter.Localization; using OpenLiveWriter.Localization.Bidi; -//using OpenLiveWriter.SpellChecker; using OpenLiveWriter.ApplicationFramework; using OpenLiveWriter.ApplicationFramework.Preferences; using OpenLiveWriter.PostEditor.ContentSources; diff --git a/src/managed/OpenLiveWriter.PostEditor/PostEditorMainControl.cs b/src/managed/OpenLiveWriter.PostEditor/PostEditorMainControl.cs index 138677b1..6f8d6ed1 100644 --- a/src/managed/OpenLiveWriter.PostEditor/PostEditorMainControl.cs +++ b/src/managed/OpenLiveWriter.PostEditor/PostEditorMainControl.cs @@ -44,7 +44,7 @@ using OpenLiveWriter.ApplicationFramework; using OpenLiveWriter.Controls; using OpenLiveWriter.PostEditor.SupportingFiles; using OpenLiveWriter.PostEditor.Updates; -//using OpenLiveWriter.SpellChecker; +using OpenLiveWriter.SpellChecker; using Timer = System.Windows.Forms.Timer; // @RIBBON TODO: Cleanly remove obsolete code @@ -888,13 +888,13 @@ namespace OpenLiveWriter.PostEditor private bool CheckSpelling() { // do auto spell check - //if (SpellingSettings.CheckSpellingBeforePublish && _htmlEditor.CanSpellCheck) - //{ - // if (!_htmlEditor.CheckSpelling(_editingManager.GetPostSpellingContextDirectory())) - // { - // return (DialogResult.Yes == DisplayMessage.Show(MessageId.SpellCheckCancelledStillPost, _mainFrameWindow)); - // } - //} + if (SpellingSettings.CheckSpellingBeforePublish && _htmlEditor.CanSpellCheck) + { + if (!_htmlEditor.CheckSpelling(_editingManager.GetPostSpellingContextDirectory())) + { + return (DialogResult.Yes == DisplayMessage.Show(MessageId.SpellCheckCancelledStillPost, _mainFrameWindow)); + } + } return true; } diff --git a/src/managed/OpenLiveWriter.PostEditor/PostEditorPreferencesPanel.cs b/src/managed/OpenLiveWriter.PostEditor/PostEditorPreferencesPanel.cs index 7ddb3e59..40605b1f 100644 --- a/src/managed/OpenLiveWriter.PostEditor/PostEditorPreferencesPanel.cs +++ b/src/managed/OpenLiveWriter.PostEditor/PostEditorPreferencesPanel.cs @@ -13,7 +13,6 @@ using OpenLiveWriter.CoreServices; using OpenLiveWriter.CoreServices.Layout; using OpenLiveWriter.Localization; using OpenLiveWriter.Localization.Bidi; -//using OpenLiveWriter.SpellChecker; using OpenLiveWriter.ApplicationFramework; using OpenLiveWriter.ApplicationFramework.Preferences; using OpenLiveWriter.PostEditor.WordCount; diff --git a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/BlogPostHtmlEditor.cs b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/BlogPostHtmlEditor.cs index bc71a6c6..2aa3b274 100644 --- a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/BlogPostHtmlEditor.cs +++ b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/BlogPostHtmlEditor.cs @@ -23,8 +23,7 @@ using OpenLiveWriter.Controls; using OpenLiveWriter.Mshtml; using OpenLiveWriter.PostEditor.Commands; using OpenLiveWriter.PostEditor.PostPropertyEditing; -//using OpenLiveWriter.SpellChecker; -//using OpenLiveWriter.SpellChecker.NLG; +using OpenLiveWriter.SpellChecker; // @RIBBON TODO: Cleanly remove obsolete code @@ -69,8 +68,7 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing InitializePropertyEditors(); ApplySpellingSettings(null, EventArgs.Empty); - //ToDo: OLW Spell Checker - //SpellingSettings.SpellingSettingsChanged += ApplySpellingSettings; + SpellingSettings.SpellingSettingsChanged += ApplySpellingSettings; EditorLoaded += new EventHandler(BlogPostHtmlEditor_EditorLoaded); FixCommandEvent += new FixCommendsDelegate(BlogPostHtmlEditor_FixCommandEvent); @@ -78,15 +76,12 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing public override void Dispose() { - //ToDo: OLW Spell Checker - //SpellingSettings.SpellingSettingsChanged -= ApplySpellingSettings; + SpellingSettings.SpellingSettingsChanged -= ApplySpellingSettings; base.Dispose(); } public override void OnEditorAccountChanged(IEditorAccount newEditorAccount) { - //ToDo: OLW Spell Checker - // Crashes here: return value of CommandManager.Get(CommandId.IgnoreOnce) is null Command cmd = CommandManager.Get(CommandId.IgnoreOnce); if (cmd != null) { @@ -103,37 +98,37 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing private void ApplySpellingSettings(object sender, EventArgs args) { - //ToDo: OLW Spell Checker - //SpellingCheckerLanguage language = SpellingSettings.Language; + SpellingCheckerLanguage language = SpellingSettings.Language; - //if (language == SpellingCheckerLanguage.None) - //{ - // No language selected. Disable the speller and return. - DisableSpelling(); - return; - //ToDo: OLW Spell Checker - //ToDo: OLW Spell Checker - // SpellingLanguageEntry languageEntry = SpellingSettings.GetInstalledLanguage(language); + if (language == SpellingCheckerLanguage.None) + { + // No language selected. Disable the speller and return. + DisableSpelling(); + } + else + { + SpellingLanguageEntry languageEntry = SpellingSettings.GetInstalledLanguage(language); - //uint sobit = 0; - //if (SpellingSettings.IgnoreUppercase) - // sobit |= (uint)SpellerOptionBit.IgnoreAllCaps; - //if (SpellingSettings.IgnoreWordsWithNumbers) - // sobit |= (uint)SpellerOptionBit.IgnoreMixedDigits; + uint sobit = 0; + if (SpellingSettings.IgnoreUppercase) + sobit |= (uint)SpellerOptionBit.IgnoreAllCaps; + if (SpellingSettings.IgnoreWordsWithNumbers) + sobit |= (uint)SpellerOptionBit.IgnoreMixedDigits; - //sobit |= (uint)SpellerOptionBit.IgnoreSingleLetter; + sobit |= (uint)SpellerOptionBit.IgnoreSingleLetter; - //List lexAbsPaths = new List(languageEntry.CSAPILex.Length); - //foreach (string path in languageEntry.CSAPILex) - // lexAbsPaths.Add(Path.Combine(SpellingSettings.DictionaryPath, path)); - //string engineDllAbsPath = Path.Combine(SpellingSettings.DictionaryPath, languageEntry.CSAPIEngine); + List lexAbsPaths = new List(languageEntry.CSAPILex.Length); + foreach (string path in languageEntry.CSAPILex) + lexAbsPaths.Add(Path.Combine(SpellingSettings.DictionaryPath, path)); + string engineDllAbsPath = Path.Combine(SpellingSettings.DictionaryPath, languageEntry.CSAPIEngine); - //SetSpellingOptions(engineDllAbsPath, - // languageEntry.LCID, - // lexAbsPaths.ToArray(), - // SpellingSettings.UserDictionaryPath, - // sobit, - // SpellingSettings.EnableAutoCorrect); + SetSpellingOptions(engineDllAbsPath, + languageEntry.LCID, + lexAbsPaths.ToArray(), + SpellingSettings.UserDictionaryPath, + sobit, + SpellingSettings.EnableAutoCorrect); + } } void BlogPostHtmlEditor_FixCommandEvent(bool fullyEditableActive) diff --git a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/BlogPostHtmlEditorControl.cs b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/BlogPostHtmlEditorControl.cs index 8f38787e..db2b0b93 100644 --- a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/BlogPostHtmlEditorControl.cs +++ b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/BlogPostHtmlEditorControl.cs @@ -29,7 +29,7 @@ using OpenLiveWriter.PostEditor.PostHtmlEditing.Behaviors; using OpenLiveWriter.PostEditor.PostHtmlEditing.Sidebar; using OpenLiveWriter.PostEditor.Tables; using OpenLiveWriter.PostEditor.Tagging; -//using OpenLiveWriter.SpellChecker; +using OpenLiveWriter.SpellChecker; using OpenLiveWriter.CoreServices.HTML; using OpenLiveWriter.PostEditor.Emoticons; using OpenLiveWriter.Api; @@ -39,20 +39,17 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing internal class BlogPostHtmlEditorControl : HtmlEditorControl, IBlogPostHtmlEditor, IHtmlEditorComponentContext { - //ToDo: OLW Spell Checker - //public BlogPostHtmlEditorControl(IMainFrameWindow mainFrameWindow, IStatusBar statusBar, MshtmlOptions options, IBlogPostImageEditingContext imageEditingContext, IBlogPostSidebarContext sidebarContext, IContentSourceSidebarContext sourceContext, SmartContentResizedListener resizedListener, IBlogPostSpellCheckingContext spellingContext, IImageReferenceFixer referenceFixer, IInternetSecurityManager internetSecurityManager, CommandManager commandManager, TemplateStrategy strategy, IEditingMode editingModeContext) : base(mainFrameWindow, statusBar, options, internetSecurityManager, commandManager) - public BlogPostHtmlEditorControl(IMainFrameWindow mainFrameWindow, IStatusBar statusBar, MshtmlOptions options, IBlogPostImageEditingContext imageEditingContext, IBlogPostSidebarContext sidebarContext, IContentSourceSidebarContext sourceContext, SmartContentResizedListener resizedListener, IImageReferenceFixer referenceFixer, IInternetSecurityManager internetSecurityManager, CommandManager commandManager, TemplateStrategy strategy, IEditingMode editingModeContext) - : base(mainFrameWindow, statusBar, options, internetSecurityManager, commandManager) + public BlogPostHtmlEditorControl(IMainFrameWindow mainFrameWindow, IStatusBar statusBar, MshtmlOptions options, IBlogPostImageEditingContext imageEditingContext, IBlogPostSidebarContext sidebarContext, IContentSourceSidebarContext sourceContext, SmartContentResizedListener resizedListener, IBlogPostSpellCheckingContext spellingContext, IImageReferenceFixer referenceFixer, IInternetSecurityManager internetSecurityManager, CommandManager commandManager, TemplateStrategy strategy, IEditingMode editingModeContext) + : base(mainFrameWindow, statusBar, options, spellingContext.SpellingChecker, internetSecurityManager, commandManager) { _strategy = strategy; _imageEditingContext = imageEditingContext; _sidebarContext = sidebarContext; _sourceContext = sourceContext; _resizedListener = resizedListener; - //ToDo: OLW Spell Checker - //_spellingContext = spellingContext; + _spellingContext = spellingContext; - //_spellingManager = new SpellingManager(CommandManager); + _spellingManager = new SpellingManager(CommandManager); _keyBoardHandler = new PostEditorKeyboardHandler(this, imageEditingContext, editingModeContext); _referenceFixer = referenceFixer; @@ -107,12 +104,11 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing public override void Dispose() { - //ToDo: OLW Spell Checker - //EditingContextChanged -= _spellingManager.UpdateSpellingContext; - //_spellingContext.SpellingOptionsChanged -= spellingSettings_SpellingSettingsChanged; + EditingContextChanged -= _spellingManager.UpdateSpellingContext; + _spellingContext.SpellingOptionsChanged -= spellingSettings_SpellingSettingsChanged; - //if (_spellingManager != null) - // _spellingManager.Dispose(); + if (_spellingManager != null) + _spellingManager.Dispose(); if (_keyBoardHandler != null) { @@ -132,7 +128,7 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing readonly IBlogPostSidebarContext _sidebarContext; readonly IContentSourceSidebarContext _sourceContext; readonly SmartContentResizedListener _resizedListener; - //readonly IBlogPostSpellCheckingContext _spellingContext; + readonly IBlogPostSpellCheckingContext _spellingContext; private PostEditorKeyboardHandler _keyBoardHandler; private IImageReferenceFixer _referenceFixer; private TemplateStrategy _strategy; @@ -199,14 +195,12 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing TitleChanged(this, e); } - //ToDo: OLW Spell Checker - //public event EventHandler EditingContextChanged; + public event EventHandler EditingContextChanged; public void UpdateEditingContext() { - //ToDo: OLW Spell Checker - //if (EditingContextChanged != null) - //EditingContextChanged(_spellingContext, null); + if (EditingContextChanged != null) + EditingContextChanged(_spellingContext, null); } public event EventHandler EditableRegionFocusChanged; @@ -332,8 +326,7 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing //post body element, so force the scroll back to the top of the document. ScrollToTop(); - //ToDo: OLW Spell Checker - //_spellingManager.ClearIgnoreOnce(); + _spellingManager.ClearIgnoreOnce(); refreshSpellCheckingSettings(); // Work around for 38082...conditionalize this for writer so that it doesn't steal focus for mail's case. @@ -1286,8 +1279,7 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing private bool _templateContainsTitle; public void LoadHtmlFragment(string title, string blogPostBody, string baseUrl, BlogEditingTemplate editingTemplate) { - //ToDo: OLW Spell Checker - //_spellingManager.ClearIgnoreOnce(); + _spellingManager.ClearIgnoreOnce(); _templateContainsTitle = editingTemplate.ContainsTitle; //if any manually attached behaviors are attached, remove them. @@ -1729,8 +1721,8 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing { MshtmlEditor.BeginInvoke(new ThreadStart(() => { - //_spellingManager.DamagedRange(newContentRange, false); - //_spellingManager.IgnoreOnce(newContentRange); + _spellingManager.DamagedRange(newContentRange, false); + _spellingManager.IgnoreOnce(newContentRange); }), null); } } @@ -1865,8 +1857,7 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing public override bool IsSelectionMisspelled() { - //ToDo: OLW Spell Checker - return false; // _spellingManager.FindMisspelling(SelectedMarkupRange.Start) != null || _spellingManager.IsInIgnoredWord(SelectedMarkupRange.Start); + return _spellingManager.FindMisspelling(SelectedMarkupRange.Start) != null || _spellingManager.IsInIgnoredWord(SelectedMarkupRange.Start); } private CommandContextMenuDefinition ContextMenuForElement(IHTMLElement element, Point screenPoint) @@ -1888,46 +1879,44 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing } else { - //MisspelledWordInfo wordInfo = _spellingManager.FindMisspelling(ScreenPointToMarkupPointer(screenPoint)); + MisspelledWordInfo wordInfo = _spellingManager.FindMisspelling(ScreenPointToMarkupPointer(screenPoint)); CommandContextMenuDefinition minimalTextEditingCommands = new TextContextMenuDefinition(true); bool anchorCommandsSupported = FullyEditableRegionActive && HTMLElementHelper.GetContainingAnchorElement(element) != null; // Ignore once once work in an edit field because we replace the HTML of smart content to much - //_spellingManager.IsIgnoreOnceEnabled = !isEditField; + _spellingManager.IsIgnoreOnceEnabled = !isEditField; if (anchorCommandsSupported) { - //ToDo: OLW Spell Checker - //if (null != wordInfo) - //{ - // return MergeContextMenuDefinitions(_spellingManager.CreateSpellCheckingContextMenu(wordInfo), - // MergeContextMenuDefinitions(new AnchorContextMenuDefinition(GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ShowAllLinkOptions)), minimalTextEditingCommands)); - //} - //else - //{ - return MergeContextMenuDefinitions(new AnchorContextMenuDefinition(GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ShowAllLinkOptions)), minimalTextEditingCommands); - //} - } - else - { - //ToDo: OLW Spell Checker - //if (null != wordInfo) - //{ - // return MergeContextMenuDefinitions(_spellingManager.CreateSpellCheckingContextMenu(wordInfo), minimalTextEditingCommands); - //} - //else - //{ - if (_tableEditingManager.ShowTableContextMenuForElement(element)) + if (null != wordInfo) { - return MergeContextMenuDefinitions( - _tableEditingManager.CreateTableContextMenuDefinition(), new TextContextMenuDefinition(true)); + return MergeContextMenuDefinitions(_spellingManager.CreateSpellCheckingContextMenu(wordInfo), + MergeContextMenuDefinitions(new AnchorContextMenuDefinition(GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ShowAllLinkOptions)), minimalTextEditingCommands)); } else { - return new TextContextMenuDefinition(); + return MergeContextMenuDefinitions(new AnchorContextMenuDefinition(GlobalEditorOptions.SupportsFeature(ContentEditorFeature.ShowAllLinkOptions)), minimalTextEditingCommands); + } + } + else + { + if (null != wordInfo) + { + return MergeContextMenuDefinitions(_spellingManager.CreateSpellCheckingContextMenu(wordInfo), minimalTextEditingCommands); + } + else + { + if (_tableEditingManager.ShowTableContextMenuForElement(element)) + { + return MergeContextMenuDefinitions( + _tableEditingManager.CreateTableContextMenuDefinition(), new TextContextMenuDefinition(true)); + } + else + { + return new TextContextMenuDefinition(); + } } - //} } } @@ -2096,22 +2085,21 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing private void InitializeSpellChecking() { IHTMLEditorDamageServices damageServices = ((IHtmlEditorComponentContext)this).DamageServices; - //ToDo: OLW Spell Checker - //if (_spellingManager == null) - return; + if (_spellingManager == null) + return; - //_spellingManager.Initialize(SpellingChecker, MshtmlEditor.MshtmlControl, HTMLDocument, - // new ReplaceWord(InsertHtml), IgnoreRangeForSpellChecking, new DamageFunction(damageServices.AddDamage)); + _spellingManager.Initialize(SpellingChecker, MshtmlEditor.MshtmlControl, HTMLDocument, + new ReplaceWord(InsertHtml), IgnoreRangeForSpellChecking, new DamageFunction(damageServices.AddDamage)); - //EditingContextChanged += new EventHandler(_spellingManager.UpdateSpellingContext); - //_spellingContext.SpellingOptionsChanged += new EventHandler(spellingSettings_SpellingSettingsChanged); - //_spellingManager.InitializeSession(_spellingContext); + EditingContextChanged += new EventHandler(_spellingManager.UpdateSpellingContext); + _spellingContext.SpellingOptionsChanged += new EventHandler(spellingSettings_SpellingSettingsChanged); + _spellingManager.InitializeSession(_spellingContext); } protected override void OnSpellCheckWordIgnored(MarkupRange range) { - //_spellingManager.IgnoreOnce(range); + _spellingManager.IgnoreOnce(range); } public override bool IgnoreRangeForSpellChecking(MarkupRange range) @@ -2125,8 +2113,8 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing if (range.Start.GetParentElement(IgnoreElementForSpellChecking) != null) return true; - //ToDo: OLW Spell Checker - return true; // _spellingManager.IsWordIgnored(range); + + return _spellingManager.IsWordIgnored(range); } private bool IgnoreElementForSpellChecking(IHTMLElement element) @@ -2149,8 +2137,7 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing return false; } - //ToDo: OLW Spell Checker - // private SpellingManager _spellingManager; + private SpellingManager _spellingManager; private void spellingSettings_SpellingSettingsChanged(object sender, EventArgs e) { @@ -2173,7 +2160,7 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing if (spellCheckingCommand != null) { - bool canSpellCheck = false; //ToDo: OLW Spell Checker // _spellingContext.CanSpellCheck; + bool canSpellCheck = _spellingContext.CanSpellCheck; if (spellCheckingCommand.On != canSpellCheck) { CommandManager.BeginUpdate(); @@ -2189,17 +2176,17 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing } } - if (false) //ToDo: OLW Spell Checker //_spellingContext.CanSpellCheck && SpellingSettings.RealTimeSpellChecking && Editable) + if (_spellingContext.CanSpellCheck && SpellingSettings.RealTimeSpellChecking && Editable) { //(re)initialize spelling squiggles for the new document - //MshtmlEditor.BeginInvoke(new ThreadStart(() => StartRealTimeSpellChecking(true))); + MshtmlEditor.BeginInvoke(new ThreadStart(() => StartRealTimeSpellChecking(true))); } else { StopRealTimeSpellChecking(); } - //_keyBoardHandler.SetAutoCorrectFile(_spellingContext.AutoCorrectLexiconFilePath); + _keyBoardHandler.SetAutoCorrectFile(_spellingContext.AutoCorrectLexiconFilePath); } private bool _realTimeSpellCheckingStarted = false; @@ -2210,14 +2197,13 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing /// private void StartRealTimeSpellChecking(bool forceSpellingScan) { - //ToDo: OLW Spell Checker - //if (!_realTimeSpellCheckingStarted) - //{ - // _realTimeSpellCheckingStarted = true; - //} + if (!_realTimeSpellCheckingStarted) + { + _realTimeSpellCheckingStarted = true; + } - //if (forceSpellingScan) - // _spellingManager.StartSession(); + if (forceSpellingScan) + _spellingManager.StartSession(); } /// @@ -2228,8 +2214,7 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing if (_realTimeSpellCheckingStarted) { _realTimeSpellCheckingStarted = false; - //ToDo: OLW Spell Checker - //_spellingManager.StopSession(false); + _spellingManager.StopSession(false); } } @@ -2240,27 +2225,25 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing public void ResumeSpellChecking() { - //ToDo: OLW Spell Checker - //if (_spellingContext.CanSpellCheck) - //{ - // StartRealTimeSpellChecking(true); - //} + if (_spellingContext.CanSpellCheck) + { + StartRealTimeSpellChecking(true); + } } protected void HandleSpellingDamage(object source, DamageEvent evt) { - //ToDo: OLW Spell Checker - //if (_spellingContext.CanSpellCheck) - //{ - // foreach (MarkupRange range in evt.DamageRegions) - // { - // if (!range.Positioned) - // continue; + if (_spellingContext.CanSpellCheck) + { + foreach (MarkupRange range in evt.DamageRegions) + { + if (!range.Positioned) + continue; - // foreach (MarkupRange targetRange in IntersectWithEditableElements(range)) - // _spellingManager.DamagedRange(targetRange, _realTimeSpellCheckingStarted); - // } - //} + foreach (MarkupRange targetRange in IntersectWithEditableElements(range)) + _spellingManager.DamagedRange(targetRange, _realTimeSpellCheckingStarted); + } + } } private MarkupPointer ScreenPointToMarkupPointer(Point screenPoint) diff --git a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/BlogPostHtmlSourceEditorControl.cs b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/BlogPostHtmlSourceEditorControl.cs index a05dc5f4..e24184a1 100644 --- a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/BlogPostHtmlSourceEditorControl.cs +++ b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/BlogPostHtmlSourceEditorControl.cs @@ -18,7 +18,7 @@ using OpenLiveWriter.HtmlEditor; using OpenLiveWriter.ApplicationFramework; using OpenLiveWriter.HtmlParser.Parser; using OpenLiveWriter.Localization; -//using OpenLiveWriter.SpellChecker; +using OpenLiveWriter.SpellChecker; namespace OpenLiveWriter.PostEditor.PostHtmlEditing { @@ -27,19 +27,16 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing private Panel panelSourceEditor; private TextBox textBoxTitle; private HtmlSourceEditorControl sourceControl; - //private readonly IBlogPostSpellCheckingContext spellingContext; + private readonly IBlogPostSpellCheckingContext spellingContext; private IBlogPostImageEditingContext editingContext; - //ToDo: OLW Spell Checker - //public BlogPostHtmlSourceEditorControl(IBlogPostSpellCheckingContext spellingContext, CommandManager commandManager, IBlogPostImageEditingContext editingContext) - public BlogPostHtmlSourceEditorControl(CommandManager commandManager, IBlogPostImageEditingContext editingContext) + public BlogPostHtmlSourceEditorControl(IBlogPostSpellCheckingContext spellingContext, CommandManager commandManager, IBlogPostImageEditingContext editingContext) { - //this.spellingContext = spellingContext; + this.spellingContext = spellingContext; this.editingContext = editingContext; InitializeComponent(); - //sourceControl = new HtmlSourceEditorControl(spellingContext.SpellingChecker, commandManager, editingContext); - sourceControl = new HtmlSourceEditorControl(commandManager, editingContext); + sourceControl = new HtmlSourceEditorControl(spellingContext.SpellingChecker, commandManager, editingContext); sourceControl.EditorControl.TextChanged += new EventHandler(EditorControl_TextChanged); sourceControl.EditorControl.GotFocus += new EventHandler(EditorControl_GotFocus); BorderControl borderControl = new BorderControl(); @@ -152,9 +149,8 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing public void UpdateEditingContext() { - //ToDo: OLW Spell Checker - //sourceControl.SpellingChecker.StopChecking(); - //sourceControl.SpellingChecker.StartChecking(spellingContext.PostSpellingContextDirectory); + sourceControl.SpellingChecker.StopChecking(); + sourceControl.SpellingChecker.StartChecking(spellingContext.PostSpellingContextDirectory); } private void textBoxTitle_TitleGotFocus(object sender, EventArgs e) @@ -389,11 +385,9 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing { private ReplaceAbsoluteFilePathsOperation _replaceOperation = new ReplaceAbsoluteFilePathsOperation(); private IBlogPostImageEditingContext editingContext; - //ToDo: OLW Spell Checker - //public HtmlSourceEditorControl(ISpellingChecker spellingChecker, CommandManager commandManager, IBlogPostImageEditingContext editingContext) - // : base(spellingChecker, commandManager) - public HtmlSourceEditorControl(CommandManager commandManager, IBlogPostImageEditingContext editingContext) - : base(commandManager) + + public HtmlSourceEditorControl(ISpellingChecker spellingChecker, CommandManager commandManager, IBlogPostImageEditingContext editingContext) + : base(spellingChecker, commandManager) { this.editingContext = editingContext; } diff --git a/src/managed/OpenLiveWriter.PostEditor/PreferencesHandler.cs b/src/managed/OpenLiveWriter.PostEditor/PreferencesHandler.cs index a713ce9c..934cbc6c 100644 --- a/src/managed/OpenLiveWriter.PostEditor/PreferencesHandler.cs +++ b/src/managed/OpenLiveWriter.PostEditor/PreferencesHandler.cs @@ -12,7 +12,7 @@ using OpenLiveWriter.Localization; using OpenLiveWriter.PostEditor.Autoreplace; using OpenLiveWriter.PostEditor.LiveClipboard; using OpenLiveWriter.PostEditor.Configuration.Accounts; -//using OpenLiveWriter.SpellChecker; +using OpenLiveWriter.SpellChecker; using OpenLiveWriter.CoreServices; namespace OpenLiveWriter.PostEditor @@ -150,13 +150,12 @@ namespace OpenLiveWriter.PostEditor preferencesPanelTypeTable["accounts"] = type; types.Add(type); - //ToDo: OLW Spell Checker //if (SpellingSettings.CanSpellCheck) //{ - // Spelling preferences. - // type = typeof(SpellingPreferencesPanel); - // preferencesPanelTypeTable["spelling"] = type; - // types.Add(type); + // Spelling preferences. + type = typeof(SpellingPreferencesPanel); + preferencesPanelTypeTable["spelling"] = type; + types.Add(type); //} //glossary management diff --git a/src/managed/OpenLiveWriter.SpellChecker/IWordRangeProvider.cs b/src/managed/OpenLiveWriter.SpellChecker/IWordRangeProvider.cs new file mode 100644 index 00000000..5c8f3436 --- /dev/null +++ b/src/managed/OpenLiveWriter.SpellChecker/IWordRangeProvider.cs @@ -0,0 +1,18 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for details. + +using System; +using System.Runtime.InteropServices; + +namespace OpenLiveWriter.SpellChecker +{ + [Guid("F4F06001-99F6-448F-9199-E863D771066B")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComVisible(true)] + public interface IWordRangeProvider + { + IWordRange GetSubjectSpellcheckWordRange(); + + void CloseSubjectSpellcheckWordRange(); + } +} diff --git a/src/managed/OpenLiveWriter.SpellChecker/OpenLiveWriter.SpellChecker.csproj b/src/managed/OpenLiveWriter.SpellChecker/OpenLiveWriter.SpellChecker.csproj index fa692a2c..edc94ad6 100644 --- a/src/managed/OpenLiveWriter.SpellChecker/OpenLiveWriter.SpellChecker.csproj +++ b/src/managed/OpenLiveWriter.SpellChecker/OpenLiveWriter.SpellChecker.csproj @@ -60,26 +60,23 @@ - + - - - - - Form Component + + @@ -89,8 +86,8 @@ Component - + @@ -99,26 +96,11 @@ SpellCheckerForm.cs Designer - SpellingPreferencesPanel.cs Designer - - - - $(FullTargetProjectPath)\Dictionaries - - - $(FullTargetProjectPath)\Dictionaries - - - - $(FullTargetProjectPath) - - - + \ No newline at end of file diff --git a/src/managed/OpenLiveWriter.SpellChecker/SentrySpellingChecker.cs b/src/managed/OpenLiveWriter.SpellChecker/SentrySpellingChecker.cs new file mode 100644 index 00000000..15bc51a4 --- /dev/null +++ b/src/managed/OpenLiveWriter.SpellChecker/SentrySpellingChecker.cs @@ -0,0 +1,14 @@ +namespace OpenLiveWriter.SpellChecker +{ + public class SentrySpellingChecker + { + public static string ContextDictionaryFileName + { + get + { + // TODO + return string.Empty; + } + } + } +} diff --git a/src/managed/OpenLiveWriter.SpellChecker/SpellerOptionBit.cs b/src/managed/OpenLiveWriter.SpellChecker/SpellerOptionBit.cs new file mode 100644 index 00000000..bab83e70 --- /dev/null +++ b/src/managed/OpenLiveWriter.SpellChecker/SpellerOptionBit.cs @@ -0,0 +1,12 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for details. + +namespace OpenLiveWriter.SpellChecker +{ + public enum SpellerOptionBit + { + IgnoreAllCaps = 2, + IgnoreMixedDigits = 4, + IgnoreSingleLetter = 131072 + } +} diff --git a/src/managed/OpenLiveWriter.SpellChecker/SpellingLanguageEntry.cs b/src/managed/OpenLiveWriter.SpellChecker/SpellingLanguageEntry.cs new file mode 100644 index 00000000..e6f41e4a --- /dev/null +++ b/src/managed/OpenLiveWriter.SpellChecker/SpellingLanguageEntry.cs @@ -0,0 +1,37 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for details. + +namespace OpenLiveWriter.SpellChecker +{ + public class SpellingLanguageEntry + { + public readonly SpellingCheckerLanguage Language; + public readonly ushort LCID; + public readonly string CSAPIEngine; + public readonly string TwoLetterIsoLanguageName; + public readonly string DisplayName; + public string[] CSAPILex { get; private set; } + + public SpellingLanguageEntry(SpellingCheckerLanguage language, ushort lcid, string csapiEngine, string[] csapiLex, string twoLetterIsoLanguageName, string displayName) + { + // TODO + this.Language = language; + this.CSAPILex = csapiLex; + this.CSAPIEngine = csapiEngine; + this.LCID = lcid; + this.TwoLetterIsoLanguageName = twoLetterIsoLanguageName; + this.DisplayName = displayName; + } + + public bool IsInstalled(string lexiconPath) + { + // TODO + return false; + } + + public override string ToString() + { + return this.DisplayName; + } + } +} diff --git a/src/managed/OpenLiveWriter.SpellChecker/WinSpellingChecker.cs b/src/managed/OpenLiveWriter.SpellChecker/WinSpellingChecker.cs new file mode 100644 index 00000000..ff8df53e --- /dev/null +++ b/src/managed/OpenLiveWriter.SpellChecker/WinSpellingChecker.cs @@ -0,0 +1,85 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for details. + +using System; +using System.Collections.Generic; + +namespace OpenLiveWriter.SpellChecker +{ + public class WinSpellingChecker : ISpellingChecker, IDisposable + { + public bool IsInitialized + { + get + { + // TODO + return false; + } + } + + public event EventHandler WordAdded; + public event EventHandler WordIgnored; + + public void AddToUserDictionary(string word) + { + // TODO + if (WordAdded == null) + return; + WordAdded(word, EventArgs.Empty); + } + + public SpellCheckResult CheckWord(string word, out string otherWord, out int offset, out int length) + { + // TODO + otherWord = null; + offset = 0; + length = word.Length; + return SpellCheckResult.Correct; + } + + public void Dispose() + { + // TODO + } + + public void IgnoreAll(string word) + { + // TODO + if (WordIgnored == null) + return; + WordIgnored(word, EventArgs.Empty); + } + + public void ReplaceAll(string word, string replaceWith) + { + // TODO + } + + public void Reset() + { + // TODO + } + + public void StartChecking(string contextDictionaryLocation) + { + // TODO + } + + public void StopChecking() + { + // TODO + } + + public SpellingSuggestion[] Suggest(string word, short maxSuggestions, short depth) + { + // TODO + List list = new List(); + return list.ToArray(); + } + + public void SetOptions(string engineDllPath, ushort lcid, string[] mainLexPaths, string userLexiconPath, uint sobitOptions) + { + // TODO + } + } +} diff --git a/src/managed/writer.sln b/src/managed/writer.sln index e9071519..df5eba94 100644 --- a/src/managed/writer.sln +++ b/src/managed/writer.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenLiveWriter.CoreServices", "OpenLiveWriter.CoreServices\OpenLiveWriter.CoreServices.csproj", "{9154B6B4-F2C3-4FB4-BE38-A26A6C9409EE}" EndProject @@ -83,6 +83,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PostBuild.CreateInstaller", {A5C213F6-F0C6-4FD6-B496-61FE434621A6} = {A5C213F6-F0C6-4FD6-B496-61FE434621A6} EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenLiveWriter.SpellChecker", "OpenLiveWriter.SpellChecker\OpenLiveWriter.SpellChecker.csproj", "{2DB3A424-0F1E-44AC-AE01-5454586CE769}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -193,6 +195,10 @@ Global {4E445FF3-7F7B-46D1-9424-682E146F1F09}.Debug|Any CPU.Build.0 = Debug|Any CPU {4E445FF3-7F7B-46D1-9424-682E146F1F09}.Release|Any CPU.ActiveCfg = Release|Any CPU {4E445FF3-7F7B-46D1-9424-682E146F1F09}.Release|Any CPU.Build.0 = Release|Any CPU + {2DB3A424-0F1E-44AC-AE01-5454586CE769}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2DB3A424-0F1E-44AC-AE01-5454586CE769}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2DB3A424-0F1E-44AC-AE01-5454586CE769}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2DB3A424-0F1E-44AC-AE01-5454586CE769}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE