Bug 36960 was never fixed correctly (or rather, I suspect it was fixed, then broken when work was done to make the tests pass). The attached patch fixes the bug and adds new tests for cross-references to numbered paragraphs. The nature of the bug is that if you have numbered paragraphs like this: 1. one (a) two (b) three 2. four (a) five a cross reference in paragraph 2(a), to paragraph 1(a), returns "1.(a)", which is not correct.
Attachment:
CheckCrossReferences.odt
Description: application/vnd.oasis.opendocument.text
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index 27b2cb9..66be2d8e 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -739,7 +739,6 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum, if ( rNodeNum.GetLevelInListTree() >= 0 ) { bool bOldHadPrefix = true; - bool bFirstIteration = true; OUString sOldPrefix; const SwNodeNum* pWorkingNodeNum( &rNodeNum ); @@ -779,7 +778,7 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum, aExtremities.nPrefixChars -= nStrip; } - if ((bFirstIteration || bOldHadPrefix) && + if ((bOldHadPrefix) && aExtremities.nSuffixChars && !aExtremities.nPrefixChars ) @@ -788,10 +787,6 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum, while (aPrevStr.Len() - nStrip2 < aExtremities.nSuffixChars) { char const cur = aPrevStr.GetChar(nStrip2); - if (!bFirstIteration && '\t' != cur && ' ' != cur) - { - break; - } --nStrip2; } if (nStrip2 < aPrevStr.Len()) @@ -799,7 +794,7 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum, aPrevStr.Erase(nStrip2, aPrevStr.Len() - nStrip2); } } - else if (sOldPrefix.getLength()) + else if (!aExtremities.nSuffixChars && !bOldHadPrefix) { aRefNumStr.Insert(sOldPrefix, 0); } @@ -809,11 +804,6 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum, aRefNumStr.Insert( aPrevStr, 0 ); } - else if ( aRefNumStr.Len() > 0 ) - { - sOldPrefix += " "; - bOldHadPrefix = true; - } if ( bInclSuperiorNumLabels && pWorkingNodeNum->GetLevelInListTree() > 0 ) { @@ -830,7 +820,6 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum, { break; } - bFirstIteration = false; } while ( pWorkingNodeNum && pWorkingNodeNum->GetLevelInListTree() >= 0 && static_cast<sal_uInt8>(pWorkingNodeNum->GetLevelInListTree()) >= nRestrictInclToThisLevel );