LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - tabbgcolordlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 77 0.0 %
Date: 2012-08-25 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 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 2008 by Sun Microsystems, Inc.
       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                 :            : 
      30                 :            : #undef SC_DLLIMPLEMENTATION
      31                 :            : 
      32                 :            : //------------------------------------------------------------------
      33                 :            : 
      34                 :            : #include "tabbgcolordlg.hxx"
      35                 :            : #include "scresid.hxx"
      36                 :            : #include "miscdlgs.hrc"
      37                 :            : 
      38                 :            : #include <tools/color.hxx>
      39                 :            : #include <sfx2/objsh.hxx>
      40                 :            : #include <svx/xtable.hxx>
      41                 :            : #include <svx/drawitem.hxx>
      42                 :            : #include <unotools/pathoptions.hxx>
      43                 :            : #include <tools/resid.hxx>
      44                 :            : #include <editeng/editrids.hrc>
      45                 :            : #include <editeng/eerdll.hxx>
      46                 :            : 
      47                 :            : #include <boost/scoped_ptr.hpp>
      48                 :            : 
      49                 :            : //==================================================================
      50                 :            : 
      51                 :            : #define HDL(hdl) LINK(this,ScTabBgColorDlg,hdl)
      52                 :            : 
      53                 :          0 : ScTabBgColorDlg::ScTabBgColorDlg( Window*         pParent,
      54                 :            :                                   const String&   rTitle,
      55                 :            :                                   const String&   rTabBgColorNoColorText,
      56                 :            :                                   const Color&    rDefaultColor,
      57                 :            :                                   const rtl::OString& sHelpId ) :
      58                 :            :     ModalDialog    ( pParent, ScResId( RID_SCDLG_TAB_BG_COLOR ) ),
      59                 :            :     aBorderWin              ( this, ScResId( TAB_BG_COLOR_CT_BORDER ) ),
      60                 :            :     aTabBgColorSet          ( &aBorderWin, ScResId( TAB_BG_COLOR_SET_BGDCOLOR ), this ),
      61                 :            :     aBtnOk                  ( this, ScResId( BTN_OK ) ),
      62                 :            :     aBtnCancel              ( this, ScResId( BTN_CANCEL ) ),
      63                 :            :     aBtnHelp                ( this, ScResId( BTN_HELP ) ),
      64                 :            :     aTabBgColor             ( rDefaultColor ),
      65                 :            :     aTabBgColorNoColorText  ( rTabBgColorNoColorText ),
      66                 :          0 :     msHelpId                ( sHelpId )
      67                 :            : 
      68                 :            : {
      69                 :          0 :     SetHelpId( sHelpId );
      70                 :          0 :     this->SetText( rTitle );
      71                 :          0 :     this->SetStyle(GetStyle() | WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL | WB_SYSTEMWINDOW | WB_STANDALONE | WB_HIDE);
      72                 :            : 
      73                 :          0 :     FillColorValueSets_Impl();
      74                 :          0 :     aTabBgColorSet.SetDoubleClickHdl( HDL(TabBgColorDblClickHdl_Impl) );
      75                 :          0 :     aBtnOk.SetClickHdl( HDL(TabBgColorOKHdl_Impl) );
      76                 :          0 :     FreeResource();
      77                 :          0 : }
      78                 :            : 
      79                 :            : //------------------------------------------------------------------------
      80                 :            : 
      81                 :          0 : void ScTabBgColorDlg::GetSelectedColor( Color& rColor ) const
      82                 :            : {
      83                 :          0 :     rColor = this->aTabBgColor;
      84                 :          0 : }
      85                 :            : 
      86                 :          0 : ScTabBgColorDlg::~ScTabBgColorDlg()
      87                 :            : {
      88                 :          0 : }
      89                 :            : 
      90                 :          0 : void ScTabBgColorDlg::FillColorValueSets_Impl()
      91                 :            : {
      92                 :          0 :     SfxObjectShell* pDocSh = SfxObjectShell::Current();
      93                 :          0 :     const SfxPoolItem* pItem = NULL;
      94                 :          0 :     XColorListRef pColorList;
      95                 :            : 
      96                 :          0 :     const Size aSize15x15 = Size( 15, 15 );
      97                 :          0 :     sal_uInt16 nSelectedItem = 0;
      98                 :            : 
      99                 :            :     OSL_ENSURE( pDocSh, "DocShell not found!" );
     100                 :            : 
     101                 :          0 :     if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem(SID_COLOR_TABLE) ) ) )
     102                 :          0 :         pColorList = ( (SvxColorListItem*)pItem )->GetColorList();
     103                 :          0 :     if ( !pColorList.is() )
     104                 :          0 :         pColorList = XColorList::CreateStdColorList();
     105                 :            : 
     106                 :          0 :     if ( pColorList.is() )
     107                 :            :     {
     108                 :          0 :         sal_uInt16 i = 0;
     109                 :          0 :         long nCount = pColorList->Count();
     110                 :          0 :         XColorEntry* pEntry = NULL;
     111                 :          0 :         Color aColWhite( COL_WHITE );
     112                 :          0 :         String aStrWhite( EditResId( RID_SVXITEMS_COLOR_WHITE ) );
     113                 :          0 :         WinBits nBits = ( aTabBgColorSet.GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS);
     114                 :          0 :         aTabBgColorSet.SetText( aTabBgColorNoColorText );
     115                 :          0 :         aTabBgColorSet.SetStyle( nBits );
     116                 :          0 :         for ( i = 0; i < nCount; i++ )
     117                 :            :         {
     118                 :          0 :             pEntry = pColorList->GetColor(i);
     119                 :          0 :             aTabBgColorSet.InsertItem( i + 1, pEntry->GetColor(), pEntry->GetName() );
     120                 :          0 :             if (pEntry->GetColor() == aTabBgColor)
     121                 :          0 :                 nSelectedItem = (i + 1);
     122                 :            :         }
     123                 :            : 
     124                 :          0 :         while ( i < 80 )
     125                 :            :         {
     126                 :          0 :             aTabBgColorSet.InsertItem( i + 1, aColWhite, aStrWhite );
     127                 :          0 :             i++;
     128                 :            :         }
     129                 :            : 
     130                 :          0 :         if ( nCount > 80 )
     131                 :            :         {
     132                 :          0 :             aTabBgColorSet.SetStyle( nBits | WB_VSCROLL );
     133                 :          0 :         }
     134                 :            :     }
     135                 :          0 :     aTabBgColorSet.SetColCount( 10 );
     136                 :          0 :     aTabBgColorSet.SetLineCount( 10 );
     137                 :          0 :     aTabBgColorSet.CalcWindowSizePixel( aSize15x15 );
     138                 :          0 :     aTabBgColorSet.Format();
     139                 :          0 :     aTabBgColorSet.SelectItem(nSelectedItem);
     140                 :          0 :     aTabBgColorSet.Resize();
     141                 :          0 : }
     142                 :            : 
     143                 :          0 : IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorDblClickHdl_Impl)
     144                 :            : /*
     145                 :            :     Handler, called when color selection is changed
     146                 :            : */
     147                 :            : {
     148                 :          0 :     sal_uInt16 nItemId = aTabBgColorSet.GetSelectItemId();
     149                 :          0 :     Color aColor = nItemId ? ( aTabBgColorSet.GetItemColor( nItemId ) ) : Color( COL_AUTO );
     150                 :          0 :     aTabBgColor = aColor;
     151                 :          0 :     EndDialog( sal_True );
     152                 :          0 :     return 0;
     153                 :            : }
     154                 :            : 
     155                 :          0 : IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorOKHdl_Impl)
     156                 :            : {
     157                 :            : 
     158                 :            : //    Handler, called when the OK button is pushed
     159                 :            : 
     160                 :          0 :     sal_uInt16 nItemId = aTabBgColorSet.GetSelectItemId();
     161                 :          0 :     Color aColor = nItemId ? ( aTabBgColorSet.GetItemColor( nItemId ) ) : Color( COL_AUTO );
     162                 :          0 :     aTabBgColor = aColor;
     163                 :          0 :     EndDialog( sal_True );
     164                 :          0 :     return 0;
     165                 :            : }
     166                 :            : 
     167                 :          0 : ScTabBgColorDlg::ScTabBgColorValueSet::ScTabBgColorValueSet( Control* pParent, const ResId& rResId, ScTabBgColorDlg* pTabBgColorDlg ) :
     168                 :          0 :     ValueSet(pParent, rResId)
     169                 :            : {
     170                 :          0 :     aTabBgColorDlg = pTabBgColorDlg;
     171                 :          0 : }
     172                 :            : 
     173                 :          0 : void ScTabBgColorDlg::ScTabBgColorValueSet::KeyInput( const KeyEvent& rKEvt )
     174                 :            : {
     175                 :          0 :     switch ( rKEvt.GetKeyCode().GetCode() )
     176                 :            :     {
     177                 :            :         case KEY_SPACE:
     178                 :            :         case KEY_RETURN:
     179                 :            :         {
     180                 :          0 :             sal_uInt16 nItemId = GetSelectItemId();
     181                 :          0 :             const Color& aColor = nItemId ? ( GetItemColor( nItemId ) ) : Color( COL_AUTO );
     182                 :          0 :             aTabBgColorDlg->aTabBgColor = aColor;
     183                 :          0 :             aTabBgColorDlg->EndDialog(sal_True);
     184                 :            :         }
     185                 :          0 :         break;
     186                 :            :     }
     187                 :          0 :     ValueSet::KeyInput(rKEvt);
     188                 :          0 : }
     189                 :            : 
     190                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10