1ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5ef39d40dSAndrew Rist  * distributed with this work for additional information
6ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10ef39d40dSAndrew Rist  *
11ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12ef39d40dSAndrew Rist  *
13ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18ef39d40dSAndrew Rist  * under the License.
19ef39d40dSAndrew Rist  *
20ef39d40dSAndrew Rist  *************************************************************/
21ef39d40dSAndrew Rist 
22ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package helper;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import com.sun.star.inspection.PropertyCategoryDescriptor;
27cdf0e10cSrcweir import com.sun.star.inspection.XObjectInspectorModel;
28cdf0e10cSrcweir 
29cdf0e10cSrcweir /**
30cdf0e10cSrcweir  * This is an implementation of <CODE>ObjectInspectorModel</CODE>.
31cdf0e10cSrcweir  * @see com.sun.star.inspection.XObjectInspectorModel
32cdf0e10cSrcweir  */
33cdf0e10cSrcweir public class ObjectInspectorModelImpl implements XObjectInspectorModel{
34cdf0e10cSrcweir 
35cdf0e10cSrcweir     /**
36cdf0e10cSrcweir      * class variable which contains the implementations of
37cdf0e10cSrcweir      * <CODE>PropertyCategoryDescriptor</CODE>
38cdf0e10cSrcweir      * @see com.sun.star.inspection.PropertyCategoryDescriptor
39cdf0e10cSrcweir      */
40cdf0e10cSrcweir     PropertyCategoryDescriptor[] m_Categories;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir     /**
43cdf0e10cSrcweir      * class variable which contains the count of implementations of
44cdf0e10cSrcweir      *  <CODE>PropertyCategoryDescriptor</CODE>
45cdf0e10cSrcweir      */
46cdf0e10cSrcweir     int m_count;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir     /**
49cdf0e10cSrcweir      * Creates a new instance of ObjectInspectorModelImpl
50cdf0e10cSrcweir      * For every count given in parameter <CODE>count</CODE> an
51cdf0e10cSrcweir      * <CODE>PropertyCategoryDescriptor</CODE> was created an filled with valuable content.
52cdf0e10cSrcweir      * @param count count of <CODE>PropertyCategoryDescriptor</CODE> to create
53cdf0e10cSrcweir      */
ObjectInspectorModelImpl(int count)54cdf0e10cSrcweir     public ObjectInspectorModelImpl(int count) {
55cdf0e10cSrcweir         m_count = count;
56cdf0e10cSrcweir         m_Categories = new PropertyCategoryDescriptor[m_count];
57cdf0e10cSrcweir         int CategoryMem = 0;
58cdf0e10cSrcweir         int inCat = 0;
59cdf0e10cSrcweir         for (int n=0; n < m_count; n++ ){
60cdf0e10cSrcweir 
61cdf0e10cSrcweir             m_Categories[n] = new PropertyCategoryDescriptor();
62cdf0e10cSrcweir 
63cdf0e10cSrcweir             int category = n / 2;
64cdf0e10cSrcweir             inCat =(CategoryMem == category)? ++inCat: 1;
65cdf0e10cSrcweir             CategoryMem = category;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir             //System.out.println("Category" + category + "Number" + inCat);
68cdf0e10cSrcweir             m_Categories[n].ProgrammaticName = "Category" + category;
69cdf0e10cSrcweir             m_Categories[n].UIName = "Category" + category + "Number" + inCat;
70cdf0e10cSrcweir             m_Categories[n].HelpURL = "h:" + n;
71cdf0e10cSrcweir         }
72cdf0e10cSrcweir     }
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     /**
75cdf0e10cSrcweir      * returns the catrgories
76cdf0e10cSrcweir      * @return returns the catrgories
77cdf0e10cSrcweir      */
describeCategories()78cdf0e10cSrcweir     public PropertyCategoryDescriptor[] describeCategories() {
79cdf0e10cSrcweir         return m_Categories;
80cdf0e10cSrcweir     }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     /**
83cdf0e10cSrcweir      * returns currently nothing
84cdf0e10cSrcweir      * @return nothing
85cdf0e10cSrcweir      */
getHandlerFactories()86cdf0e10cSrcweir     public Object[] getHandlerFactories() {
87cdf0e10cSrcweir         return null;
88cdf0e10cSrcweir     }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     /** determines whether the object inspector should have a help section
91cdf0e10cSrcweir         @return false
92cdf0e10cSrcweir     */
getHasHelpSection()93cdf0e10cSrcweir     public boolean getHasHelpSection() {
94cdf0e10cSrcweir         return false;
95cdf0e10cSrcweir     }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     /** returns minimum number of lines in the help text section.
98cdf0e10cSrcweir         @return 3
99cdf0e10cSrcweir     */
getMinHelpTextLines()100cdf0e10cSrcweir     public int getMinHelpTextLines() {
101cdf0e10cSrcweir         return 3;
102*170fb961SPedro Giffuni     }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     /** returns maximum number of lines in the help text section.
105cdf0e10cSrcweir         @return 8
106cdf0e10cSrcweir     */
getMaxHelpTextLines()107cdf0e10cSrcweir     public int getMaxHelpTextLines() {
108cdf0e10cSrcweir         return 8;
109*170fb961SPedro Giffuni     }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     /** returns whether or not the inspector's UI should be read-only
112cdf0e10cSrcweir     */
getIsReadOnly()113cdf0e10cSrcweir     public boolean getIsReadOnly() {
114cdf0e10cSrcweir         return false;
115cdf0e10cSrcweir     }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     /** sets the inspector's read-only state
118cdf0e10cSrcweir     */
setIsReadOnly( boolean _IsReadOnly )119cdf0e10cSrcweir     public void setIsReadOnly( boolean _IsReadOnly ) {
120cdf0e10cSrcweir         // not supported, and not used so far in our test cases
121cdf0e10cSrcweir     }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     /**
124cdf0e10cSrcweir      * retrieves an index in a global property ordering, for a given property name
125cdf0e10cSrcweir      * @param UIName the property whose global order index should be retrieved
126cdf0e10cSrcweir      * @throws com.sun.star.beans.UnknownPropertyException if the given property is unknown
127cdf0e10cSrcweir      * @return the global order index of PropertyName
128cdf0e10cSrcweir      */
getPropertyOrderIndex(String UIName)129cdf0e10cSrcweir     public int getPropertyOrderIndex(String UIName) {
130cdf0e10cSrcweir         int index = 0;
131cdf0e10cSrcweir         for (int n=0; n < m_Categories.length; n++){
132cdf0e10cSrcweir             if (m_Categories[n].UIName.equals(UIName)){
133cdf0e10cSrcweir                 index = n;
134cdf0e10cSrcweir                 break;
135cdf0e10cSrcweir             }
136cdf0e10cSrcweir         }
137cdf0e10cSrcweir         return index;
138cdf0e10cSrcweir     }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir  }
141