LCOV - code coverage report
Current view: top level - libreoffice/svx/source/xoutdev - xtabcolr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 226 3.1 %
Date: 2012-12-27 Functions: 3 9 33.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include "svx/XPropertyTable.hxx"
      22             : #include <unotools/pathoptions.hxx>
      23             : 
      24             : #include <svx/dialogs.hrc>
      25             : #include <svx/dialmgr.hxx>
      26             : #include <svx/xtable.hxx>
      27             : #include <svx/xpool.hxx>
      28             : 
      29             : using namespace com::sun::star;
      30             : 
      31             : 
      32          14 : XColorListRef XColorList::CreateStdColorList()
      33             : {
      34             :     return XPropertyList::CreatePropertyList(
      35          14 :         XCOLOR_LIST, SvtPathOptions().GetPalettePath() )->AsColorList();
      36             : }
      37             : 
      38         400 : XColorListRef XColorList::GetStdColorList()
      39             : {
      40         400 :     static XColorListRef aTable( CreateStdColorList() );
      41         400 :     return aTable;
      42             : }
      43             : 
      44           0 : XColorEntry* XColorList::Replace(long nIndex, XColorEntry* pEntry )
      45             : {
      46           0 :     return (XColorEntry*)XPropertyList::Replace( pEntry, nIndex );
      47             : }
      48             : 
      49           0 : XColorEntry* XColorList::Remove(long nIndex)
      50             : {
      51           0 :     return (XColorEntry*) XPropertyList::Remove(nIndex);
      52             : }
      53             : 
      54           0 : XColorEntry* XColorList::GetColor(long nIndex) const
      55             : {
      56           0 :     return (XColorEntry*) XPropertyList::Get(nIndex, 0);
      57             : }
      58             : 
      59           2 : uno::Reference< container::XNameContainer > XColorList::createInstance()
      60             : {
      61             :     return uno::Reference< container::XNameContainer >(
      62             :         SvxUnoXColorTable_createInstance( this ),
      63           2 :         uno::UNO_QUERY );
      64             : }
      65             : 
      66           0 : sal_Bool XColorList::Create()
      67             : {
      68           0 :     XubString aStr;
      69             :     xub_StrLen nLen;
      70           0 :     ResMgr& rRes = DIALOG_MGR();
      71             : 
      72             :     static sal_uInt16 aResId[] =
      73             :     {
      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
      90             :     };
      91             : 
      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.
      98             : 
      99             :     // BM: ifndef VCL part removed (deprecated)
     100             : 
     101             :     static ColorData const aColTab[] =
     102             :     {
     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
     119             :     };
     120             : 
     121           0 :     for( sal_uInt16 n = 0; n < 16; ++n )
     122             :     {
     123             :         Insert( new XColorEntry(
     124           0 :                     Color( aColTab[n] ),
     125           0 :                     String( ResId( aResId[ n ], rRes ) )
     126           0 :                 ),
     127             :                 n
     128           0 :         );
     129             :     }
     130             : 
     131           0 :     aStr = SVX_RESSTR( RID_SVXSTR_GREY );
     132           0 :     aStr.AppendAscii(" 80%");
     133           0 :     nLen = aStr.Len() - 3;
     134           0 :     Insert( new XColorEntry( Color( 51, 51, 51 ), aStr ), 16 );
     135           0 :     aStr.SetChar(nLen, sal_Unicode('7'));
     136           0 :     Insert( new XColorEntry( Color( 76, 76, 76 ), aStr ), 17 );
     137           0 :     aStr.SetChar(nLen, sal_Unicode('6'));
     138           0 :     Insert( new XColorEntry( Color(102,102,102 ), aStr ), 18 );
     139           0 :     aStr.SetChar(nLen, sal_Unicode('4'));
     140           0 :     Insert( new XColorEntry( Color(153,153,153 ), aStr ), 19 );
     141           0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     142           0 :     Insert( new XColorEntry( Color(179,179,179 ), aStr ), 20 );
     143           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     144           0 :     Insert( new XColorEntry( Color(204,204,204 ), aStr ), 21 );
     145             :     // BM: new 15%
     146           0 :     aStr.SetChar(nLen, sal_Unicode('1'));
     147           0 :     aStr.SetChar(nLen + 1, sal_Unicode('5'));
     148           0 :     Insert( new XColorEntry( Color(217,217,217 ), aStr ), 22 );
     149           0 :     aStr.SetChar(nLen + 1, sal_Unicode('0'));
     150           0 :     Insert( new XColorEntry( Color(230,230,230 ), aStr ), 23 );
     151           0 :     Insert( new XColorEntry( Color(230,230,255 ), SVX_RESSTR( RID_SVXSTR_BLUEGREY ) ), 24 );
     152             : 
     153           0 :     aStr = SVX_RESSTR( RID_SVXSTR_RED );
     154           0 :     aStr.AppendAscii(" 1");
     155           0 :     nLen = aStr.Len() - 1;
     156           0 :     Insert( new XColorEntry( Color(255, 51,102 ), aStr ), 25 );
     157           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     158           0 :     Insert( new XColorEntry( Color(220, 35,  0 ), aStr ), 26 );
     159           0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     160           0 :     Insert( new XColorEntry( Color(184, 71,  0 ), aStr ), 27 );
     161           0 :     aStr.SetChar(nLen, sal_Unicode('4'));
     162           0 :     Insert( new XColorEntry( Color(255, 51, 51 ), aStr ), 28 );
     163           0 :     aStr.SetChar(nLen, sal_Unicode('5'));
     164           0 :     Insert( new XColorEntry( Color(235, 97, 61 ), aStr ), 29 );
     165           0 :     aStr.SetChar(nLen, sal_Unicode('6'));
     166           0 :     Insert( new XColorEntry( Color(184, 71, 71 ), aStr ), 30 );
     167           0 :     aStr.SetChar(nLen, sal_Unicode('7'));
     168           0 :     Insert( new XColorEntry( Color(184,  0, 71 ), aStr ), 31 );
     169           0 :     aStr.SetChar(nLen, sal_Unicode('8'));
     170           0 :     Insert( new XColorEntry( Color(153, 40, 76 ), aStr ), 32 );
     171             : 
     172           0 :     aStr = SVX_RESSTR( RID_SVXSTR_MAGENTA );
     173           0 :     aStr.AppendAscii(" 1");
     174           0 :     nLen = aStr.Len() - 1;
     175           0 :     Insert( new XColorEntry( Color(148,  0,107 ), aStr ), 33 );
     176           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     177           0 :     Insert( new XColorEntry( Color(148, 71,107 ), aStr ), 34 );
     178           0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     179           0 :     Insert( new XColorEntry( Color(148, 71,148 ), aStr ), 35 );
     180           0 :     aStr.SetChar(nLen, sal_Unicode('4'));
     181           0 :     Insert( new XColorEntry( Color(153,102,204 ), aStr ), 36 );
     182           0 :     aStr.SetChar(nLen, sal_Unicode('5'));
     183           0 :     Insert( new XColorEntry( Color(107, 71,148 ), aStr ), 37 );
     184           0 :     aStr.SetChar(nLen, sal_Unicode('6'));
     185           0 :     Insert( new XColorEntry( Color(107, 35,148 ), aStr ), 38 );
     186           0 :     aStr.SetChar(nLen, sal_Unicode('7'));
     187           0 :     Insert( new XColorEntry( Color(107,  0,148 ), aStr ), 39 );
     188           0 :     aStr.SetChar(nLen, sal_Unicode('8'));
     189           0 :     Insert( new XColorEntry( Color( 94, 17,166 ), aStr ), 40 );
     190             : 
     191           0 :     aStr = SVX_RESSTR( RID_SVXSTR_BLUE );
     192           0 :     aStr.AppendAscii(" 1");
     193           0 :     nLen = aStr.Len() - 1;
     194           0 :     Insert( new XColorEntry( Color( 40,  0,153 ), aStr ), 41 );
     195           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     196           0 :     Insert( new XColorEntry( Color( 71,  0,184 ), aStr ), 42 );
     197           0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     198           0 :     Insert( new XColorEntry( Color( 35,  0,220 ), aStr ), 43 );
     199           0 :     aStr.SetChar(nLen, sal_Unicode('4'));
     200           0 :     Insert( new XColorEntry( Color( 35, 35,220 ), aStr ), 44 );
     201           0 :     aStr.SetChar(nLen, sal_Unicode('5'));
     202           0 :     Insert( new XColorEntry( Color(  0, 71,255 ), aStr ), 45 );
     203           0 :     aStr.SetChar(nLen, sal_Unicode('6'));
     204           0 :     Insert( new XColorEntry( Color(  0,153,255 ), aStr ), 46 );
     205           0 :     aStr.SetChar(nLen, sal_Unicode('7'));
     206           0 :     Insert( new XColorEntry( Color(  0,184,255 ), aStr ), 47 );
     207           0 :     aStr.SetChar(nLen, sal_Unicode('8'));
     208           0 :     Insert( new XColorEntry( Color(153,204,255 ), aStr ), 48 );
     209             : 
     210           0 :     aStr = SVX_RESSTR( RID_SVXSTR_CYAN );
     211           0 :     aStr.AppendAscii(" 1");
     212           0 :     nLen = aStr.Len() - 1;
     213           0 :     Insert( new XColorEntry( Color(  0,220,255 ), aStr ), 49 );
     214           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     215           0 :     Insert( new XColorEntry( Color(  0,204,204 ), aStr ), 50 );
     216           0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     217           0 :     Insert( new XColorEntry( Color( 35,184,220 ), aStr ), 51 );
     218           0 :     aStr.SetChar(nLen, sal_Unicode('4'));
     219           0 :     Insert( new XColorEntry( Color( 71,184,184 ), aStr ), 52 );
     220           0 :     aStr.SetChar(nLen, sal_Unicode('5'));
     221           0 :     Insert( new XColorEntry( Color( 51,163,163 ), aStr ), 53 );
     222           0 :     aStr.SetChar(nLen, sal_Unicode('6'));
     223           0 :     Insert( new XColorEntry( Color( 25,138,138 ), aStr ), 54 );
     224           0 :     aStr.SetChar(nLen, sal_Unicode('7'));
     225           0 :     Insert( new XColorEntry( Color(  0,107,107 ), aStr ), 55 );
     226           0 :     aStr.SetChar(nLen, sal_Unicode('8'));
     227           0 :     Insert( new XColorEntry( Color(  0, 74, 74 ), aStr ), 56 );
     228             : 
     229           0 :     aStr = SVX_RESSTR( RID_SVXSTR_GREEN );
     230           0 :     aStr.AppendAscii(" 1");
     231           0 :     nLen = aStr.Len() - 1;
     232           0 :     Insert( new XColorEntry( Color( 53, 94,  0 ), aStr ), 57 );
     233           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     234           0 :     Insert( new XColorEntry( Color( 92,133, 38 ), aStr ), 58 );
     235           0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     236           0 :     Insert( new XColorEntry( Color(125,166, 71 ), aStr ), 59 );
     237           0 :     aStr.SetChar(nLen, sal_Unicode('4'));
     238           0 :     Insert( new XColorEntry( Color(148,189, 94 ), aStr ), 60 );
     239           0 :     aStr.SetChar(nLen, sal_Unicode('5'));
     240           0 :     Insert( new XColorEntry( Color(  0,174,  0 ), aStr ), 61 );
     241           0 :     aStr.SetChar(nLen, sal_Unicode('6'));
     242           0 :     Insert( new XColorEntry( Color( 51,204,102 ), aStr ), 62 );
     243           0 :     aStr.SetChar(nLen, sal_Unicode('7'));
     244           0 :     Insert( new XColorEntry( Color( 61,235, 61 ), aStr ), 63 );
     245           0 :     aStr.SetChar(nLen, sal_Unicode('8'));
     246           0 :     Insert( new XColorEntry( Color( 35,255, 35 ), aStr ), 64 );
     247             : 
     248           0 :     aStr = SVX_RESSTR( RID_SVXSTR_YELLOW );
     249           0 :     aStr.AppendAscii(" 1");
     250           0 :     nLen = aStr.Len() - 1;
     251           0 :     Insert( new XColorEntry( Color(230,255,  0 ), aStr ), 65 );
     252           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     253           0 :     Insert( new XColorEntry( Color(255,255,153 ), aStr ), 66 );
     254           0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     255           0 :     Insert( new XColorEntry( Color(255,255,102 ), aStr ), 67 );
     256           0 :     aStr.SetChar(nLen, sal_Unicode('4'));
     257           0 :     Insert( new XColorEntry( Color(230,230, 76 ), aStr ), 68 );
     258           0 :     aStr.SetChar(nLen, sal_Unicode('5'));
     259           0 :     Insert( new XColorEntry( Color(204,204,  0 ), aStr ), 69 );
     260           0 :     aStr.SetChar(nLen, sal_Unicode('6'));
     261           0 :     Insert( new XColorEntry( Color(179,179,  0 ), aStr ), 70 );
     262           0 :     aStr.SetChar(nLen, sal_Unicode('7'));
     263           0 :     Insert( new XColorEntry( Color(128,128, 25 ), aStr ), 71 );
     264           0 :     aStr.SetChar(nLen, sal_Unicode('8'));
     265           0 :     Insert( new XColorEntry( Color(102,102,  0 ), aStr ), 72 );
     266             : 
     267           0 :     aStr = SVX_RESSTR( RID_SVXSTR_BROWN );
     268           0 :     aStr.AppendAscii(" 1");
     269           0 :     nLen = aStr.Len() - 1;
     270           0 :     Insert( new XColorEntry( Color( 76, 25,  0 ), aStr ), 73 );
     271           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     272           0 :     Insert( new XColorEntry( Color(102, 51,  0 ), aStr ), 74 );
     273           0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     274           0 :     Insert( new XColorEntry( Color(128, 76, 25 ), aStr ), 75 );
     275           0 :     aStr.SetChar(nLen, sal_Unicode('4'));
     276           0 :     Insert( new XColorEntry( Color(153,102, 51 ), aStr ), 76 );
     277             : 
     278           0 :     aStr = SVX_RESSTR( RID_SVXSTR_ORANGE );
     279           0 :     aStr.AppendAscii(" 1");
     280           0 :     nLen = aStr.Len() - 1;
     281           0 :     Insert( new XColorEntry( Color(204,102, 51 ), aStr ), 77 );
     282           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     283           0 :     Insert( new XColorEntry( Color(255,102, 51 ), aStr ), 78 );
     284           0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     285           0 :     Insert( new XColorEntry( Color(255,153,102 ), aStr ), 79 );
     286           0 :     aStr.SetChar(nLen, sal_Unicode('4'));
     287           0 :     Insert( new XColorEntry( Color(255,204,153 ), aStr ), 80 );
     288             : 
     289             :     // new chart colors
     290           0 :     aStr = SVX_RESSTR( RID_SVXSTR_VIOLET );
     291           0 :     Insert( new XColorEntry( Color( 0x99, 0x99, 0xff ), aStr ), 81 );
     292             : 
     293           0 :     aStr = SVX_RESSTR( RID_SVXSTR_BORDEAUX );
     294           0 :     Insert( new XColorEntry( Color( 0x99, 0x33, 0x66 ), aStr ), 82 );
     295             : 
     296           0 :     aStr = SVX_RESSTR( RID_SVXSTR_PALE_YELLOW );
     297           0 :     Insert( new XColorEntry( Color( 0xff, 0xff, 0xcc ), aStr ), 83 );
     298             : 
     299           0 :     aStr = SVX_RESSTR( RID_SVXSTR_PALE_GREEN );
     300           0 :     Insert( new XColorEntry( Color( 0xcc, 0xff, 0xff ), aStr ), 84 );
     301             : 
     302           0 :     aStr = SVX_RESSTR( RID_SVXSTR_DKVIOLET );
     303           0 :     Insert( new XColorEntry( Color( 0x66, 0x00, 0x66 ), aStr ), 85 );
     304             : 
     305           0 :     aStr = SVX_RESSTR( RID_SVXSTR_SALMON );
     306           0 :     Insert( new XColorEntry( Color( 0xff, 0x80, 0x80 ), aStr ), 86 );
     307             : 
     308           0 :     aStr = SVX_RESSTR( RID_SVXSTR_SEABLUE );
     309           0 :     Insert( new XColorEntry( Color( 0x00, 0x66, 0xcc ), aStr ), 87 );
     310             : 
     311             :     // Sun colors
     312           0 :     aStr = SVX_RESSTR( RID_SVXSTR_COLOR_SUN );
     313           0 :     aStr.AppendAscii(" 1");
     314           0 :     nLen = aStr.Len() - 1;
     315           0 :     Insert( new XColorEntry( Color( 0x33, 0x33, 0x66 ), aStr ), 88 );
     316           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     317           0 :     Insert( new XColorEntry( Color( 0x66, 0x66, 0x99 ), aStr ), 89 );
     318           0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     319           0 :     Insert( new XColorEntry( Color( 0x99, 0x99, 0xcc ), aStr ), 90 );
     320           0 :     aStr.SetChar(nLen, sal_Unicode('4'));
     321           0 :     Insert( new XColorEntry( Color( 0xcc, 0xcc, 0xff ), aStr ), 91 );
     322             : 
     323             :     // Chart default colors
     324           0 :     aStr = SVX_RESSTR( RID_SVXSTR_COLOR_CHART );
     325           0 :     aStr.AppendAscii(" 1");
     326           0 :     nLen = aStr.Len() - 1;
     327           0 :     Insert( new XColorEntry( Color( 0x00, 0x45, 0x86 ), aStr ), 92 );
     328           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     329           0 :     Insert( new XColorEntry( Color( 0xff, 0x42, 0x0e ), aStr ), 93 );
     330           0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     331           0 :     Insert( new XColorEntry( Color( 0xff, 0xd3, 0x20 ), aStr ), 94 );
     332           0 :     aStr.SetChar(nLen, sal_Unicode('4'));
     333           0 :     Insert( new XColorEntry( Color( 0x57, 0x9d, 0x1c ), aStr ), 95 );
     334           0 :     aStr.SetChar(nLen, sal_Unicode('5'));
     335           0 :     Insert( new XColorEntry( Color( 0x7e, 0x00, 0x21 ), aStr ), 96 );
     336           0 :     aStr.SetChar(nLen, sal_Unicode('6'));
     337           0 :     Insert( new XColorEntry( Color( 0x83, 0xca, 0xff ), aStr ), 97 );
     338           0 :     aStr.SetChar(nLen, sal_Unicode('7'));
     339           0 :     Insert( new XColorEntry( Color( 0x31, 0x40, 0x04 ), aStr ), 98 );
     340           0 :     aStr.SetChar(nLen, sal_Unicode('8'));
     341           0 :     Insert( new XColorEntry( Color( 0xae, 0xcf, 0x00 ), aStr ), 99 );
     342           0 :     aStr.SetChar(nLen, sal_Unicode('9'));
     343           0 :     Insert( new XColorEntry( Color( 0x4b, 0x1f, 0x6f ), aStr ), 100 );
     344           0 :     aStr.SetChar(nLen, sal_Unicode('1'));
     345           0 :     aStr.AppendAscii("0");
     346           0 :     nLen = aStr.Len() - 1;
     347           0 :     Insert( new XColorEntry( Color( 0xff, 0x95, 0x0e ), aStr ), 101 );
     348           0 :     aStr.SetChar(nLen, sal_Unicode('1'));
     349           0 :     Insert( new XColorEntry( Color( 0xc5, 0x00, 0x0b ), aStr ), 102 );
     350           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     351           0 :     Insert( new XColorEntry( Color( 0x00, 0x84, 0xd1 ), aStr ), 103 );
     352             : 
     353           0 :     return Count() == 104;
     354             : }
     355             : 
     356           0 : sal_Bool XColorList::CreateBitmapsForUI()
     357             : {
     358           0 :     return sal_False;
     359             : }
     360             : 
     361           0 : Bitmap* XColorList::CreateBitmapForUI( long /*nIndex*/, sal_Bool /*bDelete*/)
     362             : {
     363           0 :     return NULL;
     364             : }
     365             : 
     366             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10