--- sw/source/core/unocore/unomap.cxx.orig	2007-04-06 10:37:07.000000000 +0800
+++ sw/source/core/unocore/unomap.cxx	2007-04-06 10:38:21.000000000 +0800
@@ -984,7 +984,9 @@ const SfxItemPropertyMap* SwUnoPropertyM
                     { SW_PROP_NMID(UNO_NAME_GRID_RUBY_BELOW), RES_TEXTGRID, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, MID_GRID_RUBY_BELOW},
                     { SW_PROP_NMID(UNO_NAME_GRID_PRINT), RES_TEXTGRID, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, MID_GRID_PRINT},
                     { SW_PROP_NMID(UNO_NAME_GRID_DISPLAY), RES_TEXTGRID, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, MID_GRID_DISPLAY},
-
+                    { SW_PROP_NMID(UNO_NAME_GRID_BASE_WIDTH), RES_TEXTGRID, CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, MID_GRID_BASEWIDTH|CONVERT_TWIPS},
+                    { SW_PROP_NMID(UNO_NAME_GRID_SNAP_TO_CHARS), RES_TEXTGRID, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, MID_GRID_SNAPTOCHARS},
+                     { SW_PROP_NMID(UNO_NAME_GRID_SQUARE_PAGE_MODE), RES_TEXTGRID, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, MID_GRID_SQUARE_MODE},
 					{0,0,0,0,0}
 				};
 				aMapArr[nPropertyId] = aPageStyleMap;
@@ -1802,7 +1804,11 @@ const SfxItemPropertyMap* SwUnoPropertyM
                     // --> collapsing borders DVO, FME 2005-05-27 #i29550#
                     { SW_PROP_NMID(UNO_NAME_COLLAPSING_BORDERS), RES_COLLAPSING_BORDERS, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, 0},
                     // <-- collapsing
-					{0,0,0,0,0}
+
+			//text grid enhancement for better CJK support.  2007-04-01
+			//just export the default page mode property, other properties are not handled in this version
+                    { SW_PROP_NMID(UNO_NAME_GRID_SQUARE_PAGE_MODE), RES_TEXTGRID, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, MID_GRID_SQUARE_MODE},
+                    		{0,0,0,0,0}
 				};
 				aMapArr[nPropertyId] = aTextDefaultMap_Impl;
 				for( SfxItemPropertyMap * pMap = aTextDefaultMap_Impl;
--- sw/source/core/unocore/unoprnms.cxx.orig	2007-04-06 10:37:18.000000000 +0800
+++ sw/source/core/unocore/unoprnms.cxx	2007-04-06 10:38:34.000000000 +0800
@@ -765,7 +765,10 @@ const SwPropNameTab aPropNameTab = {
 /* 0713 UNO_NAME_TOOLTIP */ {MAP_CHAR_LEN("Tooltip")},
 /* 0714 UNO_NAME_DIALOG_LIBRARIES*/     {MAP_CHAR_LEN("DialogLibraries")},
 /* 0715 UNO_NAME_HEADER_ROW_COUNT*/     {MAP_CHAR_LEN("HeaderRowCount")},
-/* 0716 UNO_NAME_INPUT */                {MAP_CHAR_LEN("Input")}
+/* 0716 UNO_NAME_INPUT */               {MAP_CHAR_LEN("Input")},
+/* 0717 UNO_NAME_GRID_BASE_WIDTH*/      {MAP_CHAR_LEN("GridBaseWidth")},
+/* 0718 UNO_NAME_GRID_SNAP_TO_CHARS*/   {MAP_CHAR_LEN("GridSnapToChars")},
+/* 0719 UNO_NAME_SQUARE_PAGE_MODE*/     {MAP_CHAR_LEN("SquarePageMode")}
 };
 
 const SwPropNameLen& SwGetPropName( USHORT nId )
--- sw/source/filter/xml/xmlfmte.cxx.orig	2007-04-06 10:44:29.000000000 +0800
+++ sw/source/filter/xml/xmlfmte.cxx	2007-04-06 10:44:41.000000000 +0800
@@ -242,6 +242,9 @@ void SwXMLExport::_ExportStyles( sal_Boo
 #if SUPD <628 && !defined(TEST_MIB)
 	GetTextParagraphExport()->SetProgress( 0 );
 #endif
+
+	//page defaults
+	GetPageExport()->exportDefaultStyle();
 }
 
 void SwXMLExport::_ExportAutoStyles()
--- xmloff/inc/PageMasterImportContext.hxx.orig	2007-04-06 11:05:35.000000000 +0800
+++ xmloff/inc/PageMasterImportContext.hxx	2007-04-06 11:06:47.000000000 +0800
@@ -60,7 +60,8 @@ public:
 	PageStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
 			const ::rtl::OUString& rLName,
 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
-			SvXMLStylesContext& rStyles);
+			SvXMLStylesContext& rStyles,
+			sal_Bool bDefaultStyle=sal_False);
 	virtual ~PageStyleContext();
 
 	virtual SvXMLImportContext *CreateChildContext(
@@ -71,6 +72,9 @@ public:
 	virtual void FillPropertySet(
 			const ::com::sun::star::uno::Reference<
 				::com::sun::star::beans::XPropertySet > & rPropSet );
+
+	//text grid enhancement
+	virtual void SetDefaults();
 };
 
 #endif
--- xmloff/inc/xmloff/XMLPageExport.hxx.orig	2007-04-06 11:06:00.000000000 +0800
+++ xmloff/inc/xmloff/XMLPageExport.hxx	2007-04-06 11:07:00.000000000 +0800
@@ -133,5 +133,8 @@ public:
 	void	collectAutoStyles( sal_Bool bUsed )		{ exportStyles( bUsed, sal_True ); }
 	void	exportAutoStyles();
 	void	exportMasterStyles( sal_Bool bUsed )	{ exportStyles( bUsed, sal_False ); }
+
+	//text grid enhancement for better CJK support
+	void exportDefaultStyle();
 };
 

--- xmloff/inc/xmloff/xmlstyle.hxx.orig	2007-04-06 11:06:12.000000000 +0800
+++ xmloff/inc/xmloff/xmlstyle.hxx	2007-04-06 11:07:07.000000000 +0800
@@ -91,6 +91,7 @@ enum XMLStyleStylesElemTokens
 	XML_TOK_TEXT_BIBLIOGRAPHY_CONFIG,
 	XML_TOK_TEXT_LINENUMBERING_CONFIG,
 	XML_TOK_STYLE_DEFAULT_STYLE,
+	XML_TOK_STYLE_DEFAULT_PAGE_LAYOUT,	//text grid enhancement
 	XML_TOK_STYLE_STYLES_ELEM_END=XML_TOK_UNKNOWN
 };
 
--- xmloff/inc/xmloff/xmltoken.hxx.orig	2007-04-06 11:06:21.000000000 +0800
+++ xmloff/inc/xmloff/xmltoken.hxx	2007-04-06 11:07:30.000000000 +0800
@@ -2079,6 +2079,12 @@ namespace xmloff { namespace token {
         XML_LAYOUT_GRID_PRINT,
         XML_LAYOUT_GRID_DISPLAY,
 
+		//text grid enhancement for better CJK support
+		XML_DEFAULT_PAGE_LAYOUT,
+		XML_LAYOUT_GRID_SQUARE_MODE,
+		XML_LAYOUT_GRID_BASE_WIDTH,
+		XML_LAYOUT_GRID_SNAP_TO_CHARS,
+
         XML_SNAP_TO_LAYOUT_GRID,
         XML_DONT_BALANCE_TEXT_COLUMNS,
 
--- xmloff/source/core/xmltoken.cxx.orig	2007-04-06 11:07:55.000000000 +0800
+++ xmloff/source/core/xmltoken.cxx	2007-04-06 11:09:59.000000000 +0800
@@ -2089,6 +2089,12 @@ namespace xmloff { namespace token {
         TOKEN( "layout-grid-print",               XML_LAYOUT_GRID_PRINT ),
         TOKEN( "layout-grid-display",             XML_LAYOUT_GRID_DISPLAY ),
 
+		//text grid enhancement for better CJK support
+        TOKEN( "default-page-layout",             XML_DEFAULT_PAGE_LAYOUT ),
+        TOKEN( "layout-grid-square-mode",       XML_LAYOUT_GRID_SQUARE_MODE ),
+        TOKEN( "layout-grid-base-width",          XML_LAYOUT_GRID_BASE_WIDTH ),
+        TOKEN( "layout-grid-snap-to-characters",       XML_LAYOUT_GRID_SNAP_TO_CHARS ),
+
         TOKEN( "snap-to-layout-grid",             XML_SNAP_TO_LAYOUT_GRID ),
 
         TOKEN( "dont-balance-text-columns",       XML_DONT_BALANCE_TEXT_COLUMNS ),
--- xmloff/source/style/PageMasterImportContext.cxx.orig	2007-04-06 11:11:07.000000000 +0800
+++ xmloff/source/style/PageMasterImportContext.cxx	2007-04-19 15:21:57.000000000 +0800
@@ -67,8 +67,14 @@
 #include "PageMasterStyleMap.hxx"
 #endif
 
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+
 using namespace ::com::sun::star;
 using namespace ::xmloff::token;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
 
 void PageStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
                                         const rtl::OUString& rLocalName,
@@ -90,8 +96,9 @@ TYPEINIT1( PageStyleContext, XMLPropStyl
 PageStyleContext::PageStyleContext( SvXMLImport& rImport,
         sal_uInt16 nPrfx, const rtl::OUString& rLName,
         const uno::Reference< xml::sax::XAttributeList > & xAttrList,
-        SvXMLStylesContext& rStyles) :
-    XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, XML_STYLE_FAMILY_PAGE_MASTER ),
+        SvXMLStylesContext& rStyles,
+        sal_Bool bDefaultStyle) :
+    XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, XML_STYLE_FAMILY_PAGE_MASTER, bDefaultStyle),
     sPageUsage()
 {
 }
@@ -202,3 +209,18 @@ void PageStyleContext::FillPropertySet(
     }
 }
 
+// text grid enhancement for better CJK support
+//set default page layout style
+void PageStyleContext::SetDefaults( )
+{
+	Reference < XMultiServiceFactory > xFactory ( GetImport().GetModel(), UNO_QUERY);
+	if (xFactory.is())
+	{
+		Reference < XInterface > xInt = xFactory->createInstance (
+	    rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.Defaults" ) ) );
+	    Reference < beans::XPropertySet > xProperties ( xInt, UNO_QUERY );
+	    if ( xProperties.is() )
+	    	FillPropertySet ( xProperties );
+	}
+}
+
--- xmloff/source/style/PageMasterStyleMap.cxx.orig	2007-04-06 11:11:23.000000000 +0800
+++ xmloff/source/style/PageMasterStyleMap.cxx	2007-04-06 11:13:16.000000000 +0800
@@ -122,6 +122,12 @@ const XMLPropertyMapEntry aXMLPageMaster
     PLMAP( "GridPrint", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_PRINT, XML_TYPE_BOOL, 0 ),
     PLMAP( "GridDisplay", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_DISPLAY, XML_TYPE_BOOL, 0 ),
 
+	//text grid enhancement for better CJK support
+    PLMAP( "GridBaseWidth", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_BASE_WIDTH, XML_TYPE_MEASURE, 0 ),
+    PLMAP( "GridSnapToChars", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_SNAP_TO_CHARS, XML_TYPE_BOOL, 0 ),
+  	//export as a default attribute
+    PLMAP( "SquarePageMode", XML_NAMESPACE_STYLE, XML_LAYOUT_GRID_SQUARE_MODE, XML_TYPE_BOOL|MID_FLAG_DEFAULT_ITEM_EXPORT, 0 ),
+	
 	PLMAP( "UserDefinedAttributes",	XML_NAMESPACE_TEXT,		XML_XMLNS,						XML_TYPE_ATTRIBUTE_CONTAINER | MID_FLAG_SPECIAL_ITEM, 0 ),
 
 // footnote
--- xmloff/source/style/XMLPageExport.cxx.orig	2007-04-06 11:11:43.000000000 +0800
+++ xmloff/source/style/XMLPageExport.cxx	2007-04-06 11:13:30.000000000 +0800
@@ -280,3 +280,29 @@ void XMLPageExport::exportAutoStyles()
 		rExport.GetNamespaceMap()
         );
 }
+
+void XMLPageExport::exportDefaultStyle()
+{
+	Reference < lang::XMultiServiceFactory > xFactory (GetExport().GetModel(), UNO_QUERY);
+	if (xFactory.is())
+	{
+		OUString sTextDefaults ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.Defaults" ) );
+		Reference < XPropertySet > xPropSet (xFactory->createInstance ( sTextDefaults ), UNO_QUERY);
+		if (xPropSet.is())
+		{
+			// <style:default-style ...>
+			GetExport().CheckAttrList();
+
+			//<style:default-page-layout>
+			SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
+									  XML_DEFAULT_PAGE_LAYOUT,
+									  sal_True, sal_True );
+
+			//
+			::std::vector< XMLPropertyState > xPropStates =
+				xPageMasterExportPropMapper->FilterDefaults( xPropSet );
+			xPageMasterExportPropMapper->exportXML( GetExport(), xPropStates,
+								   	  XML_EXPORT_FLAG_IGN_WS );
+		}
+	}
+}
--- xmloff/source/style/xmlstyle.cxx.orig	2007-04-06 11:11:53.000000000 +0800
+++ xmloff/source/style/xmlstyle.cxx	2007-04-06 11:14:04.000000000 +0800
@@ -175,6 +175,7 @@ static __FAR_DATA SvXMLTokenMapEntry aSt
 	{ XML_NAMESPACE_TEXT,	XML_NOTES_CONFIGURATION,    XML_TOK_TEXT_NOTE_CONFIG },
 	{ XML_NAMESPACE_TEXT,	XML_BIBLIOGRAPHY_CONFIGURATION, XML_TOK_TEXT_BIBLIOGRAPHY_CONFIG },
 	{ XML_NAMESPACE_TEXT,   XML_LINENUMBERING_CONFIGURATION,XML_TOK_TEXT_LINENUMBERING_CONFIG },
+	{ XML_NAMESPACE_STYLE,	XML_DEFAULT_PAGE_LAYOUT,	XML_TOK_STYLE_DEFAULT_PAGE_LAYOUT        },
 	XML_TOKEN_MAP_END
 };
 
@@ -546,9 +547,13 @@ SvXMLStyleContext *SvXMLStylesContext::C
 			}
 			break;
 			case XML_TOK_STYLE_PAGE_MASTER:
+			case XML_TOK_STYLE_DEFAULT_PAGE_LAYOUT:
 			{
+				//there is not page family in odf now, so I specify one for it
+				sal_Bool bDefaultStyle  = XML_TOK_STYLE_DEFAULT_PAGE_LAYOUT == nToken
+					? sal_True: sal_False;
 				pStyle = new PageStyleContext( GetImport(), p_nPrefix,
-													rLocalName, xAttrList, *this );
+													rLocalName, xAttrList, *this, bDefaultStyle );
 			}
 			break;
 			case XML_TOK_TEXT_LIST_STYLE:
