LCOV - code coverage report
Current view: top level - sc/source/ui/attrdlg - tabpages.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 92 0.0 %
Date: 2014-11-03 Functions: 0 11 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             : static const sal_uInt16 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 : const sal_uInt16* ScTabPageProtection::GetRanges()
      63             : {
      64           0 :     return pProtectionRanges;
      65             : }
      66             : 
      67           0 : SfxTabPage* ScTabPageProtection::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
      68             : {
      69           0 :     return ( new ScTabPageProtection( pParent, *rAttrSet ) );
      70             : }
      71             : 
      72           0 : void ScTabPageProtection::Reset( const SfxItemSet* rCoreAttrs )
      73             : {
      74             :     //  Initialize variables
      75             : 
      76           0 :     sal_uInt16 nWhich = GetWhich( SID_SCATTR_PROTECTION );
      77           0 :     const ScProtectionAttr* pProtAttr = NULL;
      78             :     SfxItemState eItemState = rCoreAttrs->GetItemState( nWhich, false,
      79           0 :                                           (const SfxPoolItem**)&pProtAttr );
      80             : 
      81             :     // Is this a Default-Item?
      82           0 :     if ( eItemState == SfxItemState::DEFAULT )
      83           0 :         pProtAttr = static_cast<const ScProtectionAttr*>(&(rCoreAttrs->Get(nWhich)));
      84             :     // At SfxItemState::DONTCARE let to 0
      85             : 
      86           0 :     bTriEnabled = ( pProtAttr == NULL );                // TriState, when DontCare
      87           0 :     bDontCare = bTriEnabled;
      88           0 :     if (bTriEnabled)
      89             :     {
      90             :        //  Defaults which appear when a TriState will be clicked away:
      91             :        //  (because everything combined is an attribute, and also only
      92             :        //   everything combined as DontCare can be available - #38543#)
      93             : 
      94           0 :         bProtect = true;
      95           0 :         bHideForm = bHideCell = bHidePrint = false;
      96             :     }
      97             :     else
      98             :     {
      99           0 :         bProtect = pProtAttr->GetProtection();
     100           0 :         bHideCell = pProtAttr->GetHideCell();
     101           0 :         bHideForm = pProtAttr->GetHideFormula();
     102           0 :         bHidePrint = pProtAttr->GetHidePrint();
     103             :     }
     104             : 
     105             :     //  Start Controls
     106             : 
     107           0 :     m_pBtnProtect->EnableTriState( bTriEnabled );
     108           0 :     m_pBtnHideCell->EnableTriState( bTriEnabled );
     109           0 :     m_pBtnHideFormula->EnableTriState( bTriEnabled );
     110           0 :     m_pBtnHidePrint->EnableTriState( bTriEnabled );
     111             : 
     112           0 :     UpdateButtons();
     113           0 : }
     114             : 
     115           0 : bool ScTabPageProtection::FillItemSet( SfxItemSet* rCoreAttrs )
     116             : {
     117           0 :     bool                bAttrsChanged   = false;
     118           0 :     sal_uInt16              nWhich          = GetWhich( SID_SCATTR_PROTECTION );
     119           0 :     const SfxPoolItem*  pOldItem        = GetOldItem( *rCoreAttrs, SID_SCATTR_PROTECTION );
     120           0 :     const SfxItemSet&   rOldSet         = GetItemSet();
     121           0 :     SfxItemState        eItemState      = rOldSet.GetItemState( nWhich, false );
     122           0 :     ScProtectionAttr    aProtAttr;
     123             : 
     124           0 :     if ( !bDontCare )
     125             :     {
     126           0 :         aProtAttr.SetProtection( bProtect );
     127           0 :         aProtAttr.SetHideCell( bHideCell );
     128           0 :         aProtAttr.SetHideFormula( bHideForm );
     129           0 :         aProtAttr.SetHidePrint( bHidePrint );
     130             : 
     131           0 :         if ( bTriEnabled )
     132           0 :             bAttrsChanged = true;                   // DontCare -> properly value
     133             :         else
     134           0 :             bAttrsChanged = !pOldItem || !( aProtAttr == *static_cast<const ScProtectionAttr*>(pOldItem) );
     135             :     }
     136             : 
     137           0 :     if ( bAttrsChanged )
     138           0 :         rCoreAttrs->Put( aProtAttr );
     139           0 :     else if ( eItemState == SfxItemState::DEFAULT )
     140           0 :         rCoreAttrs->ClearItem( nWhich );
     141             : 
     142           0 :     return bAttrsChanged;
     143             : }
     144             : 
     145           0 : int ScTabPageProtection::DeactivatePage( SfxItemSet* pSetP )
     146             : {
     147           0 :     if ( pSetP )
     148           0 :         FillItemSet( pSetP );
     149             : 
     150           0 :     return LEAVE_PAGE;
     151             : }
     152             : 
     153           0 : IMPL_LINK( ScTabPageProtection, ButtonClickHdl, TriStateBox*, pBox )
     154             : {
     155           0 :     TriState eState = pBox->GetState();
     156           0 :     if ( eState == TRISTATE_INDET )
     157           0 :         bDontCare = true;                           // everything combined at DontCare
     158             :     else
     159             :     {
     160           0 :         bDontCare = false;                          // DontCare from everywhere
     161           0 :         bool bOn = ( eState == TRISTATE_TRUE );       // from a selected value
     162             : 
     163           0 :         if ( pBox == m_pBtnProtect )
     164           0 :             bProtect = bOn;
     165           0 :         else if ( pBox == m_pBtnHideCell )
     166           0 :             bHideCell = bOn;
     167           0 :         else if ( pBox == m_pBtnHideFormula )
     168           0 :             bHideForm = bOn;
     169           0 :         else if ( pBox == m_pBtnHidePrint )
     170           0 :             bHidePrint = bOn;
     171             :         else
     172             :         {
     173             :             OSL_FAIL("falscher Button");
     174             :         }
     175             :     }
     176             : 
     177           0 :     UpdateButtons();        // TriState and Logic-Enable
     178             : 
     179           0 :     return 0;
     180             : }
     181             : 
     182           0 : void ScTabPageProtection::UpdateButtons()
     183             : {
     184           0 :     if ( bDontCare )
     185             :     {
     186           0 :         m_pBtnProtect->SetState( TRISTATE_INDET );
     187           0 :         m_pBtnHideCell->SetState( TRISTATE_INDET );
     188           0 :         m_pBtnHideFormula->SetState( TRISTATE_INDET );
     189           0 :         m_pBtnHidePrint->SetState( TRISTATE_INDET );
     190             :     }
     191             :     else
     192             :     {
     193           0 :         m_pBtnProtect->SetState( bProtect ? TRISTATE_TRUE : TRISTATE_FALSE );
     194           0 :         m_pBtnHideCell->SetState( bHideCell ? TRISTATE_TRUE : TRISTATE_FALSE );
     195           0 :         m_pBtnHideFormula->SetState( bHideForm ? TRISTATE_TRUE : TRISTATE_FALSE );
     196           0 :         m_pBtnHidePrint->SetState( bHidePrint ? TRISTATE_TRUE : TRISTATE_FALSE );
     197             :     }
     198             : 
     199           0 :     bool bEnable = ( m_pBtnHideCell->GetState() != TRISTATE_TRUE );
     200             :     {
     201           0 :         m_pBtnProtect->Enable( bEnable );
     202           0 :         m_pBtnHideFormula->Enable( bEnable );
     203             :     }
     204           0 : }
     205             : 
     206             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10