@@ -943,6 +943,58 @@ public virtual Rectangle GetInnerAreaBBox() {
943943 return rect ;
944944 }
945945
946+ /// <summary>Applies margins of the renderer on the given rectangle</summary>
947+ /// <param name="rect">a rectangle margins will be applied on.</param>
948+ /// <param name="reverse">
949+ /// indicates whether margins will be applied
950+ /// inside (in case of false) or outside (in case of true) the rectangle.
951+ /// </param>
952+ /// <returns>
953+ /// a
954+ /// <see cref="iText.Kernel.Geom.Rectangle">border box</see>
955+ /// of the renderer
956+ /// </returns>
957+ /// <seealso cref="GetMargins()"/>
958+ public virtual Rectangle ApplyMargins ( Rectangle rect , bool reverse ) {
959+ return this . ApplyMargins ( rect , GetMargins ( ) , reverse ) ;
960+ }
961+
962+ /// <summary>
963+ /// Applies the border box of the renderer on the given rectangle
964+ /// If the border of a certain side is null, the side will remain as it was.
965+ /// </summary>
966+ /// <param name="rect">a rectangle the border box will be applied on.</param>
967+ /// <param name="reverse">
968+ /// indicates whether the border box will be applied
969+ /// inside (in case of false) or outside (in case of false) the rectangle.
970+ /// </param>
971+ /// <returns>
972+ /// a
973+ /// <see cref="iText.Kernel.Geom.Rectangle">border box</see>
974+ /// of the renderer
975+ /// </returns>
976+ /// <seealso cref="GetBorders()"/>
977+ public virtual Rectangle ApplyBorderBox ( Rectangle rect , bool reverse ) {
978+ Border [ ] borders = GetBorders ( ) ;
979+ return ApplyBorderBox ( rect , borders , reverse ) ;
980+ }
981+
982+ /// <summary>Applies paddings of the renderer on the given rectangle</summary>
983+ /// <param name="rect">a rectangle paddings will be applied on.</param>
984+ /// <param name="reverse">
985+ /// indicates whether paddings will be applied
986+ /// inside (in case of false) or outside (in case of false) the rectangle.
987+ /// </param>
988+ /// <returns>
989+ /// a
990+ /// <see cref="iText.Kernel.Geom.Rectangle">border box</see>
991+ /// of the renderer
992+ /// </returns>
993+ /// <seealso cref="GetPaddings()"/>
994+ public virtual Rectangle ApplyPaddings ( Rectangle rect , bool reverse ) {
995+ return ApplyPaddings ( rect , GetPaddings ( ) , reverse ) ;
996+ }
997+
946998 public virtual bool IsFirstOnRootArea ( ) {
947999 return IsFirstOnRootArea ( false ) ;
9481000 }
@@ -953,27 +1005,27 @@ protected internal virtual void ApplyDestinationsAndAnnotation(DrawContext drawC
9531005 ApplyLinkAnnotation ( drawContext . GetDocument ( ) ) ;
9541006 }
9551007
956- internal static bool IsBorderBoxSizing ( IRenderer renderer ) {
1008+ protected internal static bool IsBorderBoxSizing ( IRenderer renderer ) {
9571009 BoxSizingPropertyValue ? boxSizing = renderer . GetProperty < BoxSizingPropertyValue ? > ( Property . BOX_SIZING ) ;
9581010 return boxSizing != null && boxSizing . Equals ( BoxSizingPropertyValue . BORDER_BOX ) ;
9591011 }
9601012
961- internal virtual bool IsOverflowProperty ( OverflowPropertyValue ? equalsTo , int overflowProperty ) {
1013+ protected internal virtual bool IsOverflowProperty ( OverflowPropertyValue ? equalsTo , int overflowProperty ) {
9621014 return IsOverflowProperty ( equalsTo , this . GetProperty < OverflowPropertyValue ? > ( overflowProperty ) ) ;
9631015 }
9641016
965- internal static bool IsOverflowProperty ( OverflowPropertyValue ? equalsTo , IRenderer renderer , int overflowProperty
966- ) {
1017+ protected internal static bool IsOverflowProperty ( OverflowPropertyValue ? equalsTo , IRenderer renderer , int
1018+ overflowProperty ) {
9671019 return IsOverflowProperty ( equalsTo , renderer . GetProperty < OverflowPropertyValue ? > ( overflowProperty ) ) ;
9681020 }
9691021
970- internal static bool IsOverflowProperty ( OverflowPropertyValue ? equalsTo , OverflowPropertyValue ? rendererOverflowProperty
971- ) {
1022+ protected internal static bool IsOverflowProperty ( OverflowPropertyValue ? equalsTo , OverflowPropertyValue ?
1023+ rendererOverflowProperty ) {
9721024 return equalsTo . Equals ( rendererOverflowProperty ) || equalsTo . Equals ( OverflowPropertyValue . FIT ) && rendererOverflowProperty
9731025 == null ;
9741026 }
9751027
976- internal static bool IsOverflowFit ( OverflowPropertyValue ? rendererOverflowProperty ) {
1028+ protected internal static bool IsOverflowFit ( OverflowPropertyValue ? rendererOverflowProperty ) {
9771029 return rendererOverflowProperty == null || OverflowPropertyValue . FIT . Equals ( rendererOverflowProperty ) ;
9781030 }
9791031
@@ -1128,7 +1180,7 @@ internal static void ProcessWaitingDrawing(IRenderer child, Transform transformP
11281180 /// property value.
11291181 /// </remarks>
11301182 /// <param name="updatedWidthValue">element's new fixed content box width.</param>
1131- internal virtual void UpdateWidth ( UnitValue updatedWidthValue ) {
1183+ protected internal virtual void UpdateWidth ( UnitValue updatedWidthValue ) {
11321184 if ( updatedWidthValue . IsPointValue ( ) && IsBorderBoxSizing ( this ) ) {
11331185 updatedWidthValue . SetValue ( updatedWidthValue . GetValue ( ) + CalculatePaddingBorderWidth ( this ) ) ;
11341186 }
@@ -1236,7 +1288,7 @@ private float[] CalculateRadii(BorderRadius[] radii, Rectangle area, bool horizo
12361288 /// property value.
12371289 /// </remarks>
12381290 /// <param name="updatedHeight">element's new fixed content box height, shall be not null.</param>
1239- internal virtual void UpdateHeight ( UnitValue updatedHeight ) {
1291+ protected internal virtual void UpdateHeight ( UnitValue updatedHeight ) {
12401292 if ( IsBorderBoxSizing ( this ) && updatedHeight . IsPointValue ( ) ) {
12411293 updatedHeight . SetValue ( updatedHeight . GetValue ( ) + CalculatePaddingBorderHeight ( this ) ) ;
12421294 }
@@ -1297,7 +1349,7 @@ internal virtual void UpdateHeight(UnitValue updatedHeight) {
12971349 /// property value.
12981350 /// </remarks>
12991351 /// <param name="updatedMaxHeight">element's new content box max-height, shall be not null.</param>
1300- internal virtual void UpdateMaxHeight ( UnitValue updatedMaxHeight ) {
1352+ protected internal virtual void UpdateMaxHeight ( UnitValue updatedMaxHeight ) {
13011353 if ( IsBorderBoxSizing ( this ) && updatedMaxHeight . IsPointValue ( ) ) {
13021354 updatedMaxHeight . SetValue ( updatedMaxHeight . GetValue ( ) + CalculatePaddingBorderHeight ( this ) ) ;
13031355 }
@@ -1349,7 +1401,7 @@ internal virtual void UpdateMaxHeight(UnitValue updatedMaxHeight) {
13491401 /// property value.
13501402 /// </remarks>
13511403 /// <param name="updatedMinHeight">element's new content box min-height, shall be not null.</param>
1352- internal virtual void UpdateMinHeight ( UnitValue updatedMinHeight ) {
1404+ protected internal virtual void UpdateMinHeight ( UnitValue updatedMinHeight ) {
13531405 if ( IsBorderBoxSizing ( this ) && updatedMinHeight . IsPointValue ( ) ) {
13541406 updatedMinHeight . SetValue ( updatedMinHeight . GetValue ( ) + CalculatePaddingBorderHeight ( this ) ) ;
13551407 }
@@ -1407,9 +1459,7 @@ protected internal virtual void AddAllProperties(IDictionary<int, Object> proper
14071459 }
14081460
14091461 protected internal virtual float ? GetLastYLineRecursively ( ) {
1410- if ( IsOverflowProperty ( OverflowPropertyValue . HIDDEN , Property . OVERFLOW_X ) || IsOverflowProperty ( OverflowPropertyValue
1411- . HIDDEN , Property . OVERFLOW_Y ) ) {
1412- // TODO may be this logic should also be based on BlockFormattingContextUtil?
1462+ if ( ! AllowLastYLineRecursiveExtraction ( ) ) {
14131463 return null ;
14141464 }
14151465 for ( int i = childRenderers . Count - 1 ; i >= 0 ; i -- ) {
@@ -1424,20 +1474,9 @@ protected internal virtual void AddAllProperties(IDictionary<int, Object> proper
14241474 return null ;
14251475 }
14261476
1427- /// <summary>Applies margins of the renderer on the given rectangle</summary>
1428- /// <param name="rect">a rectangle margins will be applied on.</param>
1429- /// <param name="reverse">
1430- /// indicates whether margins will be applied
1431- /// inside (in case of false) or outside (in case of true) the rectangle.
1432- /// </param>
1433- /// <returns>
1434- /// a
1435- /// <see cref="iText.Kernel.Geom.Rectangle">border box</see>
1436- /// of the renderer
1437- /// </returns>
1438- /// <seealso cref="GetMargins()"/>
1439- protected internal virtual Rectangle ApplyMargins ( Rectangle rect , bool reverse ) {
1440- return this . ApplyMargins ( rect , GetMargins ( ) , reverse ) ;
1477+ protected internal virtual bool AllowLastYLineRecursiveExtraction ( ) {
1478+ return ! IsOverflowProperty ( OverflowPropertyValue . HIDDEN , Property . OVERFLOW_X ) && ! IsOverflowProperty ( OverflowPropertyValue
1479+ . HIDDEN , Property . OVERFLOW_Y ) ;
14411480 }
14421481
14431482 /// <summary>Applies given margins on the given rectangle</summary>
@@ -1497,22 +1536,6 @@ protected internal virtual UnitValue[] GetPaddings() {
14971536 return GetPaddings ( this ) ;
14981537 }
14991538
1500- /// <summary>Applies paddings of the renderer on the given rectangle</summary>
1501- /// <param name="rect">a rectangle paddings will be applied on.</param>
1502- /// <param name="reverse">
1503- /// indicates whether paddings will be applied
1504- /// inside (in case of false) or outside (in case of false) the rectangle.
1505- /// </param>
1506- /// <returns>
1507- /// a
1508- /// <see cref="iText.Kernel.Geom.Rectangle">border box</see>
1509- /// of the renderer
1510- /// </returns>
1511- /// <seealso cref="GetPaddings()"/>
1512- protected internal virtual Rectangle ApplyPaddings ( Rectangle rect , bool reverse ) {
1513- return ApplyPaddings ( rect , GetPaddings ( ) , reverse ) ;
1514- }
1515-
15161539 /// <summary>Applies given paddings on the given rectangle</summary>
15171540 /// <param name="rect">a rectangle paddings will be applied on.</param>
15181541 /// <param name="paddings">the paddings to be applied on the given rectangle</param>
@@ -1550,26 +1573,6 @@ protected internal virtual Rectangle ApplyPaddings(Rectangle rect, UnitValue[] p
15501573 3 ] . GetValue ( ) , reverse ) ;
15511574 }
15521575
1553- /// <summary>
1554- /// Applies the border box of the renderer on the given rectangle
1555- /// If the border of a certain side is null, the side will remain as it was.
1556- /// </summary>
1557- /// <param name="rect">a rectangle the border box will be applied on.</param>
1558- /// <param name="reverse">
1559- /// indicates whether the border box will be applied
1560- /// inside (in case of false) or outside (in case of false) the rectangle.
1561- /// </param>
1562- /// <returns>
1563- /// a
1564- /// <see cref="iText.Kernel.Geom.Rectangle">border box</see>
1565- /// of the renderer
1566- /// </returns>
1567- /// <seealso cref="GetBorders()"/>
1568- protected internal virtual Rectangle ApplyBorderBox ( Rectangle rect , bool reverse ) {
1569- Border [ ] borders = GetBorders ( ) ;
1570- return ApplyBorderBox ( rect , borders , reverse ) ;
1571- }
1572-
15731576 /// <summary>Applies the given border box (borders) on the given rectangle</summary>
15741577 /// <param name="rect">a rectangle paddings will be applied on.</param>
15751578 /// <param name="borders">
0 commit comments