1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 package complex.imageManager;
24 
25 import com.sun.star.graphic.XGraphic;
26 import com.sun.star.ui.ImageType;
27 import com.sun.star.ui.XImageManager;
28 import lib.TestParameters;
29 
30 
31 /**
32  *
33  */
34 public class _XImageManager {
35 
36     TestParameters tEnv = null;
37     String[]imageNames = null;
38     XGraphic[] xGraphicArray = null;
39     public XImageManager oObj;
40 
41     public _XImageManager( TestParameters tEnv, XImageManager oObj) {
42 
43         this.tEnv = tEnv;
44         this.oObj = oObj;
45     }
46 
47     public boolean _getAllImageNames() {
48         short s = ImageType.COLOR_NORMAL + ImageType.SIZE_DEFAULT;
49         imageNames = oObj.getAllImageNames(s);
50         for (int i=0; i<(imageNames.length>10?10:imageNames.length); i++)
51         {
52             System.out.println("###### Image: " + imageNames[i]);
53         }
54         return imageNames != null;
55     }
56 
57     public boolean _getImages() {
58         short s = ImageType.COLOR_NORMAL + ImageType.SIZE_DEFAULT;
59         try {
60             xGraphicArray = oObj.getImages(s, imageNames);
61         }
62         catch(com.sun.star.lang.IllegalArgumentException e) {
63         }
64         return xGraphicArray != null;
65     }
66 
67     public boolean _hasImage() {
68         boolean result = true;
69         short s = ImageType.COLOR_NORMAL + ImageType.SIZE_DEFAULT;
70         try { // check the first image names, 10 at max
71             for (int i=0; i<(imageNames.length>10?10:imageNames.length); i++)
72             {
73                 result &= oObj.hasImage(s, imageNames[i]);
74             }
75         }
76         catch(com.sun.star.lang.IllegalArgumentException e) {
77             result = false;
78         }
79         return result;
80     }
81 
82     public boolean _insertImages() {
83         try {
84             oObj.insertImages((short)imageNames.length, imageNames, xGraphicArray);
85         }
86         catch(com.sun.star.container.ElementExistException e) {
87         }
88         catch(com.sun.star.lang.IllegalArgumentException e) {
89         }
90         catch(com.sun.star.lang.IllegalAccessException e) {
91         }
92         return true;
93     }
94 
95     public boolean _removeImages() {
96         try {
97             oObj.removeImages((short)(imageNames.length-1), imageNames);
98         }
99         catch(com.sun.star.lang.IllegalArgumentException e) {
100         }
101         catch(com.sun.star.lang.IllegalAccessException e) {
102         }
103         return true;
104     }
105 
106     public boolean _replaceImages() {
107         return true;
108     }
109 
110     public boolean _reset() {
111         return true;
112     }
113 }
114