deckmint 0.1.0

Create PowerPoint presentations programmatically in Rust
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
/// One inch in English Metric Units (EMU)
pub const EMU: i64 = 914_400;
/// One point (pt) in EMU
pub const ONEPT: i64 = 12_700;
/// Golden ratio modifier for line-height
pub const LINEH_MODIFIER: f64 = 1.67;
/// Default bullet indent
pub const DEF_BULLET_MARGIN: i64 = 27;
/// Default font color (hex, no #)
pub const DEF_FONT_COLOR: &str = "000000";
/// Default font size (points)
pub const DEF_FONT_SIZE: f64 = 12.0;
/// Default title font size (points)
pub const DEF_FONT_TITLE_SIZE: f64 = 18.0;
/// Default shape line color
pub const DEF_SHAPE_LINE_COLOR: &str = "333333";
/// Default slide background color
pub const DEF_SLIDE_BKGD: &str = "FFFFFF";
/// Default slide margins (TRBL, inches)
pub const DEF_SLIDE_MARGIN_IN: [f64; 4] = [0.5, 0.5, 0.5, 0.5];
/// Default cell margins (TRBL, inches)
pub const DEF_CELL_MARGIN_IN: [f64; 4] = [0.05, 0.1, 0.05, 0.1];
/// Slide layout series base ID
pub const LAYOUT_IDX_SERIES_BASE: u64 = 2_147_483_649;
/// Slide number field ID
pub const SLDNUMFLDID: &str = "{F7021451-1387-4CA6-816F-3879F97B5CBC}";
/// Hex color regex pattern (6 hex chars)
pub const REGEX_HEX_PATTERN: &str = "^[0-9a-fA-F]{6}$";

/// Validates that a string is a 6-digit hex color
pub fn is_hex_color(s: &str) -> bool {
    s.len() == 6 && s.chars().all(|c| c.is_ascii_hexdigit())
}

/// Scheme colors (theme colors) as used in OOXML
#[derive(Debug, Clone, PartialEq)]
pub enum SchemeColor {
    /// text1 / dark text
    Text1,
    /// text2
    Text2,
    /// background1
    Background1,
    /// background2
    Background2,
    Accent1,
    Accent2,
    Accent3,
    Accent4,
    Accent5,
    Accent6,
}

impl SchemeColor {
    /// Returns the OOXML string value (e.g. "tx1", "accent1")
    pub fn as_str(&self) -> &'static str {
        match self {
            SchemeColor::Text1 => "tx1",
            SchemeColor::Text2 => "tx2",
            SchemeColor::Background1 => "bg1",
            SchemeColor::Background2 => "bg2",
            SchemeColor::Accent1 => "accent1",
            SchemeColor::Accent2 => "accent2",
            SchemeColor::Accent3 => "accent3",
            SchemeColor::Accent4 => "accent4",
            SchemeColor::Accent5 => "accent5",
            SchemeColor::Accent6 => "accent6",
        }
    }

    /// Try to parse from an OOXML scheme color string
    pub fn from_str(s: &str) -> Option<Self> {
        match s {
            "tx1" => Some(SchemeColor::Text1),
            "tx2" => Some(SchemeColor::Text2),
            "bg1" => Some(SchemeColor::Background1),
            "bg2" => Some(SchemeColor::Background2),
            "accent1" => Some(SchemeColor::Accent1),
            "accent2" => Some(SchemeColor::Accent2),
            "accent3" => Some(SchemeColor::Accent3),
            "accent4" => Some(SchemeColor::Accent4),
            "accent5" => Some(SchemeColor::Accent5),
            "accent6" => Some(SchemeColor::Accent6),
            _ => None,
        }
    }
}

/// Horizontal text alignment
#[derive(Debug, Clone, PartialEq, Default)]
pub enum AlignH {
    #[default]
    Left,
    Center,
    Right,
    Justify,
    Distribute,
}

impl AlignH {
    pub fn as_ooxml(&self) -> &'static str {
        match self {
            AlignH::Left => "l",
            AlignH::Center => "ctr",
            AlignH::Right => "r",
            AlignH::Justify => "just",
            AlignH::Distribute => "dist",
        }
    }
}

/// Vertical text alignment
#[derive(Debug, Clone, PartialEq, Default)]
pub enum AlignV {
    Top,
    #[default]
    Middle,
    Bottom,
}

impl AlignV {
    pub fn as_ooxml(&self) -> &'static str {
        match self {
            AlignV::Top => "t",
            AlignV::Middle => "ctr",
            AlignV::Bottom => "b",
        }
    }
}

/// Chart types
#[derive(Debug, Clone, PartialEq)]
pub enum ChartType {
    Area,
    Bar,
    Bar3D,
    Bubble,
    Bubble3D,
    Doughnut,
    Line,
    Pie,
    Radar,
    Scatter,
    /// Stock chart — High, Low, Close (3 series)
    StockHLC,
    /// Stock chart — Open, High, Low, Close (4 series)
    StockOHLC,
    /// Stock chart — Volume + High, Low, Close (4 series, volume bar)
    StockVHLC,
    /// Stock chart — Volume + Open, High, Low, Close (5 series, volume bar)
    StockVOHLC,
    /// 3D surface chart
    Surface,
    /// 3D surface wireframe chart
    SurfaceWireframe,
    /// 2D top-view surface chart
    SurfaceTop,
    /// 2D top-view wireframe surface chart
    SurfaceTopWireframe,
}

/// All 150+ OOXML preset shape types
#[derive(Debug, Clone, PartialEq)]
pub enum ShapeType {
    AccentBorderCallout1,
    AccentBorderCallout2,
    AccentBorderCallout3,
    AccentCallout1,
    AccentCallout2,
    AccentCallout3,
    ActionButtonBackPrevious,
    ActionButtonBeginning,
    ActionButtonBlank,
    ActionButtonDocument,
    ActionButtonEnd,
    ActionButtonForwardNext,
    ActionButtonHelp,
    ActionButtonHome,
    ActionButtonInformation,
    ActionButtonMovie,
    ActionButtonReturn,
    ActionButtonSound,
    Arc,
    BentArrow,
    BentUpArrow,
    Bevel,
    BlockArc,
    BorderCallout1,
    BorderCallout2,
    BorderCallout3,
    BracePair,
    BracketPair,
    Callout1,
    Callout2,
    Callout3,
    Can,
    ChartPlus,
    ChartStar,
    ChartX,
    Chevron,
    Chord,
    CircularArrow,
    Cloud,
    CloudCallout,
    Corner,
    CornerTabs,
    Cube,
    CurvedDownArrow,
    CurvedLeftArrow,
    CurvedRightArrow,
    CurvedUpArrow,
    CustGeom,
    Decagon,
    DiagStripe,
    Diamond,
    Dodecagon,
    Donut,
    DoubleWave,
    DownArrow,
    DownArrowCallout,
    Ellipse,
    EllipseRibbon,
    EllipseRibbon2,
    FlowChartAlternateProcess,
    FlowChartCollate,
    FlowChartConnector,
    FlowChartDecision,
    FlowChartDelay,
    FlowChartDisplay,
    FlowChartDocument,
    FlowChartExtract,
    FlowChartInputOutput,
    FlowChartInternalStorage,
    FlowChartMagneticDisk,
    FlowChartMagneticDrum,
    FlowChartMagneticTape,
    FlowChartManualInput,
    FlowChartManualOperation,
    FlowChartMerge,
    FlowChartMultidocument,
    FlowChartOfflineStorage,
    FlowChartOffpageConnector,
    FlowChartOnlineStorage,
    FlowChartOr,
    FlowChartPredefinedProcess,
    FlowChartPreparation,
    FlowChartProcess,
    FlowChartPunchedCard,
    FlowChartPunchedTape,
    FlowChartSort,
    FlowChartSummingJunction,
    FlowChartTerminator,
    FolderCorner,
    Frame,
    Funnel,
    Gear6,
    Gear9,
    HalfFrame,
    Heart,
    Heptagon,
    Hexagon,
    HomePlate,
    HorizontalScroll,
    IrregularSeal1,
    IrregularSeal2,
    LeftArrow,
    LeftArrowCallout,
    LeftBrace,
    LeftBracket,
    LeftCircularArrow,
    LeftRightArrow,
    LeftRightArrowCallout,
    LeftRightCircularArrow,
    LeftRightRibbon,
    LeftRightUpArrow,
    LeftUpArrow,
    LightningBolt,
    Line,
    LineInv,
    MathDivide,
    MathEqual,
    MathMinus,
    MathMultiply,
    MathNotEqual,
    MathPlus,
    Moon,
    NoSmoking,
    NonIsoscelesTrapezoid,
    NotchedRightArrow,
    Octagon,
    Parallelogram,
    Pentagon,
    Pie,
    PieWedge,
    Plaque,
    PlaqueTabs,
    Plus,
    QuadArrow,
    QuadArrowCallout,
    Rect,
    Ribbon,
    Ribbon2,
    RightArrow,
    RightArrowCallout,
    RightBrace,
    RightBracket,
    Round1Rect,
    Round2DiagRect,
    Round2SameRect,
    RoundRect,
    RtTriangle,
    SmileyFace,
    Snip1Rect,
    Snip2DiagRect,
    Snip2SameRect,
    SnipRoundRect,
    SquareTabs,
    Star10,
    Star12,
    Star16,
    Star24,
    Star32,
    Star4,
    Star5,
    Star6,
    Star7,
    Star8,
    StripedRightArrow,
    Sun,
    SwooshArrow,
    Teardrop,
    Trapezoid,
    Triangle,
    UpArrow,
    UpArrowCallout,
    UpDownArrow,
    UpDownArrowCallout,
    UturnArrow,
    VerticalScroll,
    Wave,
    WedgeEllipseCallout,
    WedgeRectCallout,
    WedgeRoundRectCallout,
}

impl ShapeType {
    /// Returns the OOXML preset geometry name string
    pub fn as_str(&self) -> &'static str {
        match self {
            ShapeType::AccentBorderCallout1 => "accentBorderCallout1",
            ShapeType::AccentBorderCallout2 => "accentBorderCallout2",
            ShapeType::AccentBorderCallout3 => "accentBorderCallout3",
            ShapeType::AccentCallout1 => "accentCallout1",
            ShapeType::AccentCallout2 => "accentCallout2",
            ShapeType::AccentCallout3 => "accentCallout3",
            ShapeType::ActionButtonBackPrevious => "actionButtonBackPrevious",
            ShapeType::ActionButtonBeginning => "actionButtonBeginning",
            ShapeType::ActionButtonBlank => "actionButtonBlank",
            ShapeType::ActionButtonDocument => "actionButtonDocument",
            ShapeType::ActionButtonEnd => "actionButtonEnd",
            ShapeType::ActionButtonForwardNext => "actionButtonForwardNext",
            ShapeType::ActionButtonHelp => "actionButtonHelp",
            ShapeType::ActionButtonHome => "actionButtonHome",
            ShapeType::ActionButtonInformation => "actionButtonInformation",
            ShapeType::ActionButtonMovie => "actionButtonMovie",
            ShapeType::ActionButtonReturn => "actionButtonReturn",
            ShapeType::ActionButtonSound => "actionButtonSound",
            ShapeType::Arc => "arc",
            ShapeType::BentArrow => "bentArrow",
            ShapeType::BentUpArrow => "bentUpArrow",
            ShapeType::Bevel => "bevel",
            ShapeType::BlockArc => "blockArc",
            ShapeType::BorderCallout1 => "borderCallout1",
            ShapeType::BorderCallout2 => "borderCallout2",
            ShapeType::BorderCallout3 => "borderCallout3",
            ShapeType::BracePair => "bracePair",
            ShapeType::BracketPair => "bracketPair",
            ShapeType::Callout1 => "callout1",
            ShapeType::Callout2 => "callout2",
            ShapeType::Callout3 => "callout3",
            ShapeType::Can => "can",
            ShapeType::ChartPlus => "chartPlus",
            ShapeType::ChartStar => "chartStar",
            ShapeType::ChartX => "chartX",
            ShapeType::Chevron => "chevron",
            ShapeType::Chord => "chord",
            ShapeType::CircularArrow => "circularArrow",
            ShapeType::Cloud => "cloud",
            ShapeType::CloudCallout => "cloudCallout",
            ShapeType::Corner => "corner",
            ShapeType::CornerTabs => "cornerTabs",
            ShapeType::Cube => "cube",
            ShapeType::CurvedDownArrow => "curvedDownArrow",
            ShapeType::CurvedLeftArrow => "curvedLeftArrow",
            ShapeType::CurvedRightArrow => "curvedRightArrow",
            ShapeType::CurvedUpArrow => "curvedUpArrow",
            ShapeType::CustGeom => "custGeom",
            ShapeType::Decagon => "decagon",
            ShapeType::DiagStripe => "diagStripe",
            ShapeType::Diamond => "diamond",
            ShapeType::Dodecagon => "dodecagon",
            ShapeType::Donut => "donut",
            ShapeType::DoubleWave => "doubleWave",
            ShapeType::DownArrow => "downArrow",
            ShapeType::DownArrowCallout => "downArrowCallout",
            ShapeType::Ellipse => "ellipse",
            ShapeType::EllipseRibbon => "ellipseRibbon",
            ShapeType::EllipseRibbon2 => "ellipseRibbon2",
            ShapeType::FlowChartAlternateProcess => "flowChartAlternateProcess",
            ShapeType::FlowChartCollate => "flowChartCollate",
            ShapeType::FlowChartConnector => "flowChartConnector",
            ShapeType::FlowChartDecision => "flowChartDecision",
            ShapeType::FlowChartDelay => "flowChartDelay",
            ShapeType::FlowChartDisplay => "flowChartDisplay",
            ShapeType::FlowChartDocument => "flowChartDocument",
            ShapeType::FlowChartExtract => "flowChartExtract",
            ShapeType::FlowChartInputOutput => "flowChartInputOutput",
            ShapeType::FlowChartInternalStorage => "flowChartInternalStorage",
            ShapeType::FlowChartMagneticDisk => "flowChartMagneticDisk",
            ShapeType::FlowChartMagneticDrum => "flowChartMagneticDrum",
            ShapeType::FlowChartMagneticTape => "flowChartMagneticTape",
            ShapeType::FlowChartManualInput => "flowChartManualInput",
            ShapeType::FlowChartManualOperation => "flowChartManualOperation",
            ShapeType::FlowChartMerge => "flowChartMerge",
            ShapeType::FlowChartMultidocument => "flowChartMultidocument",
            ShapeType::FlowChartOfflineStorage => "flowChartOfflineStorage",
            ShapeType::FlowChartOffpageConnector => "flowChartOffpageConnector",
            ShapeType::FlowChartOnlineStorage => "flowChartOnlineStorage",
            ShapeType::FlowChartOr => "flowChartOr",
            ShapeType::FlowChartPredefinedProcess => "flowChartPredefinedProcess",
            ShapeType::FlowChartPreparation => "flowChartPreparation",
            ShapeType::FlowChartProcess => "flowChartProcess",
            ShapeType::FlowChartPunchedCard => "flowChartPunchedCard",
            ShapeType::FlowChartPunchedTape => "flowChartPunchedTape",
            ShapeType::FlowChartSort => "flowChartSort",
            ShapeType::FlowChartSummingJunction => "flowChartSummingJunction",
            ShapeType::FlowChartTerminator => "flowChartTerminator",
            ShapeType::FolderCorner => "folderCorner",
            ShapeType::Frame => "frame",
            ShapeType::Funnel => "funnel",
            ShapeType::Gear6 => "gear6",
            ShapeType::Gear9 => "gear9",
            ShapeType::HalfFrame => "halfFrame",
            ShapeType::Heart => "heart",
            ShapeType::Heptagon => "heptagon",
            ShapeType::Hexagon => "hexagon",
            ShapeType::HomePlate => "homePlate",
            ShapeType::HorizontalScroll => "horizontalScroll",
            ShapeType::IrregularSeal1 => "irregularSeal1",
            ShapeType::IrregularSeal2 => "irregularSeal2",
            ShapeType::LeftArrow => "leftArrow",
            ShapeType::LeftArrowCallout => "leftArrowCallout",
            ShapeType::LeftBrace => "leftBrace",
            ShapeType::LeftBracket => "leftBracket",
            ShapeType::LeftCircularArrow => "leftCircularArrow",
            ShapeType::LeftRightArrow => "leftRightArrow",
            ShapeType::LeftRightArrowCallout => "leftRightArrowCallout",
            ShapeType::LeftRightCircularArrow => "leftRightCircularArrow",
            ShapeType::LeftRightRibbon => "leftRightRibbon",
            ShapeType::LeftRightUpArrow => "leftRightUpArrow",
            ShapeType::LeftUpArrow => "leftUpArrow",
            ShapeType::LightningBolt => "lightningBolt",
            ShapeType::Line => "line",
            ShapeType::LineInv => "lineInv",
            ShapeType::MathDivide => "mathDivide",
            ShapeType::MathEqual => "mathEqual",
            ShapeType::MathMinus => "mathMinus",
            ShapeType::MathMultiply => "mathMultiply",
            ShapeType::MathNotEqual => "mathNotEqual",
            ShapeType::MathPlus => "mathPlus",
            ShapeType::Moon => "moon",
            ShapeType::NoSmoking => "noSmoking",
            ShapeType::NonIsoscelesTrapezoid => "nonIsoscelesTrapezoid",
            ShapeType::NotchedRightArrow => "notchedRightArrow",
            ShapeType::Octagon => "octagon",
            ShapeType::Parallelogram => "parallelogram",
            ShapeType::Pentagon => "pentagon",
            ShapeType::Pie => "pie",
            ShapeType::PieWedge => "pieWedge",
            ShapeType::Plaque => "plaque",
            ShapeType::PlaqueTabs => "plaqueTabs",
            ShapeType::Plus => "plus",
            ShapeType::QuadArrow => "quadArrow",
            ShapeType::QuadArrowCallout => "quadArrowCallout",
            ShapeType::Rect => "rect",
            ShapeType::Ribbon => "ribbon",
            ShapeType::Ribbon2 => "ribbon2",
            ShapeType::RightArrow => "rightArrow",
            ShapeType::RightArrowCallout => "rightArrowCallout",
            ShapeType::RightBrace => "rightBrace",
            ShapeType::RightBracket => "rightBracket",
            ShapeType::Round1Rect => "round1Rect",
            ShapeType::Round2DiagRect => "round2DiagRect",
            ShapeType::Round2SameRect => "round2SameRect",
            ShapeType::RoundRect => "roundRect",
            ShapeType::RtTriangle => "rtTriangle",
            ShapeType::SmileyFace => "smileyFace",
            ShapeType::Snip1Rect => "snip1Rect",
            ShapeType::Snip2DiagRect => "snip2DiagRect",
            ShapeType::Snip2SameRect => "snip2SameRect",
            ShapeType::SnipRoundRect => "snipRoundRect",
            ShapeType::SquareTabs => "squareTabs",
            ShapeType::Star10 => "star10",
            ShapeType::Star12 => "star12",
            ShapeType::Star16 => "star16",
            ShapeType::Star24 => "star24",
            ShapeType::Star32 => "star32",
            ShapeType::Star4 => "star4",
            ShapeType::Star5 => "star5",
            ShapeType::Star6 => "star6",
            ShapeType::Star7 => "star7",
            ShapeType::Star8 => "star8",
            ShapeType::StripedRightArrow => "stripedRightArrow",
            ShapeType::Sun => "sun",
            ShapeType::SwooshArrow => "swooshArrow",
            ShapeType::Teardrop => "teardrop",
            ShapeType::Trapezoid => "trapezoid",
            ShapeType::Triangle => "triangle",
            ShapeType::UpArrow => "upArrow",
            ShapeType::UpArrowCallout => "upArrowCallout",
            ShapeType::UpDownArrow => "upDownArrow",
            ShapeType::UpDownArrowCallout => "upDownArrowCallout",
            ShapeType::UturnArrow => "uturnArrow",
            ShapeType::VerticalScroll => "verticalScroll",
            ShapeType::Wave => "wave",
            ShapeType::WedgeEllipseCallout => "wedgeEllipseCallout",
            ShapeType::WedgeRectCallout => "wedgeRectCallout",
            ShapeType::WedgeRoundRectCallout => "wedgeRoundRectCallout",
        }
    }
}