LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - tabbgcolordlg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 71 0.0 %
Date: 2014-04-14 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #undef SC_DLLIMPLEMENTATION
      22             : 
      23             : #include "tabbgcolordlg.hxx"
      24             : #include "scresid.hxx"
      25             : #include "miscdlgs.hrc"
      26             : 
      27             : #include <tools/color.hxx>
      28             : #include <sfx2/objsh.hxx>
      29             : #include <svx/xtable.hxx>
      30             : #include <svx/drawitem.hxx>
      31             : #include <unotools/pathoptions.hxx>
      32             : #include <tools/resid.hxx>
      33             : #include <editeng/editrids.hrc>
      34             : #include <editeng/eerdll.hxx>
      35             : #include <vcl/builder.hxx>
      36             : 
      37             : #include <boost/scoped_ptr.hpp>
      38             : 
      39             : #define HDL(hdl) LINK(this,ScTabBgColorDlg,hdl)
      40             : 
      41           0 : ScTabBgColorDlg::ScTabBgColorDlg(Window* pParent, const OUString& rTitle,
      42             :     const OUString& rTabBgColorNoColorText, const Color& rDefaultColor,
      43             :     const OString& sHelpId)
      44             :     : ModalDialog(pParent, "TabColorDialog", "modules/scalc/ui/tabcolordialog.ui")
      45             :     , m_aTabBgColor(rDefaultColor)
      46             :     , m_aTabBgColorNoColorText(rTabBgColorNoColorText)
      47           0 :     , m_sHelpId(sHelpId)
      48             : 
      49             : {
      50           0 :     get(m_pTabBgColorSet, "colorset");
      51           0 :     m_pTabBgColorSet->SetDialog(this);
      52           0 :     m_pTabBgColorSet->SetColCount(m_pTabBgColorSet->getColumnCount());
      53           0 :     get(m_pBtnOk, "ok");
      54             : 
      55           0 :     SetHelpId( sHelpId );
      56           0 :     this->SetText( rTitle );
      57           0 :     this->SetStyle(GetStyle() | WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL | WB_SYSTEMWINDOW | WB_STANDALONE | WB_HIDE);
      58             : 
      59           0 :     FillColorValueSets_Impl();
      60           0 :     m_pTabBgColorSet->SetDoubleClickHdl( HDL(TabBgColorDblClickHdl_Impl) );
      61           0 :     m_pBtnOk->SetClickHdl( HDL(TabBgColorOKHdl_Impl) );
      62           0 : }
      63             : 
      64           0 : void ScTabBgColorDlg::GetSelectedColor( Color& rColor ) const
      65             : {
      66           0 :     rColor = this->m_aTabBgColor;
      67           0 : }
      68             : 
      69           0 : void ScTabBgColorDlg::FillColorValueSets_Impl()
      70             : {
      71           0 :     SfxObjectShell* pDocSh = SfxObjectShell::Current();
      72           0 :     const SfxPoolItem* pItem = NULL;
      73           0 :     XColorListRef pColorList;
      74             : 
      75           0 :     sal_uInt16 nSelectedItem = 0;
      76             : 
      77             :     OSL_ENSURE( pDocSh, "DocShell not found!" );
      78             : 
      79           0 :     if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem(SID_COLOR_TABLE) ) ) )
      80           0 :         pColorList = ( (SvxColorListItem*)pItem )->GetColorList();
      81           0 :     if ( !pColorList.is() )
      82           0 :         pColorList = XColorList::CreateStdColorList();
      83             : 
      84           0 :     long nColorCount(0);
      85             : 
      86           0 :     if ( pColorList.is() )
      87             :     {
      88           0 :         nColorCount = pColorList->Count();
      89           0 :         m_pTabBgColorSet->addEntriesForXColorList(*pColorList);
      90             :     }
      91             : 
      92           0 :     if (nColorCount)
      93             :     {
      94           0 :         const WinBits nBits(m_pTabBgColorSet->GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS);
      95           0 :         m_pTabBgColorSet->SetText( m_aTabBgColorNoColorText );
      96           0 :         m_pTabBgColorSet->SetStyle( nBits );
      97             :     }
      98             : 
      99             :     //lock down a preferred size
     100           0 :     const sal_uInt32 nColCount = m_pTabBgColorSet->getColumnCount();
     101           0 :     const sal_uInt32 nRowCount(ceil(double(nColorCount)/nColCount));
     102           0 :     const sal_uInt32 nLength = m_pTabBgColorSet->getEntryEdgeLength();
     103           0 :     Size aSize(m_pTabBgColorSet->CalcWindowSizePixel(Size(nLength, nLength), nColCount, nRowCount));
     104           0 :     m_pTabBgColorSet->set_width_request(aSize.Width()+8);
     105           0 :     m_pTabBgColorSet->set_height_request(aSize.Height()+8);
     106             : 
     107           0 :     m_pTabBgColorSet->SelectItem(nSelectedItem);
     108           0 : }
     109             : 
     110           0 : IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorDblClickHdl_Impl)
     111             : /*
     112             :     Handler, called when color selection is changed
     113             : */
     114             : {
     115           0 :     sal_uInt16 nItemId = m_pTabBgColorSet->GetSelectItemId();
     116           0 :     Color aColor = nItemId ? ( m_pTabBgColorSet->GetItemColor( nItemId ) ) : Color( COL_AUTO );
     117           0 :     m_aTabBgColor = aColor;
     118           0 :     EndDialog( sal_True );
     119           0 :     return 0;
     120             : }
     121             : 
     122           0 : IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorOKHdl_Impl)
     123             : {
     124             : 
     125             : //    Handler, called when the OK button is pushed
     126             : 
     127           0 :     sal_uInt16 nItemId = m_pTabBgColorSet->GetSelectItemId();
     128           0 :     Color aColor = nItemId ? ( m_pTabBgColorSet->GetItemColor( nItemId ) ) : Color( COL_AUTO );
     129           0 :     m_aTabBgColor = aColor;
     130           0 :     EndDialog( sal_True );
     131           0 :     return 0;
     132             : }
     133             : 
     134           0 : ScTabBgColorDlg::ScTabBgColorValueSet::ScTabBgColorValueSet(Window* pParent, WinBits nStyle)
     135             :     : SvxColorValueSet(pParent, nStyle)
     136           0 :     , m_pTabBgColorDlg(NULL)
     137             : {
     138           0 : }
     139             : 
     140           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeScTabBgColorValueSet(Window *pParent, VclBuilder::stringmap &rMap)
     141             : {
     142           0 :     WinBits nWinBits = WB_TABSTOP;
     143             : 
     144           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     145           0 :     if (!sBorder.isEmpty())
     146           0 :        nWinBits |= WB_BORDER;
     147             : 
     148           0 :     return new ScTabBgColorDlg::ScTabBgColorValueSet(pParent, nWinBits);
     149             : }
     150             : 
     151           0 : void ScTabBgColorDlg::ScTabBgColorValueSet::KeyInput( const KeyEvent& rKEvt )
     152             : {
     153           0 :     switch ( rKEvt.GetKeyCode().GetCode() )
     154             :     {
     155             :         case KEY_SPACE:
     156             :         case KEY_RETURN:
     157             :         {
     158           0 :             sal_uInt16 nItemId = GetSelectItemId();
     159           0 :             const Color& aColor = nItemId ? ( GetItemColor( nItemId ) ) : Color( COL_AUTO );
     160           0 :             m_pTabBgColorDlg->m_aTabBgColor = aColor;
     161           0 :             m_pTabBgColorDlg->EndDialog(sal_True);
     162             :         }
     163           0 :         break;
     164             :     }
     165           0 :     SvxColorValueSet::KeyInput(rKEvt);
     166           0 : }
     167             : 
     168             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10