Skip to content

Commit 9b6651d

Browse files
SnipxUbuntu
authored andcommitted
Introduce new LayoutLogMessageConstant class and move one log message there
DEVSIX-6175
1 parent c38d843 commit 9b6651d

23 files changed

+155
-123
lines changed

io/src/main/java/com/itextpdf/io/logs/IoLogMessageConstant.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ public final class IoLogMessageConstant {
183183
public static final String DURING_CONSTRUCTION_OF_ICC_PROFILE_ERROR_OCCURRED = "During the construction of the ICC"
184184
+ " profile, the {0} error with message \"{1}\" occurred, the ICC profile will not be installed in the "
185185
+ "image.";
186+
187+
/**
188+
* @deprecated Unused constant. Will be removed in 7.3
189+
*/
190+
@Deprecated
186191
public static final String ELEMENT_DOES_NOT_FIT_AREA = "Element does not fit current area. {0}";
187192

188193
public static final String ELEMENT_WAS_FORCE_PLACED_KEEP_WITH_NEXT_WILL_BE_IGNORED =
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.itextpdf.layout.logs;
2+
3+
/**
4+
* Class containing constants to be used in layout.
5+
*/
6+
public final class LayoutLogMessageConstant {
7+
8+
public static final String ELEMENT_DOES_NOT_FIT_AREA = "Element does not fit current area. {0}";
9+
10+
private LayoutLogMessageConstant() {
11+
//Private constructor will prevent the instantiation of this class directly
12+
}
13+
}

layout/src/main/java/com/itextpdf/layout/renderer/BlockRenderer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ This file is part of the iText (R) project.
5858
import com.itextpdf.layout.layout.LayoutResult;
5959
import com.itextpdf.layout.layout.MinMaxWidthLayoutResult;
6060
import com.itextpdf.layout.layout.PositionedLayoutContext;
61+
import com.itextpdf.layout.logs.LayoutLogMessageConstant;
6162
import com.itextpdf.layout.margincollapse.MarginsCollapseHandler;
6263
import com.itextpdf.layout.margincollapse.MarginsCollapseInfo;
6364
import com.itextpdf.layout.minmaxwidth.MinMaxWidth;
@@ -446,7 +447,7 @@ public LayoutResult layout(LayoutContext layoutContext) {
446447
if (isNotFittingLayoutArea(layoutContext.getArea())) {
447448
if (isNotFittingWidth(layoutContext.getArea()) && !isNotFittingHeight(layoutContext.getArea())) {
448449
LoggerFactory.getLogger(getClass())
449-
.warn(MessageFormatUtil.format(IoLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA,
450+
.warn(MessageFormatUtil.format(LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA,
450451
"It fits by height so it will be forced placed"));
451452
} else if (!Boolean.TRUE.equals(getPropertyAsBoolean(Property.FORCED_PLACEMENT))) {
452453
floatRendererAreas.retainAll(nonChildFloatingRendererAreas);

layout/src/main/java/com/itextpdf/layout/renderer/ParagraphRenderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ This file is part of the iText (R) project.
4343
*/
4444
package com.itextpdf.layout.renderer;
4545

46-
import com.itextpdf.io.logs.IoLogMessageConstant;
4746
import com.itextpdf.commons.utils.MessageFormatUtil;
4847
import com.itextpdf.kernel.geom.Rectangle;
4948
import com.itextpdf.layout.borders.Border;
@@ -54,6 +53,7 @@ This file is part of the iText (R) project.
5453
import com.itextpdf.layout.layout.LineLayoutContext;
5554
import com.itextpdf.layout.layout.LineLayoutResult;
5655
import com.itextpdf.layout.layout.MinMaxWidthLayoutResult;
56+
import com.itextpdf.layout.logs.LayoutLogMessageConstant;
5757
import com.itextpdf.layout.margincollapse.MarginsCollapseHandler;
5858
import com.itextpdf.layout.minmaxwidth.MinMaxWidth;
5959
import com.itextpdf.layout.minmaxwidth.MinMaxWidthUtils;
@@ -484,7 +484,7 @@ protected LayoutResult directLayout(LayoutContext layoutContext) {
484484
if (isNotFittingLayoutArea(layoutContext.getArea())) {
485485
if(isNotFittingWidth(layoutContext.getArea()) && !isNotFittingHeight(layoutContext.getArea())) {
486486
LoggerFactory.getLogger(getClass())
487-
.warn(MessageFormatUtil.format(IoLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA,
487+
.warn(MessageFormatUtil.format(LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA,
488488
"It fits by height so it will be forced placed"));
489489
} else if (!Boolean.TRUE.equals(getPropertyAsBoolean(Property.FORCED_PLACEMENT))) {
490490
floatRendererAreas.retainAll(nonChildFloatingRendererAreas);

layout/src/main/java/com/itextpdf/layout/renderer/RootRenderer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ This file is part of the iText (R) project.
5757
import com.itextpdf.layout.layout.LayoutResult;
5858
import com.itextpdf.layout.layout.PositionedLayoutContext;
5959
import com.itextpdf.layout.layout.RootLayoutArea;
60+
import com.itextpdf.layout.logs.LayoutLogMessageConstant;
6061
import com.itextpdf.layout.margincollapse.MarginsCollapseHandler;
6162
import com.itextpdf.layout.margincollapse.MarginsCollapseInfo;
6263
import com.itextpdf.layout.properties.ClearPropertyValue;
@@ -168,7 +169,7 @@ public void addChild(IRenderer renderer) {
168169
((ImageRenderer) result.getOverflowRenderer()).autoScale(currentArea);
169170
result.getOverflowRenderer().setProperty(Property.FORCED_PLACEMENT, true);
170171
Logger logger = LoggerFactory.getLogger(RootRenderer.class);
171-
logger.warn(MessageFormatUtil.format(IoLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, ""));
172+
logger.warn(MessageFormatUtil.format(LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, ""));
172173
}
173174
} else {
174175
if (currentArea.isEmptyArea() && result.getAreaBreak() == null) {
@@ -499,7 +500,7 @@ private boolean updateForcedPlacement(IRenderer currentRenderer, IRenderer overf
499500
overflowRenderer.setProperty(Property.FORCED_PLACEMENT, true);
500501
Logger logger = LoggerFactory.getLogger(RootRenderer.class);
501502
if (logger.isWarnEnabled()) {
502-
logger.warn(MessageFormatUtil.format(IoLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, ""));
503+
logger.warn(MessageFormatUtil.format(LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, ""));
503504
}
504505
return true;
505506
}
@@ -530,7 +531,7 @@ private boolean tryDisableKeepTogether(LayoutResult result,
530531
Logger logger = LoggerFactory.getLogger(RootRenderer.class);
531532
if (logger.isWarnEnabled()) {
532533
logger.warn(MessageFormatUtil.format(
533-
IoLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA,
534+
LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA,
534535
"KeepTogether property will be ignored."));
535536
}
536537
if (!rendererIsFloat) {

layout/src/test/java/com/itextpdf/layout/BorderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ This file is part of the iText (R) project.
4242
*/
4343
package com.itextpdf.layout;
4444

45-
import com.itextpdf.io.logs.IoLogMessageConstant;
4645
import com.itextpdf.io.image.ImageDataFactory;
4746
import com.itextpdf.kernel.colors.ColorConstants;
4847
import com.itextpdf.kernel.colors.DeviceCmyk;
@@ -67,6 +66,7 @@ This file is part of the iText (R) project.
6766
import com.itextpdf.layout.element.List;
6867
import com.itextpdf.layout.element.ListItem;
6968
import com.itextpdf.layout.element.Paragraph;
69+
import com.itextpdf.layout.logs.LayoutLogMessageConstant;
7070
import com.itextpdf.test.ExtendedITextTest;
7171
import com.itextpdf.test.annotations.LogMessage;
7272
import com.itextpdf.test.annotations.LogMessages;
@@ -313,7 +313,7 @@ public void borderBoxTest() throws IOException, InterruptedException {
313313

314314
@Test
315315
@LogMessages(messages = {
316-
@LogMessage(messageTemplate = IoLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, count = 1)
316+
@LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, count = 1)
317317
})
318318
public void rotatedBordersTest() throws IOException, InterruptedException {
319319
fileName = "rotatedBordersTest.pdf";

layout/src/test/java/com/itextpdf/layout/DefaultLayoutTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ This file is part of the iText (R) project.
6161
import com.itextpdf.layout.element.AreaBreak;
6262
import com.itextpdf.layout.element.Paragraph;
6363
import com.itextpdf.layout.element.Text;
64+
import com.itextpdf.layout.logs.LayoutLogMessageConstant;
6465
import com.itextpdf.test.AssertUtil;
6566
import com.itextpdf.test.ExtendedITextTest;
6667
import com.itextpdf.test.LogLevelConstants;
@@ -188,7 +189,7 @@ public void textWithWhitespacesTest01() throws IOException, InterruptedException
188189

189190
@Test
190191
@LogMessages(messages = {
191-
@LogMessage(count = 1, messageTemplate = IoLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA)
192+
@LogMessage(count = 1, messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA)
192193
})
193194
public void addParagraphOnShortPage1() throws IOException, InterruptedException {
194195
String outFileName = destinationFolder + "addParagraphOnShortPage1.pdf";
@@ -213,7 +214,7 @@ public void addParagraphOnShortPage1() throws IOException, InterruptedException
213214

214215
@Test
215216
@LogMessages(messages = {
216-
@LogMessage(messageTemplate = IoLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA)
217+
@LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA)
217218
})
218219
public void addParagraphOnShortPage2() throws IOException, InterruptedException {
219220
String outFileName = destinationFolder + "addParagraphOnShortPage2.pdf";
@@ -234,7 +235,7 @@ public void addParagraphOnShortPage2() throws IOException, InterruptedException
234235

235236
@Test
236237
@LogMessages(messages = {
237-
@LogMessage(messageTemplate = IoLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA)
238+
@LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA)
238239
})
239240
public void addWordOnShortPageTest01() throws IOException, InterruptedException {
240241
String outFileName = destinationFolder + "addWordOnShortPageTest01.pdf";

0 commit comments

Comments
 (0)