Interop API를 사용하여 MS Office와 메일 병합을 수행하는 C# 응용 프로그램이 있습니다. 지금 오픈 오피스를 지원하려고합니다. 나는 오픈 오피스 SDK를 사용하려면 : http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/MailMerge.html#CommandOpenOffice SDK를 사용하여 데이터 소스를 만드는 동안 예외가 발생합니다.
지금 나에게 명확한 결정을 보이지 않습니다 .... 어떻게 든 편지 병합 코드가 작동하도록 관리
. 실제로 MailMerge를 수행하기 전에 "데이터 소스"를 만들어야하는데 어려움이 있습니다.
여기 자바에서 샘플을 얻을 수 있습니다 : https://wiki.openoffice.org/wiki/Documentation/DevGuide/Database/The_DataSource_Service
내가 C 번호에이 변환해야합니다.
내 어려움은 자바의 캐스트를 수행하기 위해이 객체를 사용한다는 것입니다 : C#에서 해당 아무것도 없다
XStorable store = (XStorable)UnoRuntime.queryInterface(XStorable.class, xDs);
. 일부 캐스트가 잘 작동
public static void CreateDataSource(string dataSourceProvidedFilePath, string dataSourceSavedFilePath)
{
XComponentContext oStrap = uno.util.Bootstrap.bootstrap();
XMultiServiceFactory _rMSF = (XMultiServiceFactory)oStrap.getServiceManager();
// the XSingleServiceFactory of the database context creates new generic
// com.sun.star.sdb.DataSources (!)
// retrieve the database context at the global service manager and get its
// XSingleServiceFactory interface
XSingleServiceFactory xFac = (XSingleServiceFactory) _rMSF.createInstance("com.sun.star.sdb.DatabaseContext");
//(XSingleServiceFactory)UnoRuntime.queryInterface(XSingleServiceFactory.class, _rMSF.createInstance("com.sun.star.sdb.DatabaseContext"));
// instantiate an empty data source at the XSingleServiceFactory
// interface of the DatabaseContext
Object xDs = xFac.createInstance();
// register it with the database context
XNamingService xServ = (XNamingService)xFac;
//(XNamingService)UnoRuntime.queryInterface(XNamingService.class, xFac);
XStorable store = (XStorable) xDs;
//(XStorable)UnoRuntime.queryInterface(XStorable.class, xDs);
XModel model =(XModel) xDs;
//(XModel)UnoRuntime.queryInterface(XModel.class, xDs);
//on détermine le fichier ou sera sauvegardée la data source
string dataSourcePathURL = Path.Combine(Path.GetDirectoryName(dataSourceProvidedFilePath), dataSourceSavedFilePath + ".odb").ConvertToOpenOfficeURL();
store.storeAsURL(/*"file:///c:/test.odb"*/dataSourcePathURL,model.getArgs());
xServ.registerObject("NewDataSourceName", xDs);
// setting the necessary data source properties
XPropertySet xDsProps = (XPropertySet)xDs;
//(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xDs);
// Adabas D URL
xDsProps.setPropertyValue("URL", new uno.Any("sdbc:adabas::MYDB1"));
// force password dialog
//xDsProps.setPropertyValue("IsPasswordRequired", new Boolean(true));
// suggest dsadmin as user name
xDsProps.setPropertyValue("User", new uno.Any("dsadmin"));
store.store();
}
:
XNamingService xServ = (XNamingService)xFac;
//(XNamingService)UnoRuntime.queryInterface(XNamingService.class, xFac);
그러나 다른 캐스트는 예외가 던져 :
내가 코드 이런 식으로 변환
XStorable 저장 = (XStorable) XDS를; // (XStorable) UnoRuntime.queryInterface (XStorable.class, xDs);
- 제대로 C 번호로 변환이 코드를 가지고 할 수있는 방법이>
Unable to cast transparent proxy to type 'unoidl.com.sun.star.frame.XStorable'.
있습니까?
그렇지 않으면 Java로 Open Office DataSource를 만드는 방법을 보여주는 다른 리소스를 알고 계십니까?
들으