Add more files for creating a drawing
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
// http://officeopenxml.com/WPdocument.php
|
||||
import { IMediaData } from "file/media";
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { Paragraph } from "../paragraph";
|
||||
import { Paragraph, PictureRun } from "../paragraph";
|
||||
import { Table } from "../table";
|
||||
import { Body } from "./body";
|
||||
import { DocumentAttributes } from "./document-attributes";
|
||||
@ -52,4 +53,18 @@ export class Document extends XmlComponent {
|
||||
this.addTable(table);
|
||||
return table;
|
||||
}
|
||||
|
||||
public addDrawing(imageData: IMediaData): void {
|
||||
const paragraph = new Paragraph();
|
||||
const run = new PictureRun(imageData);
|
||||
paragraph.addRun(run);
|
||||
|
||||
this.body.push(paragraph);
|
||||
}
|
||||
|
||||
public createDrawing(imageData: IMediaData): void {
|
||||
this.addDrawing(imageData);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
import { XmlAttributeComponent } from "file/xml-components";
|
||||
|
||||
export interface IGraphicFrameLockAttributes {
|
||||
xmlns?: string;
|
||||
noChangeAspect?: number;
|
||||
}
|
||||
|
||||
export class GraphicFrameLockAttributes extends XmlAttributeComponent<IGraphicFrameLockAttributes> {
|
||||
protected xmlKeys = {
|
||||
xmlns: "xmlns:a",
|
||||
noChangeAspect: "noChangeAspect",
|
||||
};
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { GraphicFrameLockAttributes } from "./graphic-frame-lock-attributes";
|
||||
|
||||
export class GraphicFrameLocks extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("a:graphicFrameLocks");
|
||||
|
||||
this.root.push(new GraphicFrameLockAttributes({
|
||||
xmlns: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
||||
noChangeAspect: 1,
|
||||
}));
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { GraphicFrameLocks } from "./graphic-frame-locks/graphic-frame-locks";
|
||||
|
||||
export class GraphicFrameProperties extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("wp:cNvGraphicFramePr");
|
||||
|
||||
this.root.push(new GraphicFrameLocks());
|
||||
}
|
||||
}
|
@ -1,10 +1 @@
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { BlipFill } from "./blip/blip-fill";
|
||||
|
||||
export class Pic extends XmlComponent {
|
||||
|
||||
constructor(referenceId: number) {
|
||||
super("pic:pic");
|
||||
this.root.push(new BlipFill(referenceId));
|
||||
}
|
||||
}
|
||||
export * from "./pic";
|
||||
|
@ -0,0 +1,11 @@
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { PicLocks } from "./pic-locks/pic-locks";
|
||||
|
||||
export class ChildNonVisualProperties extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("pic:cNvPicPr");
|
||||
|
||||
this.root.push(new PicLocks());
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
import { XmlAttributeComponent } from "file/xml-components";
|
||||
|
||||
export interface IPicLocksAttributes {
|
||||
noChangeAspect?: number;
|
||||
noChangeArrowheads?: number;
|
||||
}
|
||||
|
||||
export class PicLocksAttributes extends XmlAttributeComponent<IPicLocksAttributes> {
|
||||
protected xmlKeys = {
|
||||
noChangeAspect: "noChangeAspect",
|
||||
noChangeArrowheads: "noChangeArrowheads",
|
||||
};
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { PicLocksAttributes } from "./pic-locks-attributes";
|
||||
|
||||
export class PicLocks extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("a:picLocks");
|
||||
this.root.push(new PicLocksAttributes({
|
||||
noChangeAspect: 1,
|
||||
noChangeArrowheads: 1,
|
||||
}));
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { ChildNonVisualProperties } from "./child-non-visual-pic-properties/child-non-visual-pic-properties";
|
||||
import { NonVisualProperties } from "./non-visual-properties/non-visual-properties";
|
||||
|
||||
export class NonVisualPicProperties extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("pic:nvPicPr");
|
||||
|
||||
this.root.push(new NonVisualProperties());
|
||||
this.root.push(new ChildNonVisualProperties());
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import { XmlAttributeComponent } from "file/xml-components";
|
||||
|
||||
export interface INonVisualPropertiesAttributes {
|
||||
id?: number;
|
||||
name?: string;
|
||||
descr?: string;
|
||||
}
|
||||
|
||||
export class NonVisualPropertiesAttributes extends XmlAttributeComponent<INonVisualPropertiesAttributes> {
|
||||
protected xmlKeys = {
|
||||
id: "id",
|
||||
name: "name",
|
||||
descr: "desc",
|
||||
};
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { NonVisualPropertiesAttributes } from "./non-visual-properties-attributes";
|
||||
|
||||
export class NonVisualProperties extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
super("pic:cNvPr");
|
||||
|
||||
this.root.push(new NonVisualPropertiesAttributes({
|
||||
id: 0,
|
||||
name: "",
|
||||
descr: "",
|
||||
}));
|
||||
}
|
||||
}
|
13
src/file/drawing/inline/graphic/graphic-data/pic/pic.ts
Normal file
13
src/file/drawing/inline/graphic/graphic-data/pic/pic.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { BlipFill } from "./blip/blip-fill";
|
||||
import { NonVisualPicProperties } from "./non-visual-pic-properties/non-visual-pic-properties";
|
||||
|
||||
export class Pic extends XmlComponent {
|
||||
|
||||
constructor(referenceId: number) {
|
||||
super("pic:pic");
|
||||
|
||||
this.root.push(new NonVisualPicProperties());
|
||||
this.root.push(new BlipFill(referenceId));
|
||||
}
|
||||
}
|
@ -1,10 +1 @@
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { Graphic } from "./graphic";
|
||||
|
||||
export class Inline extends XmlComponent {
|
||||
|
||||
constructor(referenceId: number) {
|
||||
super("wp:inline");
|
||||
this.root.push(new Graphic(referenceId));
|
||||
}
|
||||
}
|
||||
export * from "./inline";
|
||||
|
13
src/file/drawing/inline/inline.ts
Normal file
13
src/file/drawing/inline/inline.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { Graphic } from "./graphic";
|
||||
import { GraphicFrameProperties } from "./graphic-frame/graphic-frame-properties";
|
||||
|
||||
export class Inline extends XmlComponent {
|
||||
|
||||
constructor(referenceId: number) {
|
||||
super("wp:inline");
|
||||
|
||||
this.root.push(new GraphicFrameProperties());
|
||||
this.root.push(new Graphic(referenceId));
|
||||
}
|
||||
}
|
@ -52,6 +52,12 @@ export class File {
|
||||
return this.document.createTable(rows, cols);
|
||||
}
|
||||
|
||||
public createImage(image: string): void {
|
||||
const mediaData = this.media.addMedia(image);
|
||||
this.relationships.createRelationship(mediaData.referenceId, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${mediaData.fileName}`);
|
||||
this.document.createDrawing(mediaData);
|
||||
}
|
||||
|
||||
public get Document(): Document {
|
||||
return this.document;
|
||||
}
|
||||
|
Reference in New Issue
Block a user