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

Generated by: LCOV version 1.10