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