[Libreoffice-commits] core.git: sw/source

Jian Hong Cheng chengjh at apache.org
Wed Jun 5 03:13:52 PDT 2013


 sw/source/core/fields/chpfld.cxx |   39 +++++++++++++++++++++++++++++----------
 1 file changed, 29 insertions(+), 10 deletions(-)

New commits:
commit 6319803762d051c4aa645692cde7245a1bbcf7ee
Author: Jian Hong Cheng <chengjh at apache.org>
Date:   Wed Sep 12 04:50:38 2012 +0000

    Resolves: #i120759# Bookmark value changed when opening the doc file
    
    * sw/source/core/fields/chpfld.cxx
    MS Word Binary compatibility
    
    Patch by: Fan Zheng,<zheng.easyfan at gmail.com>
    Found by: dongjun zong,<zongdj001 at gmail.com>
    Review by: Jian Hong Cheng,<chengjh at apache.org>
    
    (cherry picked from commit 6b6ccbcac76eb416b4ece896714d20280761598b)
    
    Change-Id: I42461863f7e880f7b9387ca08ce66fb3dad938a0

diff --git a/sw/source/core/fields/chpfld.cxx b/sw/source/core/fields/chpfld.cxx
index 1af94f7..955fb71 100644
--- a/sw/source/core/fields/chpfld.cxx
+++ b/sw/source/core/fields/chpfld.cxx
@@ -112,6 +112,35 @@ void SwChapterField::ChangeExpansion(const SwFrm* pFrm,
 
 void SwChapterField::ChangeExpansion(const SwTxtNode &rTxtNd, sal_Bool bSrchNum)
 {
+    //i120759,this function is for both the reference chapter field and normal chapter field
+    //bSrchNum can distinguish the two types,to the latter type,the outline num rule is must...
+    sNumber = aEmptyStr;
+    sTitle = aEmptyStr;
+    sPost = aEmptyStr;
+    sPre = aEmptyStr;
+    //The reference chapter field of normal num rule will be handled in this code segment
+    if (bSrchNum && !rTxtNd.IsOutline())
+    {
+        SwNumRule* pRule(rTxtNd.GetNumRule());
+        if (rTxtNd.IsCountedInList() && pRule)
+        {
+            sNumber = rTxtNd.GetNumString(false);
+            const SwNumFmt& rNFmt = pRule->Get(static_cast<unsigned short>(rTxtNd.GetActualListLevel()));
+            sPost = rNFmt.GetSuffix();
+            sPre = rNFmt.GetPrefix();
+        }
+        else
+        {
+            sNumber = String("??", RTL_TEXTENCODING_ASCII_US);
+        }
+        sTitle = rTxtNd.GetExpandTxt();
+
+        for( xub_StrLen i = 0; i < sTitle.Len(); ++i )
+            if( ' ' > sTitle.GetChar( i ) )
+                sTitle.Erase( i--, 1 );
+    }else
+    {
+    //End
     SwDoc* pDoc = (SwDoc*)rTxtNd.GetDoc();
     const SwTxtNode *pTxtNd = rTxtNd.FindOutlineNodeOfLevel( nLevel );
     if( pTxtNd )
@@ -162,13 +191,9 @@ void SwChapterField::ChangeExpansion(const SwTxtNode &rTxtNd, sal_Bool bSrchNum)
                 sPost = rNFmt.GetSuffix();
                 sPre = rNFmt.GetPrefix();
             }
-            else
-                sPost = aEmptyStr, sPre = aEmptyStr;
         }
         else
         {
-            sPost = aEmptyStr;
-            sPre = aEmptyStr;
             sNumber = String("??", RTL_TEXTENCODING_ASCII_US);
         }
 
@@ -178,12 +203,6 @@ void SwChapterField::ChangeExpansion(const SwTxtNode &rTxtNd, sal_Bool bSrchNum)
             if( ' ' > sTitle.GetChar( i ) )
                 sTitle.Erase( i--, 1 );
     }
-    else
-    {
-        sNumber = aEmptyStr;
-        sTitle = aEmptyStr;
-        sPost = aEmptyStr;
-        sPre = aEmptyStr;
     }
 }
 


More information about the Libreoffice-commits mailing list