1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DGColorNameLookUp.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVX_ACCESSIBILITY_DG_COLOR_NAME_LOOK_UP_HXX
32 #define _SVX_ACCESSIBILITY_DG_COLOR_NAME_LOOK_UP_HXX
34 #include <rtl/ustrbuf.hxx>
37 namespace accessibility
{
39 /** This is a color name lookup targeted to be used by the accessibility
40 <type>DescriptionGenerator</type> class (hence the DG prefix). It
41 encapsulates a <type>com.sun.star.drawing.ColorTable</type> and provides
42 an inverse look up of color names for given a numerical color
43 descriptions--the RGB values encoded as integer.
45 <p>The class itself is designed as singleton so that the
46 <type>com.sun.star.drawing.ColorTable</type> object needs to be created
49 <p>The singleton instance of this class lives at the moment until the
50 application terminates. However, the color table from which it takes
51 its values may change during this time. Reacting to these changes
52 remains a task for the future.</p>
54 class DGColorNameLookUp
57 /** Return the single instance of this class. Use this to look up
58 color names with the <member>LookUpColor()</member> method.
60 static DGColorNameLookUp
& Instance (void);
62 /** Return the color name of the color expressed by the given integer.
64 This integer is the sum of the 8 Bit red value shifted left 16
65 Bits, the green value shifted left 8 Bits, and the unshifted
68 The returned string is either the color name of the specified
69 color or, when no name exists, a string of the form "#RRGGBB"
70 with two hexadecimal digits for each color component.
72 ::rtl::OUString
LookUpColor (long int nColor
) const;
75 /// Define hash map type to convert numerical color values to names.
76 typedef std::hash_map
<long int, ::rtl::OUString
>
79 /// This ma translates from numerical color values to names.
80 tColorValueToNameMap maColorValueToNameMap
;
82 /** The pointer to the only instance of this class. It is NULL until
83 the <member>Instance</member> is called for the first time.
85 static DGColorNameLookUp
* mpInstance
;
87 /// Create a new (the only) instance of this class.
88 DGColorNameLookUp (void);
90 /// The destructor is never called.
91 ~DGColorNameLookUp (void);
93 /// The copy constructor is not implemented.
94 DGColorNameLookUp (const DGColorNameLookUp
&);
96 /// The assignment operator is not implemented.
97 DGColorNameLookUp
& operator= (const DGColorNameLookUp
&);
100 } // end of namespace accessibility