Index: xword/XWord/AddinActions.cs
===================================================================
--- xword/XWord/AddinActions.cs (revision 18392)
+++ xword/XWord/AddinActions.cs (working copy)
@@ -362,6 +362,39 @@
}
///
+ /// 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(string cleanHTML)
+ {
+ if ((cleanHTML.IndexOf("
0) &&
+ (addin.AddinStatus.Syntax.ToLower().IndexOf("xhtml") < 0))
+ {
+ DialogResult dr;
+ string infoMessage, caption;
+ infoMessage = "At this moment it's not possible to correctly save a page with tables using XWiki 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 +441,12 @@
{
addin.AddinStatus.Syntax = addin.DefaultSyntax;
}
+
+ bool continueWithSaving = ShowSwitchSyntaxDialog(cleanHTML);
+ if (!continueWithSaving)
+ return;
+
+
//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 18392)
+++ 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)