Author: orw Date: Thu Jun 26 09:24:49 2014 New Revision: 1605717 URL: http://svn.apache.org/r1605717 Log: 125122: WW8 import: Handle nested TOX fields - only the content of nested TOX fields is imported, no TOX field itself
Modified: openoffice/trunk/main/sw/source/filter/ww8/ww8par.cxx openoffice/trunk/main/sw/source/filter/ww8/ww8par.hxx openoffice/trunk/main/sw/source/filter/ww8/ww8par5.cxx openoffice/trunk/main/sw/source/filter/ww8/ww8par6.cxx Modified: openoffice/trunk/main/sw/source/filter/ww8/ww8par.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/filter/ww8/ww8par.cxx?rev=1605717&r1=1605716&r2=1605717&view=diff ============================================================================== --- openoffice/trunk/main/sw/source/filter/ww8/ww8par.cxx (original) +++ openoffice/trunk/main/sw/source/filter/ww8/ww8par.cxx Thu Jun 26 09:24:49 2014 @@ -3724,8 +3724,9 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uIn , nIdctHint(0) , bBidi(false) , bReadTable(false) - , mbLoadingTOCCache(false) - , mbLoadingTOCHyperlink(false) + , mbLoadingTOXCache(false) + , mnEmbeddedTOXLevel(0) + , mbLoadingTOXHyperlink(false) , mpPosAfterTOC(0) , mbCareFirstParaEndInToc(false) , mbCareLastParaEndInToc(false) Modified: openoffice/trunk/main/sw/source/filter/ww8/ww8par.hxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/filter/ww8/ww8par.hxx?rev=1605717&r1=1605716&r2=1605717&view=diff ============================================================================== --- openoffice/trunk/main/sw/source/filter/ww8/ww8par.hxx (original) +++ openoffice/trunk/main/sw/source/filter/ww8/ww8par.hxx Thu Jun 26 09:24:49 2014 @@ -1216,10 +1216,12 @@ private: boost::shared_ptr<SwPaM> mpTableEndPaM; WW8PLCFx_Cp_FKP* pFirstTablePap; - // Indicate that currently on loading a TOC, managed by Read_F_TOX() and End_Field() - bool mbLoadingTOCCache; - // Indicate that current on loading a hyperlink, which is inside a TOC; Managed by Read_F_Hyperlink() and End_Field() - bool mbLoadingTOCHyperlink; + // Indicate that currently on loading a TOX, managed by Read_F_TOX() and End_Field() + bool mbLoadingTOXCache; + int mnEmbeddedTOXLevel; + + // Indicate that current on loading a hyperlink, which is inside a TOX; Managed by Read_F_Hyperlink() and End_Field() + bool mbLoadingTOXHyperlink; // a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field() SwPaM* mpPosAfterTOC; @@ -1289,12 +1291,10 @@ private: void ImportTox( int nFldId, String aStr ); void EndSprm( sal_uInt16 nId ); - // --> OD 2010-05-06 #i103711# - // --> OD 2010-05-11 #i105414# + void NewAttr( const SfxPoolItem& rAttr, const bool bFirstLineOfStSet = false, const bool bLeftIndentSet = false ); - // <-- bool GetFontParams(sal_uInt16, FontFamily&, String&, FontPitch&, rtl_TextEncoding&); Modified: openoffice/trunk/main/sw/source/filter/ww8/ww8par5.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/filter/ww8/ww8par5.cxx?rev=1605717&r1=1605716&r2=1605717&view=diff ============================================================================== --- openoffice/trunk/main/sw/source/filter/ww8/ww8par5.cxx (original) +++ openoffice/trunk/main/sw/source/filter/ww8/ww8par5.cxx Thu Jun 26 09:24:49 2014 @@ -706,41 +706,48 @@ sal_uInt16 SwWW8ImplReader::End_Field() } } break; - // Doing corresponding status management for TOC field, index field, hyperlink field and page reference field + // Doing corresponding status management for TOX field, index field, hyperlink field and page reference field case 13://TOX case 8://index - if (mbLoadingTOCCache) + if ( mbLoadingTOXCache ) { - maTOXEndCps.insert(nCP); - mbLoadingTOCCache = false; - if ( pPaM->End() && - pPaM->End()->nNode.GetNode().GetTxtNode() && - pPaM->End()->nNode.GetNode().GetTxtNode()->Len() == 0 ) + if ( mnEmbeddedTOXLevel > 0 ) { - JoinNode(*pPaM); + --mnEmbeddedTOXLevel; } else { + maTOXEndCps.insert( nCP ); + mbLoadingTOXCache = 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; + } + + if ( mpPosAfterTOC ) + { + *pPaM = *mpPosAfterTOC; + delete mpPosAfterTOC; + mpPosAfterTOC = 0; + } } } break; case 37://REF - if (mbLoadingTOCCache && !mbLoadingTOCHyperlink) + if (mbLoadingTOXCache && !mbLoadingTOXHyperlink) { pCtrlStck->SetAttr(*pPaM->GetPoint(),RES_TXTATR_INETFMT); } break; case 88: - if (mbLoadingTOCHyperlink) - mbLoadingTOCHyperlink = false; + if (mbLoadingTOXHyperlink) + mbLoadingTOXHyperlink = false; pCtrlStck->SetAttr(*pPaM->GetPoint(),RES_TXTATR_INETFMT); break; case 36: @@ -2170,13 +2177,13 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( W const String sName(GetMappedBookmark(sOrigName)); - // loading page reference field in TOC - if (mbLoadingTOCCache ) + // loading page reference field in TOX + if (mbLoadingTOXCache ) { // insert page ref representation as plain text --> return FLD_TEXT // if there is no hyperlink settings for current toc and referenced bookmark is available, // assign link to current ref area - if ( !mbLoadingTOCHyperlink && sName.Len() > 0 ) + if ( !mbLoadingTOXHyperlink && sName.Len() > 0 ) { // #120879# add cross reference bookmark name prefix, if it matches internal TOC bookmark naming convention String sBookmarkName; @@ -3024,7 +3031,16 @@ sal_uInt16 lcl_GetMaxValidWordTOCLevel(c eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr ) { - mbLoadingTOCCache = true; + if ( !mbLoadingTOXCache ) + { + mbLoadingTOXCache = true; + } + else + { + // Embedded TOX --> continue reading its content, but no further TOX field + ++mnEmbeddedTOXLevel; + return FLD_TEXT; + } if (pF->nLRes < 3) return FLD_TEXT; // ignore (#i25440#) @@ -3610,9 +3626,9 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlin pReffedStck->aReferencedTOCBookmarks.insert( sMark ); } - if (mbLoadingTOCCache) + if (mbLoadingTOXCache) { - mbLoadingTOCHyperlink = true;//on loading a TOC field nested hyperlink field + mbLoadingTOXHyperlink = true;//on loading a TOX field nested hyperlink field } } break; @@ -3639,8 +3655,8 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlin ( sURL += INET_MARK_TOKEN ) += sMark; SwFmtINetFmt aURL( sURL, sTarget ); - // If on loading TOC field, change the default style into the "index link" - if (mbLoadingTOCCache) + // If on loading TOX field, change the default style into the "index link" + if (mbLoadingTOXCache) { String sLinkStyle = String::CreateFromAscii("Index Link"); sal_uInt16 nPoolId = Modified: openoffice/trunk/main/sw/source/filter/ww8/ww8par6.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/filter/ww8/ww8par6.cxx?rev=1605717&r1=1605716&r2=1605717&view=diff ============================================================================== --- openoffice/trunk/main/sw/source/filter/ww8/ww8par6.cxx (original) +++ openoffice/trunk/main/sw/source/filter/ww8/ww8par6.cxx Thu Jun 26 09:24:49 2014 @@ -3909,11 +3909,11 @@ void SwWW8ImplReader::Read_CColl( sal_uI || pCollA[nId].bColl ) // oder Para-Style ? return; // dann ignorieren - // 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 + // if current on loading a TOX field, and current trying to apply a hyperlink character style, + // just ignore. For the hyperlinks inside TOX 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) + if (mbLoadingTOXCache && pCollA[nId].GetWWStyleId() == ww::stiHyperlink) { return; }