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 ifc.frame; 29 30 import com.sun.star.awt.Point; 31 import com.sun.star.frame.XFrame; 32 import com.sun.star.frame.XLayoutManager; 33 import com.sun.star.awt.Rectangle; 34 import com.sun.star.awt.Size; 35 import com.sun.star.ui.DockingArea; 36 import com.sun.star.ui.XUIElement; 37 import lib.MultiMethodTest; 38 import util.utils; 39 40 public class _XLayoutManager extends MultiMethodTest { 41 public XLayoutManager oObj = null; 42 43 private XFrame xFrame = null; 44 private String sElementName = "private:resource/menubar/myMenu"; 45 46 public void before() { 47 xFrame = (XFrame)tEnv.getObjRelation("XLayoutManager.Frame"); 48 } 49 50 public void _attachFrame() { 51 oObj.attachFrame(xFrame); 52 tRes.tested("attachFrame()", true); 53 } 54 55 public void _createElement() { 56 requiredMethod("attachFrame()"); 57 oObj.createElement(sElementName); 58 tRes.tested("createElement()", true); 59 } 60 61 public void _destroyElement() { 62 requiredMethod("getElement()"); 63 requiredMethod("getElements()"); 64 oObj.destroyElement(sElementName); 65 tRes.tested("destroyElement()", true); 66 } 67 68 public void _doLayout() { 69 oObj.doLayout(); 70 tRes.tested("doLayout()", true); 71 } 72 73 public void _dockWindow() { 74 requiredMethod("createElement()"); 75 Point p = new Point(); 76 p.X = 0; 77 p.Y = 0; 78 oObj.dockWindow(sElementName, DockingArea.DOCKINGAREA_TOP, p); 79 tRes.tested("dockWindow()", true); 80 } 81 82 public void _floatWindow() { 83 requiredMethod("createElement()"); 84 oObj.floatWindow(sElementName); 85 tRes.tested("floatWindow()", true); 86 } 87 88 public void _getCurrentDockingArea() { 89 requiredMethod("attachFrame()"); 90 Rectangle rect = oObj.getCurrentDockingArea(); 91 tRes.tested("getCurrentDockingArea()", rect != null); 92 } 93 94 public void _getElement() { 95 requiredMethod("createElement()"); 96 XUIElement xElement = oObj.getElement(sElementName); 97 tRes.tested("getElement()", true); 98 } 99 100 public void _getElementPos() { 101 Point p = oObj.getElementPos(sElementName); 102 tRes.tested("getElementPos()", p != null); 103 } 104 105 public void _getElementSize() { 106 Size s = oObj.getElementSize(sElementName); 107 tRes.tested("getElementSize()", s != null); 108 } 109 110 public void _getElements() { 111 requiredMethod("createElement()"); 112 XUIElement[] xElements = oObj.getElements(); 113 for (int i=0; i<xElements.length; i++) { 114 Object o = xElements[i].getRealInterface(); 115 log.println("Element " + i + ": " + o.toString() + " " + utils.getImplName(o)); 116 } 117 tRes.tested("getElements()", xElements != null); 118 } 119 120 public void _hideElement() { 121 boolean hidden = oObj.hideElement(sElementName); 122 tRes.tested("hideElement()", true); 123 } 124 125 public void _isElementDocked() { 126 boolean docked = oObj.isElementDocked(sElementName); 127 tRes.tested("isElementDocked()", true); 128 } 129 130 public void _isElementFloating() { 131 boolean docked = oObj.isElementFloating(sElementName); 132 tRes.tested("isElementFloating()", true); 133 } 134 135 public void _isElementVisible() { 136 boolean docked = oObj.isElementVisible(sElementName); 137 tRes.tested("isElementVisible()", true); 138 } 139 140 public void _lock() { 141 oObj.lock(); 142 tRes.tested("lock()", true); 143 } 144 145 public void _reset() { 146 oObj.reset(); 147 tRes.tested("reset()", true); 148 } 149 150 public void _setDockingAreaAcceptor() { 151 oObj.setDockingAreaAcceptor(null); 152 tRes.tested("setDockingAreaAcceptor()", true); 153 } 154 155 public void _setElementPos() { 156 requiredMethod("createElement()"); 157 Point p = new Point(); 158 p.X = 0; 159 p.Y = 150; 160 oObj.setElementPos(sElementName, p); 161 tRes.tested("setElementPos()", true); 162 } 163 164 public void _setElementPosSize() { 165 requiredMethod("createElement()"); 166 Point p = new Point(); 167 p.X = 150; 168 p.Y = 0; 169 Size size = new Size(); 170 size.Height = 50; 171 size.Width = 80; 172 oObj.setElementPosSize(sElementName, p, size); 173 tRes.tested("setElementPosSize()", true); 174 } 175 176 public void _setElementSize() { 177 requiredMethod("createElement()"); 178 Size size = new Size(); 179 size.Height = 80; 180 size.Width = 50; 181 oObj.setElementSize(sElementName, size); 182 tRes.tested("setElementSize()", true); 183 } 184 185 public void _showElement() { 186 requiredMethod("createElement()"); 187 boolean shown = oObj.showElement(sElementName); 188 tRes.tested("showElement()", true); 189 190 } 191 192 public void _unlock() { 193 requiredMethod("lock()"); 194 oObj.unlock(); 195 tRes.tested("unlock()", true); 196 } 197 198 } 199