Index: inc/tox.hxx =================================================================== --- inc/tox.hxx (revision 1346300) +++ inc/tox.hxx (working copy) @@ -501,6 +501,12 @@ sal_Bool bFromObjectNames : 1; // create a table or object index // from the names rather than the caption sal_Bool bLevelFromChapter : 1; // User index: get the level from the source chapter + //Modify here for i119963, by ZF, 2012-06-13 + //Add a data member, for record the TOC field expression of MS Word binary format + //For keeping fedality and may giving a better exporting performance + String maMSTOCExpression; + //End of modification, by ZF + public: SwTOXBase( const SwTOXType* pTyp, const SwForm& rForm, sal_uInt16 nCreaType, const String& rTitle ); @@ -520,6 +526,13 @@ const String& GetTOXName() const {return aName;} void SetTOXName(const String& rSet) {aName = rSet;} + //Modify here for i119963, by ZF, 2012-06-13 + //Add a data member, for record the TOC field expression of MS Word binary format + //For keeping fedality and may giving a better exporting performance + const String& GetMSTOCExpression() {return maMSTOCExpression;} + void SetMSTOCExpression(const String& rExp) {maMSTOCExpression = rExp;} + //End of modification, by ZF + const String& GetTitle() const; // Title const String& GetTypeName() const; // Name const SwForm& GetTOXForm() const; // description of the lines Index: source/filter/ww8/ww8par.cxx =================================================================== --- source/filter/ww8/ww8par.cxx (revision 1346300) +++ source/filter/ww8/ww8par.cxx (working copy) @@ -3265,6 +3265,12 @@ nIdctHint(0), bBidi(false), bReadTable(false) + //Modify here for i119963, by ZF, 2012-06-13 + //Initialize 3 added data members + ,mbLoadingTOCCache(false) + ,mbLoadingTOCHyperlink(false) + ,mpPosAfterTOC(0) + //End of modifications, by ZF { pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); nWantedVersion = nVersionPara; Index: source/filter/ww8/ww8par.hxx =================================================================== --- source/filter/ww8/ww8par.hxx (revision 1346300) +++ source/filter/ww8/ww8par.hxx (working copy) @@ -1090,6 +1090,15 @@ bool bBidi; bool bReadTable; boost::shared_ptr mpTableEndPaM; + //Modify here for i119963, by ZF, 2012-06-13 + //Add 3 data members: + //mbLoadingTOCCache: Indicate that currently on loading a TOC, managed by Read_F_TOX() and End_Field() + //mbLoadingTOCHyperlink: Indicate that current on loading a hyperlink, which is inside a TOC; Managed by Read_F_Hyperlink() and End_Field() + //mpPosAfterTOC: a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field() + bool mbLoadingTOCCache; + bool mbLoadingTOCHyperlink; + SwPaM* mpPosAfterTOC; + //End of modifications, by ZF //--------------------------------------------- Index: source/filter/ww8/ww8par5.cxx =================================================================== --- source/filter/ww8/ww8par5.cxx (revision 1346300) +++ source/filter/ww8/ww8par5.cxx (working copy) @@ -320,7 +320,13 @@ //"_Toc*" and "_Hlt*" are unnecessary const String* pName = pB->GetName(); #if !defined(WW_NATIVE_TOC) - if( !pName || pName->EqualsIgnoreCaseAscii( "_Toc", 0, 4 ) + //Modify here for i119963, by ZF, 2012-06-13 + //Now, as we read the TOC field completely, we also need the hyperlinks inside keep available. + //So the hidden bookmarks inside for hyperlink jumping also should be kept. + //former codes: + //if( !pName || (pName->EqualsIgnoreCaseAscii( "_Toc", 0, 4 ) && maLinkSet.find(*pName)==maLinkSet.end()) + if( !pName + //End of modification, by ZF || pName->EqualsIgnoreCaseAscii( "_Hlt", 0, 4 ) ) return 0; #endif @@ -711,8 +717,38 @@ } break; #else + //Modify here for i119963, by ZF, 2012-06-13 + //Doing corresponding status management for TOC field, index field, hyperlink field and page reference field + case 13://TOX + case 8://index + if (mbLoadingTOCCache) + { + mbLoadingTOCCache = false; + if (pPaM->End() && pPaM->End()->nNode.GetNode().GetTxtNode() && pPaM->End()->nNode.GetNode().GetTxtNode()->Len() == 0) + JoinNode(*pPaM); + + if (mpPosAfterTOC) + { + *pPaM = *mpPosAfterTOC; + delete mpPosAfterTOC; + mpPosAfterTOC = 0; + } + } + break; + case 37://REF + if (mbLoadingTOCCache && !mbLoadingTOCHyperlink) + { + pCtrlStck->SetAttr(*pPaM->GetPoint(),RES_TXTATR_INETFMT); + } + break; + //End of modifications, by ZF case 88: + //Modify here for i119963, by ZF, 2012-06-13 + if (mbLoadingTOCHyperlink) + mbLoadingTOCHyperlink = false; + //End of modifications, by ZF pCtrlStck->SetAttr(*pPaM->GetPoint(),RES_TXTATR_INETFMT); + break; #endif case 36: @@ -732,10 +768,10 @@ { switch (nFieldCode) { -#if defined(WW_NATIVE_TOC) +//#if defined(WW_NATIVE_TOC) case 8: // allow recursive field in TOC... case 13: // allow recursive field in TOC... -#endif +//#endif case 36: case 68: case 79: @@ -2123,6 +2159,7 @@ case -2: if( !sOrigName.Len() ) sOrigName = aReadParam.GetResult(); + break; } } @@ -2138,8 +2175,33 @@ return FLD_TEXT; } #endif + //Modify here for i119963, by ZF, 2012-06-13 + //loading page reference field in TOC + if (mbLoadingTOCCache ) + { + //Step 1. Insert page ref representation as plain text + //Step 2. If there is no hyperlink settings for current toc, assign link to current ref area + if ( !mbLoadingTOCHyperlink) + { + String sURL,sTarget; + if( sName.Len() ) + ( sURL += INET_MARK_TOKEN ) += sName; + SwFmtINetFmt aURL( sURL, sTarget ); + String sLinkStyle = String::CreateFromAscii("Index Link"); + sal_uInt16 nPoolId = + SwStyleNameMapper::GetPoolIdFromUIName( sLinkStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); + aURL.SetVisitedFmt(sLinkStyle); + aURL.SetINetFmt(sLinkStyle); + aURL.SetVisitedFmtId(nPoolId); + aURL.SetINetFmtId(nPoolId); + pCtrlStck->NewAttr( *pPaM->GetPoint(), aURL ); + } + return FLD_TEXT; + } + //End of modifications, by ZF + SwGetRefField aFld( (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ), sName, REF_BOOKMARK, 0, REF_PAGE ); @@ -2840,6 +2902,9 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr ) { + //Modify here for i119963, by ZF, 2012-06-13 + mbLoadingTOCCache = true; + //End of modifications, by ZF #if defined(WW_NATIVE_TOC) if (1) { ::rtl::OUString aBookmarkName=::rtl::OUString::createFromAscii("_TOC"); @@ -3149,8 +3214,12 @@ */ } } - - if (bIsHyperlink) + //Modify here for i119963, by ZF, 2012-06-13 + //For loading the expression of TOC field, we need to mapping its parameters to TOX entries tokens + //also include the hyperlinks and page references + //Former codes: + /* + if (bIsHyperlink) { SwForm aForm(pBase->GetTOXForm()); sal_uInt16 nEnd = aForm.GetFormMax()-1; @@ -3171,7 +3240,42 @@ // <- #i21237# pBase->SetTOXForm(aForm); } + */ + SwFormToken aLinkStart(TOKEN_LINK_START); + SwFormToken aLinkEnd(TOKEN_LINK_END); + aLinkStart.sCharStyleName = String::CreateFromAscii("Index Link"); + aLinkEnd.sCharStyleName = String::CreateFromAscii("Index Link"); + SwForm aForm(pBase->GetTOXForm()); + sal_uInt16 nEnd = aForm.GetFormMax()-1; + + // -> #i21237# + for(sal_uInt16 nLevel = 1; nLevel <= nEnd; ++nLevel) + { + SwFormTokens aPattern = aForm.GetPattern(nLevel); + if (bIsHyperlink) + aPattern.insert(aPattern.begin(), aLinkStart); + else + { + for (SwFormTokens::iterator aItr = aPattern.begin();aItr!= aPattern.end();aItr++) + { + if (aItr->eTokenType == TOKEN_PAGE_NUMS) + { + aPattern.insert(aItr,aLinkStart); + break; + } + } + } + aPattern.push_back(aLinkEnd); + + aForm.SetPattern(nLevel, aPattern); + + } + + // <- #i21237# + pBase->SetTOXForm(aForm); + //End of modifications, by ZF + if (!nMaxLevel) nMaxLevel = WW8ListManager::nMaxLevel; pBase->SetLevel(nMaxLevel); @@ -3288,7 +3392,10 @@ } // ToxBase fertig // Update fuer TOX anstossen - rDoc.SetUpdateTOX(true); + //Modify here for i119963, by ZF, 2012-06-13 + //Commont out following TOC update statement, for the content inside TOC field was parsing directly from document + //rDoc.SetUpdateTOX(true); + //End of modification of TOC contents cacsh parsing improvement, by ZF // #i21237# // propagate tab stops from paragraph styles used in TOX to @@ -3327,13 +3434,29 @@ rDoc.InsertTableOf(*pPaM->GetPoint(), *aFltTOX.GetBase()); + //inserting a toc inserts a section before this point, so adjust pos //for future page/section segment insertion + //Modify here for i119963, by ZF, 2012-06-13 + //The TOC field representation contents should be inserted into TOC section, but not after TOC section. + //So we need update the document position when loading TOC representation and after loading TOC; + //Former codes: + /* SwPaM aRegion(*pPaM); aRegion.Move(fnMoveBackward); + */ + if (mpPosAfterTOC) + delete mpPosAfterTOC; + mpPosAfterTOC = new SwPaM(*pPaM); + (*pPaM).Move(fnMoveBackward); + SwPaM aRegion(*pPaM); + //End of modifications, by ZF ASSERT(rDoc.GetCurTOX(*aRegion.GetPoint()), "Misunderstood how toc works"); if (SwTOXBase* pBase2 = (SwTOXBase*)rDoc.GetCurTOX(*aRegion.GetPoint())) { + //Modify here for i119963, by ZF, 2012-06-13 + pBase2->SetMSTOCExpression(rStr); + //End of modification, by ZF if(nIndexCols>1) { // Set the column number for index @@ -3353,7 +3476,14 @@ if (!maApos.back()) //a para end in apo doesn't count bWasParaEnd = true; - return FLD_OK; + //Modify here for i119963, by ZF, 2012-06-13 + //Reture FLD_TEXT, instead of FLD_OK + //FLD_TEXT means the following content, commonly indicate the field representation content should be parsed + //FLD_OK means the current field loading is finished. The rest part should be ignored. + //Former codes: + //return FLD_OK; + //End of modifications, by ZF + return FLD_TEXT; } eF_ResT SwWW8ImplReader::Read_F_Shape(WW8FieldDesc* /*pF*/, String& /*rStr*/) @@ -3412,6 +3542,13 @@ if( sMark.Len() && '"' == sMark.GetChar( sMark.Len()-1 )) sMark.Erase( sMark.Len() - 1 ); + //Modify here for i119963, by ZF, 2012-06-13 + if (mbLoadingTOCCache) + { + mbLoadingTOCHyperlink = true;//on loading a TOC field nested hyperlink field + } + //End of modifications, by ZF + } break; case 't': @@ -3437,6 +3574,19 @@ ( sURL += INET_MARK_TOKEN ) += sMark; SwFmtINetFmt aURL( sURL, sTarget ); + //Modify here for i119963, by ZF, 2012-06-13 + //If on loading TOC field, change the default style into the "index link" + if (mbLoadingTOCCache) + { + String sLinkStyle = String::CreateFromAscii("Index Link"); + sal_uInt16 nPoolId = + SwStyleNameMapper::GetPoolIdFromUIName( sLinkStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); + aURL.SetVisitedFmt(sLinkStyle); + aURL.SetINetFmt(sLinkStyle); + aURL.SetVisitedFmtId(nPoolId); + aURL.SetINetFmtId(nPoolId); + } + //End of modifications, by ZF //As an attribute this needs to be closed, and that'll happen from //EndExtSprm in conjunction with the maFieldStack If there are are flyfrms Index: source/filter/ww8/ww8par6.cxx =================================================================== --- source/filter/ww8/ww8par6.cxx (revision 1346300) +++ source/filter/ww8/ww8par6.cxx (working copy) @@ -3828,6 +3828,17 @@ || pCollA[nId].bColl ) // oder Para-Style ? return; // dann ignorieren + //Modify here for i119963, by ZF, 2012-06-13 + //if current on loading a TOC field, and current trying to apply a hyperlink character style, + //just ignore. For the hyperlinks inside TOC in MS Word is not same with a common hyperlink + //Character styles: without underline and blue font color. And such type style will be applied in others + //processes. + if (mbLoadingTOCCache && pCollA[nId].GetWWStyleId() == ww::stiHyperlink) + { + return; + } + //End of modification, by ZF + NewAttr( SwFmtCharFmt( (SwCharFmt*)pCollA[nId].pFmt ) ); nCharFmt = (short) nId; }