Update msoffice.js

This commit is contained in:
Namhyeon Go 2024-06-02 02:14:23 +09:00
parent b391867f14
commit aa8f10b6a7

View File

@ -120,9 +120,6 @@ function PowerPoint() {
this.currentPresentation = null; this.currentPresentation = null;
this.open = function(filename) { this.open = function(filename) {
console.log("test");
console.log(typeof filename);
if (typeof filename !== "undefined") { if (typeof filename !== "undefined") {
// check type of the path // check type of the path
if (filename.indexOf(":\\") < 0 && filename.indexOf(":/") < 0) { if (filename.indexOf(":\\") < 0 && filename.indexOf(":/") < 0) {
@ -137,37 +134,59 @@ function PowerPoint() {
this.currentPresentation = this.application.Presentations.Add(true); this.currentPresentation = this.application.Presentations.Add(true);
} }
} else { } else {
this.currentPresentation = this.application.Presentations.Add(true); this.currentPresentation = this.application.Presentations.Add(true);
} }
//this.selectPresentation(1);
}; };
this.selectPresentation = function(idx) { this.selectPresentation = function(idx) {
if (idx == 0) { if (idx == 0) {
this.currentWorksheet = this.application.ActivePresentation; this.currentPresentation = this.application.ActivePresentation;
} else { } else {
this.currentWorksheet = this.application.Presentations(idx); this.currentPresentation = this.application.Presentations(idx);
} }
return this; return this;
}; };
// get all slides this.saveAs = function(filename) {
this.getSlides = function() { try {
var slides = []; this.currentPresentation.saveAs(filename);
return FILE.fileExists(filename);
} catch (e) {
console.error("Could not save a file:", e.message);
return false;
}
};
var slideEnum = new Enumerator(this.currentPresentation.Slides); this.close = function() {
for (; !slideEnum.atEnd(); slideEnum.moveNext()) { try {
slides.push(new PowerPoint.Slide(slideEnum.item())); this.currentPresentation.Close()
} this.currentPresentation = null;
this.application = null;
} catch (e) {
this.currentPresentation = null;
this.application = null;
}
};
return slides; // get all slides
}; this.getSlides = function() {
var slides = [];
var slideEnum = new Enumerator(this.currentPresentation.Slides);
for (; !slideEnum.atEnd(); slideEnum.moveNext()) {
slides.push(new PowerPoint.Slide(slideEnum.item()));
}
return slides;
};
} }
PowerPoint.Slide = function(slide) { PowerPoint.Slide = function(slide) {
this.slide = slide; this.slide = slide;
this.getShapes = function() { this.getShapes = function() {
// todo // todo
}; };
}; };
PowerPoint.Shape = function(shape) { PowerPoint.Shape = function(shape) {
this.shape = shape; this.shape = shape;