--- sw/source/ui/inc/conttree.hxx	2006-12-20 22:03:30.000000000 +0800
+++ sw/source/ui/inc/conttree.hxx	2007-03-14 17:17:13.000000000 +0800
@@ -43,6 +43,9 @@
 #include "swcont.hxx"
 #endif
 
+#include<map>
+//using namespace std;
+
 class SwWrtShell;
 class SwContentType;
 class SwNavigationPI;
@@ -80,6 +83,8 @@
 	SwWrtShell* 		pActiveShell;   // die aktive oder eine konst. offene View
 	SwNavigationConfig*	pConfig;
 
+    std::map< void*, sal_Bool > mOutLineNodeMap;
+
     sal_Int32           nActiveBlock;
 	USHORT				nHiddenBlock;
 	USHORT 				nRootType;
--- sw/source/ui/utlui/content.cxx	2007-02-25 14:37:53.000000000 +0800
+++ sw/source/ui/utlui/content.cxx	2007-03-16 10:17:02.000000000 +0800
@@ -1262,8 +1262,10 @@
                         if(!sEntry.Len())
                             sEntry = sSpace;
                         if(!pChild || (nLevel == 0))
+                        {
                             pChild = InsertEntry(sEntry, pParent,
                                         sal_False, LIST_APPEND,(void*)pCnt);
+                        }
                         else
                         {
                             //back search parent.
@@ -1314,7 +1316,8 @@
 
 sal_Bool  SwContentTree::Expand( SvLBoxEntry* pParent )
 {
-	if(!bIsRoot || ((SwContentType*)pParent->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE)
+	if(!bIsRoot || (((SwContentType*)pParent->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE) || 
+            (nRootType == CONTENT_TYPE_OUTLINE))
 	{
 		if(lcl_IsContentType(pParent))
 		{
@@ -1329,18 +1332,39 @@
 				nHiddenBlock |= nOr;
             if((pCntType->GetType() == CONTENT_TYPE_OUTLINE))
             {
+                std::map< void*, sal_Bool > mCurrOutLineNodeMap;
+
+                SwWrtShell* pShell = GetWrtShell();
                 sal_Bool bBool = SvTreeListBox::Expand(pParent);
                 SvLBoxEntry* pChild = Next(pParent);
                 while(pChild && lcl_IsContent(pChild) && pParent->HasChilds())
                 {
                     if(pChild->HasChilds())
-                        SvTreeListBox::Expand(pChild);
+                    {
+                        sal_Int32 nPos = ((SwContent*)pChild->GetUserData())->GetYPos();
+                        void* key = (void*)pShell->GetOutlineNode( nPos );
+                        mCurrOutLineNodeMap.insert(std::map<void*, sal_Bool>::value_type( key, sal_False ) );
+                        std::map<void*,sal_Bool>::iterator iter = mOutLineNodeMap.find( key );
+                        if( iter != mOutLineNodeMap.end() && mOutLineNodeMap[key])
+                        {
+                            mCurrOutLineNodeMap[key] = sal_True;
+                            SvTreeListBox::Expand(pChild);
+                        }
+                    }
                     pChild = Next(pChild);
                 }
+                mOutLineNodeMap = mCurrOutLineNodeMap;
                 return bBool;
             }
 
 		}
+        else if( lcl_IsContent(pParent) )
+        {
+            SwWrtShell* pShell = GetWrtShell();
+            sal_Int32 nPos = ((SwContent*)pParent->GetUserData())->GetYPos();
+            void* key = (void*)pShell->GetOutlineNode( nPos );
+            mOutLineNodeMap[key] = sal_True;
+        }
 	}
 	return SvTreeListBox::Expand(pParent);
 }
@@ -1352,7 +1376,8 @@
 sal_Bool  SwContentTree::Collapse( SvLBoxEntry* pParent )
 {
 	sal_Bool bRet;
-	if(!bIsRoot || ((SwContentType*)pParent->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE)
+	if(!bIsRoot || (((SwContentType*)pParent->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE) || 
+            (nRootType == CONTENT_TYPE_OUTLINE))
 	{
 		if(lcl_IsContentType(pParent))
 		{
@@ -1369,6 +1394,13 @@
 			else
 				nHiddenBlock &= nAnd;
 		}
+        else if( lcl_IsContent(pParent) )
+        {
+            SwWrtShell* pShell = GetWrtShell();
+            sal_Int32 nPos = ((SwContent*)pParent->GetUserData())->GetYPos();
+            void* key = (void*)pShell->GetOutlineNode( nPos );
+            mOutLineNodeMap[key] = sal_False;
+        }
 			bRet = SvTreeListBox::Collapse(pParent);
 	}
 	else
