mirror of
https://github.com/tbluemel/rtf.js.git
synced 2026-11-30 16:47:59 +01:00
Merge pull request #96 from nickchen120235/fix-fcharset
This commit is contained in:
+11
-3
@@ -5878,6 +5878,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _Containers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Containers */ "./src/rtfjs/parser/Containers.ts");
|
||||
/* harmony import */ var _destinations_DestinationBase__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./destinations/DestinationBase */ "./src/rtfjs/parser/destinations/DestinationBase.ts");
|
||||
/* harmony import */ var _destinations_Destinations__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./destinations/Destinations */ "./src/rtfjs/parser/destinations/Destinations.ts");
|
||||
/* harmony import */ var _destinations_FonttblDestinations__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./destinations/FonttblDestinations */ "./src/rtfjs/parser/destinations/FonttblDestinations.ts");
|
||||
/*
|
||||
|
||||
The MIT License (MIT)
|
||||
@@ -5910,6 +5911,7 @@ SOFTWARE.
|
||||
|
||||
|
||||
|
||||
|
||||
var Parser = /** @class */ (function () {
|
||||
function Parser(document, blob, renderer) {
|
||||
this.inst = document;
|
||||
@@ -5977,14 +5979,20 @@ var Parser = /** @class */ (function () {
|
||||
if (dest == null) {
|
||||
throw new _Helper__WEBPACK_IMPORTED_MODULE_1__.RTFJSError("Cannot route text to destination");
|
||||
}
|
||||
var summarizedText = "";
|
||||
if (dest.appendText != null && !this.parser.state.skipdestination) {
|
||||
var summarizedText = this.summarizeText(this.parser.text);
|
||||
if (dest instanceof _destinations_FonttblDestinations__WEBPACK_IMPORTED_MODULE_7__.FonttblDestinationSub) {
|
||||
summarizedText = this.summarizeText(this.parser.text, dest.charset);
|
||||
}
|
||||
else {
|
||||
summarizedText = this.summarizeText(this.parser.text);
|
||||
}
|
||||
dest.appendText(summarizedText);
|
||||
}
|
||||
this.parser.text = [];
|
||||
}
|
||||
};
|
||||
Parser.prototype.summarizeText = function (text) {
|
||||
Parser.prototype.summarizeText = function (text, charset) {
|
||||
var result = "";
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
var value = text[i];
|
||||
@@ -5993,7 +6001,7 @@ var Parser = /** @class */ (function () {
|
||||
}
|
||||
else if (value instanceof _Containers__WEBPACK_IMPORTED_MODULE_4__.HexText) {
|
||||
// Looking for current fonttbl charset
|
||||
var codepage = this.parser.codepage;
|
||||
var codepage = charset ? charset : this.parser.codepage;
|
||||
if (Object.prototype.hasOwnProperty.call(value.chp, "fontfamily")) {
|
||||
var idx = value.chp.fontfamily;
|
||||
// Code page 42 isn't a real code page and shouldn't appear here
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
@@ -33,6 +33,7 @@ import { RenderPap } from "../renderer/RenderPap";
|
||||
import { GlobalState, HexText, PlainText, State } from "./Containers";
|
||||
import { DestinationFactory } from "./destinations/DestinationBase";
|
||||
import { Destinations } from "./destinations/Destinations";
|
||||
import { FonttblDestinationSub } from "./destinations/FonttblDestinations"
|
||||
|
||||
export class Parser {
|
||||
private inst: Document;
|
||||
@@ -111,15 +112,22 @@ export class Parser {
|
||||
if (dest == null) {
|
||||
throw new RTFJSError("Cannot route text to destination");
|
||||
}
|
||||
|
||||
let summarizedText = "";
|
||||
if (dest.appendText != null && !this.parser.state.skipdestination) {
|
||||
const summarizedText = this.summarizeText(this.parser.text);
|
||||
if (dest instanceof FonttblDestinationSub) {
|
||||
summarizedText = this.summarizeText(this.parser.text, dest.charset);
|
||||
}
|
||||
else {
|
||||
summarizedText = this.summarizeText(this.parser.text);
|
||||
}
|
||||
dest.appendText(summarizedText);
|
||||
}
|
||||
this.parser.text = [];
|
||||
}
|
||||
}
|
||||
|
||||
private summarizeText(text: (PlainText | HexText)[]) {
|
||||
private summarizeText(text: (PlainText | HexText)[], charset?: number) {
|
||||
let result = "";
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
const value = text[i];
|
||||
@@ -127,7 +135,7 @@ export class Parser {
|
||||
result += value.text;
|
||||
} else if (value instanceof HexText) {
|
||||
// Looking for current fonttbl charset
|
||||
let codepage = this.parser.codepage;
|
||||
let codepage = charset ? charset : this.parser.codepage;
|
||||
if (Object.prototype.hasOwnProperty.call(value.chp, "fontfamily")) {
|
||||
const idx = value.chp.fontfamily;
|
||||
// Code page 42 isn't a real code page and shouldn't appear here
|
||||
|
||||
Reference in New Issue
Block a user