--- sw/source/filter/ww8/ww8atr.cxx.orig	2007-04-06 10:41:38.000000000 +0800
+++ sw/source/filter/ww8/ww8atr.cxx	2007-04-06 10:42:25.000000000 +0800
@@ -3516,7 +3516,16 @@ static Writer& OutWW8_SwTextGrid( Writer
                 nGridType = 2;
                 break;
             case GRID_LINES_CHARS:
-                nGridType = 1;
+				{
+					if(rItem.IsSnapToChars())
+					{
+						nGridType = 3;
+					}
+					else
+					{
+						nGridType = 1; 
+					}
+				}
                 break;
         }
         rWrtWW8.InsUInt16(0x5032);
@@ -3525,6 +3534,27 @@ static Writer& OutWW8_SwTextGrid( Writer
         UINT16 nHeight = rItem.GetBaseHeight() + rItem.GetRubyHeight();
         rWrtWW8.InsUInt16(0x9031);
         rWrtWW8.InsUInt16(nHeight);
+	   	sal_uInt32 nPageCharSize = ItemGet<SvxFontHeightItem>(*(rWrtWW8.pStyles->GetSwFmt()),
+                RES_CHRATR_CJK_FONTSIZE).GetHeight();
+
+		INT32 nCharWidth = rItem.GetBaseWidth() - nPageCharSize;	   
+	   	INT32 nFraction = 0;
+	   	nFraction = nCharWidth%20;
+	   	if( nCharWidth < 0 )
+			nFraction = 20 + nFraction;
+	  	nFraction = ((nFraction)*0xFFF)/20;
+	   	nFraction = (nFraction & 0x00000FFF);
+   
+	   	INT32 nMain = 0;
+	   	nMain = nCharWidth/20;
+	   	if( nCharWidth < 0 )
+			nMain -= 1;
+	   	nMain = nMain * 0x1000;
+	   	nMain = (nMain & 0xFFFFF000);
+   
+	   	UINT32 nCharSpace = nFraction + nMain;
+	   	rWrtWW8.InsUInt16(0x7030);
+	   	rWrtWW8.InsUInt32(nCharSpace);
     }
     return rWrt;
 }
--- sw/source/filter/ww8/wrtww8.hxx.orig	2006-08-15 01:16:28.000000000 +0800
+++ sw/source/filter/ww8/wrtww8.hxx	2007-04-09 10:13:11.000000000 +0800
@@ -964,6 +964,7 @@ public:
 
     void OutStyleTab();
     USHORT Sty_GetWWSlot( const SwFmt& rFmt ) const;
+	SwFmt* GetSwFmt(){return (*pFmtA);}
 };
 
 class WW8SaveData
--- sw/source/filter/ww8/ww8par6.cxx.orig	2007-07-26 14:26:27.000000000 +0800
+++ sw/source/filter/ww8/ww8par6.cxx	2007-07-26 14:40:44.000000000 +0800
@@ -418,12 +418,12 @@ void SwWW8ImplReader::SetDocumentGrid(Sw
         default:
             ASSERT(!this, "Unknown grid type");
         case 3:
-            //Text snaps to char grid, this doesn't make a lot of sense to
-            //me. This is closer than LINES_CHARS
-            eType = GRID_LINES_ONLY;
+            eType = GRID_LINES_CHARS;
+			aGrid.SetSnapToChars(sal_True);
             break;
         case 1:
             eType = GRID_LINES_CHARS;
+			aGrid.SetSnapToChars(sal_False);
             break;
         case 2:
             eType = GRID_LINES_ONLY;
@@ -436,6 +436,11 @@ void SwWW8ImplReader::SetDocumentGrid(Sw
     if (eType != GRID_NONE)
         rDoc.set(IDocumentSettingAccess::ADD_EXT_LEADING, true);
 
+	//force to set document as standard page mode
+	sal_Bool bSquaredMode = sal_False;
+	rDoc.SetDefaultPageMode( bSquaredMode );
+	aGrid.SetSquaredMode( bSquaredMode );
+
     //sep.dyaLinePitch
     sal_Int32 nLinePitch = rSection.maSep.dyaLinePitch;
 
@@ -466,11 +471,15 @@ void SwWW8ImplReader::SetDocumentGrid(Sw
         nCharWidth += nFraction;
     }
 
-    aGrid.SetLines(writer_cast<sal_uInt16>(nTextareaHeight/nLinePitch));
-    aGrid.SetBaseHeight(writer_cast<sal_uInt16>(nCharWidth));
-    sal_Int32 nRubyHeight = nLinePitch - nCharWidth;
-    if (nRubyHeight < 0)
-        nRubyHeight = 0;
+    aGrid.SetBaseWidth( nCharWidth );
+	aGrid.SetLines(writer_cast<sal_uInt16>(nTextareaHeight/nLinePitch));
+	aGrid.SetBaseHeight(writer_cast<sal_uInt16>(nLinePitch));
+
+	// ruby height is not supported in ww8
+    //sal_Int32 nRubyHeight = nLinePitch - nCharWidth;
+    //if (nRubyHeight < 0)
+    //    nRubyHeight = 0;
+	sal_Int32 nRubyHeight = 0;
     aGrid.SetRubyHeight(writer_cast<sal_uInt16>(nRubyHeight));
 
     rFmt.SetAttr(aGrid);
