Author: chengjh
Date: Fri Aug 24 03:28:19 2012
New Revision: 1376818

URL: http://svn.apache.org/viewvc?rev=1376818&view=rev
Log:
Fix issue #i119405: Numbering text style changed after importing the *.doc

* main/sw/inc/doc.hxx
* main/sw/inc/IDocumentContentOperations.hxx
* main/sw/inc/ndtxt.hxx
* main/sw/source/core/doc/docfmt.cxx
* main/sw/source/core/txtnode/thints.cxx
* main/sw/source/filter/inc/fltshell.hxx
* main/sw/source/filter/ww1/fltshell.cxx
* main/sw/source/filter/ww8/ww8par.cxx
* main/sw/source/filter/ww8/ww8par.hxx
* main/sw/source/filter/ww8/ww8par3.cxx
   MS Word Binary compatibility

Patch by: Fan Zheng,<zheng.easy...@gmail.com>
Found by: Jian Hong Cheng,<chen...@apache.org>
Review by: Jian Hong Cheng,<chen...@apache.org>

Modified:
    incubator/ooo/trunk/main/sw/inc/IDocumentContentOperations.hxx
    incubator/ooo/trunk/main/sw/inc/doc.hxx
    incubator/ooo/trunk/main/sw/inc/ndtxt.hxx
    incubator/ooo/trunk/main/sw/source/core/doc/docfmt.cxx
    incubator/ooo/trunk/main/sw/source/core/txtnode/thints.cxx
    incubator/ooo/trunk/main/sw/source/filter/inc/fltshell.hxx
    incubator/ooo/trunk/main/sw/source/filter/ww1/fltshell.cxx
    incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par.cxx
    incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par.hxx
    incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par3.cxx

Modified: incubator/ooo/trunk/main/sw/inc/IDocumentContentOperations.hxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/inc/IDocumentContentOperations.hxx?rev=1376818&r1=1376817&r2=1376818&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/inc/IDocumentContentOperations.hxx (original)
+++ incubator/ooo/trunk/main/sw/inc/IDocumentContentOperations.hxx Fri Aug 24 
03:28:19 2012
@@ -179,8 +179,11 @@
         hinzugefuegt.  Wenn das Attribut nicht eingefuegt werden
         konnte, liefert die Methode sal_False.
        */
+       //Modify here for #119405, by chengjh, 2012-08-16
+       //Add a para for the char attribute exp...
     virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&,
-                                const sal_uInt16 nFlags) = 0;
+                                const sal_uInt16 nFlags,bool 
bExpandCharToPara=false) = 0;
+       //End
 
     /**
     */

Modified: incubator/ooo/trunk/main/sw/inc/doc.hxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/inc/doc.hxx?rev=1376818&r1=1376817&r2=1376818&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/inc/doc.hxx (original)
+++ incubator/ooo/trunk/main/sw/inc/doc.hxx Fri Aug 24 03:28:19 2012
@@ -881,8 +881,11 @@ public:
     virtual SwDrawFrmFmt* Insert(const SwPaM &rRg, SdrObject& rDrawObj, const 
SfxItemSet* pFlyAttrSet, SwFrmFmt*);
     virtual SwFlyFrmFmt* Insert(const SwPaM &rRg, const 
svt::EmbeddedObjectRef& xObj, const SfxItemSet* pFlyAttrSet,
                                                const SfxItemSet* pGrfAttrSet, 
SwFrmFmt*);
+       //Modify here for #119405, by chengjh, 2012-08-16
+       //Add a para for the char attribute exp...
     virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&,
-                                const SetAttrMode nFlags);
+                                const SetAttrMode nFlags,bool 
bExpandCharToPara=false);
+       //End
     virtual bool InsertItemSet (const SwPaM &rRg, const SfxItemSet&,
                                 const SetAttrMode nFlags);
        virtual void ReRead(SwPaM&, const String& rGrfName, const String& 
rFltName, const Graphic* pGraphic, const GraphicObject* pGrfObj);

Modified: incubator/ooo/trunk/main/sw/inc/ndtxt.hxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/inc/ndtxt.hxx?rev=1376818&r1=1376817&r2=1376818&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/inc/ndtxt.hxx (original)
+++ incubator/ooo/trunk/main/sw/inc/ndtxt.hxx Fri Aug 24 03:28:19 2012
@@ -216,6 +216,9 @@ public:
     // SMARTTAGS
     void SetSmartTags( SwWrongList* pNew, bool bDelete = true );
     SwWrongList* GetSmartTags();
+       //Modify here for #119405, by easyfan, 2012-05-24
+       bool TryCharSetExpandToNum(const SfxItemSet& pCharSet);
+       //End of modification, by easyfan
 
     //
     // End: Data collected during idle time

Modified: incubator/ooo/trunk/main/sw/source/core/doc/docfmt.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/doc/docfmt.cxx?rev=1376818&r1=1376817&r2=1376818&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/doc/docfmt.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/doc/docfmt.cxx Fri Aug 24 03:28:19 
2012
@@ -551,7 +551,9 @@ void SwDoc::ResetAttrs( const SwPaM &rRg
 
 static bool
 lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet,
-            const SetAttrMode nFlags, SwUndoAttr *const pUndo)
+//Modify here for #119405, by easyfan, 2012-05-24
+            const SetAttrMode nFlags, SwUndoAttr *const pUndo,bool 
bExpandCharToPara=false)
+//End of modification, by easyfan
 {
        // teil die Sets auf (fuer Selektion in Nodes)
     const SfxItemSet* pCharSet = 0;
@@ -964,6 +966,26 @@ lcl_InsAttr(SwDoc *const pDoc, const SwP
                        // lediglich Selektion in einem Node.
                        if( pStt->nNode == pEnd->nNode )
             {
+                       //Modify here for #119405, by easyfan, 2012-05-24
+                       //The data parameter flag: bExpandCharToPara, comes 
from the data member of SwDoc,
+                       //Which is set in SW MS word Binary filter 
WW8ImplRreader. With this flag on, means that 
+                       //current setting attribute set is a character range 
properties set and comes from a MS word 
+                       //binary file, And the setting range include a 
paragraph end position (0X0D);
+                       //More specifications, as such property inside the 
character range properties set recorded in
+                       //MS word binary file are dealed and inserted into data 
model (SwDoc) one by one, so we 
+                       //only dealing the scenario that the char properties 
set with 1 item inside;
+                       
+                       if (bExpandCharToPara && pCharSet && pCharSet->Count() 
==1 )
+                       {
+                               SwTxtNode* pCurrentNd = 
pStt->nNode.GetNode().GetTxtNode();
+                               
+                               if (pCurrentNd)
+                               {
+                                       
pCurrentNd->TryCharSetExpandToNum(*pCharSet);
+                                               
+                               }
+                       }
+                       //End of modification, by easyfan
                 DELETECHARSETS
                 return bRet;
             }
@@ -1067,13 +1089,45 @@ lcl_InsAttr(SwDoc *const pDoc, const SwP
                ++nNodes;
        }
 
+       //Modify here for #119405, by easyfan, 2012-05-24
+       //The data parameter flag: bExpandCharToPara, comes from the data 
member of SwDoc,
+       //Which is set in SW MS word Binary filter WW8ImplRreader. With this 
flag on, means that 
+       //current setting attribute set is a character range properties set and 
comes from a MS word 
+       //binary file, And the setting range include a paragraph end position 
(0X0D);
+       //More specifications, as such property inside the character range 
properties set recorded in
+       //MS word binary file are dealed and inserted into data model (SwDoc) 
one by one, so we 
+       //only dealing the scenario that the char properties set with 1 item 
inside;
+       if (bExpandCharToPara && pCharSet && pCharSet->Count() ==1)
+       {
+               SwPosition aStartPos (*rRg.Start());
+               SwPosition aEndPos (*rRg.End());
+
+               if (aEndPos.nNode.GetNode().GetTxtNode() && aEndPos.nContent != 
aEndPos.nNode.GetNode().GetTxtNode()->Len())
+                       aEndPos.nNode--;
+
+               for (;aStartPos<=aEndPos;aStartPos.nNode++)
+               {
+                       SwTxtNode* pCurrentNd = 
aStartPos.nNode.GetNode().GetTxtNode();
+                       
+                       if (pCurrentNd)
+                       {
+                               pCurrentNd->TryCharSetExpandToNum(*pCharSet);
+                                       
+                       }
+                               
+               }
+       }
+       //End of modification, by easyfan
+
     DELETECHARSETS
     return (nNodes != 0) || bRet;
 }
 
-
+//Modify here for #119405, by chengjh, 2012-08-16
+//Add a para for the char attribute exp...
 bool SwDoc::InsertPoolItem( const SwPaM &rRg, const SfxPoolItem &rHt,
-                            const SetAttrMode nFlags )
+                            const SetAttrMode nFlags, bool bExpandCharToPara)
+//End
 {
        SwDataChanged aTmp( rRg, 0 );
        SwUndoAttr* pUndoAttr = 0;
@@ -1085,7 +1139,9 @@ bool SwDoc::InsertPoolItem( const SwPaM 
 
        SfxItemSet aSet( GetAttrPool(), rHt.Which(), rHt.Which() );
        aSet.Put( rHt );
-    bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, pUndoAttr );
+       //Modify here for #119405, by easyfan, 2012-05-24       
+       bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, 
pUndoAttr,bExpandCharToPara );
+       //End of modification, by easyfan
 
     if (GetIDocumentUndoRedo().DoesUndo())
     {

Modified: incubator/ooo/trunk/main/sw/source/core/txtnode/thints.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/txtnode/thints.cxx?rev=1376818&r1=1376817&r2=1376818&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/txtnode/thints.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/txtnode/thints.cxx Fri Aug 24 
03:28:19 2012
@@ -1607,6 +1607,79 @@ void SwTxtNode::DelSoftHyph( const xub_S
        }
 }
 
+//Modify here for #119405, by easyfan, 2012-05-24
+//In MS Word, the font underline setting of the paragraph end position wont 
affect the formatting of numbering, so we ignore it
+bool lcl_IsIgnoredCharFmtForNumbering(const sal_uInt16 nWhich)
+{
+       return (nWhich ==  RES_CHRATR_UNDERLINE);
+}
+
+//In MS Word, following properties of the paragraph end position wont affect 
the formatting of bullets, so we ignore them:
+//Font underline;
+//Font Italic of Western, CJK and CTL;
+//Font Bold of Wertern, CJK and CTL;
+bool lcl_IsIgnoredCharFmtForBullets(const sal_uInt16 nWhich)
+{
+       return (nWhich ==  RES_CHRATR_UNDERLINE || nWhich ==  
RES_CHRATR_POSTURE || nWhich ==  RES_CHRATR_WEIGHT
+               || nWhich == RES_CHRATR_CJK_POSTURE || nWhich == 
RES_CHRATR_CJK_WEIGHT 
+               || nWhich == RES_CHRATR_CTL_POSTURE || nWhich == 
RES_CHRATR_CTL_WEIGHT);
+}
+
+//Condition for expanding char set to character style of specified number rule 
level:
+//The item inside the set should not conflict to any exist and non-default 
item inside paragraph properties set (SwCntntNode::SwPAttrSet);
+//The node should have applied a number rule;
+//The node should be counted in a list, if not, make it to be;
+//The item should not conflict to any exist and non-default item inside the 
character of specified number rule level;
+//The item should not be ignored depend on the exact number rule type;
+bool SwTxtNode::TryCharSetExpandToNum(const SfxItemSet& aCharSet)
+{      
+       bool bRet = false;      
+       SfxItemIter aIter( aCharSet );
+        const SfxPoolItem* pItem = aIter.FirstItem();
+        const sal_uInt16 nWhich = pItem->Which();
+       xub_StrLen nIdx = 0;
+
+       const SfxPoolItem& rInnerItem = GetAttr(nWhich,false);
+
+       if (!IsDefaultItem(&rInnerItem) &&  !IsInvalidItem(&rInnerItem))
+               return bRet;
+
+       if ( !IsInList() && GetNumRule() && GetListId().Len() > 0 )
+       {
+               return bRet;
+       }
+
+       SwNumRule* pCurrNum = GetNumRule(false);
+
+       int nLevel = GetActualListLevel();
+
+       if (nLevel != -1 && pCurrNum)
+       {
+               const SwNumFmt* pCurrNumFmt = 
pCurrNum->GetNumFmt(static_cast<sal_uInt16>(nLevel));
+               if (pCurrNumFmt)
+               {
+                       if (pCurrNumFmt->IsItemize() && 
lcl_IsIgnoredCharFmtForBullets(nWhich))
+                               return bRet;
+                       if (pCurrNumFmt->IsEnumeration() && 
lcl_IsIgnoredCharFmtForNumbering(nWhich))
+                               return bRet;
+                       SwCharFmt* pCurrCharFmt =pCurrNumFmt->GetCharFmt();
+
+                       if (pCurrCharFmt && 
pCurrCharFmt->GetItemState(nWhich,false) != SFX_ITEM_SET)
+                       {
+                               pCurrCharFmt->SetFmtAttr(*pItem);
+                               SwNumFmt aNewNumFmt(*pCurrNumFmt);
+                               aNewNumFmt.SetCharFmt(pCurrCharFmt);
+                               pCurrNum->Set(nLevel,aNewNumFmt);
+                               bRet = true;
+                       }
+               }
+       }
+
+       
+       return bRet;
+}
+//End of modification, by easyfan
+
 // setze diese Attribute am TextNode. Wird der gesamte Bereich umspannt,
 // dann setze sie nur im AutoAttrSet (SwCntntNode:: SetAttr)
 sal_Bool SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt,

Modified: incubator/ooo/trunk/main/sw/source/filter/inc/fltshell.hxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/inc/fltshell.hxx?rev=1376818&r1=1376817&r2=1376818&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/inc/fltshell.hxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/inc/fltshell.hxx Fri Aug 24 
03:28:19 2012
@@ -72,7 +72,12 @@ public:
        sal_Bool bLocked;
        sal_Bool bCopied;
        sal_Bool bConsumedByField;
-
+       //Modify here for #119405, by easyfan, 2012-05-24
+       sal_Int32 mnStartCP;
+       sal_Int32 mnEndCP; 
+       bool bIsParaEnd;
+       //End of modification, by easyfan
+ 
        SW_DLLPUBLIC SwFltStackEntry(const SwPosition & rStartPos, SfxPoolItem* 
pHt );
        SW_DLLPUBLIC SwFltStackEntry(const SwFltStackEntry& rEntry);
        SW_DLLPUBLIC ~SwFltStackEntry();
@@ -80,6 +85,17 @@ public:
        void SetStartPos(const SwPosition & rStartPos);
        SW_DLLPUBLIC void SetEndPos(  const SwPosition & rEndPos);
        SW_DLLPUBLIC sal_Bool MakeRegion(SwDoc* pDoc, SwPaM& rRegion, sal_Bool 
bCheck );    
+       //Modify here for #119405, by easyfan, 2012-05-24
+       void SetStartCP(sal_Int32 nCP) {mnStartCP = nCP;}
+       void SetEndCP(sal_Int32 nCP) {mnEndCP = nCP;}
+       sal_Int32 GetStartCP() const {return mnStartCP;}
+       sal_Int32 GetEndCP() const {return mnEndCP;}
+       //End of modification, by easyfan
+       //Modify here for #119405, by chengjh, 2012-08-16
+       bool IsAbleMakeRegion();
+       bool IsParaEnd(){ return bIsParaEnd;}
+       void SetIsParaEnd(bool bArg){ bIsParaEnd = bArg;}
+       //End
 };
 
 class SW_DLLPUBLIC SwFltControlStack
@@ -91,6 +107,11 @@ class SW_DLLPUBLIC SwFltControlStack
 
        sal_uLong nFieldFlags;
        KeyCode aEmptyKeyCode; // fuer Bookmarks
+//Modify for #119405 by chengjh, 2012-08-16
+private:
+       bool bHasSdOD;
+       bool bSdODChecked;      
+//End
 
 protected:
        SwDoc* pDoc;
@@ -98,6 +119,16 @@ protected:
 
        void MoveAttrs( const SwPosition&  rPos );
        virtual void SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* 
pEntry);
+       //Modify here for #119405, by easyfan, 2012-05-24
+       virtual sal_Int32 GetCurrAttrCP() const {return -1;}
+       virtual bool IsParaEndInCPs(sal_Int32 nStart,sal_Int32 nEnd,bool 
bSdOD=true) const {return false;}
+       //End of modification, by easyfan
+       //Modify for #119405 by chengjh, 2012-08-16
+       //Clear the para end position recorded in reader intermittently for the 
least impact on loading performance
+       virtual void ClearParaEndPosition(){};
+       virtual bool CheckSdOD(sal_Int32 nStart,sal_Int32 nEnd){return false;}
+       bool HasSdOD();
+       //End
 
 public:
        enum Flags

Modified: incubator/ooo/trunk/main/sw/source/filter/ww1/fltshell.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/ww1/fltshell.cxx?rev=1376818&r1=1376817&r2=1376818&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/ww1/fltshell.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/ww1/fltshell.cxx Fri Aug 24 
03:28:19 2012
@@ -89,7 +89,9 @@ static SwCntntNode* GetCntntNode(SwDoc* 
 // ------ Stack-Eintrag fuer die gesamten - Attribute vom Text -----------
 SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt 
) :
        nMkNode(rStartPos.nNode, -1),
-       nPtNode(nMkNode)
+       //Modify here for #119405, by easyfan, 2012-05-24
+       nPtNode(nMkNode),mnStartCP(-1),mnEndCP(-1),bIsParaEnd(false)
+       //End of modification, by easyfan
 {
        // Anfang vom Bereich merken
        nMkCntnt = rStartPos.nContent.GetIndex();
@@ -109,6 +111,11 @@ SwFltStackEntry::SwFltStackEntry(const S
        bOld    = rEntry.bOld;
        bLocked = bCopied = sal_True; // when rEntry were NOT bLocked we would 
never have been called
        bConsumedByField = rEntry.bConsumedByField;
+       //Modify here for #119405, by chengjh, 2012-08-16
+       mnStartCP= rEntry.mnStartCP;
+       mnEndCP = rEntry.mnEndCP;
+       bIsParaEnd = rEntry.bIsParaEnd;
+       //End
 }
 
 
@@ -130,21 +137,36 @@ void SwFltStackEntry::SetEndPos(const Sw
        nPtNode = rEndPos.nNode.GetIndex()-1;
        nPtCntnt = rEndPos.nContent.GetIndex();
 }
+//Modify here for #119405, by chengjh, 2012-08-16
+//The only position of 0x0D will not be able to make regin in the old logic
+//because it is beyond the length of para...need special consideration here.
+bool SwFltStackEntry::IsAbleMakeRegion()
+{
+        SwCntntNode *const pCntntNode(
+        SwNodeIndex(nMkNode, +1).GetNode().GetCntntNode());
+       if ((nMkNode.GetIndex() == nPtNode.GetIndex()) && (nMkCntnt == nPtCntnt)
+        && ((0 != nPtCntnt) || (pCntntNode && (0 != pCntntNode->Len())))
+        && ((RES_TXTATR_FIELD != pAttr->Which())
+        && !(bIsParaEnd && pCntntNode && pCntntNode->IsTxtNode() && 0 != 
pCntntNode->Len() )))
+       {
+               return false;
+       }
 
+       return true;
+}
+//End
 sal_Bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, sal_Bool 
bCheck )
 {
     // does this range actually contain something?
     // empty range is allowed if at start of empty paragraph
     // fields are special: never have range, so leave them
-    SwCntntNode *const pCntntNode(
-        SwNodeIndex(nMkNode, +1).GetNode().GetCntntNode());
-    if ((nMkNode.GetIndex() == nPtNode.GetIndex()) && (nMkCntnt == nPtCntnt)
-        && ((0 != nPtCntnt) || (pCntntNode && (0 != pCntntNode->Len())))
-        && (RES_TXTATR_FIELD != pAttr->Which()))
+       //Modify here for #119405, by chengjh, 2012-08-16
+       //Revised the code and move the code segment to defined function
+       if ( !IsAbleMakeRegion() )
        {
                return sal_False;
        }
-
+       //End
        // !!! Die Content-Indizies beziehen sich immer auf den Node !!!
        rRegion.GetPoint()->nNode = nMkNode.GetIndex() + 1;
        SwCntntNode* pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, 
sal_True);
@@ -170,6 +192,10 @@ sal_Bool SwFltStackEntry::MakeRegion(SwD
 
 SwFltControlStack::SwFltControlStack(SwDoc* pDo, sal_uLong nFieldFl)
        : nFieldFlags(nFieldFl), pDoc(pDo), bIsEndStack(false)
+       //Modify for #119405 by chengjh, 2012-08-16
+       ,bHasSdOD(true),bSdODChecked(false)
+       //End
+
 {
 }
 
@@ -223,6 +249,9 @@ void SwFltControlStack::MarkAllAttrsOld(
 void SwFltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem & 
rAttr )
 {
        SwFltStackEntry *pTmp = new SwFltStackEntry(rPos, rAttr.Clone() );
+       //Modify here for #119405, by easyfan, 2012-05-24
+       pTmp->SetStartCP(GetCurrAttrCP());
+       //End of modification, by easyfan
        sal_uInt16 nWhich = pTmp->pAttr->Which();
        SetAttr(rPos, nWhich);// Ende von evtl. gleichen Attributen auf dem 
Stack
                                                                // Setzen, 
damit sich die Attribute nicht auf
@@ -239,6 +268,16 @@ void SwFltControlStack::DeleteAndDestroy
            delete *aElement;
            maEntries.erase(aElement);
        }
+       //Modify for #119405 by chengjh, 2012-08-16
+       //Clear the para end position recorded in reader intermittently for the 
least impact on loading performance
+       //Because the attributes handled based on the unit of para
+       if ( Count() == 0 )
+       {
+               ClearParaEndPosition();
+               bHasSdOD = true;
+               bSdODChecked = false;
+       }
+       //End
 }
 
 // SwFltControlStack::StealAttr() loescht Attribute des angegebenen Typs vom 
Stack.
@@ -326,6 +365,9 @@ void SwFltControlStack::SetAttr(const Sw
                        if (bF) {
                                pEntry->bConsumedByField = consumedByField;
                                pEntry->SetEndPos(rPos);
+                               //Modify here for #119405, by easyfan, 
2012-05-24
+                               pEntry->SetEndCP(GetCurrAttrCP());
+                               //End of modification, by easyfan
                        }
                        continue;
                }
@@ -409,7 +451,33 @@ static sal_Bool IterateNumrulePiece( con
 
        return rTmpStart <= rTmpEnd;                                    // 
gueltig ?
 }
+//Modify for #119405 by chengjh, 2012-08-16
+//***This function will check whether there is existing individual attribute 
positon for 0x0D***/
+//The check will happen only once for a paragraph during loading
+bool SwFltControlStack::HasSdOD()
+{      
+       sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
+
+       SwFltStackEntry* pEntry = 0;
+
+       bool bRet = false;
+
+       for (sal_uInt16 i=0; i < nCnt; i++)
+       {
+               pEntry = (*this)[ i ];
+               if ( pEntry && pEntry->mnStartCP == pEntry->mnEndCP )
+               {
+                       if ( CheckSdOD(pEntry->mnStartCP,pEntry->mnEndCP) )
+                       {
+                               bRet = true;
+                               break;
+                       }
+               }
+       }
 
+       return bRet;
+}
+//End
 void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, 
SwFltStackEntry* pEntry)
 {
        SwPaM aRegion( rTmpPos );
@@ -593,10 +661,37 @@ void SwFltControlStack::SetAttrInDoc(con
                }
                break;
        default:
-               if (pEntry->MakeRegion(pDoc, aRegion, sal_False))
-        {
-            pDoc->InsertPoolItem(aRegion, *pEntry->pAttr, 0);
-        }
+               {
+                       //Modify here for #119405, by chengjh, 2012-08-16
+                       //Revised for more complex situations should be 
considered
+                       if ( !bSdODChecked )
+                       {
+                               bHasSdOD = HasSdOD();
+                               bSdODChecked = true;
+                       }
+                               sal_Int32 nStart = pEntry->GetStartCP();
+                               sal_Int32 nEnd = pEntry->GetEndCP();
+                               if (nStart != -1 && nEnd != -1 && nEnd >= 
nStart )                                      
+                               {
+                                       pEntry->SetIsParaEnd( 
IsParaEndInCPs(nStart,nEnd,bHasSdOD) );
+                               }
+                       //End
+                       if (pEntry->MakeRegion(pDoc, aRegion, sal_False))
+               {
+                               //Modify here for #119405, by easyfan, 
2012-05-24                       
+                               sal_Int32 nStart = pEntry->GetStartCP();
+                               sal_Int32 nEnd = pEntry->GetEndCP();
+                               //Refined 2012-08-16
+                               if (pEntry->IsParaEnd())
+                               {
+                                       pDoc->InsertPoolItem(aRegion, 
*pEntry->pAttr, 0,true);
+                               }else
+                               {
+                                       pDoc->InsertPoolItem(aRegion, 
*pEntry->pAttr, 0);
+                               }
+                               //End
+               }       
+               }
                break;
        }
 }

Modified: incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par.cxx?rev=1376818&r1=1376817&r2=1376818&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par.cxx Fri Aug 24 
03:28:19 2012
@@ -902,6 +902,30 @@ const SwNumFmt* SwWW8FltControlStack::Ge
     return pRet;
 }
 
+//Modify here for #119405, by easyfan, 2012-05-24
+sal_Int32 SwWW8FltControlStack::GetCurrAttrCP() const 
+{
+       return rReader.GetCurrAttrCP();
+}
+bool SwWW8FltControlStack::IsParaEndInCPs(sal_Int32 nStart,sal_Int32 nEnd,bool 
bSdOD) const 
+{
+       return rReader.IsParaEndInCPs(nStart,nEnd,bSdOD);
+}
+//End of modification, by easyfan
+//Modify for #119405 by chengjh, 2012-08-16
+//Clear the para end position recorded in reader intermittently for the least 
impact on loading performance
+void SwWW8FltControlStack::ClearParaEndPosition()
+{
+       if ( Count() != 0 )
+               return;
+
+       rReader.ClearParaEndPosition();
+}
+bool SwWW8FltControlStack::CheckSdOD(sal_Int32 nStart,sal_Int32 nEnd)
+{
+       return rReader.IsParaEndInCPs(nStart,nEnd);
+}
+//End
 void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
     SwFltStackEntry* pEntry)
 {
@@ -3010,7 +3034,38 @@ long SwWW8ImplReader::ReadTextAttr(WW8_C
 
     return nNext;
 }
-
+//Modify here for #119405, by easyfan, 2012-05-24
+//Revised 2012.8.16 for the complex attribute presentation of 0x0D in MS
+bool SwWW8ImplReader::IsParaEndInCPs(sal_Int32 nStart, sal_Int32 nEnd,bool 
bSdOD) const
+{
+       //Modify for #119405 by chengjh, 2012-08-16
+       //Revised for performance consideration
+       if (nStart == -1 || nEnd == -1 || nEnd < nStart )
+               return false;
+       
+       for (cp_vector::const_reverse_iterator aItr = maEndParaPos.rbegin(); 
aItr!= maEndParaPos.rend(); aItr++)
+       //End
+       {
+               //Revised 2012.8.16,to the 0x0D,the attribute will have two 
situations
+               //*********within***********exact******//
+               //*********but also sample with only left and the position of 
0x0d is the edge of the right side***********//
+               if ( bSdOD && ( (nStart < *aItr && nEnd > *aItr) || ( nStart == 
nEnd && *aItr == nStart)) )
+                       return true;
+               else if ( !bSdOD &&  (nStart < *aItr && nEnd >= *aItr) ) 
+                       return true;
+       }
+       
+       return false;
+}
+//End of modification, by easyfan
+//Modify for #119405 by chengjh, 2012-08-16
+//Clear the para end position recorded in reader intermittently for the least 
impact on loading performance
+void SwWW8ImplReader::ClearParaEndPosition()
+{
+       if ( maEndParaPos.size() > 0 )
+               maEndParaPos.clear();
+}
+//End
 void SwWW8ImplReader::ReadAttrs(WW8_CP& rNext, WW8_CP& rTxtPos, bool& 
rbStartLine)
 {
     if( rTxtPos >= rNext )
@@ -3018,6 +3073,9 @@ void SwWW8ImplReader::ReadAttrs(WW8_CP& 
 
         do
         {
+               //Modify here for #119405, by easyfan, 2012-05-24
+               maCurrAttrCP = rTxtPos;
+               //End of modification, by easyfan
             rNext = ReadTextAttr( rTxtPos, rbStartLine );
         }
         while( rTxtPos >= rNext );
@@ -3108,7 +3166,14 @@ bool SwWW8ImplReader::ReadText(long nSta
         // create a new txtnode and join the two paragraphs together
 
         if (bStartLine && !pPreviousNode) // Zeilenende
+               {
+                       //Modify here for #119405, by easyfan, 2012-05-24
+                       //We will record the CP of a paragraph end ('0x0D'), if 
current loading contents is from main stream;
+                       if (mbOnLoadingMain)
+                               maEndParaPos.push_back(l-1);
+                       //End of modification, by easyfan
             AppendTxtNode(*pPaM->GetPoint());
+               }
 
         if (pPreviousNode && bStartLine)
         {
@@ -3270,6 +3335,10 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uIn
       nIdctHint(0),
       bBidi(false),
       bReadTable(false)
+       //Modify here for #119405, by easyfan, 2012-05-24
+       ,maCurrAttrCP(-1),
+       mbOnLoadingMain(false)
+       //End of modification, by easyfan
 {
     pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
     nWantedVersion = nVersionPara;
@@ -4102,7 +4171,13 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8G
     }
     else //ordinary case
     {
+       //Modify here for #119405, by easyfan, 2012-05-24
+       mbOnLoadingMain = true;
+       //End of modification, by easyfan
         ReadText(0, pWwFib->ccpText, MAN_MAINTEXT);
+       //Modify here for #119405, by easyfan, 2012-05-24
+       mbOnLoadingMain = false;
+       //End of modification, by easyfan
     }
 
     ::SetProgressState(nProgress, mpDocShell);    // Update

Modified: incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par.hxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par.hxx?rev=1376818&r1=1376817&r2=1376818&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par.hxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par.hxx Fri Aug 24 
03:28:19 2012
@@ -235,6 +235,15 @@ private:
 protected:
     virtual void SetAttrInDoc(const SwPosition& rTmpPos,
         SwFltStackEntry* pEntry);
+       //Modify here for #119405, by easyfan, 2012-05-24
+       virtual sal_Int32 GetCurrAttrCP() const;
+       virtual bool IsParaEndInCPs(sal_Int32 nStart,sal_Int32 nEnd,bool 
bSdOD=true) const;
+       //End of modification, by easyfan
+       //Modify for #119405 by chengjh, 2012-08-16
+       //Clear the para end position recorded in reader intermittently for the 
least impact on loading performance
+       virtual void ClearParaEndPosition();
+       virtual bool CheckSdOD(sal_Int32 nStart,sal_Int32 nEnd);
+       //End
 
 public:
     SwWW8FltControlStack(SwDoc* pDo, sal_uLong nFieldFl, SwWW8ImplReader& 
rReader_ )
@@ -789,6 +798,10 @@ struct WW8PostProcessAttrsInfo
 //-----------------------------------------
 //            Storage-Reader
 //-----------------------------------------
+//Modify here for #119405, by easyfan, 2012-05-24
+typedef std::vector<WW8_CP> cp_vector;
+//End of modification, by easyfan
+
 class SwWW8ImplReader
 {
 private:
@@ -1091,6 +1104,11 @@ private:
     bool bReadTable;
     boost::shared_ptr<SwPaM> mpTableEndPaM;
 
+       //Modify here for #119405, by easyfan, 2012-05-24
+       cp_vector maEndParaPos;
+       WW8_CP maCurrAttrCP;
+       bool mbOnLoadingMain:1;
+       //End of modification, by easyfan
 //---------------------------------------------
 
     const SprmReadInfo& GetSprmReadInfo(sal_uInt16 nId) const;
@@ -1422,7 +1440,14 @@ public:     // eigentlich private, geht 
     sal_uInt16 GetToggleBiDiAttrFlags() const;
     void SetToggleAttrFlags(sal_uInt16 nFlags);
     void SetToggleBiDiAttrFlags(sal_uInt16 nFlags);
-
+       //Modify here for #119405, by easyfan, 2012-05-24
+       WW8_CP GetCurrAttrCP() const {return maCurrAttrCP;}
+       bool IsParaEndInCPs(sal_Int32 , sal_Int32,bool bSdOD=true) const;
+       //End of modification, by easyfan
+       //Modify for #119405 by chengjh, 2012-08-16
+       //Clear the para end position recorded in reader intermittently for the 
least impact on loading performance
+       void ClearParaEndPosition();
+       //End
 
     long Read_Ftn(WW8PLCFManResult* pRes);
     sal_uInt16 End_Ftn();

Modified: incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par3.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par3.cxx?rev=1376818&r1=1376817&r2=1376818&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par3.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/filter/ww8/ww8par3.cxx Fri Aug 24 
03:28:19 2012
@@ -1022,7 +1022,24 @@ void WW8ListManager::AdjustLVL( sal_uInt
         // Style an das NumFormat haengen
         //
         aNumFmt.SetCharFmt( pFmt );
-    }
+    }  
+       //Modify for #119405 by chengjh, 2012-08-16
+       //Ensure the default char fmt is initialized for any level of num ruler 
if no customized attr
+       else
+       {
+               SwCharFmt* pFmt = aNumFmt.GetCharFmt();
+               if ( !pFmt)
+               {
+                       String aName( sPrefix.Len() ? sPrefix : 
rNumRule.GetName() );
+                       (aName += 'z') += String::CreateFromInt32( nLevel );
+                       
+                       pFmt = rDoc.MakeCharFmt(aName, 
(SwCharFmt*)rDoc.GetDfltCharFmt());
+                       bNewCharFmtCreated = true;
+                       rCharFmt[ nLevel ] = pFmt;
+                       aNumFmt.SetCharFmt( pFmt );
+               }
+       }
+       //End
     //
     // ggfs. Bullet Font an das NumFormat haengen
     //


Reply via email to