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 package ifc.configuration.backend; 28 29 import com.sun.star.configuration.backend.TemplateIdentifier; 30 import com.sun.star.configuration.backend.XUpdateHandler; 31 import com.sun.star.uno.Type; 32 33 import lib.MultiMethodTest; 34 35 import util.XLayerHandlerImpl; 36 import util.XLayerImpl; 37 38 39 /** 40 * 41 * @author sw93809 42 */ 43 public class _XUpdateHandler extends MultiMethodTest { 44 public XUpdateHandler oObj; 45 protected XLayerHandlerImpl xLayerHandler = null; 46 47 public void before() { 48 xLayerHandler = (XLayerHandlerImpl) tEnv.getObjRelation("LayerHandler"); 49 50 try { 51 xLayerHandler.startLayer(); 52 xLayerHandler.overrideNode("org.openoffice.Setup", (short) 0, 53 false); 54 xLayerHandler.overrideNode("Office", (short) 0, false); 55 xLayerHandler.overrideProperty("ooSetupInstCompleted", (short) 0, 56 new Type(java.lang.String.class), 57 false); 58 xLayerHandler.setPropertyValue(new Boolean(false)); 59 xLayerHandler.endProperty(); 60 xLayerHandler.overrideProperty("ooSetupShowIntro", (short) 0, 61 new Type(java.lang.String.class), 62 false); 63 xLayerHandler.setPropertyValue(new Boolean(true)); 64 xLayerHandler.endProperty(); 65 xLayerHandler.overrideProperty("ooSetupLocales", (short) 0, 66 new Type(java.lang.String.class), 67 false); 68 xLayerHandler.setPropertyValue("en-US"); 69 xLayerHandler.endProperty(); 70 xLayerHandler.overrideNode("Factories", (short) 0, false); 71 xLayerHandler.addOrReplaceNode("com.sun.star.chart.ChartDocument", 72 (short) 0); 73 xLayerHandler.overrideProperty("ooSetupFactoryEmptyDocumentURL", 74 (short) 0, 75 new Type(java.lang.String.class), 76 false); 77 xLayerHandler.setPropertyValue("private:factory/schart"); 78 xLayerHandler.endProperty(); 79 xLayerHandler.overrideProperty("ooSetupFactoryIcon", (short) 0, 80 new Type(java.lang.Long.class), 81 false); 82 xLayerHandler.setPropertyValue(new Integer(13)); 83 xLayerHandler.endProperty(); 84 xLayerHandler.overrideProperty("ooSetupFactoryShortName", 85 (short) 0, 86 new Type(java.lang.String.class), 87 false); 88 xLayerHandler.setPropertyValue("schart"); 89 xLayerHandler.setPropertyValueForLocale("TemplateFile", "en-US"); 90 xLayerHandler.endProperty(); 91 xLayerHandler.overrideProperty("ooSetupFactoryTemplateFile", 92 (short) 0, 93 new Type(java.lang.String.class), 94 false); 95 xLayerHandler.setPropertyValue("empty"); 96 xLayerHandler.endProperty(); 97 xLayerHandler.addProperty("ooSetupFactoryTemplateFile", (short) 0, 98 new Type(java.lang.String.class)); 99 xLayerHandler.addPropertyWithValue("ooSetupFactoryTemplateFile", 100 (short) 0, "TemplateFile"); 101 xLayerHandler.endNode(); 102 103 xLayerHandler.addOrReplaceNode("dropme", (short) 0); 104 xLayerHandler.overrideProperty("anyway", (short) 0, 105 new Type(java.lang.String.class), 106 false); 107 xLayerHandler.setPropertyValue("nice"); 108 xLayerHandler.endProperty(); 109 xLayerHandler.dropNode("dropme"); 110 xLayerHandler.endNode(); 111 112 xLayerHandler.addOrReplaceNodeFromTemplate("FromTemplate", 113 new com.sun.star.configuration.backend.TemplateIdentifier( 114 "org.openoffice.Setup", 115 "Setup"), 116 (short) 0); 117 xLayerHandler.endNode(); 118 119 xLayerHandler.endNode(); 120 xLayerHandler.endNode(); 121 xLayerHandler.endNode(); 122 xLayerHandler.endLayer(); 123 } catch (com.sun.star.configuration.backend.MalformedDataException e) { 124 log.println("Unexpected Exception " + e); 125 } catch (com.sun.star.lang.WrappedTargetException e) { 126 log.println("Unexpected Exception " + e); 127 } catch (com.sun.star.uno.Exception e) { 128 log.println("Unexpected Exception " + e); 129 } 130 } 131 132 public void _addOrReplaceNode() { 133 requiredMethod("startUpdate()"); 134 tRes.tested("addOrReplaceNode()", true); 135 } 136 137 public void _addOrReplaceNodeFromTemplate() { 138 requiredMethod("startUpdate()"); 139 tRes.tested("addOrReplaceNodeFromTemplate()", true); 140 } 141 142 public void _addOrReplaceProperty() { 143 requiredMethod("startUpdate()"); 144 tRes.tested("addOrReplaceProperty()", true); 145 } 146 147 public void _addOrReplacePropertyWithValue() { 148 requiredMethod("startUpdate()"); 149 tRes.tested("addOrReplacePropertyWithValue()", true); 150 } 151 152 public void _endNode() { 153 requiredMethod("startUpdate()"); 154 tRes.tested("endNode()", true); 155 } 156 157 public void _endProperty() { 158 requiredMethod("startUpdate()"); 159 tRes.tested("endProperty()", true); 160 } 161 162 public void _endUpdate() { 163 requiredMethod("startUpdate()"); 164 tRes.tested("endUpdate()", true); 165 } 166 167 public void _modifyNode() { 168 requiredMethod("startUpdate()"); 169 tRes.tested("modifyNode()", true); 170 } 171 172 public void _modifyProperty() { 173 requiredMethod("startUpdate()"); 174 tRes.tested("modifyProperty()", true); 175 } 176 177 public void _removeNode() { 178 requiredMethod("startUpdate()"); 179 tRes.tested("removeNode()", true); 180 } 181 182 public void _removeProperty() { 183 requiredMethod("startUpdate()"); 184 tRes.tested("removeProperty()", true); 185 } 186 187 public void _resetProperty() { 188 requiredMethod("startUpdate()"); 189 tRes.tested("resetProperty()", true); 190 } 191 192 public void _resetPropertyValue() { 193 requiredMethod("startUpdate()"); 194 tRes.tested("resetPropertyValue()", true); 195 } 196 197 public void _resetPropertyValueForLocale() { 198 requiredMethod("startUpdate()"); 199 tRes.tested("resetPropertyValueForLocale()", true); 200 } 201 202 public void _setPropertyValue() { 203 requiredMethod("startUpdate()"); 204 tRes.tested("setPropertyValue()", true); 205 } 206 207 public void _setPropertyValueForLocale() { 208 requiredMethod("startUpdate()"); 209 tRes.tested("setPropertyValueForLocale()", true); 210 } 211 212 public void _startUpdate() { 213 boolean res = true; 214 215 try { 216 XLayerImpl xLayer = (XLayerImpl) tEnv.getObjRelation("Layer"); 217 log.println("Layer called (before): " + xLayer.hasBeenCalled()); 218 oObj.startUpdate(); 219 oObj.addOrReplaceNode("whatever", (short) 0); 220 oObj.addOrReplaceNodeFromTemplate("Office", (short) 0, 221 new TemplateIdentifier()); 222 oObj.addOrReplaceProperty("prop", (short) 0, 223 new Type(java.lang.String.class)); 224 oObj.addOrReplacePropertyWithValue("prop2", (short) 0, "this"); 225 oObj.modifyProperty("ooSetupFactoryIcon", (short) 0, (short) 0, 226 new Type(java.lang.String.class)); 227 oObj.resetPropertyValue(); 228 oObj.resetPropertyValueForLocale("en-US"); 229 oObj.endProperty(); 230 oObj.modifyProperty("ooSetupFactoryEmptyDocumentURL", (short) 0, 231 (short) 0, new Type(java.lang.String.class)); 232 oObj.setPropertyValue("newValue"); 233 oObj.setPropertyValueForLocale("newValue-US", "de-DE"); 234 oObj.endProperty(); 235 oObj.removeProperty("ooSetupShowIntro"); 236 oObj.modifyNode("org.openoffice.Setup", (short) 0, (short) 0, true); 237 oObj.removeNode("whatever"); 238 oObj.resetProperty("prop"); 239 oObj.endNode(); 240 oObj.endNode(); 241 oObj.endNode(); 242 oObj.endUpdate(); 243 244 log.println("Layer called (after): " + xLayer.hasBeenCalled()); 245 246 res = xLayer.hasBeenCalled(); 247 } catch (com.sun.star.configuration.backend.MalformedDataException e) { 248 log.println("Unexpected exception " + e.getMessage()); 249 res = false; 250 } catch (com.sun.star.lang.IllegalAccessException e) { 251 log.println("Unexpected exception " + e.getMessage()); 252 res = false; 253 } catch (com.sun.star.lang.WrappedTargetException e) { 254 log.println("Unexpected exception " + e.getMessage()); 255 res = false; 256 } 257 258 tRes.tested("startUpdate()", res); 259 } 260 } 261