LCOV - code coverage report
Current view: top level - sc/source/ui/optdlg - tpdefaults.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 66 0.0 %
Date: 2014-04-14 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             : 
      10             : 
      11             : #undef SC_DLLIMPLEMENTATION
      12             : 
      13             : #include "tpdefaults.hxx"
      14             : #include "optdlg.hrc"
      15             : #include "scresid.hxx"
      16             : #include "scmod.hxx"
      17             : #include "defaultsoptions.hxx"
      18             : #include "document.hxx"
      19             : 
      20             : 
      21           0 : ScTpDefaultsOptions::ScTpDefaultsOptions(Window *pParent, const SfxItemSet &rCoreSet) :
      22           0 :     SfxTabPage(pParent, "OptDefaultPage", "modules/scalc/ui/optdefaultpage.ui", rCoreSet)
      23             : 
      24             : {
      25           0 :     get( m_pEdNSheets, "sheetsnumber");
      26           0 :     get( m_pEdSheetPrefix, "sheetprefix");
      27             : 
      28           0 :     m_pEdNSheets->SetModifyHdl( LINK(this, ScTpDefaultsOptions, NumModifiedHdl) );
      29           0 :     m_pEdSheetPrefix->SetModifyHdl( LINK(this, ScTpDefaultsOptions, PrefixModifiedHdl) );
      30           0 :     m_pEdSheetPrefix->SetGetFocusHdl( LINK(this, ScTpDefaultsOptions, PrefixEditOnFocusHdl) );
      31           0 : }
      32             : 
      33           0 : ScTpDefaultsOptions::~ScTpDefaultsOptions()
      34             : {
      35           0 : }
      36             : 
      37           0 : SfxTabPage* ScTpDefaultsOptions::Create(Window *pParent, const SfxItemSet &rCoreAttrs)
      38             : {
      39           0 :     return new ScTpDefaultsOptions(pParent, rCoreAttrs);
      40             : }
      41             : 
      42           0 : bool ScTpDefaultsOptions::FillItemSet(SfxItemSet &rCoreSet)
      43             : {
      44           0 :     sal_Bool bRet = false;
      45           0 :     ScDefaultsOptions aOpt;
      46             : 
      47           0 :     SCTAB nTabCount = static_cast<SCTAB>(m_pEdNSheets->GetValue());
      48           0 :     OUString aSheetPrefix = m_pEdSheetPrefix->GetText();
      49             : 
      50             : 
      51           0 :     if ( m_pEdNSheets->GetSavedValue() != m_pEdNSheets->GetText()
      52           0 :          || m_pEdSheetPrefix->GetSavedValue() != aSheetPrefix )
      53             :     {
      54           0 :         aOpt.SetInitTabCount( nTabCount );
      55           0 :         aOpt.SetInitTabPrefix( aSheetPrefix );
      56             : 
      57           0 :         rCoreSet.Put( ScTpDefaultsItem( SID_SCDEFAULTSOPTIONS, aOpt ) );
      58           0 :         bRet = true;
      59             :     }
      60           0 :     return bRet;
      61             : }
      62             : 
      63           0 : void ScTpDefaultsOptions::Reset(const SfxItemSet& rCoreSet)
      64             : {
      65           0 :     ScDefaultsOptions aOpt;
      66           0 :     const SfxPoolItem* pItem = NULL;
      67             : 
      68           0 :     if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCDEFAULTSOPTIONS, false , &pItem))
      69           0 :         aOpt = ((const ScTpDefaultsItem*)pItem)->GetDefaultsOptions();
      70             : 
      71           0 :     m_pEdNSheets->SetValue( static_cast<sal_uInt16>( aOpt.GetInitTabCount()) );
      72           0 :     m_pEdSheetPrefix->SetText( aOpt.GetInitTabPrefix() );
      73           0 :     m_pEdNSheets->SaveValue();
      74           0 :     m_pEdSheetPrefix->SaveValue();
      75           0 : }
      76             : 
      77           0 : int ScTpDefaultsOptions::DeactivatePage(SfxItemSet* /*pSet*/)
      78             : {
      79           0 :     return KEEP_PAGE;
      80             : }
      81             : 
      82           0 : void ScTpDefaultsOptions::CheckNumSheets()
      83             : {
      84           0 :     sal_Int64 nVal = m_pEdNSheets->GetValue();
      85           0 :     if (nVal > MAXINITTAB)
      86           0 :         m_pEdNSheets->SetValue(MAXINITTAB);
      87           0 :     if (nVal < MININITTAB)
      88           0 :         m_pEdNSheets->SetValue(MININITTAB);
      89           0 : }
      90             : 
      91           0 : void ScTpDefaultsOptions::CheckPrefix(Edit* pEdit)
      92             : {
      93           0 :     if (!pEdit)
      94           0 :         return;
      95             : 
      96           0 :     OUString aSheetPrefix = pEdit->GetText();
      97             : 
      98           0 :     if ( !aSheetPrefix.isEmpty() && !ScDocument::ValidTabName( aSheetPrefix ) )
      99             :     {
     100             :         // Revert to last good Prefix and also select it to
     101             :         // indicate something illegal was typed
     102           0 :         Selection aSel( 0,  maOldPrefixValue.getLength() );
     103           0 :         pEdit->SetText( maOldPrefixValue, aSel );
     104             :     }
     105             :     else
     106             :     {
     107           0 :         OnFocusPrefixInput(pEdit);
     108           0 :     }
     109             : }
     110             : 
     111           0 : void ScTpDefaultsOptions::OnFocusPrefixInput(Edit* pEdit)
     112             : {
     113           0 :     if (!pEdit)
     114           0 :         return;
     115             : 
     116             :     // Store Prefix in case we need to revert
     117           0 :     maOldPrefixValue = pEdit->GetText();
     118             : }
     119             : 
     120             : 
     121           0 : IMPL_LINK_NOARG(ScTpDefaultsOptions, NumModifiedHdl)
     122             : {
     123           0 :     CheckNumSheets();
     124           0 :     return 0;
     125             : }
     126             : 
     127           0 : IMPL_LINK( ScTpDefaultsOptions, PrefixModifiedHdl, Edit*, pEdit )
     128             : {
     129           0 :     CheckPrefix(pEdit);
     130           0 :     return 0;
     131             : }
     132             : 
     133           0 : IMPL_LINK( ScTpDefaultsOptions, PrefixEditOnFocusHdl, Edit*, pEdit )
     134             : {
     135           0 :     OnFocusPrefixInput(pEdit);
     136           0 :     return 0;
     137           0 : }
     138             : 
     139             : 
     140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10