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