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 
24 package helper;
25 
26 import com.sun.star.inspection.PropertyCategoryDescriptor;
27 import com.sun.star.inspection.XObjectInspectorModel;
28 
29 /**
30  * This is an implementation of <CODE>ObjectInspectorModel</CODE>.
31  * @see com.sun.star.inspection.XObjectInspectorModel
32  */
33 public class ObjectInspectorModelImpl implements XObjectInspectorModel{
34 
35     /**
36      * class variable which contains the implementations of
37      * <CODE>PropertyCategoryDescriptor</CODE>
38      * @see com.sun.star.inspection.PropertyCategoryDescriptor
39      */
40     PropertyCategoryDescriptor[] m_Categories;
41 
42     /**
43      * class variable which contains the count of implementations of
44      *  <CODE>PropertyCategoryDescriptor</CODE>
45      */
46     int m_count;
47 
48     /**
49      * Creates a new instance of ObjectInspectorModelImpl
50      * For every count given in parameter <CODE>count</CODE> an
51      * <CODE>PropertyCategoryDescriptor</CODE> was created an filled with valuable content.
52      * @param count count of <CODE>PropertyCategoryDescriptor</CODE> to create
53      */
ObjectInspectorModelImpl(int count)54     public ObjectInspectorModelImpl(int count) {
55         m_count = count;
56         m_Categories = new PropertyCategoryDescriptor[m_count];
57         int CategoryMem = 0;
58         int inCat = 0;
59         for (int n=0; n < m_count; n++ ){
60 
61             m_Categories[n] = new PropertyCategoryDescriptor();
62 
63             int category = n / 2;
64             inCat =(CategoryMem == category)? ++inCat: 1;
65             CategoryMem = category;
66 
67             //System.out.println("Category" + category + "Number" + inCat);
68             m_Categories[n].ProgrammaticName = "Category" + category;
69             m_Categories[n].UIName = "Category" + category + "Number" + inCat;
70             m_Categories[n].HelpURL = "h:" + n;
71         }
72     }
73 
74     /**
75      * returns the catrgories
76      * @return returns the catrgories
77      */
describeCategories()78     public PropertyCategoryDescriptor[] describeCategories() {
79         return m_Categories;
80     }
81 
82     /**
83      * returns currently nothing
84      * @return nothing
85      */
getHandlerFactories()86     public Object[] getHandlerFactories() {
87         return null;
88     }
89 
90     /** determines whether the object inspector should have a help section
91         @return false
92     */
getHasHelpSection()93     public boolean getHasHelpSection() {
94         return false;
95     }
96 
97     /** returns minimum number of lines in the help text section.
98         @return 3
99     */
getMinHelpTextLines()100     public int getMinHelpTextLines() {
101         return 3;
102     }
103 
104     /** returns maximum number of lines in the help text section.
105         @return 8
106     */
getMaxHelpTextLines()107     public int getMaxHelpTextLines() {
108         return 8;
109     }
110 
111     /** returns whether or not the inspector's UI should be read-only
112     */
getIsReadOnly()113     public boolean getIsReadOnly() {
114         return false;
115     }
116 
117     /** sets the inspector's read-only state
118     */
setIsReadOnly( boolean _IsReadOnly )119     public void setIsReadOnly( boolean _IsReadOnly ) {
120         // not supported, and not used so far in our test cases
121     }
122 
123     /**
124      * retrieves an index in a global property ordering, for a given property name
125      * @param UIName the property whose global order index should be retrieved
126      * @throws com.sun.star.beans.UnknownPropertyException if the given property is unknown
127      * @return the global order index of PropertyName
128      */
getPropertyOrderIndex(String UIName)129     public int getPropertyOrderIndex(String UIName) {
130         int index = 0;
131         for (int n=0; n < m_Categories.length; n++){
132             if (m_Categories[n].UIName.equals(UIName)){
133                 index = n;
134                 break;
135             }
136         }
137         return index;
138     }
139 
140  }
141