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