Combine if/else block with switch for getOperatorList.
This commit is contained in:
parent
f88e0b51c2
commit
a4f329aa38
@ -540,7 +540,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
|
|
||||||
var promise = new Promise();
|
var promise = new Promise();
|
||||||
var args = [];
|
var args = [];
|
||||||
nextOp:
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
var obj = parser.getObj();
|
var obj = parser.getObj();
|
||||||
@ -584,8 +583,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
|
|
||||||
// TODO figure out how to type-check vararg functions
|
// TODO figure out how to type-check vararg functions
|
||||||
|
|
||||||
if ((cmd == 'SCN' || cmd == 'scn') &&
|
switch (fn) {
|
||||||
!args[args.length - 1].code) {
|
case OPS.setStrokeColorN:
|
||||||
|
case OPS.setFillColorN:
|
||||||
|
if (args[args.length - 1].code) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
// compile tiling patterns
|
// compile tiling patterns
|
||||||
var patternName = args[args.length - 1];
|
var patternName = args[args.length - 1];
|
||||||
// SCN/scn applies patterns along with normal colors
|
// SCN/scn applies patterns along with normal colors
|
||||||
@ -611,7 +614,11 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
error('Unkown PatternType ' + typeNum);
|
error('Unkown PatternType ' + typeNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (cmd == 'Do' && !args[0].code) {
|
break;
|
||||||
|
case OPS.paintXObject:
|
||||||
|
if (args[0].code) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
// eagerly compile XForm objects
|
// eagerly compile XForm objects
|
||||||
var name = args[0].name;
|
var name = args[0].name;
|
||||||
var xobj = xobjs.get(name);
|
var xobj = xobjs.get(name);
|
||||||
@ -638,28 +645,34 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
error('Unhandled XObject subtype ' + type.name);
|
error('Unhandled XObject subtype ' + type.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (cmd == 'Tf') { // eagerly collect all fonts
|
break;
|
||||||
|
case OPS.setFont:
|
||||||
|
// eagerly collect all fonts
|
||||||
var loadedName = self.handleSetFont(resources, args, null,
|
var loadedName = self.handleSetFont(resources, args, null,
|
||||||
operatorList);
|
operatorList);
|
||||||
operatorList.addDependency(loadedName);
|
operatorList.addDependency(loadedName);
|
||||||
fn = OPS.setFont;
|
|
||||||
args[0] = loadedName;
|
args[0] = loadedName;
|
||||||
} else if (cmd == 'EI') {
|
break;
|
||||||
self.buildPaintImageXObject(resources, args[0], true, operatorList);
|
case OPS.endInlineImage:
|
||||||
|
self.buildPaintImageXObject(resources, args[0], true,
|
||||||
|
operatorList);
|
||||||
args = [];
|
args = [];
|
||||||
continue;
|
continue;
|
||||||
} else if (cmd === 'q') { // save
|
case OPS.save:
|
||||||
var old = this.state;
|
var old = this.state;
|
||||||
this.stateStack.push(this.state);
|
this.stateStack.push(this.state);
|
||||||
this.state = old.clone();
|
this.state = old.clone();
|
||||||
} else if (cmd === 'Q') { // restore
|
break;
|
||||||
|
case OPS.restore:
|
||||||
var prev = this.stateStack.pop();
|
var prev = this.stateStack.pop();
|
||||||
if (prev) {
|
if (prev) {
|
||||||
this.state = prev;
|
this.state = prev;
|
||||||
}
|
}
|
||||||
} else if (cmd === 'Tj') { // showText
|
break;
|
||||||
|
case OPS.showText:
|
||||||
args[0] = this.handleText(args[0]);
|
args[0] = this.handleText(args[0]);
|
||||||
} else if (cmd === 'TJ') { // showSpacedText
|
break;
|
||||||
|
case OPS.showSpacedText:
|
||||||
var arr = args[0];
|
var arr = args[0];
|
||||||
var arrLength = arr.length;
|
var arrLength = arr.length;
|
||||||
for (var i = 0; i < arrLength; ++i) {
|
for (var i = 0; i < arrLength; ++i) {
|
||||||
@ -667,15 +680,16 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
arr[i] = this.handleText(arr[i]);
|
arr[i] = this.handleText(arr[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (cmd === '\'') { // nextLineShowText
|
break;
|
||||||
|
case OPS.nextLineShowText:
|
||||||
args[0] = this.handleText(args[0]);
|
args[0] = this.handleText(args[0]);
|
||||||
} else if (cmd === '"') { // nextLineSetSpacingShowText
|
break;
|
||||||
|
case OPS.nextLineSetSpacingShowText:
|
||||||
args[2] = this.handleText(args[2]);
|
args[2] = this.handleText(args[2]);
|
||||||
} else if (cmd === 'Tr') { // setTextRenderingMode
|
break;
|
||||||
|
case OPS.setTextRenderingMode:
|
||||||
this.state.textRenderingMode = args[0];
|
this.state.textRenderingMode = args[0];
|
||||||
}
|
break;
|
||||||
|
|
||||||
switch (fn) {
|
|
||||||
// Parse the ColorSpace data to a raw format.
|
// Parse the ColorSpace data to a raw format.
|
||||||
case OPS.setFillColorSpace:
|
case OPS.setFillColorSpace:
|
||||||
case OPS.setStrokeColorSpace:
|
case OPS.setStrokeColorSpace:
|
||||||
@ -706,7 +720,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
var gState = extGState.get(dictName.name);
|
var gState = extGState.get(dictName.name);
|
||||||
self.setGState(resources, gState, operatorList);
|
self.setGState(resources, gState, operatorList);
|
||||||
args = [];
|
args = [];
|
||||||
continue nextOp;
|
continue;
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
operatorList.addOp(fn, args);
|
operatorList.addOp(fn, args);
|
||||||
|
Loading…
Reference in New Issue
Block a user