summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/complex/writer/CheckCrossReferences.java50
-rw-r--r--sw/source/core/doc/number.cxx35
2 files changed, 48 insertions, 37 deletions
diff --git a/sw/qa/complex/writer/CheckCrossReferences.java b/sw/qa/complex/writer/CheckCrossReferences.java
index 0f74a11b26f6..4f436ce67146 100644
--- a/sw/qa/complex/writer/CheckCrossReferences.java
+++ b/sw/qa/complex/writer/CheckCrossReferences.java
@@ -145,9 +145,9 @@ public class CheckCrossReferences {
final String FldResult1 = "*i*";
final String FldResult2 = "+b+*i*";
final String FldResult3 = "-1-+b+*i*";
- final String FldResult4 = "1.";
- final String FldResult5 = " 1.";
- final String FldResult6 = "A. 1.";
+ final String FldResult4 = "1";
+ final String FldResult5 = "1";
+ final String FldResult6 = "A.1";
// variables for current field
com.sun.star.text.XTextField xField = null;
@@ -171,33 +171,23 @@ public class CheckCrossReferences {
checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult1 );
checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult3 );
- // The following tests currently fail due to a regression introduced
- // with the fix for
- // <https://bugs.freedesktop.org/show_bug.cgi?id=33960> "cross
- // reference to a list number, dot bug," see thread starting at
- // <http://lists.freedesktop.org/archives/libreoffice/
- // 2011-September/017797.html> "[Libreoffice] fix for fdo#33960
- // 'cross reference to a list number, dot bug' makes
- // sw/qa/complex/writer fail":
- if (false) {
- xField = getNextField();
- xProps = getFieldProps( xField );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult5 );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
-
- xField = getNextField();
- xProps = getFieldProps( xField );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult4 );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
-
- xField = getNextField();
- xProps = getFieldProps( xField );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult6 );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
- }
+ xField = getNextField();
+ xProps = getFieldProps( xField );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult5 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
+
+ xField = getNextField();
+ xProps = getFieldProps( xField );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult4 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
+
+ xField = getNextField();
+ xProps = getFieldProps( xField );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult6 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
}
// insert a certain cross-reference bookmark and a reference field to this bookmark
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 41fc6709fe21..c6e26fe9aa0b 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -752,6 +752,8 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
if ( rNodeNum.GetLevelInListTree() >= 0 )
{
sal_Bool bOldHadPrefix = sal_True;
+ bool bFirstIteration = true;
+ ::rtl::OUString sOldPrefix;
const SwNodeNum* pWorkingNodeNum( &rNodeNum );
do
@@ -787,26 +789,44 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
if (nStrip)
{
- aPrevStr.Erase( 0, nStrip );
- aExtremities.nPrefixChars -= nStrip;
- nLen -= nStrip;
+ aPrevStr.Erase( 0, nStrip );
+ aExtremities.nPrefixChars -= nStrip;
+ nLen -= nStrip;
}
- if ( bOldHadPrefix &&
+ if ((bFirstIteration || bOldHadPrefix) &&
aExtremities.nSuffixChars &&
!aExtremities.nPrefixChars
)
{
- aPrevStr.Erase( nLen - aExtremities.nSuffixChars, aExtremities.nSuffixChars );
+ int nStrip2 = aPrevStr.Len();
+ while (aPrevStr.Len() - nStrip2 < aExtremities.nSuffixChars)
+ {
+ char const cur = aPrevStr.GetChar(nStrip2);
+ if (!bFirstIteration && '\t' != cur && ' ' != cur)
+ {
+ break;
+ }
+ --nStrip2;
+ }
+ if (nStrip2 < aPrevStr.Len())
+ {
+ aPrevStr.Erase(nStrip2, aPrevStr.Len() - nStrip2);
+ }
+ }
+ else if (sOldPrefix.getLength())
+ {
+ aRefNumStr.Insert(sOldPrefix, 0);
}
+ sOldPrefix = ::rtl::OUString();
+
bOldHadPrefix = ( aExtremities.nPrefixChars > 0);
aRefNumStr.Insert( aPrevStr, 0 );
-
}
else if ( aRefNumStr.Len() > 0 )
{
- aRefNumStr.Insert( String::CreateFromAscii(" "), 0 );
+ sOldPrefix += " ";
bOldHadPrefix = true;
}
@@ -825,6 +845,7 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
{
break;
}
+ bFirstIteration = false;
} while ( pWorkingNodeNum &&
pWorkingNodeNum->GetLevelInListTree() >= 0 &&
static_cast<sal_uInt8>(pWorkingNodeNum->GetLevelInListTree()) >= nRestrictInclToThisLevel );