LCOV - code coverage report
Current view: top level - sc/source/ui/attrdlg - tabpages.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 91 0.0 %
Date: 2012-08-25 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #undef SC_DLLIMPLEMENTATION
      31                 :            : 
      32                 :            : 
      33                 :            : 
      34                 :            : #include "global.hxx"
      35                 :            : #include "document.hxx"
      36                 :            : #include "attrib.hxx"
      37                 :            : #include "scresid.hxx"
      38                 :            : #include "sc.hrc"
      39                 :            : 
      40                 :            : #include "attrdlg.hrc"
      41                 :            : #include "tabpages.hxx"
      42                 :            : 
      43                 :            : // STATIC DATA -----------------------------------------------------------
      44                 :            : 
      45                 :            : static sal_uInt16 pProtectionRanges[] =
      46                 :            : {
      47                 :            :     SID_SCATTR_PROTECTION,
      48                 :            :     SID_SCATTR_PROTECTION,
      49                 :            :     0
      50                 :            : };
      51                 :            : 
      52                 :            : //========================================================================
      53                 :            : // Zellschutz-Tabpage:
      54                 :            : //========================================================================
      55                 :            : 
      56                 :          0 : ScTabPageProtection::ScTabPageProtection( Window*           pParent,
      57                 :            :                                           const SfxItemSet& rCoreAttrs )
      58                 :            :     :   SfxTabPage          ( pParent,
      59                 :            :                               ScResId( RID_SCPAGE_PROTECTION ),
      60                 :            :                               rCoreAttrs ),
      61                 :            :         //
      62                 :            :         aFlProtect          ( this, ScResId( FL_PROTECTION      ) ),
      63                 :            :         aBtnHideCell        ( this, ScResId( BTN_HIDE_ALL       ) ),
      64                 :            :         aBtnProtect         ( this, ScResId( BTN_PROTECTED      ) ),
      65                 :            :         aBtnHideFormula     ( this, ScResId( BTN_HIDE_FORMULAR  ) ),
      66                 :            :         aTxtHint            ( this, ScResId( FT_HINT            ) ),
      67                 :            :         aFlPrint            ( this, ScResId( FL_PRINT           ) ),
      68                 :            :         aBtnHidePrint       ( this, ScResId( BTN_HIDE_PRINT     ) ),
      69                 :          0 :         aTxtHint2           ( this, ScResId( FT_HINT2           ) )
      70                 :            : {
      71                 :            :     // diese Page braucht ExchangeSupport
      72                 :          0 :     SetExchangeSupport();
      73                 :            : 
      74                 :            :     //  States werden in Reset gesetzt
      75                 :          0 :     bTriEnabled = bDontCare = bProtect = bHideForm = bHideCell = bHidePrint = false;
      76                 :            : 
      77                 :          0 :     aBtnProtect.SetClickHdl(     LINK( this, ScTabPageProtection, ButtonClickHdl ) );
      78                 :          0 :     aBtnHideCell.SetClickHdl(    LINK( this, ScTabPageProtection, ButtonClickHdl ) );
      79                 :          0 :     aBtnHideFormula.SetClickHdl( LINK( this, ScTabPageProtection, ButtonClickHdl ) );
      80                 :          0 :     aBtnHidePrint.SetClickHdl(   LINK( this, ScTabPageProtection, ButtonClickHdl ) );
      81                 :            : 
      82                 :          0 :     FreeResource();
      83                 :          0 : }
      84                 :            : 
      85                 :            : // -----------------------------------------------------------------------
      86                 :            : 
      87                 :          0 : ScTabPageProtection::~ScTabPageProtection()
      88                 :            : {
      89                 :          0 : }
      90                 :            : 
      91                 :            : //------------------------------------------------------------------------
      92                 :            : 
      93                 :          0 : sal_uInt16* ScTabPageProtection::GetRanges()
      94                 :            : {
      95                 :          0 :     return pProtectionRanges;
      96                 :            : }
      97                 :            : 
      98                 :            : // -----------------------------------------------------------------------
      99                 :            : 
     100                 :          0 : SfxTabPage* ScTabPageProtection::Create( Window*            pParent,
     101                 :            :                                                   const SfxItemSet& rAttrSet )
     102                 :            : {
     103                 :          0 :     return ( new ScTabPageProtection( pParent, rAttrSet ) );
     104                 :            : }
     105                 :            : 
     106                 :            : //------------------------------------------------------------------------
     107                 :            : 
     108                 :          0 : void ScTabPageProtection::Reset( const SfxItemSet& rCoreAttrs )
     109                 :            : {
     110                 :            :     //  Variablen initialisieren
     111                 :            : 
     112                 :          0 :     sal_uInt16 nWhich = GetWhich( SID_SCATTR_PROTECTION );
     113                 :          0 :     const ScProtectionAttr* pProtAttr = NULL;
     114                 :            :     SfxItemState eItemState = rCoreAttrs.GetItemState( nWhich, false,
     115                 :          0 :                                           (const SfxPoolItem**)&pProtAttr );
     116                 :            : 
     117                 :            :     // handelt es sich um ein Default-Item?
     118                 :          0 :     if ( eItemState == SFX_ITEM_DEFAULT )
     119                 :          0 :         pProtAttr = (const ScProtectionAttr*)&(rCoreAttrs.Get(nWhich));
     120                 :            :     // bei SFX_ITEM_DONTCARE auf 0 lassen
     121                 :            : 
     122                 :          0 :     bTriEnabled = ( pProtAttr == NULL );                // TriState, wenn DontCare
     123                 :          0 :     bDontCare = bTriEnabled;
     124                 :          0 :     if (bTriEnabled)
     125                 :            :     {
     126                 :            :         //  Defaults, die erscheinen wenn ein TriState weggeklickt wird:
     127                 :            :         //  (weil alles zusammen ein Attribut ist, kann auch nur alles zusammen
     128                 :            :         //  auf DontCare stehen - #38543#)
     129                 :          0 :         bProtect = sal_True;
     130                 :          0 :         bHideForm = bHideCell = bHidePrint = false;
     131                 :            :     }
     132                 :            :     else
     133                 :            :     {
     134                 :          0 :         bProtect = pProtAttr->GetProtection();
     135                 :          0 :         bHideCell = pProtAttr->GetHideCell();
     136                 :          0 :         bHideForm = pProtAttr->GetHideFormula();
     137                 :          0 :         bHidePrint = pProtAttr->GetHidePrint();
     138                 :            :     }
     139                 :            : 
     140                 :            :     //  Controls initialisieren
     141                 :            : 
     142                 :          0 :     aBtnProtect     .EnableTriState( bTriEnabled );
     143                 :          0 :     aBtnHideCell    .EnableTriState( bTriEnabled );
     144                 :          0 :     aBtnHideFormula .EnableTriState( bTriEnabled );
     145                 :          0 :     aBtnHidePrint   .EnableTriState( bTriEnabled );
     146                 :            : 
     147                 :          0 :     UpdateButtons();
     148                 :          0 : }
     149                 :            : 
     150                 :            : // -----------------------------------------------------------------------
     151                 :            : 
     152                 :          0 : sal_Bool ScTabPageProtection::FillItemSet( SfxItemSet& rCoreAttrs )
     153                 :            : {
     154                 :          0 :     sal_Bool                bAttrsChanged   = false;
     155                 :          0 :     sal_uInt16              nWhich          = GetWhich( SID_SCATTR_PROTECTION );
     156                 :          0 :     const SfxPoolItem*  pOldItem        = GetOldItem( rCoreAttrs, SID_SCATTR_PROTECTION );
     157                 :          0 :     const SfxItemSet&   rOldSet         = GetItemSet();
     158                 :          0 :     SfxItemState        eItemState      = rOldSet.GetItemState( nWhich, false );
     159                 :          0 :     ScProtectionAttr    aProtAttr;
     160                 :            : 
     161                 :          0 :     if ( !bDontCare )
     162                 :            :     {
     163                 :          0 :         aProtAttr.SetProtection( bProtect );
     164                 :          0 :         aProtAttr.SetHideCell( bHideCell );
     165                 :          0 :         aProtAttr.SetHideFormula( bHideForm );
     166                 :          0 :         aProtAttr.SetHidePrint( bHidePrint );
     167                 :            : 
     168                 :          0 :         if ( bTriEnabled )
     169                 :          0 :             bAttrsChanged = sal_True;                   // DontCare -> richtiger Wert
     170                 :            :         else
     171                 :          0 :             bAttrsChanged = !pOldItem || !( aProtAttr == *(const ScProtectionAttr*)pOldItem );
     172                 :            :     }
     173                 :            : 
     174                 :            :     //--------------------------------------------------
     175                 :            : 
     176                 :          0 :     if ( bAttrsChanged )
     177                 :          0 :         rCoreAttrs.Put( aProtAttr );
     178                 :          0 :     else if ( eItemState == SFX_ITEM_DEFAULT )
     179                 :          0 :         rCoreAttrs.ClearItem( nWhich );
     180                 :            : 
     181                 :          0 :     return bAttrsChanged;
     182                 :            : }
     183                 :            : 
     184                 :            : //------------------------------------------------------------------------
     185                 :            : 
     186                 :          0 : int ScTabPageProtection::DeactivatePage( SfxItemSet* pSetP )
     187                 :            : {
     188                 :          0 :     if ( pSetP )
     189                 :          0 :         FillItemSet( *pSetP );
     190                 :            : 
     191                 :          0 :     return LEAVE_PAGE;
     192                 :            : }
     193                 :            : 
     194                 :            : //------------------------------------------------------------------------
     195                 :            : 
     196                 :          0 : IMPL_LINK( ScTabPageProtection, ButtonClickHdl, TriStateBox*, pBox )
     197                 :            : {
     198                 :          0 :     TriState eState = pBox->GetState();
     199                 :          0 :     if ( eState == STATE_DONTKNOW )
     200                 :          0 :         bDontCare = sal_True;                           // alles zusammen auf DontCare
     201                 :            :     else
     202                 :            :     {
     203                 :          0 :         bDontCare = false;                          // DontCare ueberall aus
     204                 :          0 :         sal_Bool bOn = ( eState == STATE_CHECK );       // ausgewaehlter Wert
     205                 :            : 
     206                 :          0 :         if ( pBox == &aBtnProtect )
     207                 :          0 :             bProtect = bOn;
     208                 :          0 :         else if ( pBox == &aBtnHideCell )
     209                 :          0 :             bHideCell = bOn;
     210                 :          0 :         else if ( pBox == &aBtnHideFormula )
     211                 :          0 :             bHideForm = bOn;
     212                 :          0 :         else if ( pBox == &aBtnHidePrint )
     213                 :          0 :             bHidePrint = bOn;
     214                 :            :         else
     215                 :            :         {
     216                 :            :             OSL_FAIL("falscher Button");
     217                 :            :         }
     218                 :            :     }
     219                 :            : 
     220                 :          0 :     UpdateButtons();        // TriState und Enable-Logik
     221                 :            : 
     222                 :          0 :     return 0;
     223                 :            : }
     224                 :            : 
     225                 :            : //------------------------------------------------------------------------
     226                 :            : 
     227                 :          0 : void ScTabPageProtection::UpdateButtons()
     228                 :            : {
     229                 :          0 :     if ( bDontCare )
     230                 :            :     {
     231                 :          0 :         aBtnProtect.SetState( STATE_DONTKNOW );
     232                 :          0 :         aBtnHideCell.SetState( STATE_DONTKNOW );
     233                 :          0 :         aBtnHideFormula.SetState( STATE_DONTKNOW );
     234                 :          0 :         aBtnHidePrint.SetState( STATE_DONTKNOW );
     235                 :            :     }
     236                 :            :     else
     237                 :            :     {
     238                 :          0 :         aBtnProtect.SetState( bProtect ? STATE_CHECK : STATE_NOCHECK );
     239                 :          0 :         aBtnHideCell.SetState( bHideCell ? STATE_CHECK : STATE_NOCHECK );
     240                 :          0 :         aBtnHideFormula.SetState( bHideForm ? STATE_CHECK : STATE_NOCHECK );
     241                 :          0 :         aBtnHidePrint.SetState( bHidePrint ? STATE_CHECK : STATE_NOCHECK );
     242                 :            :     }
     243                 :            : 
     244                 :          0 :     sal_Bool bEnable = ( aBtnHideCell.GetState() != STATE_CHECK );
     245                 :            :     {
     246                 :          0 :         aBtnProtect.Enable( bEnable );
     247                 :          0 :         aBtnHideFormula.Enable( bEnable );
     248                 :            :     }
     249                 :          0 : }
     250                 :            : 
     251                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10