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 complex.imageManager;
28 
29 import com.sun.star.graphic.XGraphic;
30 import com.sun.star.ui.ImageType;
31 import com.sun.star.ui.XImageManager;
32 import lib.TestParameters;
33 
34 
35 /**
36  *
37  */
38 public class _XImageManager {
39 
40     TestParameters tEnv = null;
41     String[]imageNames = null;
42     XGraphic[] xGraphicArray = null;
43     public XImageManager oObj;
44 
45     public _XImageManager( TestParameters tEnv, XImageManager oObj) {
46 
47         this.tEnv = tEnv;
48         this.oObj = oObj;
49     }
50 
51     public boolean _getAllImageNames() {
52         short s = ImageType.COLOR_NORMAL + ImageType.SIZE_DEFAULT;
53         imageNames = oObj.getAllImageNames(s);
54         for (int i=0; i<(imageNames.length>10?10:imageNames.length); i++)
55         {
56             System.out.println("###### Image: " + imageNames[i]);
57         }
58         return imageNames != null;
59     }
60 
61     public boolean _getImages() {
62         short s = ImageType.COLOR_NORMAL + ImageType.SIZE_DEFAULT;
63         try {
64             xGraphicArray = oObj.getImages(s, imageNames);
65         }
66         catch(com.sun.star.lang.IllegalArgumentException e) {
67         }
68         return xGraphicArray != null;
69     }
70 
71     public boolean _hasImage() {
72         boolean result = true;
73         short s = ImageType.COLOR_NORMAL + ImageType.SIZE_DEFAULT;
74         try { // check the first image names, 10 at max
75             for (int i=0; i<(imageNames.length>10?10:imageNames.length); i++)
76             {
77                 result &= oObj.hasImage(s, imageNames[i]);
78             }
79         }
80         catch(com.sun.star.lang.IllegalArgumentException e) {
81             result = false;
82         }
83         return result;
84     }
85 
86     public boolean _insertImages() {
87         try {
88             oObj.insertImages((short)imageNames.length, imageNames, xGraphicArray);
89         }
90         catch(com.sun.star.container.ElementExistException e) {
91         }
92         catch(com.sun.star.lang.IllegalArgumentException e) {
93         }
94         catch(com.sun.star.lang.IllegalAccessException e) {
95         }
96         return true;
97     }
98 
99     public boolean _removeImages() {
100         try {
101             oObj.removeImages((short)(imageNames.length-1), imageNames);
102         }
103         catch(com.sun.star.lang.IllegalArgumentException e) {
104         }
105         catch(com.sun.star.lang.IllegalAccessException e) {
106         }
107         return true;
108     }
109 
110     public boolean _replaceImages() {
111         return true;
112     }
113 
114     public boolean _reset() {
115         return true;
116     }
117 }
118