changeset 14557:3225e407ffbd

8265574: Improve handling of sheets Reviewed-by: mbalao, andrew
author alvdavi
date Thu, 14 Oct 2021 01:33:46 +0100
parents 7e0a831ae291
children b27642b17f65
files src/share/classes/javax/swing/text/rtf/RTFReader.java
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/javax/swing/text/rtf/RTFReader.java	Thu Oct 14 01:28:24 2021 +0100
+++ b/src/share/classes/javax/swing/text/rtf/RTFReader.java	Thu Oct 14 01:33:46 2021 +0100
@@ -973,19 +973,27 @@
             return true;
         }
 
-        public Style realize()
+        public Style realize() {
+            return realize(null);
+        }
+
+        private Style realize(Set<Integer> alreadyMetBasisIndexSet)
         {
             Style basis = null;
             Style next = null;
 
+            if (alreadyMetBasisIndexSet == null) {
+                alreadyMetBasisIndexSet = new HashSet<>();
+            }
+
             if (realizedStyle != null)
                 return realizedStyle;
 
-            if (basedOn != STYLENUMBER_NONE) {
+            if (basedOn != STYLENUMBER_NONE && alreadyMetBasisIndexSet.add(basedOn)) {
                 StyleDefiningDestination styleDest;
-                styleDest = definedStyles.get(Integer.valueOf(basedOn));
+                styleDest = definedStyles.get(basedOn);
                 if (styleDest != null && styleDest != this) {
-                    basis = styleDest.realize();
+                    basis = styleDest.realize(alreadyMetBasisIndexSet);
                 }
             }