LCOV - code coverage report
Current view: top level - sc/inc - tabprotection.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1 100.0 %
Date: 2012-08-25 Functions: 1 1 100.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                 :            : #ifndef SC_TAB_PROTECTION_HXX
      30                 :            : #define SC_TAB_PROTECTION_HXX
      31                 :            : 
      32                 :            : #include "sal/types.h"
      33                 :            : #include <com/sun/star/uno/Sequence.hxx>
      34                 :            : 
      35                 :            : #include "global.hxx"
      36                 :            : #include <boost/shared_ptr.hpp>
      37                 :            : 
      38                 :            : class ScDocument;
      39                 :            : class ScTableProtectionImpl;
      40                 :            : 
      41                 :            : enum ScPasswordHash
      42                 :            : {
      43                 :            :     PASSHASH_SHA1 = 0,
      44                 :            :     PASSHASH_XL,
      45                 :            :     PASSHASH_UNSPECIFIED
      46                 :            : };
      47                 :            : 
      48                 :            : class ScPassHashHelper
      49                 :            : {
      50                 :            : public:
      51                 :            :     /** Check for the compatibility of all password hashes.  If there is at
      52                 :            :         least one hash that needs to be regenerated, it returns true.  If all
      53                 :            :         hash values are compatible with the specified hash type, then it
      54                 :            :         returns false. */
      55                 :            :     static bool needsPassHashRegen(const ScDocument& rDoc, ScPasswordHash eHash1, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED);
      56                 :            : 
      57                 :            :     static ::rtl::OUString getHashURI(ScPasswordHash eHash);
      58                 :            : 
      59                 :            :     static ScPasswordHash getHashTypeFromURI(const ::rtl::OUString& rURI);
      60                 :            : 
      61                 :            : private:
      62                 :            :     ScPassHashHelper();
      63                 :            :     ~ScPassHashHelper();
      64                 :            : };
      65                 :            : 
      66                 :            : // ============================================================================
      67                 :            : 
      68                 :         77 : class SAL_NO_VTABLE ScPassHashProtectable
      69                 :            : {
      70                 :            : public:
      71                 :            :     virtual ~ScPassHashProtectable() = 0;
      72                 :            : 
      73                 :            :     virtual bool isProtected() const = 0;
      74                 :            :     virtual bool isProtectedWithPass() const = 0;
      75                 :            :     virtual void setProtected(bool bProtected) = 0;
      76                 :            : 
      77                 :            :     virtual bool isPasswordEmpty() const = 0;
      78                 :            :     virtual bool hasPasswordHash(ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) const = 0;
      79                 :            :     virtual void setPassword(const String& aPassText) = 0;
      80                 :            :     virtual ::com::sun::star::uno::Sequence<sal_Int8> getPasswordHash(
      81                 :            :         ScPasswordHash eHash, ScPasswordHash eHas2 = PASSHASH_UNSPECIFIED) const = 0;
      82                 :            :     virtual void setPasswordHash(
      83                 :            :         const ::com::sun::star::uno::Sequence<sal_Int8>& aPassword,
      84                 :            :         ScPasswordHash eHash = PASSHASH_SHA1, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) = 0;
      85                 :            :     virtual bool verifyPassword(const String& aPassText) const = 0;
      86                 :            : };
      87                 :            : 
      88                 :            : // ============================================================================
      89                 :            : 
      90                 :            : class SC_DLLPUBLIC ScDocProtection : public ScPassHashProtectable
      91                 :            : {
      92                 :            : public:
      93                 :            :     enum Option
      94                 :            :     {
      95                 :            :         STRUCTURE = 0,
      96                 :            :         WINDOWS,
      97                 :            :         CONTENT,
      98                 :            :         NONE        // last item - used to resize the vector
      99                 :            :     };
     100                 :            : 
     101                 :            :     explicit ScDocProtection();
     102                 :            :     explicit ScDocProtection(const ScDocProtection& r);
     103                 :            :     virtual ~ScDocProtection();
     104                 :            : 
     105                 :            :     virtual bool isProtected() const;
     106                 :            :     virtual bool isProtectedWithPass() const;
     107                 :            :     virtual void setProtected(bool bProtected);
     108                 :            : 
     109                 :            :     virtual bool isPasswordEmpty() const;
     110                 :            :     virtual bool hasPasswordHash(ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) const;
     111                 :            :     virtual void setPassword(const String& aPassText);
     112                 :            :     virtual ::com::sun::star::uno::Sequence<sal_Int8> getPasswordHash(
     113                 :            :         ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) const;
     114                 :            :     virtual void setPasswordHash(
     115                 :            :         const ::com::sun::star::uno::Sequence<sal_Int8>& aPassword,
     116                 :            :         ScPasswordHash eHash = PASSHASH_SHA1, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED);
     117                 :            :     virtual bool verifyPassword(const String& aPassText) const;
     118                 :            : 
     119                 :            :     bool isOptionEnabled(Option eOption) const;
     120                 :            :     void setOption(Option eOption, bool bEnabled);
     121                 :            : 
     122                 :            : private:
     123                 :            :     ::boost::shared_ptr<ScTableProtectionImpl> mpImpl;
     124                 :            : };
     125                 :            : 
     126                 :            : // ============================================================================
     127                 :            : 
     128                 :            : /** sheet protection state container
     129                 :            : 
     130                 :            :     This class stores sheet's protection state: 1) whether the protection
     131                 :            :     is on, 2) password and/or password hash, and 3) any associated
     132                 :            :     protection options.  This class is also used as a protection state
     133                 :            :     container for the undo/redo stack, in which case the password, hash and
     134                 :            :     the options need to be preserved even when the protection flag is
     135                 :            :     off. */
     136                 :            : class SC_DLLPUBLIC ScTableProtection : public ScPassHashProtectable
     137                 :            : {
     138                 :            : public:
     139                 :            :     enum Option
     140                 :            :     {
     141                 :            :         AUTOFILTER = 0,
     142                 :            :         DELETE_COLUMNS,
     143                 :            :         DELETE_ROWS,
     144                 :            :         FORMAT_CELLS,
     145                 :            :         FORMAT_COLUMNS,
     146                 :            :         FORMAT_ROWS,
     147                 :            :         INSERT_COLUMNS,
     148                 :            :         INSERT_HYPERLINKS,
     149                 :            :         INSERT_ROWS,
     150                 :            :         OBJECTS,
     151                 :            :         PIVOT_TABLES,
     152                 :            :         SCENARIOS,
     153                 :            :         SELECT_LOCKED_CELLS,
     154                 :            :         SELECT_UNLOCKED_CELLS,
     155                 :            :         SHEET,
     156                 :            :         SORT,
     157                 :            :         NONE        // last item - used to resize the vector
     158                 :            :     };
     159                 :            : 
     160                 :            :     explicit ScTableProtection();
     161                 :            :     explicit ScTableProtection(const ScTableProtection& r);
     162                 :            :     virtual ~ScTableProtection();
     163                 :            : 
     164                 :            :     virtual bool isProtected() const;
     165                 :            :     virtual bool isProtectedWithPass() const;
     166                 :            :     virtual void setProtected(bool bProtected);
     167                 :            : 
     168                 :            :     virtual bool isPasswordEmpty() const;
     169                 :            :     virtual bool hasPasswordHash(ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) const;
     170                 :            :     virtual void setPassword(const String& aPassText);
     171                 :            :     virtual ::com::sun::star::uno::Sequence<sal_Int8> getPasswordHash(
     172                 :            :         ScPasswordHash eHash, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED) const;
     173                 :            :     virtual void setPasswordHash(
     174                 :            :         const ::com::sun::star::uno::Sequence<sal_Int8>& aPassword,
     175                 :            :         ScPasswordHash eHash = PASSHASH_SHA1, ScPasswordHash eHash2 = PASSHASH_UNSPECIFIED);
     176                 :            :     virtual bool verifyPassword(const String& aPassText) const;
     177                 :            : 
     178                 :            :     bool isOptionEnabled(Option eOption) const;
     179                 :            :     void setOption(Option eOption, bool bEnabled);
     180                 :            : 
     181                 :            : private:
     182                 :            :     ::boost::shared_ptr<ScTableProtectionImpl> mpImpl;
     183                 :            : };
     184                 :            : 
     185                 :            : 
     186                 :            : #endif
     187                 :            : 
     188                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10