Index: CKEditor/branches/features/pasting/_source/core/htmlparser/element.js
===================================================================
--- CKEditor/branches/features/pasting/_source/core/htmlparser/element.js	(revision 4207)
+++ CKEditor/branches/features/pasting/_source/core/htmlparser/element.js	(revision 4208)
@@ -1,3 +1,3 @@
-﻿/*
+/*
 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -100,12 +100,4 @@
 			var attributes = this.attributes;
 
-			// The "_cke_replacedata" indicates that this element is replacing
-			// a data snippet, which should be outputted as is.
-			if ( attributes._cke_replacedata )
-			{
-				writer.write( attributes._cke_replacedata );
-				return;
-			}
-
 			// Ignore cke: prefixes when writing HTML.
 			var element = this,
Index: CKEditor/branches/features/pasting/_source/core/tools.js
===================================================================
--- CKEditor/branches/features/pasting/_source/core/tools.js	(revision 4207)
+++ CKEditor/branches/features/pasting/_source/core/tools.js	(revision 4208)
@@ -64,15 +64,4 @@
 			var clone;
 
-			// Array.
-			if ( obj && ( obj instanceof Array ) )
-			{
-				clone = [];
-
-				for ( var i = 0 ; i < obj.length ; i++ )
-					clone[ i ] = this.clone( obj[ i ] );
-
-				return clone;
-			}
-
 			// "Static" types.
 			if ( obj === null
@@ -81,5 +70,6 @@
 				|| ( obj instanceof Number )
 				|| ( obj instanceof Boolean )
-				|| ( obj instanceof Date ) )
+				|| ( obj instanceof Date )
+				|| ( obj instanceof RegExp) )
 			{
 				return obj;
Index: CKEditor/branches/features/pasting/_source/plugins/pagebreak/plugin.js
===================================================================
--- CKEditor/branches/features/pasting/_source/plugins/pagebreak/plugin.js	(revision 4207)
+++ CKEditor/branches/features/pasting/_source/plugins/pagebreak/plugin.js	(revision 4208)
@@ -56,5 +56,6 @@
 						div : function( element )
 						{
-							var style = element.attributes.style,
+							var attributes = element.attributes
+								style = attributes && element.attributes.style,
 								child = style && element.children.length == 1 && element.children[ 0 ],
 								childStyle = child && ( child.name == 'span' ) && child.attributes.style;
Index: CKEditor/branches/features/pasting/_source/plugins/pastefromword/plugin.js
===================================================================
--- CKEditor/branches/features/pasting/_source/plugins/pastefromword/plugin.js	(revision 4207)
+++ CKEditor/branches/features/pasting/_source/plugins/pastefromword/plugin.js	(revision 4208)
@@ -20,5 +20,9 @@
 			} );
 		
-		var config = editor.config;
+		var config = editor.config,
+			keepHeadingStructure = config.pasteFromWordKeepsStructure,
+			ignoreFontFace = config.pasteFromWordIgnoreFontFace,
+			removeStyleAttr = config.pasteFromWordRemoveStyle;
+
 		editor.on( 'paste', function( evt )
 		{
@@ -28,10 +32,149 @@
 				 && /(class=\"?Mso|style=\"[^\"]*\bmso\-|w:WordDocument)/.test( mswordHtml ) )
 			{
+				var onlyChildOf = function( element )
+				{
+					var children = element.children,
+						count = children.length,
+						firstChild = count && children[ 0 ];
+					return firstChild;
+				};
+
+				var falsyFilter = function()
+					 {
+						return false;
+					 },
+					 dropStyles = function( styles )
+					 {
+						 return function( styleText )
+						 {
+							 var rules = [];
+							 styleText.replace( /(?:"| |;|^ )\s*([^ :]+?)\s*:\s*([^;"]+?)\s*(?=;|"|$)/g,
+								 function( match, name, value )
+								 {
+									 name = name.toLowerCase();
+									 var namePattern,
+										 valuePattern;
+									 for( var i = 0 ; i < styles.length ; i++ )
+									 {
+										namePattern = styles[ i ][ 0 ],
+										valuePattern = styles[ i ][ 1 ];
+
+										if ( !( name.match( namePattern ) && ( !valuePattern || value.match( valuePattern ) ) ) )
+											rules.push( [ name, value ] );
+									 }
+								 } );
+
+							 for ( var i = 0 ; i < rules.length ; i++ )
+								 rules[ i ] = rules[ i ].join( ':' );
+							 return rules && ( rules.join( ';' ).replace( /\s+/g, '' ) + ';' );
+						 };
+					 };
+
 				var filter = editor.pasteProcessor.dataFilter;
-				// TODO: Migrate the 'CKEDITOR.plugins.pastefromword' to filter rules.
 				filter.addRules(
 				{
-
-				} );
+					elementNames :
+					[
+						// Remove style, meta and link elements.
+						[ /style|meta|link/, '' ]
+					],
+
+					elements :
+					{
+						$ : function( element )
+						{
+							var tagName = element.name,
+								child = onlyChildOf( element );
+
+							var match, level;
+							// Processing headings.
+							if ( ( match = tagName.match( /h(\d)/i ) ) && ( level = match[ 1 ] ) )
+							{
+								// Remove empty headings.
+								if( child
+									&& child.type == CKEDITOR.NODE_TEXT
+									&& !CKEDITOR.tools.trim( child.value ) )
+									return false;
+
+								// The original <Hn> tag send from Word is something like this: <Hn style="margin-top:0px;margin-bottom:0px">
+								delete element.attributes;
+
+								if ( keepHeadingStructure )
+								{
+									// Word likes to insert extra <font> tags, when using MSIE. (Wierd).
+									if ( child && child.type == CKEDITOR.NODE_ELEMENT
+											&& child.name.match( /em|font/ ) )
+										element.children = child.children;
+								}
+								else
+								{
+									// Transform headings to divs.
+									element.name = 'div';
+									var bold = new CKEDITOR.htmlParser.element( 'b' ),
+										font = new CKEDITOR.htmlParser.element( 'font', { size : Math.abs( 7 - level ) } );
+									font.children = element.children;
+									bold.children  = [ font ];
+									element.children = [ bold ];
+								}
+							}
+							// Remove empty space inline wrapper.
+							else if( tagName.match( /u|i|strike|/ ) )
+							{
+								if ( child
+									 && child.type == CKEDITOR.NODE_TEXT
+									 && CKEDITOR.tools.trim( child.value ) == '&nbsp;' )
+									delete element.name;
+							}
+							// Remove dummy wrapper span.
+							else if( tagName.match( /span|font/ ) )
+							{
+								if( !element.attributes )
+									delete element.name;
+							}
+							// Remove namespaced element while preserving the content.
+							else if( tagName.indexOf( ':' ) != -1 )
+							{
+								delete element.name;
+							}
+						}
+					},
+
+					attributeNames :
+					[
+						// Remove onmouseover and onmouseout events (from MS Word comments effect)
+						[ /^onmouse(:?out|over)/, '' ],
+						// Remove lang/language attributes.
+						[ /^lang/, '' ],
+						removeStyleAttr ? [ 'style', '' ] :
+						ignoreFontFace ? [ 'face', '' ] : null
+					],
+
+					attributes :
+					{
+						// Remove mso-xxx styles.
+						// Remove margin styles.
+						'style' : dropStyles(
+						[
+							[ /^mso-/ ],
+							[ 'margin', /0(?:cm|in) 0(?:cm|in) 0pt/ ],
+							[ 'text-indent', '0cm' ],
+							[ 'page-break-before' ],
+							[ 'tab-stops' ],
+							[ 'display', 'none' ],
+							ignoreFontFace ? [ 'font-family' ] : null
+						] ),
+						
+						'class' : falsyFilter,
+
+						// Remove align="left" attribute.
+						'align' : function( value )
+						{
+							return ! ( value == 'left ' );
+						}
+					},
+					// Remove comments [SF BUG-1481861].
+					comment : falsyFilter
+				}, 5 );
+
 			}
 		} );
@@ -42,4 +185,7 @@
 CKEDITOR.plugins.pastefromword =
 {
+	/**
+	 * @depprecated Leave it here for reference.
+	 */
 	cleanWord : function( editor, html, ignoreFont, removeStyles )
 	{
@@ -179,5 +325,5 @@
  * config.pasteFromWordRemoveStyle = true;
  */
-CKEDITOR.config.pasteFromWordRemoveStyle = false;
+CKEDITOR.config.pasteFromWordRemoveStyle = true;
 
 /**
@@ -190,3 +336,3 @@
  * config.pasteFromWordKeepsStructure = true;
  */
-CKEDITOR.config.pasteFromWordKeepsStructure = false;
+CKEDITOR.config.pasteFromWordKeepsStructure = true;
Index: CKEditor/branches/features/pasting/_source/plugins/styles/plugin.js
===================================================================
--- CKEditor/branches/features/pasting/_source/plugins/styles/plugin.js	(revision 4207)
+++ CKEditor/branches/features/pasting/_source/plugins/styles/plugin.js	(revision 4208)
@@ -199,6 +199,6 @@
 							continue;
 
-						var elementAttr = element.getAttribute( attName );
-						if ( attribs[attName] ==
+						var elementAttr = element.getAttribute( attName ) || '';
+						if ( attribs[ attName ] ==
 							 ( attName == 'style' ?
 							   normalizeCssText( elementAttr, false ) : elementAttr  ) )
