1*34dd1e25SAndrew Rist /**************************************************************
2*34dd1e25SAndrew Rist  *
3*34dd1e25SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*34dd1e25SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*34dd1e25SAndrew Rist  * distributed with this work for additional information
6*34dd1e25SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*34dd1e25SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*34dd1e25SAndrew Rist  * "License"); you may not use this file except in compliance
9*34dd1e25SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*34dd1e25SAndrew Rist  *
11*34dd1e25SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*34dd1e25SAndrew Rist  *
13*34dd1e25SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*34dd1e25SAndrew Rist  * software distributed under the License is distributed on an
15*34dd1e25SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*34dd1e25SAndrew Rist  * KIND, either express or implied.  See the License for the
17*34dd1e25SAndrew Rist  * specific language governing permissions and limitations
18*34dd1e25SAndrew Rist  * under the License.
19*34dd1e25SAndrew Rist  *
20*34dd1e25SAndrew Rist  *************************************************************/
21*34dd1e25SAndrew Rist 
22*34dd1e25SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // __________ Imports __________
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
27cdf0e10cSrcweir 
28cdf0e10cSrcweir import java.awt.*;
29cdf0e10cSrcweir import java.awt.event.*;
30cdf0e10cSrcweir import java.lang.*;
31cdf0e10cSrcweir import java.net.*;
32cdf0e10cSrcweir import javax.swing.*;
33cdf0e10cSrcweir import javax.swing.border.*;
34cdf0e10cSrcweir import java.awt.AWTEvent;
35cdf0e10cSrcweir import java.awt.event.WindowEvent;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir // __________ Implementation __________
38cdf0e10cSrcweir 
39cdf0e10cSrcweir /**
40cdf0e10cSrcweir  * This implement a java frame wich contains
41cdf0e10cSrcweir  * an office document, shows some status informations
42cdf0e10cSrcweir  * about that, provides simple functionality on it
43cdf0e10cSrcweir  * (e.g. toggle menubar, save document) and
44cdf0e10cSrcweir  * react for different situations independent
45cdf0e10cSrcweir  * (e.g. closing the document from outside).
46cdf0e10cSrcweir  * Every instance of this class will be a member
47cdf0e10cSrcweir  * inside the global "ViewContainer" of this java
48cdf0e10cSrcweir  * demo application which holds all opened views alive.
49cdf0e10cSrcweir  *
50cdf0e10cSrcweir  * @author     Andreas Schlüns
51cdf0e10cSrcweir  * @created    06.03.2002 09:38
52cdf0e10cSrcweir  */
53cdf0e10cSrcweir public class DocumentView extends    JFrame
54cdf0e10cSrcweir                           implements com.sun.star.lang.XEventListener, // react for Frame::disposing()
55cdf0e10cSrcweir                                      IShutdownListener                 // react for System.exit()
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     // ____________________
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     /**
60cdf0e10cSrcweir      * const
61cdf0e10cSrcweir      * These command strings are used to identify a received action
62cdf0e10cSrcweir      * of buttons on which we listen for action events.
63cdf0e10cSrcweir      */
64cdf0e10cSrcweir     public static final String COMMAND_OPEN   = "open"   ;
65cdf0e10cSrcweir     public static final String COMMAND_SAVE   = "save"   ;
66cdf0e10cSrcweir     public static final String COMMAND_EXPORT = "export" ;
67cdf0e10cSrcweir     public static final String COMMAND_EXIT   = "exit"   ;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     // ____________________
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     /**
72cdf0e10cSrcweir      * @member  mxFrame             office frame which contains the document of this view
73cdf0e10cSrcweir      *
74cdf0e10cSrcweir      * @member  maStatusView        special panel wich show available status informations of currently loaded document
75cdf0e10cSrcweir      * @member  maDocumentView      use JNI mechanism to plug an office window into our own java UI container (used for inplace mode only!)
76cdf0e10cSrcweir      * @member  maCustomizeView     special panel makes it possible to toggle menubar/toolbar or objectbar of loaded document
77cdf0e10cSrcweir      * @member  maInterceptor       interceptor thread which intercept "new" menu of office frame to open new frames inside this java application
78cdf0e10cSrcweir      *
79cdf0e10cSrcweir      * @member  msName              unique name of this view (returned by the global ViewContainer during registration)
80cdf0e10cSrcweir      *
81cdf0e10cSrcweir      * @member  mbOpen              button to open documents
82cdf0e10cSrcweir      * @member  mbSave              button to save currently loaded document
83cdf0e10cSrcweir      * @member  mbExport            button to save currently loaded document in HTML format (if it is possible!)
84cdf0e10cSrcweir      * @member  mbExit              button to exit this demo
85cdf0e10cSrcweir      *
86cdf0e10cSrcweir      * @member  maInterception      we try to intercept the file->new menu to open new document inside this java application
87cdf0e10cSrcweir      */
88cdf0e10cSrcweir     private com.sun.star.frame.XFrame       mxFrame             ;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     private StatusView                      maStatusView        ;
91cdf0e10cSrcweir     private NativeView                      maDocumentView      ;
92cdf0e10cSrcweir     private CustomizeView                   maCustomizeView     ;
93cdf0e10cSrcweir     private Interceptor                     maInterceptor       ;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     private String                          msName              ;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     private JButton                         mbtOpen             ;
98cdf0e10cSrcweir     private JButton                         mbtSave             ;
99cdf0e10cSrcweir     private JButton                         mbtExport           ;
100cdf0e10cSrcweir     private JButton                         mbtExit             ;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     private boolean                         mbDead              ;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     // ____________________
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     /**
107cdf0e10cSrcweir      * ctor
108cdf0e10cSrcweir      * Create view controls on startup and initialize it with default values.
109cdf0e10cSrcweir      */
DocumentView()110cdf0e10cSrcweir     DocumentView()
111cdf0e10cSrcweir     {
112cdf0e10cSrcweir         this.setSize( new Dimension(800,600) );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir         JPanel paMainPanel = (JPanel)this.getContentPane();
115cdf0e10cSrcweir 
116cdf0e10cSrcweir         // create and add command buttons to a panel
117cdf0e10cSrcweir         // it will be a sub panel of later layouted UI
118cdf0e10cSrcweir         mbtOpen   = new JButton("Open ..."        );
119cdf0e10cSrcweir         mbtSave   = new JButton("Save"            );
120cdf0e10cSrcweir         mbtExport = new JButton("Save as HTML ...");
121cdf0e10cSrcweir         mbtExit   = new JButton("Exit"            );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir         mbtOpen.setEnabled  (true );
124cdf0e10cSrcweir         mbtSave.setEnabled  (false);
125cdf0e10cSrcweir         mbtExport.setEnabled(false);
126cdf0e10cSrcweir         mbtExit.setEnabled  (true );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir         mbtOpen.setActionCommand  (COMMAND_OPEN  );
129cdf0e10cSrcweir         mbtSave.setActionCommand  (COMMAND_SAVE  );
130cdf0e10cSrcweir         mbtExport.setActionCommand(COMMAND_EXPORT);
131cdf0e10cSrcweir         mbtExit.setActionCommand  (COMMAND_EXIT  );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir         Reactor aListener = new Reactor();
134cdf0e10cSrcweir         mbtOpen.addActionListener  (aListener);
135cdf0e10cSrcweir         mbtSave.addActionListener  (aListener);
136cdf0e10cSrcweir         mbtExport.addActionListener(aListener);
137cdf0e10cSrcweir         mbtExit.addActionListener  (aListener);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         JPanel paCommands = new JPanel( new GridLayout(4,0) );
140cdf0e10cSrcweir         paCommands.add(mbtOpen);
141cdf0e10cSrcweir         paCommands.add(mbtSave);
142cdf0e10cSrcweir         paCommands.add(mbtExport);
143cdf0e10cSrcweir         paCommands.add(mbtExit);
144cdf0e10cSrcweir 
145cdf0e10cSrcweir         // create view to show status informations of opened file
146cdf0e10cSrcweir         maStatusView = new StatusView();
147cdf0e10cSrcweir 
148cdf0e10cSrcweir         // create view for toggle different bar's of document
149cdf0e10cSrcweir         maCustomizeView = new CustomizeView();
150cdf0e10cSrcweir 
151cdf0e10cSrcweir         paCommands.setBorder     ( new TitledBorder(BorderFactory.createEtchedBorder(),"Commands")                );
152cdf0e10cSrcweir         maStatusView.setBorder   ( new TitledBorder(BorderFactory.createEtchedBorder(),"Status Informations")     );
153cdf0e10cSrcweir         maCustomizeView.setBorder( new TitledBorder(BorderFactory.createEtchedBorder(),"Customize Document View") );
154cdf0e10cSrcweir 
155cdf0e10cSrcweir         // layout the whole UI
156cdf0e10cSrcweir         JPanel paTest = new JPanel(new GridLayout(3,0));
157cdf0e10cSrcweir         paTest.add(paCommands     );
158cdf0e10cSrcweir         paTest.add(maStatusView   );
159cdf0e10cSrcweir         paTest.add(maCustomizeView);
160cdf0e10cSrcweir         JScrollPane paScroll = new JScrollPane();
161cdf0e10cSrcweir         paScroll.getViewport().add(paTest,null);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir         if(ViewContainer.mbInplace==true)
164cdf0e10cSrcweir         {
165cdf0e10cSrcweir             // create view to show opened documents
166cdf0e10cSrcweir             // This special view is neccessary for inplace mode only!
167cdf0e10cSrcweir             maDocumentView = new NativeView();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir             JSplitPane paSplit = new JSplitPane();
170cdf0e10cSrcweir             paSplit.setOneTouchExpandable( true );
171cdf0e10cSrcweir 
172cdf0e10cSrcweir             paSplit.setLeftComponent (maDocumentView);
173cdf0e10cSrcweir             paSplit.setRightComponent(paScroll      );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir             paMainPanel.add(paSplit);
176cdf0e10cSrcweir         }
177cdf0e10cSrcweir         else
178cdf0e10cSrcweir         {
179cdf0e10cSrcweir             paMainPanel.add(paScroll);
180cdf0e10cSrcweir         }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir         // Register this new view on our global view container.
183cdf0e10cSrcweir         msName = FunctionHelper.getUniqueFrameName();
184cdf0e10cSrcweir         this.setTitle(msName);
185cdf0e10cSrcweir         ViewContainer.getGlobalContainer().addView(this);
186cdf0e10cSrcweir         ViewContainer.getGlobalContainer().addListener(this);
187cdf0e10cSrcweir         // be listener for closing the application
188cdf0e10cSrcweir         this.enableEvents(AWTEvent.WINDOW_EVENT_MASK);
189cdf0e10cSrcweir     }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     // ____________________
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     /**
194cdf0e10cSrcweir      * Create the view frame for showing the office documents on demand.
195cdf0e10cSrcweir      * Dependend from given command line parameter we create
196cdf0e10cSrcweir      * an office XFrame and initialize it with a window. This
197cdf0e10cSrcweir      * window can be a pure toolkit window (means toolkit of office!)
198cdf0e10cSrcweir      * or a plugged java canvas - office window combination.
199cdf0e10cSrcweir      */
createFrame()200cdf0e10cSrcweir     public void createFrame()
201cdf0e10cSrcweir     {
202cdf0e10cSrcweir         // create view frame (as a XFrame!) here
203cdf0e10cSrcweir         // Look for right view mode setted by user command line parameter.
204cdf0e10cSrcweir         // First try to get a new unambigous frame name from our global ViewContainer.
205cdf0e10cSrcweir         if(ViewContainer.mbInplace==true)
206cdf0e10cSrcweir         {
207cdf0e10cSrcweir             // inplace document view can't be initialized without a visible parent window hierarchy!
208cdf0e10cSrcweir             // So make shure that we are visible in every case!
209cdf0e10cSrcweir             this.setVisible(true);
210cdf0e10cSrcweir             mxFrame = FunctionHelper.createViewFrame(msName,maDocumentView);
211cdf0e10cSrcweir         }
212cdf0e10cSrcweir         else
213cdf0e10cSrcweir             mxFrame = FunctionHelper.createViewFrame(msName,null);
214cdf0e10cSrcweir 
215cdf0e10cSrcweir         if(mxFrame!=null)
216cdf0e10cSrcweir         {
217cdf0e10cSrcweir             // start interception
218cdf0e10cSrcweir             maInterceptor = new Interceptor(mxFrame);
219cdf0e10cSrcweir             maInterceptor.startListening();
220cdf0e10cSrcweir 
221cdf0e10cSrcweir             // start listening for status events and actualization
222cdf0e10cSrcweir             // of our status view
223cdf0e10cSrcweir             // (of course for our CustomizeView too)
224cdf0e10cSrcweir             maStatusView.setFrame   (mxFrame);
225cdf0e10cSrcweir             maCustomizeView.setFrame(mxFrame);
226cdf0e10cSrcweir 
227cdf0e10cSrcweir             // be listener for closing the remote target view frame
228cdf0e10cSrcweir             com.sun.star.lang.XComponent xBroadcaster = (com.sun.star.lang.XComponent)UnoRuntime.queryInterface(
229cdf0e10cSrcweir                 com.sun.star.lang.XComponent.class,
230cdf0e10cSrcweir                 mxFrame);
231cdf0e10cSrcweir 
232cdf0e10cSrcweir             if(xBroadcaster!=null)
233cdf0e10cSrcweir                 xBroadcaster.addEventListener(this);
234cdf0e10cSrcweir         }
235cdf0e10cSrcweir     }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir     // ____________________
238cdf0e10cSrcweir 
239cdf0e10cSrcweir     /**
240cdf0e10cSrcweir      * Different ways to load any URL from outside (may be by the command line)
241cdf0e10cSrcweir      * into this document view or to save it.
242cdf0e10cSrcweir      */
load(String sURL)243cdf0e10cSrcweir     public void load(String sURL)
244cdf0e10cSrcweir     {
245cdf0e10cSrcweir         load(sURL,new com.sun.star.beans.PropertyValue[0]);
246cdf0e10cSrcweir     }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir     // ____________________
249cdf0e10cSrcweir 
load(String sURL, com.sun.star.beans.PropertyValue[] lArguments)250cdf0e10cSrcweir     public void load(String sURL, com.sun.star.beans.PropertyValue[] lArguments)
251cdf0e10cSrcweir     {
252cdf0e10cSrcweir         com.sun.star.lang.XComponent xDocument = FunctionHelper.loadDocument(mxFrame,sURL,lArguments);
253cdf0e10cSrcweir         if(xDocument!=null)
254cdf0e10cSrcweir         {
255cdf0e10cSrcweir             mbtSave.setEnabled  (true);
256cdf0e10cSrcweir             mbtExport.setEnabled(true);
257cdf0e10cSrcweir         }
258cdf0e10cSrcweir         else
259cdf0e10cSrcweir         {
260cdf0e10cSrcweir             mbtSave.setEnabled  (false);
261cdf0e10cSrcweir             mbtExport.setEnabled(false);
262cdf0e10cSrcweir         }
263cdf0e10cSrcweir     }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir     // ____________________
266cdf0e10cSrcweir 
save()267cdf0e10cSrcweir     public void save()
268cdf0e10cSrcweir     {
269cdf0e10cSrcweir         com.sun.star.frame.XController xController = mxFrame.getController();
270cdf0e10cSrcweir         if (xController==null)
271cdf0e10cSrcweir             return;
272cdf0e10cSrcweir         com.sun.star.frame.XModel xDocument = xController.getModel();
273cdf0e10cSrcweir         if (xDocument==null)
274cdf0e10cSrcweir             return;
275cdf0e10cSrcweir         FunctionHelper.saveDocument(xDocument);
276cdf0e10cSrcweir     }
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     // ____________________
279cdf0e10cSrcweir 
exportHTML(String sURL)280cdf0e10cSrcweir     public void exportHTML(String sURL)
281cdf0e10cSrcweir     {
282cdf0e10cSrcweir         com.sun.star.frame.XController xController = mxFrame.getController();
283cdf0e10cSrcweir         if (xController==null)
284cdf0e10cSrcweir             return;
285cdf0e10cSrcweir         com.sun.star.frame.XModel xDocument = xController.getModel();
286cdf0e10cSrcweir         if (xDocument==null)
287cdf0e10cSrcweir             return;
288cdf0e10cSrcweir         FunctionHelper.saveAsHTML(xDocument,sURL);
289cdf0e10cSrcweir     }
290cdf0e10cSrcweir 
291cdf0e10cSrcweir     // ____________________
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     /**
294cdf0e10cSrcweir      * Overridden so we can react for window closing of this view.
295cdf0e10cSrcweir      */
processWindowEvent(WindowEvent aEvent)296cdf0e10cSrcweir     protected void processWindowEvent(WindowEvent aEvent)
297cdf0e10cSrcweir     {
298cdf0e10cSrcweir         if (aEvent.getID()!=WindowEvent.WINDOW_CLOSING)
299cdf0e10cSrcweir         {
300cdf0e10cSrcweir             super.processWindowEvent(aEvent);
301cdf0e10cSrcweir         }
302cdf0e10cSrcweir         else
303cdf0e10cSrcweir         if (FunctionHelper.closeFrame(mxFrame))
304cdf0e10cSrcweir         {
305cdf0e10cSrcweir             mxFrame = null;
306cdf0e10cSrcweir             shutdown();
307cdf0e10cSrcweir             super.processWindowEvent(aEvent);
308cdf0e10cSrcweir         }
309cdf0e10cSrcweir     }
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     // ____________________
312cdf0e10cSrcweir 
313cdf0e10cSrcweir     /**
314cdf0e10cSrcweir      * Here we can react for System.exit() normaly.
315cdf0e10cSrcweir      * But we use it for disposing() or windowClosing() too.
316cdf0e10cSrcweir      */
shutdown()317cdf0e10cSrcweir     public void shutdown()
318cdf0e10cSrcweir     {
319cdf0e10cSrcweir         if (mbDead)
320cdf0e10cSrcweir             return;
321cdf0e10cSrcweir         mbDead=true;
322cdf0e10cSrcweir 
323cdf0e10cSrcweir         // force these sub view to release her remote
324cdf0e10cSrcweir         // refrences too!
325cdf0e10cSrcweir         maStatusView.shutdown();
326cdf0e10cSrcweir         maCustomizeView.shutdown();
327cdf0e10cSrcweir 
328cdf0e10cSrcweir         maStatusView    = null;
329cdf0e10cSrcweir         maCustomizeView = null;
330cdf0e10cSrcweir 
331cdf0e10cSrcweir         // disable all interceptions
332cdf0e10cSrcweir         maInterceptor.shutdown();
333cdf0e10cSrcweir         maInterceptor = null;
334cdf0e10cSrcweir 
335cdf0e10cSrcweir         // close the frame and his document
336cdf0e10cSrcweir         // Relaesing of our listener connections for disposing()
337cdf0e10cSrcweir         // will be forced automaticly then. Because the frame
338cdf0e10cSrcweir         // will call us back ...
339cdf0e10cSrcweir         if (mxFrame!=null)
340cdf0e10cSrcweir             FunctionHelper.closeFrame(mxFrame);
341cdf0e10cSrcweir 
342cdf0e10cSrcweir         // deregister this view in the global container
343cdf0e10cSrcweir         // Normaly we should die afterwards by garbage collection ...
344cdf0e10cSrcweir         // In cease this was the last view - it force a system.exit().
345cdf0e10cSrcweir         // But then we are no longer a member of the global container
346cdf0e10cSrcweir         // of possible shutdown listener ... and this method should be
347cdf0e10cSrcweir         // called again.
348cdf0e10cSrcweir         ViewContainer.getGlobalContainer().removeView(this);
349cdf0e10cSrcweir     }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     // ____________________
352cdf0e10cSrcweir 
353cdf0e10cSrcweir     /**
354cdf0e10cSrcweir      * callback from our internal saved frame
355cdf0e10cSrcweir      * which wish to die. Its not neccessary to remove listener connections
356cdf0e10cSrcweir      * here. Because the broadcaster do it automaticly.
357cdf0e10cSrcweir      * We have to release all references to him only.
358cdf0e10cSrcweir      *
359cdf0e10cSrcweir      * @param aSource
360cdf0e10cSrcweir      *          describe the broadcaster of this event
361cdf0e10cSrcweir      *          Must be our internal saved frame.
362cdf0e10cSrcweir      */
disposing(com.sun.star.lang.EventObject aSource)363cdf0e10cSrcweir     public void disposing(com.sun.star.lang.EventObject aSource)
364cdf0e10cSrcweir     {
365cdf0e10cSrcweir         mxFrame = null;
366cdf0e10cSrcweir     }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir     // ____________________
369cdf0e10cSrcweir 
370cdf0e10cSrcweir     /**
371cdf0e10cSrcweir      * This inner class is used to react for events of our own UI controls.
372cdf0e10cSrcweir      * So we can start different actions then.
373cdf0e10cSrcweir      */
374cdf0e10cSrcweir     private class Reactor implements ActionListener
375cdf0e10cSrcweir     {
376cdf0e10cSrcweir         // ____________________
377cdf0e10cSrcweir 
378cdf0e10cSrcweir         /**
379cdf0e10cSrcweir         * This method react for pressed buttons or selected check boxes.
380cdf0e10cSrcweir         */
actionPerformed(ActionEvent aEvent)381cdf0e10cSrcweir         public void actionPerformed(ActionEvent aEvent)
382cdf0e10cSrcweir         {
383cdf0e10cSrcweir             String sCommand = aEvent.getActionCommand();
384cdf0e10cSrcweir             //-----------------------------
385cdf0e10cSrcweir             // open any file from disk
386cdf0e10cSrcweir             if( sCommand.compareTo(COMMAND_OPEN) == 0 )
387cdf0e10cSrcweir             {
388cdf0e10cSrcweir                 String sURL = FunctionHelper.askUserForFileURL(DocumentView.this,true);
389cdf0e10cSrcweir                 if(sURL!=null)
390cdf0e10cSrcweir                     DocumentView.this.load(sURL);
391cdf0e10cSrcweir             }
392cdf0e10cSrcweir             else
393cdf0e10cSrcweir             //-----------------------------
394cdf0e10cSrcweir             // save current document
395cdf0e10cSrcweir             if( sCommand.compareTo(COMMAND_SAVE) == 0 )
396cdf0e10cSrcweir             {
397cdf0e10cSrcweir                 DocumentView.this.save();
398cdf0e10cSrcweir             }
399cdf0e10cSrcweir             else
400cdf0e10cSrcweir             //-----------------------------
401cdf0e10cSrcweir             // export current document to html
402cdf0e10cSrcweir             if( sCommand.compareTo(COMMAND_EXPORT) == 0 )
403cdf0e10cSrcweir             {
404cdf0e10cSrcweir                 String sURL = FunctionHelper.askUserForFileURL(DocumentView.this,false);
405cdf0e10cSrcweir                 if(sURL!=null)
406cdf0e10cSrcweir                     DocumentView.this.exportHTML(sURL);
407cdf0e10cSrcweir             }
408cdf0e10cSrcweir             else
409cdf0e10cSrcweir             //-----------------------------
410cdf0e10cSrcweir             // exit application
411cdf0e10cSrcweir             if( sCommand.compareTo(COMMAND_EXIT) == 0 )
412cdf0e10cSrcweir             {
413cdf0e10cSrcweir                 // This will force deleting of this and
414cdf0e10cSrcweir                 // all other currently opened views automaticly!
415cdf0e10cSrcweir                 System.exit(0);
416cdf0e10cSrcweir             }
417cdf0e10cSrcweir         }
418cdf0e10cSrcweir     }
419cdf0e10cSrcweir }
420