cdrsdk 1.0.0

Rust SDK for CorelDRAW automation via COM IDispatch late binding
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
//! 颜色管理器& Profile & 管理策略

use wincom::{ComObject, Variant};
use windows::Win32::System::Com::IDispatch;

use crate::color::color::IvgColor;
use crate::color::context::IvgColorContext;

// =============================================================
// IvgColorProfile
// =============================================================

/// CorelDRAW 对象的后期绑定包装(颜色配置文件)。
///
/// 所有属性与方法通过 `IDispatch::Invoke` 按名称调用,调用失败时一般返回 `None` 或 `false`。
pub struct IvgColorProfile {
    disp: ComObject,
}

impl IvgColorProfile {
    /// 由 COM `IDispatch` 构造包装对象。
    pub fn new(disp: IDispatch) -> Self {
        Self { disp: ComObject::from_dispatch(disp, crate::types::IID_IDISPATCH) }
    }

    fn prop_string(&self, name: &str) -> Option<String> {
        self.disp.get_property(name).ok()?.to_string().ok()
    }

    fn prop_i64(&self, name: &str) -> Option<i64> {
        self.disp.get_property(name).ok()?.to_i64().ok()
    }

    fn prop_bool(&self, name: &str) -> Option<bool> {
        self.disp.get_property(name).ok()?.to_bool().ok()
    }

    /// 读取名称(`Name`)。
    pub fn name(&self) -> Option<String> { self.prop_string("Name") }
    /// 读取文件名称(`FileName`)。
    pub fn file_name(&self) -> Option<String> { self.prop_string("FileName") }
    /// 读取 COM 属性 `Manufacturer`。
    pub fn manufacturer(&self) -> Option<String> { self.prop_string("Manufacturer") }
    /// 读取设备模型(`DeviceModel`)。
    pub fn device_model(&self) -> Option<String> { self.prop_string("DeviceModel") }
    /// 读取设备类型(`DeviceType`)。
    pub fn device_type(&self) -> Option<i64> { self.prop_i64("DeviceType") }
    /// 读取已选中(`Selected`)。
    pub fn selected(&self) -> Option<bool> { self.prop_bool("Selected") }
    /// 读取 COM 属性 `Generic`。
    pub fn generic(&self) -> Option<bool> { self.prop_bool("Generic") }
    /// 读取已安装(`Installed`)。
    pub fn installed(&self) -> Option<bool> { self.prop_bool("Installed") }
    /// 读取标识(`ID`)。
    pub fn id(&self) -> Option<String> { self.prop_string("ID") }
    /// 读取颜色模型(`ColorModel`)。
    pub fn color_model(&self) -> Option<i64> { self.prop_i64("ColorModel") }

    /// 选择(COM 方法 `Select`)。
    pub fn select(&self) -> bool {
        self.disp.invoke_method("Select", vec![]).is_ok()
    }

    /// 用当前 profile + 渲染意图创建 ColorContext
    pub fn create_color_context(&self, rendering_intent: i32) -> Option<IvgColorContext> {
        let args = vec![Variant::from_i64(rendering_intent as i64)];
        self.disp
            .invoke_method("CreateColorContext", args)
            .ok()?
            .to_idispatch()
            .ok()
            .map(IvgColorContext::new)
    }

    /// 是否相同(COM 方法 `IsSame`)。
    pub fn is_same(&self, other: &IvgColorProfile) -> Option<bool> {
        let args = vec![other.as_variant()];
        self.disp
            .invoke_method("IsSame", args)
            .ok()?
            .to_bool()
            .ok()
    }

    /// 把底层 COM 对象包装成 `VARIANT`,用于传给其它 COM 调用。
    pub fn as_variant(&self) -> Variant {
        self.disp.as_variant()
    }

    /// 分发。
    pub fn dispatch(&self) -> &IDispatch {
        self.disp.as_dispatch()
    }
}

// =============================================================
// IvgColorProfiles
// =============================================================

/// CorelDRAW 对象的后期绑定包装(颜色配置文件集)。
///
/// 所有属性与方法通过 `IDispatch::Invoke` 按名称调用,调用失败时一般返回 `None` 或 `false`。
pub struct IvgColorProfiles {
    disp: ComObject,
}

impl IvgColorProfiles {
    /// 由 COM `IDispatch` 构造包装对象。
    pub fn new(disp: IDispatch) -> Self {
        Self { disp: ComObject::from_dispatch(disp, crate::types::IID_IDISPATCH) }
    }

    /// 读取返回条目数量(`Count`)。
    pub fn count(&self) -> Option<i64> {
        self.disp.get_property("Count").ok()?.to_i64().ok()
    }

    /// 按索引或名称取条目(COM 方法 `Item`)。
    pub fn item(&self, index_or_name: Variant) -> Option<IvgColorProfile> {
        let args = vec![index_or_name];
        self.disp
            .invoke_method("Item", args)
            .ok()?
            .to_idispatch()
            .ok()
            .map(IvgColorProfile::new)
    }

    /// 条目索引。
    pub fn item_by_index(&self, i: i32) -> Option<IvgColorProfile> {
        self.item(Variant::from_i64(i as i64))
    }

    /// 条目名称。
    pub fn item_by_name(&self, s: impl Into<String>) -> Option<IvgColorProfile> {
        self.item(Variant::from_str(s.into()))
    }

    /// 读取设备类型(`DeviceType`)。
    pub fn device_type(&self) -> Option<i64> {
        self.disp.get_property("DeviceType").ok()?.to_i64().ok()
    }

    /// 读取 COM 属性 `GenericProfile`。
    pub fn generic_profile(&self) -> Option<IvgColorProfile> {
        self.disp
            .get_property("GenericProfile")
            .ok()?
            .to_idispatch()
            .ok()
            .map(IvgColorProfile::new)
    }

    /// 选择名称(COM 方法 `SelectByName`)。
    pub fn select_by_name(&self, name: impl Into<String>) -> bool {
        let args = vec![Variant::from_str(name.into())];
        self.disp
            .invoke_method("SelectByName", args)
            .ok()
            .and_then(|v| v.to_bool().ok())
            .unwrap_or(false)
    }

    /// 调用 COM 方法 `Install`。
    pub fn install(&self, file_name: impl Into<String>) -> bool {
        let args = vec![Variant::from_str(file_name.into())];
        self.disp
            .invoke_method("Install", args)
            .ok()
            .and_then(|v| v.to_bool().ok())
            .unwrap_or(false)
    }
}

// =============================================================
// IvgColorManagementPolicy
// =============================================================

/// CorelDRAW 对象的后期绑定包装(颜色管理策略)。
///
/// 所有属性与方法通过 `IDispatch::Invoke` 按名称调用,调用失败时一般返回 `None` 或 `false`。
pub struct IvgColorManagementPolicy {
    disp: ComObject,
}

impl IvgColorManagementPolicy {
    /// 由 COM `IDispatch` 构造包装对象。
    pub fn new(disp: IDispatch) -> Self {
        Self { disp: ComObject::from_dispatch(disp, crate::types::IID_IDISPATCH) }
    }

    fn prop_i64(&self, name: &str) -> Option<i64> {
        self.disp.get_property(name).ok()?.to_i64().ok()
    }

    fn prop_bool(&self, name: &str) -> Option<bool> {
        self.disp.get_property(name).ok()?.to_bool().ok()
    }

    fn put_i64(&self, name: &str, v: i64) -> bool {
        let arg = Variant::from_i64(v);
        self.disp.set_property(name, vec![arg]).is_ok()
    }

    fn put_bool(&self, name: &str, v: bool) -> bool {
        let arg = Variant::from_bool(v);
        self.disp.set_property(name, vec![arg]).is_ok()
    }

    /// 读取动作 RGB(`ActionForRGB`)。
    pub fn action_for_rgb(&self) -> Option<i64> { self.prop_i64("ActionForRGB") }
    /// 设置动作 RGB(`ActionForRGB`)。
    pub fn set_action_for_rgb(&self, v: i32) -> bool {
        self.put_i64("ActionForRGB", v as i64)
    }

    /// 读取动作 CMYK(`ActionForCMYK`)。
    pub fn action_for_cmyk(&self) -> Option<i64> { self.prop_i64("ActionForCMYK") }
    /// 设置动作 CMYK(`ActionForCMYK`)。
    pub fn set_action_for_cmyk(&self, v: i32) -> bool {
        self.put_i64("ActionForCMYK", v as i64)
    }

    /// 读取动作灰度(`ActionForGrayscale`)。
    pub fn action_for_grayscale(&self) -> Option<i64> { self.prop_i64("ActionForGrayscale") }
    /// 设置动作灰度(`ActionForGrayscale`)。
    pub fn set_action_for_grayscale(&self, v: i32) -> bool {
        self.put_i64("ActionForGrayscale", v as i64)
    }

    /// 读取 COM 属性 `WarnOnMismatchedProfiles`。
    pub fn warn_on_mismatched_profiles(&self) -> Option<bool> {
        self.prop_bool("WarnOnMismatchedProfiles")
    }
    /// 设置 COM 属性 `WarnOnMismatchedProfiles`。
    pub fn set_warn_on_mismatched_profiles(&self, v: bool) -> bool {
        self.put_bool("WarnOnMismatchedProfiles", v)
    }

    /// 读取 COM 属性 `WarnOnMissingProfiles`。
    pub fn warn_on_missing_profiles(&self) -> Option<bool> {
        self.prop_bool("WarnOnMissingProfiles")
    }
    /// 设置 COM 属性 `WarnOnMissingProfiles`。
    pub fn set_warn_on_missing_profiles(&self, v: bool) -> bool {
        self.put_bool("WarnOnMissingProfiles", v)
    }
}

// =============================================================
// IvgColorManager
// =============================================================

/// CorelDRAW 对象的后期绑定包装(颜色管理器)。
///
/// 所有属性与方法通过 `IDispatch::Invoke` 按名称调用,调用失败时一般返回 `None` 或 `false`。
pub struct IvgColorManager {
    disp: ComObject,
}

impl IvgColorManager {
    /// 由 COM `IDispatch` 构造包装对象。
    pub fn new(disp: IDispatch) -> Self {
        Self { disp: ComObject::from_dispatch(disp, crate::types::IID_IDISPATCH) }
    }

    fn prop_i64(&self, name: &str) -> Option<i64> {
        self.disp.get_property(name).ok()?.to_i64().ok()
    }

    fn prop_bool(&self, name: &str) -> Option<bool> {
        self.disp.get_property(name).ok()?.to_bool().ok()
    }

    fn prop_string(&self, name: &str) -> Option<String> {
        self.disp.get_property(name).ok()?.to_string().ok()
    }

    fn prop_dispatch(&self, name: &str) -> Option<IDispatch> {
        self.disp.get_property(name).ok()?.to_idispatch().ok()
    }

    fn put_i64(&self, name: &str, v: i64) -> bool {
        let arg = Variant::from_i64(v);
        self.disp.set_property(name, vec![arg]).is_ok()
    }

    fn put_bool(&self, name: &str, v: bool) -> bool {
        let arg = Variant::from_bool(v);
        self.disp.set_property(name, vec![arg]).is_ok()
    }

    // ---------------------------------------------------------
    // 校准
    // ---------------------------------------------------------

    /// 读取 COM 属性 `ScannerCalibrated`。
    pub fn scanner_calibrated(&self) -> Option<bool> { self.prop_bool("ScannerCalibrated") }
    /// 设置 COM 属性 `ScannerCalibrated`。
    pub fn set_scanner_calibrated(&self, v: bool) -> bool { self.put_bool("ScannerCalibrated", v) }

    /// 读取分色打印机已校准(`SeparationPrinterCalibrated`)。
    pub fn separation_printer_calibrated(&self) -> Option<bool> {
        self.prop_bool("SeparationPrinterCalibrated")
    }
    /// 设置分色打印机已校准(`SeparationPrinterCalibrated`)。
    pub fn set_separation_printer_calibrated(&self, v: bool) -> bool {
        self.put_bool("SeparationPrinterCalibrated", v)
    }

    /// 读取合成打印机已校准(`CompositePrinterCalibrated`)。
    pub fn composite_printer_calibrated(&self) -> Option<bool> {
        self.prop_bool("CompositePrinterCalibrated")
    }

    /// 读取合成打印机校准(`CompositePrinterCalibration`)。
    pub fn composite_printer_calibration(&self) -> Option<i64> {
        self.prop_i64("CompositePrinterCalibration")
    }
    /// 设置合成打印机校准(`CompositePrinterCalibration`)。
    pub fn set_composite_printer_calibration(&self, v: i32) -> bool {
        self.put_i64("CompositePrinterCalibration", v as i64)
    }

    /// 读取监视器校准(`MonitorCalibration`)。
    pub fn monitor_calibration(&self) -> Option<i64> { self.prop_i64("MonitorCalibration") }
    /// 设置监视器校准(`MonitorCalibration`)。
    pub fn set_monitor_calibration(&self, v: i32) -> bool {
        self.put_i64("MonitorCalibration", v as i64)
    }

    // ---------------------------------------------------------
    // 出界警告
    // ---------------------------------------------------------

    /// 读取显示输出色域(`ShowOutOfGamut`)。
    pub fn show_out_of_gamut(&self) -> Option<bool> { self.prop_bool("ShowOutOfGamut") }
    /// 设置显示输出色域(`ShowOutOfGamut`)。
    pub fn set_show_out_of_gamut(&self, v: bool) -> bool { self.put_bool("ShowOutOfGamut", v) }

    /// 读取输出色域颜色(`OutOfGamutColor`)。
    pub fn out_of_gamut_color(&self) -> Option<IvgColor> {
        self.prop_dispatch("OutOfGamutColor").map(IvgColor::new)
    }

    /// 读取输出色域透明度(`OutOfGamutTransparency`)。
    pub fn out_of_gamut_transparency(&self) -> Option<i64> {
        self.prop_i64("OutOfGamutTransparency")
    }
    /// 设置输出色域透明度(`OutOfGamutTransparency`)。
    pub fn set_out_of_gamut_transparency(&self, v: i32) -> bool {
        self.put_i64("OutOfGamutTransparency", v as i64)
    }

    // ---------------------------------------------------------
    // CMYK 表现
    // ---------------------------------------------------------

    /// 读取 COM 属性 `CMYKInPercents`。
    pub fn cmyk_in_percents(&self) -> Option<bool> { self.prop_bool("CMYKInPercents") }
    /// 设置 COM 属性 `CMYKInPercents`。
    pub fn set_cmyk_in_percents(&self, v: bool) -> bool { self.put_bool("CMYKInPercents", v) }

    /// 读取 CMYK 色域专色颜色集(`CMYKGamutForSpotColors`)。
    pub fn cmyk_gamut_for_spot_colors(&self) -> Option<bool> {
        self.prop_bool("CMYKGamutForSpotColors")
    }
    /// 设置 CMYK 色域专色颜色集(`CMYKGamutForSpotColors`)。
    pub fn set_cmyk_gamut_for_spot_colors(&self, v: bool) -> bool {
        self.put_bool("CMYKGamutForSpotColors", v)
    }

    /// 读取渲染意图(`RenderingIntent`)。
    pub fn rendering_intent(&self) -> Option<i64> { self.prop_i64("RenderingIntent") }
    /// 设置渲染意图(`RenderingIntent`)。
    pub fn set_rendering_intent(&self, v: i32) -> bool {
        self.put_i64("RenderingIntent", v as i64)
    }

    /// 读取颜色引擎(`ColorEngine`)。
    pub fn color_engine(&self) -> Option<i64> { self.prop_i64("ColorEngine") }
    /// 设置颜色引擎(`ColorEngine`)。
    pub fn set_color_engine(&self, v: i32) -> bool {
        self.put_i64("ColorEngine", v as i64)
    }

    // ---------------------------------------------------------
    // 样式
    // ---------------------------------------------------------

    /// 读取样式数量(`StyleCount`)。
    pub fn style_count(&self) -> Option<i64> { self.prop_i64("StyleCount") }

    /// 样式索引(COM 方法 `StyleByIndex`)。
    pub fn style_by_index(&self, index: i32) -> Option<String> {
        let args = vec![Variant::from_i64(index as i64)];
        self.disp
            .invoke_method("StyleByIndex", args)
            .ok()?
            .to_string()
            .ok()
    }

    /// 加载样式(COM 方法 `LoadStyle`)。
    pub fn load_style(&self, name: impl Into<String>) -> bool {
        let args = vec![Variant::from_str(name.into())];
        self.disp
            .invoke_method("LoadStyle", args)
            .ok()
            .and_then(|v| v.to_bool().ok())
            .unwrap_or(false)
    }

    /// 删除样式(COM 方法 `DeleteStyle`)。
    pub fn delete_style(&self, name: impl Into<String>) -> bool {
        let args = vec![Variant::from_str(name.into())];
        self.disp
            .invoke_method("DeleteStyle", args)
            .ok()
            .and_then(|v| v.to_bool().ok())
            .unwrap_or(false)
    }

    /// 保存样式(COM 方法 `SaveStyle`)。
    pub fn save_style(&self, name: impl Into<String>) -> bool {
        let args = vec![Variant::from_str(name.into())];
        self.disp
            .invoke_method("SaveStyle", args)
            .ok()
            .and_then(|v| v.to_bool().ok())
            .unwrap_or(false)
    }

    /// 是否可以删除样式(COM 方法 `CanDeleteStyle`)。
    pub fn can_delete_style(&self, name: impl Into<String>) -> Option<bool> {
        let args = vec![Variant::from_str(name.into())];
        self.disp
            .invoke_method("CanDeleteStyle", args)
            .ok()?
            .to_bool()
            .ok()
    }

    /// 读取 COM 属性 `UnsavedStyleName`。
    pub fn unsaved_style_name(&self) -> Option<String> {
        self.prop_string("UnsavedStyleName")
    }

    // ---------------------------------------------------------
    // Profile 查询
    // ---------------------------------------------------------

    /// 调用 COM 方法 `CurrentProfile`。
    pub fn current_profile(&self, device_type: i32) -> Option<IvgColorProfile> {
        let args = vec![Variant::from_i64(device_type as i64)];
        self.disp
            .invoke_method("CurrentProfile", args)
            .ok()?
            .to_idispatch()
            .ok()
            .map(IvgColorProfile::new)
    }

    /// 已安装配置文件集(COM 方法 `InstalledProfiles`)。
    pub fn installed_profiles(&self, device_type: i32) -> Option<IvgColorProfiles> {
        let args = vec![Variant::from_i64(device_type as i64)];
        self.disp
            .invoke_method("InstalledProfiles", args)
            .ok()?
            .to_idispatch()
            .ok()
            .map(IvgColorProfiles::new)
    }

    /// 配置文件集颜色模型(COM 方法 `GetProfilesByColorModel`)。
    pub fn profiles_by_color_model(&self, color_model: i32) -> Option<IvgColorProfiles> {
        let args = vec![Variant::from_i64(color_model as i64)];
        self.disp
            .invoke_method("GetProfilesByColorModel", args)
            .ok()?
            .to_idispatch()
            .ok()
            .map(IvgColorProfiles::new)
    }

    /// 配置文件集设备(COM 方法 `GetProfilesForDevice`)。
    pub fn profiles_for_device(
        &self,
        device_type: i32,
        device_name: impl Into<String>,
    ) -> Option<IvgColorProfiles> {
        let args = vec![
            Variant::from_i64(device_type as i64),
            Variant::from_str(device_name.into()),
        ];
        self.disp
            .invoke_method("GetProfilesForDevice", args)
            .ok()?
            .to_idispatch()
            .ok()
            .map(IvgColorProfiles::new)
    }

    /// 读取默认值颜色上下文(`DefaultColorContext`)。
    pub fn default_color_context(&self) -> Option<IvgColorContext> {
        self.prop_dispatch("DefaultColorContext").map(IvgColorContext::new)
    }

    /// 读取颜色配置文件集(`ColorProfiles`)。
    pub fn color_profiles(&self) -> Option<IvgColorProfiles> {
        self.prop_dispatch("ColorProfiles").map(IvgColorProfiles::new)
    }

    /// 读取监视器颜色配置文件集(`MonitorColorProfiles`)。
    pub fn monitor_color_profiles(&self) -> Option<IvgColorProfiles> {
        self.prop_dispatch("MonitorColorProfiles").map(IvgColorProfiles::new)
    }

    // ---------------------------------------------------------
    // 策略
    // ---------------------------------------------------------

    /// 读取策略打开(`PolicyForOpen`)。
    pub fn policy_for_open(&self) -> Option<IvgColorManagementPolicy> {
        self.prop_dispatch("PolicyForOpen").map(IvgColorManagementPolicy::new)
    }

    /// 读取策略导入(`PolicyForImport`)。
    pub fn policy_for_import(&self) -> Option<IvgColorManagementPolicy> {
        self.prop_dispatch("PolicyForImport").map(IvgColorManagementPolicy::new)
    }

    // ---------------------------------------------------------
    // 导入 / 导出校正
    // ---------------------------------------------------------

    /// 读取导入上的颜色校正(`ColorCorrectionOnImport`)。
    pub fn color_correction_on_import(&self) -> Option<i64> {
        self.prop_i64("ColorCorrectionOnImport")
    }
    /// 设置导入上的颜色校正(`ColorCorrectionOnImport`)。
    pub fn set_color_correction_on_import(&self, v: i32) -> bool {
        self.put_i64("ColorCorrectionOnImport", v as i64)
    }

    /// 读取导出上的颜色校正(`ColorCorrectionOnExport`)。
    pub fn color_correction_on_export(&self) -> Option<i64> {
        self.prop_i64("ColorCorrectionOnExport")
    }
    /// 设置导出上的颜色校正(`ColorCorrectionOnExport`)。
    pub fn set_color_correction_on_export(&self, v: i32) -> bool {
        self.put_i64("ColorCorrectionOnExport", v as i64)
    }

    // ---------------------------------------------------------
    // 其它
    // ---------------------------------------------------------

    /// 读取 COM 属性 `IsICM2Available`。
    pub fn is_icm2_available(&self) -> Option<bool> { self.prop_bool("IsICM2Available") }
    /// 是否合成打印机 CMYK(`IsCompositePrinterCMYK`)。
    pub fn is_composite_printer_cmyk(&self) -> Option<bool> {
        self.prop_bool("IsCompositePrinterCMYK")
    }

    /// 读取映射灰度 CMYK 黑色(`MapGrayToCMYKBlack`)。
    pub fn map_gray_to_cmyk_black(&self) -> Option<bool> { self.prop_bool("MapGrayToCMYKBlack") }
    /// 设置映射灰度 CMYK 黑色(`MapGrayToCMYKBlack`)。
    pub fn set_map_gray_to_cmyk_black(&self, v: bool) -> bool {
        self.put_bool("MapGrayToCMYKBlack", v)
    }

    /// 读取保留纯黑色(`PreservePureBlack`)。
    pub fn preserve_pure_black(&self) -> Option<bool> { self.prop_bool("PreservePureBlack") }
    /// 设置保留纯黑色(`PreservePureBlack`)。
    pub fn set_preserve_pure_black(&self, v: bool) -> bool {
        self.put_bool("PreservePureBlack", v)
    }

    /// 读取专色颜色定义(`SpotColorDefinition`)。
    pub fn spot_color_definition(&self) -> Option<i64> { self.prop_i64("SpotColorDefinition") }
    /// 设置专色颜色定义(`SpotColorDefinition`)。
    pub fn set_spot_color_definition(&self, v: i32) -> bool {
        self.put_i64("SpotColorDefinition", v as i64)
    }

    /// 颜色引擎存在(COM 方法 `ColorEnginePresent`)。
    pub fn color_engine_present(&self, color_engine: i32) -> Option<bool> {
        let args = vec![Variant::from_i64(color_engine as i64)];
        self.disp
            .invoke_method("ColorEnginePresent", args)
            .ok()?
            .to_bool()
            .ok()
    }
}