Index: inc/tox.hxx =================================================================== --- inc/tox.hxx (revision 1346300) +++ inc/tox.hxx (working copy) @@ -501,6 +501,14 @@ 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 +protected: + //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; + sal_Bool mbKeepExpression; + //End of modification, by ZF + public: SwTOXBase( const SwTOXType* pTyp, const SwForm& rForm, sal_uInt16 nCreaType, const String& rTitle ); @@ -520,6 +528,15 @@ 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() const{return maMSTOCExpression;} + void SetMSTOCExpression(const String& rExp) {maMSTOCExpression = rExp;} + void EnableKeepExpression() {mbKeepExpression = sal_True;} + void DisableKeepExpression() {mbKeepExpression = sal_False;} + //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/core/doc/doctxm.cxx =================================================================== --- source/core/doc/doctxm.cxx (revision 1346300) +++ source/core/doc/doctxm.cxx (working copy) @@ -799,6 +799,11 @@ IsHiddenFlag() ) return; + //Modify here for i119963, by ZF, 2012-07-03 + if (!mbKeepExpression) + maMSTOCExpression = String(); + //End of modification, by ZF + SwDoc* pDoc = (SwDoc*)pSectNd->GetDoc(); DBG_ASSERT(pDoc != NULL, "Where is the document?"); Index: source/core/tox/tox.cxx =================================================================== --- source/core/tox/tox.cxx (revision 1346300) +++ source/core/tox/tox.cxx (working copy) @@ -521,6 +521,9 @@ bFromChapter(sal_False), bFromObjectNames(sal_False), bLevelFromChapter(sal_False) + //for i119963, by ZF, 2012-07-03 + ,mbKeepExpression(sal_True) + //End of modification { aData.nOptions = 0; } @@ -528,6 +531,9 @@ SwTOXBase::SwTOXBase( const SwTOXBase& rSource, SwDoc* pDoc ) : SwClient( rSource.GetRegisteredInNonConst() ) + //for i119963, by ZF, 2012-07-03 + ,mbKeepExpression(sal_True) + //End of modification { CopyTOXBase( pDoc, rSource ); } @@ -539,6 +545,9 @@ SwTOXBase& SwTOXBase::CopyTOXBase( SwDoc* pDoc, const SwTOXBase& rSource ) { + //for i119963, by ZF, 2012-07-03 + maMSTOCExpression = rSource.maMSTOCExpression; + //End of modification SwTOXType* pType = (SwTOXType*)rSource.GetTOXType(); if( pDoc && USHRT_MAX == pDoc->GetTOXTypes().GetPos( pType )) { Index: source/filter/ww8/attributeoutputbase.hxx =================================================================== --- source/filter/ww8/attributeoutputbase.hxx (revision 1346300) +++ source/filter/ww8/attributeoutputbase.hxx (working copy) @@ -187,8 +187,10 @@ void StartTOX( const SwSection& rSect ); - void EndTOX( const SwSection& rSect ); + void EndTOX( const SwSection& rSect,bool bCareEnd=true ); + virtual void OnTOXEnding() {} + virtual void TOXMark( const SwTxtNode& rNode, const SwTOXMark& rAttr ); /// Output redlining. Index: source/filter/ww8/dump/ww8scan.cxx =================================================================== --- source/filter/ww8/dump/ww8scan.cxx (revision 1346300) +++ source/filter/ww8/dump/ww8scan.cxx (working copy) @@ -3541,7 +3541,7 @@ return true; } -bool WW8PLCFx_FLD::EndPosIsFieldEnd() +bool WW8PLCFx_FLD::EndPosIsFieldEnd(WW8_CP& nCP) { bool bRet = false; @@ -3554,7 +3554,10 @@ void* pData; long nTest; if ( pPLCF->Get(nTest, pData) && ((((sal_uInt8*)pData)[0] & 0x1f) == 0x15) ) + { + nCP = nTest; bRet = true; + } pPLCF->SetIdx(n); } Index: source/filter/ww8/writerwordglue.cxx =================================================================== --- source/filter/ww8/writerwordglue.cxx (revision 1346300) +++ source/filter/ww8/writerwordglue.cxx (working copy) @@ -522,6 +522,10 @@ return true; if (nB == RES_TXTATR_CHARFMT) return false; + if (nA == RES_TXTATR_INETFMT) + return true; + if (nB == RES_TXTATR_INETFMT) + return false; return nA < nB; } Index: source/filter/ww8/wrtw8nds.cxx =================================================================== --- source/filter/ww8/wrtw8nds.cxx (revision 1346300) +++ source/filter/ww8/wrtw8nds.cxx (working copy) @@ -1955,7 +1955,7 @@ if ( pTOXSect ) { m_aCurrentCharPropStarts.pop(); - AttrOutput().EndTOX( *pTOXSect ); + AttrOutput().EndTOX( *pTOXSect ,false); } WriteCR( pTextNodeInfoInner ); } @@ -1993,6 +1993,7 @@ aAttrIter.OutFlys( nEnd ); // insert final bookmarks if any before CR and after flys AppendBookmarks( rNode, nEnd, 1 ); + WriteCR( pTextNodeInfoInner ); if ( pTOXSect ) { @@ -2000,7 +2001,7 @@ AttrOutput().EndTOX( *pTOXSect ); } - WriteCR( pTextNodeInfoInner ); + //WriteCR( pTextNodeInfoInner ); if ( bRedlineAtEnd ) { @@ -2523,7 +2524,8 @@ SwNodeIndex aIdx( rSectionNode, 1 ); const SwNode& rNd = aIdx.GetNode(); - if ( !rNd.IsSectionNode() && !IsInTable() ) //No sections in table + if ( !rNd.IsSectionNode() && !IsInTable() + && rSection.GetType() != TOX_CONTENT_SECTION && rSection.GetType() != TOX_HEADER_SECTION) //No sections in table { // Bug 74245 - if the first Node inside the section has an own // PageDesc or PageBreak attribut, then dont write Index: source/filter/ww8/wrtww8.cxx =================================================================== --- source/filter/ww8/wrtww8.cxx (revision 1346300) +++ source/filter/ww8/wrtww8.cxx (working copy) @@ -33,6 +33,9 @@ #include +#include +#include + #include #include // memcpy() #include @@ -186,7 +189,7 @@ WW8_FC GetStartFc() const { return nStartFc; } }; -class WW8_WrtBookmarks +/*class WW8_WrtBookmarks { private: SvULongs aSttCps, aEndCps; // Array of Start- and End CPs @@ -208,8 +211,144 @@ void MoveFieldMarks(sal_uLong nFrom,sal_uLong nTo); // String GetWWBkmkName( const String& rName ) const; +};*/ + +typedef std::map BKMKNames; +typedef BKMKNames::iterator BKMKNmItr; +typedef std::pair BKMK; +typedef std::pair BKMKCP; +typedef std::multimap BKMKCPs; +typedef BKMKCPs::iterator CPItr; + +class WW8_WrtBookmarks +{ +private: + BKMKCPs aSttCps,aEndCps; + BKMKNames maSwBkmkNms; + WW8_WrtBookmarks(const WW8_WrtBookmarks&); + WW8_WrtBookmarks& operator=(const WW8_WrtBookmarks&); +public: + WW8_WrtBookmarks(); + ~WW8_WrtBookmarks(); + void Append( WW8_CP nStartCp, const String& rNm, const ::sw::mark::IMark* pBkmk=NULL ); + void Write( WW8Export& rWrt ); + void MoveFieldMarks(sal_uLong nFrom,sal_uLong nTo); }; +WW8_WrtBookmarks::WW8_WrtBookmarks() +{} + +WW8_WrtBookmarks::~WW8_WrtBookmarks() +{ + CPItr aEnd = aSttCps.end(); + for (CPItr aItr = aSttCps.begin();aItr!=aEnd;aItr++) + { + if (aItr->second) + { + delete aItr->second; + aItr->second = NULL; + } + } +} + +void WW8_WrtBookmarks::Append( WW8_CP nStartCp, const String& rNm, const ::sw::mark::IMark*) +{ + std::pair aResult = maSwBkmkNms.insert(std::pair(rNm,0L)); + if (aResult.second) + { + BKMK aBK(false,rNm); + BKMKCP* pBKCP = new BKMKCP((long)nStartCp,aBK); + aSttCps.insert(std::pair(nStartCp,pBKCP)); + aResult.first->second = (long)nStartCp; + } + else + { + std::pair aRange = aSttCps.equal_range(aResult.first->second); + for (CPItr aItr = aRange.first;aItr != aRange.second;aItr++) + { + if (aItr->second && aItr->second->second.second == rNm) + { + if (aItr->second->second.first) + nStartCp--; + aItr->second->first = (long)nStartCp; + break; + } + } + } +} + +void WW8_WrtBookmarks::Write( WW8Export& rWrt) +{ + if (!aSttCps.size()) + return; + CPItr aItr; + long n; + std::vector aNames; + SvMemoryStream aTempStrm1(65535,65535); + SvMemoryStream aTempStrm2(65535,65535); + for (aItr = aSttCps.begin();aItr!=aSttCps.end();aItr++) + { + if (aItr->second) + { + aEndCps.insert(std::pair(aItr->second->first,aItr->second)); + aNames.push_back(aItr->second->second.second); + SwWW8Writer::WriteLong( aTempStrm1, aItr->first); + } + } + + aTempStrm1.Seek(0L); + for (aItr = aEndCps.begin(), n = 0;aItr != aEndCps.end();aItr++,n++) + { + if (aItr->second) + { + aItr->second->first = n; + SwWW8Writer::WriteLong( aTempStrm2, aItr->first); + } + } + + aTempStrm2.Seek(0L); + rWrt.WriteAsStringTable(aNames, rWrt.pFib->fcSttbfbkmk,rWrt.pFib->lcbSttbfbkmk); + SvStream& rStrm = rWrt.bWrtWW8 ? *rWrt.pTableStrm : rWrt.Strm(); + rWrt.pFib->fcPlcfbkf = rStrm.Tell(); + rStrm<ccpText + rWrt.pFib->ccpTxbx); + for (aItr = aSttCps.begin();aItr!=aSttCps.end();aItr++) + { + if (aItr->second) + { + SwWW8Writer::WriteLong(rStrm, aItr->second->first); + } + } + rWrt.pFib->lcbPlcfbkf = rStrm.Tell() - rWrt.pFib->fcPlcfbkf; + rWrt.pFib->fcPlcfbkl = rStrm.Tell(); + rStrm<ccpText + rWrt.pFib->ccpTxbx); + rWrt.pFib->lcbPlcfbkl = rStrm.Tell() - rWrt.pFib->fcPlcfbkl; +} + +void WW8_WrtBookmarks::MoveFieldMarks(sal_uLong nFrom,sal_uLong nTo) +{ + std::pair aRange = aSttCps.equal_range(nFrom); + CPItr aItr = aRange.first; + while (aItr != aRange.second) + { + if (aItr->second) + { + if (aItr->second->first == nFrom) + { + aItr->second->second.first = true; + aItr->second->first = nTo; + } + aSttCps.insert(std::pair(nTo,aItr->second)); + aItr->second = NULL; + aRange = aSttCps.equal_range(nFrom); + aItr = aRange.first; + continue; + } + aItr++; + } +} + #define ANZ_DEFAULT_STYLES 16 // die Namen der StorageStreams @@ -1255,7 +1394,7 @@ //-------------------------------------------------------------------------- /* */ -WW8_WrtBookmarks::WW8_WrtBookmarks() +/*WW8_WrtBookmarks::WW8_WrtBookmarks() : aSttCps( 0, 16 ), aEndCps( 0, 16 ) { } @@ -1380,7 +1519,7 @@ } } } -} +}*/ void WW8Export::AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, xub_StrLen nLen ) @@ -2535,7 +2674,8 @@ ; else if ( aIdx.GetNode().IsSectionNode() ) ; - else if ( !IsInTable() ) //No sections in table + else if ( !IsInTable() + && (rSect.GetType() != TOX_CONTENT_SECTION && rSect.GetType() != TOX_HEADER_SECTION )) //No sections in table { ReplaceCr( (char)0xc ); // Indikator fuer Page/Section-Break Index: source/filter/ww8/ww8atr.cxx =================================================================== --- source/filter/ww8/ww8atr.cxx (revision 1346300) +++ source/filter/ww8/ww8atr.cxx (working copy) @@ -957,7 +957,8 @@ void WW8AttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) { - m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->Count(), m_rWW8Export.pO->GetData() ); + m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell() - (mbOnTOXEnding?2:0), m_rWW8Export.pO->Count(), m_rWW8Export.pO->GetData() ); + mbOnTOXEnding = false; m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // delete if ( pTextNodeInfoInner.get() != NULL ) @@ -1001,6 +1002,11 @@ } } +void WW8AttributeOutput::OnTOXEnding() +{ + mbOnTOXEnding = true; +} + void WW8AttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData ) { Redline( pRedlineData ); @@ -2066,7 +2072,10 @@ static const sal_Char sEntryEnd[] = "\" "; ww::eField eCode = ww::eTOC; - String sStr; + //Modify here for i119963, by ZF, 2012-07-03 + String sStr = pTOX->GetMSTOCExpression(); + if (!sStr.Len()) + //End of modification, by ZF switch (pTOX->GetType()) { case TOX_INDEX: @@ -2406,7 +2415,7 @@ GetExport( ).bStartTOX = false; } -void AttributeOutputBase::EndTOX( const SwSection& rSect ) +void AttributeOutputBase::EndTOX( const SwSection& rSect,bool bCareEnd ) { const SwTOXBase* pTOX = rSect.GetTOXBase(); if ( pTOX ) @@ -2415,6 +2424,8 @@ GetExport( ).OutputField( 0, eCode, aEmptyStr, WRITEFIELD_CLOSE ); } GetExport( ).bInWriteTOX = false; + if (bCareEnd) + OnTOXEnding(); } bool MSWordExportBase::GetNumberFmt(const SwField& rFld, String& rStr) Index: source/filter/ww8/ww8attributeoutput.hxx =================================================================== --- source/filter/ww8/ww8attributeoutput.hxx (revision 1346300) +++ source/filter/ww8/ww8attributeoutput.hxx (working copy) @@ -52,6 +52,8 @@ /// virtual void StartRun( const SwRedlineData* pRedlineData ); + virtual void OnTOXEnding(); + /// End of the text run. /// /// No-op for binary filters. @@ -429,8 +431,10 @@ /// of the field results if we were forced to split text. sal_uInt16 m_nFieldResults; + bool mbOnTOXEnding; + public: - WW8AttributeOutput( WW8Export &rWW8Export ) : AttributeOutputBase(), m_rWW8Export( rWW8Export ) {} + WW8AttributeOutput( WW8Export &rWW8Export ) : AttributeOutputBase(), m_rWW8Export( rWW8Export ),mbOnTOXEnding(false) {} virtual ~WW8AttributeOutput() {} /// Return the right export class. Index: source/filter/ww8/ww8par.cxx =================================================================== --- source/filter/ww8/ww8par.cxx (revision 1346300) +++ source/filter/ww8/ww8par.cxx (working copy) @@ -2733,7 +2733,13 @@ break; case 0x15: if( !bSpec ) // Juristenparagraph - cInsert = '\xa7'; + { + cp_set::iterator aItr = maTOXEndCps.find((WW8_CP)nPosCp); + if (aItr == maTOXEndCps.end()) + cInsert = '\xa7'; + else + maTOXEndCps.erase(aItr); + } break; case 0x9: cInsert = '\x9'; // Tab @@ -3096,7 +3102,23 @@ // create a new txtnode and join the two paragraphs together if (bStartLine && !pPreviousNode) // Zeilenende - AppendTxtNode(*pPaM->GetPoint()); + { + bool bSplit = true; + if (mbCareFirstParaEndInToc) + { + mbCareFirstParaEndInToc = false; + if (pPaM->End() && pPaM->End()->nNode.GetNode().GetTxtNode() && pPaM->End()->nNode.GetNode().GetTxtNode()->Len() == 0) + bSplit = false; + } + if (mbCareLastParaEndInToc) + { + mbCareLastParaEndInToc = false; + if (pPaM->End() && pPaM->End()->nNode.GetNode().GetTxtNode() && pPaM->End()->nNode.GetNode().GetTxtNode()->Len() == 0) + bSplit = false; + } + if (bSplit) + AppendTxtNode(*pPaM->GetPoint()); + } if (pPreviousNode && bStartLine) { @@ -3265,6 +3287,15 @@ 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) + ,mbCareFirstParaEndInToc(false) + ,mbCareLastParaEndInToc(false) + //,mbTOCJustFinished(false) + //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) @@ -789,6 +789,9 @@ //----------------------------------------- // Storage-Reader //----------------------------------------- +typedef std::set cp_set; + + class SwWW8ImplReader { private: @@ -1090,6 +1093,19 @@ 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; + bool mbCareFirstParaEndInToc; + bool mbCareLastParaEndInToc; + //bool mbTOCJustFinished; + SwPaM* mpPosAfterTOC; + //End of modifications, by ZF + cp_set maTOXEndCps; //--------------------------------------------- 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 @@ -662,7 +668,8 @@ sal_uInt16 nRet = 0; WW8PLCFx_FLD* pF = pPlcxMan->GetFld(); ASSERT(pF, "WW8PLCFx_FLD - Pointer nicht da"); - if (!pF || !pF->EndPosIsFieldEnd()) + WW8_CP nCP = 0; + if (!pF || !pF->EndPosIsFieldEnd(nCP)) return nRet; const SvtFilterOptions* pOpt = SvtFilterOptions::Get(); @@ -711,8 +718,41 @@ } 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) + { + maTOXEndCps.insert(nCP); + mbLoadingTOCCache = false; + if (pPaM->End() && pPaM->End()->nNode.GetNode().GetTxtNode() && pPaM->End()->nNode.GetNode().GetTxtNode()->Len() == 0) + JoinNode(*pPaM); + else + mbCareLastParaEndInToc = true; + + 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 +772,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 +2163,7 @@ case -2: if( !sOrigName.Len() ) sOrigName = aReadParam.GetResult(); + break; } } @@ -2138,8 +2179,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 +2906,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"); @@ -2979,6 +3048,7 @@ case TOX_CONTENT: { bool bIsHyperlink = false; + bool bShowPage = true; // TOX_OUTLINELEVEL setzen wir genau dann, wenn // die Parameter \o in 1 bis 9 liegen // oder der Parameter \f existiert @@ -3088,6 +3158,7 @@ case 'n': // don't print page numbers { // read START and END param + bShowPage = false; sal_uInt16 nStart, nEnd; if( !aReadParam.GetTokenSttFromTo( &nStart, &nEnd, WW8ListManager::nMaxLevel ) ) @@ -3149,8 +3220,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 +3246,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; (bIsHyperlink || bShowPage) && nLevel <= nEnd; ++nLevel) + { + SwFormTokens aPattern = aForm.GetPattern(nLevel); + if (bIsHyperlink) + aPattern.insert(aPattern.begin(), aLinkStart); + else if (bShowPage) + { + 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 +3398,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 @@ -3297,6 +3410,12 @@ //#i10028# inserting a toc implicltly acts like a parabreak //in word and writer + + if (pPaM->End() && pPaM->End()->nNode.GetNode().GetTxtNode() && pPaM->End()->nNode.GetNode().GetTxtNode()->Len() != 0) + { + mbCareFirstParaEndInToc = true; + } + if (pPaM->GetPoint()->nContent.GetIndex()) AppendTxtNode(*pPaM->GetPoint()); @@ -3325,15 +3444,33 @@ // Setze Anfang in Stack pReffedStck->NewAttr( *pPos, aFltTOX ); + + 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 +3490,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 +3556,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 +3588,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; } Index: source/filter/ww8/ww8scan.cxx =================================================================== --- source/filter/ww8/ww8scan.cxx (revision 1346300) +++ source/filter/ww8/ww8scan.cxx (working copy) @@ -3786,7 +3786,7 @@ return true; } -bool WW8PLCFx_FLD::EndPosIsFieldEnd() +bool WW8PLCFx_FLD::EndPosIsFieldEnd(WW8_CP& nCP) { bool bRet = false; @@ -3799,7 +3799,10 @@ void* pData; sal_Int32 nTest; if ( pPLCF->Get(nTest, pData) && ((((sal_uInt8*)pData)[0] & 0x1f) == 0x15) ) + { + nCP = nTest; bRet = true; + } pPLCF->SetIdx(n); } @@ -4116,7 +4119,14 @@ else if( l1 < l0 ) nIsEnd = 1; else - nIsEnd = ( nIsEnd ) ? 0 : 1; + { + const void * p = pBook[0]->GetData(pBook[0]->GetIdx()); + long nPairFor = (p == NULL)? 0L : SVBT16ToShort(*((SVBT16*) p)); + if (nPairFor == pBook[1]->GetIdx()) + nIsEnd = 0; + else + nIsEnd = ( nIsEnd ) ? 0 : 1; + } } return *this; } Index: source/filter/ww8/ww8scan.hxx =================================================================== --- source/filter/ww8/ww8scan.hxx (revision 1346300) +++ source/filter/ww8/ww8scan.hxx (working copy) @@ -701,7 +701,7 @@ virtual void GetSprms(WW8PLCFxDesc* p); virtual WW8PLCFx& operator ++( int ); bool StartPosIsFieldStart(); - bool EndPosIsFieldEnd(); + bool EndPosIsFieldEnd(WW8_CP&); bool GetPara(long nIdx, WW8FieldDesc& rF); }; Index: source/ui/index/toxmgr.cxx =================================================================== --- source/ui/index/toxmgr.cxx (revision 1346300) +++ source/ui/index/toxmgr.cxx (working copy) @@ -459,8 +459,16 @@ if (pNewTOX != NULL) // => pTOX != NULL pDoc->ChgTOX(*pTOX, *pNewTOX); + //Modify here for i119963, by ZF, 2012-07-03 + pTOX->DisableKeepExpression(); + //End of modification, by ZF + bRet = pSh->UpdateTableOf(*pTOX, pSet); + //Modify here for i119963, by ZF, 2012-07-03 + pTOX->EnableKeepExpression(); + //End of modification, by ZF + if (pDoc->GetIDocumentUndoRedo().DoesUndo()) { pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_TOXCHANGE, NULL);