Skip to content

Commit 17ef711

Browse files
committed
refactor: Clean up Makefile and improve code readability in PDF render objects
1 parent fc811bb commit 17ef711

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

Makefile

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
# CONFIGURATION
1212
# ============================================================================
1313

14-
# Xcode project used to build TPPDF
15-
XCODE_PROJECT = TPPDF.xcodeproj
16-
1714
# Xcode scheme used to build TPPDF
1815
XCODE_SCHEME = TPPDF
1916

@@ -209,7 +206,6 @@ test-disable:
209206
.PHONY: test-ios
210207
test-ios: build-ios test-enable
211208
set -o pipefail && NSUnbufferedIO=YES xcrun xcodebuild \
212-
-project $(XCODE_PROJECT) \
213209
-scheme $(XCODE_SCHEME) \
214210
-destination 'platform=iOS Simulator,OS=$(IOS_SIMULATOR_OS),name=$(IOS_DEVICE_NAME)' \
215211
test | tee raw-test-ios.log | xcbeautify --preserve-unbeautified
@@ -221,7 +217,6 @@ test-ios: build-ios test-enable
221217
.PHONY: test-macos
222218
test-macos: build-macos test-enable
223219
set -o pipefail && NSUnbufferedIO=YES xcrun xcodebuild \
224-
-project $(XCODE_PROJECT) \
225220
-scheme $(XCODE_SCHEME) \
226221
-destination 'platform=macOS' \
227222
test | tee raw-test-macos.log | xcbeautify --preserve-unbeautified
@@ -233,7 +228,6 @@ test-macos: build-macos test-enable
233228
.PHONY: test-maccatalyst
234229
test-maccatalyst: build-maccatalyst test-enable
235230
set -o pipefail && NSUnbufferedIO=YES xcrun xcodebuild \
236-
-project $(XCODE_PROJECT) \
237231
-scheme $(XCODE_SCHEME) \
238232
-destination 'platform=macOS,variant=Mac Catalyst' \
239233
test | tee raw-test-maccatalyst.log | xcbeautify --preserve-unbeautified
@@ -245,7 +239,6 @@ test-maccatalyst: build-maccatalyst test-enable
245239
.PHONY: test-tvos
246240
test-tvos: build-tvos test-enable
247241
set -o pipefail && NSUnbufferedIO=YES xcrun xcodebuild \
248-
-project $(XCODE_PROJECT) \
249242
-scheme $(XCODE_SCHEME) \
250243
-destination 'platform=tvOS Simulator,OS=$(TVOS_SIMULATOR_OS),name=$(TVOS_DEVICE_NAME)' \
251244
test | tee raw-test-tvos.log | xcbeautify --preserve-unbeautified
@@ -257,7 +250,6 @@ test-tvos: build-tvos test-enable
257250
.PHONY: test-watchos
258251
test-watchos: build-watchos test-enable
259252
set -o pipefail && NSUnbufferedIO=YES xcrun xcodebuild \
260-
-project $(XCODE_PROJECT) \
261253
-scheme $(XCODE_SCHEME) \
262254
-destination 'platform=watchOS Simulator,OS=$(WATCHOS_SIMULATOR_OS),name=$(WATCHOS_DEVICE_NAME)' \
263255
test | tee raw-test-watchos.log | xcbeautify --preserve-unbeautified
@@ -269,7 +261,6 @@ test-watchos: build-watchos test-enable
269261
.PHONY: test-visionos
270262
test-visionos: build-visionos test-enable
271263
set -o pipefail && NSUnbufferedIO=YES xcrun xcodebuild \
272-
-project $(XCODE_PROJECT) \
273264
-scheme $(XCODE_SCHEME) \
274265
-destination 'platform=visionOS Simulator,OS=$(VISION_OS_SIMULATOR_OS),name=$(VISION_OS_DEVICE_NAME)' \
275266
test | tee raw-test-visionos.log | xcbeautify --preserve-unbeautified

Source/API/Utils/PDFRenderObject.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class PDFRenderObject: CustomStringConvertible {
2222

2323
/// Attributes set for this object, and their calculated frame
2424
var attributes: [(attribute: PDFObjectAttribute, frame: CGRect)] = []
25-
25+
2626
init(frame: CGRect = .null, attributes: [(attribute: PDFObjectAttribute, frame: CGRect)] = []) {
2727
self.frame = frame
2828
self.attributes = attributes

Source/Internal/Table/PDFTableObject.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class PDFTableObject: PDFRenderObject {
272272
return NSAttributedString(string: text, attributes: attributes)
273273
}
274274

275-
func createRenderObjects( // swiftlint:disable:this cyclomatic_complexity
275+
func createRenderObjects(
276276
generator: PDFGenerator,
277277
container: PDFContainer,
278278
cells: [PDFTableCalculatedCell],
@@ -304,7 +304,7 @@ class PDFTableObject: PDFRenderObject {
304304
cellFrame.origin.y += table.margin
305305
contentFrame.origin.y -= startPosition.y - minOffset
306306
contentFrame.origin.y += table.margin
307-
307+
308308
// Maintain pageStart and pageEnd
309309
pageStart.x = min(cellFrame.minX, pageStart.x)
310310
pageStart.y = min(cellFrame.minY, pageStart.y)
@@ -401,7 +401,7 @@ class PDFTableObject: PDFRenderObject {
401401
maxOffset: maxOffset)
402402
result += try sliceObject.calculate(generator: generator, container: container)
403403
}
404-
404+
405405
// Draw the table outline for the page
406406
let tableOutlineObject = PDFRectangleObject(lineStyle: table.style.outline, frame: CGRect(
407407
x: pageStart.x - table.margin,
@@ -410,13 +410,13 @@ class PDFTableObject: PDFRenderObject {
410410
height: pageEnd.y - pageStart.y + table.margin*2
411411
))
412412
result += [(container, tableOutlineObject)]
413-
413+
414414
if !nextPageCells.isEmpty {
415415
result += try PDFPageBreakObject().calculate(generator: generator, container: container)
416416
firstPage = false
417417
}
418418
} while !nextPageCells.isEmpty
419-
419+
420420
return (objects: result, offset: pageEnd.y + table.margin)
421421
}
422422

@@ -515,7 +515,7 @@ class PDFTableObject: PDFRenderObject {
515515
/// - frame: Frame of cell
516516
/// - Returns: Calculated `PDFRectangleObject`
517517
func createCellBackgroundObject(style: PDFTableCellStyle, frame: CGRect) -> PDFRenderObject {
518-
return PDFRectangleObject(lineStyle: .none, frame: frame, fillColor: style.colors.fill)
518+
PDFRectangleObject(lineStyle: .none, frame: frame, fillColor: style.colors.fill)
519519
}
520520

521521
/**

Tests/TPPDFTests/Layout/PDFLayout_Spec.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class PDFLayout_Spec: QuickSpec {
6464
it("can set content offset in heights") {
6565
expect(PDFContainer.all).to(allPass {
6666
let random = CGFloat(arc4random())
67-
layout.setContentOffset(in: $0, to: random)
68-
return layout.getContentOffset(in: $0) == random
67+
layout.setContentOffset(in: $0!, to: random)
68+
return layout.getContentOffset(in: $0!) == random
6969
})
7070
}
7171

0 commit comments

Comments
 (0)