LCOV - code coverage report
Current view: top level - sc/source/ui/optdlg - tpdefaults.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 72 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 19 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 :     disposeOnce();
      34           0 : }
      35             : 
      36           0 : void ScTpDefaultsOptions::dispose()
      37             : {
      38           0 :     m_pEdNSheets.clear();
      39           0 :     m_pEdSheetPrefix.clear();
      40           0 :     SfxTabPage::dispose();
      41           0 : }
      42             : 
      43           0 : VclPtr<SfxTabPage> ScTpDefaultsOptions::Create(vcl::Window *pParent, const SfxItemSet *rCoreAttrs)
      44             : {
      45           0 :     return VclPtr<ScTpDefaultsOptions>::Create(pParent, *rCoreAttrs);
      46             : }
      47             : 
      48           0 : bool ScTpDefaultsOptions::FillItemSet(SfxItemSet *rCoreSet)
      49             : {
      50           0 :     bool bRet = false;
      51           0 :     ScDefaultsOptions aOpt;
      52             : 
      53           0 :     SCTAB nTabCount = static_cast<SCTAB>(m_pEdNSheets->GetValue());
      54           0 :     OUString aSheetPrefix = m_pEdSheetPrefix->GetText();
      55             : 
      56           0 :     if ( m_pEdNSheets->IsValueChangedFromSaved()
      57           0 :          || m_pEdSheetPrefix->GetSavedValue() != aSheetPrefix )
      58             :     {
      59           0 :         aOpt.SetInitTabCount( nTabCount );
      60           0 :         aOpt.SetInitTabPrefix( aSheetPrefix );
      61             : 
      62           0 :         rCoreSet->Put( ScTpDefaultsItem( SID_SCDEFAULTSOPTIONS, aOpt ) );
      63           0 :         bRet = true;
      64             :     }
      65           0 :     return bRet;
      66             : }
      67             : 
      68           0 : void ScTpDefaultsOptions::Reset(const SfxItemSet* rCoreSet)
      69             : {
      70           0 :     ScDefaultsOptions aOpt;
      71           0 :     const SfxPoolItem* pItem = NULL;
      72             : 
      73           0 :     if(SfxItemState::SET == rCoreSet->GetItemState(SID_SCDEFAULTSOPTIONS, false , &pItem))
      74           0 :         aOpt = static_cast<const ScTpDefaultsItem*>(pItem)->GetDefaultsOptions();
      75             : 
      76           0 :     m_pEdNSheets->SetValue( static_cast<sal_uInt16>( aOpt.GetInitTabCount()) );
      77           0 :     m_pEdSheetPrefix->SetText( aOpt.GetInitTabPrefix() );
      78           0 :     m_pEdNSheets->SaveValue();
      79           0 :     m_pEdSheetPrefix->SaveValue();
      80           0 : }
      81             : 
      82           0 : SfxTabPage::sfxpg ScTpDefaultsOptions::DeactivatePage(SfxItemSet* /*pSet*/)
      83             : {
      84           0 :     return KEEP_PAGE;
      85             : }
      86             : 
      87           0 : void ScTpDefaultsOptions::CheckNumSheets()
      88             : {
      89           0 :     sal_Int64 nVal = m_pEdNSheets->GetValue();
      90           0 :     if (nVal > MAXINITTAB)
      91           0 :         m_pEdNSheets->SetValue(MAXINITTAB);
      92           0 :     if (nVal < MININITTAB)
      93           0 :         m_pEdNSheets->SetValue(MININITTAB);
      94           0 : }
      95             : 
      96           0 : void ScTpDefaultsOptions::CheckPrefix(Edit* pEdit)
      97             : {
      98           0 :     if (!pEdit)
      99           0 :         return;
     100             : 
     101           0 :     OUString aSheetPrefix = pEdit->GetText();
     102             : 
     103           0 :     if ( !aSheetPrefix.isEmpty() && !ScDocument::ValidTabName( aSheetPrefix ) )
     104             :     {
     105             :         // Revert to last good Prefix and also select it to
     106             :         // indicate something illegal was typed
     107           0 :         Selection aSel( 0,  maOldPrefixValue.getLength() );
     108           0 :         pEdit->SetText( maOldPrefixValue, aSel );
     109             :     }
     110             :     else
     111             :     {
     112           0 :         OnFocusPrefixInput(pEdit);
     113           0 :     }
     114             : }
     115             : 
     116           0 : void ScTpDefaultsOptions::OnFocusPrefixInput(Edit* pEdit)
     117             : {
     118           0 :     if (!pEdit)
     119           0 :         return;
     120             : 
     121             :     // Store Prefix in case we need to revert
     122           0 :     maOldPrefixValue = pEdit->GetText();
     123             : }
     124             : 
     125           0 : IMPL_LINK_NOARG(ScTpDefaultsOptions, NumModifiedHdl)
     126             : {
     127           0 :     CheckNumSheets();
     128           0 :     return 0;
     129             : }
     130             : 
     131           0 : IMPL_LINK( ScTpDefaultsOptions, PrefixModifiedHdl, Edit*, pEdit )
     132             : {
     133           0 :     CheckPrefix(pEdit);
     134           0 :     return 0;
     135             : }
     136             : 
     137           0 : IMPL_LINK( ScTpDefaultsOptions, PrefixEditOnFocusHdl, Edit*, pEdit )
     138             : {
     139           0 :     OnFocusPrefixInput(pEdit);
     140           0 :     return 0;
     141           0 : }
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11