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

Generated by: LCOV version 1.10