[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source
Michael Stahl
mstahl at redhat.com
Mon Aug 26 06:16:09 PDT 2013
sw/qa/complex/writer/CheckCrossReferences.java | 74 ++++++++----
sw/qa/complex/writer/testdocuments/CheckCrossReferences.odt |binary
sw/source/core/doc/number.cxx | 32 -----
3 files changed, 57 insertions(+), 49 deletions(-)
New commits:
commit 2395ae8d2ecb5b527d8856ddbce4831a6d2a7092
Author: Michael Stahl <mstahl at redhat.com>
Date: Mon Aug 26 14:59:45 2013 +0200
fdo#33960: simplify SwNumRule::MakeRefNumString further
Change-Id: Ib0e9ccb163d5132ca18142361f72376642915fcb
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 7b8d773..ffd471b 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -730,7 +730,6 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
if ( rNodeNum.GetLevelInListTree() >= 0 )
{
bool bOldHadPrefix = true;
- OUString sOldPrefix;
const SwNodeNum* pWorkingNodeNum( &rNodeNum );
do
@@ -772,21 +771,9 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
!aExtremities.nPrefixChars
)
{
- nStrip = 0;
- while (nStrip < aExtremities.nSuffixChars)
- {
- ++nStrip;
- }
- if (nStrip)
- {
- aPrevStr = aPrevStr.copy(0, aPrevStr.getLength()-nStrip);
- }
- }
- else if (!aExtremities.nSuffixChars && !bOldHadPrefix)
- {
- aRefNumStr = sOldPrefix + aRefNumStr;
+ aPrevStr = aPrevStr.copy(0,
+ aPrevStr.getLength() - aExtremities.nSuffixChars);
}
- sOldPrefix = OUString();
bOldHadPrefix = ( aExtremities.nPrefixChars > 0);
commit ee41ad3482011b3e736b8bbd51353f71b2369dfb
Author: Troy Rollo <libreoffice at troy.rollo.name>
Date: Mon Aug 26 13:35:45 2013 +0200
fdo#33960: sw: fix cross reference fields some more
Change-Id: Ia0a34c8fa475f9dea609962997bce9169d9b8878
diff --git a/sw/qa/complex/writer/CheckCrossReferences.java b/sw/qa/complex/writer/CheckCrossReferences.java
index 541ea49..c12f81a 100644
--- a/sw/qa/complex/writer/CheckCrossReferences.java
+++ b/sw/qa/complex/writer/CheckCrossReferences.java
@@ -38,28 +38,20 @@ public class CheckCrossReferences {
public com.sun.star.text.XTextField getNextField()
throws com.sun.star.uno.Exception
{
- if ( xPortionEnum != null ) {
- while ( xPortionEnum.hasMoreElements() ) {
- com.sun.star.beans.XPropertySet xPortionProps =
+ while (true) {
+ while (xPortionEnum == null) {
+ if (!xParaEnum.hasMoreElements())
+ fail("Cannot retrieve next field.");
+
+ com.sun.star.container.XEnumerationAccess aPara =
UnoRuntime.queryInterface(
- com.sun.star.beans.XPropertySet.class , xPortionEnum.nextElement());
- final String sPortionType =
- xPortionProps.getPropertyValue( "TextPortionType" ).toString();
- if ( sPortionType.equals( "TextField") ) {
- com.sun.star.text.XTextField xField = UnoRuntime.queryInterface(
- com.sun.star.text.XTextField.class,
- xPortionProps.getPropertyValue( "TextField" ) );
- assertNotNull("Cannot retrieve next field.", xField);
- return xField;
- }
+ com.sun.star.container.XEnumerationAccess.class, xParaEnum.nextElement());
+ xPortionEnum = aPara.createEnumeration();
}
- }
- while ( xParaEnum.hasMoreElements() ) {
- com.sun.star.container.XEnumerationAccess aPara =
- UnoRuntime.queryInterface(
- com.sun.star.container.XEnumerationAccess.class, xParaEnum.nextElement());
- xPortionEnum = aPara.createEnumeration();
+ if ( xPortionEnum == null )
+ break;
+
while ( xPortionEnum.hasMoreElements() ) {
com.sun.star.beans.XPropertySet xPortionProps =
UnoRuntime.queryInterface(
@@ -74,9 +66,9 @@ public class CheckCrossReferences {
return xField;
}
}
+ xPortionEnum = null;
}
- fail("Cannot retrieve next field.");
return null; // unreachable
}
@@ -135,6 +127,12 @@ public class CheckCrossReferences {
final String FldResult4 = "1";
final String FldResult5 = "1";
final String FldResult6 = "A.1";
+ final String FldResult7 = "2(a)";
+ final String FldResult8 = "2(b)";
+ final String FldResult9 = "2";
+ final String FldResult10 = "1(a)";
+ final String FldResult11 = "(b)";
+ final String FldResult12 = "(a)";
// variables for current field
com.sun.star.text.XTextField xField = null;
@@ -175,6 +173,42 @@ public class CheckCrossReferences {
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, FldResult7 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult12 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult7 );
+
+ xField = getNextField();
+ xProps = getFieldProps( xField );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult8 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult11 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult8 );
+
+ xField = getNextField();
+ xProps = getFieldProps( xField );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult9 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult9 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult9 );
+
+ 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, FldResult4 );
+
+ xField = getNextField();
+ xProps = getFieldProps( xField );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult10 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult12 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult10 );
+
+ xField = getNextField();
+ xProps = getFieldProps( xField );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult12 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult12 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult7 );
}
// insert a certain cross-reference bookmark and a reference field to this bookmark
diff --git a/sw/qa/complex/writer/testdocuments/CheckCrossReferences.odt b/sw/qa/complex/writer/testdocuments/CheckCrossReferences.odt
index d8102f0..d948442 100644
Binary files a/sw/qa/complex/writer/testdocuments/CheckCrossReferences.odt and b/sw/qa/complex/writer/testdocuments/CheckCrossReferences.odt differ
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index aa9b425..7b8d773 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -730,7 +730,6 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
if ( rNodeNum.GetLevelInListTree() >= 0 )
{
bool bOldHadPrefix = true;
- bool bFirstIteration = true;
OUString sOldPrefix;
const SwNodeNum* pWorkingNodeNum( &rNodeNum );
@@ -768,20 +767,14 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
aExtremities.nPrefixChars -= nStrip;
}
- if ((bFirstIteration || bOldHadPrefix) &&
+ if (bOldHadPrefix &&
aExtremities.nSuffixChars &&
!aExtremities.nPrefixChars
)
{
nStrip = 0;
- const sal_Int32 nLastPos = aPrevStr.getLength() - 1;
while (nStrip < aExtremities.nSuffixChars)
{
- const sal_Unicode cur = aPrevStr[nLastPos-nStrip];
- if (!bFirstIteration && '\t' != cur && ' ' != cur)
- {
- break;
- }
++nStrip;
}
if (nStrip)
@@ -789,7 +782,7 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
aPrevStr = aPrevStr.copy(0, aPrevStr.getLength()-nStrip);
}
}
- else if (!sOldPrefix.isEmpty())
+ else if (!aExtremities.nSuffixChars && !bOldHadPrefix)
{
aRefNumStr = sOldPrefix + aRefNumStr;
}
@@ -799,11 +792,6 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
aRefNumStr = aPrevStr + aRefNumStr;
}
- else if ( !aRefNumStr.isEmpty() )
- {
- sOldPrefix += " ";
- bOldHadPrefix = true;
- }
if ( bInclSuperiorNumLabels && pWorkingNodeNum->GetLevelInListTree() > 0 )
{
@@ -820,7 +808,6 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
{
break;
}
- bFirstIteration = false;
} while ( pWorkingNodeNum &&
pWorkingNodeNum->GetLevelInListTree() >= 0 &&
static_cast<sal_uInt8>(pWorkingNodeNum->GetLevelInListTree()) >= nRestrictInclToThisLevel );
More information about the Libreoffice-commits
mailing list