summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver-Rainer Wittmann <orw@apache.org>2014-06-26 09:24:49 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-06-26 16:29:17 +0100
commite28797356f34253bcbe7237d7bfdbcda2a3f5b3c (patch)
tree0171743138c2b9febf62dbc6e5a38abbc9f2117f
parent749bd87e90ed80c26d93748f2fbe682d533c53f1 (diff)
Resolves: #i125122# WW8 import: Handle nested TOX fields
- only the content of nested TOX fields is imported, no TOX field itself (cherry picked from commit 1df1e98e7b6556892f546cc559e31f9fd9e00a78) (cherry picked from commit b2d0492ea85a2f96378326361421749619269b15) Conflicts: sw/source/filter/ww8/ww8par.hxx sw/source/filter/ww8/ww8par5.cxx sw/source/filter/ww8/ww8par6.cxx Change-Id: I29cf81df72bf548414bef06b54a691eae6a5edcd
-rw-r--r--sw/source/filter/ww8/ww8par.cxx5
-rw-r--r--sw/source/filter/ww8/ww8par.hxx5
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx72
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx6
4 files changed, 54 insertions, 34 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index e0074f10dd04..34ca56e6dc4e 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4220,8 +4220,9 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SvStorage* pStorage,
, nIdctHint(0)
, bBidi(false)
, bReadTable(false)
- , mbLoadingTOCCache(false)
- , mbLoadingTOCHyperlink(false)
+ , mbLoadingTOXCache(false)
+ , mnEmbeddedTOXLevel(0)
+ , mbLoadingTOXHyperlink(false)
, mpPosAfterTOC(0)
, mbCareFirstParaEndInToc(false)
, mbCareLastParaEndInToc(false)
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 6da60d5a3bf2..a9558a764bcf 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1336,9 +1336,10 @@ private:
bool bReadTable;
boost::shared_ptr<SwPaM> mpTableEndPaM;
// Indicate that currently on loading a TOC, managed by Read_F_TOX() and End_Field()
- bool mbLoadingTOCCache;
+ bool mbLoadingTOXCache;
+ int mnEmbeddedTOXLevel;
// Indicate that current on loading a hyperlink, which is inside a TOC; Managed by Read_F_Hyperlink() and End_Field()
- bool mbLoadingTOCHyperlink;
+ bool mbLoadingTOXHyperlink;
// a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field()
SwPaM* mpPosAfterTOC;
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index c7352c21c58e..d9ca4f287ef4 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -495,42 +495,50 @@ 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);
+ 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)
+ case 37: //REF
+ if (mbLoadingTOXCache && !mbLoadingTOXHyperlink)
{
pCtrlStck->SetAttr(*pPaM->GetPoint(),RES_TXTATR_INETFMT);
}
break;
case 88:
- if (mbLoadingTOCHyperlink)
- mbLoadingTOCHyperlink = false;
- pCtrlStck->SetAttr(*pPaM->GetPoint(),RES_TXTATR_INETFMT);
+ if (mbLoadingTOXHyperlink)
+ mbLoadingTOXHyperlink = false;
+ pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_TXTATR_INETFMT);
break;
case 36:
case 68:
@@ -2027,13 +2035,13 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, OUString& rStr )
const OUString 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.isEmpty() )
+ if (!mbLoadingTOXHyperlink && !sName.isEmpty())
{
// #i120879# add cross reference bookmark name prefix, if it
// matches internal TOC bookmark naming convention
@@ -2817,7 +2825,17 @@ static sal_uInt16 lcl_GetMaxValidWordTOCLevel(const SwForm &rForm)
eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& 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#)
@@ -3398,9 +3416,9 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlink( WW8FieldDesc* /*pF*/, OUString& rStr
pReffedStck->aReferencedTOCBookmarks.insert( sMark );
}
- if (mbLoadingTOCCache)
+ if (mbLoadingTOXCache)
{
- mbLoadingTOCHyperlink = true;//on loading a TOC field nested hyperlink field
+ mbLoadingTOXHyperlink = true; //on loading a TOC field nested hyperlink field
}
}
break;
@@ -3426,9 +3444,9 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlink( WW8FieldDesc* /*pF*/, OUString& rStr
if( !sMark.isEmpty() )
( sURL += "#" ) += sMark;
- SwFmtINetFmt aURL( sURL, sTarget );
+ SwFmtINetFmt aURL(sURL, sTarget);
// If on loading TOC field, change the default style into the "index link"
- if (mbLoadingTOCCache)
+ if (mbLoadingTOXCache)
{
OUString sLinkStyle("Index Link");
sal_uInt16 nPoolId =
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 884af8595a57..1ee747b12797 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -3728,11 +3728,11 @@ void SwWW8ImplReader::Read_CColl( sal_uInt16, const sal_uInt8* pData, short nLen
|| vColl[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 && vColl[nId].GetWWStyleId() == ww::stiHyperlink)
+ if (mbLoadingTOXCache && vColl[nId].GetWWStyleId() == ww::stiHyperlink)
{
return;
}