Skip to content

Commit a7c829d

Browse files
Artyom Yanchevskyyulian-gaponenko
authored andcommitted
Add MetaInfoContainer, remove public getters of MetaInfo
DEVSIX-5605 Autoported commit. Original commit hash: [fa1597c49]
1 parent f2363e5 commit a7c829d

File tree

6 files changed

+97
-13
lines changed

6 files changed

+97
-13
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2021 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
using iText.Kernel.Counter.Event;
24+
using iText.Test;
25+
26+
namespace iText.Layout.Renderer {
27+
public class MetaInfoContainerUnitTest : ExtendedITextTest {
28+
[NUnit.Framework.Test]
29+
public virtual void CreateAndGetMetaInfoTest() {
30+
MetaInfoContainerUnitTest.TestMetaInfo metaInfo = new MetaInfoContainerUnitTest.TestMetaInfo();
31+
MetaInfoContainer metaInfoContainer = new MetaInfoContainer(metaInfo);
32+
NUnit.Framework.Assert.AreSame(metaInfo, metaInfoContainer.GetMetaInfo());
33+
}
34+
35+
[NUnit.Framework.Test]
36+
public virtual void GetNullMetaInfoTest() {
37+
MetaInfoContainer metaInfoContainer = new MetaInfoContainer(null);
38+
NUnit.Framework.Assert.IsNull(metaInfoContainer.GetMetaInfo());
39+
}
40+
41+
private class TestMetaInfo : IMetaInfo {
42+
}
43+
}
44+
}

itext/itext.kernel/itext/kernel/pdf/PdfDocument.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -589,13 +589,6 @@ public virtual PdfDocumentInfo GetDocumentInfo() {
589589
return info;
590590
}
591591

592-
/// <summary>Gets document MetaInfo.</summary>
593-
/// <returns>meta info</returns>
594-
public virtual IMetaInfo GetMetaInfo() {
595-
// TODO DEVSIX-5605 remove this public method before new license key release. Refactor logic to get metaInfo for pdfCalligraph module
596-
return properties != null ? properties.metaInfo : null;
597-
}
598-
599592
/// <summary>
600593
/// Gets original document id
601594
/// In order to set originalDocumentId

itext/itext.layout/itext/layout/properties/Property.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ public sealed class Property {
250250

251251
public const int MAX_WIDTH = 79;
252252

253+
public const int META_INFO = 135;
254+
253255
public const int MIN_HEIGHT = 85;
254256

255257
public const int MIN_WIDTH = 80;
@@ -370,7 +372,7 @@ public sealed class Property {
370372
/// </remarks>
371373
private static readonly bool[] INHERITED_PROPERTIES;
372374

373-
private const int MAX_INHERITED_PROPERTY_ID = 124;
375+
private const int MAX_INHERITED_PROPERTY_ID = 135;
374376

375377
static Property() {
376378
INHERITED_PROPERTIES = new bool[MAX_INHERITED_PROPERTY_ID + 1];
@@ -412,6 +414,7 @@ static Property() {
412414
INHERITED_PROPERTIES[iText.Layout.Properties.Property.RENDERING_MODE] = true;
413415
INHERITED_PROPERTIES[iText.Layout.Properties.Property.LINE_HEIGHT] = true;
414416
INHERITED_PROPERTIES[iText.Layout.Properties.Property.OVERFLOW_WRAP] = true;
417+
INHERITED_PROPERTIES[iText.Layout.Properties.Property.META_INFO] = true;
415418
}
416419

417420
private Property() {

itext/itext.layout/itext/layout/renderer/LineRenderer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,8 @@ private void UpdateBidiLevels(int totalNumberOfTrimmedGlyphs, BaseDirection? bas
15421542
if (unicodeIdsReorderingList.Count > 0) {
15431543
PdfDocument pdfDocument = GetPdfDocument();
15441544
SequenceId sequenceId = pdfDocument == null ? null : pdfDocument.GetDocumentIdWrapper();
1545-
IMetaInfo metaInfo = pdfDocument == null ? null : pdfDocument.GetMetaInfo();
1545+
MetaInfoContainer metaInfoContainer = this.GetProperty<MetaInfoContainer>(Property.META_INFO);
1546+
IMetaInfo metaInfo = metaInfoContainer == null ? null : metaInfoContainer.GetMetaInfo();
15461547
levels = TypographyUtils.GetBidiLevels(baseDirection, ArrayUtil.ToIntArray(unicodeIdsReorderingList), sequenceId
15471548
, metaInfo);
15481549
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2021 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
using iText.Kernel.Counter.Event;
24+
25+
namespace iText.Layout.Renderer {
26+
/// <summary>Class to store metaInfo that will be used for layout renderers.</summary>
27+
public class MetaInfoContainer {
28+
private readonly IMetaInfo metaInfo;
29+
30+
/// <summary>Creates MetaInfoContainer instance with provided meta info.</summary>
31+
/// <param name="metaInfo">the meta info</param>
32+
public MetaInfoContainer(IMetaInfo metaInfo) {
33+
this.metaInfo = metaInfo;
34+
}
35+
36+
/// <summary>Return the IMetaInfo object</summary>
37+
/// <returns>returns IMetaInfo</returns>
38+
internal virtual IMetaInfo GetMetaInfo() {
39+
return metaInfo;
40+
}
41+
}
42+
}

itext/itext.layout/itext/layout/renderer/TextRenderer.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,8 @@ public virtual void ApplyOtf() {
692692
if (!otfFeaturesApplied && TypographyUtils.IsPdfCalligraphAvailable() && text.start < text.end) {
693693
PdfDocument pdfDocument = GetPdfDocument();
694694
SequenceId sequenceId = pdfDocument == null ? null : pdfDocument.GetDocumentIdWrapper();
695-
IMetaInfo metaInfo = pdfDocument == null ? null : pdfDocument.GetMetaInfo();
695+
MetaInfoContainer metaInfoContainer = this.GetProperty<MetaInfoContainer>(Property.META_INFO);
696+
IMetaInfo metaInfo = metaInfoContainer == null ? null : metaInfoContainer.GetMetaInfo();
696697
if (HasOtfFont()) {
697698
Object typographyConfig = this.GetProperty<Object>(Property.TYPOGRAPHY_CONFIG);
698699
ICollection<UnicodeScript> supportedScripts = null;
@@ -898,7 +899,7 @@ public override void Draw(DrawContext drawContext) {
898899
if (horizontalScaling != null && horizontalScaling != 1) {
899900
canvas.SetHorizontalScaling((float)horizontalScaling * 100);
900901
}
901-
GlyphLine.IGlyphLineFilter filter = new _IGlyphLineFilter_959();
902+
GlyphLine.IGlyphLineFilter filter = new _IGlyphLineFilter_960();
902903
bool appearanceStreamLayout = true.Equals(GetPropertyAsBoolean(Property.APPEARANCE_STREAM_LAYOUT));
903904
if (GetReversedRanges() != null) {
904905
bool writeReversedChars = !appearanceStreamLayout;
@@ -960,8 +961,8 @@ public override void Draw(DrawContext drawContext) {
960961
}
961962
}
962963

963-
private sealed class _IGlyphLineFilter_959 : GlyphLine.IGlyphLineFilter {
964-
public _IGlyphLineFilter_959() {
964+
private sealed class _IGlyphLineFilter_960 : GlyphLine.IGlyphLineFilter {
965+
public _IGlyphLineFilter_960() {
965966
}
966967

967968
public bool Accept(Glyph glyph) {

0 commit comments

Comments
 (0)