*** empty log message ***
[thera-pi.git] / TheraPiHilfe / src / therapiHilfe / ooPanel.java
blob6857cd81393a8d000d1cb83690c287c762b0053b
1 package therapiHilfe;
6 import java.awt.BorderLayout;
7 import java.awt.Component;
8 import java.awt.Cursor;
9 import java.awt.Dimension;
10 import java.awt.GridLayout;
13 import javax.swing.JComponent;
14 import javax.swing.JLabel;
15 import javax.swing.JPanel;
16 import javax.swing.SwingUtilities;
18 import org.jdesktop.swingx.JXFrame;
19 import org.jdesktop.swingx.JXPanel;
20 import org.jdesktop.swingx.JXTitledPanel;
24 import java.awt.Container;
25 import java.awt.event.ComponentAdapter;
26 import java.awt.event.ComponentEvent;
27 import java.awt.event.WindowEvent;
28 import java.awt.event.WindowListener;
29 import java.io.BufferedReader;
30 import java.io.BufferedWriter;
31 import java.io.ByteArrayInputStream;
32 import java.io.ByteArrayOutputStream;
33 import java.io.File;
34 import java.io.FileInputStream;
35 import java.io.FileNotFoundException;
36 import java.io.FileOutputStream;
37 import java.io.FileReader;
38 import java.io.FileWriter;
39 import java.io.IOException;
40 import java.io.InputStream;
41 import java.io.OutputStream;
42 import java.sql.ResultSet;
43 import java.sql.SQLException;
44 import java.sql.Statement;
45 import java.util.HashMap;
46 import java.util.Vector;
48 import ag.ion.bion.officelayer.NativeView;
49 import ag.ion.bion.officelayer.application.IApplicationAssistant;
50 import ag.ion.bion.officelayer.application.ILazyApplicationInfo;
51 import ag.ion.bion.officelayer.application.IOfficeApplication;
52 import ag.ion.bion.officelayer.application.OfficeApplicationException;
53 import ag.ion.bion.officelayer.application.OfficeApplicationRuntime;
54 import ag.ion.bion.officelayer.desktop.DesktopException;
55 import ag.ion.bion.officelayer.desktop.GlobalCommands;
56 import ag.ion.bion.officelayer.desktop.IFrame;
57 import ag.ion.bion.officelayer.document.DocumentDescriptor;
58 import ag.ion.bion.officelayer.document.DocumentException;
59 import ag.ion.bion.officelayer.document.IDocument;
60 import ag.ion.bion.officelayer.document.IDocumentDescriptor;
61 import ag.ion.bion.officelayer.event.ICloseListener;
62 import ag.ion.bion.officelayer.event.IDocumentEvent;
63 import ag.ion.bion.officelayer.event.IDocumentListener;
64 import ag.ion.bion.officelayer.event.IEvent;
65 import ag.ion.bion.officelayer.filter.HTMLFilter;
66 import ag.ion.bion.officelayer.filter.PDFFilter;
67 import ag.ion.bion.officelayer.internal.application.ApplicationAssistant;
68 import ag.ion.bion.officelayer.text.ITextCursor;
69 import ag.ion.bion.officelayer.text.ITextDocument;
70 import ag.ion.bion.officelayer.web.IWebDocument;
71 import ag.ion.noa.NOAException;
72 import ag.ion.noa.frame.ILayoutManager;
74 import com.sun.star.awt.Key;
75 import com.sun.star.awt.KeyEvent;
76 import com.sun.star.awt.KeyModifier;
77 import com.sun.star.awt.XExtendedToolkit;
78 import com.sun.star.awt.XKeyHandler;
79 import com.sun.star.awt.XToolkit;
80 import com.sun.star.awt.XTopWindow;
81 import com.sun.star.awt.XWindow;
82 import com.sun.star.awt.XWindowPeer;
83 import com.sun.star.beans.UnknownPropertyException;
84 import com.sun.star.beans.XPropertySet;
85 import com.sun.star.container.NoSuchElementException;
86 import com.sun.star.container.XNameAccess;
87 import com.sun.star.container.XNameContainer;
88 import com.sun.star.frame.XController;
89 import com.sun.star.frame.XFrame;
90 import com.sun.star.frame.XFrameActionListener;
91 import com.sun.star.frame.XFramesSupplier;
92 import com.sun.star.lang.EventObject;
93 import com.sun.star.lang.WrappedTargetException;
94 import com.sun.star.lang.XEventListener;
95 import com.sun.star.lang.XMultiServiceFactory;
96 import com.sun.star.lang.XServiceInfo;
97 import com.sun.star.text.XTextContent;
98 import com.sun.star.text.XTextGraphicObjectsSupplier;
99 import com.sun.star.uno.Any;
100 import com.sun.star.uno.Exception;
101 import com.sun.star.uno.UnoRuntime;
102 import com.sun.star.view.DocumentZoomType;
104 public class ooPanel{
106 public ITextDocument doc = null;
107 public IFrame frame = null;
108 public ICloseListener clListener = null;
110 private XExtendedToolkit extendedToolkit = null;
111 private com.sun.star.awt.XTopWindowListener topWindowListener = null;
112 private XFrame xxframe = null;
113 private XTopWindow myTopWindow = null;
114 static ooPanel thisClass;
115 public JXPanel noaPanel = null;
116 private static IFrame officeFrame = null;
117 static ITextDocument document = null;
118 public static ITextDocument textDocument;
119 public static IWebDocument webdocument = null;
120 public static IWebDocument webtextDocument;
121 final static int ANSICHT_WEB = 1;
122 final static int ANSICHT_DOKUMENT = 0;
123 public static int ansicht = 0;
124 DokumentListener doclistener = null;
127 ooPanel(JXPanel jpan){
128 noaPanel = jpan;
129 thisClass = this;
130 fillNOAPanel();
132 try {
133 //configureOOOFrame(piHelp.officeapplication,officeFrame);
134 } catch (Throwable e) {
135 // TODO Auto-generated catch block
136 e.printStackTrace();
142 /*********************************************************/
143 private void fillNOAPanel() {
144 if (noaPanel != null) {
145 try {
146 if (piHelp.officeapplication == null)
147 piHelp.officeapplication = startOOO();
150 officeFrame = constructOOOFrame(piHelp.officeapplication, noaPanel);
151 DocumentDescriptor d = new DocumentDescriptor();
152 d.setTitle("piHelp- leeres Dokument");
153 //d.setURL(piHelp.tempvz+"dummy.html");
154 //d.setAsTemplate(true);
155 //d.setFilterDefinition(HTMLFilter.FILTER.getFilterDefinition(IDocument.WRITER));
158 File f = new File( piHelp.tempvz+"dummy.html" );
159 byte[] buffer = new byte[ (int) f.length() ];
160 InputStream in = new FileInputStream( f );
161 in.read( buffer );
162 in.close();
165 //document = (ITextDocument) piHelp.officeapplication.getDocumentService().loadDocument(officeFrame,in, d);
166 //document = (ITextDocument) piHelp.officeapplication.getDocumentService().loadDocument(helpFenster.readFileToOutputStream(piHelp.tempvz+"dummy.html"), d);
167 document = (ITextDocument) piHelp.officeapplication.getDocumentService().constructNewDocument(officeFrame,IDocument.WRITER,d);
168 ansicht = ANSICHT_DOKUMENT;
169 piHelp.thisClass.jFrame.setExtendedState(JXFrame.MAXIMIZED_BOTH);
170 piHelp.thisClass.jFrame.validate();
172 //textDocument = (ITextDocument)document;
173 if(doclistener == null){
174 doclistener = new DokumentListener(piHelp.officeapplication);
176 piHelp.officeapplication.getDesktopService().addDocumentListener(doclistener);
177 officeFrame.disableDispatch(GlobalCommands.CLOSE_DOCUMENT);
178 officeFrame.disableDispatch(GlobalCommands.QUIT_APPLICATION);
179 officeFrame.disableDispatch(GlobalCommands.CLOSE_WINDOW);
180 officeFrame.updateDispatches();
182 webdocument = (IWebDocument) piHelp.officeapplication.getDocumentService().constructNewDocument(officeFrame,
183 IDocument.WEB,
184 DocumentDescriptor.DEFAULT);
188 noaPanel.setVisible(true);
189 piHelp.thisFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
191 catch (Throwable throwable) {
192 noaPanel.add(new JLabel("Error in creating the NOA panel: " + throwable.getMessage()));
196 /*********************************************************/
197 private IOfficeApplication startOOO() throws Throwable {
198 IApplicationAssistant applicationAssistant = new ApplicationAssistant(piHelp.OfficeNativePfad);
199 //IApplicationAssistant applicationAssistant = new ApplicationAssistant(System.getProperty("user.dir") + "\\lib");
200 ILazyApplicationInfo[] appInfos = applicationAssistant.getLocalApplications();
201 for(int i = 0; i < appInfos.length;i++){
202 //System.out.println(appInfos[i]);
205 if (appInfos.length < 1)
206 throw new Throwable("No OpenOffice.org Application found.");
207 HashMap configuration = new HashMap();
208 configuration.put(IOfficeApplication.APPLICATION_HOME_KEY, appInfos[0].getHome());
209 configuration.put(IOfficeApplication.APPLICATION_TYPE_KEY, IOfficeApplication.LOCAL_APPLICATION);
210 IOfficeApplication officeAplication = OfficeApplicationRuntime.getApplication(configuration);
212 officeAplication.setConfiguration(configuration);
213 officeAplication.activate();
214 return officeAplication;
217 private IFrame constructOOOFrame(IOfficeApplication officeApplication, final Container parent)
218 throws Throwable {
219 final NativeView nativeView = new NativeView(piHelp.OfficeNativePfad);
220 if(nativeView == null){
221 //System.out.println("nativeView == null");
223 if(parent == null){
224 //System.out.println("nativeView == null");
226 parent.add(nativeView);
227 parent.addComponentListener(new ComponentAdapter(){
228 public void componentResized(ComponentEvent e) {
229 nativeView.setPreferredSize(new Dimension(parent.getWidth()-5,parent.getHeight()-5));
230 parent.getLayout().layoutContainer(parent);
233 nativeView.setPreferredSize(new Dimension(parent.getWidth() - 5, parent.getHeight() - 5));
234 parent.getLayout().layoutContainer(parent);
235 IFrame officeFrame = officeApplication.getDesktopService().constructNewOfficeFrame(nativeView);
236 parent.validate();
237 return officeFrame;
239 public static void configureOOOFrame(IOfficeApplication officeApplication, IFrame officeFrame) throws Throwable {
240 ILayoutManager layoutManager = officeFrame.getLayoutManager();
241 layoutManager.hideAll();
242 layoutManager.showElement(ILayoutManager.URL_TOOLBAR_STANDARDBAR);
243 layoutManager.showElement(ILayoutManager.URL_TOOLBAR_TEXTOBJECTBAR);
244 layoutManager.showElement(ILayoutManager.URL_STATUSBAR);
246 officeFrame.disableDispatch(GlobalCommands.CLOSE_DOCUMENT);
247 officeFrame.disableDispatch(GlobalCommands.CLOSE_WINDOW);
248 officeFrame.disableDispatch(GlobalCommands.QUIT_APPLICATION);
249 officeFrame.disableDispatch(GlobalCommands.NEW_MENU);
250 officeFrame.disableDispatch(GlobalCommands.NEW_DOCUMENT);
251 officeFrame.disableDispatch(GlobalCommands.OPEN_DOCUMENT);
252 officeFrame.disableDispatch(GlobalCommands.EDIT_DOCUMENT);
253 officeFrame.disableDispatch(GlobalCommands.DIREKT_EXPORT_DOCUMENT);
254 officeFrame.disableDispatch(GlobalCommands.MAIL_DOCUMENT);
255 officeFrame.disableDispatch(GlobalCommands.OPEN_HYPERLINK_DIALOG);
256 officeFrame.disableDispatch(GlobalCommands.EDIT_HYPERLINK);
257 officeFrame.disableDispatch(GlobalCommands.OPEN_DRAW_TOOLBAR);
258 officeFrame.disableDispatch(GlobalCommands.OPEN_NAVIGATOR);
259 officeFrame.disableDispatch(GlobalCommands.OPEN_GALLERY);
260 officeFrame.disableDispatch(GlobalCommands.OPEN_DATASOURCES);
261 officeFrame.disableDispatch(GlobalCommands.OPEN_STYLE_SHEET);
262 officeFrame.disableDispatch(GlobalCommands.OPEN_HELP);
263 //officeFrame.disableDispatch(GlobalCommands.PRINT_PREVIEW);
266 officeFrame.updateDispatches();
268 //officeFrame.getDispatch(".uno:PrintLayout").dispatch();
271 public static void allesOOZu(){
274 public static void schliesseText(){
275 try {
276 piHelp.officeapplication.getDesktopService().removeDocumentListener(thisClass.doclistener);
277 } catch (OfficeApplicationException e) {
278 // TODO Auto-generated catch block
279 e.printStackTrace();
281 if(ansicht == ANSICHT_WEB){
282 if(webdocument.isOpen()){
283 webdocument.close();
285 thisClass.noaPanel.remove(0);
286 }else{
287 document.close();
288 thisClass.noaPanel.remove(0);
291 public static void neuesNoaPanel(){
292 thisClass.fillNOAPanel();
294 /*********************************************************/
295 public static void starteNeuenText(){
296 try {
297 DocumentDescriptor d = new DocumentDescriptor();
298 document = (ITextDocument) piHelp.officeapplication.getDocumentService().constructNewDocument(officeFrame,IDocument.WRITER,d);
299 ansicht = ANSICHT_DOKUMENT;
300 } catch (NOAException e) {
301 // TODO Auto-generated catch block
302 e.printStackTrace();
303 } catch (OfficeApplicationException e) {
304 // TODO Auto-generated catch block
305 e.printStackTrace();
309 /*********************************************************/
310 public static void erzeugeAusByteArray(byte[] bhtml,String datei,boolean alsweb){
311 InputStream is = new ByteArrayInputStream( bhtml );
312 FileOutputStream fileOut;
313 String indatei = datei;
314 if(! indatei.contains(".html")){
315 indatei = indatei+".html";
317 try {
318 fileOut = new FileOutputStream(indatei);
319 fileOut.write(bhtml);
320 fileOut.flush();
321 fileOut.close();
322 extrahiereBilder(datei);
323 } catch (FileNotFoundException e1) {
324 // TODO Auto-generated catch block
325 e1.printStackTrace();
326 } catch (IOException e) {
327 // TODO Auto-generated catch block
328 e.printStackTrace();
331 /********************************************************/
333 public static void starteDatei(String datei,boolean alsweb){
335 /************
337 * Erst hier das Dokument laden
340 //ITextDocument document;
341 String startdatei = datei;
342 if(! startdatei.contains(".html")){
343 startdatei = datei+".html";
346 try {
348 webdocument = (IWebDocument) piHelp.officeapplication.getDocumentService().constructNewDocument(officeFrame,
349 IDocument.WEB,docdescript);
351 try {
353 if(alsweb){
354 IDocumentDescriptor docdescript = DocumentDescriptor.DEFAULT;
355 docdescript.setURL(datei);
356 docdescript.setFilterDefinition(HTMLFilter.FILTER.getFilterDefinition(IDocument.WEB));
357 webdocument = (IWebDocument) piHelp.officeapplication.getDocumentService().loadDocument(officeFrame, startdatei, docdescript);
358 ansicht = ANSICHT_WEB;
359 }else{
360 IDocumentDescriptor docdescript = DocumentDescriptor.DEFAULT;
361 docdescript.setURL(datei);
362 docdescript.setFilterDefinition(HTMLFilter.FILTER.getFilterDefinition(IDocument.WRITER));
363 //System.out.println("***************Datei = *****************"+startdatei);
364 document = (ITextDocument) piHelp.officeapplication.getDocumentService().loadDocument(officeFrame, startdatei, docdescript);
365 ansicht = ANSICHT_DOKUMENT;
367 } catch (DocumentException e) {
368 // TODO Auto-generated catch block
369 e.printStackTrace();
375 //ITextDocument doc = (ITextDocument) webdocument.getWebDocument();
376 //webdocument.getViewCursorService().getViewCursor().getTextCursorFromStart().insertDocument( is, new HTMLFilter() );
377 //doc.getViewCursorService().getViewCursor().getTextCursorFromStart().insertDocument( is, new HTMLFilter() );
378 //doc.reformat();
380 document = (ITextDocument)piHelp.officeapplication.getDocumentService().constructNewDocument( officeFrame,
381 IDocument.WRITER, DocumentDescriptor.DEFAULT);
382 document.getViewCursorService().getViewCursor().getTextCursorFromStart().insertDocument( is, new HTMLFilter() );
383 textDocument = (ITextDocument) document;
386 } catch (OfficeApplicationException e) {
387 // TODO Auto-generated catch block
388 e.printStackTrace();
394 * @throws Exception *******************************************************/
395 public static String speichernText(String aktdatei,Boolean neu) {
396 FileOutputStream outputStream = null;
397 String datei = null;
398 try {
401 File tempFile;
402 try {
403 tempFile = File.createTempFile("noatemp" + System.currentTimeMillis(), "html");
404 tempFile.deleteOnExit();
405 outputStream = new FileOutputStream(tempFile);
406 } catch (IOException e) {
407 // TODO Auto-generated catch block
408 e.printStackTrace();
413 datei = new String(aktdatei);
414 if(!datei.contains(".html")){
415 datei = datei+".html";
416 }else{
417 //System.out.println("ooPane - speichernText, Dateiname korrekt ->"+datei);
419 //System.out.println("ooPane - exportiere Datei nach ->"+datei);
420 // textDocument.getPersistenceService().export(temppfad+tempname, new HTMLFilter());
421 if(ansicht == ANSICHT_DOKUMENT){
422 //System.out.println(document.getDocumentType());
423 File f = new File(datei);
425 try {
427 ITextDocument textDocument = document;
428 XTextGraphicObjectsSupplier graphicObjSupplier = (XTextGraphicObjectsSupplier) UnoRuntime.queryInterface(XTextGraphicObjectsSupplier.class,
429 textDocument.getXTextDocument());
430 XNameAccess nameAccess = graphicObjSupplier.getGraphicObjects();
431 String[] names = nameAccess.getElementNames();
432 for (int i = 0; i < names.length; i++) {
433 Any xImageAny;
434 xImageAny = (Any) nameAccess.getByName(names[i]);
435 Object xImageObject = xImageAny.getObject();
436 XTextContent xImage = (XTextContent) xImageObject;
437 XServiceInfo xInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, xImage);
438 if (xInfo.supportsService("com.sun.star.text.TextGraphicObject")) {
439 XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
440 xImage);
441 String name = xPropSet.getPropertyValue("LinkDisplayName").toString();
442 String graphicURL = xPropSet.getPropertyValue("GraphicURL").toString();
443 //only ones that are not embedded
444 if (graphicURL.indexOf("vnd.sun.") == -1) {
445 XMultiServiceFactory multiServiceFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class,
446 textDocument.getXTextDocument());
447 XNameContainer xBitmapContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class,
448 multiServiceFactory.createInstance("com.sun.star.drawing.BitmapTable"));
449 if (!xBitmapContainer.hasByName(name)) {
450 xBitmapContainer.insertByName(name, graphicURL);
451 String newGraphicURL = xBitmapContainer.getByName(name).toString();
452 xPropSet.setPropertyValue("GraphicURL", newGraphicURL);
457 } catch (NoSuchElementException e) {
458 e.printStackTrace();
459 } catch (WrappedTargetException e) {
460 e.printStackTrace();
461 } catch (UnknownPropertyException e) {
462 e.printStackTrace();
463 } catch (Exception e) {
464 e.printStackTrace();
469 if(f.exists()){
470 //System.out.println("IDcument - Datei wird nur gespeichert");
471 //document.getPersistenceService().export(datei, new HTMLFilter());
472 document.getPersistenceService().store();
473 Thread.sleep(100);
474 }else{
475 //System.out.println("IDcument - Datei wird exportiert");
476 document.getPersistenceService().export(datei, new HTMLFilter());
477 Thread.sleep(100);
480 //document.getPersistenceService().store(datei);
481 //document.getPersistenceService().export(datei+".html", new HTMLFilter());
482 //document.getPersistenceService().export(datei+"#", new HTMLFilter());
483 }else{
484 File f = new File(datei);
486 try {
488 IWebDocument textDocument = webdocument;
489 XTextGraphicObjectsSupplier graphicObjSupplier = (XTextGraphicObjectsSupplier) UnoRuntime.queryInterface(XTextGraphicObjectsSupplier.class,
490 textDocument.getWebDocument());
491 XNameAccess nameAccess = graphicObjSupplier.getGraphicObjects();
492 String[] names = nameAccess.getElementNames();
493 for (int i = 0; i < names.length; i++) {
494 Any xImageAny;
495 xImageAny = (Any) nameAccess.getByName(names[i]);
496 Object xImageObject = xImageAny.getObject();
497 XTextContent xImage = (XTextContent) xImageObject;
498 XServiceInfo xInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, xImage);
499 if (xInfo.supportsService("com.sun.star.text.TextGraphicObject")) {
500 XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,
501 xImage);
502 String name = xPropSet.getPropertyValue("LinkDisplayName").toString();
503 String graphicURL = xPropSet.getPropertyValue("GraphicURL").toString();
504 //only ones that are not embedded
505 if (graphicURL.indexOf("vnd.sun.") == -1) {
506 XMultiServiceFactory multiServiceFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class,
507 textDocument.getWebDocument());
508 XNameContainer xBitmapContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class,
509 multiServiceFactory.createInstance("com.sun.star.drawing.BitmapTable"));
510 if (!xBitmapContainer.hasByName(name)) {
511 xBitmapContainer.insertByName(name, graphicURL);
512 String newGraphicURL = xBitmapContainer.getByName(name).toString();
513 xPropSet.setPropertyValue("GraphicURL", newGraphicURL);
518 } catch (NoSuchElementException e) {
519 e.printStackTrace();
520 } catch (WrappedTargetException e) {
521 e.printStackTrace();
522 } catch (UnknownPropertyException e) {
523 e.printStackTrace();
524 } catch (Exception e) {
525 e.printStackTrace();
529 if(f.exists()){
530 //System.out.println("IWeb - Datei wird nur gespeichert");
531 webdocument.getPersistenceService().store();
532 Thread.sleep(100);
533 //webdocument.getPersistenceService().export(datei, new HTMLFilter());
534 }else{
535 //System.out.println("IWeb - Datei wird exportiert");
536 webdocument.getPersistenceService().export(datei, new HTMLFilter());
537 Thread.sleep(100);
540 //webdocument.getPersistenceService().export(datei+".html", new HTMLFilter());
541 //webdocument.getPersistenceService().export(datei+".export", new HTMLFilter());
544 } catch (DocumentException e) {
546 e.printStackTrace();
547 } catch (InterruptedException e) {
549 e.printStackTrace();
551 return new String(datei);
554 /***********************************************/
555 public static void extrahiereBilder(String url){
556 //System.out.println("Beginn extrahiereBilder aus "+url);
557 helpFenster.thisClass.bilder.clear();
558 BufferedReader infile = null;
559 BufferedWriter outfile = null;
561 try {
562 infile = new BufferedReader(new FileReader(url));
563 outfile = new BufferedWriter(new FileWriter(url+".html"));
564 String str;
565 while((str=infile.readLine())!=null){
566 if(str.contains("IMG SRC=")){
567 outfile.write( testeString(new String(str),"/")+"\n" );
568 outfile.flush();
569 }else{
570 outfile.write(new String(str)+"\n");
571 outfile.flush();
574 outfile.flush();
575 outfile.close();
576 infile.close();
577 } catch (IOException e) {
578 // TODO Auto-generated catch block
579 e.printStackTrace();
582 /***********************************************/
583 public static String testeString(String webstring,String trenner){
584 int aktuell = 0;
585 int wo = 0;
587 String meinweb = new String(webstring);
588 String ssret = "";
589 int lang = meinweb.length();
591 while( (wo = webstring.indexOf("IMG SRC=\"",aktuell)) > 0){
592 String nurBild = "";
593 boolean start = false;
594 boolean austritt = false;
595 int iende = 0;
596 int istart = 0;
597 for(int i = wo; i < lang; i++){
598 for(int d = 0; d < 1;d++){
599 if( (meinweb.substring(i,i+1).equals("\"")) && (!start)){
600 i++;
601 istart = i;
602 start = true;
603 break;
605 if( (meinweb.substring(i,i+1).equals("\"")) && (start)){
606 start = false;
607 iende = i;
608 austritt = true;
609 break;
612 if(austritt){
613 break;
615 if(start){
616 nurBild = nurBild +meinweb.substring(i,i+1);
619 int ergebnis = nurBild.lastIndexOf(trenner);
620 String sret = "";
621 if(ergebnis > -1){
622 sret = new String(nurBild.substring(ergebnis+1));
623 String salt = meinweb.substring(istart,iende);
624 ssret = new String( meinweb.replaceAll(salt, sret));
625 //sret = new String(nurBild);
626 helpFenster.thisClass.bilder.add(sret.replaceAll("%20"," "));
627 }else{
628 //String salt = meinweb.substring(istart,iende);
629 sret = nurBild;
630 ssret = new String(meinweb);
631 helpFenster.thisClass.bilder.add(nurBild.replaceAll("%20", " "));
633 //System.out.println("Gefunden "+sret);
634 aktuell = new Integer(iende);
637 return ssret;
640 /***********************************************/
642 class testObVorhanden{
643 String svorhanden = null;
644 public boolean init(String svorhanden){
645 boolean ret = true;
646 Statement stmtx = null;
647 ResultSet rsx = null;
648 String[] comboInhalt = null;
649 stmtx = null;
650 rsx = null;
651 //System.out.println("In holeGruppen");
652 try {
653 stmtx = (Statement) piHelp.conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
654 ResultSet.CONCUR_UPDATABLE );
656 } catch (SQLException e) {
657 // TODO Auto-generated catch block
658 e.printStackTrace();
660 try {
661 rsx = stmtx.executeQuery("select count(*) from htitel where titel="+svorhanden);
662 rsx.next();
663 if(rsx.getInt(1) <=0){
664 ret = false;
666 }catch(SQLException e){
667 e.printStackTrace();
669 if (rsx != null) {
670 try {
671 rsx.close();
672 } catch (SQLException sqlEx) { // ignore }
673 rsx = null;
676 if (stmtx != null) {
677 try {
678 stmtx.close();
679 } catch (SQLException sqlEx) { // ignore }
680 stmtx = null;
685 return ret;
689 class DokumentListener implements IDocumentListener {
691 private IOfficeApplication officeAplication = null;
692 public DokumentListener(IOfficeApplication officeAplication) {
693 this.officeAplication = officeAplication;
695 @Override
696 public void onAlphaCharInput(IDocumentEvent arg0) {
697 // TODO Auto-generated method stub
700 @Override
701 public void onFocus(IDocumentEvent arg0) {
702 // TODO Auto-generated method stub
705 @Override
706 public void onInsertDone(IDocumentEvent arg0) {
707 // TODO Auto-generated method stub
710 @Override
711 public void onInsertStart(IDocumentEvent arg0) {
712 // TODO Auto-generated method stub
715 @Override
716 public void onLoad(IDocumentEvent arg0) {
717 // TODO Auto-generated method stub
720 @Override
721 public void onLoadDone(IDocumentEvent arg0) {
722 System.out.println("onLoad Done");
723 // TODO Auto-generated method stub
724 //System.out.println("************************Dokument geladen************************* "+arg0);
727 @Override
728 public void onLoadFinished(IDocumentEvent arg0) {
729 System.out.println("onLoad Finished");
730 // TODO Auto-generated method stub
731 //System.out.println("************************Dokument geladen finished************************* "+arg0);
733 try {
734 Reha.officeapplication.getDesktopService().removeDocumentListener(this);
735 } catch (OfficeApplicationException e) {
736 // TODO Auto-generated catch block
737 e.printStackTrace();
741 @Override
742 public void onModifyChanged(IDocumentEvent arg0) {
743 // TODO Auto-generated method stub
746 @Override
747 public void onMouseOut(IDocumentEvent arg0) {
748 // TODO Auto-generated method stub
751 @Override
752 public void onMouseOver(IDocumentEvent arg0) {
753 // TODO Auto-generated method stub
756 @Override
757 public void onNew(IDocumentEvent arg0) {
758 // TODO Auto-generated method stub
761 @Override
762 public void onNonAlphaCharInput(IDocumentEvent arg0) {
763 // TODO Auto-generated method stub
766 @Override
767 public void onSave(IDocumentEvent arg0) {
768 // TODO Auto-generated method stub
769 //System.out.println("************************Dokument gespeichert - doneSave************************* "+arg0);
771 @Override
772 public void onSaveAs(IDocumentEvent arg0) {
773 // TODO Auto-generated method stub
776 @Override
777 public void onSaveAsDone(IDocumentEvent arg0) {
778 System.out.println("saveas Done");
781 @Override
782 public void onSaveDone(IDocumentEvent arg0) {
783 System.out.println("save Done");
784 // TODO Auto-generated method stub
785 //System.out.println("************************Dokument gespeichert - done************************* "+arg0);
787 @Override
788 public void onSaveFinished(IDocumentEvent arg0) {
789 // TODO Auto-generated method stub
790 //System.out.println("************************Dokument gespeichert - finished************************* "+arg0);
792 @Override
793 public void onUnload(IDocumentEvent arg0) {
794 // TODO Auto-generated method stub
797 @Override
798 public void disposing(IEvent arg0) {
799 // TODO Auto-generated method stub