LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svtools/source/config - colorcfg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 169 234 72.2 %
Date: 2013-07-09 Functions: 26 42 61.9 %
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 <svtools/colorcfg.hxx>
      22             : #include <com/sun/star/uno/Any.hxx>
      23             : #include <com/sun/star/uno/Sequence.hxx>
      24             : #include <com/sun/star/lang/Locale.hpp>
      25             : #include <com/sun/star/beans/PropertyValue.hpp>
      26             : #include <unotools/configitem.hxx>
      27             : #include <unotools/configpaths.hxx>
      28             : #include <com/sun/star/uno/Sequence.h>
      29             : #include <svl/poolitem.hxx> //Any2Bool
      30             : #include <svl/smplhint.hxx>
      31             : #include <osl/mutex.hxx>
      32             : 
      33             : #include <itemholder2.hxx>
      34             : 
      35             :  /* #100822# ----
      36             : #include <vcl/wrkwin.hxx>
      37             :  ------------- */
      38             : #include <vcl/svapp.hxx>
      39             : #include <vcl/event.hxx>
      40             : #include <rtl/instance.hxx>
      41             : 
      42             : //-----------------------------------------------------------------------------
      43             : using namespace utl;
      44             : using namespace com::sun::star;
      45             : 
      46             : 
      47             : namespace svtools
      48             : {
      49             : 
      50             : static const sal_Char cColor[] = "/Color";
      51             : static const sal_Char cColorSchemes[] = "ColorSchemes/";
      52             : sal_Int32            nColorRefCount_Impl = 0;
      53             : namespace
      54             : {
      55             :     struct ColorMutex_Impl
      56             :         : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {};
      57             : }
      58             : 
      59             : ColorConfig_Impl*    ColorConfig::m_pImpl = NULL;
      60             : 
      61             : class ColorConfig_Impl : public utl::ConfigItem
      62             : {
      63             :     ColorConfigValue    m_aConfigValues[ColorConfigEntryCount];
      64             :     sal_Bool            m_bEditMode;
      65             :     OUString       m_sIsVisible;
      66             :     OUString       m_sLoadedScheme;
      67             : 
      68             :     uno::Sequence< OUString> GetPropertyNames(const OUString& rScheme);
      69             : public:
      70             :     ColorConfig_Impl(sal_Bool bEditMode = sal_False);
      71             :     virtual ~ColorConfig_Impl();
      72             : 
      73             :     void                            Load(const OUString& rScheme);
      74             :     void                            CommitCurrentSchemeName();
      75             :     //changes the name of the current scheme but doesn't load it!
      76           0 :     void                            SetCurrentSchemeName(const OUString& rSchemeName) {m_sLoadedScheme = rSchemeName;}
      77             :     virtual void                    Commit();
      78             :     virtual void                    Notify( const uno::Sequence<OUString>& aPropertyNames);
      79             : 
      80       63857 :     const ColorConfigValue&         GetColorConfigValue(ColorConfigEntry eValue)
      81       63857 :                                                             {return m_aConfigValues[eValue];}
      82             :     void                            SetColorConfigValue(ColorConfigEntry eValue,
      83             :                                                             const ColorConfigValue& rValue );
      84             : 
      85           0 :     const OUString&            GetLoadedScheme() const {return m_sLoadedScheme;}
      86             : 
      87             :     uno::Sequence< OUString> GetSchemeNames();
      88             : 
      89             :     sal_Bool                        AddScheme(const OUString& rNode);
      90             :     sal_Bool                        RemoveScheme(const OUString& rNode);
      91          24 :     void                            SetModified(){ConfigItem::SetModified();}
      92          12 :     void                            ClearModified(){ConfigItem::ClearModified();}
      93             :     void                            SettingsChanged();
      94             : 
      95             :     // #100822#
      96             :     DECL_LINK( DataChangedEventListener, VclWindowEvent* );
      97             : 
      98             :     void ImplUpdateApplicationSettings();
      99             : };
     100             : 
     101         116 : uno::Sequence< OUString> ColorConfig_Impl::GetPropertyNames(const OUString& rScheme)
     102             : {
     103         116 :     uno::Sequence<OUString> aNames(2 * ColorConfigEntryCount);
     104         116 :     OUString* pNames = aNames.getArray();
     105             :     struct ColorConfigEntryData_Impl
     106             :     {
     107             :         const sal_Char* cName;
     108             :         sal_Int32       nLength;
     109             :         rtl_TextEncoding eEncoding;
     110             :         sal_Bool bCanBeVisible;
     111             :     };
     112             :     static const ColorConfigEntryData_Impl cNames[] =
     113             :     {
     114             :         { RTL_CONSTASCII_USTRINGPARAM("/DocColor")        ,sal_False },
     115             :         { RTL_CONSTASCII_USTRINGPARAM("/DocBoundaries")   ,sal_True },
     116             :         { RTL_CONSTASCII_USTRINGPARAM("/AppBackground")   ,sal_False },
     117             :         { RTL_CONSTASCII_USTRINGPARAM("/ObjectBoundaries"),sal_True },
     118             :         { RTL_CONSTASCII_USTRINGPARAM("/TableBoundaries") ,sal_True },
     119             :         { RTL_CONSTASCII_USTRINGPARAM("/FontColor")     ,sal_False },
     120             :         { RTL_CONSTASCII_USTRINGPARAM("/Links")           ,sal_True },
     121             :         { RTL_CONSTASCII_USTRINGPARAM("/LinksVisited")    ,sal_True },
     122             :         { RTL_CONSTASCII_USTRINGPARAM("/Spell")     ,sal_False },
     123             :         { RTL_CONSTASCII_USTRINGPARAM("/SmartTags")     ,sal_False },
     124             :         { RTL_CONSTASCII_USTRINGPARAM("/Shadow")        , sal_True },
     125             :         { RTL_CONSTASCII_USTRINGPARAM("/WriterTextGrid")  ,sal_False },
     126             :         { RTL_CONSTASCII_USTRINGPARAM("/WriterFieldShadings"),sal_True },
     127             :         { RTL_CONSTASCII_USTRINGPARAM("/WriterIdxShadings")     ,sal_True },
     128             :         { RTL_CONSTASCII_USTRINGPARAM("/WriterDirectCursor")    ,sal_True },
     129             :         { RTL_CONSTASCII_USTRINGPARAM("/WriterScriptIndicator")    ,sal_False },
     130             :         { RTL_CONSTASCII_USTRINGPARAM("/WriterSectionBoundaries")    ,sal_True },
     131             :         { RTL_CONSTASCII_USTRINGPARAM("/WriterHeaderFooterMark")    ,sal_False },
     132             :         { RTL_CONSTASCII_USTRINGPARAM("/WriterPageBreaks")    ,sal_False },
     133             :         { RTL_CONSTASCII_USTRINGPARAM("/HTMLSGML")        ,sal_False },
     134             :         { RTL_CONSTASCII_USTRINGPARAM("/HTMLComment")     ,sal_False },
     135             :         { RTL_CONSTASCII_USTRINGPARAM("/HTMLKeyword")     ,sal_False },
     136             :         { RTL_CONSTASCII_USTRINGPARAM("/HTMLUnknown")     ,sal_False },
     137             :         { RTL_CONSTASCII_USTRINGPARAM("/CalcGrid")        ,sal_False },
     138             :         { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreak"), sal_False },
     139             :         { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreakManual"), sal_False },
     140             :         { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreakAutomatic"), sal_False },
     141             :         { RTL_CONSTASCII_USTRINGPARAM("/CalcDetective")   ,sal_False },
     142             :         { RTL_CONSTASCII_USTRINGPARAM("/CalcDetectiveError")   ,sal_False },
     143             :         { RTL_CONSTASCII_USTRINGPARAM("/CalcReference")   ,sal_False },
     144             :         { RTL_CONSTASCII_USTRINGPARAM("/CalcNotesBackground") ,sal_False },
     145             :         { RTL_CONSTASCII_USTRINGPARAM("/DrawGrid")        ,sal_True },
     146             :         { RTL_CONSTASCII_USTRINGPARAM("/BASICIdentifier"),  sal_False },
     147             :         { RTL_CONSTASCII_USTRINGPARAM("/BASICComment")   ,  sal_False },
     148             :         { RTL_CONSTASCII_USTRINGPARAM("/BASICNumber")    ,  sal_False },
     149             :         { RTL_CONSTASCII_USTRINGPARAM("/BASICString")    ,  sal_False },
     150             :         { RTL_CONSTASCII_USTRINGPARAM("/BASICOperator")  ,  sal_False },
     151             :         { RTL_CONSTASCII_USTRINGPARAM("/BASICKeyword")   ,  sal_False },
     152             :         { RTL_CONSTASCII_USTRINGPARAM("/BASICError"),  sal_False },
     153             :         { RTL_CONSTASCII_USTRINGPARAM("/SQLIdentifier"),  sal_False },
     154             :         { RTL_CONSTASCII_USTRINGPARAM("/SQLNumber"),  sal_False },
     155             :         { RTL_CONSTASCII_USTRINGPARAM("/SQLString"),  sal_False },
     156             :         { RTL_CONSTASCII_USTRINGPARAM("/SQLOperator"),  sal_False },
     157             :         { RTL_CONSTASCII_USTRINGPARAM("/SQLKeyword"),  sal_False },
     158             :         { RTL_CONSTASCII_USTRINGPARAM("/SQLParameter"),  sal_False },
     159             :         { RTL_CONSTASCII_USTRINGPARAM("/SQLComment"),  sal_False }
     160             :     };
     161         116 :     int nIndex = 0;
     162         232 :     OUString sColor = cColor;
     163         232 :     OUString sBase(cColorSchemes);
     164         116 :     sBase += utl::wrapConfigurationElementName(rScheme);
     165         116 :     const int nCount = ColorConfigEntryCount;
     166        5452 :     for(sal_Int32 i = 0; i < 4 * nCount; i+= 4)
     167             :     {
     168        5336 :         OUString sBaseName(sBase);
     169        5336 :         sal_Int32 nPos = i / 4;
     170        5336 :         sBaseName += OUString(cNames[nPos].cName, cNames[nPos].nLength, cNames[nPos].eEncoding);
     171        5336 :         pNames[nIndex] += sBaseName;
     172        5336 :         pNames[nIndex++] += sColor;
     173        5336 :         if(cNames[nPos].bCanBeVisible)
     174             :         {
     175        1276 :             pNames[nIndex] += sBaseName;
     176        1276 :             pNames[nIndex++] += m_sIsVisible;
     177             :         }
     178        5336 :     }
     179         116 :     aNames.realloc(nIndex);
     180         232 :     return aNames;
     181             : }
     182             : 
     183          80 : ColorConfig_Impl::ColorConfig_Impl(sal_Bool bEditMode) :
     184             :     ConfigItem("Office.UI/ColorScheme"),
     185             :     m_bEditMode(bEditMode),
     186          80 :     m_sIsVisible("/IsVisible")
     187             : {
     188          80 :     if(!m_bEditMode)
     189             :     {
     190             :         //try to register on the root node - if possible
     191          80 :         uno::Sequence < OUString > aNames(1);
     192          80 :         EnableNotification( aNames );
     193             :     }
     194          80 :     Load(OUString());
     195             : 
     196          80 :     ImplUpdateApplicationSettings();
     197             : 
     198             :     // #100822#
     199          80 :     ::Application::AddEventListener( LINK(this, ColorConfig_Impl, DataChangedEventListener) );
     200             : 
     201          80 : }
     202             : 
     203         135 : ColorConfig_Impl::~ColorConfig_Impl()
     204             : {
     205             :     // #100822#
     206          45 :     ::Application::RemoveEventListener( LINK(this, ColorConfig_Impl, DataChangedEventListener) );
     207          90 : }
     208             : 
     209         104 : void ColorConfig_Impl::Load(const OUString& rScheme)
     210             : {
     211         104 :     OUString sScheme(rScheme);
     212         104 :     if(sScheme.isEmpty())
     213             :     {
     214             :         //detect current scheme name
     215         104 :         uno::Sequence < OUString > aCurrent(1);
     216         104 :         aCurrent.getArray()[0] = "CurrentColorScheme";
     217         208 :         uno::Sequence< uno::Any > aCurrentVal = GetProperties( aCurrent );
     218         208 :         aCurrentVal.getConstArray()[0] >>= sScheme;
     219             :     }
     220         104 :     m_sLoadedScheme = sScheme;
     221             :     //
     222         208 :     uno::Sequence < OUString > aColorNames = GetPropertyNames(sScheme);
     223         208 :     uno::Sequence< uno::Any > aColors = GetProperties( aColorNames );
     224         104 :     const uno::Any* pColors = aColors.getConstArray();
     225         104 :     const OUString* pColorNames = aColorNames.getConstArray();
     226         104 :     sal_Int32 nIndex = 0;
     227        4784 :     for(int i = 0; i < 2 * ColorConfigEntryCount && aColors.getLength() > nIndex; i+= 2)
     228             :     {
     229        4784 :         if(pColors[nIndex].hasValue())
     230           0 :             pColors[nIndex] >>= m_aConfigValues[i / 2].nColor;
     231             :         else
     232        4784 :             m_aConfigValues[i/2].nColor = COL_AUTO;
     233        4784 :         nIndex++;
     234        4784 :         if(nIndex >= aColors.getLength())
     235         104 :             break;
     236             :         //test for visibility property
     237        4680 :         if(pColorNames[nIndex].match(m_sIsVisible, pColorNames[nIndex].getLength() - m_sIsVisible.getLength()))
     238        1144 :              m_aConfigValues[i / 2].bIsVisible = Any2Bool(pColors[nIndex++]);
     239         104 :     }
     240         104 : }
     241             : 
     242          24 : void    ColorConfig_Impl::Notify( const uno::Sequence<OUString>& )
     243             : {
     244             :     //loading via notification always uses the default setting
     245          24 :     Load(OUString());
     246          24 :     NotifyListeners(0);
     247          24 : }
     248             : 
     249          12 : void ColorConfig_Impl::Commit()
     250             : {
     251          12 :     uno::Sequence < OUString > aColorNames = GetPropertyNames(m_sLoadedScheme);
     252          24 :     uno::Sequence < beans::PropertyValue > aPropValues(aColorNames.getLength());
     253          12 :     beans::PropertyValue* pPropValues = aPropValues.getArray();
     254          12 :     const OUString* pColorNames = aColorNames.getConstArray();
     255          12 :     sal_Int32 nIndex = 0;
     256          12 :     const uno::Type& rBoolType = ::getBooleanCppuType();
     257         552 :     for(int i = 0; i < 2 * ColorConfigEntryCount && aColorNames.getLength() > nIndex; i+= 2)
     258             :     {
     259         552 :         pPropValues[nIndex].Name = pColorNames[nIndex];
     260             :         //save automatic colors as void value
     261         552 :         if(COL_AUTO != sal::static_int_cast<ColorData>(m_aConfigValues[i/2].nColor))
     262           0 :             pPropValues[nIndex].Value <<= m_aConfigValues[i/2].nColor;
     263             : 
     264         552 :         nIndex++;
     265         552 :         if(nIndex >= aColorNames.getLength())
     266          12 :             break;
     267             :         //test for visibility property
     268         540 :         if(pColorNames[nIndex].match(m_sIsVisible, pColorNames[nIndex].getLength() - m_sIsVisible.getLength()))
     269             :         {
     270         132 :              pPropValues[nIndex].Name = pColorNames[nIndex];
     271         132 :              pPropValues[nIndex].Value.setValue(&m_aConfigValues[i/2].bIsVisible, rBoolType);
     272         132 :              nIndex++;
     273             :         }
     274             :     }
     275          24 :     OUString sNode("ColorSchemes");
     276          12 :     SetSetProperties(sNode, aPropValues);
     277             : 
     278          24 :     CommitCurrentSchemeName();
     279          12 : }
     280             : 
     281          12 : void ColorConfig_Impl::CommitCurrentSchemeName()
     282             : {
     283             :     //save current scheme name
     284          12 :     uno::Sequence < OUString > aCurrent(1);
     285          12 :     aCurrent.getArray()[0] = "CurrentColorScheme";
     286          24 :     uno::Sequence< uno::Any > aCurrentVal(1);
     287          12 :     aCurrentVal.getArray()[0] <<= m_sLoadedScheme;
     288          24 :     PutProperties(aCurrent, aCurrentVal);
     289          12 : }
     290             : 
     291          12 : void ColorConfig_Impl::SetColorConfigValue(ColorConfigEntry eValue, const ColorConfigValue& rValue )
     292             : {
     293          12 :     if(rValue != m_aConfigValues[eValue])
     294             :     {
     295          12 :         m_aConfigValues[eValue] = rValue;
     296          12 :         SetModified();
     297             :     }
     298          12 : }
     299             : 
     300           0 : uno::Sequence< OUString> ColorConfig_Impl::GetSchemeNames()
     301             : {
     302           0 :     return GetNodeNames("ColorSchemes");
     303             : }
     304             : 
     305           0 : sal_Bool ColorConfig_Impl::AddScheme(const OUString& rScheme)
     306             : {
     307           0 :     if(ConfigItem::AddNode("ColorSchemes", rScheme))
     308             :     {
     309           0 :         m_sLoadedScheme = rScheme;
     310           0 :         Commit();
     311           0 :         return sal_True;
     312             :     }
     313           0 :     return sal_False;
     314             : }
     315             : 
     316           0 : sal_Bool ColorConfig_Impl::RemoveScheme(const OUString& rScheme)
     317             : {
     318           0 :     uno::Sequence< OUString > aElements(1);
     319           0 :     aElements.getArray()[0] = rScheme;
     320           0 :     return ClearNodeElements("ColorSchemes", aElements);
     321             : }
     322             : 
     323           0 : void ColorConfig_Impl::SettingsChanged()
     324             : {
     325           0 :     SolarMutexGuard aVclGuard;
     326             : 
     327           0 :     ImplUpdateApplicationSettings();
     328             : 
     329           0 :     NotifyListeners(0);
     330           0 : }
     331             : 
     332     2179112 : IMPL_LINK( ColorConfig_Impl, DataChangedEventListener, VclWindowEvent*, pEvent )
     333             : {
     334     1089556 :     if ( pEvent->GetId() == VCLEVENT_APPLICATION_DATACHANGED )
     335             :     {
     336           4 :         DataChangedEvent* pData = (DataChangedEvent*)(pEvent->GetData());
     337           8 :         if ( (pData->GetType() == DATACHANGED_SETTINGS) &&
     338           4 :              (pData->GetFlags() & SETTINGS_STYLE) )
     339             :         {
     340           0 :             SettingsChanged();
     341           0 :             return 1L;
     342             :         } else
     343           4 :             return 0L;
     344             :     } else
     345     1089552 :         return 0L;
     346             : }
     347             : 
     348             : // ---------------------------------------------------------------------------
     349             : 
     350             : /** updates the font color in the vcl window settings */
     351          80 : void ColorConfig_Impl::ImplUpdateApplicationSettings()
     352             : {
     353          80 :     Application* pApp = GetpApp();
     354          80 :     if( pApp )
     355             :     {
     356          80 :         AllSettings aSettings = pApp->GetSettings();
     357         160 :         StyleSettings aStyleSettings( aSettings.GetStyleSettings() );
     358             : 
     359          80 :         ColorConfigValue aRet = GetColorConfigValue(svtools::FONTCOLOR);
     360          80 :         if(COL_AUTO == sal::static_int_cast<ColorData>(aRet.nColor))
     361          80 :             aRet.nColor = ColorConfig::GetDefaultColor(svtools::FONTCOLOR).GetColor();
     362             : 
     363          80 :         Color aFontColor(aRet.nColor);
     364             : 
     365          80 :         if( aStyleSettings.GetFontColor() != aFontColor )
     366             :         {
     367           0 :             aStyleSettings.SetFontColor( aFontColor );
     368             : 
     369           0 :             aSettings.SetStyleSettings( aStyleSettings );
     370           0 :             pApp->SetSettings( aSettings );
     371          80 :         }
     372             :     }
     373          80 : }
     374             : 
     375             : // ---------------------------------------------------------------------------
     376             : 
     377        9494 : ColorConfig::ColorConfig()
     378             : {
     379        9494 :     ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
     380        9494 :     if ( !m_pImpl )
     381             :     {
     382          68 :         m_pImpl = new ColorConfig_Impl;
     383          68 :         svtools::ItemHolder2::holdConfigItem(E_COLORCFG);
     384             :     }
     385        9494 :     ++nColorRefCount_Impl;
     386        9494 :     m_pImpl->AddListener(this);
     387        9494 : }
     388             : 
     389       19273 : ColorConfig::~ColorConfig()
     390             : {
     391        9428 :     ::osl::MutexGuard aGuard( ColorMutex_Impl::get() );
     392        9428 :     m_pImpl->RemoveListener(this);
     393        9428 :     if(!--nColorRefCount_Impl)
     394             :     {
     395          33 :         delete m_pImpl;
     396          33 :         m_pImpl = 0;
     397        9428 :     }
     398        9845 : }
     399             : 
     400       62812 : Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry)
     401             : {
     402             :     static const sal_Int32 aAutoColors[] =
     403             :     {
     404             :         COL_WHITE, // DOCCOLOR
     405             :         0xc0c0c0, // DOCBOUNDARIES
     406             :         0x808080, // APPBACKGROUND
     407             :         0xc0c0c0, // OBJECTBOUNDARIES
     408             :         0xc0c0c0, // TABLEBOUNDARIES
     409             :         COL_BLACK, // FONTCOLOR
     410             :         0xcc, // LINKS
     411             :         0x80, // LINKSVISITED
     412             :         0xff0000, // SPELL
     413             :         COL_LIGHTMAGENTA,// SMARTTAGS
     414             :         COL_GRAY, // SHADOWCOLOR
     415             :         0xc0c0c0, // WRITERTEXTGRID
     416             :         0xc0c0c0, // WRITERFIELDSHADIN
     417             :         0xc0c0c0, // WRITERIDXSHADINGS
     418             :         0, // WRITERDIRECTCURSOR
     419             :         COL_GREEN,  //WRITERSCRIPTINDICATOR
     420             :         0xc0c0c0, //WRITERSECTIONBOUNDARIES
     421             :         0x0369a3, //WRITERHEADERFOOTERMARK,
     422             :         COL_BLUE, //WRITERPAGEBREAKS,
     423             :         COL_LIGHTBLUE, // HTMLSGML
     424             :         COL_LIGHTGREEN, // HTMLCOMMENT
     425             :         COL_LIGHTRED, // HTMLKEYWORD
     426             :         COL_GRAY, // HTMLUNKNOWN
     427             :         COL_LIGHTGRAY, // CALCGRID
     428             :         COL_BLUE, //CALCPAGEBREAK
     429             :         0x2300dc, //CALCPAGEBREAKMANUAL
     430             :         COL_GRAY, //CALCPAGEBREAKAUTOMATIC
     431             :         COL_LIGHTBLUE, // CALCDETECTIVE
     432             :         COL_LIGHTRED, // CALCDETECTIVEERROR
     433             :         COL_LIGHTRED, // CALCREFERENCE
     434             :         0xffffc0, // CALCNOTESBACKGROUND
     435             :         0xc0c0c0, // DRAWGRID
     436             :         COL_GREEN, // BASICIDENTIFIER,
     437             :         COL_GRAY,// BASICCOMMENT   ,
     438             :         COL_LIGHTRED,// BASICNUMBER    ,
     439             :         COL_LIGHTRED,// BASICSTRING    ,
     440             :         COL_BLUE, // BASICOPERATOR  ,
     441             :         COL_BLUE, // BASICKEYWORD   ,
     442             :         COL_RED, //BASICERROR
     443             :         0x009900, // SQLIDENTIFIER
     444             :         0x000000, // SQLNUMBER
     445             :         0xCE7B00, // SQLSTRING
     446             :         0x000000, // SQLOPERATOR
     447             :         0x0000E6, // SQLKEYWORD
     448             :         0x259D9D, // SQLPARAMTER
     449             :         0x969696,// SQLCOMMENT
     450             :     };
     451       62812 :     Color aRet;
     452       62812 :     switch(eEntry)
     453             :     {
     454             :         case APPBACKGROUND :
     455        1702 :             aRet = Application::GetSettings().GetStyleSettings().GetWorkspaceColor();
     456        1702 :             break;
     457             : 
     458             :         case LINKS :
     459          80 :             aRet = Application::GetSettings().GetStyleSettings().GetLinkColor();
     460          80 :             break;
     461             : 
     462             :         case LINKSVISITED :
     463          57 :             aRet = Application::GetSettings().GetStyleSettings().GetVisitedLinkColor();
     464          57 :             break;
     465             : 
     466             :         default:
     467       60973 :             aRet = aAutoColors[eEntry];
     468             :     }
     469       62812 :     return aRet;
     470             : }
     471             : 
     472       63765 : ColorConfigValue ColorConfig::GetColorValue(ColorConfigEntry eEntry, sal_Bool bSmart)const
     473             : {
     474       63765 :     ColorConfigValue aRet = m_pImpl->GetColorConfigValue(eEntry);
     475       63765 :     if(bSmart)
     476             :     {
     477       62622 :         if(COL_AUTO == sal::static_int_cast<ColorData>(aRet.nColor))
     478       62622 :             aRet.nColor = ColorConfig::GetDefaultColor(eEntry).GetColor();
     479             :     }
     480             : 
     481       63765 :     return aRet;
     482             : }
     483             : 
     484          12 : EditableColorConfig::EditableColorConfig() :
     485          12 :     m_pImpl(new ColorConfig_Impl),
     486          24 :     m_bModified(sal_False)
     487             : {
     488          12 :     m_pImpl->BlockBroadcasts(sal_True);
     489          12 : }
     490             : 
     491          12 : EditableColorConfig::~EditableColorConfig()
     492             : {
     493          12 :     m_pImpl->BlockBroadcasts(sal_False);
     494          12 :     if(m_bModified)
     495          12 :         m_pImpl->SetModified();
     496          12 :     if(m_pImpl->IsModified())
     497          12 :         m_pImpl->Commit();
     498          12 :     delete m_pImpl;
     499          12 : }
     500             : 
     501           0 : uno::Sequence< OUString >  EditableColorConfig::GetSchemeNames() const
     502             : {
     503           0 :     return m_pImpl->GetSchemeNames();
     504             : }
     505             : 
     506           0 : void EditableColorConfig::DeleteScheme(const OUString& rScheme )
     507             : {
     508           0 :     m_pImpl->RemoveScheme(rScheme);
     509           0 : }
     510             : 
     511           0 : void EditableColorConfig::AddScheme(const OUString& rScheme )
     512             : {
     513           0 :     m_pImpl->AddScheme(rScheme);
     514           0 : }
     515             : 
     516           0 : sal_Bool EditableColorConfig::LoadScheme(const OUString& rScheme )
     517             : {
     518           0 :     if(m_bModified)
     519           0 :         m_pImpl->SetModified();
     520           0 :     if(m_pImpl->IsModified())
     521           0 :         m_pImpl->Commit();
     522           0 :     m_bModified = sal_False;
     523           0 :     m_pImpl->Load(rScheme);
     524             :     //the name of the loaded scheme has to be committed separately
     525           0 :     m_pImpl->CommitCurrentSchemeName();
     526           0 :     return sal_True;
     527             : }
     528             : 
     529           0 : const OUString& EditableColorConfig::GetCurrentSchemeName()const
     530             : {
     531           0 :     return m_pImpl->GetLoadedScheme();
     532             : }
     533             : 
     534             : // Changes the name of the current scheme but doesn't load it!
     535           0 : void EditableColorConfig::SetCurrentSchemeName(const OUString& rScheme)
     536             : {
     537           0 :     m_pImpl->SetCurrentSchemeName(rScheme);
     538           0 :     m_pImpl->CommitCurrentSchemeName();
     539           0 : }
     540             : 
     541          12 : const ColorConfigValue& EditableColorConfig::GetColorValue(
     542             :     ColorConfigEntry eEntry)const
     543             : {
     544          12 :     return m_pImpl->GetColorConfigValue(eEntry);
     545             : }
     546             : 
     547          12 : void EditableColorConfig::SetColorValue(
     548             :     ColorConfigEntry eEntry, const ColorConfigValue& rValue)
     549             : {
     550          12 :     m_pImpl->SetColorConfigValue(eEntry, rValue);
     551          12 :     m_pImpl->ClearModified();
     552          12 :     m_bModified = sal_True;
     553          12 : }
     554             : 
     555           0 : void EditableColorConfig::SetModified()
     556             : {
     557           0 :     m_bModified = sal_True;
     558           0 : }
     559             : 
     560           0 : void EditableColorConfig::Commit()
     561             : {
     562           0 :     if(m_bModified)
     563           0 :         m_pImpl->SetModified();
     564           0 :     if(m_pImpl->IsModified())
     565           0 :         m_pImpl->Commit();
     566           0 :     m_bModified = sal_False;
     567           0 : }
     568             : // -----------------------------------------------------------------------------
     569           0 : void EditableColorConfig::DisableBroadcast()
     570             : {
     571           0 :     m_pImpl->BlockBroadcasts(sal_True);
     572           0 : }
     573             : // -----------------------------------------------------------------------------
     574           0 : void EditableColorConfig::EnableBroadcast()
     575             : {
     576           0 :     m_pImpl->BlockBroadcasts(sal_False);
     577           0 : }
     578             : // -----------------------------------------------------------------------------
     579             : 
     580         465 : }//namespace svtools
     581             : 
     582             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10