Merge remote-tracking branch 'refs/remotes/OpenLiveWriter/master'

This commit is contained in:
kathweaver 2016-01-23 18:59:00 -06:00
commit fa0d3e266c
50 changed files with 573 additions and 1080 deletions

View File

@ -54,6 +54,8 @@
<file src="OpenLiveWriter.Mshtml.dll" target="lib\net451\OpenLiveWriter.Mshtml.dll" />
<file src="OpenLiveWriter.PostEditor.dll" target="lib\net451\OpenLiveWriter.PostEditor.dll" />
<file src="OpenLiveWriter.Ribbon.dll" target="lib\net451\OpenLiveWriter.Ribbon.dll" />
<file src="OpenLiveWriter.SpellChecker.dll" target="lib\net451\OpenLiveWriter.SpellChecker.dll" />
<file src="PlatformSpellCheck.dll" target="lib\net451\PlatformSpellCheck.dll" />
<file src="Splat.dll" target="lib\net451\Splat.dll" />
<file src="Squirrel.dll" target="lib\net451\Squirrel.dll" />
<file src="System.Net.Http.Extensions.dll" target="lib\net451\System.Net.Http.Extensions.dll" />

8
faq.md
View File

@ -2,13 +2,13 @@
A: Open Live Writer is an open source fork of the original Windows Live Writer; an application for authoring, editing, and publishing weblog posts.
##### Q: Does this replace Windows Live Writer?
A: Technically no, spiritually yes. Open Live Writer is designed to run side-by-side with Windows Live Writer so you can still use Windows Live Writer as you have been. Spiritually, the volunteer team hopes that Open Live Writer will have all of the functionality of Windows Live Writer and much more. One of the best things about Windows Live Writer was the community behind it, this the community can really get involved with Open Live Writer.
A: Technically no, spiritually yes. Open Live Writer is designed to run side-by-side with Windows Live Writer so you can still use Windows Live Writer as you have been. Spiritually, the volunteer team hopes that Open Live Writer will have all of the functionality of Windows Live Writer and much more. One of the best things about Windows Live Writer was the community behind it, thus the community can really get involved with Open Live Writer.
##### Q: Why the .NET Foundation?
A: The codebase is approximately 200,000 lines of C# so it was a good fit. Take a look at their [About](http://www.dotnetfoundation.org/about) page to learn more.
##### Q: Does it work on older versions of Windows?
A: We focused on Windows 10 for the v0.5 release. We hope to support Windows 7 and Windows 8 for a while at least.
A: We focused on Windows 10 for the v0.5 release. We hope to support Windows 7 and Windows 8 for a while at least. We will not be able to support Windows XP due to the version of .NET used.
##### Q: Does it work on a Mac? On Linux?
A: Since .NET runs on Mac OS and Linux, it is possible to port some of the code to run on Mac OS or Linux. But significant portions of the code use Windows-specific APIs. You are welcome to find the code on GitHub and fork it to run under Mono - that would be awesome.
@ -19,7 +19,9 @@ A: Yes! Open Live Writer is licensed under the open source [MIT license](https:/
##### Q: I found a bug, what do I do?
A: Add to an existing issue or create a new issue via GitHub: https://github.com/OpenLiveWriter/OpenLiveWriter/issues/new
Before creating a new issue, make sure that the issue does not already exist and feel free to add to the issue.
When creating a new issue, identify as much information as you can to assist the developers in fixing the issue.
When creating a new issue, identify as much information as you can to assist the developers in fixing the issue. It would be
helpful to include the log file and any messages you received. The log file is found at %localappdata%\OpenLiveWriter . An easy way
to get to it is to navigate to File | About | Show log file which is on the lower left of the about dialog box.
##### Q: How can I get involved?
A: WELCOME! We definitely love contributions!

View File

@ -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
{

View File

@ -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
/// <summary>
/// Get the spelling-checker (demand-create and cache/re-use)
/// </summary>
//protected ISpellingChecker SpellingChecker
//{
// get
// {
// return _spellingChecker;
// }
//}
//private ISpellingChecker _spellingChecker;
protected ISpellingChecker SpellingChecker
{
get
{
return _spellingChecker;
}
}
private ISpellingChecker _spellingChecker;
#endregion
@ -3442,7 +3440,7 @@ namespace OpenLiveWriter.HtmlEditor
/// Check the spelling of the document, returning true if the user completed the spelling check
/// </summary>
/// <returns>false if they cancelled the spelling check or if we're already in the middle of executing a spell check</returns>
public bool CheckSpelling(string contextDictionaryPath)
public bool CheckSpelling()
{
if (!Editable || _isSpellChecking)
return false;
@ -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);
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);
//wordRangeProvider.CloseSubjectSpellcheckWordRange();
fCompleted = true; // spellCheckerForm.Completed;
wordRangeProvider.CloseSubjectSpellcheckWordRange();
fCompleted = spellCheckerForm.Completed;
}
}

View File

@ -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);
@ -278,40 +276,38 @@ namespace OpenLiveWriter.HtmlEditor
}
}
public bool CheckSpelling(string contextDictionaryPath)
public bool CheckSpelling()
{
//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);
// return completed status
return true; // spellCheckerForm.Completed;
//}
// return completed status
return spellCheckerForm.Completed;
}
}
//ToDo: OLW Spell Checker
/// <summary>
/// Get the spelling-checker (demand-create and cache/re-use)
/// </summary>
//public ISpellingChecker SpellingChecker
//{
// get
// {
// return _spellingChecker;
// }
//}
//private ISpellingChecker _spellingChecker;
public ISpellingChecker SpellingChecker
{
get
{
return _spellingChecker;
}
}
private ISpellingChecker _spellingChecker;
#endregion

View File

@ -94,7 +94,7 @@ namespace OpenLiveWriter.HtmlEditor
LinkInfo DiscoverCurrentLink();
bool CheckSpelling(string contextDictionaryPath);
bool CheckSpelling();
bool FullyEditableRegionActive { get; }

View File

@ -7,6 +7,10 @@
<ProjectGuid>{6A6872BC-67EF-4A42-A21A-30ECED376923}</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\OpenLiveWriter.SpellChecker\OpenLiveWriter.SpellChecker.csproj">
<Project>{2db3a424-0f1e-44ac-ae01-5454586ce769}</Project>
<Name>OpenLiveWriter.SpellChecker</Name>
</ProjectReference>
<Reference Include="Accessibility" />
<Reference Include="System" />
<Reference Include="System.Data" />
@ -234,4 +238,4 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(RepoRoot)\writer.build.targets" />
</Project>
</Project>

View File

@ -212,5 +212,17 @@ namespace OpenLiveWriter.Localization
{
return new CultureInfo(lcid).TextInfo.IsRightToLeft;
}
public static bool IsRtlCulture(string bcp47Code)
{
try
{
return new CultureInfo(bcp47Code).TextInfo.IsRightToLeft;
}
catch
{
return false;
}
}
}
}

View File

@ -649,7 +649,7 @@
Type="Exclamation"
Buttons="YesNo"
Title="Open Live Writer"
Text="{0}&#xD;&#xA;Not a valid URL.&#xD;&#xA;Do you want to continue?"
Text="{0}&#xD;&#xA;Not a valid URL.&#xD;&#xA;Do you want to go back and edit the URL?"
comment:Text="{0} - the url that was entered"/>
<Message
Identifier="InvalidInsertionPoint"

View File

@ -2835,7 +2835,7 @@ Check the file name and try again.</value>
<data name="DisplayMessage.InputIsNotUrl.Text" xml:space="preserve">
<value>{0}
Not a valid URL.
Do you want to continue?</value>
Do you want to go back and edit the URL?</value>
<comment>{0} - the url that was entered</comment></data>
<data name="DisplayMessage.InputIsNotUrl.Title" xml:space="preserve">
<value>Open Live Writer</value>

View File

@ -1319,166 +1319,14 @@ namespace OpenLiveWriter.Localization
/// </summary>
DeleteSomething,
/// <summary>
/// Arabic
/// </summary>
DictionaryLanguageArabic,
/// <summary>
/// Basque
/// </summary>
DictionaryLanguageBasque,
/// <summary>
/// Bulgarian
/// </summary>
DictionaryLanguageBulgarian,
/// <summary>
/// Catalan
/// </summary>
DictionaryLanguageCatalan,
/// <summary>
/// Croatian
/// </summary>
DictionaryLanguageCroatian,
/// <summary>
/// Czech
/// </summary>
DictionaryLanguageCzech,
/// <summary>
/// Dutch
/// </summary>
DictionaryLanguageDutch,
/// <summary>
/// English (Australia)
/// </summary>
DictionaryLanguageEnglishAustralia,
/// <summary>
/// English (Canada)
/// </summary>
DictionaryLanguageEnglishCanada,
/// <summary>
/// English (United Kingdom)
/// </summary>
DictionaryLanguageEnglishUK,
/// <summary>
/// English (United States)
/// </summary>
DictionaryLanguageEnglishUS,
/// <summary>
/// Estonian
/// </summary>
DictionaryLanguageEstonian,
/// <summary>
/// Finnish
/// </summary>
DictionaryLanguageFinnish,
/// <summary>
/// French
/// </summary>
DictionaryLanguageFrench,
/// <summary>
/// German
/// </summary>
DictionaryLanguageGerman,
/// <summary>
/// German (Reform)
/// </summary>
DictionaryLanguageGermanReform,
/// <summary>
/// Greek
/// </summary>
DictionaryLanguageGreek,
/// <summary>
/// Hebrew
/// </summary>
DictionaryLanguageHebrew,
/// <summary>
/// Hungarian
/// </summary>
DictionaryLanguageHungarian,
/// <summary>
/// Indonesian
/// </summary>
DictionaryLanguageIndonesian,
/// <summary>
/// Italian
/// </summary>
DictionaryLanguageItalian,
/// <summary>
/// Korean
/// </summary>
DictionaryLanguageKorean,
/// <summary>
/// Dictionary &language:
/// </summary>
DictionaryLanguageLabel,
/// <summary>
/// Latvian
/// </summary>
DictionaryLanguageLatvian,
/// <summary>
/// Lithuanian
/// </summary>
DictionaryLanguageLithuanian,
/// <summary>
/// Malay
/// </summary>
DictionaryLanguageMalay,
/// <summary>
/// (None)
/// </summary>
DictionaryLanguageNone,
/// <summary>
/// Polish
/// </summary>
DictionaryLanguagePolish,
/// <summary>
/// Portuguese
/// </summary>
DictionaryLanguagePortuguese,
/// <summary>
/// Portuguese (Brazil)
/// </summary>
DictionaryLanguagePortugueseBrazil,
/// <summary>
/// Romanian
/// </summary>
DictionaryLanguageRomanian,
/// <summary>
/// Russian
/// </summary>
DictionaryLanguageRussian,
/// <summary>
/// Serbian (Cyrillic)
/// </summary>
DictionaryLanguageSerbianCyrillic,
/// <summary>
/// Serbian (Latin)
/// </summary>
DictionaryLanguageSerbianLatin,
/// <summary>
/// Slovak
/// </summary>
DictionaryLanguageSlovak,
/// <summary>
/// Slovenian
/// </summary>
DictionaryLanguageSlovenian,
/// <summary>
/// Spanish
/// </summary>
DictionaryLanguageSpanish,
/// <summary>
/// Swedish
/// </summary>
DictionaryLanguageSwedish,
/// <summary>
/// Turkish
/// </summary>
DictionaryLanguageTurkish,
/// <summary>
/// Ukrainian
/// </summary>
DictionaryLanguageUkrainian,
/// <summary>
/// {0}x{1}
/// </summary>
DimensionsFormat,
@ -4480,10 +4328,6 @@ namespace OpenLiveWriter.Localization
/// </summary>
SpellingPrefName,
/// <summary>
/// Ignore words with &numbers
/// </summary>
SpellingPrefNum,
/// <summary>
/// General options
/// </summary>
SpellingPrefOptions,
@ -4496,10 +4340,6 @@ namespace OpenLiveWriter.Localization
/// </summary>
SpellingPrefReal,
/// <summary>
/// Ignore words in &UPPERCASE
/// </summary>
SpellingPrefUpper,
/// <summary>
/// (No suggestions)
/// </summary>
SpellNoSuggest,

View File

@ -1249,126 +1249,12 @@
<value>Delete {0}</value>
<comment>{0} can be Post, Page, Draft, Published</comment>
</data>
<data name="DictionaryLanguageArabic" xml:space="preserve">
<value>Arabic</value>
</data>
<data name="DictionaryLanguageBasque" xml:space="preserve">
<value>Basque</value>
</data>
<data name="DictionaryLanguageBulgarian" xml:space="preserve">
<value>Bulgarian</value>
</data>
<data name="DictionaryLanguageCatalan" xml:space="preserve">
<value>Catalan</value>
</data>
<data name="DictionaryLanguageCroatian" xml:space="preserve">
<value>Croatian</value>
</data>
<data name="DictionaryLanguageCzech" xml:space="preserve">
<value>Czech</value>
</data>
<data name="DictionaryLanguageDutch" xml:space="preserve">
<value>Dutch</value>
</data>
<data name="DictionaryLanguageEnglishAustralia" xml:space="preserve">
<value>English (Australia)</value>
</data>
<data name="DictionaryLanguageEnglishCanada" xml:space="preserve">
<value>English (Canada)</value>
</data>
<data name="DictionaryLanguageEnglishUK" xml:space="preserve">
<value>English (United Kingdom)</value>
</data>
<data name="DictionaryLanguageEnglishUS" xml:space="preserve">
<value>English (United States)</value>
</data>
<data name="DictionaryLanguageEstonian" xml:space="preserve">
<value>Estonian</value>
</data>
<data name="DictionaryLanguageFinnish" xml:space="preserve">
<value>Finnish</value>
</data>
<data name="DictionaryLanguageFrench" xml:space="preserve">
<value>French</value>
</data>
<data name="DictionaryLanguageGerman" xml:space="preserve">
<value>German</value>
</data>
<data name="DictionaryLanguageGermanReform" xml:space="preserve">
<value>German (Reform)</value>
</data>
<data name="DictionaryLanguageGreek" xml:space="preserve">
<value>Greek</value>
</data>
<data name="DictionaryLanguageHebrew" xml:space="preserve">
<value>Hebrew</value>
</data>
<data name="DictionaryLanguageHungarian" xml:space="preserve">
<value>Hungarian</value>
</data>
<data name="DictionaryLanguageIndonesian" xml:space="preserve">
<value>Indonesian</value>
</data>
<data name="DictionaryLanguageItalian" xml:space="preserve">
<value>Italian</value>
</data>
<data name="DictionaryLanguageKorean" xml:space="preserve">
<value>Korean</value>
</data>
<data name="DictionaryLanguageLabel" xml:space="preserve">
<value>Dictionary &amp;language:</value>
</data>
<data name="DictionaryLanguageLatvian" xml:space="preserve">
<value>Latvian</value>
</data>
<data name="DictionaryLanguageLithuanian" xml:space="preserve">
<value>Lithuanian</value>
</data>
<data name="DictionaryLanguageMalay" xml:space="preserve">
<value>Malay</value>
</data>
<data name="DictionaryLanguageNone" xml:space="preserve">
<value>(None)</value>
</data>
<data name="DictionaryLanguagePolish" xml:space="preserve">
<value>Polish</value>
</data>
<data name="DictionaryLanguagePortuguese" xml:space="preserve">
<value>Portuguese</value>
</data>
<data name="DictionaryLanguagePortugueseBrazil" xml:space="preserve">
<value>Portuguese (Brazil)</value>
</data>
<data name="DictionaryLanguageRomanian" xml:space="preserve">
<value>Romanian</value>
</data>
<data name="DictionaryLanguageRussian" xml:space="preserve">
<value>Russian</value>
</data>
<data name="DictionaryLanguageSerbianCyrillic" xml:space="preserve">
<value>Serbian (Cyrillic)</value>
</data>
<data name="DictionaryLanguageSerbianLatin" xml:space="preserve">
<value>Serbian (Latin)</value>
</data>
<data name="DictionaryLanguageSlovak" xml:space="preserve">
<value>Slovak</value>
</data>
<data name="DictionaryLanguageSlovenian" xml:space="preserve">
<value>Slovenian</value>
</data>
<data name="DictionaryLanguageSpanish" xml:space="preserve">
<value>Spanish</value>
</data>
<data name="DictionaryLanguageSwedish" xml:space="preserve">
<value>Swedish</value>
</data>
<data name="DictionaryLanguageTurkish" xml:space="preserve">
<value>Turkish</value>
</data>
<data name="DictionaryLanguageUkrainian" xml:space="preserve">
<value>Ukrainian</value>
</data>
<data name="DimensionsFormat" xml:space="preserve">
<value>{0}x{1}</value>
<comment>{0} - width, {1} - height</comment>

View File

@ -46,6 +46,7 @@ namespace OpenLiveWriter.PostEditor
"Google API Client Library for .NET (Apache 2.0) (C) Copyright Google Inc.\nhttps://developers.google.com/api-client-library/dotnet/",
"Ionic Zlib Copyright (c) 2000,2001,2002,2003 ymnk, JCraft",
"Mono.Cecil (MIT) Copyright © 2008 - 2015 Jb Evain Copyright © 2008 - 2011 Novell, Inc \nhttps://github.com/jbevain/cecil",
"PlatformSpellCheck (MIT) Copyright © 2015 Bruce Bowyer-Smyth \nhttps://github.com/bbowyersmyth/spellcheck/",
/* XmpMetadata.cs */ "Portions Copyright © 2011 Omar Shahine, licensed under Creative Commons Attribution 3.0 Unported License.",
"Splat (MIT) Copyright © 2013 Paul Betts \nhttps://github.com/paulcbetts/splat/",
"Squirrel.Windows (MIT) Copyright © 2012 GitHub, Inc. \nhttps://github.com/squirrel/squirrel.windows",

View File

@ -382,11 +382,6 @@ namespace OpenLiveWriter.PostEditor
get { return BlogPost.Id; }
}
public string GetPostSpellingContextDirectory()
{
return SupportingFileStorage.SpellingContextDirectory;
}
public event EventHandler EditingStatusChanged;
#endregion

View File

@ -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;
@ -105,44 +105,6 @@ namespace OpenLiveWriter.PostEditor
return cleanPath;
}
public string SpellingContextDirectory
{
get
{
if (_spellingContextDirectory == null)
{
_spellingContextDirectory = Path.Combine(StoragePath, SPELLING_CONTEXT);
if (!Directory.Exists(_spellingContextDirectory))
Directory.CreateDirectory(_spellingContextDirectory);
}
return _spellingContextDirectory;
}
}
private string _spellingContextDirectory;
private const string SPELLING_CONTEXT = "SpellingContext";
public void WriteSpellingContextDictionary(Stream dictionaryContents)
{
string contextDictionaryPath = Path.Combine(SpellingContextDirectory, CONTEXT_DICTIONARY_FILE);
using (FileStream dictionaryFile = new FileStream(contextDictionaryPath, FileMode.Create))
{
StreamHelper.Transfer(dictionaryContents, dictionaryFile);
}
}
public Stream ReadSpellingContextDictionary()
{
string contextDictionaryPath = Path.Combine(SpellingContextDirectory, CONTEXT_DICTIONARY_FILE);
if (File.Exists(contextDictionaryPath))
return new FileStream(contextDictionaryPath, FileMode.Open);
else
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 DirectoryInfo _storageDirectory;
}

View File

@ -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<string>(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)
{
@ -970,7 +966,7 @@ namespace OpenLiveWriter.PostEditor
private void InitializeTextEditingCommands()
{
DisposeTextEditingCommandDispatcher();
_textEditingCommandDispatcher = new TextEditingCommandDispatcher(_mainFrameWindow, new SpellingContextDirectorySource(_editingContext.GetPostSpellingContextDirectory), _postEditingSite.StyleControl, CommandManager);
_textEditingCommandDispatcher = new TextEditingCommandDispatcher(_mainFrameWindow, _postEditingSite.StyleControl, CommandManager);
_textEditingCommandDispatcher.RegisterPostEditor(this, ComponentContext, new TextEditingFocusHandler(Focus));
if (_mainFrameWindow is Control)
@ -1610,10 +1606,10 @@ namespace OpenLiveWriter.PostEditor
_currentEditor.CommandSource.PrintPreview();
}
public bool CheckSpelling(string spellingContextDirectory)
public bool CheckSpelling()
{
// check spelling
return _currentEditor.CommandSource.CheckSpelling(spellingContextDirectory);
return _currentEditor.CommandSource.CheckSpelling();
}
public void Focus()
@ -2407,49 +2403,36 @@ namespace OpenLiveWriter.PostEditor
{
get
{
return true; // _spellingChecker.IsInitialized;
return _spellingChecker.IsInitialized;
}
}
public string PostSpellingContextDirectory
{
get { return _supportingFileStorage.SpellingContextDirectory; }
}
public string AutoCorrectLexiconFilePath
{
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)
public void SetSpellingOptions(string bcp47Code, bool useAutoCorrect)
{
if (ControlHelper.ControlCanHandleInvoke(_editorContainer) && _editorContainer.InvokeRequired)
{
_editorContainer.BeginInvoke(new ThreadStart(
() => SetSpellingOptions(dllName, lcid, mainLexFiles, userLexFile, sobitOptions, useAutoCorrect)
() => SetSpellingOptions(bcp47Code, useAutoCorrect)
));
return;
}
//ToDo: OLW Spell Checker
//_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");
//}
_spellingChecker.StopChecking();
_spellingChecker.SetOptions(bcp47Code);
_spellingChecker.StartChecking();
_autoCorrectLexiconFile = null; // TODO: Auto correct custom file
if (SpellingOptionsChanged != null)
{
SpellingOptionsChanged(this, EventArgs.Empty);
@ -2458,8 +2441,8 @@ namespace OpenLiveWriter.PostEditor
public void DisableSpelling()
{
//_spellingChecker.StopChecking();
//_spellingChecker.SetOptions(null, 0, null, null, 0);
_spellingChecker.StopChecking();
_spellingChecker.SetOptions(string.Empty);
if (SpellingOptionsChanged != null)
SpellingOptionsChanged(this, EventArgs.Empty);
}

View File

@ -39,8 +39,6 @@ namespace OpenLiveWriter.PostEditor
[ComVisible(true)]
public class ContentEditorFactory : IContentEditorFactory
{
private uint _globalSobitOptions;
#region IContentEditorFactory Members
private RedirectionLogger _logger;
@ -128,25 +126,8 @@ namespace OpenLiveWriter.PostEditor
return new ContentEditorProxy(this, contentEditorSite, internetSecurityManager, htmlDocument, options, dlControlFlags, color, wpost);
}
public void SetSpellingOptions(uint sobitOptions)
{
_globalSobitOptions = sobitOptions;
if (GlobalSpellingOptionsChanged != null)
GlobalSpellingOptionsChanged(this, EventArgs.Empty);
}
#endregion
internal uint GlobalSpellingOptions
{
get
{
return _globalSobitOptions;
}
}
internal event EventHandler GlobalSpellingOptionsChanged;
#region IContentEditorFactory Members
public void DoPreloadWork()
@ -337,8 +318,6 @@ namespace OpenLiveWriter.PostEditor
{
contentEditor.IndentColor = color;
}
this.factory.GlobalSpellingOptionsChanged += GlobalSpellingOptionsChangedHandler;
}
catch (Exception ex)
{
@ -439,7 +418,6 @@ namespace OpenLiveWriter.PostEditor
}
private ContentEditorFactory factory;
private SpellingOptionState _spellingState;
private string _wysiwygHTML;
private string _previewHTML;
public void SetTheme(string wysiwygHTML)
@ -451,12 +429,9 @@ namespace OpenLiveWriter.PostEditor
contentEditor.SetTheme(_wysiwygHTML, null, false);
}
public void SetSpellingOptions(string dllName, ushort lcid, string[] mainLexFiles, string userLexFile, uint sobitOptions, bool useAutoCorrect)
public void SetSpellingOptions(string bcp47Code, uint sobitOptions, bool useAutoCorrect)
{
_spellingState = new SpellingOptionState(
dllName, lcid, mainLexFiles, userLexFile, sobitOptions, useAutoCorrect);
_spellingState.Apply(contentEditor, factory.GlobalSpellingOptions);
if (CultureHelper.IsRtlLcid(lcid))
if (CultureHelper.IsRtlCulture(bcp47Code))
{
EmailContentTarget target =
GlobalEditorOptions.ContentTarget as EmailContentTarget;
@ -469,41 +444,9 @@ namespace OpenLiveWriter.PostEditor
public void DisableSpelling()
{
_spellingState = null;
contentEditor.DisableSpelling();
}
private void GlobalSpellingOptionsChangedHandler(object sender, EventArgs e)
{
if (_spellingState != null)
_spellingState.Apply(contentEditor, factory.GlobalSpellingOptions);
}
class SpellingOptionState
{
readonly string dllName;
readonly ushort lcid;
readonly string[] mainLexFiles;
readonly string userLexFile;
readonly uint sobitOptions;
readonly bool useAutoCorrect;
public SpellingOptionState(string dllName, ushort lcid, string[] mainLexFiles, string userLexFile, uint sobitOptions, bool useAutoCorrect)
{
this.dllName = dllName;
this.lcid = lcid;
this.mainLexFiles = mainLexFiles;
this.userLexFile = userLexFile;
this.sobitOptions = sobitOptions;
this.useAutoCorrect = useAutoCorrect;
}
public void Apply(ContentEditor editor, uint globalSobitOptions)
{
editor.SetSpellingOptions(dllName, lcid, mainLexFiles, userLexFile, sobitOptions | globalSobitOptions, useAutoCorrect);
}
}
public void AutoreplaceEmoticons(bool enabled)
{
AutoreplaceSettings.EnableEmoticonsReplacement = enabled;
@ -515,8 +458,6 @@ namespace OpenLiveWriter.PostEditor
public void Dispose()
{
factory.GlobalSpellingOptionsChanged -= GlobalSpellingOptionsChangedHandler;
contentEditor.DocumentComplete -= new EventHandler(blogPostHtmlEditor_DocumentComplete);
contentEditor.GotFocus -= new EventHandler(contentEditor_GotFocus);
contentEditor.LostFocus -= new EventHandler(contentEditor_LostFocus);

View File

@ -130,12 +130,10 @@ namespace OpenLiveWriter.PostEditor
/// <summary>
/// Selling configuration
/// </summary>
/// <param name="dllName">path to engine dll</param>
/// <param name="lcid">lcid of the language to spell</param>
/// <param name="mainLexFiles">path to lexicon files</param>
/// <param name="userLexFile"></param>
/// <param name="bcp47Code">BCP47 culture code of the language to spell</param>
/// <param name="sobitOptions">spelling options</param>
void SetSpellingOptions(string dllName, ushort lcid, string[] mainLexFiles, string userLexFile, uint sobitOptions, bool useAutoCorrect);
/// <param name="useAutoCorrect">Auto correct spelling</param>
void SetSpellingOptions(string bcp47Code, uint sobitOptions, bool useAutoCorrect);
/// <summary>
/// Turns off spelling checking--for example, user selected "None" for dictionary

View File

@ -269,12 +269,7 @@ namespace OpenLiveWriter.PostEditor
/// disposes native resources
/// </summary>
void Shutdown();
/// <summary>
/// Spelling options
/// </summary>
void SetSpellingOptions(uint sobitOptions);
/// <summary>
/// Preloads some of the costly work assoicated with creating a ContentEditor
/// </summary>

View File

@ -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.
/// </summary>
//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

View File

@ -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
{

View File

@ -21,8 +21,6 @@ namespace OpenLiveWriter.PostEditor
PostEditorFile AutoSaveLocalFile { get; }
// @SharedCanvas - this should not be here, it is only hear because it was an
// easy way to get the information from BlogPostManagingEditor into the CE
string GetPostSpellingContextDirectory();
}
public class BlogPostEditingContext : IBlogPostEditingContext

View File

@ -48,8 +48,12 @@ namespace OpenLiveWriter.PostEditor.ImageInsertion.WebImages
{
if (!UrlHelper.IsUrl(_source.SourceImageLink))
{
if (DisplayMessage.Show(MessageId.InputIsNotUrl, this, _source.SourceImageLink) == System.Windows.Forms.DialogResult.No)
//Ask if they want to go back and correct the link or just abort it altogether
if (DisplayMessage.Show(MessageId.InputIsNotUrl, this, _source.SourceImageLink) == System.Windows.Forms.DialogResult.Yes)
{
_source.TabSelected();
return;
}
}
DialogResult = System.Windows.Forms.DialogResult.OK;
}

View File

@ -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;

View File

@ -11,6 +11,10 @@
</NuGetPackageImportStamp>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\OpenLiveWriter.SpellChecker\OpenLiveWriter.SpellChecker.csproj">
<Project>{2db3a424-0f1e-44ac-ae01-5454586ce769}</Project>
<Name>OpenLiveWriter.SpellChecker</Name>
</ProjectReference>
<Reference Include="Accessibility" />
<Reference Include="DeltaCompressionDotNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1d14d6e5194e7f4a, processorArchitecture=MSIL">
<HintPath>..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.dll</HintPath>

View File

@ -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;

View File

@ -366,9 +366,6 @@ namespace OpenLiveWriter.PostEditor
//read in the image data (note: this must happen before fixing the file references)
BlogPostImageDataList imageDataList = (BlogPostImageDataList)ReadXml(postStorage, POST_IMAGE_FILES, new XmlReadHandler(new ImageListReader(supportingFilePersister, supportingFileService).ReadImageFiles));
// read spelling context dictionary into supporting file storage
ReadSpellingContextDictionary(postStorage, supportingFileStorage);
//read the extension data settings
BlogPostExtensionDataList extensionDataList = new BlogPostExtensionDataList(supportingFileService);
try
@ -515,9 +512,6 @@ namespace OpenLiveWriter.PostEditor
//write the extension data
WriteXml(postStorage, POST_EXTENSION_DATA_LIST, editingContext.ExtensionDataList, new XmlWriteHandler(new ExtensionDataListWriter(supportingFilePersister, blogPost.Contents).WriteExtensionDataList));
// spelling context dictionary
WriteSpellingContextDictionary(postStorage, editingContext.SupportingFileStorage);
//Convert file references in the HTML contents to the new storage path
string fixedUpPostContents = supportingFilePersister.FixupHtmlReferences(blogPost.Contents);
WriteStringUtf8(postStorage, POST_CONTENTS, fixedUpPostContents);
@ -978,31 +972,6 @@ namespace OpenLiveWriter.PostEditor
return categories.ToArray(typeof(BlogPostCategory));
}
private void ReadSpellingContextDictionary(Storage postStorage, BlogPostSupportingFileStorage supportingFileStorage)
{
// try to get the dictionary stream
Stream dictionaryStream;
try { dictionaryStream = postStorage.OpenStream(SPELLING_CONTEXT_DICTIONARY, StorageMode.Open); }
catch (StorageException) { return; }
// write it to supporting file storage
using (dictionaryStream)
supportingFileStorage.WriteSpellingContextDictionary(dictionaryStream);
}
private void WriteSpellingContextDictionary(Storage postStorage, BlogPostSupportingFileStorage supportingFileStorage)
{
Stream spellingStream = supportingFileStorage.ReadSpellingContextDictionary();
if (spellingStream != null)
{
using (spellingStream)
{
using (Stream stream = postStorage.OpenStream(SPELLING_CONTEXT_DICTIONARY, StorageMode.Create))
StreamHelper.Transfer(spellingStream, stream);
}
}
}
private class AttachedImageListWriter
{
SupportingFileReferenceList _referenceList;
@ -1792,8 +1761,6 @@ namespace OpenLiveWriter.PostEditor
private const string CATEGORY_NAME_ATTRIBUTE = "Name";
private const string CATEGORY_PARENT_ATTRIBUTE = "Parent";
private const string SPELLING_CONTEXT_DICTIONARY = "SpellingContextDictionary";
private const string SUPPORTING_FILE_LINK_ELEMENT = "SupportingFileLink";
private const string SUPPORTING_FILE_LINK_NAME_ATTRIBUTE = "Name";
private const string SUPPORTING_FILE_LINK_FILE_ID_ATTRIBUTE = "SupportingFileId";

View File

@ -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())
{
return (DialogResult.Yes == DisplayMessage.Show(MessageId.SpellCheckCancelledStillPost, _mainFrameWindow));
}
}
return true;
}
@ -1107,11 +1107,6 @@ namespace OpenLiveWriter.PostEditor
#region Private Helper Methods
private string GetSpellingContextDirectory()
{
return _editingManager.GetPostSpellingContextDirectory();
}
private void ManageCommands()
{
// Temporary work around for WinLive 51425.

View File

@ -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;

View File

@ -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,19 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing
private void ApplySpellingSettings(object sender, EventArgs args)
{
//ToDo: OLW Spell Checker
//SpellingCheckerLanguage language = SpellingSettings.Language;
string 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);
//uint sobit = 0;
//if (SpellingSettings.IgnoreUppercase)
// sobit |= (uint)SpellerOptionBit.IgnoreAllCaps;
//if (SpellingSettings.IgnoreWordsWithNumbers)
// sobit |= (uint)SpellerOptionBit.IgnoreMixedDigits;
//sobit |= (uint)SpellerOptionBit.IgnoreSingleLetter;
//List<string> lexAbsPaths = new List<string>(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);
if (string.IsNullOrEmpty(language))
{
// No language selected. Disable the speller and return.
DisableSpelling();
}
else
{
SetSpellingOptions(
language,
SpellingSettings.EnableAutoCorrect);
}
}
void BlogPostHtmlEditor_FixCommandEvent(bool fullyEditableActive)

View File

@ -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
/// <param name="forceSpellingScan"></param>
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();
}
/// <summary>
@ -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)

View File

@ -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();
}
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;
}

View File

@ -7,8 +7,10 @@ using System.Drawing;
using System.Globalization;
using System.IO;
using mshtml;
using OpenLiveWriter.Controls;
using OpenLiveWriter.CoreServices;
using OpenLiveWriter.Extensibility.ImageEditing;
using OpenLiveWriter.Localization;
using OpenLiveWriter.PostEditor.PostHtmlEditing.ImageEditing.Decorators;
namespace OpenLiveWriter.PostEditor.PostHtmlEditing
@ -93,8 +95,15 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing
imgHtmlElement.setAttribute("height", oldHeight, 0);
if (!String.IsNullOrEmpty(oldWidth))
imgHtmlElement.setAttribute("width", oldWidth, 0);
info = new ImagePropertiesInfo(new Uri(imgSrc), new Size(width, height), remoteImageDecoratorsList);
Uri infoUri;
if (Uri.TryCreate(imgSrc, UriKind.Absolute, out infoUri))
{
info = new ImagePropertiesInfo(infoUri, new Size(width, height), remoteImageDecoratorsList);
}
else
{
info = new ImagePropertiesInfo(new Uri("http://www.example.com"), new Size(width, height), remoteImageDecoratorsList);
}
info.ImgElement = imgHtmlElement;
// Sets the correct inline image size and image size name for the remote image.

View File

@ -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,14 +150,10 @@ 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
type = typeof(GlossaryPreferencesPanel);

View File

@ -24,8 +24,6 @@ using OpenLiveWriter.PostEditor.Commands;
namespace OpenLiveWriter.PostEditor
{
public delegate string SpellingContextDirectorySource();
public delegate void TextEditingFocusHandler();
public class TextEditingCommandDispatcher : IDisposable
{
@ -460,11 +458,10 @@ namespace OpenLiveWriter.PostEditor
private readonly CommandManager CommandManager;
public TextEditingCommandDispatcher(IWin32Window owner, SpellingContextDirectorySource spellingContextDirSource, IHtmlStylePicker stylePicker, CommandManager commandManager)
public TextEditingCommandDispatcher(IWin32Window owner, IHtmlStylePicker stylePicker, CommandManager commandManager)
{
CommandManager = commandManager;
_owner = owner;
_spellingContextDirSource = spellingContextDirSource;
_stylePicker = stylePicker;
InitializeCommands();
}
@ -597,7 +594,7 @@ namespace OpenLiveWriter.PostEditor
InitializeCommand(new RTLTextBlockCommand());
InitializeCommand(new InsertLinkCommand());
InitializeCommand(new FindCommand());
InitializeCommand(new CheckSpellingCommand(_spellingContextDirSource));
InitializeCommand(new CheckSpellingCommand());
InitializeCommand(new EditLinkCommand());
InitializeCommand(new RemoveLinkCommand());
InitializeCommand(new RemoveLinkAndClearFormattingCommand());
@ -1552,10 +1549,6 @@ namespace OpenLiveWriter.PostEditor
private class CheckSpellingCommand : TextEditingCommand
{
private bool _isExecuting;
public CheckSpellingCommand(SpellingContextDirectorySource spellingContextDirSource)
{
_spellingContextDirSource = spellingContextDirSource;
}
public override CommandId CommandId { get { return CommandId.CheckSpelling; } }
@ -1575,7 +1568,7 @@ namespace OpenLiveWriter.PostEditor
string doNotShow = args.GetString("OLECMDEXECOPT_DONTPROMPTUSER");
bool showFinishedUI = !StringHelper.ToBool(doNotShow, false);
if (!PostEditor.CheckSpelling(_spellingContextDirSource()))
if (!PostEditor.CheckSpelling())
{
args.Cancelled = true;
return;
@ -1603,8 +1596,6 @@ namespace OpenLiveWriter.PostEditor
{
return new DontPromptUserCommand(CommandId.CheckSpelling);
}
private SpellingContextDirectorySource _spellingContextDirSource;
}
internal class DontPromptUserCommand : Command
@ -1640,7 +1631,6 @@ namespace OpenLiveWriter.PostEditor
}
private IWin32Window _owner;
private SpellingContextDirectorySource _spellingContextDirSource;
private IHtmlStylePicker _stylePicker;
private IHtmlEditorCommandSource _postEditor;
private TextEditingFocusHandler _focusCallback;

View File

@ -11,7 +11,6 @@ namespace OpenLiveWriter.SpellChecker
public interface IBlogPostSpellCheckingContext
{
bool CanSpellCheck { get; }
string PostSpellingContextDirectory { get; }
ISpellingChecker SpellingChecker { get; }
string AutoCorrectLexiconFilePath { get; }
event EventHandler SpellingOptionsChanged;

View File

@ -16,10 +16,7 @@ namespace OpenLiveWriter.SpellChecker
/// and that we would like the user's Ignore All and Replace All commands
/// to be persisted in a context-bound dictionary
/// </summary>
/// <param name="contextDictionaryLocation">directory where the
/// spell checker can write a context-bound dictionary (null to not
/// use a context-dictionary)</param>
void StartChecking( string contextDictionaryLocation ) ;
void StartChecking() ;
/// <summary>
/// Notify the spell checker that we have stopped checking the document
@ -69,57 +66,8 @@ namespace OpenLiveWriter.SpellChecker
/// <param name="word">word to replace</param>
/// <param name="replaceWith">replacement word</param>
void ReplaceAll( string word, string replaceWith ) ;
void Reset();
}
/// <summary>
/// Languages supported by the spelling checker
/// </summary>
public enum SpellingCheckerLanguage
{
None,
EnglishUS,
EnglishUK,
EnglishCanada,
EnglishAustralia,
Spanish,
German,
GermanReform,
French,
Korean,
Italian,
Dutch,
PortugueseBrazil,
Turkish,
Arabic,
Bulgarian,
Catalan,
Czech,
Greek,
Estonian,
Basque,
Finnish,
Hebrew,
Croatian,
Hungarian,
Indonesian,
Lithuanian,
Latvian,
Malay,
Polish,
Portuguese,
Romanian,
Russian,
Slovak,
Slovenian,
SerbianLatin,
SerbianCyrillic,
Swedish,
Ukrainian,
}
/// <summary>
/// Possible result codes from check-word call
/// </summary>

View File

@ -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();
}
}

View File

@ -8,6 +8,10 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="PlatformSpellCheck, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\PlatformSpellCheck.1.0.0\lib\net45\PlatformSpellCheck.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
@ -60,26 +64,20 @@
<Compile Include="HighlightSegmentTracker.cs" />
<Compile Include="HtmlTextBoxWordRange.cs" />
<Compile Include="IBlogPostSpellCheckingContext.cs" />
<Compile Include="NlgSpellerException.cs" />
<Compile Include="SortedMarkupRangeList.cs" />
<Compile Include="ISpellingChecker.cs" />
<Compile Include="IWordRange.cs" />
<Compile Include="IWordRangeProvider.cs" />
<Compile Include="MisspelledWordInfo.cs" />
<Compile Include="MshtmlWordRange.cs" />
<Compile Include="NlgSpellingChecker.cs" />
<Compile Include="NlgSpeller.cs" />
<Compile Include="NLG\ProofBase.cs" />
<Compile Include="NLG\SpellApiEx.cs" />
<Compile Include="SentrySpellingChecker.cs" />
<Compile Include="SpellCheckerForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SpellCheckingContextMenuDefinition.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="SpellingConfigReader.cs" />
<Compile Include="SpellingHighlighter.cs" />
<Compile Include="SpellingLanguageEntry.cs" />
<Compile Include="SpellingManager.cs" />
<Compile Include="SpellingPreferences.cs" />
<Compile Include="SpellingPreferencesPanel.cs">
@ -89,8 +87,8 @@
<Compile Include="SpellingTimer.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="SSCE.cs" />
<Compile Include="TextBoxWordRange.cs" />
<Compile Include="WinSpellingChecker.cs" />
<EmbeddedResource Include="Images\SpellingDictionaries.png" />
<EmbeddedResource Include="Images\SpellingGeneral.png" />
<EmbeddedResource Include="Images\SpellingPanelBitmap.png" />
@ -99,26 +97,14 @@
<DependentUpon>SpellCheckerForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="SpellingConfig.xml" />
<EmbeddedResource Include="SpellingPreferencesPanel.resx">
<DependentUpon>SpellingPreferencesPanel.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<!-- COPY READ-ONLY REDISTRIBUTABLE DICTIONARIES TO OUTPUT DIRECTORY (ALLOWS THEIR USE
IN DEVELOPMENT CONFIGURATIONS) -->
<RobocopyCompiled Include="$(ProjectDir)Redistribute\Dictionaries\">
<DestinationFolder>$(FullTargetProjectPath)\Dictionaries</DestinationFolder>
</RobocopyCompiled>
<RobocopyCompiled Include="$(ProjectDir)\Dictionaries\">
<DestinationFolder>$(FullTargetProjectPath)\Dictionaries</DestinationFolder>
</RobocopyCompiled>
<!-- COPY REDISTRIBUTABLE SPELLING ENGINE DLL TO SYSTEM DIRECTORY -->
<RobocopyCompiled Include="$(ProjectDir)Redistribute\ssceonf1.dll">
<DestinationFolder>$(FullTargetProjectPath)</DestinationFolder>
</RobocopyCompiled>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(RepoRoot)\writer.build.targets" />
</Project>
</Project>

View File

@ -93,22 +93,11 @@ namespace OpenLiveWriter.SpellChecker
this.owner = owner;
}
/// <summary>
/// Check spelling
/// </summary>
public void CheckSpelling(IWordRange range)
{
CheckSpelling(range, null);
}
/// <summary>
/// Check spelling
/// </summary>
/// <param name="range">word range to check</param>
/// <param name="contextDictionaryLocation">directory where the
/// spell checker can write a context-bound dictionary (null to not
/// use a context-dictionary)</param>
public void CheckSpelling(IWordRange range, string contextDictionaryLocation)
public void CheckSpelling(IWordRange range)
{
// save reference to word-range
wordRange = range;
@ -298,7 +287,6 @@ namespace OpenLiveWriter.SpellChecker
{
// remove feedback from the document
RemoveHighlight();
spellingChecker.Reset();
}
/// <summary>

View File

@ -1,51 +0,0 @@
// 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;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Xml;
using OpenLiveWriter.CoreServices.ResourceDownloading;
using OpenLiveWriter.Localization;
namespace OpenLiveWriter.SpellChecker
{
internal class SpellingConfigReader
{
private static readonly SpellingLanguageEntry[] languages;
private static readonly SpellingCheckerLanguage defaultLanguage;
public static SpellingLanguageEntry[] Languages
{
get { return languages; }
}
public static SpellingCheckerLanguage DefaultLanguage
{
get { return defaultLanguage; }
}
static SpellingConfigReader()
{
// TODO:OLW
if (languages == null)
{
languages = new SpellingLanguageEntry[]
{
CreateNullDictionaryLanguage()
};
}
defaultLanguage = SpellingCheckerLanguage.None;
}
private static SpellingLanguageEntry CreateNullDictionaryLanguage()
{
return new SpellingLanguageEntry(SpellingCheckerLanguage.None, 0xFFFF, null, new string[0], "", Res.Get(StringId.DictionaryLanguageNone));
}
}
}

View File

@ -0,0 +1,22 @@
// 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 string BCP47Code;
public readonly string DisplayName;
public SpellingLanguageEntry(string bcp47Code, string displayName)
{
this.BCP47Code = bcp47Code;
this.DisplayName = displayName;
}
public override string ToString()
{
return this.DisplayName;
}
}
}

View File

@ -64,7 +64,7 @@ namespace OpenLiveWriter.SpellChecker
_mshtmlControl.MarkupServicesRaw,
(IHTMLDocument4)_htmlDocument);
//start new highlighter
_spellingChecker.StartChecking(_spellingContext.PostSpellingContextDirectory);
_spellingChecker.StartChecking();
_spellingChecker.WordIgnored += new EventHandler(_spellingChecker_WordIgnored);
_spellingChecker.WordAdded += new EventHandler(_spellingChecker_WordAdded);
@ -273,7 +273,7 @@ namespace OpenLiveWriter.SpellChecker
spellCheckerForm.WordIgnored += (sender2, args) => IgnoreOnce(wordRange.CurrentWordRange);
// check spelling
spellCheckerForm.CheckSpelling(wordRange, _spellingContext.PostSpellingContextDirectory);
spellCheckerForm.CheckSpelling(wordRange);
_mshtmlControl.MarkupServices.EndUndoUnit();
// restore focus to the control that had it before we spell-checked

View File

@ -43,36 +43,16 @@ namespace OpenLiveWriter.SpellChecker
set { realTimeSpellChecking = value; Modified(); }
}
private bool realTimeSpellChecking;
/// <summary>
/// Ignore words in upper-case
/// </summary>
public bool IgnoreUppercase
{
get { return ignoreUppercase; }
set { ignoreUppercase = value; Modified(); }
}
private bool ignoreUppercase;
/// <summary>
/// Ignore words with numbers
/// </summary>
public bool IgnoreWordsWithNumbers
{
get { return ignoreWordsWithNumbers; }
set { ignoreWordsWithNumbers = value; Modified(); }
}
private bool ignoreWordsWithNumbers;
/// <summary>
/// Main language for spell checking
/// </summary>
public SpellingCheckerLanguage Language
public string Language
{
get { return language; }
set { language = value; Modified(); }
}
private SpellingCheckerLanguage language;
private string language;
/// <summary>
/// Enables/Disables AutoCorrect
@ -89,8 +69,6 @@ namespace OpenLiveWriter.SpellChecker
/// </summary>
protected override void LoadPreferences()
{
ignoreUppercase = SpellingSettings.IgnoreUppercase;
ignoreWordsWithNumbers = SpellingSettings.IgnoreWordsWithNumbers;
realTimeSpellChecking = SpellingSettings.RealTimeSpellChecking;
checkSpellingBeforePublish = SpellingSettings.CheckSpellingBeforePublish;
enableAutoCorrect = SpellingSettings.EnableAutoCorrect;
@ -102,8 +80,6 @@ namespace OpenLiveWriter.SpellChecker
/// </summary>
protected override void SavePreferences()
{
SpellingSettings.IgnoreUppercase = ignoreUppercase;
SpellingSettings.IgnoreWordsWithNumbers = ignoreWordsWithNumbers;
SpellingSettings.RealTimeSpellChecking = realTimeSpellChecking;
SpellingSettings.CheckSpellingBeforePublish = checkSpellingBeforePublish;
SpellingSettings.EnableAutoCorrect = enableAutoCorrect;

View File

@ -20,12 +20,7 @@ namespace OpenLiveWriter.SpellChecker
/// </summary>
public class SpellingPreferencesPanel : PreferencesPanel
{
//private GroupBox groupBoxInternationalDictionaries;
private GroupBox _groupBoxGeneralOptions;
private CheckBox _checkBoxIgnoreUppercase;
private CheckBox _checkBoxIgnoreNumbers;
//private PictureBox pictureBoxInternationalDictionaries;
//private Label labelDictionary;
/// <summary>
/// Required designer variable.
/// </summary>
@ -51,8 +46,6 @@ namespace OpenLiveWriter.SpellChecker
_labelDictionaryLanguage.Text = Res.Get(StringId.DictionaryLanguageLabel);
_groupBoxGeneralOptions.Text = Res.Get(StringId.SpellingPrefOptions);
_checkBoxRealTimeChecking.Text = Res.Get(StringId.SpellingPrefReal);
_checkBoxIgnoreNumbers.Text = Res.Get(StringId.SpellingPrefNum);
_checkBoxIgnoreUppercase.Text = Res.Get(StringId.SpellingPrefUpper);
_checkBoxCheckBeforePublish.Text = Res.Get(StringId.SpellingPrefPub);
_checkBoxAutoCorrect.Text = Res.Get(StringId.SpellingPrefAuto);
PanelName = Res.Get(StringId.SpellingPrefName);
@ -65,8 +58,6 @@ namespace OpenLiveWriter.SpellChecker
spellingPreferences.PreferencesModified += new EventHandler(spellingPreferences_PreferencesModified);
// core options
_checkBoxIgnoreUppercase.Checked = spellingPreferences.IgnoreUppercase;
_checkBoxIgnoreNumbers.Checked = spellingPreferences.IgnoreWordsWithNumbers;
_checkBoxCheckBeforePublish.Checked = spellingPreferences.CheckSpellingBeforePublish;
_checkBoxRealTimeChecking.Checked = spellingPreferences.RealTimeSpellChecking;
_checkBoxAutoCorrect.Checked = spellingPreferences.EnableAutoCorrect;
@ -74,29 +65,33 @@ namespace OpenLiveWriter.SpellChecker
// initialize language combo
_comboBoxLanguage.BeginUpdate();
_comboBoxLanguage.Items.Clear();
SpellingCheckerLanguage currentLanguage = spellingPreferences.Language;
string currentLanguage = spellingPreferences.Language;
SpellingLanguageEntry[] languages = SpellingSettings.GetInstalledLanguages();
Array.Sort(languages, new SentryLanguageEntryComparer(CultureInfo.CurrentUICulture));
_comboBoxLanguage.Items.Add(new SpellingLanguageEntry(string.Empty, Res.Get(StringId.DictionaryLanguageNone)));
foreach (SpellingLanguageEntry language in languages)
{
int index = _comboBoxLanguage.Items.Add(language);
if (language.Language == currentLanguage)
if (language.BCP47Code == currentLanguage)
_comboBoxLanguage.SelectedIndex = index;
}
// defend against invalid value
if (_comboBoxLanguage.SelectedIndex == -1)
{
Debug.Fail("Language in registry not supported!");
if (!string.IsNullOrEmpty(currentLanguage))
{
Debug.Fail("Language in registry not supported!");
}
_comboBoxLanguage.SelectedIndex = 0; // "None"
}
_comboBoxLanguage.EndUpdate();
ManageSpellingOptions();
// hookup to changed events to update preferences
_checkBoxIgnoreUppercase.CheckedChanged += new EventHandler(checkBoxIgnoreUppercase_CheckedChanged);
_checkBoxIgnoreNumbers.CheckedChanged += new EventHandler(checkBoxIgnoreNumbers_CheckedChanged);
_checkBoxCheckBeforePublish.CheckedChanged += new EventHandler(checkBoxCheckBeforePublish_CheckedChanged);
_checkBoxRealTimeChecking.CheckedChanged += new EventHandler(checkBoxRealTimeChecking_CheckedChanged);
_checkBoxAutoCorrect.CheckedChanged += new EventHandler(checkBoxAutoCorrect_CheckedChanged);
@ -108,8 +103,6 @@ namespace OpenLiveWriter.SpellChecker
private void ManageSpellingOptions()
{
bool enabled = _comboBoxLanguage.SelectedIndex != 0; // "None"
_checkBoxIgnoreUppercase.Enabled = enabled;
_checkBoxIgnoreNumbers.Enabled = enabled;
_checkBoxCheckBeforePublish.Enabled = enabled;
_checkBoxRealTimeChecking.Enabled = enabled;
_checkBoxAutoCorrect.Enabled = enabled;
@ -193,8 +186,6 @@ namespace OpenLiveWriter.SpellChecker
this._comboBoxLanguage = new System.Windows.Forms.ComboBox();
this._labelDictionaryLanguage = new System.Windows.Forms.Label();
this._checkBoxRealTimeChecking = new System.Windows.Forms.CheckBox();
this._checkBoxIgnoreNumbers = new System.Windows.Forms.CheckBox();
this._checkBoxIgnoreUppercase = new System.Windows.Forms.CheckBox();
this._checkBoxCheckBeforePublish = new System.Windows.Forms.CheckBox();
this._checkBoxAutoCorrect = new System.Windows.Forms.CheckBox();
this._groupBoxGeneralOptions.SuspendLayout();
@ -207,8 +198,6 @@ namespace OpenLiveWriter.SpellChecker
this._groupBoxGeneralOptions.Controls.Add(this._comboBoxLanguage);
this._groupBoxGeneralOptions.Controls.Add(this._labelDictionaryLanguage);
this._groupBoxGeneralOptions.Controls.Add(this._checkBoxRealTimeChecking);
this._groupBoxGeneralOptions.Controls.Add(this._checkBoxIgnoreNumbers);
this._groupBoxGeneralOptions.Controls.Add(this._checkBoxIgnoreUppercase);
this._groupBoxGeneralOptions.Controls.Add(this._checkBoxCheckBeforePublish);
this._groupBoxGeneralOptions.Controls.Add(this._checkBoxAutoCorrect);
this._groupBoxGeneralOptions.FlatStyle = System.Windows.Forms.FlatStyle.System;
@ -248,28 +237,10 @@ namespace OpenLiveWriter.SpellChecker
this._checkBoxRealTimeChecking.TabIndex = 2;
this._checkBoxRealTimeChecking.Text = "Use &real time spell checking (squiggles)";
//
// _checkBoxIgnoreNumbers
//
this._checkBoxIgnoreNumbers.FlatStyle = System.Windows.Forms.FlatStyle.System;
this._checkBoxIgnoreNumbers.Location = new System.Drawing.Point(16, 111);
this._checkBoxIgnoreNumbers.Name = "_checkBoxIgnoreNumbers";
this._checkBoxIgnoreNumbers.Size = new System.Drawing.Size(323, 18);
this._checkBoxIgnoreNumbers.TabIndex = 4;
this._checkBoxIgnoreNumbers.Text = "Ignore words with &numbers";
//
// _checkBoxIgnoreUppercase
//
this._checkBoxIgnoreUppercase.FlatStyle = System.Windows.Forms.FlatStyle.System;
this._checkBoxIgnoreUppercase.Location = new System.Drawing.Point(16, 88);
this._checkBoxIgnoreUppercase.Name = "_checkBoxIgnoreUppercase";
this._checkBoxIgnoreUppercase.Size = new System.Drawing.Size(323, 18);
this._checkBoxIgnoreUppercase.TabIndex = 3;
this._checkBoxIgnoreUppercase.Text = "Ignore words in &UPPERCASE";
//
// _checkBoxCheckBeforePublish
//
this._checkBoxCheckBeforePublish.FlatStyle = System.Windows.Forms.FlatStyle.System;
this._checkBoxCheckBeforePublish.Location = new System.Drawing.Point(16, 134);
this._checkBoxCheckBeforePublish.Location = new System.Drawing.Point(16, 88);
this._checkBoxCheckBeforePublish.Name = "_checkBoxCheckBeforePublish";
this._checkBoxCheckBeforePublish.Size = new System.Drawing.Size(323, 18);
this._checkBoxCheckBeforePublish.TabIndex = 5;
@ -278,7 +249,7 @@ namespace OpenLiveWriter.SpellChecker
// _checkBoxAutoCorrect
//
this._checkBoxAutoCorrect.FlatStyle = System.Windows.Forms.FlatStyle.System;
this._checkBoxAutoCorrect.Location = new System.Drawing.Point(16, 157);
this._checkBoxAutoCorrect.Location = new System.Drawing.Point(16, 111);
this._checkBoxAutoCorrect.Name = "_checkBoxAutoCorrect";
this._checkBoxAutoCorrect.Size = new System.Drawing.Size(323, 18);
this._checkBoxAutoCorrect.TabIndex = 6;
@ -298,16 +269,6 @@ namespace OpenLiveWriter.SpellChecker
}
#endregion
private void checkBoxIgnoreUppercase_CheckedChanged(object sender, EventArgs e)
{
spellingPreferences.IgnoreUppercase = _checkBoxIgnoreUppercase.Checked;
}
private void checkBoxIgnoreNumbers_CheckedChanged(object sender, EventArgs e)
{
spellingPreferences.IgnoreWordsWithNumbers = _checkBoxIgnoreNumbers.Checked;
}
private void checkBoxCheckBeforePublish_CheckedChanged(object sender, EventArgs e)
{
spellingPreferences.CheckSpellingBeforePublish = _checkBoxCheckBeforePublish.Checked;
@ -325,7 +286,7 @@ namespace OpenLiveWriter.SpellChecker
private void comboBoxLanguage_SelectedIndexChanged(object sender, EventArgs e)
{
spellingPreferences.Language = (_comboBoxLanguage.SelectedItem as SpellingLanguageEntry).Language;
spellingPreferences.Language = (_comboBoxLanguage.SelectedItem as SpellingLanguageEntry).BCP47Code;
ManageSpellingOptions();
}
}

View File

@ -112,9 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -10,6 +10,7 @@ using OpenLiveWriter.CoreServices;
using OpenLiveWriter.CoreServices.Diagnostics;
using OpenLiveWriter.CoreServices.Settings;
using OpenLiveWriter.Localization;
using System.Collections.Generic;
/*
TODO:
@ -25,41 +26,6 @@ namespace OpenLiveWriter.SpellChecker
/// </summary>
public class SpellingSettings
{
[Obsolete]
public static bool CanSpellCheck
{
get
{
return Language != SpellingCheckerLanguage.None;
}
}
/// <summary>
/// Path to dictionary files
/// </summary>
public static string DictionaryPath
{
get
{
return Path.Combine(ApplicationEnvironment.InstallationDirectory, "Dictionaries");
}
}
public static string UserDictionaryPath
{
get
{
// In the past this property returned the DIRECTORY
// where the user dictionary file should go. Now it returns the path to
// the FILE itself.
string userDictionaryPath = Path.Combine(ApplicationEnvironment.ApplicationDataDirectory, "Dictionaries");
if (!Directory.Exists(userDictionaryPath))
Directory.CreateDirectory(userDictionaryPath);
return Path.Combine(userDictionaryPath, "User.dic");
}
}
public static event EventHandler SpellingSettingsChanged;
public static void FireChangedEvent()
@ -82,58 +48,34 @@ namespace OpenLiveWriter.SpellChecker
// This is GetBoolean rather than just "return RealTimeSpellCheckingDefault"
// to ensure that the default gets written to the registry.
return SpellingKey.GetBoolean(REAL_TIME_SPELL_CHECKING, RealTimeSpellCheckingDefault);
return SpellingKey.GetBoolean(REAL_TIME_SPELL_CHECKING, true);
}
set { SpellingKey.SetBoolean(REAL_TIME_SPELL_CHECKING, value); }
}
private const string REAL_TIME_SPELL_CHECKING = "RealTimeSpellChecking";
private static bool RealTimeSpellCheckingDefault
{
get
{
try
{
string lang = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
foreach (SpellingLanguageEntry sentryLang in GetInstalledLanguages())
if (sentryLang.TwoLetterIsoLanguageName == lang)
return true;
return false;
}
catch (Exception e)
{
Trace.WriteLine(e.ToString());
return false;
}
}
}
/// <summary>
/// Languages supported by the sentry spelling checker
/// </summary>
public static SpellingLanguageEntry[] GetInstalledLanguages()
{
string lexiconPath = DictionaryPath;
ArrayList list = new ArrayList();
foreach (SpellingLanguageEntry entry in SpellingConfigReader.Languages)
List<SpellingLanguageEntry> list = new List<SpellingLanguageEntry>();
foreach (string entry in WinSpellingChecker.GetInstalledLanguages())
{
if (entry.Language == SpellingCheckerLanguage.None
|| entry.IsInstalled(lexiconPath))
try
{
list.Add(entry);
CultureInfo entryCulture = CultureInfo.GetCultureInfo(entry);
list.Add(new SpellingLanguageEntry(entry, entryCulture.DisplayName));
}
catch
{
list.Add(new SpellingLanguageEntry(entry, entry));
}
}
return (SpellingLanguageEntry[])list.ToArray(typeof(SpellingLanguageEntry));
}
public static SpellingLanguageEntry GetInstalledLanguage(SpellingCheckerLanguage language)
{
foreach (SpellingLanguageEntry entry in GetInstalledLanguages())
{
if (entry.Language == language)
return entry;
}
return null;
return list.ToArray();
}
/// <summary>
@ -183,7 +125,7 @@ namespace OpenLiveWriter.SpellChecker
/// <summary>
/// Main language for spell checking
/// </summary>
public static SpellingCheckerLanguage Language
public static string Language
{
get
{
@ -191,11 +133,13 @@ namespace OpenLiveWriter.SpellChecker
// If so, use it. If not, check if the default language has dictionaries
// installed. If so, use it. If not, use the English-US.
SpellingCheckerLanguage defaultLanguage = SpellingConfigReader.DefaultLanguage;
SpellingCheckerLanguage preferredLanguage;
// CurrentUICulture is currently forced into en-US which is unlikely to be the preferred dictionary
// CurrentCulture is not modified so is more likely to be correct
string defaultLanguage = CultureInfo.CurrentCulture.Name;
string preferredLanguage;
try
{
preferredLanguage = (SpellingCheckerLanguage)SpellingKey.GetEnumValue(LANGUAGE, typeof(SpellingCheckerLanguage), defaultLanguage);
preferredLanguage = SpellingKey.GetString(LANGUAGE, defaultLanguage);
}
catch (Exception e)
{
@ -203,32 +147,34 @@ namespace OpenLiveWriter.SpellChecker
preferredLanguage = defaultLanguage;
}
if (preferredLanguage == SpellingCheckerLanguage.None)
return SpellingCheckerLanguage.None;
if (string.IsNullOrEmpty(preferredLanguage))
return string.Empty;
foreach (SpellingLanguageEntry lang in GetInstalledLanguages())
if (WinSpellingChecker.IsLanguageSupported(preferredLanguage))
{
if (lang.Language == preferredLanguage)
return preferredLanguage;
return preferredLanguage;
}
// Language in registry is not installed!
Trace.WriteLine("Dictionary language specified in registry is not installed. Using fallback");
foreach (SpellingLanguageEntry lang in GetInstalledLanguages())
{
if (lang.Language == defaultLanguage)
{
Language = defaultLanguage;
return defaultLanguage;
}
if (WinSpellingChecker.IsLanguageSupported(defaultLanguage))
{
Language = defaultLanguage;
return defaultLanguage;
}
return Language = SpellingCheckerLanguage.EnglishUS;
if (WinSpellingChecker.IsLanguageSupported("en-US"))
{
Language = "en-US";
return "en-US";
}
return string.Empty;
}
set { SpellingKey.SetString(LANGUAGE, value.ToString()); }
set { SpellingKey.SetString(LANGUAGE, value); }
}
private const string LANGUAGE = "DictionaryLanguage";
private const string LANGUAGE = "SpellingLanguage";
internal static SettingsPersisterHelper SettingsKey = ApplicationEnvironment.PreferencesSettingsRoot.GetSubSettings("PostEditor");
public static SettingsPersisterHelper SpellingKey = SettingsKey.GetSubSettings("Spelling");

View File

@ -0,0 +1,167 @@
// 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;
using System.Linq;
namespace OpenLiveWriter.SpellChecker
{
public class WinSpellingChecker : ISpellingChecker, IDisposable
{
private PlatformSpellCheck.SpellChecker _speller;
private string _bcp47Code;
public bool IsInitialized
{
get
{
return _speller != null;
}
}
public event EventHandler WordAdded;
public event EventHandler WordIgnored;
public void AddToUserDictionary(string word)
{
CheckInitialized();
_speller.Add(word);
if (WordAdded == null)
return;
WordAdded(word, EventArgs.Empty);
}
public SpellCheckResult CheckWord(string word, out string otherWord, out int offset, out int length)
{
CheckInitialized();
otherWord = null;
if (string.IsNullOrEmpty(word))
{
offset = 0;
length = 0;
return SpellCheckResult.Correct;
}
PlatformSpellCheck.SpellingError spellerStatus = _speller.Check(word).FirstOrDefault();
if (spellerStatus == null)
{
offset = 0;
length = word.Length;
return SpellCheckResult.Correct;
}
else
{
offset = (int)spellerStatus.StartIndex;
length = (int)spellerStatus.Length;
switch (spellerStatus.RecommendedAction)
{
case PlatformSpellCheck.RecommendedAction.Delete:
otherWord = "";
return SpellCheckResult.AutoReplace;
case PlatformSpellCheck.RecommendedAction.Replace:
otherWord = spellerStatus.RecommendedReplacement;
return SpellCheckResult.AutoReplace;
case PlatformSpellCheck.RecommendedAction.GetSuggestions:
return SpellCheckResult.Misspelled;
default:
return SpellCheckResult.Correct;
}
}
}
public void Dispose()
{
StopChecking();
}
public void IgnoreAll(string word)
{
CheckInitialized();
_speller.Ignore(word);
if (WordIgnored == null)
return;
WordIgnored(word, EventArgs.Empty);
}
public void ReplaceAll(string word, string replaceWith)
{
CheckInitialized();
_speller.AutoCorrect(word, replaceWith);
}
public void StartChecking()
{
if (!PlatformSpellCheck.SpellChecker.IsPlatformSupported() ||
string.IsNullOrEmpty(_bcp47Code))
{
StopChecking();
return;
}
_speller = new PlatformSpellCheck.SpellChecker(_bcp47Code);
}
public void StopChecking()
{
if (_speller != null)
_speller.Dispose();
_speller = null;
}
public SpellingSuggestion[] Suggest(string word, short maxSuggestions, short depth)
{
CheckInitialized();
List<SpellingSuggestion> list = new List<SpellingSuggestion>();
foreach (string suggestion in _speller.Suggestions(word).Take(maxSuggestions))
{
list.Add(new SpellingSuggestion(suggestion, 1));
}
return list.ToArray();
}
public void SetOptions(string bcp47Code)
{
_bcp47Code = bcp47Code;
}
public static string[] GetInstalledLanguages()
{
if (PlatformSpellCheck.SpellChecker.IsPlatformSupported())
{
return PlatformSpellCheck.SpellChecker.SupportedLanguages.ToArray();
}
return new string[0];
}
public static bool IsLanguageSupported(string bcp47Code)
{
if (string.IsNullOrEmpty(bcp47Code))
{
return false;
}
if (PlatformSpellCheck.SpellChecker.IsPlatformSupported())
{
return PlatformSpellCheck.SpellChecker.IsLanguageSupported(bcp47Code);
}
return false;
}
private void CheckInitialized()
{
if (!IsInitialized)
throw new InvalidOperationException("Operation attempted on an uninitialized WinSpellingChecker");
}
}
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="PlatformSpellCheck" version="1.0.0" targetFramework="net452" />
</packages>

View File

@ -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