Kaydet (Commit) 23464204 authored tarafından Troy Rollo's avatar Troy Rollo Kaydeden (comit) Cédric Bosdonnat

fdo#33960 - import/export xrefs to numbered paras

üst 7e631b61
...@@ -813,8 +813,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) ...@@ -813,8 +813,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr )
case RTFFLD_REF: case RTFFLD_REF:
{ {
String sOrigBkmName; String sOrigBkmName;
bool bChapterNr = false; REFERENCEMARK eFormat = REF_CONTENT;
bool bAboveBelow = false;
RtfFieldSwitch aRFS( aSaveStr ); RtfFieldSwitch aRFS( aSaveStr );
while( !aRFS.IsAtEnd() ) while( !aRFS.IsAtEnd() )
...@@ -828,42 +827,35 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) ...@@ -828,42 +827,35 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr )
sOrigBkmName = sParam; sOrigBkmName = sParam;
break; break;
/* References to numbers in Word could be either to a numbered
paragraph or to a chapter number. However Word does not seem to
have the capability we do, of refering to the chapter number some
other bookmark is in. As a result, cross-references to chapter
numbers in a word document will be cross-references to a numbered
paragraph, being the chapter heading paragraph. As it happens, our
cross-references to numbered paragraphs will do the right thing
when the target is a numbered chapter heading, so there is no need
for us to use the REF_CHAPTER bookmark format on import.
*/
case 'n': case 'n':
eFormat = REF_NUMBER_NO_CONTEXT;
break;
case 'r': case 'r':
eFormat = REF_NUMBER;
break;
case 'w': case 'w':
bChapterNr = true; // activate flag 'Chapter Number' eFormat = REF_NUMBER_FULL_CONTEXT;
break; break;
case 'p': case 'p':
bAboveBelow = true; eFormat = REF_UPDOWN;
break; break;
} }
} }
if (!bAboveBelow || bChapterNr) SwGetRefField aFld(
{ (SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD ),
if (bChapterNr) sOrigBkmName,REF_BOOKMARK,0,eFormat);
{ pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 );
SwGetRefField aFld(
(SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD ),
sOrigBkmName,REF_BOOKMARK,0,REF_CHAPTER);
pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 );
}
else
{
SwGetRefField aFld(
(SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD ),
sOrigBkmName,REF_BOOKMARK,0,REF_CONTENT);
pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 );
}
}
if( bAboveBelow )
{
SwGetRefField aFld( (SwGetRefFieldType*)
pDoc->GetSysFldType( RES_GETREFFLD ), sOrigBkmName, REF_BOOKMARK, 0,
REF_UPDOWN );
pDoc->InsertPoolItem(*pPam, SwFmtFld(aFld), 0);
}
} }
break; break;
......
...@@ -2830,6 +2830,18 @@ void AttributeOutputBase::TextField( const SwFmtFld& rField ) ...@@ -2830,6 +2830,18 @@ void AttributeOutputBase::TextField( const SwFmtFld& rField )
sStr = FieldString(eFld); sStr = FieldString(eFld);
sStr += GetExport().GetBookmarkName(nSubType, sStr += GetExport().GetBookmarkName(nSubType,
&rRFld.GetSetRefName(), 0); &rRFld.GetSetRefName(), 0);
switch (pFld->GetFormat())
{
case REF_NUMBER:
sStr.APPEND_CONST_ASC(" \\r");
break;
case REF_NUMBER_NO_CONTEXT:
sStr.APPEND_CONST_ASC(" \\n");
break;
case REF_NUMBER_FULL_CONTEXT:
sStr.APPEND_CONST_ASC(" \\w");
break;
}
break; break;
case REF_FOOTNOTE: case REF_FOOTNOTE:
case REF_ENDNOTE: case REF_ENDNOTE:
......
...@@ -2064,8 +2064,7 @@ eF_ResT SwWW8ImplReader::Read_F_Set( WW8FieldDesc* pF, String& rStr ) ...@@ -2064,8 +2064,7 @@ eF_ResT SwWW8ImplReader::Read_F_Set( WW8FieldDesc* pF, String& rStr )
eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr ) eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr )
{ // Reference - Field { // Reference - Field
String sOrigBkmName; String sOrigBkmName;
bool bChapterNr = false; REFERENCEMARK eFormat = REF_CONTENT;
bool bAboveBelow = false;
long nRet; long nRet;
_ReadFieldParams aReadParam( rStr ); _ReadFieldParams aReadParam( rStr );
...@@ -2077,14 +2076,29 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr ) ...@@ -2077,14 +2076,29 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr )
if( !sOrigBkmName.Len() ) // get name of bookmark if( !sOrigBkmName.Len() ) // get name of bookmark
sOrigBkmName = aReadParam.GetResult(); sOrigBkmName = aReadParam.GetResult();
break; break;
/* References to numbers in Word could be either to a numbered
paragraph or to a chapter number. However Word does not seem to
have the capability we do, of refering to the chapter number some
other bookmark is in. As a result, cross-references to chapter
numbers in a word document will be cross-references to a numbered
paragraph, being the chapter heading paragraph. As it happens, our
cross-references to numbered paragraphs will do the right thing
when the target is a numbered chapter heading, so there is no need
for us to use the REF_CHAPTER bookmark format on import.
*/
case 'n': case 'n':
eFormat = REF_NUMBER_NO_CONTEXT;
break;
case 'r': case 'r':
eFormat = REF_NUMBER;
break;
case 'w': case 'w':
bChapterNr = true; // activate flag 'Chapter Number' eFormat = REF_NUMBER_FULL_CONTEXT;
break; break;
case 'p': case 'p':
bAboveBelow = true; eFormat = REF_UPDOWN;
break; break;
case 'h': case 'h':
break; break;
...@@ -2096,36 +2110,23 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr ) ...@@ -2096,36 +2110,23 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr )
String sBkmName(GetMappedBookmark(sOrigBkmName)); String sBkmName(GetMappedBookmark(sOrigBkmName));
if (!bAboveBelow || bChapterNr) SwGetRefField aFld(
(SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ),
sBkmName,REF_BOOKMARK,0,eFormat);
if (eFormat == REF_CONTENT)
{ {
if (bChapterNr) /*
{ If we are just inserting the contents of the bookmark, then it
SwGetRefField aFld( is possible that the bookmark is actually a variable, so we
(SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ), must store it until the end of the document to see if it was,
sBkmName,REF_BOOKMARK,0,REF_CHAPTER); in which case we'll turn it into a show variable
rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); */
} pReffingStck->NewAttr( *pPaM->GetPoint(), SwFmtFld(aFld) );
else pReffingStck->SetAttr( *pPaM->GetPoint(), RES_TXTATR_FIELD);
{
/*
If we are just inserting the contents of the bookmark, then it
is possible that the bookmark is actually a variable, so we
must store it until the end of the document to see if it was,
in which case we'll turn it into a show variable
*/
SwGetRefField aFld(
(SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ),
sBkmName,REF_BOOKMARK,0,REF_CONTENT);
pReffingStck->NewAttr( *pPaM->GetPoint(), SwFmtFld(aFld) );
pReffingStck->SetAttr( *pPaM->GetPoint(), RES_TXTATR_FIELD);
}
} }
else
if( bAboveBelow )
{ {
SwGetRefField aFld( (SwGetRefFieldType*)
rDoc.GetSysFldType( RES_GETREFFLD ), sBkmName, REF_BOOKMARK, 0,
REF_UPDOWN );
rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
} }
return FLD_OK; return FLD_OK;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment