LCOV - code coverage report
Current view: top level - cui/source/tabpages - tpcolor.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 666 0.0 %
Date: 2012-08-25 Functions: 0 55 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1428 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <tools/shl.hxx>
      30                 :            : #include <tools/urlobj.hxx>
      31                 :            : #include <unotools/pathoptions.hxx>
      32                 :            : #include <sfx2/app.hxx>
      33                 :            : #include <sfx2/module.hxx>
      34                 :            : #include <sfx2/objsh.hxx>
      35                 :            : #include <sfx2/viewsh.hxx>
      36                 :            : #include <sfx2/viewfrm.hxx>
      37                 :            : #include <sfx2/dispatch.hxx>
      38                 :            : #include <svtools/colrdlg.hxx>
      39                 :            : #include <vcl/msgbox.hxx>
      40                 :            : #include <sfx2/filedlghelper.hxx>
      41                 :            : #include <svx/ofaitem.hxx>
      42                 :            : #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
      43                 :            : 
      44                 :            : #define _SVX_TPCOLOR_CXX
      45                 :            : 
      46                 :            : #include <cuires.hrc>
      47                 :            : #include "helpid.hrc"
      48                 :            : #include "svx/xattr.hxx"
      49                 :            : #include <svx/xpool.hxx>
      50                 :            : #include <svx/xtable.hxx>
      51                 :            : #include "svx/drawitem.hxx"
      52                 :            : #include "cuitabarea.hxx"
      53                 :            : #include "tabarea.hrc"
      54                 :            : #include "defdlgname.hxx"
      55                 :            : #include <svx/svxdlg.hxx>
      56                 :            : #include <dialmgr.hxx>
      57                 :            : #include <cuitabline.hxx>
      58                 :            : #include <svx/dialmgr.hxx>
      59                 :            : #include <svx/dialogs.hrc>
      60                 :            : 
      61                 :            : namespace css = ::com::sun::star;
      62                 :            : 
      63                 :            : 
      64                 :            : // Load save embed functionality
      65                 :          0 : SvxLoadSaveEmbed::SvxLoadSaveEmbed( Window *pParent, Window *pDialog,
      66                 :            :                                     const ResId &rLoad, const ResId &rSave,
      67                 :            :                                     const ResId &rEmbed, const ResId &rTableName,
      68                 :            :                                     XPropertyListType t, XOutdevItemPool* pXPool )
      69                 :            :     : meType( t )
      70                 :            :     , mpXPool( pXPool )
      71                 :            :     , mpTopDlg( pDialog )
      72                 :            :     , maBoxEmbed( pParent, rEmbed )
      73                 :            :     , maBtnLoad( pParent, rLoad )
      74                 :            :     , maBtnSave( pParent, rSave )
      75 [ #  # ][ #  # ]:          0 :     , maTableName( pParent, rTableName )
                 [ #  # ]
      76                 :            : {
      77         [ #  # ]:          0 :     maBoxEmbed.SetToggleHdl( LINK( this, SvxLoadSaveEmbed, EmbedToggleHdl_Impl ) );
      78                 :            : 
      79         [ #  # ]:          0 :     maBtnLoad.SetClickHdl( LINK( this, SvxLoadSaveEmbed, ClickLoadHdl_Impl ) );
      80         [ #  # ]:          0 :     maBtnSave.SetClickHdl( LINK( this, SvxLoadSaveEmbed, ClickSaveHdl_Impl ) );
      81                 :            : 
      82 [ #  # ][ #  # ]:          0 :     SetEmbed( GetEmbed() );
      83         [ #  # ]:          0 :     UpdateTableName();
      84                 :          0 : }
      85                 :            : 
      86                 :          0 : XPropertyListRef SvxLoadSaveEmbed::GetList()
      87                 :            : {
      88         [ #  # ]:          0 :     SvxAreaTabDialog* pArea = dynamic_cast< SvxAreaTabDialog* >( mpTopDlg );
      89         [ #  # ]:          0 :     SvxLineTabDialog* pLine = dynamic_cast< SvxLineTabDialog* >( mpTopDlg );
      90                 :            : 
      91                 :          0 :     XColorListRef pList;
      92         [ #  # ]:          0 :     if( pArea )
      93 [ #  # ][ #  # ]:          0 :         pList = pArea->GetNewColorList();
      94         [ #  # ]:          0 :     if( pLine )
      95 [ #  # ][ #  # ]:          0 :         pList = pLine->GetNewColorList();
      96                 :            : 
      97         [ #  # ]:          0 :     if( !pList.is() ) {
      98         [ #  # ]:          0 :         if( pArea )
      99 [ #  # ][ #  # ]:          0 :             pList = pArea->GetColorList();
     100         [ #  # ]:          0 :         if( pLine )
     101 [ #  # ][ #  # ]:          0 :             pList = pLine->GetColorList();
     102                 :            :     }
     103                 :            : 
     104                 :            :     // URGH - abstract this nicely ... for re-using SvxLoadSaveEmbed
     105         [ #  # ]:          0 :     if( !pList.is() ) {
     106         [ #  # ]:          0 :         SvxColorTabPage *pPage = dynamic_cast< SvxColorTabPage *>( this );
     107         [ #  # ]:          0 :         if( pPage )
     108 [ #  # ][ #  # ]:          0 :             pList = pPage->GetColorList();
     109                 :            :     }
     110                 :            : 
     111                 :          0 :     return XPropertyListRef( static_cast< XPropertyList * >( pList.get() ) );
     112                 :            : }
     113                 :            : 
     114                 :          0 : void SvxLoadSaveEmbed::SetEmbed( bool bEmbed )
     115                 :            : {
     116         [ #  # ]:          0 :     XPropertyListRef pList = GetList();
     117         [ #  # ]:          0 :     if( pList.is() )
     118                 :          0 :         pList->SetEmbedInDocument( bEmbed );
     119         [ #  # ]:          0 :     maBoxEmbed.Check( bEmbed );
     120                 :          0 : }
     121                 :            : 
     122                 :          0 : bool SvxLoadSaveEmbed::GetEmbed()
     123                 :            : {
     124         [ #  # ]:          0 :     XPropertyListRef pList = GetList();
     125         [ #  # ]:          0 :     return pList.is() ? pList->IsEmbedInDocument() : 0;
     126                 :            : }
     127                 :            : 
     128                 :          0 : IMPL_LINK_NOARG(SvxLoadSaveEmbed, EmbedToggleHdl_Impl)
     129                 :            : {
     130                 :          0 :     SetEmbed( maBoxEmbed.IsChecked() );
     131                 :          0 :     return 0;
     132                 :            : }
     133                 :            : 
     134                 :          0 : void SvxLoadSaveEmbed::HideLoadSaveEmbed()
     135                 :            : {
     136                 :          0 :     maBtnLoad.Hide();
     137                 :          0 :     maBtnSave.Hide();
     138                 :          0 :     maBoxEmbed.Hide();
     139                 :          0 : }
     140                 :            : 
     141                 :          0 : void SvxLoadSaveEmbed::UpdateTableName()
     142                 :            : {
     143                 :            :     // Truncate the name if necessary ...
     144 [ #  # ][ #  # ]:          0 :     String aString( CUI_RES( RID_SVXSTR_TABLE ) );
     145         [ #  # ]:          0 :     aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
     146                 :            : 
     147         [ #  # ]:          0 :     XPropertyListRef pList = GetList();
     148         [ #  # ]:          0 :     if( !pList.is() )
     149                 :          0 :         return;
     150                 :            : 
     151 [ #  # ][ #  # ]:          0 :     INetURLObject aURL( pList->GetPath() );
     152 [ #  # ][ #  # ]:          0 :     aURL.Append( pList->GetName() );
     153                 :            : 
     154 [ #  # ][ #  # ]:          0 :     if ( aURL.getBase().getLength() > 18 )
     155                 :            :     {
     156 [ #  # ][ #  # ]:          0 :         aString += String(aURL.getBase()).Copy( 0, 15 );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     157         [ #  # ]:          0 :         aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
     158                 :            :     }
     159                 :            :     else
     160 [ #  # ][ #  # ]:          0 :         aString += String (aURL.getBase());
         [ #  # ][ #  # ]
     161                 :            : 
     162 [ #  # ][ #  # ]:          0 :     maTableName.SetText( aString );
         [ #  # ][ #  # ]
                 [ #  # ]
     163                 :            : }
     164                 :            : 
     165                 :            : // -----------------------------------------------------------------------
     166                 :            : 
     167                 :          0 : IMPL_LINK_NOARG(SvxLoadSaveEmbed, ClickLoadHdl_Impl)
     168                 :            : {
     169                 :          0 :     ResMgr& rMgr = CUI_MGR();
     170                 :          0 :     sal_uInt16 nReturn = RET_YES;
     171                 :          0 :     bool bLoaded = false;
     172                 :            : 
     173 [ #  # ][ #  # ]:          0 :     if( IsModified() && GetList()->Count() > 0 )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     174                 :            :     {
     175                 :            :         nReturn = WarningBox( mpTopDlg, WinBits( WB_YES_NO_CANCEL ),
     176 [ #  # ][ #  # ]:          0 :                     String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute();
         [ #  # ][ #  # ]
                 [ #  # ]
     177                 :            : 
     178         [ #  # ]:          0 :         if ( nReturn == RET_YES )
     179         [ #  # ]:          0 :             GetList()->Save();
     180                 :            :     }
     181                 :            : 
     182         [ #  # ]:          0 :     if ( nReturn != RET_CANCEL )
     183                 :            :     {
     184                 :            :         ::sfx2::FileDialogHelper aDlg(
     185                 :            :             css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
     186         [ #  # ]:          0 :             0 );
     187 [ #  # ][ #  # ]:          0 :         String aStrFilterType( XPropertyList::GetDefaultExtFilter( meType ) );
     188         [ #  # ]:          0 :         aDlg.AddFilter( aStrFilterType, aStrFilterType );
     189                 :            : 
     190 [ #  # ][ #  # ]:          0 :         INetURLObject aFile( SvtPathOptions().GetPalettePath() );
         [ #  # ][ #  # ]
                 [ #  # ]
     191 [ #  # ][ #  # ]:          0 :         aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
         [ #  # ][ #  # ]
     192                 :            : 
     193 [ #  # ][ #  # ]:          0 :         if ( aDlg.Execute() == ERRCODE_NONE )
     194                 :            :         {
     195                 :            :             XColorListRef pList = XPropertyList::CreatePropertyListFromURL(
     196 [ #  # ][ #  # ]:          0 :                                         meType, aDlg.GetPath(), mpXPool )->AsColorList();
         [ #  # ][ #  # ]
                 [ #  # ]
     197 [ #  # ][ #  # ]:          0 :             if( pList->Load() )
     198                 :            :             {
     199                 :            :                 // check whether the table may be deleted:
     200         [ #  # ]:          0 :                 SvxAreaTabDialog* pArea = dynamic_cast< SvxAreaTabDialog* >( mpTopDlg );
     201         [ #  # ]:          0 :                 SvxLineTabDialog* pLine = dynamic_cast< SvxLineTabDialog* >( mpTopDlg );
     202                 :            : 
     203                 :            :                 // FIXME: want to have a generic set and get method by type ...
     204         [ #  # ]:          0 :                 if( pArea )
     205         [ #  # ]:          0 :                     pArea->SetNewColorList( pList );
     206         [ #  # ]:          0 :                 else if( pLine )
     207         [ #  # ]:          0 :                     pLine->SetNewColorList( pList );
     208                 :            : 
     209                 :          0 :                 bLoaded = true;
     210         [ #  # ]:          0 :                 UpdateTableName();
     211                 :            : 
     212         [ #  # ]:          0 :                 AddState( CT_CHANGED );
     213         [ #  # ]:          0 :                 SetModified( false );
     214         [ #  # ]:          0 :                 SetEmbed( true );
     215                 :            :             }
     216                 :            :             else
     217                 :            :             {
     218                 :            :                 ErrorBox aErrorBox( mpTopDlg, WinBits( WB_OK ),
     219 [ #  # ][ #  # ]:          0 :                     String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) );
                 [ #  # ]
     220 [ #  # ][ #  # ]:          0 :                 aErrorBox.Execute();
     221                 :          0 :             }
     222 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     223                 :            :     }
     224                 :          0 :     Update( bLoaded );
     225                 :            : 
     226                 :          0 :     return 0;
     227                 :            : }
     228                 :            : 
     229                 :          0 : void SvxLoadSaveEmbed::EnableSave( bool bCanSave )
     230                 :            : {
     231         [ #  # ]:          0 :     if ( bCanSave )
     232                 :          0 :         maBtnSave.Enable();
     233                 :            :     else
     234                 :          0 :         maBtnSave.Disable();
     235                 :          0 : }
     236                 :            : 
     237                 :            : // -----------------------------------------------------------------------
     238                 :            : 
     239                 :          0 : IMPL_LINK_NOARG(SvxLoadSaveEmbed, ClickSaveHdl_Impl)
     240                 :            : {
     241                 :            :     ::sfx2::FileDialogHelper aDlg(
     242         [ #  # ]:          0 :         css::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
     243                 :            : 
     244 [ #  # ][ #  # ]:          0 :     String aStrFilterType( XPropertyList::GetDefaultExtFilter( meType ) );
     245         [ #  # ]:          0 :     aDlg.AddFilter( aStrFilterType, aStrFilterType );
     246                 :            : 
     247 [ #  # ][ #  # ]:          0 :     INetURLObject aFile( SvtPathOptions().GetPalettePath() );
         [ #  # ][ #  # ]
                 [ #  # ]
     248                 :            :     DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     249                 :            : 
     250         [ #  # ]:          0 :     XPropertyListRef pList = GetList();
     251                 :            : 
     252         [ #  # ]:          0 :     if( pList->GetName().Len() )
     253                 :            :     {
     254 [ #  # ][ #  # ]:          0 :         aFile.Append( pList->GetName() );
     255                 :            : 
     256 [ #  # ][ #  # ]:          0 :         if( aFile.getExtension().isEmpty() )
     257 [ #  # ][ #  # ]:          0 :             aFile.SetExtension( XPropertyList::GetDefaultExt( meType ) );
     258                 :            :     }
     259                 :            : 
     260 [ #  # ][ #  # ]:          0 :     aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
         [ #  # ][ #  # ]
     261 [ #  # ][ #  # ]:          0 :     if ( aDlg.Execute() == ERRCODE_NONE )
     262                 :            :     {
     263 [ #  # ][ #  # ]:          0 :         INetURLObject aURL( aDlg.GetPath() );
         [ #  # ][ #  # ]
     264         [ #  # ]:          0 :         INetURLObject aPathURL( aURL );
     265                 :            : 
     266         [ #  # ]:          0 :         aPathURL.removeSegment();
     267         [ #  # ]:          0 :         aPathURL.removeFinalSlash();
     268                 :            : 
     269 [ #  # ][ #  # ]:          0 :         pList->SetName( aURL.getName() );
         [ #  # ][ #  # ]
     270 [ #  # ][ #  # ]:          0 :         pList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
         [ #  # ][ #  # ]
     271                 :            : 
     272 [ #  # ][ #  # ]:          0 :         if( pList->Save() )
     273                 :            :         {
     274         [ #  # ]:          0 :             UpdateTableName();
     275         [ #  # ]:          0 :             AddState( CT_SAVED );
     276         [ #  # ]:          0 :             SetModified( false );
     277                 :            :         }
     278                 :            :         else
     279                 :            :         {
     280                 :            :             ErrorBox aErrorBox( mpTopDlg, WinBits( WB_OK ),
     281 [ #  # ][ #  # ]:          0 :                 String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) );
         [ #  # ][ #  # ]
     282 [ #  # ][ #  # ]:          0 :             aErrorBox.Execute();
     283 [ #  # ][ #  # ]:          0 :         }
     284                 :            :     }
     285 [ #  # ][ #  # ]:          0 :     return 0;
                 [ #  # ]
     286                 :            : }
     287                 :            : 
     288                 :          0 : void SvxColorTabPage::Update(bool bLoaded)
     289                 :            : {
     290         [ #  # ]:          0 :     pColorList = XColorListRef( static_cast<XColorList *>( GetList().get() ) );
     291                 :            : 
     292         [ #  # ]:          0 :     if (bLoaded)
     293                 :            :     {
     294                 :          0 :         aLbColor.Clear();
     295                 :          0 :         aValSetColorList.Clear();
     296                 :          0 :         Construct();
     297                 :          0 :         Reset( rOutAttrs );
     298                 :            : 
     299         [ #  # ]:          0 :         if( aLbColor.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND )
     300                 :          0 :             aLbColor.SelectEntryPos( 0 );
     301                 :            :         else
     302                 :          0 :             aLbColor.SelectEntryPos( aLbColor.GetSelectEntryPos() );
     303                 :            : 
     304                 :          0 :         ChangeColorHdl_Impl( this );
     305                 :          0 :         SelectColorLBHdl_Impl( this );
     306                 :            :     }
     307                 :            : 
     308                 :          0 :     UpdateModified();
     309                 :          0 : }
     310                 :            : 
     311                 :            : // FIXME: you have to hate yourself for this - all this
     312                 :            : // horrible and broadly unused pointer based coupling
     313                 :            : // needs to die. cf SetupForViewFrame
     314                 :            : #define COLORPAGE_UNKNOWN ((sal_uInt16)0xFFFF)
     315                 :            : 
     316                 :            : struct SvxColorTabPageShadow
     317                 :            : {
     318                 :            :     sal_uInt16 nUnknownType;
     319                 :            :     sal_uInt16 nUnknownPos;
     320                 :            :     sal_Bool   bIsAreaTP;
     321                 :            :     sal_uInt16 nChangeType;
     322                 :          0 :     SvxColorTabPageShadow()
     323                 :            :         : nUnknownType( COLORPAGE_UNKNOWN )
     324                 :            :         , nUnknownPos( COLORPAGE_UNKNOWN )
     325                 :            :         , bIsAreaTP( sal_False )
     326                 :          0 :         , nChangeType( 0 )
     327                 :            :     {
     328                 :          0 :     }
     329                 :            : };
     330                 :            : 
     331                 :            : // -----------------------------------------------------------------------
     332                 :            : 
     333                 :          0 : SvxColorTabPage::SvxColorTabPage
     334                 :            : (
     335                 :            :     Window* pParent,
     336                 :            :     const SfxItemSet& rInAttrs
     337                 :            : ) :
     338                 :            : 
     339                 :          0 :     SfxTabPage          ( pParent, CUI_RES( RID_SVXPAGE_COLOR ), rInAttrs ),
     340                 :            :     SvxLoadSaveEmbed    ( this, GetParentDialog(),
     341   [ #  #  #  # ]:          0 :                           CUI_RES( BTN_LOAD ), CUI_RES( BTN_SAVE ),
     342   [ #  #  #  # ]:          0 :                           CUI_RES( BTN_EMBED ), CUI_RES( FT_TABLE_NAME ),
     343                 :          0 :                           XCOLOR_LIST, (XOutdevItemPool*) rInAttrs.GetPool() ),
     344                 :            : 
     345                 :            :     pShadow             ( new SvxColorTabPageShadow() ),
     346         [ #  # ]:          0 :     aFlProp             ( this, CUI_RES( FL_PROP ) ),
     347         [ #  # ]:          0 :     aFtName             ( this, CUI_RES( FT_NAME ) ),
     348         [ #  # ]:          0 :     aEdtName            ( this, CUI_RES( EDT_NAME ) ),
     349         [ #  # ]:          0 :     aFtColor            ( this, CUI_RES( FT_COLOR ) ),
     350         [ #  # ]:          0 :     aLbColor            ( this, CUI_RES( LB_COLOR ) ),
     351                 :            : 
     352         [ #  # ]:          0 :     aValSetColorList   ( this, CUI_RES( CTL_COLORTABLE ) ),
     353                 :            : 
     354         [ #  # ]:          0 :     aCtlPreviewOld      ( this, CUI_RES( CTL_PREVIEW_OLD ) ),
     355         [ #  # ]:          0 :     aCtlPreviewNew      ( this, CUI_RES( CTL_PREVIEW_NEW ) ),
     356                 :            : 
     357         [ #  # ]:          0 :     aLbColorModel       ( this, CUI_RES( LB_COLORMODEL ) ),
     358         [ #  # ]:          0 :     aFtColorModel1      ( this, CUI_RES( FT_1 ) ),
     359         [ #  # ]:          0 :     aMtrFldColorModel1  ( this, CUI_RES( MTR_FLD_1 ) ),
     360         [ #  # ]:          0 :     aFtColorModel2      ( this, CUI_RES( FT_2 ) ),
     361         [ #  # ]:          0 :     aMtrFldColorModel2  ( this, CUI_RES( MTR_FLD_2 ) ),
     362         [ #  # ]:          0 :     aFtColorModel3      ( this, CUI_RES( FT_3 ) ),
     363         [ #  # ]:          0 :     aMtrFldColorModel3  ( this, CUI_RES( MTR_FLD_3 ) ),
     364         [ #  # ]:          0 :     aFtColorModel4      ( this, CUI_RES( FT_4 ) ),
     365         [ #  # ]:          0 :     aMtrFldColorModel4  ( this, CUI_RES( MTR_FLD_4 ) ),
     366         [ #  # ]:          0 :     aBtnAdd             ( this, CUI_RES( BTN_ADD ) ),
     367         [ #  # ]:          0 :     aBtnModify          ( this, CUI_RES( BTN_MODIFY ) ),
     368         [ #  # ]:          0 :     aBtnWorkOn          ( this, CUI_RES( BTN_WORK_ON ) ),
     369         [ #  # ]:          0 :     aBtnDelete          ( this, CUI_RES( BTN_DELETE ) ),
     370                 :            : 
     371                 :            :     rOutAttrs           ( rInAttrs ),
     372                 :            : 
     373                 :            :     // All the horrific pointers we store and should not
     374                 :            :     pPageType           ( NULL ),
     375                 :            :     pDlgType            ( NULL ),
     376                 :            :     pPos                ( NULL ),
     377                 :            :     pbAreaTP            ( NULL ),
     378                 :            : 
     379                 :            :     aXFStyleItem        ( XFILL_SOLID ),
     380                 :            :     aXFillColorItem     ( String(), Color( COL_BLACK ) ),
     381                 :          0 :     aXFillAttr          ( (XOutdevItemPool*) rInAttrs.GetPool() ),
     382                 :          0 :     rXFSet              ( aXFillAttr.GetItemSet() ),
     383 [ #  # ][ #  # ]:          0 :     eCM                 ( CM_RGB )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     384                 :            : {
     385         [ #  # ]:          0 :     FreeResource();
     386                 :            : 
     387                 :            :     // this page needs ExchangeSupport
     388                 :          0 :     SetExchangeSupport();
     389                 :            : 
     390                 :            :     // setting the output device
     391         [ #  # ]:          0 :     rXFSet.Put( aXFStyleItem );
     392         [ #  # ]:          0 :     rXFSet.Put( aXFillColorItem );
     393         [ #  # ]:          0 :     aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
     394         [ #  # ]:          0 :     aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
     395                 :            : 
     396                 :            :     // overload handler
     397                 :            :     aLbColor.SetSelectHdl(
     398         [ #  # ]:          0 :         LINK( this, SvxColorTabPage, SelectColorLBHdl_Impl ) );
     399                 :            :     aValSetColorList.SetSelectHdl(
     400         [ #  # ]:          0 :         LINK( this, SvxColorTabPage, SelectValSetHdl_Impl ) );
     401                 :            :     aLbColorModel.SetSelectHdl(
     402         [ #  # ]:          0 :         LINK( this, SvxColorTabPage, SelectColorModelHdl_Impl ) );
     403                 :            : 
     404         [ #  # ]:          0 :     Link aLink = LINK( this, SvxColorTabPage, ModifiedHdl_Impl );
     405                 :          0 :     aMtrFldColorModel1.SetModifyHdl( aLink );
     406                 :          0 :     aMtrFldColorModel2.SetModifyHdl( aLink );
     407                 :          0 :     aMtrFldColorModel3.SetModifyHdl( aLink );
     408                 :          0 :     aMtrFldColorModel4.SetModifyHdl( aLink );
     409                 :            : 
     410         [ #  # ]:          0 :     aBtnAdd.SetClickHdl( LINK( this, SvxColorTabPage, ClickAddHdl_Impl ) );
     411                 :            :     aBtnModify.SetClickHdl(
     412         [ #  # ]:          0 :         LINK( this, SvxColorTabPage, ClickModifyHdl_Impl ) );
     413                 :            :     aBtnWorkOn.SetClickHdl(
     414         [ #  # ]:          0 :         LINK( this, SvxColorTabPage, ClickWorkOnHdl_Impl ) );
     415                 :            :     aBtnDelete.SetClickHdl(
     416         [ #  # ]:          0 :         LINK( this, SvxColorTabPage, ClickDeleteHdl_Impl ) );
     417                 :            : 
     418                 :            :     // ValueSet
     419 [ #  # ][ #  # ]:          0 :     aValSetColorList.SetStyle( aValSetColorList.GetStyle() | WB_VSCROLL | WB_ITEMBORDER );
     420         [ #  # ]:          0 :     aValSetColorList.SetColCount( 8 );
     421         [ #  # ]:          0 :     aValSetColorList.SetLineCount( 13 );
     422         [ #  # ]:          0 :     aValSetColorList.SetExtraSpacing( 0 );
     423         [ #  # ]:          0 :     aValSetColorList.Show();
     424                 :            : 
     425 [ #  # ][ #  # ]:          0 :     aLbColorModel.SetAccessibleName( String( CUI_RES(STR_CUI_COLORMODEL) ) );
         [ #  # ][ #  # ]
     426         [ #  # ]:          0 :     aBtnAdd.SetAccessibleRelationMemberOf( &aFlProp );
     427         [ #  # ]:          0 :     aBtnModify.SetAccessibleRelationMemberOf( &aFlProp );
     428         [ #  # ]:          0 :     aBtnWorkOn.SetAccessibleRelationMemberOf( &aFlProp );
     429         [ #  # ]:          0 :     aBtnDelete.SetAccessibleRelationMemberOf( &aFlProp );
     430                 :          0 : }
     431                 :            : 
     432 [ #  # ][ #  # ]:          0 : SvxColorTabPage::~SvxColorTabPage()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     433                 :            : {
     434                 :          0 :     delete pShadow;
     435         [ #  # ]:          0 : }
     436                 :            : 
     437                 :            : // -----------------------------------------------------------------------
     438                 :            : 
     439                 :          0 : void SvxColorTabPage::Construct()
     440                 :            : {
     441                 :          0 :     aLbColor.Fill( pColorList );
     442                 :          0 :     FillValueSet_Impl( aValSetColorList );
     443                 :          0 :     UpdateTableName();
     444                 :          0 : }
     445                 :            : 
     446                 :            : // -----------------------------------------------------------------------
     447                 :            : 
     448                 :          0 : void SvxColorTabPage::ActivatePage( const SfxItemSet& )
     449                 :            : {
     450         [ #  # ]:          0 :     if( *pDlgType == 0 ) // area dialog
     451                 :            :     {
     452                 :          0 :         *pbAreaTP = sal_False;
     453                 :            : 
     454         [ #  # ]:          0 :         if( pColorList.is() )
     455                 :            :         {
     456 [ #  # ][ #  # ]:          0 :             if( *pPageType == PT_COLOR && *pPos != LISTBOX_ENTRY_NOTFOUND )
     457                 :            :             {
     458                 :          0 :                 aLbColor.SelectEntryPos( *pPos );
     459                 :          0 :                 aValSetColorList.SelectItem( aLbColor.GetSelectEntryPos() + 1 );
     460         [ #  # ]:          0 :                 aEdtName.SetText( aLbColor.GetSelectEntry() );
     461                 :            : 
     462                 :          0 :                 ChangeColorHdl_Impl( this );
     463                 :            :             }
     464 [ #  # ][ #  # ]:          0 :             else if( *pPageType == PT_COLOR && *pPos == LISTBOX_ENTRY_NOTFOUND )
     465                 :            :             {
     466                 :          0 :                 const SfxPoolItem* pPoolItem = NULL;
     467 [ #  # ][ #  # ]:          0 :                 if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), sal_True, &pPoolItem ) )
                 [ #  # ]
     468                 :            :                 {
     469         [ #  # ]:          0 :                     aLbColorModel.SelectEntryPos( CM_RGB );
     470                 :            : 
     471         [ #  # ]:          0 :                     aAktuellColor.SetColor ( ( ( const XFillColorItem* ) pPoolItem )->GetColorValue().GetColor() );
     472                 :            : 
     473 [ #  # ][ #  # ]:          0 :                     aEdtName.SetText( ( ( const XFillColorItem* ) pPoolItem )->GetName() );
                 [ #  # ]
     474                 :            : 
     475         [ #  # ]:          0 :                     aMtrFldColorModel1.SetValue( ColorToPercent_Impl( aAktuellColor.GetRed() ) );
     476         [ #  # ]:          0 :                     aMtrFldColorModel2.SetValue( ColorToPercent_Impl( aAktuellColor.GetGreen() ) );
     477         [ #  # ]:          0 :                     aMtrFldColorModel3.SetValue( ColorToPercent_Impl( aAktuellColor.GetBlue() ) );
     478                 :            : 
     479                 :            :                     // fill ItemSet and pass it on to XOut
     480 [ #  # ][ #  # ]:          0 :                     rXFSet.Put( XFillColorItem( String(), aAktuellColor ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     481         [ #  # ]:          0 :                     aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
     482         [ #  # ]:          0 :                     aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
     483                 :            : 
     484         [ #  # ]:          0 :                     aCtlPreviewNew.Invalidate();
     485         [ #  # ]:          0 :                     aCtlPreviewOld.Invalidate();
     486                 :            :                 }
     487                 :            :             }
     488                 :            : 
     489                 :            :             // so that the possibly changed color is discarded
     490                 :          0 :             SelectColorLBHdl_Impl( this );
     491                 :            : 
     492                 :          0 :             *pPageType = PT_COLOR;
     493                 :          0 :             *pPos = LISTBOX_ENTRY_NOTFOUND;
     494                 :            :         }
     495                 :            :     }
     496                 :            :     else
     497                 :          0 :         HideLoadSaveEmbed();
     498                 :          0 : }
     499                 :            : 
     500                 :            : // -----------------------------------------------------------------------
     501                 :            : 
     502                 :          0 : int SvxColorTabPage::DeactivatePage( SfxItemSet* _pSet )
     503                 :            : {
     504         [ #  # ]:          0 :     if ( CheckChanges_Impl() == -1L )
     505                 :          0 :         return( KEEP_PAGE );
     506                 :            : 
     507         [ #  # ]:          0 :     if( _pSet )
     508                 :          0 :         FillItemSet( *_pSet );
     509                 :            : 
     510                 :          0 :     return( LEAVE_PAGE );
     511                 :            : }
     512                 :            : 
     513                 :            : // -----------------------------------------------------------------------
     514                 :            : 
     515                 :          0 : long SvxColorTabPage::CheckChanges_Impl()
     516                 :            : {
     517                 :            :     // used to NOT lose changes
     518                 :            : 
     519                 :          0 :     Color aTmpColor (aAktuellColor);
     520         [ #  # ]:          0 :     if (eCM != CM_RGB)
     521         [ #  # ]:          0 :         ConvertColorValues (aTmpColor, CM_RGB);
     522                 :            : 
     523         [ #  # ]:          0 :     sal_uInt16 nPos = aLbColor.GetSelectEntryPos();
     524         [ #  # ]:          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     525                 :            :     {
     526         [ #  # ]:          0 :         Color aColor = pColorList->GetColor( nPos )->GetColor();
     527         [ #  # ]:          0 :         String aString = aLbColor.GetSelectEntry();
     528                 :            : 
     529                 :            :         // aNewColor, because COL_USER != COL_something, even if RGB values are the same
     530                 :            :         // Color aNewColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() );
     531                 :            : 
     532   [ #  #  #  #  :          0 :         if( ColorToPercent_Impl( aTmpColor.GetRed() ) != ColorToPercent_Impl( aColor.GetRed() ) ||
           #  # ][ #  # ]
                 [ #  # ]
     533                 :          0 :             ColorToPercent_Impl( aTmpColor.GetGreen() ) != ColorToPercent_Impl( aColor.GetGreen() ) ||
     534                 :          0 :             ColorToPercent_Impl( aTmpColor.GetBlue() ) != ColorToPercent_Impl( aColor.GetBlue() ) ||
     535 [ #  # ][ #  # ]:          0 :             aString != aEdtName.GetText() )
         [ #  # ][ #  # ]
                 [ #  # ]
     536                 :            :         {
     537         [ #  # ]:          0 :             ResMgr& rMgr = CUI_MGR();
     538         [ #  # ]:          0 :             Image aWarningBoxImage = WarningBox::GetStandardImage();
     539         [ #  # ]:          0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     540                 :            :             AbstractSvxMessDialog* aMessDlg = pFact->CreateSvxMessDialog( GetParentDialog(), RID_SVXDLG_MESSBOX,
     541         [ #  # ]:          0 :                                                         SVX_RESSTR( RID_SVXSTR_COLOR ),
     542                 :            :                                                         String( ResId( RID_SVXSTR_ASK_CHANGE_COLOR, rMgr ) ),
     543 [ #  # ][ #  # ]:          0 :                                                         &aWarningBoxImage );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     544                 :            :             aMessDlg->SetButtonText( MESS_BTN_1,
     545 [ #  # ][ #  # ]:          0 :                                     String( ResId( RID_SVXSTR_CHANGE, rMgr ) ) );
                 [ #  # ]
     546                 :            :             aMessDlg->SetButtonText( MESS_BTN_2,
     547 [ #  # ][ #  # ]:          0 :                                     String( ResId( RID_SVXSTR_ADD, rMgr ) ) );
                 [ #  # ]
     548                 :            : 
     549         [ #  # ]:          0 :             short nRet = aMessDlg->Execute();
     550                 :            : 
     551   [ #  #  #  # ]:          0 :             switch( nRet )
     552                 :            :             {
     553                 :            :                 case RET_BTN_1:
     554                 :            :                 {
     555         [ #  # ]:          0 :                     ClickModifyHdl_Impl( this );
     556         [ #  # ]:          0 :                     aColor = pColorList->GetColor( nPos )->GetColor();
     557                 :            :                 }
     558                 :          0 :                 break;
     559                 :            : 
     560                 :            :                 case RET_BTN_2:
     561                 :            :                 {
     562         [ #  # ]:          0 :                     ClickAddHdl_Impl( this );
     563         [ #  # ]:          0 :                     nPos = aLbColor.GetSelectEntryPos();
     564         [ #  # ]:          0 :                     aColor = pColorList->GetColor( nPos )->GetColor();
     565                 :            :                 }
     566                 :          0 :                 break;
     567                 :            : 
     568                 :            :                 case RET_CANCEL:
     569                 :          0 :                 break;
     570                 :            :             }
     571 [ #  # ][ #  # ]:          0 :             delete aMessDlg;
                 [ #  # ]
     572         [ #  # ]:          0 :         }
     573                 :            :     }
     574         [ #  # ]:          0 :     if( *pDlgType == 0 ) // area dialog
     575                 :            :     {
     576         [ #  # ]:          0 :         nPos = aLbColor.GetSelectEntryPos();
     577         [ #  # ]:          0 :         if( nPos != LISTBOX_ENTRY_NOTFOUND )
     578                 :            :         {
     579                 :          0 :             *pPos = nPos;
     580                 :            :         }
     581                 :            :     }
     582                 :          0 :     return 0;
     583                 :            : }
     584                 :            : 
     585                 :            : // -----------------------------------------------------------------------
     586                 :            : 
     587                 :          0 : sal_Bool SvxColorTabPage::FillItemSet( SfxItemSet& rSet )
     588                 :            : {
     589 [ #  # ][ #  # ]:          0 :     if( ( *pDlgType != 0 ) ||
                 [ #  # ]
     590                 :            :         ( *pPageType == PT_COLOR && *pbAreaTP == sal_False ) )
     591                 :            :     {
     592         [ #  # ]:          0 :         String aString;
     593                 :          0 :         Color  aColor;
     594                 :            : 
     595         [ #  # ]:          0 :         sal_uInt16 nPos = aLbColor.GetSelectEntryPos();
     596         [ #  # ]:          0 :         if( nPos != LISTBOX_ENTRY_NOTFOUND )
     597                 :            :         {
     598         [ #  # ]:          0 :             aColor  = pColorList->GetColor( nPos )->GetColor();
     599 [ #  # ][ #  # ]:          0 :             aString = aLbColor.GetSelectEntry();
                 [ #  # ]
     600                 :            :         }
     601                 :            :         else
     602                 :            :         {
     603                 :          0 :             aColor.SetColor (aAktuellColor.GetColor());
     604         [ #  # ]:          0 :             if (eCM != CM_RGB)
     605         [ #  # ]:          0 :                 ConvertColorValues (aColor, CM_RGB);
     606                 :            :         }
     607 [ #  # ][ #  # ]:          0 :         rSet.Put( XFillColorItem( aString, aColor ) );
                 [ #  # ]
     608 [ #  # ][ #  # ]:          0 :         rSet.Put( XFillStyleItem( XFILL_SOLID ) );
         [ #  # ][ #  # ]
     609                 :            :     }
     610                 :            : 
     611                 :          0 :     return( sal_True );
     612                 :            : }
     613                 :            : 
     614                 :          0 : void SvxColorTabPage::UpdateModified()
     615                 :            : {
     616                 :          0 :     bool bEnable = pColorList->Count();
     617                 :          0 :     aBtnModify.Enable( bEnable );
     618                 :          0 :     aBtnWorkOn.Enable( bEnable );
     619                 :          0 :     aBtnDelete.Enable( bEnable );
     620                 :          0 :     EnableSave( bEnable );
     621                 :          0 : }
     622                 :            : 
     623                 :            : // -----------------------------------------------------------------------
     624                 :            : 
     625                 :          0 : void SvxColorTabPage::Reset( const SfxItemSet& rSet )
     626                 :            : {
     627         [ #  # ]:          0 :     sal_uInt16 nState = rSet.GetItemState( XATTR_FILLCOLOR );
     628                 :            : 
     629         [ #  # ]:          0 :     if ( nState >= SFX_ITEM_DEFAULT )
     630                 :            :     {
     631 [ #  # ][ #  # ]:          0 :         XFillColorItem aColorItem( (const XFillColorItem&)rSet.Get( XATTR_FILLCOLOR ) );
     632 [ #  # ][ #  # ]:          0 :         aLbColor.SelectEntry( aColorItem.GetColorValue() );
     633 [ #  # ][ #  # ]:          0 :         aValSetColorList.SelectItem( aLbColor.GetSelectEntryPos() + 1 );
     634 [ #  # ][ #  # ]:          0 :         aEdtName.SetText( aLbColor.GetSelectEntry() );
         [ #  # ][ #  # ]
     635                 :            :     }
     636                 :            : 
     637                 :            :     // set color model
     638         [ #  # ]:          0 :     String aStr = GetUserData();
     639 [ #  # ][ #  # ]:          0 :     aLbColorModel.SelectEntryPos( (sal_uInt16) aStr.ToInt32() );
     640                 :            : 
     641         [ #  # ]:          0 :     ChangeColorHdl_Impl( this );
     642         [ #  # ]:          0 :     SelectColorModelHdl_Impl( this );
     643                 :            : 
     644         [ #  # ]:          0 :     aCtlPreviewOld.Invalidate();
     645 [ #  # ][ #  # ]:          0 :     UpdateModified();
     646                 :          0 : }
     647                 :            : 
     648                 :            : // -----------------------------------------------------------------------
     649                 :            : 
     650                 :          0 : SfxTabPage* SvxColorTabPage::Create( Window* pWindow,
     651                 :            :                 const SfxItemSet& rOutAttrs )
     652                 :            : {
     653         [ #  # ]:          0 :     return( new SvxColorTabPage( pWindow, rOutAttrs ) );
     654                 :            : }
     655                 :            : 
     656                 :            : //------------------------------------------------------------------------
     657                 :            : 
     658                 :            : //
     659                 :            : // is called when the content of the MtrFields is changed for color values
     660                 :            : //
     661                 :          0 : IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl)
     662                 :            : {
     663                 :            :     // read current MtrFields, if cmyk, then k-value as transparency
     664         [ #  # ]:          0 :     aAktuellColor.SetColor ( Color( (sal_uInt8)PercentToColor_Impl( (sal_uInt16) aMtrFldColorModel4.GetValue() ),
     665         [ #  # ]:          0 :                                     (sal_uInt8)PercentToColor_Impl( (sal_uInt16) aMtrFldColorModel1.GetValue() ),
     666         [ #  # ]:          0 :                                     (sal_uInt8)PercentToColor_Impl( (sal_uInt16) aMtrFldColorModel2.GetValue() ),
     667         [ #  # ]:          0 :                                     (sal_uInt8)PercentToColor_Impl( (sal_uInt16) aMtrFldColorModel3.GetValue() ) ).GetColor() );
     668                 :            : 
     669                 :          0 :     Color aTmpColor(aAktuellColor);
     670         [ #  # ]:          0 :     if (eCM != CM_RGB)
     671         [ #  # ]:          0 :         ConvertColorValues (aTmpColor, CM_RGB);
     672                 :            : 
     673 [ #  # ][ #  # ]:          0 :     rXFSet.Put( XFillColorItem( String(), aTmpColor ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     674         [ #  # ]:          0 :     aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
     675                 :            : 
     676         [ #  # ]:          0 :     aCtlPreviewNew.Invalidate();
     677                 :            : 
     678                 :          0 :     return 0;
     679                 :            : }
     680                 :            : 
     681                 :            : //------------------------------------------------------------------------
     682                 :            : 
     683                 :          0 : IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl)
     684                 :            : {
     685                 :          0 :     Window *pWindow = this;
     686         [ #  # ]:          0 :     while( pWindow )
     687                 :            :     {
     688         [ #  # ]:          0 :         pWindow = pWindow->GetParent();
     689                 :            :     }
     690                 :            : 
     691         [ #  # ]:          0 :     ResMgr& rMgr = CUI_MGR();
     692         [ #  # ]:          0 :     String aDesc( ResId( RID_SVXSTR_DESC_COLOR, rMgr ) );
     693         [ #  # ]:          0 :     String aName( aEdtName.GetText() );
     694                 :            :     XColorEntry* pEntry;
     695         [ #  # ]:          0 :     long nCount = pColorList->Count();
     696                 :          0 :     sal_Bool bDifferent = sal_True;
     697                 :            : 
     698                 :            :     // check if name is already existing
     699 [ #  # ][ #  # ]:          0 :     for ( long i = 0; i < nCount && bDifferent; i++ )
                 [ #  # ]
     700 [ #  # ][ #  # ]:          0 :         if ( aName == pColorList->GetColor( i )->GetName() )
                 [ #  # ]
     701                 :          0 :             bDifferent = sal_False;
     702                 :            : 
     703                 :            :     // if yes, it is repeated and a new name is demanded
     704         [ #  # ]:          0 :     if ( !bDifferent )
     705                 :            :     {
     706                 :            :         WarningBox aWarningBox( GetParentDialog(), WinBits( WB_OK ),
     707 [ #  # ][ #  # ]:          0 :             String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
         [ #  # ][ #  # ]
     708         [ #  # ]:          0 :         aWarningBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
     709         [ #  # ]:          0 :         aWarningBox.Execute();
     710                 :            : 
     711         [ #  # ]:          0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     712 [ #  # ][ #  # ]:          0 :         AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc );
     713                 :          0 :         sal_Bool bLoop = sal_True;
     714                 :            : 
     715 [ #  # ][ #  # ]:          0 :         while ( !bDifferent && bLoop && pDlg->Execute() == RET_OK )
         [ #  # ][ #  # ]
                 [ #  # ]
     716                 :            :         {
     717         [ #  # ]:          0 :             pDlg->GetName( aName );
     718                 :          0 :             bDifferent = sal_True;
     719                 :            : 
     720 [ #  # ][ #  # ]:          0 :             for( long i = 0; i < nCount && bDifferent; i++ )
                 [ #  # ]
     721                 :            :             {
     722 [ #  # ][ #  # ]:          0 :                 if( aName == pColorList->GetColor( i )->GetName() )
                 [ #  # ]
     723                 :          0 :                     bDifferent = sal_False;
     724                 :            :             }
     725                 :            : 
     726         [ #  # ]:          0 :             if( bDifferent )
     727                 :          0 :                 bLoop = sal_False;
     728                 :            :             else
     729         [ #  # ]:          0 :                 aWarningBox.Execute();
     730                 :            :         }
     731 [ #  # ][ #  # ]:          0 :         delete( pDlg );
                 [ #  # ]
     732                 :            :     }
     733                 :            : 
     734                 :            :     // if not existing the entry is entered
     735         [ #  # ]:          0 :     if( bDifferent )
     736                 :            :     {
     737         [ #  # ]:          0 :         if (eCM != CM_RGB)
     738         [ #  # ]:          0 :             ConvertColorValues (aAktuellColor, CM_RGB);
     739 [ #  # ][ #  # ]:          0 :         pEntry = new XColorEntry( aAktuellColor, aName );
     740                 :            : 
     741 [ #  # ][ #  # ]:          0 :         pColorList->Insert( pEntry, pColorList->Count() );
     742                 :            : 
     743         [ #  # ]:          0 :         aLbColor.Append( pEntry );
     744         [ #  # ]:          0 :         aValSetColorList.InsertItem( aValSetColorList.GetItemCount() + 1,
     745         [ #  # ]:          0 :                 pEntry->GetColor(), pEntry->GetName() );
     746                 :            : 
     747 [ #  # ][ #  # ]:          0 :         aLbColor.SelectEntryPos( aLbColor.GetEntryCount() - 1 );
     748                 :            : 
     749                 :          0 :         *pnColorListState |= CT_MODIFIED;
     750                 :            : 
     751         [ #  # ]:          0 :         SelectColorLBHdl_Impl( this );
     752                 :            :     }
     753         [ #  # ]:          0 :     UpdateModified();
     754                 :            : 
     755 [ #  # ][ #  # ]:          0 :     return 0;
     756                 :            : }
     757                 :            : 
     758                 :            : //------------------------------------------------------------------------
     759                 :            : 
     760                 :          0 : IMPL_LINK_NOARG(SvxColorTabPage, ClickModifyHdl_Impl)
     761                 :            : {
     762                 :          0 :     sal_uInt16 nPos = aLbColor.GetSelectEntryPos();
     763                 :            : 
     764         [ #  # ]:          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     765                 :            :     {
     766         [ #  # ]:          0 :         ResMgr& rMgr = CUI_MGR();
     767         [ #  # ]:          0 :         String aDesc( ResId( RID_SVXSTR_DESC_COLOR, rMgr ) );
     768         [ #  # ]:          0 :         String aName( aEdtName.GetText() );
     769         [ #  # ]:          0 :         long nCount = pColorList->Count();
     770                 :          0 :         sal_Bool bDifferent = sal_True;
     771                 :            : 
     772                 :            :         // check if name is already existing
     773 [ #  # ][ #  # ]:          0 :         for ( long i = 0; i < nCount && bDifferent; i++ )
                 [ #  # ]
     774 [ #  # ][ #  # ]:          0 :             if ( aName == pColorList->GetColor( i )->GetName() && nPos != i )
         [ #  # ][ #  # ]
                 [ #  # ]
     775                 :          0 :                 bDifferent = sal_False;
     776                 :            : 
     777                 :            :         // if yes, it is repeated and a new name is demanded
     778         [ #  # ]:          0 :         if ( !bDifferent )
     779                 :            :         {
     780                 :            :             WarningBox aWarningBox( GetParentDialog(), WinBits( WB_OK ),
     781 [ #  # ][ #  # ]:          0 :                 String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
         [ #  # ][ #  # ]
     782         [ #  # ]:          0 :             aWarningBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
     783         [ #  # ]:          0 :             aWarningBox.Execute();
     784                 :            : 
     785         [ #  # ]:          0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     786 [ #  # ][ #  # ]:          0 :             AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc );
     787                 :          0 :             sal_Bool bLoop = sal_True;
     788                 :            : 
     789 [ #  # ][ #  # ]:          0 :             while ( !bDifferent && bLoop && pDlg->Execute() == RET_OK )
         [ #  # ][ #  # ]
                 [ #  # ]
     790                 :            :             {
     791         [ #  # ]:          0 :                 pDlg->GetName( aName );
     792                 :          0 :                 bDifferent = sal_True;
     793                 :            : 
     794 [ #  # ][ #  # ]:          0 :                 for ( long i = 0; i < nCount && bDifferent; i++ )
                 [ #  # ]
     795 [ #  # ][ #  # ]:          0 :                     if( aName == pColorList->GetColor( i )->GetName() && nPos != i )
         [ #  # ][ #  # ]
                 [ #  # ]
     796                 :          0 :                         bDifferent = sal_False;
     797                 :            : 
     798         [ #  # ]:          0 :                 if( bDifferent )
     799                 :          0 :                     bLoop = sal_False;
     800                 :            :                 else
     801         [ #  # ]:          0 :                     aWarningBox.Execute();
     802                 :            :             }
     803 [ #  # ][ #  # ]:          0 :             delete( pDlg );
                 [ #  # ]
     804                 :            :         }
     805                 :            : 
     806                 :            :         // if not existing the entry is entered
     807         [ #  # ]:          0 :         if( bDifferent )
     808                 :            :         {
     809         [ #  # ]:          0 :             XColorEntry* pEntry = pColorList->GetColor( nPos );
     810                 :            : 
     811                 :          0 :             Color aTmpColor (aAktuellColor);
     812         [ #  # ]:          0 :             if (eCM != CM_RGB)
     813         [ #  # ]:          0 :                 ConvertColorValues (aTmpColor, CM_RGB);
     814                 :            : 
     815                 :          0 :             pEntry->SetColor( aTmpColor );
     816         [ #  # ]:          0 :             pEntry->SetName( aName );
     817                 :            : 
     818         [ #  # ]:          0 :             aLbColor.Modify( pEntry, nPos );
     819         [ #  # ]:          0 :             aLbColor.SelectEntryPos( nPos );
     820                 :            :             /////
     821         [ #  # ]:          0 :             aValSetColorList.SetItemColor( nPos + 1, pEntry->GetColor() );
     822         [ #  # ]:          0 :             aValSetColorList.SetItemText( nPos + 1, pEntry->GetName() );
     823         [ #  # ]:          0 :             aEdtName.SetText( aName );
     824                 :            : 
     825         [ #  # ]:          0 :             aCtlPreviewOld.Invalidate();
     826                 :            : 
     827                 :          0 :             *pnColorListState |= CT_MODIFIED;
     828 [ #  # ][ #  # ]:          0 :         }
     829                 :            :     }
     830                 :          0 :     return 0;
     831                 :            : }
     832                 :            : 
     833                 :            : //------------------------------------------------------------------------
     834                 :            : 
     835                 :          0 : IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl)
     836                 :            : {
     837 [ #  # ][ #  # ]:          0 :     SvColorDialog* pColorDlg = new SvColorDialog( GetParentDialog() );
                 [ #  # ]
     838                 :            : 
     839                 :          0 :     Color aTmpColor (aAktuellColor);
     840         [ #  # ]:          0 :     if (eCM != CM_RGB)
     841         [ #  # ]:          0 :         ConvertColorValues (aTmpColor, CM_RGB);
     842                 :            : 
     843         [ #  # ]:          0 :     pColorDlg->SetColor (aTmpColor);
     844         [ #  # ]:          0 :     pColorDlg->SetMode( svtools::ColorPickerMode_MODIFY );
     845                 :            : 
     846 [ #  # ][ #  # ]:          0 :     if( pColorDlg->Execute() == RET_OK )
     847                 :            :     {
     848                 :          0 :         sal_uInt16 nK = 0;
     849         [ #  # ]:          0 :         Color aPreviewColor = pColorDlg->GetColor();
     850                 :          0 :         aAktuellColor = aPreviewColor;
     851         [ #  # ]:          0 :         if (eCM != CM_RGB)
     852         [ #  # ]:          0 :             ConvertColorValues (aAktuellColor, eCM);
     853                 :            : 
     854         [ #  # ]:          0 :         aMtrFldColorModel1.SetValue( ColorToPercent_Impl( aAktuellColor.GetRed() ) );
     855         [ #  # ]:          0 :         aMtrFldColorModel2.SetValue( ColorToPercent_Impl( aAktuellColor.GetGreen() ) );
     856         [ #  # ]:          0 :         aMtrFldColorModel3.SetValue( ColorToPercent_Impl( aAktuellColor.GetBlue() ) );
     857         [ #  # ]:          0 :         aMtrFldColorModel4.SetValue( ColorToPercent_Impl( nK ) );
     858                 :            : 
     859                 :            :         // fill ItemSet and pass it on to XOut
     860 [ #  # ][ #  # ]:          0 :         rXFSet.Put( XFillColorItem( String(), aPreviewColor ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     861                 :            :         //aCtlPreviewOld.SetAttributes( aXFillAttr );
     862         [ #  # ]:          0 :         aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
     863                 :            : 
     864         [ #  # ]:          0 :         aCtlPreviewNew.Invalidate();
     865                 :            :     }
     866 [ #  # ][ #  # ]:          0 :     delete( pColorDlg );
     867                 :            : 
     868                 :          0 :     return 0;
     869                 :            : }
     870                 :            : 
     871                 :            : //------------------------------------------------------------------------
     872                 :            : 
     873                 :          0 : IMPL_LINK_NOARG(SvxColorTabPage, ClickDeleteHdl_Impl)
     874                 :            : {
     875                 :          0 :     sal_uInt16 nPos = aLbColor.GetSelectEntryPos();
     876                 :            : 
     877         [ #  # ]:          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     878                 :            :     {
     879                 :            :         QueryBox aQueryBox( GetParentDialog(), WinBits( WB_YES_NO | WB_DEF_NO ),
     880 [ #  # ][ #  # ]:          0 :             String( CUI_RES( RID_SVXSTR_ASK_DEL_COLOR ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     881                 :            : 
     882 [ #  # ][ #  # ]:          0 :         if( aQueryBox.Execute() == RET_YES )
     883                 :            :         {
     884         [ #  # ]:          0 :             XColorEntry* pEntry = pColorList->Remove( nPos );
     885                 :            :             DBG_ASSERT( pEntry, "ColorEntry not found !" );
     886 [ #  # ][ #  # ]:          0 :             delete pEntry;
     887                 :            : 
     888                 :            :             // update Listbox and ValueSet
     889         [ #  # ]:          0 :             aLbColor.RemoveEntry( nPos );
     890         [ #  # ]:          0 :             aValSetColorList.Clear();
     891         [ #  # ]:          0 :             FillValueSet_Impl( aValSetColorList );
     892                 :            : 
     893                 :            :             // positioning
     894         [ #  # ]:          0 :             aLbColor.SelectEntryPos( nPos );
     895         [ #  # ]:          0 :             SelectColorLBHdl_Impl( this );
     896                 :            : 
     897         [ #  # ]:          0 :             aCtlPreviewOld.Invalidate();
     898                 :            : 
     899                 :          0 :             *pnColorListState |= CT_MODIFIED;
     900         [ #  # ]:          0 :         }
     901                 :            :     }
     902                 :          0 :     UpdateModified();
     903                 :            : 
     904                 :          0 :     return 0;
     905                 :            : }
     906                 :            : 
     907                 :            : //------------------------------------------------------------------------
     908                 :            : 
     909                 :          0 : IMPL_LINK_NOARG(SvxColorTabPage, SelectColorLBHdl_Impl)
     910                 :            : {
     911                 :          0 :     sal_uInt16 nPos = aLbColor.GetSelectEntryPos();
     912         [ #  # ]:          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     913                 :            :     {
     914                 :          0 :         aValSetColorList.SelectItem( nPos + 1 );
     915         [ #  # ]:          0 :         aEdtName.SetText( aLbColor.GetSelectEntry() );
     916                 :            : 
     917                 :            :         rXFSet.Put( XFillColorItem( String(),
     918 [ #  # ][ #  # ]:          0 :                                     aLbColor.GetSelectEntryColor() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     919                 :          0 :         aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
     920                 :          0 :         aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
     921                 :            : 
     922                 :          0 :         aCtlPreviewOld.Invalidate();
     923                 :          0 :         aCtlPreviewNew.Invalidate();
     924                 :            : 
     925                 :          0 :         ChangeColorHdl_Impl( this );
     926                 :            :     }
     927                 :          0 :     return 0;
     928                 :            : }
     929                 :            : 
     930                 :            : //------------------------------------------------------------------------
     931                 :            : 
     932                 :          0 : IMPL_LINK_NOARG(SvxColorTabPage, SelectValSetHdl_Impl)
     933                 :            : {
     934                 :          0 :     sal_uInt16 nPos = aValSetColorList.GetSelectItemId();
     935         [ #  # ]:          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     936                 :            :     {
     937                 :          0 :         aLbColor.SelectEntryPos( nPos - 1 );
     938         [ #  # ]:          0 :         aEdtName.SetText( aLbColor.GetSelectEntry() );
     939                 :            : 
     940                 :            :         rXFSet.Put( XFillColorItem( String(),
     941 [ #  # ][ #  # ]:          0 :                                     aLbColor.GetSelectEntryColor() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     942                 :          0 :         aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
     943                 :          0 :         aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
     944                 :            : 
     945                 :          0 :         aCtlPreviewOld.Invalidate();
     946                 :          0 :         aCtlPreviewNew.Invalidate();
     947                 :            : 
     948                 :          0 :         ChangeColorHdl_Impl( this );
     949                 :            :     }
     950                 :          0 :     return 0;
     951                 :            : }
     952                 :            : 
     953                 :            : //------------------------------------------------------------------------
     954                 :            : 
     955                 :          0 : void SvxColorTabPage::ConvertColorValues (Color& rColor, ColorModel eModell)
     956                 :            : {
     957      [ #  #  # ]:          0 :     switch (eModell)
     958                 :            :     {
     959                 :            :         case CM_RGB:
     960                 :            :         {
     961                 :          0 :             CmykToRgb_Impl (rColor, (sal_uInt16)rColor.GetTransparency() );
     962                 :          0 :             rColor.SetTransparency ((sal_uInt8) 0);
     963                 :            :         }
     964                 :          0 :         break;
     965                 :            : 
     966                 :            :         case CM_CMYK:
     967                 :            :         {
     968                 :            :             sal_uInt16 nK;
     969         [ #  # ]:          0 :             RgbToCmyk_Impl (rColor, nK );
     970         [ #  # ]:          0 :             rColor.SetTransparency ((sal_uInt8) nK);
     971                 :            :         }
     972                 :          0 :         break;
     973                 :            :     }
     974                 :          0 : }
     975                 :            : 
     976                 :          0 : IMPL_LINK_NOARG(SvxColorTabPage, SelectColorModelHdl_Impl)
     977                 :            : {
     978                 :          0 :     int nPos = aLbColorModel.GetSelectEntryPos();
     979         [ #  # ]:          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     980                 :            :     {
     981         [ #  # ]:          0 :         if (eCM != (ColorModel) nPos)
     982                 :            :         {
     983                 :          0 :             ConvertColorValues (aAktuellColor, (ColorModel) nPos);
     984                 :            :         }
     985                 :            : 
     986                 :          0 :         eCM = (ColorModel) nPos;
     987                 :            : 
     988      [ #  #  # ]:          0 :         switch( eCM )
     989                 :            :         {
     990                 :            :             case CM_RGB:
     991                 :            :             {
     992         [ #  # ]:          0 :                 String aStr( aLbColorModel.GetSelectEntry() );
     993         [ #  # ]:          0 :                 String aColorStr(rtl::OUString("~X"));
     994                 :          0 :                 xub_StrLen nIdx = 1;
     995         [ #  # ]:          0 :                 aColorStr.SetChar( nIdx, aStr.GetChar( 0 ) );
     996         [ #  # ]:          0 :                 aFtColorModel1.SetText( aColorStr );
     997         [ #  # ]:          0 :                 aColorStr.SetChar( nIdx, aStr.GetChar( 1 ) );
     998         [ #  # ]:          0 :                 aFtColorModel2.SetText( aColorStr );
     999         [ #  # ]:          0 :                 aColorStr.SetChar( nIdx, aStr.GetChar( 2 ) );
    1000         [ #  # ]:          0 :                 aFtColorModel3.SetText( aColorStr );
    1001                 :            : 
    1002         [ #  # ]:          0 :                 aFtColorModel4.Hide();
    1003         [ #  # ]:          0 :                 aMtrFldColorModel4.Hide();
    1004         [ #  # ]:          0 :                 aMtrFldColorModel4.SetValue( 0L );
    1005                 :            : 
    1006         [ #  # ]:          0 :                 aMtrFldColorModel1.SetHelpId( HID_TPCOLOR_RGB_1 );
    1007         [ #  # ]:          0 :                 aMtrFldColorModel2.SetHelpId( HID_TPCOLOR_RGB_2 );
    1008         [ #  # ]:          0 :                 aMtrFldColorModel3.SetHelpId( HID_TPCOLOR_RGB_3 );
    1009                 :            : 
    1010                 :            :                 // Because the old HelpText is still at the Control
    1011                 :            :                 // a change of the HelpID alone would not work
    1012 [ #  # ][ #  # ]:          0 :                 aMtrFldColorModel1.SetHelpText( String() );
                 [ #  # ]
    1013 [ #  # ][ #  # ]:          0 :                 aMtrFldColorModel2.SetHelpText( String() );
                 [ #  # ]
    1014 [ #  # ][ #  # ]:          0 :                 aMtrFldColorModel3.SetHelpText( String() );
                 [ #  # ]
    1015                 :            : 
    1016                 :            :                 // handle RGB-values (0..255, not in %),
    1017                 :            :                 // and adjust MetricFields respectively
    1018         [ #  # ]:          0 :                 aMtrFldColorModel1.SetUnit(FUNIT_NONE);
    1019         [ #  # ]:          0 :                 aMtrFldColorModel1.SetMin(0);
    1020         [ #  # ]:          0 :                 aMtrFldColorModel1.SetMax(255);
    1021         [ #  # ]:          0 :                 aMtrFldColorModel1.SetLast(255);
    1022                 :            : 
    1023         [ #  # ]:          0 :                 aMtrFldColorModel2.SetUnit(FUNIT_NONE);
    1024         [ #  # ]:          0 :                 aMtrFldColorModel2.SetMin(0);
    1025         [ #  # ]:          0 :                 aMtrFldColorModel2.SetMax(255);
    1026         [ #  # ]:          0 :                 aMtrFldColorModel2.SetLast(255);
    1027                 :            : 
    1028         [ #  # ]:          0 :                 aMtrFldColorModel3.SetUnit(FUNIT_NONE);
    1029         [ #  # ]:          0 :                 aMtrFldColorModel3.SetMin(0);
    1030         [ #  # ]:          0 :                 aMtrFldColorModel3.SetMax(255);
    1031 [ #  # ][ #  # ]:          0 :                 aMtrFldColorModel3.SetLast(255);
                 [ #  # ]
    1032                 :            :             }
    1033                 :          0 :             break;
    1034                 :            : 
    1035                 :            :             case CM_CMYK:
    1036                 :            :             {
    1037         [ #  # ]:          0 :                 String aStr( aLbColorModel.GetSelectEntry() );
    1038         [ #  # ]:          0 :                 String aColorStr(rtl::OUString("~X"));
    1039                 :          0 :                 xub_StrLen nIdx = 1;
    1040         [ #  # ]:          0 :                 aColorStr.SetChar( nIdx, aStr.GetChar( 0 ) );
    1041         [ #  # ]:          0 :                 aFtColorModel1.SetText( aColorStr );
    1042         [ #  # ]:          0 :                 aColorStr.SetChar( nIdx, aStr.GetChar( 1 ) );
    1043         [ #  # ]:          0 :                 aFtColorModel2.SetText( aColorStr );
    1044         [ #  # ]:          0 :                 aColorStr.SetChar( nIdx,aStr.GetChar( 2 ) );
    1045         [ #  # ]:          0 :                 aFtColorModel3.SetText( aColorStr );
    1046         [ #  # ]:          0 :                 aColorStr.SetChar( nIdx,aStr.GetChar( 3 ) );
    1047         [ #  # ]:          0 :                 aFtColorModel4.SetText( aColorStr );
    1048                 :            : 
    1049         [ #  # ]:          0 :                 aFtColorModel4.Show();
    1050         [ #  # ]:          0 :                 aMtrFldColorModel4.Show();
    1051                 :            : 
    1052         [ #  # ]:          0 :                 aMtrFldColorModel1.SetHelpId( HID_TPCOLOR_CMYK_1 );
    1053         [ #  # ]:          0 :                 aMtrFldColorModel2.SetHelpId( HID_TPCOLOR_CMYK_2 );
    1054         [ #  # ]:          0 :                 aMtrFldColorModel3.SetHelpId( HID_TPCOLOR_CMYK_3 );
    1055                 :            : 
    1056                 :            :                 // s.o.
    1057 [ #  # ][ #  # ]:          0 :                 aMtrFldColorModel1.SetHelpText( String() );
                 [ #  # ]
    1058 [ #  # ][ #  # ]:          0 :                 aMtrFldColorModel2.SetHelpText( String() );
                 [ #  # ]
    1059 [ #  # ][ #  # ]:          0 :                 aMtrFldColorModel3.SetHelpText( String() );
                 [ #  # ]
    1060                 :            : 
    1061                 :            :                 // handle CMYK-values (0..100%)
    1062                 :            :                 // and adjust MetricFields respectively
    1063         [ #  # ]:          0 :                 String aStrUnit( RTL_CONSTASCII_USTRINGPARAM( " %" ) );
    1064                 :            : 
    1065         [ #  # ]:          0 :                 aMtrFldColorModel1.SetUnit(FUNIT_CUSTOM);
    1066         [ #  # ]:          0 :                 aMtrFldColorModel1.SetCustomUnitText( aStrUnit );
    1067         [ #  # ]:          0 :                 aMtrFldColorModel1.SetMin(0);
    1068         [ #  # ]:          0 :                 aMtrFldColorModel1.SetMax(100);
    1069         [ #  # ]:          0 :                 aMtrFldColorModel1.SetLast(100);
    1070                 :            : 
    1071         [ #  # ]:          0 :                 aMtrFldColorModel2.SetUnit(FUNIT_CUSTOM);
    1072         [ #  # ]:          0 :                 aMtrFldColorModel2.SetCustomUnitText( aStrUnit );
    1073         [ #  # ]:          0 :                 aMtrFldColorModel2.SetMin(0);
    1074         [ #  # ]:          0 :                 aMtrFldColorModel2.SetMax(100);
    1075         [ #  # ]:          0 :                 aMtrFldColorModel2.SetLast(100);
    1076                 :            : 
    1077         [ #  # ]:          0 :                 aMtrFldColorModel3.SetUnit(FUNIT_CUSTOM);
    1078         [ #  # ]:          0 :                 aMtrFldColorModel3.SetCustomUnitText( aStrUnit );
    1079         [ #  # ]:          0 :                 aMtrFldColorModel3.SetMin(0);
    1080         [ #  # ]:          0 :                 aMtrFldColorModel3.SetMax(100);
    1081 [ #  # ][ #  # ]:          0 :                 aMtrFldColorModel3.SetLast(100);
         [ #  # ][ #  # ]
    1082                 :            :             }
    1083                 :          0 :             break;
    1084                 :            :         }
    1085                 :            : 
    1086                 :          0 :         aMtrFldColorModel1.SetValue( ColorToPercent_Impl( aAktuellColor.GetRed() ) );
    1087                 :          0 :         aMtrFldColorModel2.SetValue( ColorToPercent_Impl( aAktuellColor.GetGreen() ) );
    1088                 :          0 :         aMtrFldColorModel3.SetValue( ColorToPercent_Impl( aAktuellColor.GetBlue() ) );
    1089                 :          0 :         aMtrFldColorModel4.SetValue( ColorToPercent_Impl( aAktuellColor.GetTransparency() ) );
    1090                 :            :     }
    1091                 :            : 
    1092 [ #  # ][ #  # ]:          0 :     aMtrFldColorModel1.SetAccessibleName( GetNonMnemonicString(aFtColorModel1.GetText()) );
                 [ #  # ]
    1093 [ #  # ][ #  # ]:          0 :     aMtrFldColorModel2.SetAccessibleName( GetNonMnemonicString(aFtColorModel2.GetText()) );
                 [ #  # ]
    1094 [ #  # ][ #  # ]:          0 :     aMtrFldColorModel3.SetAccessibleName( GetNonMnemonicString(aFtColorModel3.GetText()) );
                 [ #  # ]
    1095 [ #  # ][ #  # ]:          0 :     aMtrFldColorModel4.SetAccessibleName( GetNonMnemonicString(aFtColorModel4.GetText()) );
                 [ #  # ]
    1096                 :            : 
    1097                 :          0 :     return 0;
    1098                 :            : }
    1099                 :            : 
    1100                 :            : //------------------------------------------------------------------------
    1101                 :            : 
    1102                 :          0 : long SvxColorTabPage::ChangeColorHdl_Impl( void* )
    1103                 :            : {
    1104                 :          0 :     int nPos = aLbColor.GetSelectEntryPos();
    1105         [ #  # ]:          0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
    1106                 :            :     {
    1107                 :          0 :         XColorEntry* pEntry = pColorList->GetColor( nPos );
    1108                 :            : 
    1109                 :          0 :         aAktuellColor.SetColor ( pEntry->GetColor().GetColor() );
    1110         [ #  # ]:          0 :         if (eCM != CM_RGB)
    1111                 :          0 :             ConvertColorValues (aAktuellColor, eCM);
    1112                 :            : 
    1113                 :          0 :         aMtrFldColorModel1.SetValue( ColorToPercent_Impl( aAktuellColor.GetRed() ) );
    1114                 :          0 :         aMtrFldColorModel2.SetValue( ColorToPercent_Impl( aAktuellColor.GetGreen() ) );
    1115                 :          0 :         aMtrFldColorModel3.SetValue( ColorToPercent_Impl( aAktuellColor.GetBlue() ) );
    1116                 :          0 :         aMtrFldColorModel4.SetValue( ColorToPercent_Impl( aAktuellColor.GetTransparency() ) );
    1117                 :            : 
    1118                 :            :         // fill ItemSet and pass it on to XOut
    1119 [ #  # ][ #  # ]:          0 :         rXFSet.Put( XFillColorItem( String(), pEntry->GetColor() ) );
                 [ #  # ]
    1120                 :          0 :         aCtlPreviewOld.SetAttributes( aXFillAttr.GetItemSet() );
    1121                 :          0 :         aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() );
    1122                 :            : 
    1123                 :          0 :         aCtlPreviewNew.Invalidate();
    1124                 :            :     }
    1125                 :          0 :     return 0;
    1126                 :            : }
    1127                 :            : 
    1128                 :            : //------------------------------------------------------------------------
    1129                 :            : 
    1130                 :          0 : void SvxColorTabPage::FillValueSet_Impl( ValueSet& rVs )
    1131                 :            : {
    1132                 :          0 :     long nCount = pColorList->Count();
    1133                 :            :     XColorEntry* pColorEntry;
    1134                 :            : 
    1135         [ #  # ]:          0 :     if( nCount > 104 )
    1136                 :          0 :         rVs.SetStyle( rVs.GetStyle() | WB_VSCROLL );
    1137                 :            : 
    1138         [ #  # ]:          0 :     for( long i = 0; i < nCount; i++ )
    1139                 :            :     {
    1140                 :          0 :         pColorEntry = pColorList->GetColor( i );
    1141                 :          0 :         rVs.InsertItem( (sal_uInt16) i + 1, pColorEntry->GetColor(), pColorEntry->GetName() );
    1142                 :            :     }
    1143                 :          0 : }
    1144                 :            : 
    1145                 :            : //------------------------------------------------------------------------
    1146                 :            : 
    1147                 :            : // A RGB value is converted to a CMYK value - not in an ideal way as
    1148                 :            : // R is converted into C, G into M and B into Y. The K value is held in an
    1149                 :            : // extra variable. For further color models one should develop own
    1150                 :            : // classes which should contain the respective casts.
    1151                 :            : 
    1152                 :          0 : void SvxColorTabPage::RgbToCmyk_Impl( Color& rColor, sal_uInt16& rK )
    1153                 :            : {
    1154                 :          0 :     sal_uInt16 const nColor1 = 255 - rColor.GetRed();
    1155                 :          0 :     sal_uInt16 const nColor2 = 255 - rColor.GetGreen();
    1156                 :          0 :     sal_uInt16 const nColor3 = 255 - rColor.GetBlue();
    1157                 :            : 
    1158                 :          0 :     rK = Min( Min( nColor1, nColor2 ), nColor3 );
    1159                 :            : 
    1160                 :          0 :     rColor.SetRed( sal::static_int_cast< sal_uInt8 >( nColor1 - rK ) );
    1161                 :          0 :     rColor.SetGreen( sal::static_int_cast< sal_uInt8 >( nColor2 - rK ) );
    1162                 :          0 :     rColor.SetBlue( sal::static_int_cast< sal_uInt8 >( nColor3 - rK ) );
    1163                 :          0 : }
    1164                 :            : 
    1165                 :            : //------------------------------------------------------------------------
    1166                 :            : 
    1167                 :            : // reverse case to RgbToCmyk_Impl (see above)
    1168                 :            : 
    1169                 :          0 : void SvxColorTabPage::CmykToRgb_Impl( Color& rColor, const sal_uInt16 nK )
    1170                 :            : {
    1171                 :            :     long lTemp;
    1172                 :            : 
    1173                 :          0 :     lTemp = 255 - ( rColor.GetRed() + nK );
    1174                 :            : 
    1175         [ #  # ]:          0 :     if( lTemp < 0L )
    1176                 :          0 :         lTemp = 0L;
    1177                 :          0 :     rColor.SetRed( (sal_uInt8)lTemp );
    1178                 :            : 
    1179                 :          0 :     lTemp = 255 - ( rColor.GetGreen() + nK );
    1180                 :            : 
    1181         [ #  # ]:          0 :     if( lTemp < 0L )
    1182                 :          0 :         lTemp = 0L;
    1183                 :          0 :     rColor.SetGreen( (sal_uInt8)lTemp );
    1184                 :            : 
    1185                 :          0 :     lTemp = 255 - ( rColor.GetBlue() + nK );
    1186                 :            : 
    1187         [ #  # ]:          0 :     if( lTemp < 0L )
    1188                 :          0 :         lTemp = 0L;
    1189                 :          0 :     rColor.SetBlue( (sal_uInt8)lTemp );
    1190                 :          0 : }
    1191                 :            : 
    1192                 :            : //------------------------------------------------------------------------
    1193                 :            : 
    1194                 :          0 : sal_uInt16 SvxColorTabPage::ColorToPercent_Impl( sal_uInt16 nColor )
    1195                 :            : {
    1196                 :          0 :     sal_uInt16 nWert = 0;
    1197                 :            : 
    1198      [ #  #  # ]:          0 :     switch (eCM)
    1199                 :            :     {
    1200                 :            :         case CM_RGB :
    1201                 :          0 :             nWert = nColor;
    1202                 :          0 :             break;
    1203                 :            : 
    1204                 :            :         case CM_CMYK:
    1205                 :          0 :             nWert = (sal_uInt16) ( (double) nColor * 100.0 / 255.0 + 0.5 );
    1206                 :          0 :             break;
    1207                 :            :     }
    1208                 :            : 
    1209                 :          0 :     return ( nWert );
    1210                 :            : }
    1211                 :            : 
    1212                 :            : //------------------------------------------------------------------------
    1213                 :            : 
    1214                 :          0 : sal_uInt16 SvxColorTabPage::PercentToColor_Impl( sal_uInt16 nPercent )
    1215                 :            : {
    1216                 :          0 :     sal_uInt16 nWert = 0;
    1217                 :            : 
    1218      [ #  #  # ]:          0 :     switch (eCM)
    1219                 :            :     {
    1220                 :            :         case CM_RGB :
    1221                 :          0 :             nWert = nPercent;
    1222                 :          0 :             break;
    1223                 :            : 
    1224                 :            :         case CM_CMYK:
    1225                 :          0 :             nWert = (sal_uInt16) ( (double) nPercent * 255.0 / 100.0 + 0.5 );
    1226                 :          0 :             break;
    1227                 :            :     }
    1228                 :            : 
    1229                 :          0 :     return ( nWert );
    1230                 :            : }
    1231                 :            : 
    1232                 :            : //------------------------------------------------------------------------
    1233                 :            : 
    1234                 :          0 : void SvxColorTabPage::FillUserData()
    1235                 :            : {
    1236                 :            :     // the color model is saved in the Ini-file
    1237         [ #  # ]:          0 :     SetUserData( UniString::CreateFromInt32( eCM ) );
    1238                 :          0 : }
    1239                 :            : 
    1240                 :            : //------------------------------------------------------------------------
    1241                 :            : 
    1242                 :          0 : void SvxColorTabPage::SetupForViewFrame( SfxViewFrame *pViewFrame )
    1243                 :            : {
    1244                 :          0 :     const OfaRefItem<XColorList> *pPtr = NULL;
    1245 [ #  # ][ #  # ]:          0 :     if ( pViewFrame != NULL && pViewFrame->GetDispatcher() )
                 [ #  # ]
    1246                 :            :         pPtr = (const OfaRefItem<XColorList> *)pViewFrame->
    1247                 :            :             GetDispatcher()->Execute( SID_GET_COLORLIST,
    1248                 :          0 :                                       SFX_CALLMODE_SYNCHRON );
    1249 [ #  # ][ #  # ]:          0 :     pColorList = pPtr ? pPtr->GetValue() : XColorList::GetStdColorList();
    1250                 :            : 
    1251                 :          0 :     SetPageType( &pShadow->nUnknownType );
    1252                 :          0 :     SetDlgType( &pShadow->nUnknownType );
    1253                 :          0 :     SetPos( &pShadow->nUnknownPos );
    1254                 :          0 :     SetAreaTP( &pShadow->bIsAreaTP );
    1255                 :          0 :     SetColorChgd( (ChangeType*)&pShadow->nChangeType );
    1256                 :          0 :     Construct();
    1257                 :          0 : }
    1258                 :            : 
    1259                 :          0 : void SvxColorTabPage::SaveToViewFrame( SfxViewFrame *pViewFrame )
    1260                 :            : {
    1261         [ #  # ]:          0 :     if( !pColorList.is() )
    1262                 :          0 :         return;
    1263                 :            : 
    1264                 :          0 :     pColorList->Save();
    1265                 :            : 
    1266         [ #  # ]:          0 :     if( !pViewFrame )
    1267                 :          0 :         return;
    1268                 :            : 
    1269                 :            :     // notify current viewframe that it uses the same color table
    1270         [ #  # ]:          0 :     if ( !pViewFrame->GetDispatcher() )
    1271                 :          0 :         return;
    1272                 :            : 
    1273                 :            :     const OfaRefItem<XColorList> * pPtr;
    1274                 :          0 :     pPtr = (const OfaRefItem<XColorList>*)pViewFrame->GetDispatcher()->Execute( SID_GET_COLORLIST, SFX_CALLMODE_SYNCHRON );
    1275         [ #  # ]:          0 :     if( pPtr )
    1276                 :            :     {
    1277                 :          0 :         XColorListRef pReference = pPtr->GetValue();
    1278                 :            : 
    1279 [ #  # ][ #  # ]:          0 :         if( pReference.is() &&
         [ #  # ][ #  # ]
    1280         [ #  # ]:          0 :             pReference->GetPath() == pColorList->GetPath() &&
    1281         [ #  # ]:          0 :             pReference->GetName() == pColorList->GetName() )
    1282         [ #  # ]:          0 :             SfxObjectShell::Current()->PutItem( SvxColorListItem( pColorList,
    1283 [ #  # ][ #  # ]:          0 :                                                                   SID_COLOR_TABLE ) );
                 [ #  # ]
    1284                 :            :     }
    1285                 :            : }
    1286                 :            : 
    1287                 :          0 : void SvxColorTabPage::SetPropertyList( XPropertyListType t, const XPropertyListRef &xRef )
    1288                 :            : {
    1289                 :            :     (void) t;
    1290                 :            :     OSL_ASSERT( t == XCOLOR_LIST );
    1291         [ #  # ]:          0 :     pColorList = XColorListRef( static_cast<XColorList *>(xRef.get() ) );
    1292                 :          0 : }
    1293                 :            : 
    1294                 :          0 : void SvxColorTabPage::SetColorList( XColorListRef pColList )
    1295                 :            : {
    1296         [ #  # ]:          0 :     SetPropertyList( XCOLOR_LIST, XPropertyListRef( ( pColList.get() ) ) );
    1297                 :          0 : }
    1298                 :            : 
    1299                 :          0 : XPropertyListRef SvxColorTabPage::GetPropertyList( XPropertyListType t )
    1300                 :            : {
    1301                 :            :     (void) t;
    1302                 :            :     OSL_ASSERT( t == XCOLOR_LIST );
    1303                 :          0 :     return XPropertyListRef( pColorList.get() );
    1304                 :            : }
    1305                 :            : 
    1306                 :            : 
    1307                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
    1308                 :            : 

Generated by: LCOV version 1.10