bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / xoutdev / xtabcolr.cxx
blobb4628c68d404d2be6ba61be3ccb75c57838cb100
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "svx/XPropertyTable.hxx"
22 #include <unotools/pathoptions.hxx>
24 #include <svx/dialogs.hrc>
25 #include <svx/dialmgr.hxx>
26 #include <svx/xtable.hxx>
27 #include <svx/xpool.hxx>
29 using namespace com::sun::star;
32 XColorListRef XColorList::CreateStdColorList()
34 return XPropertyList::CreatePropertyList(
35 XCOLOR_LIST, SvtPathOptions().GetPalettePath() )->AsColorList();
38 XColorListRef XColorList::GetStdColorList()
40 static XColorListRef aTable( CreateStdColorList() );
41 return aTable;
44 XColorEntry* XColorList::Replace(long nIndex, XColorEntry* pEntry )
46 return (XColorEntry*)XPropertyList::Replace( pEntry, nIndex );
49 XColorEntry* XColorList::Remove(long nIndex)
51 return (XColorEntry*) XPropertyList::Remove(nIndex);
54 XColorEntry* XColorList::GetColor(long nIndex) const
56 return (XColorEntry*) XPropertyList::Get(nIndex, 0);
59 uno::Reference< container::XNameContainer > XColorList::createInstance()
61 return uno::Reference< container::XNameContainer >(
62 SvxUnoXColorTable_createInstance( this ),
63 uno::UNO_QUERY );
66 sal_Bool XColorList::Create()
68 XubString aStr;
69 xub_StrLen nLen;
70 ResMgr& rRes = DIALOG_MGR();
72 static sal_uInt16 aResId[] =
74 RID_SVXSTR_BLACK,
75 RID_SVXSTR_BLUE,
76 RID_SVXSTR_GREEN,
77 RID_SVXSTR_CYAN,
78 RID_SVXSTR_RED,
79 RID_SVXSTR_MAGENTA,
80 RID_SVXSTR_BROWN,
81 RID_SVXSTR_GREY,
82 RID_SVXSTR_LIGHTGREY,
83 RID_SVXSTR_LIGHTBLUE,
84 RID_SVXSTR_LIGHTGREEN,
85 RID_SVXSTR_LIGHTCYAN,
86 RID_SVXSTR_LIGHTRED,
87 RID_SVXSTR_LIGHTMAGENTA,
88 RID_SVXSTR_YELLOW,
89 RID_SVXSTR_WHITE
92 // MT: COL_XXX ist in VCL kein enum mehr!!!
93 // COL_WHITE ist seeeehr gross! ( => Zugriff ueber das obige Array hinweg )
94 // Mit der unteren Schleife gibt es keinen Absturtz, aber es ist
95 // alles schwarz, weil alles kleine Werte.
96 // Ausserdem ist die ganze Vorgehensweise laut MM sehr unperformant
97 // => lieber gleich Stringlisten laden.
99 // BM: ifndef VCL part removed (deprecated)
101 static ColorData const aColTab[] =
103 COL_BLACK,
104 COL_BLUE,
105 COL_GREEN,
106 COL_CYAN,
107 COL_RED,
108 COL_MAGENTA,
109 COL_BROWN,
110 COL_GRAY,
111 COL_LIGHTGRAY,
112 COL_LIGHTBLUE,
113 COL_LIGHTGREEN,
114 COL_LIGHTCYAN,
115 COL_LIGHTRED,
116 COL_LIGHTMAGENTA,
117 COL_YELLOW,
118 COL_WHITE
121 for( sal_uInt16 n = 0; n < 16; ++n )
123 Insert( new XColorEntry(
124 Color( aColTab[n] ),
125 String( ResId( aResId[ n ], rRes ) )
131 aStr = SVX_RESSTR( RID_SVXSTR_GREY );
132 aStr.AppendAscii(" 80%");
133 nLen = aStr.Len() - 3;
134 Insert( new XColorEntry( Color( 51, 51, 51 ), aStr ), 16 );
135 aStr.SetChar(nLen, sal_Unicode('7'));
136 Insert( new XColorEntry( Color( 76, 76, 76 ), aStr ), 17 );
137 aStr.SetChar(nLen, sal_Unicode('6'));
138 Insert( new XColorEntry( Color(102,102,102 ), aStr ), 18 );
139 aStr.SetChar(nLen, sal_Unicode('4'));
140 Insert( new XColorEntry( Color(153,153,153 ), aStr ), 19 );
141 aStr.SetChar(nLen, sal_Unicode('3'));
142 Insert( new XColorEntry( Color(179,179,179 ), aStr ), 20 );
143 aStr.SetChar(nLen, sal_Unicode('2'));
144 Insert( new XColorEntry( Color(204,204,204 ), aStr ), 21 );
145 // BM: new 15%
146 aStr.SetChar(nLen, sal_Unicode('1'));
147 aStr.SetChar(nLen + 1, sal_Unicode('5'));
148 Insert( new XColorEntry( Color(217,217,217 ), aStr ), 22 );
149 aStr.SetChar(nLen + 1, sal_Unicode('0'));
150 Insert( new XColorEntry( Color(230,230,230 ), aStr ), 23 );
151 Insert( new XColorEntry( Color(230,230,255 ), SVX_RESSTR( RID_SVXSTR_BLUEGREY ) ), 24 );
153 aStr = SVX_RESSTR( RID_SVXSTR_RED );
154 aStr.AppendAscii(" 1");
155 nLen = aStr.Len() - 1;
156 Insert( new XColorEntry( Color(255, 51,102 ), aStr ), 25 );
157 aStr.SetChar(nLen, sal_Unicode('2'));
158 Insert( new XColorEntry( Color(220, 35, 0 ), aStr ), 26 );
159 aStr.SetChar(nLen, sal_Unicode('3'));
160 Insert( new XColorEntry( Color(184, 71, 0 ), aStr ), 27 );
161 aStr.SetChar(nLen, sal_Unicode('4'));
162 Insert( new XColorEntry( Color(255, 51, 51 ), aStr ), 28 );
163 aStr.SetChar(nLen, sal_Unicode('5'));
164 Insert( new XColorEntry( Color(235, 97, 61 ), aStr ), 29 );
165 aStr.SetChar(nLen, sal_Unicode('6'));
166 Insert( new XColorEntry( Color(184, 71, 71 ), aStr ), 30 );
167 aStr.SetChar(nLen, sal_Unicode('7'));
168 Insert( new XColorEntry( Color(184, 0, 71 ), aStr ), 31 );
169 aStr.SetChar(nLen, sal_Unicode('8'));
170 Insert( new XColorEntry( Color(153, 40, 76 ), aStr ), 32 );
172 aStr = SVX_RESSTR( RID_SVXSTR_MAGENTA );
173 aStr.AppendAscii(" 1");
174 nLen = aStr.Len() - 1;
175 Insert( new XColorEntry( Color(148, 0,107 ), aStr ), 33 );
176 aStr.SetChar(nLen, sal_Unicode('2'));
177 Insert( new XColorEntry( Color(148, 71,107 ), aStr ), 34 );
178 aStr.SetChar(nLen, sal_Unicode('3'));
179 Insert( new XColorEntry( Color(148, 71,148 ), aStr ), 35 );
180 aStr.SetChar(nLen, sal_Unicode('4'));
181 Insert( new XColorEntry( Color(153,102,204 ), aStr ), 36 );
182 aStr.SetChar(nLen, sal_Unicode('5'));
183 Insert( new XColorEntry( Color(107, 71,148 ), aStr ), 37 );
184 aStr.SetChar(nLen, sal_Unicode('6'));
185 Insert( new XColorEntry( Color(107, 35,148 ), aStr ), 38 );
186 aStr.SetChar(nLen, sal_Unicode('7'));
187 Insert( new XColorEntry( Color(107, 0,148 ), aStr ), 39 );
188 aStr.SetChar(nLen, sal_Unicode('8'));
189 Insert( new XColorEntry( Color( 94, 17,166 ), aStr ), 40 );
191 aStr = SVX_RESSTR( RID_SVXSTR_BLUE );
192 aStr.AppendAscii(" 1");
193 nLen = aStr.Len() - 1;
194 Insert( new XColorEntry( Color( 40, 0,153 ), aStr ), 41 );
195 aStr.SetChar(nLen, sal_Unicode('2'));
196 Insert( new XColorEntry( Color( 71, 0,184 ), aStr ), 42 );
197 aStr.SetChar(nLen, sal_Unicode('3'));
198 Insert( new XColorEntry( Color( 35, 0,220 ), aStr ), 43 );
199 aStr.SetChar(nLen, sal_Unicode('4'));
200 Insert( new XColorEntry( Color( 35, 35,220 ), aStr ), 44 );
201 aStr.SetChar(nLen, sal_Unicode('5'));
202 Insert( new XColorEntry( Color( 0, 71,255 ), aStr ), 45 );
203 aStr.SetChar(nLen, sal_Unicode('6'));
204 Insert( new XColorEntry( Color( 0,153,255 ), aStr ), 46 );
205 aStr.SetChar(nLen, sal_Unicode('7'));
206 Insert( new XColorEntry( Color( 0,184,255 ), aStr ), 47 );
207 aStr.SetChar(nLen, sal_Unicode('8'));
208 Insert( new XColorEntry( Color(153,204,255 ), aStr ), 48 );
210 aStr = SVX_RESSTR( RID_SVXSTR_CYAN );
211 aStr.AppendAscii(" 1");
212 nLen = aStr.Len() - 1;
213 Insert( new XColorEntry( Color( 0,220,255 ), aStr ), 49 );
214 aStr.SetChar(nLen, sal_Unicode('2'));
215 Insert( new XColorEntry( Color( 0,204,204 ), aStr ), 50 );
216 aStr.SetChar(nLen, sal_Unicode('3'));
217 Insert( new XColorEntry( Color( 35,184,220 ), aStr ), 51 );
218 aStr.SetChar(nLen, sal_Unicode('4'));
219 Insert( new XColorEntry( Color( 71,184,184 ), aStr ), 52 );
220 aStr.SetChar(nLen, sal_Unicode('5'));
221 Insert( new XColorEntry( Color( 51,163,163 ), aStr ), 53 );
222 aStr.SetChar(nLen, sal_Unicode('6'));
223 Insert( new XColorEntry( Color( 25,138,138 ), aStr ), 54 );
224 aStr.SetChar(nLen, sal_Unicode('7'));
225 Insert( new XColorEntry( Color( 0,107,107 ), aStr ), 55 );
226 aStr.SetChar(nLen, sal_Unicode('8'));
227 Insert( new XColorEntry( Color( 0, 74, 74 ), aStr ), 56 );
229 aStr = SVX_RESSTR( RID_SVXSTR_GREEN );
230 aStr.AppendAscii(" 1");
231 nLen = aStr.Len() - 1;
232 Insert( new XColorEntry( Color( 53, 94, 0 ), aStr ), 57 );
233 aStr.SetChar(nLen, sal_Unicode('2'));
234 Insert( new XColorEntry( Color( 92,133, 38 ), aStr ), 58 );
235 aStr.SetChar(nLen, sal_Unicode('3'));
236 Insert( new XColorEntry( Color(125,166, 71 ), aStr ), 59 );
237 aStr.SetChar(nLen, sal_Unicode('4'));
238 Insert( new XColorEntry( Color(148,189, 94 ), aStr ), 60 );
239 aStr.SetChar(nLen, sal_Unicode('5'));
240 Insert( new XColorEntry( Color( 0,174, 0 ), aStr ), 61 );
241 aStr.SetChar(nLen, sal_Unicode('6'));
242 Insert( new XColorEntry( Color( 51,204,102 ), aStr ), 62 );
243 aStr.SetChar(nLen, sal_Unicode('7'));
244 Insert( new XColorEntry( Color( 61,235, 61 ), aStr ), 63 );
245 aStr.SetChar(nLen, sal_Unicode('8'));
246 Insert( new XColorEntry( Color( 35,255, 35 ), aStr ), 64 );
248 aStr = SVX_RESSTR( RID_SVXSTR_YELLOW );
249 aStr.AppendAscii(" 1");
250 nLen = aStr.Len() - 1;
251 Insert( new XColorEntry( Color(230,255, 0 ), aStr ), 65 );
252 aStr.SetChar(nLen, sal_Unicode('2'));
253 Insert( new XColorEntry( Color(255,255,153 ), aStr ), 66 );
254 aStr.SetChar(nLen, sal_Unicode('3'));
255 Insert( new XColorEntry( Color(255,255,102 ), aStr ), 67 );
256 aStr.SetChar(nLen, sal_Unicode('4'));
257 Insert( new XColorEntry( Color(230,230, 76 ), aStr ), 68 );
258 aStr.SetChar(nLen, sal_Unicode('5'));
259 Insert( new XColorEntry( Color(204,204, 0 ), aStr ), 69 );
260 aStr.SetChar(nLen, sal_Unicode('6'));
261 Insert( new XColorEntry( Color(179,179, 0 ), aStr ), 70 );
262 aStr.SetChar(nLen, sal_Unicode('7'));
263 Insert( new XColorEntry( Color(128,128, 25 ), aStr ), 71 );
264 aStr.SetChar(nLen, sal_Unicode('8'));
265 Insert( new XColorEntry( Color(102,102, 0 ), aStr ), 72 );
267 aStr = SVX_RESSTR( RID_SVXSTR_BROWN );
268 aStr.AppendAscii(" 1");
269 nLen = aStr.Len() - 1;
270 Insert( new XColorEntry( Color( 76, 25, 0 ), aStr ), 73 );
271 aStr.SetChar(nLen, sal_Unicode('2'));
272 Insert( new XColorEntry( Color(102, 51, 0 ), aStr ), 74 );
273 aStr.SetChar(nLen, sal_Unicode('3'));
274 Insert( new XColorEntry( Color(128, 76, 25 ), aStr ), 75 );
275 aStr.SetChar(nLen, sal_Unicode('4'));
276 Insert( new XColorEntry( Color(153,102, 51 ), aStr ), 76 );
278 aStr = SVX_RESSTR( RID_SVXSTR_ORANGE );
279 aStr.AppendAscii(" 1");
280 nLen = aStr.Len() - 1;
281 Insert( new XColorEntry( Color(204,102, 51 ), aStr ), 77 );
282 aStr.SetChar(nLen, sal_Unicode('2'));
283 Insert( new XColorEntry( Color(255,102, 51 ), aStr ), 78 );
284 aStr.SetChar(nLen, sal_Unicode('3'));
285 Insert( new XColorEntry( Color(255,153,102 ), aStr ), 79 );
286 aStr.SetChar(nLen, sal_Unicode('4'));
287 Insert( new XColorEntry( Color(255,204,153 ), aStr ), 80 );
289 // new chart colors
290 aStr = SVX_RESSTR( RID_SVXSTR_VIOLET );
291 Insert( new XColorEntry( Color( 0x99, 0x99, 0xff ), aStr ), 81 );
293 aStr = SVX_RESSTR( RID_SVXSTR_BORDEAUX );
294 Insert( new XColorEntry( Color( 0x99, 0x33, 0x66 ), aStr ), 82 );
296 aStr = SVX_RESSTR( RID_SVXSTR_PALE_YELLOW );
297 Insert( new XColorEntry( Color( 0xff, 0xff, 0xcc ), aStr ), 83 );
299 aStr = SVX_RESSTR( RID_SVXSTR_PALE_GREEN );
300 Insert( new XColorEntry( Color( 0xcc, 0xff, 0xff ), aStr ), 84 );
302 aStr = SVX_RESSTR( RID_SVXSTR_DKVIOLET );
303 Insert( new XColorEntry( Color( 0x66, 0x00, 0x66 ), aStr ), 85 );
305 aStr = SVX_RESSTR( RID_SVXSTR_SALMON );
306 Insert( new XColorEntry( Color( 0xff, 0x80, 0x80 ), aStr ), 86 );
308 aStr = SVX_RESSTR( RID_SVXSTR_SEABLUE );
309 Insert( new XColorEntry( Color( 0x00, 0x66, 0xcc ), aStr ), 87 );
311 // Sun colors
312 aStr = SVX_RESSTR( RID_SVXSTR_COLOR_SUN );
313 aStr.AppendAscii(" 1");
314 nLen = aStr.Len() - 1;
315 Insert( new XColorEntry( Color( 0x33, 0x33, 0x66 ), aStr ), 88 );
316 aStr.SetChar(nLen, sal_Unicode('2'));
317 Insert( new XColorEntry( Color( 0x66, 0x66, 0x99 ), aStr ), 89 );
318 aStr.SetChar(nLen, sal_Unicode('3'));
319 Insert( new XColorEntry( Color( 0x99, 0x99, 0xcc ), aStr ), 90 );
320 aStr.SetChar(nLen, sal_Unicode('4'));
321 Insert( new XColorEntry( Color( 0xcc, 0xcc, 0xff ), aStr ), 91 );
323 // Chart default colors
324 aStr = SVX_RESSTR( RID_SVXSTR_COLOR_CHART );
325 aStr.AppendAscii(" 1");
326 nLen = aStr.Len() - 1;
327 Insert( new XColorEntry( Color( 0x00, 0x45, 0x86 ), aStr ), 92 );
328 aStr.SetChar(nLen, sal_Unicode('2'));
329 Insert( new XColorEntry( Color( 0xff, 0x42, 0x0e ), aStr ), 93 );
330 aStr.SetChar(nLen, sal_Unicode('3'));
331 Insert( new XColorEntry( Color( 0xff, 0xd3, 0x20 ), aStr ), 94 );
332 aStr.SetChar(nLen, sal_Unicode('4'));
333 Insert( new XColorEntry( Color( 0x57, 0x9d, 0x1c ), aStr ), 95 );
334 aStr.SetChar(nLen, sal_Unicode('5'));
335 Insert( new XColorEntry( Color( 0x7e, 0x00, 0x21 ), aStr ), 96 );
336 aStr.SetChar(nLen, sal_Unicode('6'));
337 Insert( new XColorEntry( Color( 0x83, 0xca, 0xff ), aStr ), 97 );
338 aStr.SetChar(nLen, sal_Unicode('7'));
339 Insert( new XColorEntry( Color( 0x31, 0x40, 0x04 ), aStr ), 98 );
340 aStr.SetChar(nLen, sal_Unicode('8'));
341 Insert( new XColorEntry( Color( 0xae, 0xcf, 0x00 ), aStr ), 99 );
342 aStr.SetChar(nLen, sal_Unicode('9'));
343 Insert( new XColorEntry( Color( 0x4b, 0x1f, 0x6f ), aStr ), 100 );
344 aStr.SetChar(nLen, sal_Unicode('1'));
345 aStr.AppendAscii("0");
346 nLen = aStr.Len() - 1;
347 Insert( new XColorEntry( Color( 0xff, 0x95, 0x0e ), aStr ), 101 );
348 aStr.SetChar(nLen, sal_Unicode('1'));
349 Insert( new XColorEntry( Color( 0xc5, 0x00, 0x0b ), aStr ), 102 );
350 aStr.SetChar(nLen, sal_Unicode('2'));
351 Insert( new XColorEntry( Color( 0x00, 0x84, 0xd1 ), aStr ), 103 );
353 return Count() == 104;
356 Bitmap XColorList::CreateBitmapForUI( long /*nIndex*/ )
358 return Bitmap();
361 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */