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 #ifndef _SVX_ACCESSIBILITY_DG_COLOR_NAME_LOOK_UP_HXX 29 #define _SVX_ACCESSIBILITY_DG_COLOR_NAME_LOOK_UP_HXX 30 31 #include <rtl/ustrbuf.hxx> 32 #include <hash_map> 33 34 namespace accessibility { 35 36 /** This is a color name lookup targeted to be used by the accessibility 37 <type>DescriptionGenerator</type> class (hence the DG prefix). It 38 encapsulates a <type>com.sun.star.drawing.ColorTable</type> and provides 39 an inverse look up of color names for given a numerical color 40 descriptions--the RGB values encoded as integer. 41 42 <p>The class itself is designed as singleton so that the 43 <type>com.sun.star.drawing.ColorTable</type> object needs to be created 44 only once.</p> 45 46 <p>The singleton instance of this class lives at the moment until the 47 application terminates. However, the color table from which it takes 48 its values may change during this time. Reacting to these changes 49 remains a task for the future.</p> 50 */ 51 class DGColorNameLookUp 52 { 53 public: 54 /** Return the single instance of this class. Use this to look up 55 color names with the <member>LookUpColor()</member> method. 56 */ 57 static DGColorNameLookUp& Instance (void); 58 59 /** Return the color name of the color expressed by the given integer. 60 @param nColor 61 This integer is the sum of the 8 Bit red value shifted left 16 62 Bits, the green value shifted left 8 Bits, and the unshifted 63 blue value. 64 @return 65 The returned string is either the color name of the specified 66 color or, when no name exists, a string of the form "#RRGGBB" 67 with two hexadecimal digits for each color component. 68 */ 69 ::rtl::OUString LookUpColor (long int nColor) const; 70 71 private: 72 /// Define hash map type to convert numerical color values to names. 73 typedef std::hash_map<long int, ::rtl::OUString> 74 tColorValueToNameMap; 75 76 /// This ma translates from numerical color values to names. 77 tColorValueToNameMap maColorValueToNameMap; 78 79 /** The pointer to the only instance of this class. It is NULL until 80 the <member>Instance</member> is called for the first time. 81 */ 82 static DGColorNameLookUp* mpInstance; 83 84 /// Create a new (the only) instance of this class. 85 DGColorNameLookUp (void); 86 87 /// The destructor is never called. 88 ~DGColorNameLookUp (void); 89 90 /// The copy constructor is not implemented. 91 DGColorNameLookUp (const DGColorNameLookUp&); 92 93 /// The assignment operator is not implemented. 94 DGColorNameLookUp& operator= (const DGColorNameLookUp&); 95 }; 96 97 } // end of namespace accessibility 98 99 #endif 100