@@ -43,6 +43,7 @@ This file is part of the iText (R) project.
43
43
44
44
import org .slf4j .Logger ;
45
45
import org .slf4j .LoggerFactory ;
46
+
46
47
import java .util .Collections ;
47
48
import java .util .List ;
48
49
@@ -54,6 +55,7 @@ public class ListItemRenderer extends DivRenderer {
54
55
55
56
/**
56
57
* Creates a ListItemRenderer from its corresponding layout object.
58
+ *
57
59
* @param modelElement the {@link com.itextpdf.layout.element.ListItem} which this object should manage
58
60
*/
59
61
public ListItemRenderer (ListItem modelElement ) {
@@ -182,7 +184,7 @@ public void draw(DrawContext drawContext) {
182
184
applyBorderBox (occupiedArea .getBBox (), true );
183
185
applyMargins (occupiedArea .getBBox (), true );
184
186
185
- ListSymbolAlignment listSymbolAlignment = (ListSymbolAlignment )parent .<ListSymbolAlignment >getProperty (Property .LIST_SYMBOL_ALIGNMENT ,
187
+ ListSymbolAlignment listSymbolAlignment = (ListSymbolAlignment ) parent .<ListSymbolAlignment >getProperty (Property .LIST_SYMBOL_ALIGNMENT ,
186
188
isRtl ? ListSymbolAlignment .LEFT : ListSymbolAlignment .RIGHT );
187
189
float dxPosition = x - symbolRenderer .getOccupiedArea ().getBBox ().getX ();
188
190
if (listSymbolAlignment == ListSymbolAlignment .RIGHT ) {
@@ -210,7 +212,7 @@ public void draw(DrawContext drawContext) {
210
212
211
213
// symbols are not drawn here, because they are in page margins
212
214
if (!isRtl && symbolRenderer .getOccupiedArea ().getBBox ().getRight () > effectiveArea .getLeft ()
213
- || isRtl && symbolRenderer .getOccupiedArea ().getBBox ().getLeft () < effectiveArea .getRight ()) {
215
+ || isRtl && symbolRenderer .getOccupiedArea ().getBBox ().getLeft () < effectiveArea .getRight ()) {
214
216
beginElementOpacityApplying (drawContext );
215
217
symbolRenderer .draw (drawContext );
216
218
endElementOpacityApplying (drawContext );
@@ -261,20 +263,23 @@ private void applyListSymbolPosition() {
261
263
ParagraphRenderer paragraphRenderer = (ParagraphRenderer ) childRenderers .get (0 );
262
264
// TODO DEVSIX-6876 LIST_SYMBOL_INDENT is not inherited
263
265
Float symbolIndent = this .getPropertyAsFloat (Property .LIST_SYMBOL_INDENT );
264
-
265
- if (symbolRenderer instanceof LineRenderer ) {
266
- if ( symbolIndent != null ) {
267
- symbolRenderer . getChildRenderers (). get ( 1 ). setProperty ( isRtl ? Property . MARGIN_LEFT : Property . MARGIN_RIGHT , UnitValue . createPointValue (( float ) symbolIndent ));
268
- }
269
- for (IRenderer childRenderer : symbolRenderer .getChildRenderers ()) {
266
+ if ( symbolRenderer instanceof LineRenderer ) {
267
+ if (symbolIndent != null ) {
268
+ symbolRenderer . getChildRenderers (). get ( 1 ). setProperty ( isRtl ? Property . MARGIN_LEFT : Property . MARGIN_RIGHT , UnitValue . createPointValue (( float ) symbolIndent ));
269
+ }
270
+ if (! paragraphRenderer . childRenderers . contains ( symbolRenderer . getChildRenderers (). get ( 1 ))) {
271
+ for (IRenderer childRenderer : symbolRenderer .getChildRenderers ()) {
270
272
paragraphRenderer .childRenderers .add (0 , childRenderer );
271
273
}
272
- } else {
273
- if (symbolIndent != null ) {
274
- symbolRenderer .setProperty (isRtl ? Property .MARGIN_LEFT : Property .MARGIN_RIGHT , UnitValue .createPointValue ((float ) symbolIndent ));
275
- }
274
+ }
275
+ } else {
276
+ if (symbolIndent != null ) {
277
+ symbolRenderer .setProperty (isRtl ? Property .MARGIN_LEFT : Property .MARGIN_RIGHT , UnitValue .createPointValue ((float ) symbolIndent ));
278
+ }
279
+ if (!paragraphRenderer .childRenderers .contains (symbolRenderer )) {
276
280
paragraphRenderer .childRenderers .add (0 , symbolRenderer );
277
281
}
282
+ }
278
283
symbolAddedInside = true ;
279
284
} else if (childRenderers .size () > 0 && childRenderers .get (0 ) instanceof ImageRenderer ) {
280
285
IRenderer paragraphRenderer = renderSymbolInNeutralParagraph ();
@@ -322,11 +327,11 @@ private float[] calculateAscenderDescender() {
322
327
Property .FONT_SIZE ));
323
328
}
324
329
float [] ascenderDescender = TextRenderer .calculateAscenderDescender (listItemFont );
325
- return new float [] {
330
+ return new float []{
326
331
fontSize .getValue () * FontProgram .convertTextSpaceToGlyphSpace (ascenderDescender [0 ]),
327
332
fontSize .getValue () * FontProgram .convertTextSpaceToGlyphSpace (ascenderDescender [1 ])
328
333
};
329
334
}
330
- return new float [] {0 , 0 };
335
+ return new float []{0 , 0 };
331
336
}
332
337
}
0 commit comments