Index: xword/ContentFiltering/Office/Word/LocalToWebHTML.cs =================================================================== --- xword/ContentFiltering/Office/Word/LocalToWebHTML.cs (revision 20691) +++ xword/ContentFiltering/Office/Word/LocalToWebHTML.cs (working copy) @@ -49,6 +49,7 @@ content = content.Replace(" ", " "); xmlDoc.LoadXml(content); ClearStyles(ref xmlDoc); + RemoveGrammarAndSpellingErrorAttributes(ref xmlDoc); AdaptImages(ref xmlDoc); AdaptLists(ref xmlDoc); AdaptMacros(ref xmlDoc); @@ -59,6 +60,33 @@ } /// + /// Removes 'gramE' and 'spellE' span attributes from text marked as + /// containing grammar or spelling errors. + /// + /// A refrence to the xml document. + private void RemoveGrammarAndSpellingErrorAttributes(ref XmlDocument xmlDoc) + { + XmlNodeList nodes = xmlDoc.GetElementsByTagName("span"); + foreach (XmlNode node in nodes) + { + XmlAttribute classAttribute=node.Attributes["class"]; + if (classAttribute==null) + { + continue; + } + + if ( + classAttribute.Value.ToLower().Trim().IndexOf("grame")>=0 + || + classAttribute.Value.ToLower().Trim().IndexOf("spelle")>=0 + ) + { + node.Attributes.Remove(classAttribute); + } + } + } + + /// /// Deletes the style attributes from the Word generated content /// /// A refrence to the xml document. Index: xword/XWord/AddinActions.cs =================================================================== --- xword/XWord/AddinActions.cs (revision 20691) +++ xword/XWord/AddinActions.cs (working copy) @@ -44,6 +44,14 @@ String newPageText = "Hi! This is your new page. Please put your content here and then share it with others by saving it on the wiki."; + + Word.Options wordOptions; + bool checkGrammarAsYouType=false; + bool checkGrammarWithSpelling=false; + bool checkSpellingAsYouType=false; + bool contextualSpeller=false; + + /// /// Generic webclient used for conneting to xwiki. /// @@ -307,6 +315,41 @@ } /// + /// Save user settings for grammar and spelling checking. + /// + private void SaveGrammarAndSpellingSettings() + { + wordOptions = addin.Application.Options; + checkGrammarAsYouType = wordOptions.CheckGrammarAsYouType; + checkGrammarWithSpelling = wordOptions.CheckGrammarWithSpelling; + checkSpellingAsYouType = wordOptions.CheckSpellingAsYouType; + contextualSpeller = wordOptions.ContextualSpeller; + + } + + /// + /// Disable grammar and spelling checking. + /// + private void DisableGrammarAndSpellingChecking() + { + wordOptions.CheckGrammarAsYouType = false; + wordOptions.CheckGrammarWithSpelling = false; + wordOptions.CheckSpellingAsYouType = false; + wordOptions.ContextualSpeller = false; + } + + /// + /// Restore user settings for grammar and spelling checking. + /// + private void RestoreGrammarAndSpellingSettings() + { + wordOptions.CheckGrammarAsYouType = checkGrammarAsYouType; + wordOptions.CheckGrammarWithSpelling = checkGrammarWithSpelling; + wordOptions.CheckSpellingAsYouType = checkSpellingAsYouType; + wordOptions.ContextualSpeller = contextualSpeller; + } + + /// /// Saves the page to the wiki. Shows a message box with an error if the operation fails. /// /// The full name of the wiki page. @@ -314,29 +357,15 @@ /// The wiki syntax of the saved page. private void SavePage(String pageName, ref String pageContent, String syntax) { - //Save user settings for grammar and spelling checking - Word.Options wordOptions = addin.Application.Options; - bool checkGrammarAsYouType = wordOptions.CheckGrammarAsYouType; - bool checkGrammarWithSpelling = wordOptions.CheckGrammarWithSpelling; - bool checkSpellingAsYouType = wordOptions.CheckSpellingAsYouType; - bool contextualSpeller = wordOptions.ContextualSpeller; + SaveGrammarAndSpellingSettings(); + DisableGrammarAndSpellingChecking(); if (!this.Client.LoggedIn) { Client.Login(addin.username, addin.password); } - if (addin.ActiveDocumentContentRange.GrammaticalErrors.Count > 0 - || - addin.ActiveDocumentContentRange.SpellingErrors.Count > 0 - ) - { - //Disable grammar and spelling check - wordOptions.CheckGrammarAsYouType = false; - wordOptions.CheckGrammarWithSpelling = false; - wordOptions.CheckSpellingAsYouType = false; - wordOptions.ContextualSpeller = false; - } + if (!Client.SavePageHTML(pageName, pageContent, syntax)) { Log.Error("Failed to save page " + pageName + "on server " + addin.serverURL); @@ -365,13 +394,7 @@ } } - //Put back user setting for grammar and spelling checks - wordOptions.CheckGrammarAsYouType = checkGrammarAsYouType; - wordOptions.CheckGrammarWithSpelling = checkGrammarWithSpelling; - wordOptions.CheckSpellingAsYouType = checkSpellingAsYouType; - wordOptions.ContextualSpeller = contextualSpeller; - - + RestoreGrammarAndSpellingSettings(); } ///