Skip to content

Commit

Permalink
fix(parser): 여러 색상 옵션 허용
Browse files Browse the repository at this point in the history
  • Loading branch information
hahnlee committed May 16, 2024
1 parent 5728b39 commit 4535503
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/parser/src/models/doc-info/border-fill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ export function mapFill(reader: ByteReader): Fill {
}
return { kind }
case FillKind.Color:
return { kind, content: ColorFill.fromReader(reader) } as const
return { kind, content: ColorFill.fromReader(reader, false) } as const
case FillKind.Image:
return { kind, content: ImageFill.fromReader(reader) } as const
case FillKind.Gradation:
return { kind, content: GradationFill.fromReader(reader) }
return { kind, content: GradationFill.fromReader(reader, false) }
default:
throw new Error(`Unknown fill kind: ${kind}`)
}
Expand Down Expand Up @@ -276,7 +276,7 @@ export class ColorFill {
public alpha: number,
) {}

static fromReader(reader: ByteReader) {
static fromReader(reader: ByteReader, checkEof: boolean = true) {
const backgroundColor = ColorRef.fromBits(reader.readUInt32())
const patternColor = ColorRef.fromBits(reader.readUInt32())
const patternKind = mapPatternKind(reader.readInt32() + 1)
Expand All @@ -287,7 +287,7 @@ export class ColorFill {
throw new Error('DocInfo: ColorFill: Additional info is not zero')
}

if (!reader.isEOF()) {
if (checkEof && !reader.isEOF()) {
throw new Error('DocInfo: ColorFill: Reader is not EOF')
}

Expand Down Expand Up @@ -341,7 +341,7 @@ export class GradationFill {
public alpha: number,
) {}

static fromReader(reader: ByteReader) {
static fromReader(reader: ByteReader, checkEof = true) {
const kind = mapGradationKind(reader.readUInt8())
const angle = reader.readUInt32()
const centerX = reader.readUInt32()
Expand All @@ -365,7 +365,7 @@ export class GradationFill {
const stepCenter = reader.readUInt8()
const alpha = reader.readUInt8()

if (!reader.isEOF()) {
if (checkEof && !reader.isEOF()) {
throw new Error('DocInfo: GradationFill: Reader is not EOF')
}

Expand Down

0 comments on commit 4535503

Please sign in to comment.