Index: xword/XWord/AddinActions.cs =================================================================== --- xword/XWord/AddinActions.cs (revision 18464) +++ xword/XWord/AddinActions.cs (working copy) @@ -354,7 +354,10 @@ { MessageBox.Show("You are not currently editing a wiki page", "XWord", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; - } + } + bool continueWithSaving = ShowSwitchSyntaxDialog(); + if (!continueWithSaving) + return; LoadingDialog loadingDialog = new LoadingDialog("Saving to wiki..."); ThreadPool.QueueUserWorkItem(new WaitCallback(loadingDialog.ShowSyncDialog)); SaveToXwiki(); @@ -362,6 +365,43 @@ } /// + /// If current syntax is XWiki 2.0 and the page contains table(s), promt the user + /// to switch to XHTML syntax with an Yes/No/Cancel message box. + /// + /// Cleaned HTML source code. + /// FALSE if the user presses 'Cancel', meaning the saving should not continue. TRUE in other cases. + private bool ShowSwitchSyntaxDialog() + { + if (addin.AddinStatus.Syntax == null) + { + addin.AddinStatus.Syntax = addin.DefaultSyntax; + } + if ((addin.ActiveDocumentInstance.Tables.Count>0) && + (addin.AddinStatus.Syntax.ToLower().IndexOf("xhtml") < 0)) + { + DialogResult dr; + string infoMessage, caption; + infoMessage = "This page contains elements that can not properly be saved inXWiki 2.0 syntax."; + infoMessage += Environment.NewLine; + infoMessage += "Would you like to switch to XHTML syntax?"; + caption = "Feature Not Yet Implemented"; + + dr = System.Windows.Forms.MessageBox.Show(infoMessage, caption, MessageBoxButtons.YesNoCancel, + MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); + + if (dr == DialogResult.Yes) + { + addin.AddinStatus.Syntax = "XHTML"; + Globals.Ribbons.XWikiRibbon.SwitchSyntax("XHTML"); + } + if (dr == DialogResult.Cancel) + return false; + + } + return true; + } + + /// /// Saves the currently edited page or document to the server. /// private void SaveToXwiki() @@ -408,6 +448,8 @@ { addin.AddinStatus.Syntax = addin.DefaultSyntax; } + + //Convert the source to the propper encoding. Encoding iso = Encoding.GetEncoding("ISO-8859-1"); byte[] content = Encoding.Unicode.GetBytes(cleanHTML); Index: xword/XWord/XWikiRibbon.cs =================================================================== --- xword/XWord/XWikiRibbon.cs (revision 18464) +++ xword/XWord/XWikiRibbon.cs (working copy) @@ -53,7 +53,19 @@ selectionOptionsGroup.Visible = false; } } - + + /// + /// Changes the selected item from dropDownSyntax control with the one + /// that is labeled with toSyntax string. + /// + /// Existing item in dropDownSyntax to be selected. + public void SwitchSyntax(string toSyntax) + { + for (int i = 0; i < dropDownSyntax.Items.Count; i++) + if (dropDownSyntax.Items[i].Label == toSyntax) + dropDownSyntax.SelectedItem = dropDownSyntax.Items[i]; + } + private void SyncSaving_Click(object sender, RibbonControlEventArgs e) { if (syncSaving.Checked)