xref: /AOO41X/main/sc/source/core/data/tabprotection.cxx (revision b3f79822e811ac3493b185030a72c3c5a51f32d8)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "tabprotection.hxx"
30cdf0e10cSrcweir #include "tools/debug.hxx"
31cdf0e10cSrcweir #include "svl/PasswordHelper.hxx"
32cdf0e10cSrcweir #include <comphelper/docpasswordhelper.hxx>
33cdf0e10cSrcweir #include "document.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #define DEBUG_TAB_PROTECTION 0
36cdf0e10cSrcweir 
37cdf0e10cSrcweir using namespace ::com::sun::star;
38cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
39cdf0e10cSrcweir using ::rtl::OUString;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // ============================================================================
42cdf0e10cSrcweir 
needsPassHashRegen(const ScDocument & rDoc,ScPasswordHash eHash)43cdf0e10cSrcweir bool ScPassHashHelper::needsPassHashRegen(const ScDocument& rDoc, ScPasswordHash eHash)
44cdf0e10cSrcweir {
45cdf0e10cSrcweir     if (rDoc.IsDocProtected())
46cdf0e10cSrcweir     {
47cdf0e10cSrcweir         const ScDocProtection* p = rDoc.GetDocProtection();
48cdf0e10cSrcweir         if (!p->isPasswordEmpty() && !p->hasPasswordHash(eHash))
49cdf0e10cSrcweir             return true;
50cdf0e10cSrcweir     }
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     SCTAB nTabCount = rDoc.GetTableCount();
53cdf0e10cSrcweir     for (SCTAB i = 0; i < nTabCount; ++i)
54cdf0e10cSrcweir     {
55cdf0e10cSrcweir         const ScTableProtection* p = rDoc.GetTabProtection(i);
56cdf0e10cSrcweir         if (!p || !p->isProtected())
57cdf0e10cSrcweir             // Sheet not protected.  Skip it.
58cdf0e10cSrcweir             continue;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir         if (!p->isPasswordEmpty() && !p->hasPasswordHash(eHash))
61cdf0e10cSrcweir             return true;
62cdf0e10cSrcweir     }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     return false;
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir // ============================================================================
68cdf0e10cSrcweir 
~ScPassHashProtectable()69cdf0e10cSrcweir ScPassHashProtectable::~ScPassHashProtectable()
70cdf0e10cSrcweir {
71cdf0e10cSrcweir }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir // ============================================================================
74cdf0e10cSrcweir 
75cdf0e10cSrcweir class ScTableProtectionImpl
76cdf0e10cSrcweir {
77cdf0e10cSrcweir public:
78cdf0e10cSrcweir     static ::com::sun::star::uno::Sequence<sal_Int8> hashPassword(const String& aPassText, ScPasswordHash eHash = PASSHASH_OOO);
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     explicit ScTableProtectionImpl(SCSIZE nOptSize);
81cdf0e10cSrcweir     explicit ScTableProtectionImpl(const ScTableProtectionImpl& r);
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     bool isProtected() const;
84cdf0e10cSrcweir     bool isProtectedWithPass() const;
85cdf0e10cSrcweir     void setProtected(bool bProtected);
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     bool isPasswordEmpty() const;
88cdf0e10cSrcweir     bool hasPasswordHash(ScPasswordHash eHash) const;
89cdf0e10cSrcweir     void setPassword(const String& aPassText);
90cdf0e10cSrcweir     ::com::sun::star::uno::Sequence<sal_Int8> getPasswordHash(ScPasswordHash eHash) const;
91cdf0e10cSrcweir     void setPasswordHash(const ::com::sun::star::uno::Sequence<sal_Int8>& aPassword, ScPasswordHash eHash = PASSHASH_OOO);
92cdf0e10cSrcweir     bool verifyPassword(const String& aPassText) const;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     bool isOptionEnabled(SCSIZE nOptId) const;
95cdf0e10cSrcweir     void setOption(SCSIZE nOptId, bool bEnabled);
96cdf0e10cSrcweir 
97cdf0e10cSrcweir private:
98cdf0e10cSrcweir     String maPassText;
99cdf0e10cSrcweir     ::com::sun::star::uno::Sequence<sal_Int8>   maPassHash;
100cdf0e10cSrcweir     ::std::vector<bool> maOptions;
101cdf0e10cSrcweir     bool mbEmptyPass;
102cdf0e10cSrcweir     bool mbProtected;
103cdf0e10cSrcweir     ScPasswordHash meHash;
104cdf0e10cSrcweir };
105cdf0e10cSrcweir 
hashPassword(const String & aPassText,ScPasswordHash eHash)106cdf0e10cSrcweir Sequence<sal_Int8> ScTableProtectionImpl::hashPassword(const String& aPassText, ScPasswordHash eHash)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir     Sequence<sal_Int8> aHash;
109cdf0e10cSrcweir     switch (eHash)
110cdf0e10cSrcweir     {
111cdf0e10cSrcweir         case PASSHASH_XL:
112cdf0e10cSrcweir             aHash = ::comphelper::DocPasswordHelper::GetXLHashAsSequence( aPassText, RTL_TEXTENCODING_UTF8 );
113cdf0e10cSrcweir         break;
114cdf0e10cSrcweir         case PASSHASH_OOO:
115cdf0e10cSrcweir         default:
116cdf0e10cSrcweir             SvPasswordHelper::GetHashPassword(aHash, aPassText);
117cdf0e10cSrcweir         break;
118cdf0e10cSrcweir     }
119cdf0e10cSrcweir     return aHash;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
ScTableProtectionImpl(SCSIZE nOptSize)122cdf0e10cSrcweir ScTableProtectionImpl::ScTableProtectionImpl(SCSIZE nOptSize) :
123cdf0e10cSrcweir     maOptions(nOptSize),
124cdf0e10cSrcweir     mbEmptyPass(true),
125cdf0e10cSrcweir     mbProtected(false),
126cdf0e10cSrcweir     meHash(PASSHASH_OOO)
127cdf0e10cSrcweir {
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
ScTableProtectionImpl(const ScTableProtectionImpl & r)130cdf0e10cSrcweir ScTableProtectionImpl::ScTableProtectionImpl(const ScTableProtectionImpl& r) :
131cdf0e10cSrcweir     maPassText(r.maPassText),
132cdf0e10cSrcweir     maPassHash(r.maPassHash),
133cdf0e10cSrcweir     maOptions(r.maOptions),
134cdf0e10cSrcweir     mbEmptyPass(r.mbEmptyPass),
135cdf0e10cSrcweir     mbProtected(r.mbProtected),
136cdf0e10cSrcweir     meHash(r.meHash)
137cdf0e10cSrcweir {
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
isProtected() const140cdf0e10cSrcweir bool ScTableProtectionImpl::isProtected() const
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     return mbProtected;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
isProtectedWithPass() const145cdf0e10cSrcweir bool ScTableProtectionImpl::isProtectedWithPass() const
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     if (!mbProtected)
148cdf0e10cSrcweir         return false;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     return maPassText.Len() || maPassHash.getLength();
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
setProtected(bool bProtected)153cdf0e10cSrcweir void ScTableProtectionImpl::setProtected(bool bProtected)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     mbProtected = bProtected;
156cdf0e10cSrcweir     // We need to keep the old password even when the protection is off.  So,
157cdf0e10cSrcweir     // don't erase the password data here.
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
setPassword(const String & aPassText)160cdf0e10cSrcweir void ScTableProtectionImpl::setPassword(const String& aPassText)
161cdf0e10cSrcweir {
162cdf0e10cSrcweir     // We can't hash it here because we don't know whether this document will
163cdf0e10cSrcweir     // get saved to Excel or ODF, depending on which we will need to use a
164cdf0e10cSrcweir     // different hashing algorithm.  One alternative is to hash it using all
165cdf0e10cSrcweir     // hash algorithms that we support, and store them all.
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     maPassText = aPassText;
168cdf0e10cSrcweir     mbEmptyPass = aPassText.Len() == 0;
169cdf0e10cSrcweir     if (mbEmptyPass)
170cdf0e10cSrcweir     {
171cdf0e10cSrcweir         maPassHash = Sequence<sal_Int8>();
172cdf0e10cSrcweir     }
173cdf0e10cSrcweir }
174cdf0e10cSrcweir 
isPasswordEmpty() const175cdf0e10cSrcweir bool ScTableProtectionImpl::isPasswordEmpty() const
176cdf0e10cSrcweir {
177cdf0e10cSrcweir     return mbEmptyPass;
178cdf0e10cSrcweir }
179cdf0e10cSrcweir 
hasPasswordHash(ScPasswordHash eHash) const180cdf0e10cSrcweir bool ScTableProtectionImpl::hasPasswordHash(ScPasswordHash eHash) const
181cdf0e10cSrcweir {
182cdf0e10cSrcweir     if (mbEmptyPass)
183cdf0e10cSrcweir         return true;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     if (maPassText.Len())
186cdf0e10cSrcweir         return true;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     if (meHash == eHash)
189cdf0e10cSrcweir         return true;
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     return false;
192cdf0e10cSrcweir }
193cdf0e10cSrcweir 
getPasswordHash(ScPasswordHash eHash) const194cdf0e10cSrcweir Sequence<sal_Int8> ScTableProtectionImpl::getPasswordHash(ScPasswordHash eHash) const
195cdf0e10cSrcweir {
196cdf0e10cSrcweir     if (mbEmptyPass)
197cdf0e10cSrcweir         // Flaged as empty.
198cdf0e10cSrcweir         return Sequence<sal_Int8>();
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     if (maPassText.Len())
201cdf0e10cSrcweir         // Cleartext password exists.  Hash it.
202cdf0e10cSrcweir         return hashPassword(maPassText, eHash);
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     if (meHash == eHash)
205cdf0e10cSrcweir         // Stored hash exists.
206cdf0e10cSrcweir         return maPassHash;
207cdf0e10cSrcweir 
208cdf0e10cSrcweir     // Failed to find a matching hash.
209cdf0e10cSrcweir     return Sequence<sal_Int8>();
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
setPasswordHash(const uno::Sequence<sal_Int8> & aPassword,ScPasswordHash eHash)212cdf0e10cSrcweir void ScTableProtectionImpl::setPasswordHash(const uno::Sequence<sal_Int8>& aPassword, ScPasswordHash eHash)
213cdf0e10cSrcweir {
214cdf0e10cSrcweir     sal_Int32 nLen = aPassword.getLength();
215cdf0e10cSrcweir     mbEmptyPass = nLen <= 0 ? true : false;
216cdf0e10cSrcweir     meHash = eHash;
217cdf0e10cSrcweir     maPassHash = aPassword;
218cdf0e10cSrcweir 
219cdf0e10cSrcweir #if DEBUG_TAB_PROTECTION
220cdf0e10cSrcweir     for (sal_Int32 i = 0; i < nLen; ++i)
221cdf0e10cSrcweir         printf("%2.2X ", static_cast<sal_uInt8>(aPassword[i]));
222cdf0e10cSrcweir     printf("\n");
223cdf0e10cSrcweir #endif
224cdf0e10cSrcweir }
225cdf0e10cSrcweir 
verifyPassword(const String & aPassText) const226cdf0e10cSrcweir bool ScTableProtectionImpl::verifyPassword(const String& aPassText) const
227cdf0e10cSrcweir {
228cdf0e10cSrcweir #if DEBUG_TAB_PROTECTION
229cdf0e10cSrcweir     fprintf(stdout, "ScTableProtectionImpl::verifyPassword: input = '%s'\n",
230cdf0e10cSrcweir             OUStringToOString(rtl::OUString(aPassText), RTL_TEXTENCODING_UTF8).getStr());
231cdf0e10cSrcweir #endif
232cdf0e10cSrcweir 
233cdf0e10cSrcweir     if (mbEmptyPass)
234cdf0e10cSrcweir         return aPassText.Len() == 0;
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     if (maPassText.Len())
237cdf0e10cSrcweir         // Clear text password exists, and this one takes precedence.
238cdf0e10cSrcweir         return aPassText.Equals(maPassText);
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     Sequence<sal_Int8> aHash = hashPassword(aPassText, meHash);
241cdf0e10cSrcweir 
242cdf0e10cSrcweir #if DEBUG_TAB_PROTECTION
243cdf0e10cSrcweir     fprintf(stdout, "ScTableProtectionImpl::verifyPassword: hash = ");
244cdf0e10cSrcweir     for (sal_Int32 i = 0; i < aHash.getLength(); ++i)
245cdf0e10cSrcweir         printf("%2.2X ", static_cast<sal_uInt8>(aHash[i]));
246cdf0e10cSrcweir     printf("\n");
247cdf0e10cSrcweir #endif
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     return aHash == maPassHash;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir 
isOptionEnabled(SCSIZE nOptId) const252cdf0e10cSrcweir bool ScTableProtectionImpl::isOptionEnabled(SCSIZE nOptId) const
253cdf0e10cSrcweir {
254cdf0e10cSrcweir     if ( maOptions.size() <= static_cast<size_t>(nOptId) )
255cdf0e10cSrcweir     {
256cdf0e10cSrcweir         DBG_ERROR("ScTableProtectionImpl::isOptionEnabled: wrong size");
257cdf0e10cSrcweir         return false;
258cdf0e10cSrcweir     }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir     return maOptions[nOptId];
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
setOption(SCSIZE nOptId,bool bEnabled)263cdf0e10cSrcweir void ScTableProtectionImpl::setOption(SCSIZE nOptId, bool bEnabled)
264cdf0e10cSrcweir {
265cdf0e10cSrcweir     if ( maOptions.size() <= static_cast<size_t>(nOptId) )
266cdf0e10cSrcweir     {
267cdf0e10cSrcweir         DBG_ERROR("ScTableProtectionImpl::setOption: wrong size");
268cdf0e10cSrcweir         return;
269cdf0e10cSrcweir     }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     maOptions[nOptId] = bEnabled;
272cdf0e10cSrcweir }
273cdf0e10cSrcweir 
274cdf0e10cSrcweir // ============================================================================
275cdf0e10cSrcweir 
ScDocProtection()276cdf0e10cSrcweir ScDocProtection::ScDocProtection() :
277cdf0e10cSrcweir     mpImpl(new ScTableProtectionImpl(static_cast<SCSIZE>(ScDocProtection::NONE)))
278cdf0e10cSrcweir {
279cdf0e10cSrcweir }
280cdf0e10cSrcweir 
ScDocProtection(const ScDocProtection & r)281cdf0e10cSrcweir ScDocProtection::ScDocProtection(const ScDocProtection& r) :
282cdf0e10cSrcweir     ScPassHashProtectable(),
283cdf0e10cSrcweir     mpImpl(new ScTableProtectionImpl(*r.mpImpl))
284cdf0e10cSrcweir {
285cdf0e10cSrcweir }
286cdf0e10cSrcweir 
~ScDocProtection()287cdf0e10cSrcweir ScDocProtection::~ScDocProtection()
288cdf0e10cSrcweir {
289cdf0e10cSrcweir }
290cdf0e10cSrcweir 
isProtected() const291cdf0e10cSrcweir bool ScDocProtection::isProtected() const
292cdf0e10cSrcweir {
293cdf0e10cSrcweir     return mpImpl->isProtected();
294cdf0e10cSrcweir }
295cdf0e10cSrcweir 
isProtectedWithPass() const296cdf0e10cSrcweir bool ScDocProtection::isProtectedWithPass() const
297cdf0e10cSrcweir {
298cdf0e10cSrcweir     return mpImpl->isProtectedWithPass();
299cdf0e10cSrcweir }
300cdf0e10cSrcweir 
setProtected(bool bProtected)301cdf0e10cSrcweir void ScDocProtection::setProtected(bool bProtected)
302cdf0e10cSrcweir {
303cdf0e10cSrcweir     mpImpl->setProtected(bProtected);
304cdf0e10cSrcweir 
305cdf0e10cSrcweir     // Currently Calc doesn't support document protection options.  So, let's
306cdf0e10cSrcweir     // assume that when the document is protected, its structure is protected.
307cdf0e10cSrcweir     // We need to do this for Excel export.
308cdf0e10cSrcweir     mpImpl->setOption(ScDocProtection::STRUCTURE, bProtected);
309cdf0e10cSrcweir }
310cdf0e10cSrcweir 
isPasswordEmpty() const311cdf0e10cSrcweir bool ScDocProtection::isPasswordEmpty() const
312cdf0e10cSrcweir {
313cdf0e10cSrcweir     return mpImpl->isPasswordEmpty();
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
hasPasswordHash(ScPasswordHash eHash) const316cdf0e10cSrcweir bool ScDocProtection::hasPasswordHash(ScPasswordHash eHash) const
317cdf0e10cSrcweir {
318cdf0e10cSrcweir     return mpImpl->hasPasswordHash(eHash);
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
setPassword(const String & aPassText)321cdf0e10cSrcweir void ScDocProtection::setPassword(const String& aPassText)
322cdf0e10cSrcweir {
323cdf0e10cSrcweir     mpImpl->setPassword(aPassText);
324cdf0e10cSrcweir }
325cdf0e10cSrcweir 
getPasswordHash(ScPasswordHash eHash) const326cdf0e10cSrcweir uno::Sequence<sal_Int8> ScDocProtection::getPasswordHash(ScPasswordHash eHash) const
327cdf0e10cSrcweir {
328cdf0e10cSrcweir     return mpImpl->getPasswordHash(eHash);
329cdf0e10cSrcweir }
330cdf0e10cSrcweir 
setPasswordHash(const uno::Sequence<sal_Int8> & aPassword,ScPasswordHash eHash)331cdf0e10cSrcweir void ScDocProtection::setPasswordHash(const uno::Sequence<sal_Int8>& aPassword, ScPasswordHash eHash)
332cdf0e10cSrcweir {
333cdf0e10cSrcweir     mpImpl->setPasswordHash(aPassword, eHash);
334cdf0e10cSrcweir }
335cdf0e10cSrcweir 
verifyPassword(const String & aPassText) const336cdf0e10cSrcweir bool ScDocProtection::verifyPassword(const String& aPassText) const
337cdf0e10cSrcweir {
338cdf0e10cSrcweir     return mpImpl->verifyPassword(aPassText);
339cdf0e10cSrcweir }
340cdf0e10cSrcweir 
isOptionEnabled(Option eOption) const341cdf0e10cSrcweir bool ScDocProtection::isOptionEnabled(Option eOption) const
342cdf0e10cSrcweir {
343cdf0e10cSrcweir     return mpImpl->isOptionEnabled(eOption);
344cdf0e10cSrcweir }
345cdf0e10cSrcweir 
setOption(Option eOption,bool bEnabled)346cdf0e10cSrcweir void ScDocProtection::setOption(Option eOption, bool bEnabled)
347cdf0e10cSrcweir {
348cdf0e10cSrcweir     mpImpl->setOption(eOption, bEnabled);
349cdf0e10cSrcweir }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir // ============================================================================
352cdf0e10cSrcweir 
ScTableProtection()353cdf0e10cSrcweir ScTableProtection::ScTableProtection() :
354cdf0e10cSrcweir     mpImpl(new ScTableProtectionImpl(static_cast<SCSIZE>(ScTableProtection::NONE)))
355cdf0e10cSrcweir {
356cdf0e10cSrcweir     // Set default values for the options.
357cdf0e10cSrcweir     mpImpl->setOption(SELECT_LOCKED_CELLS,   true);
358cdf0e10cSrcweir     mpImpl->setOption(SELECT_UNLOCKED_CELLS, true);
359cdf0e10cSrcweir }
360cdf0e10cSrcweir 
ScTableProtection(const ScTableProtection & r)361cdf0e10cSrcweir ScTableProtection::ScTableProtection(const ScTableProtection& r) :
362cdf0e10cSrcweir     ScPassHashProtectable(),
363cdf0e10cSrcweir     mpImpl(new ScTableProtectionImpl(*r.mpImpl))
364cdf0e10cSrcweir {
365cdf0e10cSrcweir }
366cdf0e10cSrcweir 
~ScTableProtection()367cdf0e10cSrcweir ScTableProtection::~ScTableProtection()
368cdf0e10cSrcweir {
369cdf0e10cSrcweir }
370cdf0e10cSrcweir 
isProtected() const371cdf0e10cSrcweir bool ScTableProtection::isProtected() const
372cdf0e10cSrcweir {
373cdf0e10cSrcweir     return mpImpl->isProtected();
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
isProtectedWithPass() const376cdf0e10cSrcweir bool ScTableProtection::isProtectedWithPass() const
377cdf0e10cSrcweir {
378cdf0e10cSrcweir     return mpImpl->isProtectedWithPass();
379cdf0e10cSrcweir }
380cdf0e10cSrcweir 
setProtected(bool bProtected)381cdf0e10cSrcweir void ScTableProtection::setProtected(bool bProtected)
382cdf0e10cSrcweir {
383cdf0e10cSrcweir     mpImpl->setProtected(bProtected);
384cdf0e10cSrcweir }
385cdf0e10cSrcweir 
isPasswordEmpty() const386cdf0e10cSrcweir bool ScTableProtection::isPasswordEmpty() const
387cdf0e10cSrcweir {
388cdf0e10cSrcweir     return mpImpl->isPasswordEmpty();
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
hasPasswordHash(ScPasswordHash eHash) const391cdf0e10cSrcweir bool ScTableProtection::hasPasswordHash(ScPasswordHash eHash) const
392cdf0e10cSrcweir {
393cdf0e10cSrcweir     return mpImpl->hasPasswordHash(eHash);
394cdf0e10cSrcweir }
395cdf0e10cSrcweir 
setPassword(const String & aPassText)396cdf0e10cSrcweir void ScTableProtection::setPassword(const String& aPassText)
397cdf0e10cSrcweir {
398cdf0e10cSrcweir     mpImpl->setPassword(aPassText);
399cdf0e10cSrcweir }
400cdf0e10cSrcweir 
getPasswordHash(ScPasswordHash eHash) const401cdf0e10cSrcweir Sequence<sal_Int8> ScTableProtection::getPasswordHash(ScPasswordHash eHash) const
402cdf0e10cSrcweir {
403cdf0e10cSrcweir     return mpImpl->getPasswordHash(eHash);
404cdf0e10cSrcweir }
405cdf0e10cSrcweir 
setPasswordHash(const uno::Sequence<sal_Int8> & aPassword,ScPasswordHash eHash)406cdf0e10cSrcweir void ScTableProtection::setPasswordHash(const uno::Sequence<sal_Int8>& aPassword, ScPasswordHash eHash)
407cdf0e10cSrcweir {
408cdf0e10cSrcweir     mpImpl->setPasswordHash(aPassword, eHash);
409cdf0e10cSrcweir }
410cdf0e10cSrcweir 
verifyPassword(const String & aPassText) const411cdf0e10cSrcweir bool ScTableProtection::verifyPassword(const String& aPassText) const
412cdf0e10cSrcweir {
413cdf0e10cSrcweir     return mpImpl->verifyPassword(aPassText);
414cdf0e10cSrcweir }
415cdf0e10cSrcweir 
isOptionEnabled(Option eOption) const416cdf0e10cSrcweir bool ScTableProtection::isOptionEnabled(Option eOption) const
417cdf0e10cSrcweir {
418cdf0e10cSrcweir     return mpImpl->isOptionEnabled(eOption);
419cdf0e10cSrcweir }
420cdf0e10cSrcweir 
setOption(Option eOption,bool bEnabled)421cdf0e10cSrcweir void ScTableProtection::setOption(Option eOption, bool bEnabled)
422cdf0e10cSrcweir {
423cdf0e10cSrcweir     mpImpl->setOption(eOption, bEnabled);
424cdf0e10cSrcweir }
425cdf0e10cSrcweir 
426