Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
qq15725 committed Dec 4, 2024
1 parent 602b8a2 commit 392bc7b
Show file tree
Hide file tree
Showing 73 changed files with 575 additions and 531 deletions.
9 changes: 9 additions & 0 deletions src/openxml/drawing/AdjustHandleList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.adjusthandlelist
*/
@defineElement('a:ahLst')
export class AdjustHandleList extends OXML {
// TODO
}
10 changes: 10 additions & 0 deletions src/openxml/drawing/AdjustValueList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { ShapeGuide } from './ShapeGuide'
import { defineChildren, defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.adjustvaluelist
*/
@defineElement('a:avLst')
export class AdjustValueList extends OXML {
@defineChildren('a:gd') declare value: ShapeGuide[]
}
12 changes: 12 additions & 0 deletions src/openxml/drawing/ArcTo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineAttribute, defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.arcto
*/
@defineElement('a:arcTo')
export class ArcTo extends OXML {
@defineAttribute('hR', 'ST_AdjCoordinate') declare hR: number
@defineAttribute('wR', 'ST_AdjCoordinate') declare wR: number
@defineAttribute('stAng', 'ST_AdjAngle') declare stAng: number
@defineAttribute('swAng', 'ST_AdjAngle') declare swAng: number
}
4 changes: 2 additions & 2 deletions src/openxml/drawing/BackgroundColor.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineElement } from '../../core'
import { _ColorDefinable } from './_ColorDefinable'
import { _Color } from './_Color'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.backgroundcolor
*/
@defineElement('a:bgClr')
export class BackgroundColor extends _ColorDefinable {
export class BackgroundColor extends _Color {
//
}
9 changes: 9 additions & 0 deletions src/openxml/drawing/CloseShapePath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.closeshapepath
*/
@defineElement('a:close')
export class CloseShapePath extends OXML {
//
}
9 changes: 9 additions & 0 deletions src/openxml/drawing/ConnectionSiteList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.connectionsitelist
*/
@defineElement('a:cxnLst')
export class ConnectionSiteList extends OXML {
// TODO
}
10 changes: 10 additions & 0 deletions src/openxml/drawing/CubicBezierCurveTo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Point } from './Point'
import { defineChildren, defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.cubicbeziercurveto
*/
@defineElement('a:cubicBezTo')
export class CubicBezierCurveTo extends OXML {
@defineChildren('a:pt') declare value: Point[]
}
17 changes: 11 additions & 6 deletions src/openxml/drawing/CustomGeometry.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import type { AdjustHandleList } from './AdjustHandleList'
import type { AdjustValueList } from './AdjustValueList'
import type { ConnectionSiteList } from './ConnectionSiteList'
import type { PathList } from './PathList'
import type { Rectangle } from './Rectangle'
import type { ShapeGuideList } from './ShapeGuideList'
import { defineChild, defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.customgeometry
*/
@defineElement('a:custGeom')
export class CustomGeometry extends OXML {
@defineChild('a:ahLst') declare ahLst: OXML
@defineChild('a:avLst') declare avLst: OXML
@defineChild('a:cxnLst') declare cxnLst: OXML
@defineChild('a:gdLst') declare gdLst: OXML
@defineChild('a:pathLst') declare pathLst: OXML
@defineChild('a:rect') declare rect: Rectangle
@defineChild('a:ahLst') ahLst?: AdjustHandleList
@defineChild('a:avLst') avLst?: AdjustValueList
@defineChild('a:cxnLst') cxnLst?: ConnectionSiteList
@defineChild('a:gdLst') gdLst?: ShapeGuideList
@defineChild('a:pathLst') pathLst?: PathList
@defineChild('a:rect') rect?: Rectangle
}
10 changes: 10 additions & 0 deletions src/openxml/drawing/DefaultParagraphProperties.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineElement } from '../../core'
import { _ParagraphProperties } from './_ParagraphProperties'

/**
* @link https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.DefaultParagraphProperties
*/
@defineElement('a:defPPr')
export class DefaultParagraphProperties extends _ParagraphProperties {
//
}
9 changes: 9 additions & 0 deletions src/openxml/drawing/EffectDag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineElement, OXML } from '../../core'

/**
* @link https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.effectdag
*/
@defineElement('a:effectDag')
export class EffectDag extends OXML {
// TODO
}
12 changes: 10 additions & 2 deletions src/openxml/drawing/EffectList.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { defineElement, OXML } from '../../core'
import { defineChild, defineElement, OXML } from '../../core'

/**
* @link https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.effectlist
*/
@defineElement('a:effectLst')
export class EffectList extends OXML {
//
// TODO
@defineChild('blur') blur?: OXML
@defineChild('fillOverlay') fillOverlay?: OXML
@defineChild('glow') glow?: OXML
@defineChild('innerShdw') innerShdw?: OXML
@defineChild('outerShdw') outerShdw?: OXML
@defineChild('prstShdw') prstShdw?: OXML
@defineChild('reflection') reflection?: OXML
@defineChild('softEdge') softEdge?: OXML
}
4 changes: 2 additions & 2 deletions src/openxml/drawing/EffectReference.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineAttribute, defineElement } from '../../core'
import { _ColorDefinable } from './_ColorDefinable'
import { _Color } from './_Color'

/**
* @link https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.effectreference
*/
@defineElement('a:effectRef')
export class EffectReference extends _ColorDefinable {
export class EffectReference extends _Color {
@defineAttribute('idx') declare idx: string
}
2 changes: 1 addition & 1 deletion src/openxml/drawing/Extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import { defineAttribute, defineElement, OXML } from '../../core'
*/
@defineElement('a:ext')
export class Extension extends OXML {
@defineAttribute('uri', 'string') declare uri: string
@defineAttribute('uri') declare uri: string
}
8 changes: 4 additions & 4 deletions src/openxml/drawing/FillRectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { defineAttribute, defineElement, OXML } from '../../core'
*/
@defineElement('a:fillRect')
export class FillRectangle extends OXML {
@defineAttribute('b', 'rate') declare b: number
@defineAttribute('l', 'rate') declare l: number
@defineAttribute('r', 'rate') declare r: number
@defineAttribute('t', 'rate') declare t: number
@defineAttribute('b', 'ST_Percentage') declare b: number
@defineAttribute('l', 'ST_Percentage') declare l: number
@defineAttribute('r', 'ST_Percentage') declare r: number
@defineAttribute('t', 'ST_Percentage') declare t: number
}
4 changes: 2 additions & 2 deletions src/openxml/drawing/FillReference.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineAttribute, defineElement } from '../../core'
import { _ColorDefinable } from './_ColorDefinable'
import { _Color } from './_Color'

/**
* @link https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.fillreference
*/
@defineElement('a:fillRef')
export class FillReference extends _ColorDefinable {
export class FillReference extends _Color {
@defineAttribute('idx') declare idx: string
}
4 changes: 2 additions & 2 deletions src/openxml/drawing/FontReference.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineAttribute, defineElement } from '../../core'
import { _ColorDefinable } from './_ColorDefinable'
import { _Color } from './_Color'

/**
* @link https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.fontreference
*/
@defineElement('a:fontRef')
export class FontReference extends _ColorDefinable {
export class FontReference extends _Color {
@defineAttribute('idx') declare idx: string
}
18 changes: 4 additions & 14 deletions src/openxml/drawing/ForegroundColor.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import type { HslColor } from './HslColor'
import type { PresetColor } from './PresetColor'
import type { RgbColorModelHex } from './RgbColorModelHex'
import type { RgbColorModelPercentage } from './RgbColorModelPercentage'
import type { SchemeColor } from './SchemeColor'
import type { SystemColor } from './SystemColor'
import { defineChild, defineElement, OXML } from '../../core'
import { defineElement } from '../../core'
import { _Color } from './_Color'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.foregroundcolor
*/
@defineElement('a:fgClr')
export class ForegroundColor extends OXML {
@defineChild('a:hslClr') hslClr?: HslColor
@defineChild('a:prstClr') prstClr?: PresetColor
@defineChild('a:schemeClr') schemeClr?: SchemeColor
@defineChild('a:scrgbClr') scrgbClr?: RgbColorModelPercentage
@defineChild('a:srgbClr') srgbClr?: RgbColorModelHex
@defineChild('a:sysClr') sysClr?: SystemColor
export class ForegroundColor extends _Color {
//
}
4 changes: 2 additions & 2 deletions src/openxml/drawing/GradientStop.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineAttribute, defineElement } from '../../core'
import { _ColorDefinable } from './_ColorDefinable'
import { _Color } from './_Color'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.GradientStop
*/
@defineElement('a:gs')
export class GradientStop extends _ColorDefinable {
export class GradientStop extends _Color {
@defineAttribute('pos', 'positiveFixedPercentage') declare pos: number
}
9 changes: 9 additions & 0 deletions src/openxml/drawing/GroupFill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.groupfill
*/
@defineElement('a:grpFill')
export class GroupFill extends OXML {
//
}
5 changes: 4 additions & 1 deletion src/openxml/drawing/HslColor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineAttribute, defineElement, OXML } from '../../core'
import type { Alpha } from './Alpha'
import { defineAttribute, defineChild, defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.hslcolor
Expand All @@ -8,4 +9,6 @@ export class HslColor extends OXML {
@defineAttribute('hue', 'positiveFixedAngle') declare hue: number
@defineAttribute('sat', 'percentage') declare sat: number
@defineAttribute('lum', 'percentage') declare lum: number

@defineChild('a:alpha') alpha?: Alpha
}
4 changes: 2 additions & 2 deletions src/openxml/drawing/LineReference.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineAttribute, defineElement } from '../../core'
import { _ColorDefinable } from './_ColorDefinable'
import { _Color } from './_Color'

/**
* @link https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.linereference
*/
@defineElement('a:lnRef')
export class LineReference extends _ColorDefinable {
export class LineReference extends _Color {
@defineAttribute('idx') declare idx: string
}
10 changes: 10 additions & 0 deletions src/openxml/drawing/LineTo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Point } from './Point'
import { defineChild, defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.lineto
*/
@defineElement('a:lnTo')
export class LineTo extends OXML {
@defineChild('a:pt') declare pt: Point
}
5 changes: 3 additions & 2 deletions src/openxml/drawing/ListStyle.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { defineElement, OXML } from '../../core'
import { defineElement } from '../../core'
import { _Style } from './_Style'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.liststyle
*/
@defineElement('a:lstStyle')
export class ListStyle extends OXML {
export class ListStyle extends _Style {
//
}
10 changes: 10 additions & 0 deletions src/openxml/drawing/MoveTo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Point } from './Point'
import { defineChild, defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.moveto
*/
@defineElement('a:moveTo')
export class MoveTo extends OXML {
@defineChild('a:pt') declare pt: Point
}
4 changes: 2 additions & 2 deletions src/openxml/drawing/Paragraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export class Paragraph extends OXML {
@defineProperty('pPr.marL', 0) declare marginLeft: number
@defineProperty('pPr.marR', 0) declare marginRight: number
@defineProperty('pPr.indent', 0) declare textIndent: number
@defineProperty('pPr.lvl') level?: number
@defineProperty('pPr.fontAlgn') fontAlign?: string

get level(): number | undefined { return this.pPr.lvl }
get textAlign(): TextAlignmentTypeValues | undefined { return this.pPr.algn }
get fontAlign(): string | undefined { return this.pPr.fontAlgn }
get rightToLeft(): string | undefined { return this.pPr.rtl }
}
34 changes: 32 additions & 2 deletions src/openxml/drawing/Path.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
import { defineElement, OXML } from '../../core'
import { defineAttribute, defineElement, OXML } from '../../core'
import { ArcTo } from './ArcTo'
import { CloseShapePath } from './CloseShapePath'
import { CubicBezierCurveTo } from './CubicBezierCurveTo'
import { LineTo } from './LineTo'
import { MoveTo } from './MoveTo'
import { QuadraticBezierCurveTo } from './QuadraticBezierCurveTo'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.path
*/
@defineElement('a:path')
export class Path extends OXML {
//
@defineAttribute('extrusionOk', 'boolean') extrusionOk?: boolean
@defineAttribute('fill', 'boolean') fill?: boolean
@defineAttribute('stroke', 'boolean') stroke?: boolean
@defineAttribute('w', 'ST_PositiveCoordinate') declare w: number
@defineAttribute('h', 'ST_PositiveCoordinate') declare h: number

get commands() {
return Array.from(this.element.children).map((element) => {
switch (element.tagName) {
case 'a:arcTo':
return new ArcTo().fromElement(element)
case 'a:close':
return new CloseShapePath().fromElement(element)
case 'a:lnTo':
return new LineTo().fromElement(element)
case 'a:cubicBezTo':
return new CubicBezierCurveTo().fromElement(element)
case 'a:quadBezTo':
return new QuadraticBezierCurveTo().fromElement(element)
case 'a:moveTo':
default:
return new MoveTo().fromElement(element)
}
})
}
}
10 changes: 10 additions & 0 deletions src/openxml/drawing/PathList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Path } from './Path'
import { defineChildren, defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.pathlist
*/
@defineElement('a:pathLst')
export class PathList extends OXML {
@defineChildren('a:path') declare value: Path[]
}
10 changes: 10 additions & 0 deletions src/openxml/drawing/Point.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineAttribute, defineElement, OXML } from '../../core'

/**
* https://learn.microsoft.com/dotnet/api/documentformat.openxml.drawing.point
*/
@defineElement('a:pt')
export class Point extends OXML {
@defineAttribute('x', 'ST_AdjCoordinate') declare x: number
@defineAttribute('y', 'ST_AdjCoordinate') declare y: number
}
Loading

0 comments on commit 392bc7b

Please sign in to comment.