1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package com.sun.star.comp.beans; 29 30 import com.sun.star.uno.UnoRuntime; 31 32 //========================================================================== 33 /** Wrapper class for service OfficeDocument which emulates the upcoming 34 mode of automatic runtime Java classes to get rid of the need for 35 queryInterface. 36 37 See further information on the wrapping and compatibility limitations 38 in the base class Wrapper. 39 40 @since OOo 2.0.0 41 */ 42 public class OfficeDocument extends Wrapper 43 implements 44 com.sun.star.frame.XModel, 45 com.sun.star.util.XModifiable, 46 com.sun.star.frame.XStorable, 47 com.sun.star.view.XPrintable 48 { 49 private com.sun.star.frame.XModel xModel; 50 private com.sun.star.util.XModifiable xModifiable; 51 private com.sun.star.view.XPrintable xPrintable; 52 private com.sun.star.frame.XStorable xStorable; 53 54 public OfficeDocument( com.sun.star.frame.XModel xModel ) 55 { 56 super( xModel ); 57 58 this.xModel = xModel; 59 this.xModifiable = (com.sun.star.util.XModifiable) 60 UnoRuntime.queryInterface( 61 com.sun.star.util.XModifiable.class, xModel ); 62 this.xPrintable = (com.sun.star.view.XPrintable) 63 UnoRuntime.queryInterface( 64 com.sun.star.view.XPrintable.class, xModel ); 65 this.xStorable = (com.sun.star.frame.XStorable) 66 UnoRuntime.queryInterface( 67 com.sun.star.frame.XStorable.class, xModel ); 68 } 69 70 //========================================================== 71 // com.sun.star.frame.XModel 72 //---------------------------------------------------------- 73 74 public boolean attachResource( /*IN*/String aURL, 75 /*IN*/com.sun.star.beans.PropertyValue[] aArguments ) 76 { 77 return xModel.attachResource( aURL, aArguments ); 78 } 79 80 public String getURL( ) 81 { 82 return xModel.getURL(); 83 } 84 85 public com.sun.star.beans.PropertyValue[] getArgs( ) 86 { 87 return xModel.getArgs(); 88 } 89 90 public void connectController( 91 /*IN*/ com.sun.star.frame.XController xController ) 92 { 93 xModel.connectController( xController ); 94 } 95 96 public void disconnectController( 97 /*IN*/ com.sun.star.frame.XController xController ) 98 { 99 xModel.disconnectController( xController ); 100 } 101 102 public void lockControllers( ) 103 { 104 xModel.lockControllers(); 105 } 106 107 public void unlockControllers( ) 108 { 109 xModel.unlockControllers(); 110 } 111 112 public boolean hasControllersLocked( ) 113 { 114 return xModel.hasControllersLocked(); 115 } 116 117 public com.sun.star.frame.XController getCurrentController( ) 118 { 119 return xModel.getCurrentController(); 120 } 121 122 public void setCurrentController( 123 /*IN*/ com.sun.star.frame.XController xController ) 124 throws com.sun.star.container.NoSuchElementException 125 { 126 xModel.setCurrentController( xController ); 127 } 128 129 public java.lang.Object getCurrentSelection( ) 130 { 131 return xModel.getCurrentSelection(); 132 } 133 134 //========================================================== 135 // com.sun.star.util.XModifyBroadcaster 136 //---------------------------------------------------------- 137 138 public void addModifyListener( 139 /*IN*/ com.sun.star.util.XModifyListener xListener ) 140 { 141 xModifiable.addModifyListener( xListener ); 142 } 143 144 public void removeModifyListener( 145 /*IN*/ com.sun.star.util.XModifyListener xListener ) 146 { 147 xModifiable.removeModifyListener( xListener ); 148 } 149 150 //========================================================== 151 // com.sun.star.util.XModifiable 152 //---------------------------------------------------------- 153 154 public boolean isModified( ) 155 { 156 return xModifiable.isModified(); 157 } 158 159 public void setModified( /*IN*/boolean bModified ) 160 throws com.sun.star.beans.PropertyVetoException 161 { 162 xModifiable.setModified( bModified ); 163 } 164 165 //========================================================== 166 // com.sun.star.view.XPrintable 167 //---------------------------------------------------------- 168 169 public com.sun.star.beans.PropertyValue[] getPrinter( ) 170 { 171 return xPrintable.getPrinter(); 172 } 173 174 public void setPrinter( /*IN*/ com.sun.star.beans.PropertyValue[] aPrinter ) 175 throws com.sun.star.lang.IllegalArgumentException 176 { 177 xPrintable.setPrinter( aPrinter ); 178 } 179 180 public void print( /*IN*/ com.sun.star.beans.PropertyValue[] xOptions ) 181 throws com.sun.star.lang.IllegalArgumentException 182 { 183 xPrintable.print( xOptions ); 184 } 185 186 //========================================================== 187 // com.sun.star.frame.XStorable 188 //---------------------------------------------------------- 189 190 public boolean hasLocation( ) 191 { 192 return xStorable.hasLocation(); 193 } 194 195 public String getLocation( ) 196 { 197 return xStorable.getLocation(); 198 } 199 200 public boolean isReadonly( ) 201 { 202 return xStorable.isReadonly(); 203 } 204 205 public void store( ) 206 throws com.sun.star.io.IOException 207 { 208 xStorable.store(); 209 } 210 211 public void storeAsURL( /*IN*/ String aURL, /*IN*/ com.sun.star.beans.PropertyValue[] aArguments ) 212 throws com.sun.star.io.IOException 213 { 214 xStorable.storeAsURL( aURL, aArguments ); 215 } 216 217 public void storeToURL( /*IN*/ String aURL, /*IN*/ com.sun.star.beans.PropertyValue[] aArguments ) 218 throws com.sun.star.io.IOException 219 { 220 xStorable.storeToURL( aURL, aArguments ); 221 } 222 223 }; 224 225 226 227