file関係
DataSource
Table
SQL(HSQLDB)
file操作
文書入力
Style
file操作
Page操作
図形
Style
Connector
その他
file操作
Page操作
図形
Style
Connector
画面切り替え(SlideShow)
Annimation(SlideShow)
//Open new Base file
importClass(Packages.com.sun.star.beans.PropertyValue);
importClass(Packages.com.sun.star.comp.helper.Bootstrap);
importClass(Packages.com.sun.star.comp.helper.BootstrapException);
importClass(Packages.com.sun.star.frame.XComponentLoader);
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
xContext = XSCRIPTCONTEXT.getComponentContext();
// xContext = Bootstrap.bootstrap(); //<= OOo3.1.1以前は動作した。
xMultiComponentFactory = xContext.getServiceManager();
xtest = xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
xcomponentloader = UnoRuntime.queryInterface(XComponentLoader,xtest);
loadURL = "private:factory/sdatabase";
propertyvalue = new Array();
xcomponentloader.loadComponentFromURL(loadURL, "_blank", 0, propertyvalue);
//Open Base file
importClass(Packages.com.sun.star.beans.PropertyValue);
importClass(Packages.com.sun.star.comp.helper.Bootstrap);
importClass(Packages.com.sun.star.comp.helper.BootstrapException);
importClass(Packages.com.sun.star.frame.XComponentLoader);
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
xContext = XSCRIPTCONTEXT.getComponentContext();
// xContext = Bootstrap.bootstrap(); //<= OOo3.1.1以前は動作した。
xMultiComponentFactory = xContext.getServiceManager();
xtest = xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
xcomponentloader = UnoRuntime.queryInterface(XComponentLoader,xtest);
//
loadURL = "file:///C:/temp/oBaseMacro2.odb";
// loadURL = oURL.toString(); // <= String化しなくともOK
propertyvalue = new Array();
xcomponentloader.loadComponentFromURL(loadURL, "_blank", 0, propertyvalue);
//
importClass(Packages.javax.swing.JOptionPane);
JOptionPane.showMessageDialog(null, "Success");
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
importClass(Packages.com.sun.star.beans.PropertyValue);
importClass(Packages.com.sun.star.comp.helper.Bootstrap);
importClass(Packages.com.sun.star.comp.helper.BootstrapException);
importClass(Packages.com.sun.star.frame.XComponentLoader);
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.beans.UnknownPropertyException);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.lang.WrappedTargetException);
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
// xContext = Bootstrap.bootstrap(); //<= OOo3.1.1以前は動作した。
xMultiComponentFactory = xContext.getServiceManager();
xtest = xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
xcomponentloader = UnoRuntime.queryInterface(XComponentLoader,xtest);
loadURL = "private:factory/sdatabase";
propertyvalue = new Array();
oDoc = xcomponentloader.loadComponentFromURL(loadURL, "_blank", 0, propertyvalue);
//
xOfficeDatabaseDocument = UnoRuntime.queryInterface(XOfficeDatabaseDocument, oDoc);
xDataSource = xOfficeDatabaseDocument.getDataSource();
xPropertySet = UnoRuntime.queryInterface(XPropertySet, xDataSource);
xPropertySet.setPropertyValue("URL", "sdbc:embedded:hsqldb");
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof WrappedTargetException) {
// getPropertyValue
} else if (e instanceof UnknownPropertyException)
{
// getPropertyValue
} else {
}
}
// 本Codeは2回続けて実行は不可
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
importClass(Packages.com.sun.star.beans.PropertyValue);
importClass(Packages.com.sun.star.comp.helper.Bootstrap);
importClass(Packages.com.sun.star.comp.helper.BootstrapException);
importClass(Packages.com.sun.star.frame.XComponentLoader);
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.beans.UnknownPropertyException);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.lang.WrappedTargetException);
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
importClass(Packages.com.sun.star.frame.XStorable);
importClass(Packages.com.sun.star.io.IOException);
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
// xContext = Bootstrap.bootstrap(); //<= OOo3.1.1以前は動作した。
xMultiComponentFactory = xContext.getServiceManager();
xtest = xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
xcomponentloader = UnoRuntime.queryInterface(XComponentLoader,xtest);
//
loadURL = "private:factory/sdatabase";
propertyvalue = new Array();
oDoc = xcomponentloader.loadComponentFromURL(loadURL, "_blank", 0, propertyvalue);
//
xOfficeDatabaseDocument = UnoRuntime.queryInterface(XOfficeDatabaseDocument, oDoc);
xDataSource = xOfficeDatabaseDocument.getDataSource();
xPropertySet = UnoRuntime.queryInterface(XPropertySet, xDataSource);
xPropertySet.setPropertyValue("URL", "sdbc:embedded:hsqldb");
//
oStoreURL = "file:///C:/temp/oBaseMacro3.odb";
xStorable = UnoRuntime.queryInterface(XStorable,oDoc);
storeProps = new PropertyValue();
storeProps.Name = "Overwrite";
storeProps.Value = true;
xStorable.storeAsURL(oStoreURL,[storeProps]);
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof WrappedTargetException) {
} else if (e instanceof UnknownPropertyException)
{
} else {
}
}
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
importClass(Packages.com.sun.star.beans.PropertyValue);
importClass(Packages.com.sun.star.comp.helper.Bootstrap);
importClass(Packages.com.sun.star.comp.helper.BootstrapException);
importClass(Packages.com.sun.star.frame.XComponentLoader);
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.beans.UnknownPropertyException);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.lang.WrappedTargetException);
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
importClass(Packages.com.sun.star.frame.XStorable);
importClass(Packages.com.sun.star.io.IOException);
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
// xContext = Bootstrap.bootstrap(); //<= OOo3.1.1以前は動作した。
xMultiComponentFactory = xContext.getServiceManager();
xtest = xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
xcomponentloader = UnoRuntime.queryInterface(XComponentLoader,xtest);
//
oStoreURL = "file:///C:/temp/oBaseMacro3.odb";
propertyvalue = new Array();
oDoc = xcomponentloader.loadComponentFromURL(oStoreURL, "_blank", 0, propertyvalue);
//
xOfficeDatabaseDocument = UnoRuntime.queryInterface(XOfficeDatabaseDocument, oDoc);
xDataSource = xOfficeDatabaseDocument.getDataSource();
xPropertySet = UnoRuntime.queryInterface(XPropertySet, xDataSource);
xPropertySet.setPropertyValue("URL", "sdbc:embedded:hsqldb");
//
xStorable = UnoRuntime.queryInterface(XStorable,oDoc);
storeProps = new PropertyValue();
storeProps.Name = "Overwrite";
storeProps.Value = true;
xStorable.storeAsURL(oStoreURL,[storeProps]);
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof WrappedTargetException) {
} else if (e instanceof UnknownPropertyException)
{
} else {
}
}
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
importClass(Packages.com.sun.star.beans.PropertyValue);
importClass(Packages.com.sun.star.comp.helper.Bootstrap);
importClass(Packages.com.sun.star.comp.helper.BootstrapException);
importClass(Packages.com.sun.star.frame.XComponentLoader);
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.beans.UnknownPropertyException);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.lang.WrappedTargetException);
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
importClass(Packages.com.sun.star.frame.XStorable);
importClass(Packages.com.sun.star.io.IOException);
//
importClass(Packages.com.sun.star.lang.XComponent);
//importClass(Packages.com.sun.star.sdbc.XCloseable);
importClass(Packages.com.sun.star.uno.RuntimeException);
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
// xContext = Bootstrap.bootstrap(); //<= OOo3.1.1以前は動作した。
xMultiComponentFactory = xContext.getServiceManager();
xtest = xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
xcomponentloader = UnoRuntime.queryInterface(XComponentLoader,xtest);
//
oStoreURL = "file:///C:/temp/oBaseMacro3.odb";
propertyvalue = new Array();
oDoc = xcomponentloader.loadComponentFromURL(oStoreURL, "_blank", 0, propertyvalue);
//
xOfficeDatabaseDocument = UnoRuntime.queryInterface(XOfficeDatabaseDocument, oDoc);
xDataSource = xOfficeDatabaseDocument.getDataSource();
xPropertySet = UnoRuntime.queryInterface(XPropertySet, xDataSource);
xPropertySet.setPropertyValue("URL", "sdbc:embedded:hsqldb");
//
xStorable = UnoRuntime.queryInterface(XStorable,oDoc);
storeProps = new PropertyValue();
storeProps.Name = "Overwrite";
storeProps.Value = true;
xStorable.storeAsURL(oStoreURL,[storeProps]);
//
// xCloseCon = UnoRuntime.queryInterface(XCloseable,oDoc); // <= closeを入れると不可
// xCloseCon.close(); // <= closeを入れると不可
xDispose = UnoRuntime.queryInterface(XComponent,oDoc);
xDispose.dispose();
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof WrappedTargetException) {
} else if (e instanceof UnknownPropertyException)
{
} else {
}
}
DataSource
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
//
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
importClass(Packages.com.sun.star.container.NoSuchElementException);
importClass(Packages.com.sun.star.container.XNameAccess);
importClass(Packages.com.sun.star.uno.XInterface);
importClass(Packages.com.sun.star.sdbc.XConnection);
//
importClass(Packages.com.sun.star.lang.XComponent);
importClass(Packages.com.sun.star.sdbc.XCloseable);
importClass(Packages.com.sun.star.uno.RuntimeException);
//
//importClass(Packages.com.sun.star.sdbc.SQLException);
//importClass(Packages.com.sun.star.sdbc.XStatement);
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
xMultiComponentFactory = xContext.getServiceManager();
//
oBaseURL = "file:///C:/temp/oBaseMacroTest.odb"; // <= Current Base Fileは不可
//
xBaseContext = xMultiComponentFactory.createInstanceWithContext("com.sun.star.sdb.DatabaseContext", xContext);
xBaseAccess = UnoRuntime.queryInterface(XNameAccess, xBaseContext);
xBaseInface = UnoRuntime.queryInterface(XInterface, xBaseAccess.getByName(oBaseURL));
xDataSource = UnoRuntime.queryInterface(XDataSource, xBaseInface);
xCon = xDataSource.getConnection("", "");
//
xCloseCon = UnoRuntime.queryInterface(XCloseable, xCon);
xCloseCon.close();
xDispose = UnoRuntime.queryInterface(XComponent, xCon);
xDispose.dispose();
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof RuntimeException) {
// dispose
} else {
}
}
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
//
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
importClass(Packages.com.sun.star.container.NoSuchElementException);
importClass(Packages.com.sun.star.container.XNameAccess);
importClass(Packages.com.sun.star.uno.XInterface);
importClass(Packages.com.sun.star.sdbc.XConnection);
//
importClass(Packages.com.sun.star.lang.XComponent);
importClass(Packages.com.sun.star.sdbc.XCloseable);
importClass(Packages.com.sun.star.uno.RuntimeException);
//
//importClass(Packages.com.sun.star.sdbc.SQLException);
//importClass(Packages.com.sun.star.sdbc.XStatement);
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
xMultiComponentFactory = xContext.getServiceManager();
//
// oBaseURL = "file:///C:/temp/oBaseMacroTest.odb"; // <= Current Base Fileは不可
oBaseURL = "file:///C:/temp/oBaseMacro3.odb"; // <= Other Base File
//
xBaseContext = xMultiComponentFactory.createInstanceWithContext("com.sun.star.sdb.DatabaseContext", xContext);
xBaseAccess = UnoRuntime.queryInterface(XNameAccess, xBaseContext);
xBaseInface = UnoRuntime.queryInterface(XInterface, xBaseAccess.getByName(oBaseURL));
xDataSource = UnoRuntime.queryInterface(XDataSource, xBaseInface);
xCon = xDataSource.getConnection("", "");
//
xCloseCon = UnoRuntime.queryInterface(XCloseable, xCon);
xCloseCon.close();
xDispose = UnoRuntime.queryInterface(XComponent, xCon);
xDispose.dispose();
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof RuntimeException) {
// dispose
} else {
}
}
Table
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
//
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
importClass(Packages.com.sun.star.container.NoSuchElementException);
importClass(Packages.com.sun.star.container.XNameAccess);
importClass(Packages.com.sun.star.uno.XInterface);
importClass(Packages.com.sun.star.sdbc.XConnection);
//
importClass(Packages.com.sun.star.lang.XComponent);
importClass(Packages.com.sun.star.sdbc.XCloseable);
importClass(Packages.com.sun.star.uno.RuntimeException);
//
importClass(Packages.com.sun.star.sdbcx.XTablesSupplier);
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
xMultiComponentFactory = xContext.getServiceManager();
//
oBaseURL = "file:///C:/temp/oBaseMacroTest.odb"; // <= Current Base Fileは不可
//DataSourceと接続
xBaseContext = xMultiComponentFactory.createInstanceWithContext("com.sun.star.sdb.DatabaseContext", xContext);
xBaseAccess = UnoRuntime.queryInterface(XNameAccess, xBaseContext);
xBaseInface = UnoRuntime.queryInterface(XInterface, xBaseAccess.getByName(oBaseURL));
xDataSource = UnoRuntime.queryInterface(XDataSource, xBaseInface);
xCon = xDataSource.getConnection("", "");
//同名のTbaleが既にあるか?
xTableName = "TEST"
xTablesInface = UnoRuntime.queryInterface(XTablesSupplier, xCon);
xBaseTables = xTablesInface.getTables();
xTableExist = xBaseTables.hasByName(xTableName);
xDisp = xTableName + " Tableの存在有無Check結果 => " + xTableExist
JOptionPane.showMessageDialog(null, xDisp);
//DataSourceとの切断
xCloseCon = UnoRuntime.queryInterface(XCloseable, xCon);
xCloseCon.close();
xDispose = UnoRuntime.queryInterface(XComponent, xCon);
xDispose.dispose();
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof RuntimeException) {
// dispose
} else {
}
}
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
//
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
importClass(Packages.com.sun.star.container.NoSuchElementException);
importClass(Packages.com.sun.star.container.XNameAccess);
importClass(Packages.com.sun.star.uno.XInterface);
importClass(Packages.com.sun.star.sdbc.XConnection);
//
importClass(Packages.com.sun.star.lang.XComponent);
importClass(Packages.com.sun.star.sdbc.XCloseable);
importClass(Packages.com.sun.star.uno.RuntimeException);
//
importClass(Packages.com.sun.star.sdbcx.XTablesSupplier);
//
function oExistTb(oCon,TbName){
xTablesInface = UnoRuntime.queryInterface(XTablesSupplier, xCon);
xBaseTables = xTablesInface.getTables();
xTableExist = xBaseTables.hasByName(TbName);
return xTableExist
};
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
xMultiComponentFactory = xContext.getServiceManager();
//
oBaseURL = "file:///C:/temp/oBaseMacro3.odb"; // <= Current Base Fileは不可
//DataSourceと接続
xBaseContext = xMultiComponentFactory.createInstanceWithContext("com.sun.star.sdb.DatabaseContext", xContext);
xBaseAccess = UnoRuntime.queryInterface(XNameAccess, xBaseContext);
xBaseInface = UnoRuntime.queryInterface(XInterface, xBaseAccess.getByName(oBaseURL));
xDataSource = UnoRuntime.queryInterface(XDataSource, xBaseInface);
xCon = xDataSource.getConnection("", "");
//同名のTbaleが既にあるか?
xTableName = "TEST"
xTableExist = oExistTb(xCon,xTableName);
xDisp = xTableName + " Tableの存在有無Check結果 => " + xTableExist;
JOptionPane.showMessageDialog(null, xDisp);
//DataSourceとの切断
xCloseCon = UnoRuntime.queryInterface(XCloseable, xCon);
xCloseCon.close();
xDispose = UnoRuntime.queryInterface(XComponent, xCon);
xDispose.dispose();
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof RuntimeException) {
// dispose
} else {
}
}
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
importClass(Packages.com.sun.star.beans.PropertyValue);
importClass(Packages.com.sun.star.comp.helper.Bootstrap);
importClass(Packages.com.sun.star.comp.helper.BootstrapException);
importClass(Packages.com.sun.star.frame.XComponentLoader);
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.beans.UnknownPropertyException);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.lang.WrappedTargetException);
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
importClass(Packages.com.sun.star.frame.XStorable);
importClass(Packages.com.sun.star.io.IOException);
//
importClass(Packages.com.sun.star.lang.XComponent);
//importClass(Packages.com.sun.star.sdbc.XCloseable);
importClass(Packages.com.sun.star.uno.RuntimeException);
//
importClass(Packages.com.sun.star.container.NoSuchElementException);
importClass(Packages.com.sun.star.container.XNameAccess);
importClass(Packages.com.sun.star.uno.XInterface);
importClass(Packages.com.sun.star.sdbc.XConnection);
//
importClass(Packages.com.sun.star.sdbcx.XTablesSupplier);
//
function oExistTb(oCon,TbName){
xTablesInface = UnoRuntime.queryInterface(XTablesSupplier, xCon);
xBaseTables = xTablesInface.getTables();
xTableExist = xBaseTables.hasByName(TbName);
return xTableExist
};
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
// xContext = Bootstrap.bootstrap(); //<= OOo3.1.1以前は動作した。
xMultiComponentFactory = xContext.getServiceManager();
xtest = xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
xcomponentloader = UnoRuntime.queryInterface(XComponentLoader,xtest);
//
oBaseURL = "file:///C:/temp/oBaseMacro3.odb";
propertyvalue = new Array();
oDoc = xcomponentloader.loadComponentFromURL(oBaseURL, "_blank", 0, propertyvalue);
//Datasorceとの接続
xBaseContext = xMultiComponentFactory.createInstanceWithContext("com.sun.star.sdb.DatabaseContext", xContext);
xBaseAccess = UnoRuntime.queryInterface(XNameAccess, xBaseContext);
xBaseInface = UnoRuntime.queryInterface(XInterface, xBaseAccess.getByName(oBaseURL));
xDataSource = UnoRuntime.queryInterface(XDataSource, xBaseInface);
xCon = xDataSource.getConnection("", "");
//同名のTbaleが既にあるか?
xTableName = "TEST"
xTableExist = oExistTb(xCon,xTableName);
xDisp = xTableName + " Tableの存在有無Check結果 => " + xTableExist;
JOptionPane.showMessageDialog(null, xDisp);
//HSQLの設定
xOfficeDatabaseDocument = UnoRuntime.queryInterface(XOfficeDatabaseDocument, oDoc);
xDataSource = xOfficeDatabaseDocument.getDataSource();
xPropertySet = UnoRuntime.queryInterface(XPropertySet, xDataSource);
xPropertySet.setPropertyValue("URL", "sdbc:embedded:hsqldb");
//保存
xStorable = UnoRuntime.queryInterface(XStorable,oDoc);
storeProps = new PropertyValue();
storeProps.Name = "Overwrite";
storeProps.Value = true;
xStorable.storeAsURL(oBaseURL,[storeProps]);
//DataSourceとの切断
xCloseCon = UnoRuntime.queryInterface(XCloseable, xCon);
xCloseCon.close();
xDispose = UnoRuntime.queryInterface(XComponent, xCon);
xDispose.dispose();
//Fileの終了
xDispose = UnoRuntime.queryInterface(XComponent,oDoc);
xDispose.dispose();
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof WrappedTargetException) {
xDispose = UnoRuntime.queryInterface(XComponent,oDoc);
xDispose.dispose();
} else if (e instanceof UnknownPropertyException){
xDispose = UnoRuntime.queryInterface(XComponent,oDoc);
xDispose.dispose();
} else {
}
}
SQL(HSQLDB)
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
//
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
importClass(Packages.com.sun.star.container.NoSuchElementException);
importClass(Packages.com.sun.star.container.XNameAccess);
importClass(Packages.com.sun.star.uno.XInterface);
importClass(Packages.com.sun.star.sdbc.XConnection);
//
importClass(Packages.com.sun.star.lang.XComponent);
importClass(Packages.com.sun.star.sdbc.XCloseable);
importClass(Packages.com.sun.star.uno.RuntimeException);
//
importClass(Packages.com.sun.star.sdbc.SQLException);
importClass(Packages.com.sun.star.sdbc.XStatement);
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
xMultiComponentFactory = xContext.getServiceManager();
//
oBaseURL = "file:///C:/temp/oBaseMacroTest.odb"; // <= Current Base Fileは不可
//
xBaseContext = xMultiComponentFactory.createInstanceWithContext("com.sun.star.sdb.DatabaseContext", xContext);
xBaseAccess = UnoRuntime.queryInterface(XNameAccess, xBaseContext);
xBaseInface = UnoRuntime.queryInterface(XInterface, xBaseAccess.getByName(oBaseURL));
xDataSource = UnoRuntime.queryInterface(XDataSource, xBaseInface);
xCon = xDataSource.getConnection("", "");
//
xConInface = UnoRuntime.queryInterface(XConnection, xCon);
xStatement = xConInface.createStatement();
oSQL = "CREATE TABLE TEST(ID INTEGER IDENTITY,Anrede varchar(5),Titel varchar(10),Name varchar(30), PRIMARY KEY (ID))"
xStatement.execute(oSQL)
//
xCloseCon = UnoRuntime.queryInterface(XCloseable, xCon);
xCloseCon.close();
xDispose = UnoRuntime.queryInterface(XComponent, xCon);
xDispose.dispose();
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof RuntimeException) {
// dispose
} else if (e instanceof SQLException) {
// createStatement, execute, close
} else {
}
}
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
//
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
importClass(Packages.com.sun.star.container.NoSuchElementException);
importClass(Packages.com.sun.star.container.XNameAccess);
importClass(Packages.com.sun.star.uno.XInterface);
importClass(Packages.com.sun.star.sdbc.XConnection);
//
importClass(Packages.com.sun.star.lang.XComponent);
importClass(Packages.com.sun.star.sdbc.XCloseable);
importClass(Packages.com.sun.star.uno.RuntimeException);
//
importClass(Packages.com.sun.star.sdbc.SQLException);
importClass(Packages.com.sun.star.sdbc.XStatement);
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
xMultiComponentFactory = xContext.getServiceManager();
//
oBaseURL = "file:///C:/temp/oBaseMacro3.odb"; // <= Other Base File
// oBaseURL = "file:///C:/temp/oBaseMacroTest.odb"; // <= Current Base File
xBaseContext = xMultiComponentFactory.createInstanceWithContext("com.sun.star.sdb.DatabaseContext", xContext);
xBaseAccess = UnoRuntime.queryInterface(XNameAccess, xBaseContext);
xBaseInface = UnoRuntime.queryInterface(XInterface, xBaseAccess.getByName(oBaseURL));
xDataSource = UnoRuntime.queryInterface(XDataSource, xBaseInface);
xCon = xDataSource.getConnection("", "");
//
xConInface = UnoRuntime.queryInterface(XConnection, xCon);
xStatement = xConInface.createStatement();
oSQL = "CREATE TABLE TEST(ID INTEGER IDENTITY,Anrede varchar(5),Titel varchar(10),Name varchar(30), PRIMARY KEY (ID))"
xStatement.execute(oSQL)
//
xCloseCon = UnoRuntime.queryInterface(XCloseable, xCon);
xCloseCon.close();
xDispose = UnoRuntime.queryInterface(XComponent, xCon);
xDispose.dispose();
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof RuntimeException) {
// dispose
} else if (e instanceof SQLException) {
// createStatement, execute, close
} else {
}
}
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
//
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
importClass(Packages.com.sun.star.container.NoSuchElementException);
importClass(Packages.com.sun.star.container.XNameAccess);
importClass(Packages.com.sun.star.uno.XInterface);
importClass(Packages.com.sun.star.sdbc.XConnection);
//
importClass(Packages.com.sun.star.lang.XComponent);
importClass(Packages.com.sun.star.sdbc.XCloseable);
importClass(Packages.com.sun.star.uno.RuntimeException);
//
importClass(Packages.com.sun.star.sdbc.SQLException);
importClass(Packages.com.sun.star.sdbc.XStatement);
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
xMultiComponentFactory = xContext.getServiceManager();
//
oBaseURL = "file:///C:/temp/oBaseMacro3.odb"; // <= Other Base File
// oBaseURL = "file:///C:/temp/oBaseMacroTest.odb"; // <= Current Base File
xBaseContext = xMultiComponentFactory.createInstanceWithContext("com.sun.star.sdb.DatabaseContext", xContext);
xBaseAccess = UnoRuntime.queryInterface(XNameAccess, xBaseContext);
xBaseInface = UnoRuntime.queryInterface(XInterface, xBaseAccess.getByName(oBaseURL));
xDataSource = UnoRuntime.queryInterface(XDataSource, xBaseInface);
xCon = xDataSource.getConnection("", "");
//
xConInface = UnoRuntime.queryInterface(XConnection, xCon);
xStatement = xConInface.createStatement();
xTableName = "TEST"
// 同名Tableがあれば削除
oSQL1 = "DROP TABLE " + xTableName + " IF EXISTS;"
xStatement.execute(oSQL1)
// Table作成
oSQL2 = "CREATE TABLE " + xTableName + "(ID INTEGER IDENTITY,Anrede varchar(5),Titel varchar(10),Name varchar(30), PRIMARY KEY (ID))"
xStatement.execute(oSQL2)
//
xCloseCon = UnoRuntime.queryInterface(XCloseable, xCon);
xCloseCon.close();
xDispose = UnoRuntime.queryInterface(XComponent, xCon);
xDispose.dispose();
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof RuntimeException) {
// dispose
} else if (e instanceof SQLException) {
// createStatement, execute, close
} else {
}
}
// Base in JavaScript
importClass(Packages.javax.swing.JOptionPane);
importClass(Packages.com.sun.star.beans.PropertyValue);
importClass(Packages.com.sun.star.comp.helper.Bootstrap);
importClass(Packages.com.sun.star.comp.helper.BootstrapException);
importClass(Packages.com.sun.star.frame.XComponentLoader);
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
//
importClass(Packages.com.sun.star.beans.UnknownPropertyException);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.lang.WrappedTargetException);
importClass(Packages.com.sun.star.sdb.XOfficeDatabaseDocument);
importClass(Packages.com.sun.star.sdbc.XDataSource);
//
importClass(Packages.com.sun.star.frame.XStorable);
importClass(Packages.com.sun.star.io.IOException);
//
importClass(Packages.com.sun.star.lang.XComponent);
//importClass(Packages.com.sun.star.sdbc.XCloseable);
importClass(Packages.com.sun.star.uno.RuntimeException);
//
importClass(Packages.com.sun.star.container.NoSuchElementException);
importClass(Packages.com.sun.star.container.XNameAccess);
importClass(Packages.com.sun.star.uno.XInterface);
importClass(Packages.com.sun.star.sdbc.XConnection);
//
importClass(Packages.com.sun.star.sdbcx.XTablesSupplier);
//
function oExistTb(oCon,TbName){
xTablesInface = UnoRuntime.queryInterface(XTablesSupplier, xCon);
xBaseTables = xTablesInface.getTables();
xTableExist = xBaseTables.hasByName(TbName);
return xTableExist
};
//
try{
xContext = XSCRIPTCONTEXT.getComponentContext();
// xContext = Bootstrap.bootstrap(); //<= OOo3.1.1以前は動作した。
xMultiComponentFactory = xContext.getServiceManager();
xtest = xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
xcomponentloader = UnoRuntime.queryInterface(XComponentLoader,xtest);
//
oBaseURL = "file:///C:/temp/oBaseMacro3.odb";
propertyvalue = new Array();
oDoc = xcomponentloader.loadComponentFromURL(oBaseURL, "_default", 0, propertyvalue);
//Datasorceとの接続
xBaseContext = xMultiComponentFactory.createInstanceWithContext("com.sun.star.sdb.DatabaseContext", xContext);
xBaseAccess = UnoRuntime.queryInterface(XNameAccess, xBaseContext);
xBaseInface = UnoRuntime.queryInterface(XInterface, xBaseAccess.getByName(oBaseURL));
xDataSource = UnoRuntime.queryInterface(XDataSource, xBaseInface);
xCon = xDataSource.getConnection("", "");
//同名のTbaleが既にあるか?
xTableName = "TEST"
xTableExist = oExistTb(xCon,xTableName);
if(xTableExist != true){
xConInface = UnoRuntime.queryInterface(XConnection, xCon);
xStatement = xConInface.createStatement();
oSQL = "CREATE TABLE " + xTableName + "(ID INTEGER IDENTITY,Anrede varchar(5),Titel varchar(10),Name varchar(30), PRIMARY KEY (ID))"
xStatement.execute(oSQL)
}
else{
JOptionPane.showMessageDialog(null, "同名Tableが存在します。");
}
//HSQLの設定 // <= Crashする時がある
xOfficeDatabaseDocument = UnoRuntime.queryInterface(XOfficeDatabaseDocument, oDoc);
xDataSource = xOfficeDatabaseDocument.getDataSource();
xPropertySet = UnoRuntime.queryInterface(XPropertySet, xDataSource);
xPropertySet.setPropertyValue("URL", "sdbc:embedded:hsqldb");
//保存 // <= Crashする時がある
xStorable = UnoRuntime.queryInterface(XStorable,oDoc);
storeProps = new PropertyValue();
storeProps.Name = "Overwrite";
storeProps.Value = true;
xStorable.storeAsURL(oBaseURL,[storeProps]);
//DataSourceとの切断
xCloseCon = UnoRuntime.queryInterface(XCloseable, xCon);
xCloseCon.close();
xDispose = UnoRuntime.queryInterface(XComponent, xCon);
xDispose.dispose();
//Fileの終了
xDispose = UnoRuntime.queryInterface(XComponent,oDoc);
xDispose.dispose();
//
JOptionPane.showMessageDialog(null, "Success");
}catch (e){
if (e instanceof WrappedTargetException) {
//
} else if (e instanceof UnknownPropertyException){
//
} else {
}
}
file操作
//Open new Writer file
importClass(Packages.com.sun.star.beans.PropertyValue);
importClass(Packages.com.sun.star.comp.helper.Bootstrap);
importClass(Packages.com.sun.star.comp.helper.BootstrapException);
importClass(Packages.com.sun.star.frame.XComponentLoader);
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
xContext = XSCRIPTCONTEXT.getComponentContext();
// xContext = Bootstrap.bootstrap(); //<= OOo3.1.1以前は動作した。
xMultiComponentFactory = xContext.getServiceManager();
xtest = xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
xcomponentloader = UnoRuntime.queryInterface(XComponentLoader,xtest);
loadURL = "private:factory/swriter";
propertyvalue = new Array();
xcomponentloader.loadComponentFromURL(loadURL, "_blank", 0, propertyvalue);
文書入力
// Hello World in JavaScript
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.text.XTextDocument);
importClass(Packages.com.sun.star.text.XTextRange);
// DocumentへのAccessを可能にする
oDoc = XSCRIPTCONTEXT.getDocument();
xTextDoc = UnoRuntime.queryInterface(XTextDocument,oDoc);
xText = xTextDoc.getText();
//選択範囲があればその範囲を取得
xTextRange = xText.getEnd();
xTextRange.setString( "Hello World in JavaScript" );
Style
// [ Writer Style ] Color of Chractors
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.text.XTextDocument);
importClass(Packages.com.sun.star.text.XTextRange);
//
importClass(Packages.com.sun.star.container.XIndexAccess);
importClass(Packages.com.sun.star.beans.XPropertySet);
//
importClass(java.awt.Color);
//
oDoc = XSCRIPTCONTEXT.getDocument();
xTextDoc = UnoRuntime.queryInterface(XTextDocument,oDoc);
xText = xTextDoc.getText();
// Goto Start Position.
xTextRange = xText.getStart();
// Color [ Red ]
oColor = Color(1,0,0); // Red
oRGB = oColor.getRGB();
oChrProperties1 =UnoRuntime.queryInterface(XPropertySet, xTextRange);
oChrProperties1.setPropertyValue("CharColor", new java.lang.Integer(oRGB))
// Insert String
xTextRange.setString( "Color is red. " );
// goto End Position
xTextRange = xText.getEnd();
// Color [ Blue ]
oColor = Color(0,0,1); // Blue
oRGB = oColor.getRGB();
oChrProperties1 =UnoRuntime.queryInterface(XPropertySet, xTextRange);
oChrProperties1.setPropertyValue("CharColor", new java.lang.Integer(oRGB))
// Insert String
xTextRange.setString( " Color is Blue." );
// Msgbox
importClass(Packages.javax.swing.JOptionPane);
JOptionPane.showMessageDialog(null, "Success");
// [ Writer Style ] Color of Chractors2
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.text.XTextDocument);
importClass(Packages.com.sun.star.text.XText);
importClass(Packages.com.sun.star.text.XTextCursor);
importClass(Packages.com.sun.star.text.XWordCursor);
importClass(Packages.com.sun.star.frame.XModel);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(java.awt.Color);
//
WordColor = new Array();
WordColor[0] = Color(1,0,0); //red
WordColor[1] = Color(1,165/255,0); //orange
WordColor[2] = Color(1,1,0); //yellow
WordColor[3] = Color(0,1,0); //green
WordColor[4] = Color(0,0,1); //blue
WordColor[5] = Color(75/255,0,130/255); //indigo
WordColor[6] = Color(223/255,130/255,238/255); //violet
n = WordColor.length;
//
oDoc = UnoRuntime.queryInterface(XModel,XSCRIPTCONTEXT.getInvocationContext());
if ( !oDoc )
oDoc = XSCRIPTCONTEXT.getDocument();
//
xTextDoc = UnoRuntime.queryInterface(XTextDocument,oDoc);
xText = xTextDoc.getText();
nCursor = xText.createTextCursor();
wCursor = UnoRuntime.queryInterface(XWordCursor, nCursor);
//
nCursor.gotoStart(false);
//
MoreText = true;
c = 0;
while(MoreText)
{
wCursor.gotoEndOfWord(true);
colorer = UnoRuntime.queryInterface(XPropertySet, nCursor);
w = WordColor[c].getRGB();
colorer.setPropertyValue("CharColor",new java.lang.Integer(w));
c = (c + 1) % n;
MoreText = wCursor.gotoNextWord(false);
}
file操作
//Open new Draw file
importClass(Packages.com.sun.star.beans.PropertyValue);
importClass(Packages.com.sun.star.comp.helper.Bootstrap);
importClass(Packages.com.sun.star.comp.helper.BootstrapException);
importClass(Packages.com.sun.star.frame.XComponentLoader);
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
xContext = XSCRIPTCONTEXT.getComponentContext();
// xContext = Bootstrap.bootstrap(); //<= OOo3.1.1以前は動作した。
xMultiComponentFactory = xContext.getServiceManager();
xtest = xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
xcomponentloader = UnoRuntime.queryInterface(XComponentLoader,xtest);
loadURL = "private:factory/sdraw";
propertyvalue = new Array();
xcomponentloader.loadComponentFromURL(loadURL, "_blank", 0, propertyvalue);
Page操作
//Access the Page
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
//Draw Document Page1へのAccess
loadProps = new Array();
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
drawPage = xDrawPages.getByIndex(0);
xDrawPage =UnoRuntime.queryInterface(XDrawPage, drawPage);
//Insert Page
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
//Draw Document
loadProps = new Array();
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
//Insert Page
for(i=0; i<3; i++)
{
xDrawPages.insertNewByIndex(0);
}
//Remove Page
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
//Draw Document
loadProps = new Array();
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
//Insert Page
xDrawPages.insertNewByIndex(0);
//Remove Page
xRemPage =UnoRuntime.queryInterface(XDrawPage, xDrawPages.getByIndex(0));
xDrawPages.remove(xRemPage)
/Named Slide
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.container.XNamed);
//Draw Document
loadProps = new Array();
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
//Insert Slide
xDrawPages.insertNewByIndex(0);
//Set Name
xPage =UnoRuntime.queryInterface(XDrawPage,xDrawPages.getByIndex(0));
xPageName =UnoRuntime.queryInterface(XNamed, xPage);
xPageName.setName("page one");
//Get Page Name
oPageName = xPageName.getName()
//Confirm Page Name
importClass(Packages.javax.swing.JOptionPane);
JOptionPane.showMessageDialog(null, oPageName);
//Count Slide
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
//Draw Document
loadProps = new Array();
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
//Slide数Count
var oCount=xDrawPages.getCount()
JOptionPane.showMessageDialog(null, oCount + "枚");
図形作図
//Create Shapes
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
loadProps = new Array();
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
drawPage = xDrawPages.getByIndex(0);
xDrawPage =UnoRuntime.queryInterface(XDrawPage, drawPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xDrawComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(3000, 3000));
xDrawPage.add(RxShape);
//Caption
Cp_shape =xDocumentFactory.createInstance("com.sun.star.drawing.CaptionShape");
CpxShape =UnoRuntime.queryInterface(XShape, Cp_shape);
CpxShape.setPosition(new Point(5000, 6000));
CpxShape.setSize(new Size(3000, 3000));
xDrawPage.add(CpxShape);
//EllipseShape
Ep_shape =xDocumentFactory.createInstance("com.sun.star.drawing.EllipseShape");
EpxShape =UnoRuntime.queryInterface(XShape, Ep_shape);
EpxShape.setPosition(new Point(2000, 15500));
EpxShape.setSize(new Size(2000, 2000));
xDrawPage.add(EpxShape);
//Line
Li_shape =xDocumentFactory.createInstance("com.sun.star.drawing.LineShape");
LixShape =UnoRuntime.queryInterface(XShape, Li_shape);
LixShape.setPosition(new Point(10000, 4000));
LixShape.setSize(new Size(2000, 2000));
xDrawPage.add(LixShape);
//Add Text into Shapes
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.text.XText);
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
drawPage = xDrawPages.getByIndex(0);
xDrawPage =UnoRuntime.queryInterface(XDrawPage, drawPage);
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xDrawComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(5000, 3000));
xDrawPage.add(RxShape);
//Add Text
oText_Chr = new Array();
oText_Chr[0] = "Macro in JavaScript";
oText =UnoRuntime.queryInterface(XText, RxShape);
oText.setString(oText_Chr[0]);
Style
[ Color ]
//Background and Line Color for Element.
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
loadProps = new Array();
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
drawPage = xDrawPages.getByIndex(0);
xDrawPage =UnoRuntime.queryInterface(XDrawPage, drawPage);
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xDrawComponent);
shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
xShape =UnoRuntime.queryInterface(XShape, shape);
xShape.setPosition(new Point(3000, 3000));
xShape.setSize(new Size(10000, 10000));
//Color
oChrProperties1 =UnoRuntime.queryInterface(XPropertySet, xShape);
//Background
oChrProperties1.setPropertyValue("FillColor", new java.lang.Integer(16309472));
//Line
oChrProperties1.setPropertyValue("LineColor", new java.lang.Integer(255000000));
xDrawPage.add(xShape);
//Change Text Color for Element.
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.text.XText);
loadProps = new Array();
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
drawPage = xDrawPages.getByIndex(0);
xDrawPage =UnoRuntime.queryInterface(XDrawPage, drawPage);
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xDrawComponent);
shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
xShape =UnoRuntime.queryInterface(XShape, shape);
xShape.setPosition(new Point(3000, 3000));
xShape.setSize(new Size(10000, 10000));
//Color
oChrProperties1 =UnoRuntime.queryInterface(XPropertySet, xShape);
//Background
oChrProperties1.setPropertyValue("FillColor", new java.lang.Integer(16309472));
//Line
oChrProperties1.setPropertyValue("LineColor", new java.lang.Integer(255000000));
xDrawPage.add(xShape);
//Add Text
oText_Chr = new Array();
oText_Chr[0] = "Macro in JavaScript";
oText =UnoRuntime.queryInterface(XText, xShape);
oText.setString(oText_Chr[0]);
//Change Text Color
oChrProperties1.setPropertyValue("CharColor", new java.lang.Integer(255000000)); //To be after setting text.
[ Note ] : If you insert color change code before setting text, it dose not change color
//Hatching
importPackage(java.lang);
importClass(Packages.javax.swing.JOptionPane);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.drawing.FillProperties);
try{
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
drawPage = xDrawPages.getByIndex(0);
xDrawPage =UnoRuntime.queryInterface(XDrawPage, drawPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xDrawComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(3000, 3000));
//Color of Hatch
xShapeProp =UnoRuntime.queryInterface(XMultiServiceFactory, R_shape);
oHatchProp =UnoRuntime.queryInterface(FillProperties, xShapeProp);
oHatchProp.setPropertyValue("FillStyle", "HATCH");
oHatchProp.setPropertyValue("HatchStyle","SINGLE");
oHatchProp.setPropertyValue("Color", new java.lang.Integer(2554848));
oHatchProp.setPropertyValue("Distance", new java.lang.Integer(1000)); // unit : 1/100mm
oHatchProp.setPropertyValue("Angle", new java.lang.Integer(450)); // unit : 1/10 degree
xDrawPage.add(RxShape);
JOptionPane.showMessageDialog(null, "Success");
}catch(e){
//Error処理
errorname = e.name;
errormsg = e.message;
eDisp= errorname + "\n" + errormsg;
JOptionPane.showMessageDialog(null, eDisp);
}
Connector
//Add Connectors
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
loadProps = new Array();
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
drawPage = xDrawPages.getByIndex(0);
xDrawPage =UnoRuntime.queryInterface(XDrawPage, drawPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xDrawComponent);
//Rectangle1
R1_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
R1xShape =UnoRuntime.queryInterface(XShape, R1_shape);
R1xShape.setPosition(new Point(2000, 2000));
R1xShape.setSize(new Size(3000, 3000));
xDrawPage.add(R1xShape);
//Rectangle2
R2_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
R2xShape =UnoRuntime.queryInterface(XShape, R2_shape);
R2xShape.setPosition(new Point(12000, 5000));
R2xShape.setSize(new Size(3000, 3000));
xDrawPage.add(R2xShape);
// Connector
connector = xDocumentFactory.createInstance("com.sun.star.drawing.ConnectorShape");
xConnector =UnoRuntime.queryInterface(XShape, connector);
xDrawPage.add(xConnector);
//Point from start to end
xConnectorProps =UnoRuntime.queryInterface(XPropertySet, connector);
xConnectorProps.setPropertyValue("StartShape", R1xShape);
xConnectorProps.setPropertyValue("EndShape", R2xShape);
//Glue point positions: 0=top 1=right 2=bottom 3=left
xConnectorProps.setPropertyValue("StartGluePointIndex", new java.lang.Integer(1));
xConnectorProps.setPropertyValue("EndGluePointIndex", new java.lang.Integer(3));
//Add Connectors(2)
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
loadProps = new Array();
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
drawPage = xDrawPages.getByIndex(0);
xDrawPage =UnoRuntime.queryInterface(XDrawPage, drawPage);
//kaisou set
orgUnits = new Array(2);//階層数
orgUnits[0] = new Array("Level 0"); // level 0
orgUnits[1] = new Array("Level 1L", "Level 1R"); // level 1
levelCount = new Array(1, 3); //階層数(Array(level0,level1))
//Initial set
xStartShape = null;
//
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xDrawComponent);
//
// Creating and adding RectangleShapes
for(level=0; level <= 1; level++)
{
for(i = levelCount[level] - 1; i > -1; i--)
{
shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
xShape =UnoRuntime.queryInterface(XShape, shape);
xShape.setPosition(new Point(3000+(i*4000), 3000+level*6000));
xShape.setSize(new Size(3000, 2000));
//Element Draw
xDrawPage.add(xShape);
// Memorize the root shape, for connectors
if(level == 0 && i == 0)
{
xStartShape = xShape;
}
//Connectors
// Add connectors for level 1
if(level == 1)
{
connector = xDocumentFactory.createInstance("com.sun.star.drawing.ConnectorShape");
xConnector =UnoRuntime.queryInterface(XShape, connector);
xDrawPage.add(xConnector);
//Point from start to end
xConnectorProps =UnoRuntime.queryInterface(XPropertySet, connector);
xConnectorProps.setPropertyValue("StartShape", xStartShape);
xConnectorProps.setPropertyValue("EndShape", xShape);
//Glue point positions: 0=top 1=right 2=bottom 3=left
xConnectorProps.setPropertyValue("StartGluePointIndex", new java.lang.Integer(2));
xConnectorProps.setPropertyValue("EndGluePointIndex", new java.lang.Integer(0));
}
}
}
その他
//Create Level Element.
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
xDrawComponent = XSCRIPTCONTEXT.getDocument();
xDrawPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xDrawComponent);
xDrawPages = xDrawPagesSupplier.getDrawPages();
drawPage = xDrawPages.getByIndex(0);
xDrawPage =UnoRuntime.queryInterface(XDrawPage, drawPage);
//kaisou set
orgUnits = new Array(2);//階層数
orgUnits[0] = new Array("Level 0"); // level 0
orgUnits[1] = new Array("Level 1L", "Level 1R"); // level 1
levelCount = new Array(1, 2); //階層数(Array(level0,level1))
//
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xDrawComponent);
//
// Creating and adding RectangleShapes
for(level=0; level <= 1; level++)
{
for(i = levelCount[level] - 1; i > -1; i--)
{
shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
xShape =UnoRuntime.queryInterface(XShape, shape);
xShape.setPosition(new Point(3000+(i*4000), 3000+level*6000));
xShape.setSize(new Size(3000, 2000));
//Element Draw
xDrawPage.add(xShape);
}
}
file操作
//Open new Impress file
importClass(Packages.com.sun.star.beans.PropertyValue);
importClass(Packages.com.sun.star.comp.helper.Bootstrap);
importClass(Packages.com.sun.star.comp.helper.BootstrapException);
importClass(Packages.com.sun.star.frame.XComponentLoader);
importClass(Packages.com.sun.star.lang.XMultiComponentFactory);
importClass(Packages.com.sun.star.uno.Exception);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.uno.XComponentContext);
xContext = XSCRIPTCONTEXT.getComponentContext();
// xContext = Bootstrap.bootstrap(); //<= OOo3.1.1以前は動作した。
xMultiComponentFactory = xContext.getServiceManager();
xtest = xMultiComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
xcomponentloader = UnoRuntime.queryInterface(XComponentLoader,xtest);
loadURL = "private:factory/simpress";
propertyvalue = new Array();
xcomponentloader.loadComponentFromURL(loadURL, "_blank", 0, propertyvalue);
Page操作
//Access the Page
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
//Impress Document Page1へのAccess
loadProps = new Array();
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
//Add the Pages
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
//Impress DocumentへのAccess
loadProps = new Array();
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
//Insert Page
for(i=0; i<3; i++)
{
xImpPages.insertNewByIndex(0);
}
//Remove the Page
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage); // Thisline is important.
importClass(Packages.javax.swing.JOptionPane);
//Impress Document Page1へのAccess
loadProps = new Array();
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
//Count Pages
var oCountPage = xImpPages.getCount()
//Remove Page
if( oCountPage <= 1 )
{
JOptionPane.showMessageDialog("Message", "Master Pageは削除できません。(2page以上のFileを選択)");
}else{
xRemPage =UnoRuntime.queryInterface(XDrawPage, xImpPages.getByIndex(0));
xImpPages.remove(xRemPage);
}
//Named the Page
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage); // Thisline is important.
importClass(Packages.com.sun.star.container.XNamed);
importClass(Packages.javax.swing.JOptionPane);
//Impress Document
loadProps = new Array();
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
//Set Name for page 1
xPage =UnoRuntime.queryInterface(XDrawPage,xImpPages.getByIndex(0));
xPageName =UnoRuntime.queryInterface(XNamed, xPage);
xPageName.setName("page one");
//Get Page Name
oPageName = xPageName.getName()
//Confirm Page Name
JOptionPane.showMessageDialog(null, oPageName);
//Count the Pages
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.javax.swing.JOptionPane);
//Impress Document Page1へのAccess
loadProps = new Array();
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
//Count Pages
var oCountPage = xImpPages.getCount()
//Confirm count
JOptionPane.showMessageDialog(null, oCountPage + "枚");
//The way to show the Screen.
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.lang.XServiceInfo);
importClass(Packages.javax.swing.JOptionPane);
//Impress Document Page1へのAccess
loadProps = new Array();
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// page1のPage情報取得
xPageInfo =UnoRuntime.queryInterface( XServiceInfo, xImpressPage );
oPInfo = xPageInfo.getText();
JOptionPane.showMessageDialog(null, xPageInfo);
図形
//Create Shapes
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
//Impress Document Page1へのAccess
loadProps = new Array();
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(3000, 3000));
xImpressPage.add(RxShape);
//Caption
Cp_shape =xDocumentFactory.createInstance("com.sun.star.drawing.CaptionShape");
CpxShape =UnoRuntime.queryInterface(XShape, Cp_shape);
CpxShape.setPosition(new Point(5000, 6000));
CpxShape.setSize(new Size(3000, 3000));
xImpressPage.add(CpxShape);
//EllipseShape
Ep_shape =xDocumentFactory.createInstance("com.sun.star.drawing.EllipseShape");
EpxShape =UnoRuntime.queryInterface(XShape, Ep_shape);
EpxShape.setPosition(new Point(2000, 15500));
EpxShape.setSize(new Size(2000, 2000));
xImpressPage.add(EpxShape);
//Line
Li_shape =xDocumentFactory.createInstance("com.sun.star.drawing.LineShape");
LixShape =UnoRuntime.queryInterface(XShape, Li_shape);
LixShape.setPosition(new Point(10000, 4000));
LixShape.setSize(new Size(2000, 2000));
xImpressPage.add(LixShape);
//Add Text into Shapes
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.text.XText);
//Impress Document Page1へのAccess
loadProps = new Array();
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(6000, 3000));
xImpressPage.add(RxShape);
//Add Text
oText_Chr = new Array();
oText_Chr[0] = "Macro in JavaScript";
oText =UnoRuntime.queryInterface(XText, RxShape);
oText.setString(oText_Chr[0]);
//Add Text into Shapes(No.2)
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.presentation.AnimationEffect);
importClass(Packages.com.sun.star.text.XText);
importClass(Packages.com.sun.star.text.XTextRange);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(8000, 3000));
xImpressPage.add(RxShape);
//Add Text
xText =UnoRuntime.queryInterface(XText, RxShape);
xTextCursor = xText.createTextCursor();
xTextRange =UnoRuntime.queryInterface(XTextRange, xTextCursor);
xTextRange.setString("Macro in JavaScript");
//Add Text into Shapes(No.3)
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.text.XText);
importClass(Packages.com.sun.star.text.ControlCharacter);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(8000, 3000));
xImpressPage.add(RxShape);
//Add Text(No.3)
xText =UnoRuntime.queryInterface(XText, RxShape);
xTextCursor = xText.createTextCursor();
xText.insertControlCharacter(xTextCursor,ControlCharacter.PARAGRAPH_BREAK,false );
xTextCursor.gotoEnd(false);
xText.setString("Macro in JavaScript");
//Move the Element.
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.javax.swing.JOptionPane);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
//Point1
R1xShape =UnoRuntime.queryInterface(XShape, R_shape);
R1xShape.setPosition(new Point(5000, 2000));
R1xShape.setSize(new Size(6000, 3000));
xImpressPage.add(R1xShape);
//Confirm
JOptionPane.showMessageDialog(null, "移動します。");
//Point2
R2xShape =UnoRuntime.queryInterface(XShape, R1xShape);
R2xShape.setPosition(new Point(15000, 5000));
xImpressPage.add(R2xShape);
//Select the Element.
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
//Point1
R1xShape =UnoRuntime.queryInterface(XShape, R_shape);
R1xShape.setPosition(new Point(5000, 2000));
R1xShape.setSize(new Size(6000, 3000));
xImpressPage.add(R1xShape);
//Select Element
oSelShape =UnoRuntime.queryInterface(XShape, R1xShape);
//Set Shape's Name ang Get Shape's Name.
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.container.XNamed);
importClass(Packages.javax.swing.JOptionPane);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(6000, 3000));
//set Name
xShapeName =UnoRuntime.queryInterface(XNamed, RxShape);
xShapeName.setName("Macro1");
//Drawing
xImpressPage.add(RxShape);
//Get Name
oSelShape =UnoRuntime.queryInterface(XShape, RxShape);
oSelName =UnoRuntime.queryInterface(XNamed, oSelShape);
oShapeName = oSelName.getName()
//Confirm Name
JOptionPane.showMessageDialog(null, oShapeName);
//Remove the Shape
importPackage(java.lang);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.container.XNamed);
importClass(Packages.javax.swing.JOptionPane);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(6000, 3000));
//set Name
xShapeName =UnoRuntime.queryInterface(XNamed, RxShape);
xShapeName.setName("Macro1");
//Drawing
xImpressPage.add(RxShape);
//Confirm
JOptionPane.showMessageDialog(null, "Shape名" + xShapeName.getName() + "を削除します");
//Remove
oSelShape =UnoRuntime.queryInterface(XShape, RxShape);
xImpressPage.remove(oSelShape);
Style
[ Color ]
//Background and Line Color for Shape
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(6000, 3000));
//Color
oChrProperties1 =UnoRuntime.queryInterface(XPropertySet, RxShape); //This line is important.
//Background
oChrProperties1.setPropertyValue("FillColor", new java.lang.Integer(16309472));
//Line
oChrProperties1.setPropertyValue("LineColor", new java.lang.Integer(255000000));
xImpressPage.add(RxShape);
//Change Text Color for Element
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.text.XText);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(6000, 3000));
//Color
oChrProperties1 =UnoRuntime.queryInterface(XPropertySet, RxShape);
//Background
oChrProperties1.setPropertyValue("FillColor", new java.lang.Integer(16309472));
//Line
oChrProperties1.setPropertyValue("LineColor", new java.lang.Integer(255000000));
xImpressPage.add(RxShape);
//Add Text
oText_Chr = new Array();
oText_Chr[0] = "Macro in JavaScript";
oText =UnoRuntime.queryInterface(XText, RxShape);
oText.setString(oText_Chr[0]);
//Change Text Color
oChrProperties1.setPropertyValue("CharColor", new java.lang.Integer(255000000)); //To be after setting text.
[ Note ] : If you insert color change code before setting text, it dose not change color
//Change Text Color for SHape(No.2)
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.text.XText);
importClass(Packages.com.sun.star.text.XTextRange);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(8000, 3000));
xImpressPage.add(RxShape);
//Add Text
xText =UnoRuntime.queryInterface(XText, RxShape);
xTextCursor = xText.createTextCursor();
xTextRange =UnoRuntime.queryInterface(XTextRange, xTextCursor);
xTextRange.setString("Macro in JavaScript");
//Change Text Color
xTextCursor.gotoEnd(true);
xChrPropSet =UnoRuntime.queryInterface(XPropertySet, xTextRange);
xChrPropSet.setPropertyValue("CharColor", new java.lang.Integer(0xff0000)); //文字色を赤
Connector
//Connect the Shape
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.javax.swing.JOptionPane);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle1
R1_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
R1xShape =UnoRuntime.queryInterface(XShape, R1_shape);
R1xShape.setPosition(new Point(5000, 2000));
R1xShape.setSize(new Size(3000, 3000));
//Rectangle2
R2_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
R2xShape =UnoRuntime.queryInterface(XShape, R2_shape);
R2xShape.setPosition(new Point(15000, 5000));
R2xShape.setSize(new Size(3000, 3000));
// xImpressPage.add(R2xShape);
//Drawing
xImpressPage.add(R1xShape);
xImpressPage.add(R2xShape);
//Connector
connector = xDocumentFactory.createInstance("com.sun.star.drawing.ConnectorShape");
xConnector =UnoRuntime.queryInterface(XShape, connector);
xImpressPage.add(xConnector);
//Point from start to end
xConnectorProps =UnoRuntime.queryInterface(XPropertySet, connector);
xConnectorProps.setPropertyValue("StartShape", R1xShape);
xConnectorProps.setPropertyValue("EndShape", R2xShape);
//Glue point positions: 0=top 1=right 2=bottom 3=left
xConnectorProps.setPropertyValue("StartGluePointIndex", new java.lang.Integer(1));
xConnectorProps.setPropertyValue("EndGluePointIndex", new java.lang.Integer(3));
//The way to show the Screen.
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.lang.XServiceInfo);
importClass(Packages.com.sun.star.presentation.FadeEffect);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// page1のScreen設定
xPropSet = UnoRuntime.queryInterface(XPropertySet, xImpressPage );
xPropSet.setPropertyValue("Effect", FadeEffect.FADE_FROM_LEFT );
//[ Note ]
・スライドイン(下へ) : FADE_FROM_TOP
・スライドイン(左へ) : FADE_FROM_RIGHT
・スライドイン(右へ) : FADE_FROM_LEFT
・スライドイン(上へ) : FADE_FROM_BOTTOM
//The Speed to show the Screen.
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.lang.XServiceInfo);
importClass(Packages.com.sun.star.presentation.FadeEffect);
importClass(Packages.com.sun.star.presentation.AnimationSpeed);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// page1のScreen設定
xPropSet = UnoRuntime.queryInterface(XPropertySet, xImpressPage );
xPropSet.setPropertyValue("Effect", FadeEffect.FADE_FROM_BOTTOM );
xPropSet.setPropertyValue("Speed", AnimationSpeed.FAST );
//[ Note ]
・早い : AnimationSpeed.FAST
・中程度の速度 : AnimationSpeed.MEDIUM
・遅い : AnimationSpeed.SLOW
//Switch the way of Screen(By mouse click)
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.lang.XServiceInfo);
importClass(Packages.com.sun.star.presentation.FadeEffect);
importClass(Packages.com.sun.star.presentation.AnimationSpeed);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// page1のScreen設定
xPropSet = UnoRuntime.queryInterface(XPropertySet, xImpressPage );
xPropSet.setPropertyValue("Effect", FadeEffect.FADE_FROM_BOTTOM );
xPropSet.setPropertyValue("Speed", AnimationSpeed.FAST );
xPropSet.setPropertyValue("Change", new java.lang.Integer(0));
//Switch the way of Screen(On timer)
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.lang.XServiceInfo);
importClass(Packages.com.sun.star.presentation.FadeEffect);
importClass(Packages.com.sun.star.presentation.AnimationSpeed);
//Impress Document Page1へのAccess
loadProps = new Array();
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// page1のScreen設定
xPropSet = UnoRuntime.queryInterface(XPropertySet, xImpressPage );
xPropSet.setPropertyValue("Effect", FadeEffect.FADE_FROM_BOTTOM );
xPropSet.setPropertyValue("Speed", AnimationSpeed.FAST );
xPropSet.setPropertyValue("Change", new java.lang.Integer(1));
xPropSet.setPropertyValue("Duration", new java.lang.Integer(5)); //unit : sec
//The Speed to show the Screen.
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
//importClass(Packages.com.sun.star.drawing.XShape);
//importClass(Packages.com.sun.star.awt.Point);
//importClass(Packages.com.sun.star.awt.Size);
//importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.lang.XServiceInfo);
importClass(Packages.com.sun.star.presentation.FadeEffect);
importClass(Packages.com.sun.star.presentation.AnimationSpeed);
//importClass(Packages.javax.swing.JOptionPane);
//Impress Document Page1へのAccess
oImpPage = new Array();
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
//Slide数Count
var oCount=xImpPages.getCount()
// pageのScreen設定
for(i=0 ; i<=oCount-1 ; i++)
{
oImpPage[i] = xImpPages.getByIndex(i);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage[i]);
setSlideTransition(xImpressPage, FadeEffect.FADE_FROM_RIGHT, AnimationSpeed.SLOW, 1, 2 );
}
//
// [ Function1 : setSlideTransition ]
function setSlideTransition(xPage, eEffect, eSpeed, nChange, nDuration)
{
xPropSet = UnoRuntime.queryInterface(XPropertySet, xPage );
xPropSet.setPropertyValue("Effect", eEffect );
xPropSet.setPropertyValue("Speed", eSpeed );
xPropSet.setPropertyValue("Change", new java.lang.Integer(nChange));
xPropSet.setPropertyValue("Duration", new java.lang.Integer(nDuration));
}
Annimation
//Animation Shapes
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.presentation.AnimationEffect);
//Impress Document Page1へのAccess
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(3000, 3000));
xImpressPage.add(RxShape);
//Property for Shape
xPropSet =UnoRuntime.queryInterface(XPropertySet, RxShape);
xPropSet.setPropertyValue("Effect",AnimationEffect.WAVYLINE_FROM_TOP);
//[ Note ]
・WAVYLINE_FROM_TOP : 上部から表示
・WAVYLINE_FROM_LEFT : 上部から表示
・WAVYLINE_FROM_RIGHT : 上部から表示
・WAVYLINE_FROM_BOTTOM : 上部から表示
[ Bookmark ]
//The Shape with Bookmark
importPackage(java.lang);
importClass(Packages.com.sun.star.beans.XPropertySet);
importClass(Packages.javax.swing.JOptionPane);
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.drawing.XDrawPagesSupplier);
importClass(Packages.com.sun.star.drawing.XDrawPage);
importClass(Packages.com.sun.star.drawing.XShape);
importClass(Packages.com.sun.star.awt.Point);
importClass(Packages.com.sun.star.awt.Size);
importClass(Packages.com.sun.star.lang.XMultiServiceFactory);
importClass(Packages.com.sun.star.container.XNamed);
importClass(Packages.com.sun.star.presentation.ClickAction);
try{
//Impress DocumentへのAccess
loadProps = new Array();
xImpComponent = XSCRIPTCONTEXT.getDocument();
xImpPagesSupplier =UnoRuntime.queryInterface(XDrawPagesSupplier, xImpComponent);
xImpPages = xImpPagesSupplier.getDrawPages();
//Insert Page
for(i=0; i<2; i++)
{
xImpPages.insertNewByIndex(0);
}
//Page3へのAccess
oImpPage = xImpPages.getByIndex(2);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
// Page Name設定
xPageName =UnoRuntime.queryInterface(XNamed, xImpressPage);
xPageName.setName("page three");
//Page1にAccess
oImpPage = xImpPages.getByIndex(0);
xImpressPage =UnoRuntime.queryInterface(XDrawPage, oImpPage);
//Page1に要素追加
// Get document factory
xDocumentFactory =UnoRuntime.queryInterface(XMultiServiceFactory, xImpComponent);
//Rectangle
R_shape =xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
RxShape =UnoRuntime.queryInterface(XShape, R_shape);
RxShape.setPosition(new Point(5000, 2000));
RxShape.setSize(new Size(5000, 3000));
//Drawing
xImpressPage.add(RxShape);
//要素に"page three" へのBookmark設定
xShapePropSet =UnoRuntime.queryInterface(XPropertySet, RxShape );
xShapePropSet.setPropertyValue("OnClick", ClickAction.BOOKMARK);
xShapePropSet.setPropertyValue("Bookmark", xPageName.getName());
//Confirm
JOptionPane.showMessageDialog(null, "success");
}catch(e){
//Error処理
errorname = e.name;
errormsg = e.message;
eDisp= errorname + "\n" + errormsg;
JOptionPane.showMessageDialog(null, eDisp);
}