Новичок
Профиль
Группа: Участник
Сообщений: 29
Регистрация: 26.12.2008
Репутация: нет Всего: нет
|
Добрый день, столкнулся очень со странной проблемой и немогу ее решить!!! есть приложение(локально, работает на все 100%), но когда я ее вызываю из другой программы через web службу axis возникает проблема программа выполняется до определенной строчки кода и все зависает, никаких ошибок никаких эксепшинов ничего невозникает просто как будто чегото ждет!!! Создал лог выполнения тоже без результатно, лог выдает такое, что, при выполнение первого метода на первой строчке все вешается. Но при вызове етой программы на своем компьютере все работает как надо, подскажите куда копать, просто уже незнаею где зарыта собака!!! вот кодик если кому интересно | Код | package oooReporter; import com.sun.star.beans.*; import com.sun.star.comp.helper.BootstrapException; import com.sun.star.io.IOException; import com.sun.star.lang.*; import com.sun.star.sheet.TablePageBreakData; import com.sun.star.sheet.XSheetPageBreak; import com.sun.star.style.BreakType; import com.sun.star.style.XStyle; import com.sun.star.text.*; import com.sun.star.uno.Exception; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XInterface; import com.sun.star.util.CloseVetoException; import com.sun.star.util.XCloseable; import com.sun.star.util.XURLTransformer; import com.sun.star.frame.*; import java.lang.Object.*; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter;
import com.sun.star.style.*; import com.sun.star.sheet.XSheetPageBreak.*;
import ooo.connector.BootstrapSocketConnector; public class Document{ public Document(){} static String file; static XMultiComponentFactory xRemoteServiceManager = null; static XComponentContext xRemoteContext = null; static XURLTransformer xTransformer = null; static XComponentLoader xComponentLoader = null; static XDesktop xDesktop = null; static Object oGraphic = null; static XText xText = null; static String ShapeName,ImagePath,SearchWord=null; static String Sname=null; static XComponent xComp=null; static XComponentLoader xCompLoader=null; static XTextDocument xTextDoc=null; static XMultiServiceFactory xMSFDoc=null; static XTextCursor xTextCursor=null; static XWordCursor WordCursor=null; static XSentenceCursor LineCursor=null; static XPageCursor page=null; static XTextViewCursorSupplier xViewCursorSupplier = null; static PrintWriter Log =null; static int i = 0; public static void odtToDoc(String file) throws BootstrapException, Exception { String sUrl = file; XComponentContext xContext = null; xContext = BootstrapSocketConnector.bootstrap("C:/Program Files/OpenOffice.org 3/program"); XMultiComponentFactory xMCF=xContext.getServiceManager(); Object oDesktop = xMCF.createInstanceWithContext( "com.sun.star.frame.Desktop", xContext); xCompLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,oDesktop); PropertyValue propertyValues[] =new PropertyValue[1]; propertyValues[0] = new PropertyValue(); propertyValues[0].Name = "Hidden"; propertyValues[0].Value = new Boolean(true); Object oDocToStore =xCompLoader.loadComponentFromURL(sUrl, "_blank", 0, propertyValues); XStorable xStorable =(XStorable)UnoRuntime.queryInterface( XStorable.class, oDocToStore ); propertyValues = new PropertyValue[2]; propertyValues[0] = new PropertyValue(); propertyValues[0].Name = "Overwrite"; propertyValues[0].Value = new Boolean(true);
propertyValues[1] = new PropertyValue(); propertyValues[1].Name = "FilterName"; propertyValues[1].Value ="MS Word 97";
xStorable.storeAsURL("file:///F:/Work/oooReport_file/"+"oooReport_file.doc", propertyValues); XCloseable xCloseable = (XCloseable)UnoRuntime.queryInterface( XCloseable.class, xStorable);
if ( xCloseable != null ) { xCloseable.close(false); } else { XComponent xComp =(XComponent)UnoRuntime.queryInterface( XComponent.class, xStorable); xComp.dispose(); } } public static void docToOdt(String file) throws BootstrapException, Exception { String sUrl = file; XComponentContext xContext = null; xContext = BootstrapSocketConnector.bootstrap("C:/Program Files/OpenOffice.org 3/program"); XMultiComponentFactory xMCF=xContext.getServiceManager(); Object oDesktop = xMCF.createInstanceWithContext( "com.sun.star.frame.Desktop", xContext); xCompLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,oDesktop); PropertyValue propertyValues[] =new PropertyValue[1]; propertyValues[0] = new PropertyValue(); propertyValues[0].Name = "Hidden"; propertyValues[0].Value = new Boolean(true); Object oDocToStore =xCompLoader.loadComponentFromURL(sUrl, "_blank", 0, propertyValues); XStorable xStorable =(XStorable)UnoRuntime.queryInterface( XStorable.class, oDocToStore ); propertyValues = new PropertyValue[2]; propertyValues[0] = new PropertyValue(); propertyValues[0].Name = "Overwrite"; propertyValues[0].Value = new Boolean(true);
propertyValues[1] = new PropertyValue(); propertyValues[1].Name = "FilterName"; propertyValues[1].Value ="MS Word 97";
xStorable.storeAsURL("file:///c:/2.doc", propertyValues); XCloseable xCloseable = (XCloseable)UnoRuntime.queryInterface( XCloseable.class, xStorable);
if ( xCloseable != null ) { xCloseable.close(false); } else { XComponent xComp =(XComponent)UnoRuntime.queryInterface( XComponent.class, xStorable); xComp.dispose(); } } public void newDocument() throws Exception, java.io.IOException, BootstrapException{ xDesktop = (XDesktop)UnoRuntime.queryInterface(XDesktop.class,xRemoteServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop",xRemoteContext ) ); xCompLoader =(XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, xDesktop); PropertyValue propertyValues[] =new PropertyValue[1];/*для скрытово режима*/ //propertyValues[0] = new PropertyValue(); //propertyValues[0].Name = "Hidden"; //propertyValues[0].Value = new Boolean(true); xComp = xCompLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0,new PropertyValue[0]/*propertyValues*/); xTextDoc =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, xComp); xMSFDoc =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); xText = xTextDoc.getText(); xTextCursor = xText.createTextCursor(); xText = xTextDoc.getText(); xTextCursor = xText.createTextCursor(); LineCursor=(XSentenceCursor)UnoRuntime.queryInterface( XSentenceCursor.class, xTextCursor); WordCursor=(XWordCursor)UnoRuntime.queryInterface( XWordCursor.class, xTextCursor); xTextCursor.gotoStart(false); saveDocument(); } public static XComponent openDocument(String sURL) throws Exception, java.io.IOException{ java.io.File sourceFile = new java.io.File(sURL); StringBuffer sTmp = new StringBuffer("file:///"); sTmp.append(sourceFile.getCanonicalPath().replace('\\', '/')); sURL = sTmp.toString(); xDesktop = (XDesktop)UnoRuntime.queryInterface(XDesktop.class,xRemoteServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop",xRemoteContext ) ); xCompLoader =(XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, xDesktop); PropertyValue propertyValues[] =new PropertyValue[1];/*для скрытово режима*/ propertyValues[0] = new PropertyValue(); propertyValues[0].Name = "Hidden"; propertyValues[0].Value = new Boolean(true); xComp = xCompLoader.loadComponentFromURL(sURL, "_blank",0,propertyValues); xTextDoc =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, xComp); xMSFDoc =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); xText = xTextDoc.getText(); xTextCursor = xText.createTextCursor(); WordCursor=(XWordCursor)UnoRuntime.queryInterface( XWordCursor.class, xTextCursor); LineCursor=(XSentenceCursor)UnoRuntime.queryInterface( XSentenceCursor.class, xTextCursor); int count=0; while(WordCursor.gotoNextWord(false)){ count=count+1; } WordCursor.gotoStart(false); for (int i=0;i<count;i++){ WordCursor.gotoEndOfWord(true); SearchWord=WordCursor.getString(); WordCursor.gotoNextWord(false); if (SearchWord.equals("SHAPE")){ WordCursor.gotoPreviousWord(true); WordCursor.setString(""); LineCursor.gotoEndOfSentence(true); ShapeName=LineCursor.getString(); xTextCursor.setString(""); LineCursor.gotoStartOfSentence(false); LineCursor.gotoNextSentence(false); insertImage(ShapeName); } } return xComp; } public static void insertImageForArray(String n) throws Exception, java.io.IOException{ oGraphic =xMSFDoc.createInstance("com.sun.star.text.TextGraphicObject"); XTextContent xTextContent =(XTextContent)UnoRuntime.queryInterface(XTextContent.class, oGraphic ); xText.insertTextContent(LineCursor, xTextContent, true); XPropertySet xPropSet=(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, oGraphic); ImagePath=comServer(n); File GifFile =new java.io.File(ImagePath); StringBuffer sUrl = new StringBuffer("file:///"); sUrl.append(GifFile.getCanonicalPath().replace('\\', '/')); xPropSet.setPropertyValue( "AnchorType",TextContentAnchorType.AT_PARAGRAPH); xPropSet.setPropertyValue( "GraphicURL", sUrl.toString() ); xPropSet.setPropertyValue( "Width", new Integer(15400)); xPropSet.setPropertyValue( "Height", new Integer(5000)); xViewCursorSupplier = (XTextViewCursorSupplier) UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xTextDoc.getCurrentController()); XPageCursor page = (XPageCursor) UnoRuntime.queryInterface (XPageCursor.class,xViewCursorSupplier.getViewCursor()); XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); xCursorProps.setPropertyValue("BreakType", BreakType.PAGE_AFTER); xText.insertControlCharacter(xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false); page.jumpToNextPage(); } public static void insertImage(String n) throws Exception, java.io.IOException{ oGraphic =xMSFDoc.createInstance("com.sun.star.text.TextGraphicObject"); XTextContent xTextContent =(XTextContent)UnoRuntime.queryInterface(XTextContent.class, oGraphic ); xText.insertTextContent(LineCursor, xTextContent, true); XPropertySet xPropSet=(XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, oGraphic); ImagePath=comServer(n); File GifFile =new java.io.File(ImagePath); StringBuffer sUrl = new StringBuffer("file:///"); sUrl.append(GifFile.getCanonicalPath().replace('\\', '/')); xPropSet.setPropertyValue( "AnchorType",TextContentAnchorType.AT_PARAGRAPH); xPropSet.setPropertyValue( "GraphicURL", sUrl.toString() ); xPropSet.setPropertyValue( "Width", new Integer(15400)); xPropSet.setPropertyValue( "Height", new Integer(5000)); } public static String comServer(String path) throws IOException, java.io.IOException { Com server= new Com(); return path=server.comServer(path); } public static void saveDocument() throws IOException{ PropertyValue[] propertyValue =new PropertyValue[1]; propertyValue[0] = new PropertyValue(); propertyValue[0].Name = "Hidden"; propertyValue[0].Value = new Boolean(true); XStorable xStorable =(XStorable)UnoRuntime.queryInterface(XStorable.class, xComp ); propertyValue = new PropertyValue[2]; propertyValue[0] = new PropertyValue(); propertyValue[0].Name = "Overwrite"; propertyValue[0].Value = new Boolean(true); propertyValue[1] = new PropertyValue(); propertyValue[1].Name = "FilterName"; propertyValue[1].Value = "StarOffice XML (Writer)"; xStorable.storeAsURL("file:///F:/Work/oooReport_file/"+"oooReport_file.odt", propertyValue ); } public static void createLog(String Text_Log) throws FileNotFoundException{ boolean appendToTheEndOfFile = true; Log=new PrintWriter(new OutputStreamWriter (new FileOutputStream("c:/Reporter_Log.log",appendToTheEndOfFile))); Log.println(Text_Log);
} public static void insertLog(String Text_log){ Log.append(Text_log); } public static void closeLog(){ Log.close(); } public void connect() throws BootstrapException, Exception, FileNotFoundException{ createLog("==начало метода=="); closeLog(); xRemoteContext = BootstrapSocketConnector.bootstrap("C:/Program Files/OpenOffice.org 3/program"); createLog("==xRemoteContext-Создан=="); closeLog(); xRemoteServiceManager = xRemoteContext.getServiceManager(); createLog("==xRemoteServiceManager-Создан=="); closeLog(); Object transformer = xRemoteServiceManager.createInstanceWithContext( "com.sun.star.util.URLTransformer", xRemoteContext ); createLog("==transformer-Создан=="); closeLog(); xTransformer = (XURLTransformer)UnoRuntime.queryInterface( XURLTransformer.class, transformer); createLog("==xTransformer-Создан=="); closeLog(); Object desktop = (XInterface) xRemoteServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", xRemoteContext); createLog("==desktop-Создан=="); closeLog(); xDesktop = (XDesktop)UnoRuntime.queryInterface( XDesktop.class, desktop); createLog("==xDesktop-Создан=="); closeLog(); xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface( XComponentLoader.class, desktop); createLog("==xComponentLoader-Создан=="); closeLog(); createLog("==Завершение метода=="); closeLog(); } public static void closeDocument() { //xTextDoc.dispose(); xDesktop.terminate(); } }
|
т.е. я вызываю метод connect() который создает экземпляр openoffica в памяти, НО вот в чем вся странность он его создает(вижу это в процесах), НО в лог ничего незаписывается(только записывается что ЛОГ СОЗДАН), по логике если office загрузился, то и в лог это должно записатся, но этово нет!!! Извеняюсь за такую проблемму, но просто уже незнаю куда копать!!!
|