diff options
author | Troy Rollo <libreoffice@troy.rollo.name> | 2013-08-26 13:35:45 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-08-26 15:12:47 +0200 |
commit | ee41ad3482011b3e736b8bbd51353f71b2369dfb (patch) | |
tree | 98d745a4ad607e93992a6ce9c1ec25a27afe66ba /sw/qa/complex | |
parent | 2492604c92506043982551755710c78dcecf7c31 (diff) |
fdo#33960: sw: fix cross reference fields some more
Change-Id: Ia0a34c8fa475f9dea609962997bce9169d9b8878
Diffstat (limited to 'sw/qa/complex')
-rw-r--r-- | sw/qa/complex/writer/CheckCrossReferences.java | 74 | ||||
-rw-r--r-- | sw/qa/complex/writer/testdocuments/CheckCrossReferences.odt | bin | 11628 -> 17626 bytes |
2 files changed, 54 insertions, 20 deletions
diff --git a/sw/qa/complex/writer/CheckCrossReferences.java b/sw/qa/complex/writer/CheckCrossReferences.java index 541ea49d4c72..c12f81a74e91 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 Binary files differindex d8102f0356f8..d9484421d3dc 100644 --- a/sw/qa/complex/writer/testdocuments/CheckCrossReferences.odt +++ b/sw/qa/complex/writer/testdocuments/CheckCrossReferences.odt |