Index: /FCKeditor/branches/developers/alfonsoml/_whatsnew.html
===================================================================
--- /FCKeditor/branches/developers/alfonsoml/_whatsnew.html	(revision 56)
+++ /FCKeditor/branches/developers/alfonsoml/_whatsnew.html	(revision 57)
@@ -52,20 +52,26 @@
 			the inner folder for each type (file, image, flash and media) are all lower-cased
 			too.</li>
-		<li>[<a target="_blank" href="https://sourceforge.net/tracker/index.php?func=detail&aid=1456343&group_id=75348&atid=543655">SF
+		<li>[<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1456343&group_id=75348&atid=543655">SF
 			PATCH-1456343</a>] New sample file showing how to dinamically exchange a textarea and an instance of FCKeditor. 
 			Thanks to Finn Hakansson</li>
-		<li>[<a target="_blank" href="https://sourceforge.net/tracker/index.php?func=detail&aid=1496115&group_id=75348&atid=543655">SF
-			PATCH-1496115</a>] [<a target="_blank" href="https://sourceforge.net/tracker/index.php?func=detail&aid=1588578&group_id=75348&atid=543653">SF
-			BUG-1588578</a>] [<a target="_blank" href="https://sourceforge.net/tracker/index.php?func=detail&aid=1376534&group_id=75348&atid=543653">SF
-			BUG-1376534</a>] [<a target="_blank" href="https://sourceforge.net/tracker/index.php?func=detail&aid=1343506&group_id=75348&atid=543653">SF
-			BUG-1343506</a>] [<a target="_blank" href="https://sourceforge.net/tracker/index.php?func=detail&aid=1211065&group_id=75348&atid=543656">SF
-			Feature-1211065</a>] [<a target="_blank" href="https://sourceforge.net/tracker/index.php?func=detail&aid=949144&group_id=75348&atid=543656">SF
+		<li>[<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1496115&group_id=75348&atid=543655">SF
+			PATCH-1496115</a>] [<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1588578&group_id=75348&atid=543653">SF
+			BUG-1588578</a>] [<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1376534&group_id=75348&atid=543653">SF
+			BUG-1376534</a>] [<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1343506&group_id=75348&atid=543653">SF
+			BUG-1343506</a>] [<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1211065&group_id=75348&atid=543656">SF
+			Feature-1211065</a>] [<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=949144&group_id=75348&atid=543656">SF
 			Feature-949144</a>] The content of anchors are shown and preserved on creation. * </li>
-		<li>[<a target="_blank" href="https://sourceforge.net/tracker/index.php?func=detail&aid=1587175&group_id=75348&atid=543656">SF
+		<li>[<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1587175&group_id=75348&atid=543656">SF
 			Feature-1587175</a>] Local links to an anchor are readjusted if the anchor changes.</li>
-		<li>[<a target="_blank" href="https://sourceforge.net/tracker/index.php?func=detail&aid=1500040&group_id=75348&atid=543655">SF
+		<li>[<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1500040&group_id=75348&atid=543655">SF
 			PATCH-1500040</a>] New configuration values to specify the Id and Class for the body element.</li>
-		<li>[<a target="_blank" href="https://sourceforge.net/tracker/index.php?func=detail&aid=1577202&group_id=75348&atid=543655">SF
+		<li>[<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1577202&group_id=75348&atid=543655">SF
 			PATCH-1577202</a>] The links created with the popup option now are accesible even if the user has javascript disabled.</li>
+		<li>[<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1443472&group_id=75348&atid=543655">SF
+			PATCH-1443472</a>] [<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1576488&group_id=75348&atid=543653">SF
+			BUG-1576488</a>] [<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1334305&group_id=75348&atid=543653">SF
+			BUG-1334305</a>] [<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1578312&group_id=75348&atid=543653">SF
+			BUG-1578312</a>] The Paste from Word clean up function can be configured with FCKConfig.CleanWordKeepStructure to preserve 
+			the markup as much as possible. Thanks Jean-Charles ROGEZ. </li>
 	</ul>
 
@@ -82,5 +88,6 @@
 			be used.</li>
 		<li>[<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&atid=543653&aid=1573714&group_id=75348">SF
-			BUG-1573714</a>] Paste was not working in IE if both AutoDetectPasteFromWord and
+			BUG-1573714</a>] [<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&atid=543653&aid=1593323&group_id=75348">SF
+			BUG-1593323</a>] Paste was not working in IE if both AutoDetectPasteFromWord and
 			ForcePasteAsPlainText settings were set to "false". </li>
 		<li>[<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&atid=543653&aid=1578306&group_id=75348">SF
@@ -101,5 +108,6 @@
 		<li>Depending on the implementation of toolbar combos (mainly for custom plugins) the
 			editor area was loosing the focus when clicking in the combo label. Fixed.</li>
-		<li>InsertHtml() was inserting the HTML outside the editor area on some very specific
+		<li>[<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1596937&group_id=75348&atid=543653">SF
+			BUG-1596937</a>] InsertHtml() was inserting the HTML outside the editor area on some very specific
 			cases.</li>
 		<li>[<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&atid=543653&aid=1585548&group_id=75348">SF
@@ -119,5 +127,6 @@
 			menus. Fixed.</li>
 		<li>[<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&atid=543653&aid=1526154&group_id=75348">SF
-			BUG-1526154</a>] With Firefox, &lt;style&gt; tags defined in the source are now
+			BUG-1526154</a>] [<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&aid=1509208&group_id=75348&atid=543653">SF
+			BUG-1509208</a>] With Firefox, &lt;style&gt; tags defined in the source are now
 			preserved.</li>
 		<li>[<a target="_blank" href="https://sourceforge.net/tracker/?func=detail&atid=543653&aid=1535946&group_id=75348">SF
Index: /FCKeditor/branches/developers/alfonsoml/editor/_source/internals/fckselection_ie.js
===================================================================
--- /FCKeditor/branches/developers/alfonsoml/editor/_source/internals/fckselection_ie.js	(revision 56)
+++ /FCKeditor/branches/developers/alfonsoml/editor/_source/internals/fckselection_ie.js	(revision 57)
@@ -99,4 +99,7 @@
 	var oNode ;
 
+	if ( !FCK.EditorDocument )
+		return null ;
+
 	if ( FCK.EditorDocument.selection.type == "Control" )
 	{
Index: /FCKeditor/branches/developers/alfonsoml/editor/_source/internals/fcktools.js
===================================================================
--- /FCKeditor/branches/developers/alfonsoml/editor/_source/internals/fcktools.js	(revision 56)
+++ /FCKeditor/branches/developers/alfonsoml/editor/_source/internals/fcktools.js	(revision 57)
@@ -200,2 +200,109 @@
 	return new fCloneCreator ;
 }
+
+// This function will be called from the PasteFromWord dialog (fck_paste.html)
+// Input: oNode a DOM node that contains the raw paste from the clipboard 
+// bIgnoreFont, bRemoveStyles booleans according to the values set in the dialog
+// Output: the cleaned string
+FCKTools.CleanWord = function( oNode, bIgnoreFont, bRemoveStyles )
+{
+	var html = oNode.innerHTML ;
+
+	html = html.replace(/<o:p>\s*<\/o:p>/g, '') ;
+	html = html.replace(/<o:p>.*?<\/o:p>/g, '&nbsp;') ;
+	
+	// Remove mso-xxx styles.
+	html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, '' ) ;
+
+	// Remove margin styles.
+	html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, '' ) ;
+	html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;
+
+	html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, '' ) ;
+	html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;
+
+	html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;
+
+	html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;
+
+	html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;
+
+	html = html.replace( /\s*tab-stops:[^;"]*;?/gi, '' ) ;
+	html = html.replace( /\s*tab-stops:[^"]*/gi, '' ) ;
+
+	// Remove FONT face attributes.
+	if ( bIgnoreFont )
+	{
+		html = html.replace( /\s*face="[^"]*"/gi, '' ) ;
+		html = html.replace( /\s*face=[^ >]*/gi, '' ) ;
+
+		html = html.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, '' ) ;
+	}
+	
+	// Remove Class attributes
+	html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
+
+	// Remove styles.
+	if ( bRemoveStyles )
+		html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
+
+	// Remove empty styles.
+	html =  html.replace( /\s*style="\s*"/gi, '' ) ;
+	
+	html = html.replace( /<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi, '&nbsp;' ) ;
+	
+	html = html.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;
+	
+	// Remove Lang attributes
+	html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
+	
+	html = html.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;
+	
+	html = html.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;
+
+	// Remove XML elements and declarations
+	html = html.replace(/<\\?\?xml[^>]*>/gi, '' ) ;
+	
+	// Remove Tags with XML namespace declarations: <o:p><\/o:p>
+	html = html.replace(/<\/?\w+:[^>]*>/gi, '' ) ;
+	
+	// Remove comments [SF BUG-1481861].
+	html = html.replace(/<\!--.*-->/g, '' ) ;
+
+	html = html.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ;
+
+	html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;
+
+	if ( FCKConfig.CleanWordKeepsStructure )
+	{
+		// The original <Hn> tag send from Word is something like this: <Hn style="margin-top:0px;margin-bottom:0px">
+		html = html.replace( /<H(\d)([^>]*)>/gi, '<h$1>' ) ;
+
+		// Word likes to insert extra <font> tags, when using MSIE. (Wierd).
+		html = html.replace( /<(H\d)><FONT[^>]*>(.*?)<\/FONT><\/\1>/gi, '<$1>$2</$1>' );
+		html = html.replace( /<(H\d)><EM>(.*?)<\/EM><\/\1>/gi, '<$1>$2</$1>' );
+	}
+	else
+	{
+		html = html.replace( /<H1([^>]*)>/gi, '<div$1><b><font size="6">' ) ;
+		html = html.replace( /<H2([^>]*)>/gi, '<div$1><b><font size="5">' ) ;
+		html = html.replace( /<H3([^>]*)>/gi, '<div$1><b><font size="4">' ) ;
+		html = html.replace( /<H4([^>]*)>/gi, '<div$1><b><font size="3">' ) ;
+		html = html.replace( /<H5([^>]*)>/gi, '<div$1><b><font size="2">' ) ;
+		html = html.replace( /<H6([^>]*)>/gi, '<div$1><b><font size="1">' ) ;
+
+		html = html.replace( /<\/H\d>/gi, '<\/font><\/b><\/div>' ) ;
+
+		// Transform <P> to <DIV>
+		var re = new RegExp( '(<P)([^>]*>.*?)(<\/P>)', 'gi' ) ;	// Different because of a IE 5.0 error
+		html = html.replace( re, '<div$2<\/div>' ) ;
+
+		// Remove empty tags (three times, just to be sure).
+		// This also removes any empty anchor
+		html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;
+		html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;
+		html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' ) ;
+	}
+
+	return html ;
+}
Index: /FCKeditor/branches/developers/alfonsoml/editor/dialog/fck_paste.html
===================================================================
--- /FCKeditor/branches/developers/alfonsoml/editor/dialog/fck_paste.html	(revision 56)
+++ /FCKeditor/branches/developers/alfonsoml/editor/dialog/fck_paste.html	(revision 57)
@@ -15,4 +15,6 @@
 	<script type="text/javascript">
 var oEditor = window.parent.InnerDialogLoaded() ;
+var FCK = oEditor.FCK;
+var FCKTools	= oEditor.FCKTools ;
 
 window.onload = function ()
@@ -50,9 +52,13 @@
 		
 		if ( oFrame.contentDocument ) 
-			sHtml = oFrame.contentDocument.body.innerHTML ;
+			oBody = oFrame.contentDocument.body ;
 		else
-			sHtml = oFrame.contentWindow.document.body.innerHTML ;
-
-		sHtml = CleanWord( sHtml ) ;
+			oBody = oFrame.contentWindow.document.body ;
+
+		sHtml = FCKTools.CleanWord( oBody ,document.getElementById('chkRemoveFont').checked, document.getElementById('chkRemoveStyles').checked ) ;
+
+		// Fix relative anchor URLs (IE automatically adds the current page URL).
+		var re = new RegExp( window.location + "#", "g" ) ;
+		sHtml = sHtml.replace( re, '#') ;
 	}
 	else
Index: /FCKeditor/branches/developers/alfonsoml/fckconfig.js
===================================================================
--- /FCKeditor/branches/developers/alfonsoml/fckconfig.js	(revision 56)
+++ /FCKeditor/branches/developers/alfonsoml/fckconfig.js	(revision 57)
@@ -153,4 +153,8 @@
 FCKConfig.BodyClass = '' ;
 
+// The option switches between trying to keep the html structure or do the changes so the content looks like it was in Word
+FCKConfig.CleanWordKeepStructure = false ;
+
+
 // The following value defines which File Browser connector and Quick Upload 
 // "uploader" to use. It is valid for the default implementaion and it is here
