LCOV - code coverage report
Current view: top level - sc/source/ui/attrdlg - tabpages.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 100 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 13 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 "global.hxx"
      23             : #include "document.hxx"
      24             : #include "attrib.hxx"
      25             : #include "scresid.hxx"
      26             : #include "sc.hrc"
      27             : 
      28             : #include "tabpages.hxx"
      29             : 
      30             : // STATIC DATA -----------------------------------------------------------
      31             : 
      32             : const sal_uInt16 ScTabPageProtection::pProtectionRanges[] =
      33             : {
      34             :     SID_SCATTR_PROTECTION,
      35             :     SID_SCATTR_PROTECTION,
      36             :     0
      37             : };
      38             : 
      39             : // Zellschutz-Tabpage:
      40             : 
      41           0 : ScTabPageProtection::ScTabPageProtection(vcl::Window* pParent, const SfxItemSet& rCoreAttrs)
      42             :     : SfxTabPage(pParent, "CellProtectionPage",
      43           0 :         "modules/scalc/ui/cellprotectionpage.ui", &rCoreAttrs)
      44             : {
      45           0 :     get(m_pBtnHideCell,"checkHideAll");
      46           0 :     get(m_pBtnProtect,"checkProtected");
      47           0 :     get(m_pBtnHideFormula,"checkHideFormula");
      48           0 :     get(m_pBtnHidePrint,"checkHidePrinting");
      49             : 
      50             :     // This Page need ExchangeSupport
      51           0 :     SetExchangeSupport();
      52             : 
      53             :     //  States will be set in Reset
      54           0 :     bTriEnabled = bDontCare = bProtect = bHideForm = bHideCell = bHidePrint = false;
      55             : 
      56           0 :     m_pBtnProtect->SetClickHdl(     LINK( this, ScTabPageProtection, ButtonClickHdl ) );
      57           0 :     m_pBtnHideCell->SetClickHdl(    LINK( this, ScTabPageProtection, ButtonClickHdl ) );
      58           0 :     m_pBtnHideFormula->SetClickHdl( LINK( this, ScTabPageProtection, ButtonClickHdl ) );
      59           0 :     m_pBtnHidePrint->SetClickHdl(   LINK( this, ScTabPageProtection, ButtonClickHdl ) );
      60           0 : }
      61             : 
      62           0 : ScTabPageProtection::~ScTabPageProtection()
      63             : {
      64           0 :     disposeOnce();
      65           0 : }
      66             : 
      67           0 : void ScTabPageProtection::dispose()
      68             : {
      69           0 :     m_pBtnHideCell.clear();
      70           0 :     m_pBtnProtect.clear();
      71           0 :     m_pBtnHideFormula.clear();
      72           0 :     m_pBtnHidePrint.clear();
      73           0 :     SfxTabPage::dispose();
      74           0 : }
      75             : 
      76           0 : VclPtr<SfxTabPage> ScTabPageProtection::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
      77             : {
      78           0 :     return VclPtr<ScTabPageProtection>::Create( pParent, *rAttrSet );
      79             : }
      80             : 
      81           0 : void ScTabPageProtection::Reset( const SfxItemSet* rCoreAttrs )
      82             : {
      83             :     //  Initialize variables
      84             : 
      85           0 :     sal_uInt16 nWhich = GetWhich( SID_SCATTR_PROTECTION );
      86           0 :     const ScProtectionAttr* pProtAttr = NULL;
      87             :     SfxItemState eItemState = rCoreAttrs->GetItemState( nWhich, false,
      88           0 :                                           reinterpret_cast<const SfxPoolItem**>(&pProtAttr) );
      89             : 
      90             :     // Is this a Default-Item?
      91           0 :     if ( eItemState == SfxItemState::DEFAULT )
      92           0 :         pProtAttr = static_cast<const ScProtectionAttr*>(&(rCoreAttrs->Get(nWhich)));
      93             :     // At SfxItemState::DONTCARE let to 0
      94             : 
      95           0 :     bTriEnabled = ( pProtAttr == NULL );                // TriState, when DontCare
      96           0 :     bDontCare = bTriEnabled;
      97           0 :     if (bTriEnabled)
      98             :     {
      99             :        //  Defaults which appear when a TriState will be clicked away:
     100             :        //  (because everything combined is an attribute, and also only
     101             :        //   everything combined as DontCare can be available - #38543#)
     102             : 
     103           0 :         bProtect = true;
     104           0 :         bHideForm = bHideCell = bHidePrint = false;
     105             :     }
     106             :     else
     107             :     {
     108           0 :         bProtect = pProtAttr->GetProtection();
     109           0 :         bHideCell = pProtAttr->GetHideCell();
     110           0 :         bHideForm = pProtAttr->GetHideFormula();
     111           0 :         bHidePrint = pProtAttr->GetHidePrint();
     112             :     }
     113             : 
     114             :     //  Start Controls
     115             : 
     116           0 :     m_pBtnProtect->EnableTriState( bTriEnabled );
     117           0 :     m_pBtnHideCell->EnableTriState( bTriEnabled );
     118           0 :     m_pBtnHideFormula->EnableTriState( bTriEnabled );
     119           0 :     m_pBtnHidePrint->EnableTriState( bTriEnabled );
     120             : 
     121           0 :     UpdateButtons();
     122           0 : }
     123             : 
     124           0 : bool ScTabPageProtection::FillItemSet( SfxItemSet* rCoreAttrs )
     125             : {
     126           0 :     bool                bAttrsChanged   = false;
     127           0 :     sal_uInt16              nWhich          = GetWhich( SID_SCATTR_PROTECTION );
     128           0 :     const SfxPoolItem*  pOldItem        = GetOldItem( *rCoreAttrs, SID_SCATTR_PROTECTION );
     129           0 :     const SfxItemSet&   rOldSet         = GetItemSet();
     130           0 :     SfxItemState        eItemState      = rOldSet.GetItemState( nWhich, false );
     131           0 :     ScProtectionAttr    aProtAttr;
     132             : 
     133           0 :     if ( !bDontCare )
     134             :     {
     135           0 :         aProtAttr.SetProtection( bProtect );
     136           0 :         aProtAttr.SetHideCell( bHideCell );
     137           0 :         aProtAttr.SetHideFormula( bHideForm );
     138           0 :         aProtAttr.SetHidePrint( bHidePrint );
     139             : 
     140           0 :         if ( bTriEnabled )
     141           0 :             bAttrsChanged = true;                   // DontCare -> properly value
     142             :         else
     143           0 :             bAttrsChanged = !pOldItem || !( aProtAttr == *static_cast<const ScProtectionAttr*>(pOldItem) );
     144             :     }
     145             : 
     146           0 :     if ( bAttrsChanged )
     147           0 :         rCoreAttrs->Put( aProtAttr );
     148           0 :     else if ( eItemState == SfxItemState::DEFAULT )
     149           0 :         rCoreAttrs->ClearItem( nWhich );
     150             : 
     151           0 :     return bAttrsChanged;
     152             : }
     153             : 
     154           0 : SfxTabPage::sfxpg ScTabPageProtection::DeactivatePage( SfxItemSet* pSetP )
     155             : {
     156           0 :     if ( pSetP )
     157           0 :         FillItemSet( pSetP );
     158             : 
     159           0 :     return LEAVE_PAGE;
     160             : }
     161             : 
     162           0 : IMPL_LINK( ScTabPageProtection, ButtonClickHdl, TriStateBox*, pBox )
     163             : {
     164           0 :     TriState eState = pBox->GetState();
     165           0 :     if ( eState == TRISTATE_INDET )
     166           0 :         bDontCare = true;                           // everything combined at DontCare
     167             :     else
     168             :     {
     169           0 :         bDontCare = false;                          // DontCare from everywhere
     170           0 :         bool bOn = ( eState == TRISTATE_TRUE );       // from a selected value
     171             : 
     172           0 :         if ( pBox == m_pBtnProtect )
     173           0 :             bProtect = bOn;
     174           0 :         else if ( pBox == m_pBtnHideCell )
     175           0 :             bHideCell = bOn;
     176           0 :         else if ( pBox == m_pBtnHideFormula )
     177           0 :             bHideForm = bOn;
     178           0 :         else if ( pBox == m_pBtnHidePrint )
     179           0 :             bHidePrint = bOn;
     180             :         else
     181             :         {
     182             :             OSL_FAIL("falscher Button");
     183             :         }
     184             :     }
     185             : 
     186           0 :     UpdateButtons();        // TriState and Logic-Enable
     187             : 
     188           0 :     return 0;
     189             : }
     190             : 
     191           0 : void ScTabPageProtection::UpdateButtons()
     192             : {
     193           0 :     if ( bDontCare )
     194             :     {
     195           0 :         m_pBtnProtect->SetState( TRISTATE_INDET );
     196           0 :         m_pBtnHideCell->SetState( TRISTATE_INDET );
     197           0 :         m_pBtnHideFormula->SetState( TRISTATE_INDET );
     198           0 :         m_pBtnHidePrint->SetState( TRISTATE_INDET );
     199             :     }
     200             :     else
     201             :     {
     202           0 :         m_pBtnProtect->SetState( bProtect ? TRISTATE_TRUE : TRISTATE_FALSE );
     203           0 :         m_pBtnHideCell->SetState( bHideCell ? TRISTATE_TRUE : TRISTATE_FALSE );
     204           0 :         m_pBtnHideFormula->SetState( bHideForm ? TRISTATE_TRUE : TRISTATE_FALSE );
     205           0 :         m_pBtnHidePrint->SetState( bHidePrint ? TRISTATE_TRUE : TRISTATE_FALSE );
     206             :     }
     207             : 
     208           0 :     bool bEnable = ( m_pBtnHideCell->GetState() != TRISTATE_TRUE );
     209             :     {
     210           0 :         m_pBtnProtect->Enable( bEnable );
     211           0 :         m_pBtnHideFormula->Enable( bEnable );
     212             :     }
     213           0 : }
     214             : 
     215             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11