1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package com.sun.star.comp.beans;
25 
26 import com.sun.star.uno.UnoRuntime;
27 
28 //==========================================================================
29 /**	Wrapper class for service OfficeDocument which emulates the upcoming
30  	mode of automatic runtime Java classes to get rid of the need for
31 	queryInterface.
32 
33 	See further information on the wrapping and compatibility limitations
34 	in the base class Wrapper.
35 
36     @since OOo 2.0.0
37  */
38 public class OfficeDocument extends Wrapper
39 	implements
40 		com.sun.star.frame.XModel,
41 		com.sun.star.util.XModifiable,
42 		com.sun.star.frame.XStorable,
43 		com.sun.star.view.XPrintable
44 {
45 	private com.sun.star.frame.XModel xModel;
46 	private com.sun.star.util.XModifiable xModifiable;
47 	private com.sun.star.view.XPrintable xPrintable;
48 	private com.sun.star.frame.XStorable xStorable;
49 
OfficeDocument( com.sun.star.frame.XModel xModel )50 	public OfficeDocument( com.sun.star.frame.XModel xModel )
51 	{
52 		super( xModel );
53 
54 		this.xModel = xModel;
55 		this.xModifiable = (com.sun.star.util.XModifiable)
56 			UnoRuntime.queryInterface(
57 				com.sun.star.util.XModifiable.class, xModel );
58 		this.xPrintable = (com.sun.star.view.XPrintable)
59 			UnoRuntime.queryInterface(
60 				com.sun.star.view.XPrintable.class, xModel );
61 		this.xStorable = (com.sun.star.frame.XStorable)
62 			UnoRuntime.queryInterface(
63 				com.sun.star.frame.XStorable.class, xModel );
64 	}
65 
66 	//==========================================================
67 	// com.sun.star.frame.XModel
68 	//----------------------------------------------------------
69 
attachResource( String aURL, com.sun.star.beans.PropertyValue[] aArguments )70 	public boolean attachResource( /*IN*/String aURL,
71 			/*IN*/com.sun.star.beans.PropertyValue[] aArguments )
72 	{
73 		return xModel.attachResource( aURL, aArguments );
74 	}
75 
getURL( )76 	public String getURL(  )
77 	{
78 		return xModel.getURL();
79 	}
80 
getArgs( )81 	public com.sun.star.beans.PropertyValue[] getArgs(  )
82 	{
83 		return xModel.getArgs();
84 	}
85 
connectController( com.sun.star.frame.XController xController )86 	public void connectController(
87 		/*IN*/ com.sun.star.frame.XController xController )
88 	{
89 		xModel.connectController( xController );
90 	}
91 
disconnectController( com.sun.star.frame.XController xController )92 	public void disconnectController(
93 		/*IN*/ com.sun.star.frame.XController xController )
94 	{
95 		xModel.disconnectController( xController );
96 	}
97 
lockControllers( )98 	public void lockControllers(  )
99 	{
100 		xModel.lockControllers();
101 	}
102 
unlockControllers( )103 	public void unlockControllers(  )
104 	{
105 		xModel.unlockControllers();
106 	}
107 
hasControllersLocked( )108 	public boolean hasControllersLocked(  )
109 	{
110 		return xModel.hasControllersLocked();
111 	}
112 
getCurrentController( )113 	public com.sun.star.frame.XController getCurrentController(  )
114 	{
115 		return xModel.getCurrentController();
116 	}
117 
setCurrentController( com.sun.star.frame.XController xController )118 	public void setCurrentController(
119 		/*IN*/ com.sun.star.frame.XController xController )
120 		throws com.sun.star.container.NoSuchElementException
121 	{
122 		xModel.setCurrentController( xController );
123 	}
124 
getCurrentSelection( )125 	public java.lang.Object getCurrentSelection(  )
126 	{
127 		return xModel.getCurrentSelection();
128 	}
129 
130 	//==========================================================
131 	// com.sun.star.util.XModifyBroadcaster
132 	//----------------------------------------------------------
133 
addModifyListener( com.sun.star.util.XModifyListener xListener )134 	public void addModifyListener(
135 		/*IN*/ com.sun.star.util.XModifyListener xListener )
136 	{
137 		xModifiable.addModifyListener( xListener );
138 	}
139 
removeModifyListener( com.sun.star.util.XModifyListener xListener )140 	public void removeModifyListener(
141 		/*IN*/ com.sun.star.util.XModifyListener xListener )
142 	{
143 		xModifiable.removeModifyListener( xListener );
144 	}
145 
146 	//==========================================================
147 	// com.sun.star.util.XModifiable
148 	//----------------------------------------------------------
149 
isModified( )150 	public boolean isModified(  )
151 	{
152 		return xModifiable.isModified();
153 	}
154 
setModified( boolean bModified )155 	public void setModified( /*IN*/boolean bModified )
156 		throws com.sun.star.beans.PropertyVetoException
157 	{
158 		xModifiable.setModified( bModified );
159 	}
160 
161 	//==========================================================
162 	// com.sun.star.view.XPrintable
163 	//----------------------------------------------------------
164 
getPrinter( )165 	public com.sun.star.beans.PropertyValue[] getPrinter(  )
166 	{
167 		return xPrintable.getPrinter();
168 	}
169 
setPrinter( com.sun.star.beans.PropertyValue[] aPrinter )170 	public void setPrinter( /*IN*/ com.sun.star.beans.PropertyValue[] aPrinter )
171 		throws com.sun.star.lang.IllegalArgumentException
172 	{
173 		xPrintable.setPrinter( aPrinter );
174 	}
175 
print( com.sun.star.beans.PropertyValue[] xOptions )176 	public void print( /*IN*/ com.sun.star.beans.PropertyValue[] xOptions )
177 		throws com.sun.star.lang.IllegalArgumentException
178 	{
179 		xPrintable.print( xOptions );
180 	}
181 
182 	//==========================================================
183 	// com.sun.star.frame.XStorable
184 	//----------------------------------------------------------
185 
hasLocation( )186 	public boolean hasLocation(  )
187 	{
188 		return xStorable.hasLocation();
189 	}
190 
getLocation( )191 	public String getLocation(  )
192 	{
193 		return xStorable.getLocation();
194 	}
195 
isReadonly( )196 	public boolean isReadonly(  )
197 	{
198 		return xStorable.isReadonly();
199 	}
200 
store( )201 	public void store(  )
202 		throws com.sun.star.io.IOException
203 	{
204 		xStorable.store();
205 	}
206 
storeAsURL( String aURL, com.sun.star.beans.PropertyValue[] aArguments )207 	public void storeAsURL( /*IN*/ String aURL, /*IN*/ com.sun.star.beans.PropertyValue[] aArguments )
208 		throws com.sun.star.io.IOException
209 	{
210 		xStorable.storeAsURL( aURL, aArguments );
211 	}
212 
storeToURL( String aURL, com.sun.star.beans.PropertyValue[] aArguments )213 	public void storeToURL( /*IN*/ String aURL, /*IN*/ com.sun.star.beans.PropertyValue[] aArguments )
214 		throws com.sun.star.io.IOException
215 	{
216 		xStorable.storeToURL( aURL, aArguments );
217 	}
218 
219 };
220 
221 
222 
223