@mlightcad/libredwg-web 0.8.2 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/libredwg-web.js +38 -6
- package/dist/libredwg-web.umd.cjs +38 -6
- package/lib/converter/dwgColorToBackgroundFillColor.d.ts +12 -0
- package/lib/converter/dwgColorToBackgroundFillColor.d.ts.map +1 -0
- package/lib/converter/dwgColorToBackgroundFillColor.js +48 -0
- package/lib/converter/dwgColorToBackgroundFillColor.js.map +1 -0
- package/lib/converter/entityConverter.d.ts.map +1 -1
- package/lib/converter/entityConverter.js +25 -5
- package/lib/converter/entityConverter.js.map +1 -1
- package/lib/converter/index.d.ts +1 -0
- package/lib/converter/index.d.ts.map +1 -1
- package/lib/converter/index.js +1 -0
- package/lib/converter/index.js.map +1 -1
- package/lib/database/entities/mtext.d.ts +4 -2
- package/lib/database/entities/mtext.d.ts.map +1 -1
- package/package.json +3 -3
- package/wasm/libredwg-web.d.ts +26 -13
- package/wasm/libredwg-web.js +15 -2
- package/wasm/libredwg-web.wasm +0 -0
package/README.md
CHANGED
|
@@ -47,6 +47,8 @@ pnpm build:prepare
|
|
|
47
47
|
pnpm build:obj
|
|
48
48
|
|
|
49
49
|
# Use emscripten to build web assembly for libredwg
|
|
50
|
+
# (script/build-wasm.mjs: coalesces tsgen.wasm locals for --emit-tsd;
|
|
51
|
+
# prefers this package's TypeScript 5.x over a global tsc 6+)
|
|
50
52
|
pnpm build:wasm
|
|
51
53
|
|
|
52
54
|
# Copy web assembly (wasm file and JavaScript glue code file) from build directory to distribution directory of this package
|
package/dist/libredwg-web.js
CHANGED
|
@@ -1216,6 +1216,33 @@ function dwgColorToMLeaderRawColor(color) {
|
|
|
1216
1216
|
}
|
|
1217
1217
|
return RAW_COLOR_TYPE_BY_BLOCK << 24 >> 0;
|
|
1218
1218
|
}
|
|
1219
|
+
function dwgColorToBackgroundFillColor(color) {
|
|
1220
|
+
if (color == null) return void 0;
|
|
1221
|
+
const methodNum = color.method;
|
|
1222
|
+
const method = color.method != null && methodNum !== 0 ? methodNum : color.rgb >>> 24 & 255;
|
|
1223
|
+
const index = color.index;
|
|
1224
|
+
if (method === Dwg_Color_Method.ByLayer || method === Dwg_Color_Method.ByBlock || method === Dwg_Color_Method.None || index === 256) {
|
|
1225
|
+
return void 0;
|
|
1226
|
+
}
|
|
1227
|
+
if (method === Dwg_Color_Method.ForegroundColor) {
|
|
1228
|
+
return 7;
|
|
1229
|
+
}
|
|
1230
|
+
if (method === Dwg_Color_Method.TrueColor) {
|
|
1231
|
+
if (color.rgb == null) return void 0;
|
|
1232
|
+
return color.rgb & 16777215;
|
|
1233
|
+
}
|
|
1234
|
+
if (index >= 1 && index <= 255) {
|
|
1235
|
+
return index;
|
|
1236
|
+
}
|
|
1237
|
+
if (index === 0) {
|
|
1238
|
+
return void 0;
|
|
1239
|
+
}
|
|
1240
|
+
if (color.rgb != null) {
|
|
1241
|
+
const rgb24 = color.rgb & 16777215;
|
|
1242
|
+
if (rgb24 !== 0) return rgb24;
|
|
1243
|
+
}
|
|
1244
|
+
return void 0;
|
|
1245
|
+
}
|
|
1219
1246
|
const MODEL_SPACE = "*MODEL_SPACE";
|
|
1220
1247
|
const MODEL_SPACE_PREFIX = "*PAPER_SPACE";
|
|
1221
1248
|
const isModelSpace = (name) => {
|
|
@@ -1984,8 +2011,14 @@ class LibreEntityConverter {
|
|
|
1984
2011
|
}
|
|
1985
2012
|
convertLeader(entity, commonAttrs) {
|
|
1986
2013
|
const libredwg = this.libredwg;
|
|
1987
|
-
|
|
1988
|
-
|
|
2014
|
+
let styleName = "";
|
|
2015
|
+
try {
|
|
2016
|
+
styleName = libredwg.dwg_entity_get_dimstyle_name(entity) || "";
|
|
2017
|
+
} catch {
|
|
2018
|
+
styleName = "";
|
|
2019
|
+
}
|
|
2020
|
+
const arrowheadOn = libredwg.dwg_dynapi_entity_data(entity, "arrowhead_on");
|
|
2021
|
+
const isArrowheadEnabled = arrowheadOn > 0;
|
|
1989
2022
|
const isSpline = libredwg.dwg_dynapi_entity_data(entity, "path_type");
|
|
1990
2023
|
const leaderCreationFlag = libredwg.dwg_dynapi_entity_data(entity, "annot_type");
|
|
1991
2024
|
const isHooklineSameDirection = libredwg.dwg_dynapi_entity_data(entity, "hookline_dir");
|
|
@@ -2004,7 +2037,7 @@ class LibreEntityConverter {
|
|
|
2004
2037
|
type: "LEADER",
|
|
2005
2038
|
...commonAttrs,
|
|
2006
2039
|
styleName,
|
|
2007
|
-
isArrowheadEnabled
|
|
2040
|
+
isArrowheadEnabled,
|
|
2008
2041
|
isSpline: isSpline > 0,
|
|
2009
2042
|
leaderCreationFlag,
|
|
2010
2043
|
isHooklineSameDirection: isHooklineSameDirection > 0,
|
|
@@ -2701,6 +2734,7 @@ class LibreEntityConverter {
|
|
|
2701
2734
|
const fillBoxScale = libredwg.dwg_dynapi_entity_data(entity, "bg_fill_scale");
|
|
2702
2735
|
const backgroundFillColor = libredwg.dwg_dynapi_entity_data(entity, "bg_fill_color");
|
|
2703
2736
|
const backgroundFillTransparency = libredwg.dwg_dynapi_entity_data(entity, "bg_fill_trans");
|
|
2737
|
+
const decodedBackgroundFillColor = backgroundFill === 1 ? dwgColorToBackgroundFillColor(backgroundFillColor) : void 0;
|
|
2704
2738
|
const columnType = libredwg.dwg_dynapi_entity_data(entity, "column_type");
|
|
2705
2739
|
const columnFlowReversed = libredwg.dwg_dynapi_entity_data(entity, "flow_reversed");
|
|
2706
2740
|
const columnAutoHeight = libredwg.dwg_dynapi_entity_data(entity, "auto_height");
|
|
@@ -2732,10 +2766,8 @@ class LibreEntityConverter {
|
|
|
2732
2766
|
lineSpacingStyle,
|
|
2733
2767
|
lineSpacing,
|
|
2734
2768
|
backgroundFill,
|
|
2735
|
-
// backgroundColor: backgroundColor.rgb, // TODO: Double check whether it should be color index
|
|
2736
2769
|
fillBoxScale,
|
|
2737
|
-
backgroundFillColor:
|
|
2738
|
-
// TODO: Double check whether it should be color index
|
|
2770
|
+
...decodedBackgroundFillColor !== void 0 ? { backgroundFillColor: decodedBackgroundFillColor } : {},
|
|
2739
2771
|
backgroundFillTransparency,
|
|
2740
2772
|
columnType,
|
|
2741
2773
|
// columnCount: columnCount,
|
|
@@ -1218,6 +1218,33 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1218
1218
|
}
|
|
1219
1219
|
return RAW_COLOR_TYPE_BY_BLOCK << 24 >> 0;
|
|
1220
1220
|
}
|
|
1221
|
+
function dwgColorToBackgroundFillColor(color) {
|
|
1222
|
+
if (color == null) return void 0;
|
|
1223
|
+
const methodNum = color.method;
|
|
1224
|
+
const method = color.method != null && methodNum !== 0 ? methodNum : color.rgb >>> 24 & 255;
|
|
1225
|
+
const index = color.index;
|
|
1226
|
+
if (method === Dwg_Color_Method.ByLayer || method === Dwg_Color_Method.ByBlock || method === Dwg_Color_Method.None || index === 256) {
|
|
1227
|
+
return void 0;
|
|
1228
|
+
}
|
|
1229
|
+
if (method === Dwg_Color_Method.ForegroundColor) {
|
|
1230
|
+
return 7;
|
|
1231
|
+
}
|
|
1232
|
+
if (method === Dwg_Color_Method.TrueColor) {
|
|
1233
|
+
if (color.rgb == null) return void 0;
|
|
1234
|
+
return color.rgb & 16777215;
|
|
1235
|
+
}
|
|
1236
|
+
if (index >= 1 && index <= 255) {
|
|
1237
|
+
return index;
|
|
1238
|
+
}
|
|
1239
|
+
if (index === 0) {
|
|
1240
|
+
return void 0;
|
|
1241
|
+
}
|
|
1242
|
+
if (color.rgb != null) {
|
|
1243
|
+
const rgb24 = color.rgb & 16777215;
|
|
1244
|
+
if (rgb24 !== 0) return rgb24;
|
|
1245
|
+
}
|
|
1246
|
+
return void 0;
|
|
1247
|
+
}
|
|
1221
1248
|
const MODEL_SPACE = "*MODEL_SPACE";
|
|
1222
1249
|
const MODEL_SPACE_PREFIX = "*PAPER_SPACE";
|
|
1223
1250
|
const isModelSpace = (name) => {
|
|
@@ -1986,8 +2013,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1986
2013
|
}
|
|
1987
2014
|
convertLeader(entity, commonAttrs) {
|
|
1988
2015
|
const libredwg = this.libredwg;
|
|
1989
|
-
|
|
1990
|
-
|
|
2016
|
+
let styleName = "";
|
|
2017
|
+
try {
|
|
2018
|
+
styleName = libredwg.dwg_entity_get_dimstyle_name(entity) || "";
|
|
2019
|
+
} catch {
|
|
2020
|
+
styleName = "";
|
|
2021
|
+
}
|
|
2022
|
+
const arrowheadOn = libredwg.dwg_dynapi_entity_data(entity, "arrowhead_on");
|
|
2023
|
+
const isArrowheadEnabled = arrowheadOn > 0;
|
|
1991
2024
|
const isSpline = libredwg.dwg_dynapi_entity_data(entity, "path_type");
|
|
1992
2025
|
const leaderCreationFlag = libredwg.dwg_dynapi_entity_data(entity, "annot_type");
|
|
1993
2026
|
const isHooklineSameDirection = libredwg.dwg_dynapi_entity_data(entity, "hookline_dir");
|
|
@@ -2006,7 +2039,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2006
2039
|
type: "LEADER",
|
|
2007
2040
|
...commonAttrs,
|
|
2008
2041
|
styleName,
|
|
2009
|
-
isArrowheadEnabled
|
|
2042
|
+
isArrowheadEnabled,
|
|
2010
2043
|
isSpline: isSpline > 0,
|
|
2011
2044
|
leaderCreationFlag,
|
|
2012
2045
|
isHooklineSameDirection: isHooklineSameDirection > 0,
|
|
@@ -2703,6 +2736,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2703
2736
|
const fillBoxScale = libredwg.dwg_dynapi_entity_data(entity, "bg_fill_scale");
|
|
2704
2737
|
const backgroundFillColor = libredwg.dwg_dynapi_entity_data(entity, "bg_fill_color");
|
|
2705
2738
|
const backgroundFillTransparency = libredwg.dwg_dynapi_entity_data(entity, "bg_fill_trans");
|
|
2739
|
+
const decodedBackgroundFillColor = backgroundFill === 1 ? dwgColorToBackgroundFillColor(backgroundFillColor) : void 0;
|
|
2706
2740
|
const columnType = libredwg.dwg_dynapi_entity_data(entity, "column_type");
|
|
2707
2741
|
const columnFlowReversed = libredwg.dwg_dynapi_entity_data(entity, "flow_reversed");
|
|
2708
2742
|
const columnAutoHeight = libredwg.dwg_dynapi_entity_data(entity, "auto_height");
|
|
@@ -2734,10 +2768,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2734
2768
|
lineSpacingStyle,
|
|
2735
2769
|
lineSpacing,
|
|
2736
2770
|
backgroundFill,
|
|
2737
|
-
// backgroundColor: backgroundColor.rgb, // TODO: Double check whether it should be color index
|
|
2738
2771
|
fillBoxScale,
|
|
2739
|
-
backgroundFillColor:
|
|
2740
|
-
// TODO: Double check whether it should be color index
|
|
2772
|
+
...decodedBackgroundFillColor !== void 0 ? { backgroundFillColor: decodedBackgroundFillColor } : {},
|
|
2741
2773
|
backgroundFillTransparency,
|
|
2742
2774
|
columnType,
|
|
2743
2775
|
// columnCount: columnCount,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dwg_Color } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Decodes a libredwg CMC {@link Dwg_Color} into the numeric form expected by
|
|
4
|
+
* MTEXT `backgroundFillColor`: an ACI index `1..255`, or a 24-bit RGB.
|
|
5
|
+
*
|
|
6
|
+
* Returns `undefined` for ByLayer / ByBlock / None (and similar placeholders
|
|
7
|
+
* AutoCAD stores when `bg_fill_flag` is 2 or 3 — canvas / window background).
|
|
8
|
+
* Those must not be passed through as `color.rgb` (`0xC0000000` etc.), whose
|
|
9
|
+
* low 24 bits are zero and render as pure black.
|
|
10
|
+
*/
|
|
11
|
+
export declare function dwgColorToBackgroundFillColor(color: Dwg_Color | undefined | null): number | undefined;
|
|
12
|
+
//# sourceMappingURL=dwgColorToBackgroundFillColor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dwgColorToBackgroundFillColor.d.ts","sourceRoot":"","sources":["../../src/converter/dwgColorToBackgroundFillColor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,mBAAmB,CAAA;AAE/D;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,GAClC,MAAM,GAAG,SAAS,CA2CpB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Dwg_Color_Method } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Decodes a libredwg CMC {@link Dwg_Color} into the numeric form expected by
|
|
4
|
+
* MTEXT `backgroundFillColor`: an ACI index `1..255`, or a 24-bit RGB.
|
|
5
|
+
*
|
|
6
|
+
* Returns `undefined` for ByLayer / ByBlock / None (and similar placeholders
|
|
7
|
+
* AutoCAD stores when `bg_fill_flag` is 2 or 3 — canvas / window background).
|
|
8
|
+
* Those must not be passed through as `color.rgb` (`0xC0000000` etc.), whose
|
|
9
|
+
* low 24 bits are zero and render as pure black.
|
|
10
|
+
*/
|
|
11
|
+
export function dwgColorToBackgroundFillColor(color) {
|
|
12
|
+
if (color == null)
|
|
13
|
+
return undefined;
|
|
14
|
+
const methodNum = color.method;
|
|
15
|
+
const method = color.method != null && methodNum !== 0
|
|
16
|
+
? methodNum
|
|
17
|
+
: ((color.rgb >>> 24) & 0xff);
|
|
18
|
+
const index = color.index;
|
|
19
|
+
if (method === Dwg_Color_Method.ByLayer ||
|
|
20
|
+
method === Dwg_Color_Method.ByBlock ||
|
|
21
|
+
method === Dwg_Color_Method.None ||
|
|
22
|
+
index === 256) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
if (method === Dwg_Color_Method.ForegroundColor) {
|
|
26
|
+
return 7;
|
|
27
|
+
}
|
|
28
|
+
if (method === Dwg_Color_Method.TrueColor) {
|
|
29
|
+
if (color.rgb == null)
|
|
30
|
+
return undefined;
|
|
31
|
+
return color.rgb & 0xffffff;
|
|
32
|
+
}
|
|
33
|
+
// ACI / entity colour (0xC2): prefer the index so ACI 7 stays foreground.
|
|
34
|
+
// Index 0 is ByBlock — not a usable fill colour.
|
|
35
|
+
if (index >= 1 && index <= 255) {
|
|
36
|
+
return index;
|
|
37
|
+
}
|
|
38
|
+
if (index === 0) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
if (color.rgb != null) {
|
|
42
|
+
const rgb24 = color.rgb & 0xffffff;
|
|
43
|
+
if (rgb24 !== 0)
|
|
44
|
+
return rgb24;
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=dwgColorToBackgroundFillColor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dwgColorToBackgroundFillColor.js","sourceRoot":"","sources":["../../src/converter/dwgColorToBackgroundFillColor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAE/D;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CAC3C,KAAmC;IAEnC,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,SAAS,CAAA;IAEnC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAgB,CAAA;IACxC,MAAM,MAAM,GACV,KAAK,CAAC,MAAM,IAAI,IAAI,IAAI,SAAS,KAAK,CAAC;QACrC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,CAAA;IACjC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;IAEzB,IACE,MAAM,KAAK,gBAAgB,CAAC,OAAO;QACnC,MAAM,KAAK,gBAAgB,CAAC,OAAO;QACnC,MAAM,KAAK,gBAAgB,CAAC,IAAI;QAChC,KAAK,KAAK,GAAG,EACb,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,IAAI,MAAM,KAAK,gBAAgB,CAAC,eAAe,EAAE,CAAC;QAChD,OAAO,CAAC,CAAA;IACV,CAAC;IAED,IAAI,MAAM,KAAK,gBAAgB,CAAC,SAAS,EAAE,CAAC;QAC1C,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI;YAAE,OAAO,SAAS,CAAA;QACvC,OAAO,KAAK,CAAC,GAAG,GAAG,QAAQ,CAAA;IAC7B,CAAC;IAED,0EAA0E;IAC1E,iDAAiD;IACjD,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAA;IACd,CAAC;IACD,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,GAAG,QAAQ,CAAA;QAClC,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,KAAK,CAAA;IAC/B,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityConverter.d.ts","sourceRoot":"","sources":["../../src/converter/entityConverter.ts"],"names":[],"mappings":"AAAA,OAAO,EAcL,cAAc,EACd,WAAW,EAQX,SAAS,EA4DV,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAML,cAAc,EAGf,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"entityConverter.d.ts","sourceRoot":"","sources":["../../src/converter/entityConverter.ts"],"names":[],"mappings":"AAAA,OAAO,EAcL,cAAc,EACd,WAAW,EAQX,SAAS,EA4DV,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAML,cAAc,EAGf,MAAM,mBAAmB,CAAA;AAmB1B,qBAAa,oBAAoB;IAC/B,QAAQ,EAAE,UAAU,CAAA;IACpB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAY;IACvC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAY;IACvC,OAAO,EAAE,cAAc,EAAE,CAAK;IAC9B,kBAAkB,EAAE,MAAM,CAAA;gBAEd,QAAQ,EAAE,UAAU;IAKhC,OAAO,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,GAAE,OAAe;IAkB/C,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE;IAIpC,KAAK;IAOL,OAAO,CAAC,UAAU,EAAE,cAAc,GAAG,SAAS,GAAG,SAAS;IAwG1D,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,cAAc;IA4CtB,OAAO,CAAC,UAAU;IAwBlB,OAAO,CAAC,qBAAqB;IAqD7B,OAAO,CAAC,oBAAoB;IA6D5B,OAAO,CAAC,aAAa;IA2CrB,OAAO,CAAC,aAAa;IAqCrB,OAAO,CAAC,aAAa;IAoBrB,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,6BAA6B;IAsBrC,OAAO,CAAC,4BAA4B;IA6BpC,OAAO,CAAC,wBAAwB;IAmBhC,OAAO,CAAC,wBAAwB;IAoBhC,OAAO,CAAC,sBAAsB;IAmB9B,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,YAAY;IAmGpB,OAAO,CAAC,yBAAyB;IAgFjC,OAAO,CAAC,YAAY;IAoDpB,OAAO,CAAC,aAAa;IAoErB,OAAO,CAAC,aAAa;IAwDrB,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,iBAAiB;IAwDzB,OAAO,CAAC,YAAY;IAmDpB,OAAO,CAAC,kBAAkB;IAyhB1B,OAAO,CAAC,gBAAgB;IAuCxB,OAAO,CAAC,eAAe;IAoBvB,OAAO,CAAC,YAAY;IA+EpB,OAAO,CAAC,YAAY;IAsBpB,OAAO,CAAC,iBAAiB;IA6CzB,OAAO,CAAC,iBAAiB;IAiCzB,OAAO,CAAC,kBAAkB;IA2E1B,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,cAAc;IAkDtB,OAAO,CAAC,YAAY;IA+BpB,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,aAAa;IA+DrB,OAAO,CAAC,YAAY;IA2DpB,OAAO,CAAC,iBAAiB;IA+BzB,OAAO,CAAC,eAAe;IAiCvB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,gBAAgB;IAsBxB,OAAO,CAAC,eAAe;IAgIvB,OAAO,CAAC,cAAc;IAqDtB,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,uBAAuB;IAuC/B,OAAO,CAAC,cAAc;IA8CtB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,YAAY;CAMrB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DwgBoundaryPathEdgeType, DwgHatchAssociativity, DwgHatchGradientColorFlag, DwgHatchGradientFlag, DwgHatchSolidFill } from '../database/index.js';
|
|
2
2
|
import { Dwg_Hatch_Edge_Type, Dwg_Object_Type } from '../types/index.js';
|
|
3
|
+
import { dwgColorToBackgroundFillColor } from './dwgColorToBackgroundFillColor.js';
|
|
3
4
|
import { dwgColorToMLeaderRawColor } from './dwgColorToMLeaderRawColor.js';
|
|
4
5
|
import { decodeOle2FrameCornersFromData, idToString, uint8ArrayToHexString } from './utils.js';
|
|
5
6
|
export class LibreEntityConverter {
|
|
@@ -826,8 +827,19 @@ export class LibreEntityConverter {
|
|
|
826
827
|
}
|
|
827
828
|
convertLeader(entity, commonAttrs) {
|
|
828
829
|
const libredwg = this.libredwg;
|
|
829
|
-
|
|
830
|
-
|
|
830
|
+
// LEADER stores its dimension style on `dimstyle`. The MTEXT getter reads
|
|
831
|
+
// `style`, which this entity does not have, so the name was always empty
|
|
832
|
+
// and arrow size fell back to the default 2.5 drawing units.
|
|
833
|
+
let styleName = '';
|
|
834
|
+
try {
|
|
835
|
+
styleName = libredwg.dwg_entity_get_dimstyle_name(entity) || '';
|
|
836
|
+
}
|
|
837
|
+
catch {
|
|
838
|
+
styleName = '';
|
|
839
|
+
}
|
|
840
|
+
// DXF group 71. arrowhead_type is a separate field and does not control this flag.
|
|
841
|
+
const arrowheadOn = libredwg.dwg_dynapi_entity_data(entity, 'arrowhead_on');
|
|
842
|
+
const isArrowheadEnabled = arrowheadOn > 0;
|
|
831
843
|
const isSpline = libredwg.dwg_dynapi_entity_data(entity, 'path_type');
|
|
832
844
|
const leaderCreationFlag = libredwg.dwg_dynapi_entity_data(entity, 'annot_type');
|
|
833
845
|
const isHooklineSameDirection = libredwg.dwg_dynapi_entity_data(entity, 'hookline_dir');
|
|
@@ -848,7 +860,7 @@ export class LibreEntityConverter {
|
|
|
848
860
|
type: 'LEADER',
|
|
849
861
|
...commonAttrs,
|
|
850
862
|
styleName: styleName,
|
|
851
|
-
isArrowheadEnabled: isArrowheadEnabled
|
|
863
|
+
isArrowheadEnabled: isArrowheadEnabled,
|
|
852
864
|
isSpline: isSpline > 0,
|
|
853
865
|
leaderCreationFlag: leaderCreationFlag,
|
|
854
866
|
isHooklineSameDirection: isHooklineSameDirection > 0,
|
|
@@ -1325,6 +1337,13 @@ export class LibreEntityConverter {
|
|
|
1325
1337
|
const fillBoxScale = libredwg.dwg_dynapi_entity_data(entity, 'bg_fill_scale');
|
|
1326
1338
|
const backgroundFillColor = libredwg.dwg_dynapi_entity_data(entity, 'bg_fill_color');
|
|
1327
1339
|
const backgroundFillTransparency = libredwg.dwg_dynapi_entity_data(entity, 'bg_fill_trans');
|
|
1340
|
+
// Only when bg_fill_flag is 1 (use fill colour). Decode CMC — do not
|
|
1341
|
+
// pass through packed method bytes (e.g. ByLayer 0xC0000000), which
|
|
1342
|
+
// paint as black when treated as RGB. Omit for flags 2/3 (window /
|
|
1343
|
+
// canvas) and for ByLayer / ByBlock placeholders.
|
|
1344
|
+
const decodedBackgroundFillColor = backgroundFill === 1
|
|
1345
|
+
? dwgColorToBackgroundFillColor(backgroundFillColor)
|
|
1346
|
+
: undefined;
|
|
1328
1347
|
const columnType = libredwg.dwg_dynapi_entity_data(entity, 'column_type');
|
|
1329
1348
|
const columnFlowReversed = libredwg.dwg_dynapi_entity_data(entity, 'flow_reversed');
|
|
1330
1349
|
const columnAutoHeight = libredwg.dwg_dynapi_entity_data(entity, 'auto_height');
|
|
@@ -1352,9 +1371,10 @@ export class LibreEntityConverter {
|
|
|
1352
1371
|
lineSpacingStyle: lineSpacingStyle,
|
|
1353
1372
|
lineSpacing: lineSpacing,
|
|
1354
1373
|
backgroundFill: backgroundFill,
|
|
1355
|
-
// backgroundColor: backgroundColor.rgb, // TODO: Double check whether it should be color index
|
|
1356
1374
|
fillBoxScale: fillBoxScale,
|
|
1357
|
-
|
|
1375
|
+
...(decodedBackgroundFillColor !== undefined
|
|
1376
|
+
? { backgroundFillColor: decodedBackgroundFillColor }
|
|
1377
|
+
: {}),
|
|
1358
1378
|
backgroundFillTransparency: backgroundFillTransparency,
|
|
1359
1379
|
columnType: columnType,
|
|
1360
1380
|
// columnCount: columnCount,
|