Index: /home/exo/java/projects/xwiki/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
===================================================================
--- /home/exo/java/projects/xwiki/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java	(revision 1070)
+++ /home/exo/java/projects/xwiki/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java	(working copy)
@@ -41,6 +41,7 @@
 import com.xpn.xwiki.util.Util;
 import com.xpn.xwiki.web.EditForm;
 import com.xpn.xwiki.web.ObjectAddForm;
+import com.xpn.xwiki.web.PrepareEditForm;
 import com.xpn.xwiki.web.Utils;
 import org.apache.commons.jrcs.diff.Diff;
 import org.apache.commons.jrcs.diff.DifferentiationFailedException;
@@ -132,6 +133,9 @@
 
     private XWikiStoreInterface store;
 
+    private Vector sections = new Vector();
+    private int sectionID_ = 0 ;
+
     public XWikiStoreInterface getStore() {
         return store;
     }
@@ -319,10 +323,10 @@
     public void setTitle(String title) {
         if (title == null)
             title = "";
+        this.title = title;
         if (!title.equals(this.title)) {
-            setContentDirty(true);
+            setMetaDataDirty(true);
         }
-        this.title = title;
     }
 
     public String getFormat() {
@@ -700,20 +704,14 @@
     }
 
     public Vector getObjects(String classname) {
-        if (classname.indexOf(".")==-1)
-         classname = "XWiki." + classname;
         return (Vector) getxWikiObjects().get(classname);
     }
 
     public void setObjects(String classname, Vector objects) {
-        if (classname.indexOf(".")==-1)
-         classname = "XWiki." + classname;
         getxWikiObjects().put(classname, objects);
     }
 
     public BaseObject getObject(String classname) {
-        if (classname.indexOf(".")==-1)
-         classname = "XWiki." + classname;
         Vector objects = (Vector) getxWikiObjects().get(classname);
         if (objects == null)
             return null;
@@ -727,8 +725,6 @@
 
     public BaseObject getObject(String classname, int nb) {
         try {
-            if (classname.indexOf(".")==-1)
-             classname = "XWiki." + classname;
             return (BaseObject) ((Vector) getxWikiObjects().get(classname)).get(nb);
         } catch (Exception e) {
             return null;
@@ -740,8 +736,6 @@
     }
 
     public BaseObject getObject(String classname, String key, String value, boolean failover) {
-        if (classname.indexOf(".")==-1)
-         classname = "XWiki." + classname;
         try {
             if (value == null) {
                 if (failover)
@@ -1143,7 +1137,7 @@
     }
     */
 
-    public void readFromTemplate(EditForm eform, XWikiContext context) throws XWikiException {
+    public void readFromTemplate(PrepareEditForm eform, XWikiContext context) throws XWikiException {
         String template = eform.getTemplate();
         readFromTemplate(template, context);
     }
@@ -1471,7 +1465,7 @@
         el = new DOMElement("version");
         el.addText(getVersion());
         docel.add(el);
-        
+
         el = new DOMElement("title");
         el.addText(getTitle());
         docel.add(el);
@@ -1492,7 +1486,7 @@
             if (bclass.getFieldList().size() > 0) {
                 docel.add(bclass.toXML(null));
             }
-            
+
             // Add Objects
             Iterator it = getxWikiObjects().values().iterator();
             while (it.hasNext()) {
@@ -1733,7 +1727,7 @@
                 context.setDatabase(getDatabase());
             try{
                context.getWiki().getAttachmentStore().deleteXWikiAttachment(attachment, context, true);
-            }catch(java.lang.OutOfMemoryError e){                
+            }catch(java.lang.OutOfMemoryError e){
                 throw new XWikiException(XWikiException.MODULE_XWIKI_APP,
                     XWikiException.ERROR_XWIKI_APP_JAVA_HEAP_SPACE,
                     "Out Of Memory Exception");
@@ -2522,4 +2516,125 @@
         return context.getUser().equals(getFullName());
     }
 
+    public void setSplitSections(String[] sections_){
+        sections.add(sections_);
+    }
+
+    public String[] getSplitSections(int index) {
+        return (String[])sections.get(index-1);
+    }
+
+    public Vector getSplisSections(){
+        return sections ;
+    }
+
+    public void removeSections(){
+        sections.removeAllElements();
+    }
+    // return content of section
+    public String mergeSections(int idSection) {
+        Vector vt = getSplisSections();
+        int indexEnd = 0 ;
+        // paramater of section
+        String[] obSection = (String[]) vt.get(idSection-1);
+        int indexStart = Integer.parseInt(obSection[1].trim());
+        String level = obSection[2];
+        int dot = level.indexOf(".");
+        for(int i = idSection ;i<vt.size() ;i++){
+            String[] sectionNext =(String[]) vt.get(i);
+            String levelNext = sectionNext[2];
+            if( i != vt.size() ){
+
+                if(dot == -1 ){
+                    if(levelNext.indexOf(".") == -1){
+                        indexEnd = Integer.parseInt(sectionNext[1].trim());
+                        break ;
+                    }
+                }else{
+                    indexEnd = Integer.parseInt(sectionNext[1].trim());
+                    break;
+                }
+
+            }else{
+                indexEnd = 0;
+            }
+        }
+        String sectionContent = null;
+
+        if(indexStart < 0){
+               indexStart = 0;
+        }
+       if(indexEnd == 0)
+          sectionContent = getContent().substring(indexStart);
+        else
+          sectionContent = getContent().substring(indexStart,indexEnd);
+
+
+
+        return sectionContent;
+    }
+
+    public int getSection() {
+        return sectionID_;
+    }
+
+    public void setSection(int idSection){
+      this.sectionID_ = idSection;
+    }
+
+    public int getIndexContentSection(int idSection){
+       String[] obSection =  getSplitSections(idSection);
+       return Integer.parseInt(obSection[1].trim());
+
+    }
+
+    public String getTitleSection(int idSection){
+        String[] obSection = getSplitSections(idSection);
+        return obSection[3];
+    }
+
+    public String updateSection(int idSection , String newcontent) {
+        int secIndex = getIndexContentSection(idSection);
+        if(secIndex < 0 ) secIndex = 0;
+        if(idSection == sections.size() && idSection != 1){
+            String contentBegin = getContent().substring(0,secIndex);
+            return contentBegin+newcontent;
+        }else if(sections.size() == 1) {
+            return newcontent;
+        }else {
+            Vector vt = getSplisSections();
+            String[] obSection = (String[]) vt.get(idSection-1);
+            String levelSection = obSection[2];
+            int dot = levelSection.indexOf(".");
+            int indexNext = 0;
+
+            for(int i =idSection ; i<vt.size(); i++){
+                String[] ob = (String[])vt.get(i);
+                String level = ob[2];
+                if( dot == -1 ){
+
+                    if(level.indexOf(".") == -1 ){
+                        indexNext = Integer.parseInt(ob[1].trim());
+                        break;
+                    }
+                }else{
+                    indexNext = Integer.parseInt(ob[1].trim());
+                    break;
+                }
+            }
+            if(indexNext == 0){
+              return content.substring(0,secIndex) + newcontent;
+            }else if(idSection == 1){
+                String contentAfter = getContent().substring(indexNext);
+                return newcontent+contentAfter;
+            }else{
+              String contentAfter = getContent().substring(indexNext);
+              String contentBegin = getContent().substring(0,secIndex);
+              return  contentBegin + newcontent+contentAfter;
+            }
+
+        }
+
+    }
+
 }
