Index: /FCKeditor/trunk/_test/automated/tests/fckdomrange.html
===================================================================
--- /FCKeditor/trunk/_test/automated/tests/fckdomrange.html	(revision 803)
+++ /FCKeditor/trunk/_test/automated/tests/fckdomrange.html	(revision 804)
@@ -28,4 +28,6 @@
 	<script type="text/javascript">
 
+var FCKConfig = { EnterMode : 'p' } ;
+
 FCKScriptLoader.Load( 'FCKDomRange' ) ;
 
@@ -529,5 +531,5 @@
 	if ( docFrag.AppendTo ) docFrag.AppendTo( tmpDiv ) ; else tmpDiv.appendChild( docFrag ) ;
 
-	assertEquals( 'Range HTML', 'this text has no block tag. it should be corrected when working with the enter key set to p or div tags. the <strong id=_strongnopara>br configuration</strong> should not make changes instead.', GetTestInnerHtml( tmpDiv ) ) ;
+	assertEquals( 'Range HTML', 'this text has no block tag.<br>it should be corrected when working with the enter key set to p or div tags. the <strong id=_strongnopara>br configuration</strong> should not make changes instead.<br>it has three lines separated by br tags.', GetTestInnerHtml( tmpDiv ) ) ;
 }
 
@@ -613,7 +615,7 @@
 			alt="" />
 	</p>
-	This text has no block tag. It should be corrected when working with the enter key
+	This text has no block tag.<br />It should be corrected when working with the enter key
 	set to "p" or "div" tags. The <strong id="_StrongNoPara">"br" configuration</strong>
-	should not make changes instead.
+	should not make changes instead.<br />It has three lines separated by BR tags.
 	<p>
 		In the test we will try to recreate this document using the editor tools. To make
Index: /FCKeditor/trunk/_test/manual/fckdomrange/test1.html
===================================================================
--- /FCKeditor/trunk/_test/manual/fckdomrange/test1.html	(revision 803)
+++ /FCKeditor/trunk/_test/manual/fckdomrange/test1.html	(revision 804)
@@ -37,4 +37,7 @@
 FCKConfig.Debug = false ;
 FCKConfig.BasePath = '../../../editor/' ;
+FCKConfig.EnterMode = 'br' ;
+
+FCKListsLib.Setup() ;
 
 var oRange ;
@@ -56,6 +59,6 @@
 	document.getElementById('xEndNode').innerHTML			= ( oRange.EndNode ? oRange.EndNode.nodeType == 1 ? oRange.EndNode.tagName : '[text]' : 'null' ) ;
 	
-	document.getElementById('xStartNode').title	= oRange.StartNode.nodeType == 1 ? '' : oRange.StartNode.nodeValue ;
-	document.getElementById('xEndNode').title	= oRange.EndNode.nodeType == 1 ? '' : oRange.EndNode.nodeValue ;
+	document.getElementById('xStartNode').title	= ( !oRange.StartNode || oRange.StartNode.nodeType == 1 ) ? '' : oRange.StartNode.nodeValue ;
+	document.getElementById('xEndNode').title	= ( !oRange.EndNode || oRange.EndNode.nodeType == 1 ) ? '' : oRange.EndNode.nodeValue ;
 }
 
@@ -169,4 +172,25 @@
 	UpdateDetails() ;
 	oRange.Window.focus() ;
+}
+
+function GetParagraphs()
+{
+	var paragraphs = oRange.GetParagraphs() ;
+	
+	var msg = '' ;
+
+	var div = oRange.Window.document.createElement( 'div' ) ;
+
+	// To avoid breaking ranges, we should process it in reverse order.
+	for ( var i = paragraphs.length - 1 ; i >= 0 ; i-- )
+	{
+		div.innerHTML = '' ;
+		paragraphs[i].ExtractContents().AppendTo( div ) ;
+		msg = div.innerHTML + '\n---\n' + msg ;
+	}
+	
+	msg = 'Number of ranges: ' + paragraphs.length + '\n---\n' + msg ;
+	
+	alert( msg ) ;
 }
 
@@ -223,4 +247,5 @@
 		<input type="button" value="Check Is Collapsed" onclick="CheckIsCollapsed(); return false;" />
 		<input type="button" value="Check Is Empty" onclick="CheckIsEmpty(); return false;" />
+		<input type="button" value="Get Paragraphs" onclick="GetParagraphs(); return false;" />
 	</p>
 	<table>
Index: /FCKeditor/trunk/_test/manual/fckdomrange/test1_inner.html
===================================================================
--- /FCKeditor/trunk/_test/manual/fckdomrange/test1_inner.html	(revision 803)
+++ /FCKeditor/trunk/_test/manual/fckdomrange/test1_inner.html	(revision 804)
@@ -86,7 +86,9 @@
 			alt="" />
 	</p>
-	This text has no block tag. It should be corrected when working with the enter key
+	This text has no block tag.<br />
+	It should be corrected when working with the enter key
 	set to "p" or "div" tags. The <strong>"br" configuration</strong> should not make
-	changes instead.
+	changes instead.<br />
+	It has three lines separated by BR.
 	<p>
 		In the test we will try to recreate this document using the editor tools. To make
Index: /FCKeditor/trunk/editor/_source/commandclasses/fckjustifycommands.js
===================================================================
--- /FCKeditor/trunk/editor/_source/commandclasses/fckjustifycommands.js	(revision 804)
+++ /FCKeditor/trunk/editor/_source/commandclasses/fckjustifycommands.js	(revision 804)
@@ -0,0 +1,83 @@
+﻿/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * FCKJustifyCommand Class: controls text justification.
+ */
+
+var FCKJustifyCommand = function( alignValue )
+{
+	this.AlignVaue = alignValue ;
+	this.CurrentState = FCK_TRISTATE_DISABLED ;
+}
+
+FCKJustifyCommand.prototype = 
+{
+	Execute : function()
+	{
+		var range = new FCKDomRange( FCK.EditorWindow ) ;
+		range.MoveToSelection() ;
+		range.Expand( 'block_contents' ) ;
+		if ( range.StartContainer == range.Window.document.body )
+			range.FixBlock( true ) ;
+		range.StartContainer.removeAttribute( 'align' ) ;
+
+		if ( this.CurrentState == FCK_TRISTATE_OFF)
+			range.StartContainer.style.textAlign = this.AlignVaue ;
+		else if ( this.CurrentState == FCK_TRISTATE_ON )
+			range.StartContainer.style.textAlign = '' ;
+
+		FCK.Events.FireEvent( 'OnSelectionChange' ) ;
+	},
+
+	GetState : function()
+	{
+		if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG || ! FCK.EditorWindow )
+		{
+			this.CurrentState = FCK_TRISTATE_DISABLED ;
+			return this.CurrentState ;
+		}
+
+		var parentEl = FCKSelection.GetParentElement() ;
+		var nearestBlock = parentEl ;
+		while ( nearestBlock )
+		{
+			if ( FCKListsLib.BlockBoundaries[nearestBlock.nodeName.toLowerCase()] )
+				break ;
+			nearestBlock = nearestBlock.parentNode ;
+		}
+
+		if ( ! nearestBlock )
+		{
+			this.CurrentState = FCK_TRISTATE_OFF ;
+			return this.CurrentState ;
+		}
+
+		if ( nearestBlock.align == this.AlignVaue || nearestBlock.style.textAlign == this.AlignVaue  )
+		{
+			this.CurrentState = FCK_TRISTATE_ON ;
+			return this.CurrentState ;
+		}
+		else
+		{
+			this.CurrentState = FCK_TRISTATE_OFF ;
+			return this.CurrentState ;
+		}
+	}
+} ;
Index: /FCKeditor/trunk/editor/_source/commandclasses/fckstylecommand.js
===================================================================
--- /FCKeditor/trunk/editor/_source/commandclasses/fckstylecommand.js	(revision 803)
+++ /FCKeditor/trunk/editor/_source/commandclasses/fckstylecommand.js	(revision 804)
Index: /FCKeditor/trunk/editor/_source/internals/fckcommands.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckcommands.js	(revision 803)
+++ /FCKeditor/trunk/editor/_source/internals/fckcommands.js	(revision 804)
@@ -89,4 +89,9 @@
 		case 'PasteWord'	: oCommand = new FCKPasteWordCommand() ; break ;
 
+		case 'JustifyLeft'	: oCommand = new FCKJustifyCommand( 'left' ) ; break ;
+		case 'JustifyCenter'	: oCommand = new FCKJustifyCommand( 'center' ) ; break ;
+		case 'JustifyRight'	: oCommand = new FCKJustifyCommand( 'right' ) ; break ;
+		case 'JustifyFull'	: oCommand = new FCKJustifyCommand( 'justify' ) ; break ;
+
 		case 'TableInsertRowAfter'		: oCommand = new FCKTableCommand('TableInsertRowAfter') ; break ;
 		case 'TableInsertRowBefore'		: oCommand = new FCKTableCommand('TableInsertRowBefore') ; break ;
Index: /FCKeditor/trunk/editor/fckeditor.html
===================================================================
--- /FCKeditor/trunk/editor/fckeditor.html	(revision 803)
+++ /FCKeditor/trunk/editor/fckeditor.html	(revision 804)
@@ -117,4 +117,5 @@
 LoadScript( '_source/commandclasses/fckfitwindow.js' ) ;
 LoadScript( '_source/commandclasses/fcklistcommands.js' ) ;
+LoadScript( '_source/commandclasses/fckjustifycommands.js' ) ;
 LoadScript( '_source/commandclasses/fckcorestylecommand.js' ) ;
 LoadScript( '_source/commandclasses/fckremoveformatcommand.js' ) ;
Index: /FCKeditor/trunk/fckpackager.xml
===================================================================
--- /FCKeditor/trunk/fckpackager.xml	(revision 803)
+++ /FCKeditor/trunk/fckpackager.xml	(revision 804)
@@ -127,4 +127,5 @@
 		<File path="editor/_source/commandclasses/fckfitwindow.js" />
 		<File path="editor/_source/commandclasses/fcklistcommands.js" />
+		<File path="editor/_source/commandclasses/fckjustifycommands.js" />
 		<File path="editor/_source/commandclasses/fckcorestylecommand.js" />
 		<File path="editor/_source/commandclasses/fckremoveformatcommand.js" />
@@ -218,4 +219,5 @@
 		<File path="editor/_source/commandclasses/fckfitwindow.js" />
 		<File path="editor/_source/commandclasses/fcklistcommands.js" />
+		<File path="editor/_source/commandclasses/fckjustifycommands.js" />
 		<File path="editor/_source/commandclasses/fckcorestylecommand.js" />
 		<File path="editor/_source/commandclasses/fckremoveformatcommand.js" />
