2022-06-26 23:26:42 +01:00
|
|
|
import { IMediaData } from "@file/media";
|
|
|
|
import { XmlComponent } from "@file/xml-components";
|
2022-10-26 23:09:36 +01:00
|
|
|
|
2018-06-08 16:03:04 +02:00
|
|
|
import { Anchor } from "./anchor";
|
2022-10-26 23:09:36 +01:00
|
|
|
import { DocPropertiesOptions } from "./doc-properties/doc-properties";
|
2018-06-09 23:49:01 +01:00
|
|
|
import { IFloating } from "./floating";
|
2023-12-27 20:20:45 +00:00
|
|
|
import { createInline } from "./inline";
|
|
|
|
import { OutlineOptions } from "./inline/graphic/graphic-data/pic/shape-properties/outline/outline";
|
2018-06-08 16:03:04 +02:00
|
|
|
|
2023-12-27 20:20:45 +00:00
|
|
|
export type IDistance = {
|
2018-11-02 02:51:57 +00:00
|
|
|
readonly distT?: number;
|
|
|
|
readonly distB?: number;
|
|
|
|
readonly distL?: number;
|
|
|
|
readonly distR?: number;
|
2023-12-27 20:20:45 +00:00
|
|
|
};
|
2018-06-08 16:03:04 +02:00
|
|
|
|
2018-06-09 23:49:01 +01:00
|
|
|
export interface IDrawingOptions {
|
2018-11-02 02:51:57 +00:00
|
|
|
readonly floating?: IFloating;
|
2022-10-26 23:09:36 +01:00
|
|
|
readonly docProperties?: DocPropertiesOptions;
|
2023-12-27 20:20:45 +00:00
|
|
|
readonly outline?: OutlineOptions;
|
2018-06-08 16:03:04 +02:00
|
|
|
}
|
|
|
|
|
2021-05-26 09:28:31 +03:00
|
|
|
// <xsd:complexType name="CT_Drawing">
|
|
|
|
// <xsd:choice minOccurs="1" maxOccurs="unbounded">
|
|
|
|
// <xsd:element ref="wp:anchor" minOccurs="0"/>
|
|
|
|
// <xsd:element ref="wp:inline" minOccurs="0"/>
|
|
|
|
// </xsd:choice>
|
|
|
|
// </xsd:complexType>
|
|
|
|
|
2017-12-30 20:59:05 +00:00
|
|
|
export class Drawing extends XmlComponent {
|
2022-08-31 07:52:27 +01:00
|
|
|
public constructor(imageData: IMediaData, drawingOptions: IDrawingOptions = {}) {
|
2017-12-30 20:59:05 +00:00
|
|
|
super("w:drawing");
|
|
|
|
|
2019-01-09 01:16:47 +00:00
|
|
|
if (!drawingOptions.floating) {
|
2023-12-27 20:20:45 +00:00
|
|
|
this.root.push(
|
|
|
|
createInline({
|
|
|
|
mediaData: imageData,
|
|
|
|
transform: imageData.transformation,
|
|
|
|
docProperties: drawingOptions.docProperties,
|
|
|
|
outline: drawingOptions.outline,
|
|
|
|
}),
|
|
|
|
);
|
2019-01-09 01:16:47 +00:00
|
|
|
} else {
|
2023-12-27 20:20:45 +00:00
|
|
|
this.root.push(new Anchor({ mediaData: imageData, transform: imageData.transformation, drawingOptions }));
|
2018-06-08 16:03:04 +02:00
|
|
|
}
|
2017-12-30 20:59:05 +00:00
|
|
|
}
|
|
|
|
}
|