LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - tabbgcolordlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 87 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 18 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             : #undef SC_DLLIMPLEMENTATION
      21             : 
      22             : #include "tabbgcolordlg.hxx"
      23             : #include "scresid.hxx"
      24             : #include "miscdlgs.hrc"
      25             : 
      26             : #include <tools/color.hxx>
      27             : #include <sfx2/objsh.hxx>
      28             : #include <svx/xtable.hxx>
      29             : #include <svx/drawitem.hxx>
      30             : #include <unotools/pathoptions.hxx>
      31             : #include <tools/resid.hxx>
      32             : #include <editeng/editrids.hrc>
      33             : #include <editeng/eerdll.hxx>
      34             : #include <vcl/builderfactory.hxx>
      35             : 
      36             : #include <boost/scoped_ptr.hpp>
      37             : 
      38             : #define HDL(hdl) LINK(this,ScTabBgColorDlg,hdl)
      39             : 
      40           0 : ScTabBgColorDlg::ScTabBgColorDlg(vcl::Window* pParent, const OUString& rTitle,
      41             :     const OUString& rTabBgColorNoColorText, const Color& rDefaultColor,
      42             :     const OString& sHelpId)
      43             :     : ModalDialog(pParent, "TabColorDialog", "modules/scalc/ui/tabcolordialog.ui")
      44             :     , m_aTabBgColor(rDefaultColor)
      45           0 :     , m_aTabBgColorNoColorText(rTabBgColorNoColorText)
      46             : 
      47             : {
      48           0 :     get(m_pTabBgColorSet, "colorset");
      49           0 :     m_pTabBgColorSet->SetDialog(this);
      50           0 :     m_pTabBgColorSet->SetColCount(SvxColorValueSet::getColumnCount());
      51           0 :     get(m_pBtnOk, "ok");
      52             : 
      53           0 :     SetHelpId( sHelpId );
      54           0 :     this->SetText( rTitle );
      55           0 :     this->SetStyle(GetStyle() | WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL | WB_SYSTEMWINDOW | WB_STANDALONE | WB_HIDE);
      56             : 
      57           0 :     FillColorValueSets_Impl();
      58           0 :     m_pTabBgColorSet->SetDoubleClickHdl( HDL(TabBgColorDblClickHdl_Impl) );
      59           0 :     m_pBtnOk->SetClickHdl( HDL(TabBgColorOKHdl_Impl) );
      60           0 : }
      61             : 
      62           0 : ScTabBgColorDlg::~ScTabBgColorDlg()
      63             : {
      64           0 :     disposeOnce();
      65           0 : }
      66             : 
      67           0 : void ScTabBgColorDlg::dispose()
      68             : {
      69           0 :     m_pTabBgColorSet.clear();
      70           0 :     m_pBtnOk.clear();
      71           0 :     ModalDialog::dispose();
      72           0 : }
      73             : 
      74           0 : void ScTabBgColorDlg::GetSelectedColor( Color& rColor ) const
      75             : {
      76           0 :     rColor = this->m_aTabBgColor;
      77           0 : }
      78             : 
      79           0 : void ScTabBgColorDlg::FillColorValueSets_Impl()
      80             : {
      81           0 :     SfxObjectShell* pDocSh = SfxObjectShell::Current();
      82           0 :     const SfxPoolItem* pItem = NULL;
      83           0 :     XColorListRef pColorList;
      84             : 
      85           0 :     sal_uInt16 nSelectedItem = 0;
      86             : 
      87             :     OSL_ENSURE( pDocSh, "DocShell not found!" );
      88             : 
      89           0 :     if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem(SID_COLOR_TABLE) ) ) )
      90           0 :         pColorList = static_cast<const SvxColorListItem*>(pItem)->GetColorList();
      91           0 :     if ( !pColorList.is() )
      92           0 :         pColorList = XColorList::CreateStdColorList();
      93             : 
      94           0 :     long nColorCount(0);
      95             : 
      96           0 :     if ( pColorList.is() )
      97             :     {
      98           0 :         nColorCount = pColorList->Count();
      99           0 :         m_pTabBgColorSet->addEntriesForXColorList(*pColorList);
     100             :     }
     101             : 
     102           0 :     if (nColorCount)
     103             :     {
     104           0 :         const WinBits nBits(m_pTabBgColorSet->GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS);
     105           0 :         m_pTabBgColorSet->SetText( m_aTabBgColorNoColorText );
     106           0 :         m_pTabBgColorSet->SetStyle( nBits );
     107             :     }
     108             : 
     109             :     //lock down a preferred size
     110           0 :     const sal_uInt32 nColCount = SvxColorValueSet::getColumnCount();
     111           0 :     const sal_uInt32 nRowCount(ceil(double(nColorCount)/nColCount));
     112           0 :     const sal_uInt32 nLength = SvxColorValueSet::getEntryEdgeLength();
     113           0 :     Size aSize(m_pTabBgColorSet->CalcWindowSizePixel(Size(nLength, nLength), nColCount, nRowCount));
     114           0 :     m_pTabBgColorSet->set_width_request(aSize.Width()+8);
     115           0 :     m_pTabBgColorSet->set_height_request(aSize.Height()+8);
     116             : 
     117           0 :     m_pTabBgColorSet->SelectItem(nSelectedItem);
     118           0 : }
     119             : 
     120           0 : IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorDblClickHdl_Impl)
     121             : /*
     122             :     Handler, called when color selection is changed
     123             : */
     124             : {
     125           0 :     sal_uInt16 nItemId = m_pTabBgColorSet->GetSelectItemId();
     126           0 :     Color aColor = nItemId ? ( m_pTabBgColorSet->GetItemColor( nItemId ) ) : Color( COL_AUTO );
     127           0 :     m_aTabBgColor = aColor;
     128           0 :     EndDialog( RET_OK );
     129           0 :     return 0;
     130             : }
     131             : 
     132           0 : IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorOKHdl_Impl)
     133             : {
     134             : 
     135             : //    Handler, called when the OK button is pushed
     136             : 
     137           0 :     sal_uInt16 nItemId = m_pTabBgColorSet->GetSelectItemId();
     138           0 :     Color aColor = nItemId ? ( m_pTabBgColorSet->GetItemColor( nItemId ) ) : Color( COL_AUTO );
     139           0 :     m_aTabBgColor = aColor;
     140           0 :     EndDialog( RET_OK );
     141           0 :     return 0;
     142             : }
     143             : 
     144           0 : ScTabBgColorDlg::ScTabBgColorValueSet::ScTabBgColorValueSet(vcl::Window* pParent, WinBits nStyle)
     145             :     : SvxColorValueSet(pParent, nStyle)
     146           0 :     , m_pTabBgColorDlg(NULL)
     147             : {
     148           0 : }
     149             : 
     150           0 : ScTabBgColorDlg::ScTabBgColorValueSet::~ScTabBgColorValueSet()
     151             : {
     152           0 :     disposeOnce();
     153           0 : }
     154             : 
     155           0 : void ScTabBgColorDlg::ScTabBgColorValueSet::dispose()
     156             : {
     157           0 :     m_pTabBgColorDlg.clear();
     158           0 :     SvxColorValueSet::dispose();
     159           0 : }
     160             : 
     161           0 : VCL_BUILDER_DECL_FACTORY(ScTabBgColorValueSet)
     162             : {
     163           0 :     WinBits nWinBits = WB_TABSTOP;
     164             : 
     165           0 :     OString sBorder = VclBuilder::extractCustomProperty(rMap);
     166           0 :     if (!sBorder.isEmpty())
     167           0 :        nWinBits |= WB_BORDER;
     168             : 
     169           0 :     rRet = VclPtr<ScTabBgColorDlg::ScTabBgColorValueSet>::Create(pParent, nWinBits);
     170           0 : }
     171             : 
     172           0 : void ScTabBgColorDlg::ScTabBgColorValueSet::KeyInput( const KeyEvent& rKEvt )
     173             : {
     174           0 :     switch ( rKEvt.GetKeyCode().GetCode() )
     175             :     {
     176             :         case KEY_SPACE:
     177             :         case KEY_RETURN:
     178             :         {
     179           0 :             sal_uInt16 nItemId = GetSelectItemId();
     180           0 :             const Color& aColor = nItemId ? ( GetItemColor( nItemId ) ) : Color( COL_AUTO );
     181           0 :             m_pTabBgColorDlg->m_aTabBgColor = aColor;
     182           0 :             m_pTabBgColorDlg->EndDialog(RET_OK);
     183             :         }
     184           0 :         break;
     185             :     }
     186           0 :     SvxColorValueSet::KeyInput(rKEvt);
     187           0 : }
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11