Index: CKEditor/branches/features/pasting/_source/core/htmlparser/filter.js
===================================================================
--- CKEditor/branches/features/pasting/_source/core/htmlparser/filter.js	(revision 4247)
+++ CKEditor/branches/features/pasting/_source/core/htmlparser/filter.js	(revision 4255)
@@ -1,2 +1,4 @@
+
+
 /*
 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
@@ -150,6 +152,9 @@
 			{
 				var item = items[ j ];
-				item.pri = priority;
-				list.splice( i, 0, item );
+				if( item )
+				{
+					item.pri = priority;
+					list.splice( i, 0, item );
+				}
 			}
 		}
Index: CKEditor/branches/features/pasting/_source/plugins/pastefromword/dialogs/pastefromword.js
===================================================================
--- CKEditor/branches/features/pasting/_source/plugins/pastefromword/dialogs/pastefromword.js	(revision 4247)
+++ CKEditor/branches/features/pasting/_source/plugins/pastefromword/dialogs/pastefromword.js	(revision 4255)
@@ -6,4 +6,16 @@
 CKEDITOR.dialog.add( 'pastefromword', function( editor )
 {
+	// Help to switch the editor config entry temporarily.
+	function getConfigSwitcher( config, entryName )
+	{
+		var originalValue = config[ entryName ];
+
+		return function( newValue )
+		{
+			config[ entryName ] =
+				typeof newValue != 'undefined' ? newValue : originalValue;
+		}
+	}
+
 	return {
 		title : editor.lang.pastefromword.title,
@@ -103,11 +115,18 @@
 				iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ),
 				editor = this.getParentEditor(),
+				config = editor.config,
+				ignoreFontFace = this.getValueOf( 'general', 'ignoreFontFace' ),
 				//TODO: Bring those dialog-based configs to the paste processor.
 				html = iframe.$.contentWindow.document.body.innerHTML;
 
-				// Insertion should happen after main document design mode turned on.
-				setTimeout( function(){
-					editor.fire( 'paste', { 'html' : html } );
-				}, 0 );
+			// Insertion should happen after main document design mode turned on.
+			 setTimeout( function(){
+
+				var switcher;
+				( switcher = getConfigSwitcher( editor.config,'pasteFromWordIgnoreFontFace' ) )
+						( ignoreFontFace );
+				editor.fire( 'paste', { 'html' : html } );
+				switcher();
+			}, 0 );
 		},
 		onHide : function()
@@ -174,10 +193,4 @@
 								label : editor.lang.pastefromword.ignoreFontFace,
 								'default' : editor.config.pasteFromWordIgnoreFontFace
-							},
-							{
-								type : 'checkbox',
-								id : 'removeStyle',
-								label : editor.lang.pastefromword.removeStyle,
-								'default' : editor.config.pasteFromWordRemoveStyle
 							}
 						]
Index: CKEditor/branches/features/pasting/_source/plugins/pastefromword/plugin.js
===================================================================
--- CKEditor/branches/features/pasting/_source/plugins/pastefromword/plugin.js	(revision 4247)
+++ CKEditor/branches/features/pasting/_source/plugins/pastefromword/plugin.js	(revision 4255)
@@ -20,8 +20,4 @@
 					command : 'pastefromword'
 				} );
-
-			var config = editor.config,
-				ignoreFontFace = config.pasteFromWordIgnoreFontFace,
-				removeStyleAttr = config.pasteFromWordRemoveStyle;
 
 			editor.on( 'paste', function( evt )
@@ -234,5 +230,7 @@
 					{
 						 var rules = [];
-						 styleText.replace( /\s*([^ :;]+?)\s*:\s*([^;"]+?)\s*(?=;|$)/g,
+						// quote might be html-encoded which confused the next regexp.
+						 styleText.replace( /&quot;/g, '"' )
+								  .replace( /\s*([^ :;]+?)\s*:\s*([^;]+?)\s*(?=;|$)/g,
 							 function( match, name, value )
 							 {
@@ -240,5 +238,6 @@
 								 var namePattern,
 									 valuePattern,
-									 newValue;
+									 newValue,
+									 newName;
 								 for( var i = 0 ; i < styles.length && styles[ i ] ; i++ )
 								 {
@@ -246,8 +245,10 @@
 									valuePattern = styles[ i ][ 1 ];
 									newValue = styles[ i ][ 2 ];
+									newName = styles[ i ][ 3 ];
 
 									if ( name.match( namePattern )
 										 && ( !valuePattern || value.match( valuePattern ) ) )
 									{
+										name = newName || name;
 										if( typeof newValue == 'function' )
 											newValue = newValue( value, element );
@@ -261,8 +262,8 @@
 							 } );
 
-						 for ( var i = 0 ; i < rules.length ; i++ )
+						for ( var i = 0 ; i < rules.length ; i++ )
 							 rules[ i ] = rules[ i ].join( ':' );
 						return rules.length ?
-						         ( rules.join( ';' ) + ';' )
+						         ( rules.join( ';' ) + ';' ).replace( /"/g, '&quot;' )
 						         // Remove attribute if there's no styles.
 								 : false;
@@ -292,6 +293,5 @@
 				listDtdParents = CKEDITOR.dtd.parentOf( 'ol' ),
 				config = editor.config,
-				ignoreFontFace = config.pasteFromWordIgnoreFontFace,
-				removeStyleAttr = config.pasteFromWordRemoveStyle;
+				ignoreFontFace = config.pasteFromWordIgnoreFontFace;
 
 			return {
@@ -299,6 +299,6 @@
 				elementNames :
 				[
-					// Remove style, meta and link elements.
-					[ /style|meta|link/, '' ]
+					// Remove script, meta and link elements.
+					[ /meta|link|script|style/, '' ]
 				],
 
@@ -309,28 +309,21 @@
 						var tagName = element.name || '';
 
-						var match, level;
 						// Processing headings.
-						if ( ( match = tagName.match( /h(\d)/i ) ) && ( level = match[ 1 ] ) )
+						if ( tagName.match( /h(\d)/i ) )
+						{
+							element.filterChildren();
+							var onlyChild = element.onlyChild();
+							// Remove empty headings.
+							if( onlyChild && onlyChild.value
+								&& !CKEDITOR.tools.trim( onlyChild.value ) )
+								return false;
+							delete element.attributes;
+						}
+						// Remove inline elements which contain only empty spaces.
+						else if( tagName.match( /^(:?b|u|i|strike|span)$/ ) )
 						{
 							element.filterChildren();
 							var child = element.onlyChild();
-
-							// Remove empty headings.
-							if( child && child.value
-								&& !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;
-
-							// Word likes to insert extra <font> tags, when using MSIE. (Wierd).
-							if ( child && /em|font/.exec( child.name ) )
-								element.children = child.children;
-						}
-						// Remove inline elements which contain only empty spaces.
-						else if( tagName.match( /^(:?b|u|i|strike|span)$/ ) )
-						{
-							element.filterChildren();
-							var child = element.onlyChild();
-							if ( child && /(:?\s|&nbsp;)+/.exec( child.value ) )
+							if ( child && /^(:?\s|&nbsp;)+$/.exec( child.value ) )
 								delete element.name;
 						}
@@ -340,4 +333,39 @@
 							if( !element.attributes )
 								delete element.name;
+							// Normalize <font> into <span> + style text.
+							else if( tagName == 'font' )
+							{
+								element.filterChildren();
+								// Merge nested <font> tags.
+								var parent = element.parent;
+								if( 'font' == parent.name )
+								{
+									CKEDITOR.tools.extend( parent.attributes,
+											element.attributes );
+									delete element.name;
+									return;
+								}
+								// Convert the topmost into a span with font-styles. 
+								else
+								{
+									var attrs = element.attributes,
+										styleText = '';
+									if( attrs.color )
+										styleText += 'color:' + attrs.color + ';';
+									if( attrs.face )
+										styleText += 'font-family:' + attrs.face + ';';
+									// TODO: Mapping size in ranges of xx-small,
+									// x-small, small, medium, large, x-large, xx-large.
+									if( attrs.size )
+										styleText += 'font-size:' +
+										            ( attrs.size > 3 ? 'larger'
+												      : ( attrs.size < 3 ? 'smaller' : 'medium' ) )+ ';';
+
+									if( styleText )
+										element.attributes = { 'style' : styleText };
+
+									element.name = 'span';
+								}
+							}
 						}
 						// Remove namespaced element while preserving the content.
@@ -360,10 +388,10 @@
 						else if ( !tagName )
 						{
-							// Trim &nbsp; at the beginning of document for IE. 
+							// Trim empty spaces at the beginning of document for IE. 
 							if( CKEDITOR.env.ie )
 							{
 								var firstTextChild = element.firstTextChild();
 								if ( firstTextChild
-									 && CKEDITOR.tools.trim( firstTextChild.value ).match( /(?:&nbsp;)+/ ) )
+									 && firstTextChild.value.match( /^(:?\s|&nbsp;)+$/ ) )
 									element.children.splice( 0, 1 );
 							}
@@ -551,5 +579,5 @@
 					// Remove lang/language attributes.
 					[ /^lang/, '' ],
-					ignoreFontFace ? [ 'face', '' ] : null
+					ignoreFontFace ? [ /^(?:face|font|size)/, '' ] : null
 				],
 
@@ -564,4 +592,12 @@
 						[ /mso-/ ],
 						[ /-moz-/ ],
+						// Replace verbose background color style.
+						[ /^background$/, null, function( value )
+						{
+							return value.match( /^[^\s]+/ )[ 0 ];
+						}, 'background-color' ],
+						[ 'background-color', 'transparent' ],
+						// Remove verbose border-color style for Firefox.
+						CKEDITOR.env.gecko ? [ 'border-color', /(:?windowtext|-moz-use-text-color|\s)*/ ] : null,
 						[ 'margin', /0(?:cm|in) 0(?:cm|in) 0pt/ ],
 						[ 'text-indent', '0cm' ],
@@ -570,7 +606,7 @@
 						[ 'display', 'none' ],
 						[ 'text-align', 'left' ],
-						ignoreFontFace ? [ 'font-family' ] : null,
+						ignoreFontFace ? [ /font-?/ ] : null,
 					] ),
-					'width' : function( element )
+					'width' : function( value, element )
 					{
 						// Prefer width style over attribute on table cell.
@@ -664,24 +700,3 @@
  * config.pasteFromWordIgnoreFontFace = false;
  */
-CKEDITOR.config.pasteFromWordIgnoreFontFace = true;
-
-/**
- * Whether the "Remove styles definitions" checkbox is enabled by default in
- * the Paste from Word dialog.
- * @type Boolean
- * @default false
- * @example
- * config.pasteFromWordRemoveStyle = true;
- */
-CKEDITOR.config.pasteFromWordRemoveStyle = true;
-
-/**
- * Whether to keep structure markup (&lt;h1&gt;, &lt;h2&gt;, etc.) or replace
- * it with elements that create more similar pasting results when pasting
- * content from Microsoft Word into the Paste from Word dialog.
- * @type Boolean
- * @default false
- * @example
- * config.pasteFromWordKeepsStructure = true;
- */
-CKEDITOR.config.pasteFromWordKeepsStructure = true;
+CKEDITOR.config.pasteFromWordIgnoreFontFace = false;
