You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2012/08/28 11:27:03 UTC
svn commit: r1378038 - in
/incubator/ooo/branches/writer001/main/sw/source/filter/ww8: ww8par.cxx
ww8par.hxx ww8par5.cxx ww8par6.cxx
Author: orw
Date: Tue Aug 28 09:27:02 2012
New Revision: 1378038
URL: http://svn.apache.org/viewvc?rev=1378038&view=rev
Log:
#119963# - WW8 import: import of actual TOC content - first part of TOC enhancement
Patch by: zhengfan
Review by: Oliver.
Modified:
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.cxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.hxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par5.cxx
incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par6.cxx
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.cxx?rev=1378038&r1=1378037&r2=1378038&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.cxx Tue Aug 28 09:27:02 2012
@@ -3245,31 +3245,34 @@ bool SwWW8ImplReader::ReadText(long nSta
SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SvStorage* pStorage,
SvStream* pSt, SwDoc& rD, const String& rBaseURL, bool bNewDoc)
- : mpDocShell(rD.GetDocShell()),
- maTracer(*(mpDocShell->GetMedium())),
- pStg(pStorage),
- pStrm(pSt),
- pTableStream(0),
- pDataStream(0),
- rDoc(rD),
- maSectionManager(*this),
- maInsertedTables(rD),
- maSectionNameGenerator(rD,CREATE_CONST_ASC("WW")),
- maGrfNameGenerator(bNewDoc,String('G')),
- maParaStyleMapper(rD),
- maCharStyleMapper(rD),
- maTxtNodesHavingFirstLineOfstSet(),
- maTxtNodesHavingLeftIndentSet(),
- pMSDffManager(0),
- mpAtnNames(0),
- pAuthorInfos(0),
- sBaseURL(rBaseURL),
- m_bRegardHindiDigits( false ),
- mbNewDoc(bNewDoc),
- nDropCap(0),
- nIdctHint(0),
- bBidi(false),
- bReadTable(false)
+ : mpDocShell(rD.GetDocShell())
+ , maTracer(*(mpDocShell->GetMedium()))
+ , pStg(pStorage)
+ , pStrm(pSt)
+ , pTableStream(0)
+ , pDataStream(0)
+ , rDoc(rD)
+ , maSectionManager(*this)
+ , maInsertedTables(rD)
+ , maSectionNameGenerator(rD,CREATE_CONST_ASC("WW"))
+ , maGrfNameGenerator(bNewDoc,String('G'))
+ , maParaStyleMapper(rD)
+ , maCharStyleMapper(rD)
+ , maTxtNodesHavingFirstLineOfstSet()
+ , maTxtNodesHavingLeftIndentSet()
+ , pMSDffManager(0)
+ , mpAtnNames(0)
+ , pAuthorInfos(0)
+ , sBaseURL(rBaseURL)
+ , m_bRegardHindiDigits( false )
+ , mbNewDoc(bNewDoc)
+ , nDropCap(0)
+ , nIdctHint(0)
+ , bBidi(false)
+ , bReadTable(false)
+ , mbLoadingTOCCache(false)
+ , mbLoadingTOCHyperlink(false)
+ , mpPosAfterTOC(0)
{
pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
nWantedVersion = nVersionPara;
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.hxx?rev=1378038&r1=1378037&r2=1378038&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.hxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par.hxx Tue Aug 28 09:27:02 2012
@@ -1079,7 +1079,7 @@ private:
// the very 1st Line Numbering and ignore the rest)
bool bFirstPara; // first paragraph?
- bool bFirstParaOfPage;//cs2c--xushanchuan add for bug11210
+ bool bFirstParaOfPage;//cs2c--xushanchuan add for bug11210
bool bParaAutoBefore;
bool bParaAutoAfter;
@@ -1087,9 +1087,15 @@ private:
int nDropCap;
int nIdctHint;
- bool bBidi;
+ bool bBidi;
bool bReadTable;
boost::shared_ptr<SwPaM> mpTableEndPaM;
+ // 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;
+ // a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field()
+ SwPaM* mpPosAfterTOC;
//---------------------------------------------
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par5.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par5.cxx?rev=1378038&r1=1378037&r2=1378038&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par5.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par5.cxx Tue Aug 28 09:27:02 2012
@@ -317,12 +317,16 @@ long SwWW8ImplReader::Read_Book(WW8PLCFM
return 0;
}
- //"_Toc*" and "_Hlt*" are unnecessary
+ // "_Hlt*" are unnecessary
const String* pName = pB->GetName();
#if !defined(WW_NATIVE_TOC)
- if( !pName || pName->EqualsIgnoreCaseAscii( "_Toc", 0, 4 )
- || pName->EqualsIgnoreCaseAscii( "_Hlt", 0, 4 ) )
+ // 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.
+ if ( !pName ||
+ pName->EqualsIgnoreCaseAscii( "_Hlt", 0, 4 ) )
+ {
return 0;
+ }
#endif
//JP 16.11.98: ToUpper darf auf keinen Fall gemacht werden, weil der
@@ -711,9 +715,34 @@ sal_uInt16 SwWW8ImplReader::End_Field()
}
break;
#else
+ // 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;
case 88:
+ if (mbLoadingTOCHyperlink)
+ mbLoadingTOCHyperlink = false;
pCtrlStck->SetAttr(*pPaM->GetPoint(),RES_TXTATR_INETFMT);
- break;
+ break;
#endif
case 36:
case 68:
@@ -732,10 +761,10 @@ bool AcceptableNestedField(sal_uInt16 nF
{
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:
@@ -2129,6 +2158,7 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( W
case -2:
if( !sOrigName.Len() )
sOrigName = aReadParam.GetResult();
+
break;
}
}
@@ -2144,7 +2174,28 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( W
return FLD_TEXT;
}
#endif
-
+ //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;
+ }
SwGetRefField aFld(
(SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ), sName,
@@ -2162,7 +2213,7 @@ bool ConvertMacroSymbol( const String& r
if( rReference.EqualsAscii( "(" ) )
{
bConverted = true;
- sal_Unicode cSymbol;
+ sal_Unicode cSymbol = 0x0000;
if( rName.EqualsAscii( "CheckIt" ) )
cSymbol = 0xF06F;
else if( rName.EqualsAscii( "UncheckIt" ) )
@@ -2953,12 +3004,13 @@ sal_uInt16 lcl_GetMaxValidWordTOCLevel(c
eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr )
{
+ mbLoadingTOCCache = true;
+
#if defined(WW_NATIVE_TOC)
if (1) {
::rtl::OUString aBookmarkName=::rtl::OUString::createFromAscii("_TOC");
maFieldStack.back().SetBookmarkName(aBookmarkName);
maFieldStack.back().SetBookmarkType(::rtl::OUString::createFromAscii(ODF_TOC));
-// maFieldStack.back().AddParam(::rtl::OUString::createFromAscii("Description"), aFormula.sToolTip);
return FLD_TEXT;
}
#endif
@@ -3263,27 +3315,35 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8
}
}
- if (bIsHyperlink)
- {
- SwForm aForm(pBase->GetTOXForm());
- sal_uInt16 nEnd = aForm.GetFormMax()-1;
- SwFormToken aLinkStart(TOKEN_LINK_START);
- SwFormToken aLinkEnd(TOKEN_LINK_END);
-
- // -> #i21237#
- for(sal_uInt16 nLevel = 1; nLevel <= nEnd; ++nLevel)
- {
- SwFormTokens aPattern = aForm.GetPattern(nLevel);
+ // For loading the expression of TOC field, we need to mapping its parameters to TOX entries tokens
+ // also include the hyperlinks and page references
+ 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;
+ for(sal_uInt16 nLevel = 1; nLevel <= nEnd; ++nLevel)
+ {
+ SwFormTokens aPattern = aForm.GetPattern(nLevel);
+ if (bIsHyperlink)
aPattern.insert(aPattern.begin(), aLinkStart);
- aPattern.push_back(aLinkEnd);
-
- aForm.SetPattern(nLevel, aPattern);
-
+ else
+ {
+ for (SwFormTokens::iterator aItr = aPattern.begin();aItr!= aPattern.end();aItr++)
+ {
+ if (aItr->eTokenType == TOKEN_PAGE_NUMS)
+ {
+ aPattern.insert(aItr,aLinkStart);
+ break;
+ }
+ }
}
- // <- #i21237#
- pBase->SetTOXForm(aForm);
+ aPattern.push_back(aLinkEnd);
+ aForm.SetPattern(nLevel, aPattern);
}
+ pBase->SetTOXForm(aForm);
if (!nMaxLevel)
nMaxLevel = WW8ListManager::nMaxLevel;
@@ -3400,8 +3460,8 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8
break;
} // ToxBase fertig
- // Update fuer TOX anstossen
- rDoc.SetUpdateTOX(true);
+ // no Update of TOC anymore as its actual content is imported and kept.
+ //rDoc.SetUpdateTOX(true);
// #i21237#
// propagate tab stops from paragraph styles used in TOX to
@@ -3440,10 +3500,19 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8
rDoc.InsertTableOf(*pPaM->GetPoint(), *aFltTOX.GetBase());
+
//inserting a toc inserts a section before this point, so adjust pos
//for future page/section segment insertion
+ //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;
+ if (mpPosAfterTOC)
+ {
+ delete mpPosAfterTOC;
+ }
+ mpPosAfterTOC = new SwPaM(*pPaM);
+ (*pPaM).Move(fnMoveBackward);
SwPaM aRegion(*pPaM);
- aRegion.Move(fnMoveBackward);
+
ASSERT(rDoc.GetCurTOX(*aRegion.GetPoint()), "Misunderstood how toc works");
if (SwTOXBase* pBase2 = (SwTOXBase*)rDoc.GetCurTOX(*aRegion.GetPoint()))
{
@@ -3466,7 +3535,11 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8
if (!maApos.back()) //a para end in apo doesn't count
bWasParaEnd = true;
- return FLD_OK;
+
+ //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.
+ return FLD_TEXT;
}
eF_ResT SwWW8ImplReader::Read_F_Shape(WW8FieldDesc* /*pF*/, String& /*rStr*/)
@@ -3525,6 +3598,10 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlin
if( sMark.Len() && '"' == sMark.GetChar( sMark.Len()-1 ))
sMark.Erase( sMark.Len() - 1 );
+ if (mbLoadingTOCCache)
+ {
+ mbLoadingTOCHyperlink = true;//on loading a TOC field nested hyperlink field
+ }
}
break;
case 't':
@@ -3551,6 +3628,18 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlin
SwFmtINetFmt aURL( sURL, sTarget );
+ // 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);
+ }
+
//As an attribute this needs to be closed, and that'll happen from
//EndExtSprm in conjunction with the maFieldStack If there are are flyfrms
//between the start and begin, their hyperlinks will be set at that time
Modified: incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par6.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par6.cxx?rev=1378038&r1=1378037&r2=1378038&view=diff
==============================================================================
--- incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par6.cxx (original)
+++ incubator/ooo/branches/writer001/main/sw/source/filter/ww8/ww8par6.cxx Tue Aug 28 09:27:02 2012
@@ -3875,6 +3875,15 @@ 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
+ // 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;
+ }
+
NewAttr( SwFmtCharFmt( (SwCharFmt*)pCollA[nId].pFmt ) );
nCharFmt = (short) nId;
}