ooo-build r13555 - in trunk: . patches/dev300



Author: kyoshida
Date: Thu Aug 14 02:09:25 2008
New Revision: 13555
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13555&view=rev

Log:
2008-08-13  Kohei Yoshida  <kyoshida novell com>

	* patches/dev300/cws-scsheetprotection02-sc.diff: launch password 
	retype dialog for xls -> ods file save to regenerate password hashes
	when necessary.


Modified:
   trunk/ChangeLog
   trunk/patches/dev300/cws-scsheetprotection02-sc.diff

Modified: trunk/patches/dev300/cws-scsheetprotection02-sc.diff
==============================================================================
--- trunk/patches/dev300/cws-scsheetprotection02-sc.diff	(original)
+++ trunk/patches/dev300/cws-scsheetprotection02-sc.diff	Thu Aug 14 02:09:25 2008
@@ -1,5 +1,5 @@
 diff --git sc/inc/document.hxx sc/inc/document.hxx
-index 749c97d..953337c 100644
+index 24fdc1d..dbd59c0 100644
 --- sc/inc/document.hxx
 +++ sc/inc/document.hxx
 @@ -89,6 +89,7 @@ class ScDBData;
@@ -66,21 +66,23 @@
  	void				FindMaxRotCol( SCTAB nTab, RowInfo* pRowInfo, SCSIZE nArrCount,
  										SCCOL nX1, SCCOL nX2 ) const;
 diff --git sc/inc/sc.hrc sc/inc/sc.hrc
-index 7753e5b..e7e8945 100644
+index 7753e5b..25bd2f2 100644
 --- sc/inc/sc.hrc
 +++ sc/inc/sc.hrc
-@@ -1652,6 +1652,11 @@
- // Autoformat for DataPilot
- #define SID_PIVOT_AFMT              (SC_OOO_BUILD_START + 4)
- 
-+// Sheet and document protection with password
-+#define RID_SCDLG_TABPROTECTION         (SC_OOO_BUILD_START + 5)
-+#define RID_SCDLG_DOCPROTECTION         (SC_OOO_BUILD_START + 6)
-+#define RID_SCDLG_RETYPEPASS            (SC_OOO_BUILD_START + 7)
-+#define RID_SCDLG_RETYPEPASS_INPUT      (SC_OOO_BUILD_START + 8)
- 
+@@ -1625,7 +1625,12 @@
+ #define RID_SCDLG_CONFLICTS             (SC_DIALOGS_START + 145)
+ #define RID_SCDLG_SHAREDOCUMENT         (SC_DIALOGS_START + 146)
+ 
+-#define SC_DIALOGS_END          (SC_DIALOGS_START + 150)
++#define RID_SCDLG_TABPROTECTION         (SC_DIALOGS_START + 147)
++#define RID_SCDLG_DOCPROTECTION         (SC_DIALOGS_START + 148)
++#define RID_SCDLG_RETYPEPASS            (SC_DIALOGS_START + 149)
++#define RID_SCDLG_RETYPEPASS_INPUT      (SC_DIALOGS_START + 150)
++
++#define SC_DIALOGS_END          (SC_DIALOGS_START + 151)
  
- #endif
+ #ifndef STD_MASKCOLOR
+ #define STD_MASKCOLOR Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; }
 diff --git sc/inc/scextopt.hxx sc/inc/scextopt.hxx
 index 772b77c..dac5afa 100644
 --- sc/inc/scextopt.hxx
@@ -143,42 +145,37 @@
  	void			SetPageSize( const Size& rSize );
 diff --git sc/inc/tabprotection.hxx sc/inc/tabprotection.hxx
 new file mode 100644
-index 0000000..135a792
+index 0000000..a0fe748
 --- /dev/null
 +++ sc/inc/tabprotection.hxx
-@@ -0,0 +1,166 @@
+@@ -0,0 +1,178 @@
 +/*************************************************************************
 + *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile: tabprotection.hxx,v $
-+ *
-+ *  $Revision: 1.1.4.4 $
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 + *
-+ *  last change: $Author: kohei $ $Date: 2008/05/20 05:17:39 $
++ * Copyright 2008 by Sun Microsystems, Inc.
 + *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
++ * OpenOffice.org - a multi-platform office productivity suite
 + *
++ * $RCSfile: tabprotection.hxx,v $
++ * $Revision: 1.1.4.5 $
 + *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ * This file is part of OpenOffice.org.
 + *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
++ * OpenOffice.org is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU Lesser General Public License version 3
++ * only, as published by the Free Software Foundation.
 + *
-+ *    This library is distributed in the hope that it will be useful,
-+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-+ *    Lesser General Public License for more details.
++ * OpenOffice.org is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU Lesser General Public License version 3 for more details
++ * (a copy is included in the LICENSE file that accompanied this code).
 + *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
++ * You should have received a copy of the GNU Lesser General Public License
++ * version 3 along with OpenOffice.org.  If not, see
++ * <http://www.openoffice.org/license.html>
++ * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
 +
@@ -192,6 +189,7 @@
 +#include <vector>
 +#include <memory>
 +
++class ScDocument;
 +class ScTableProtectionImpl;
 +
 +enum ScPasswordHash
@@ -200,6 +198,22 @@
 +    PASSHASH_XL
 +};
 +
++class ScPassHashHelper
++{
++public:
++    /** Check for the compatibility of all password hashes.  If there is at
++        least one hash that needs to be regenerated, it returns true.  If all
++        hash values are compatible with the specified hash type, then it
++        returns false. */
++    static bool needsPassHashRegen(const ScDocument& rDoc, ScPasswordHash eHash);
++
++private:
++    ScPassHashHelper();
++    ~ScPassHashHelper();
++};
++
++// ============================================================================
++
 +class SAL_NO_VTABLE ScPassHashProtectable
 +{
 +public:
@@ -335,7 +349,7 @@
  #endif
  
 diff --git sc/source/core/data/documen2.cxx sc/source/core/data/documen2.cxx
-index 948fdad..3552fd5 100644
+index b7fcea0..da5791d 100644
 --- sc/source/core/data/documen2.cxx
 +++ sc/source/core/data/documen2.cxx
 @@ -150,6 +150,7 @@ ScDocument::ScDocument( ScDocumentMode	eMode,
@@ -677,48 +691,49 @@
  	if ( bPageSizeValid )
 diff --git sc/source/core/data/tabprotection.cxx sc/source/core/data/tabprotection.cxx
 new file mode 100644
-index 0000000..d96b6c8
+index 0000000..d4f983b
 --- /dev/null
 +++ sc/source/core/data/tabprotection.cxx
-@@ -0,0 +1,436 @@
+@@ -0,0 +1,463 @@
 +/*************************************************************************
 + *
-+ *  OpenOffice.org - a multi-platform office productivity suite
-+ *
-+ *  $RCSfile: tabprotection.cxx,v $
-+ *
-+ *  $Revision: 1.1.4.6 $
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 + *
-+ *  last change: $Author: kohei $ $Date: 2008/05/22 22:31:10 $
++ * Copyright 2008 by Sun Microsystems, Inc.
 + *
-+ *  The Contents of this file are made available subject to
-+ *  the terms of GNU Lesser General Public License Version 2.1.
++ * OpenOffice.org - a multi-platform office productivity suite
 + *
++ * $RCSfile: tabprotection.cxx,v $
++ * $Revision: 1.1.4.7 $
 + *
-+ *    GNU Lesser General Public License Version 2.1
-+ *    =============================================
-+ *    Copyright 2005 by Sun Microsystems, Inc.
-+ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ * This file is part of OpenOffice.org.
 + *
-+ *    This library is free software; you can redistribute it and/or
-+ *    modify it under the terms of the GNU Lesser General Public
-+ *    License version 2.1, as published by the Free Software Foundation.
++ * OpenOffice.org is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU Lesser General Public License version 3
++ * only, as published by the Free Software Foundation.
 + *
-+ *    This library is distributed in the hope that it will be useful,
-+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-+ *    Lesser General Public License for more details.
++ * OpenOffice.org is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU Lesser General Public License version 3 for more details
++ * (a copy is included in the LICENSE file that accompanied this code).
 + *
-+ *    You should have received a copy of the GNU Lesser General Public
-+ *    License along with this library; if not, write to the Free Software
-+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-+ *    MA  02111-1307  USA
++ * You should have received a copy of the GNU Lesser General Public License
++ * version 3 along with OpenOffice.org.  If not, see
++ * <http://www.openoffice.org/license.html>
++ * for a copy of the LGPLv3 License.
 + *
 + ************************************************************************/
 +
++// MARKER(update_precomp.py): autogen include statement, do not remove
++#include "precompiled_sc.hxx"
++
++// INCLUDE ---------------------------------------------------------------
++
 +#include "tabprotection.hxx"
 +#include "tools/debug.hxx"
 +#include "svtools/PasswordHelper.hxx"
++#include "document.hxx"
 +
 +#define DEBUG_TAB_PROTECTION 0
 +
@@ -728,6 +743,32 @@
 +
 +// ============================================================================
 +
++bool ScPassHashHelper::needsPassHashRegen(const ScDocument& rDoc, ScPasswordHash eHash)
++{
++    if (rDoc.IsDocProtected())
++    {
++        const ScDocProtection* p = rDoc.GetDocProtection();
++        if (!p->isPasswordEmpty() && !p->hasPasswordHash(eHash))
++            return true;
++    }
++
++    SCTAB nTabCount = rDoc.GetTableCount();
++    for (SCTAB i = 0; i < nTabCount; ++i)
++    {
++        const ScTableProtection* p = rDoc.GetTabProtection(i);
++        if (!p || !p->isProtected())
++            // Sheet not protected.  Skip it.
++            continue;
++
++        if (!p->isPasswordEmpty() && !p->hasPasswordHash(eHash))
++            return true;
++    }
++
++    return false;
++}
++
++// ============================================================================
++
 +ScPassHashProtectable::~ScPassHashProtectable()
 +{
 +}
@@ -3518,7 +3559,7 @@
 +}
 +
 diff --git sc/source/filter/xml/xmlbodyi.cxx sc/source/filter/xml/xmlbodyi.cxx
-index 9f4a55e..bc9687f 100644
+index 87245d5..5f3545a 100644
 --- sc/source/filter/xml/xmlbodyi.cxx
 +++ sc/source/filter/xml/xmlbodyi.cxx
 @@ -52,6 +52,7 @@
@@ -3558,7 +3599,7 @@
  	}
  	GetScImport().UnlockSolarMutex();
 diff --git sc/source/filter/xml/xmlexprt.cxx sc/source/filter/xml/xmlexprt.cxx
-index 951e00a..009796e 100644
+index 951e00a..52f5145 100644
 --- sc/source/filter/xml/xmlexprt.cxx
 +++ sc/source/filter/xml/xmlexprt.cxx
 @@ -67,6 +67,7 @@
@@ -3605,11 +3646,11 @@
  								rtl::OUStringBuffer aBuffer;
  								if (pDoc)
 -									SvXMLUnitConverter::encodeBase64(aBuffer, pDoc->GetTabPassword(static_cast<SCTAB>(nTable)));
-+                        {
-+                            ScTableProtection* pProtect = pDoc->GetTabProtection(static_cast<SCTAB>(nTable));
-+                            if (pProtect)
-+                                SvXMLUnitConverter::encodeBase64(aBuffer, pProtect->getPasswordHash(PASSHASH_OOO));
-+                        }
++                                {
++                                    ScTableProtection* pProtect = pDoc->GetTabProtection(static_cast<SCTAB>(nTable));
++                                    if (pProtect)
++                                        SvXMLUnitConverter::encodeBase64(aBuffer, pProtect->getPasswordHash(PASSHASH_OOO));
++                                }
  								if (aBuffer.getLength())
  									AddAttribute(XML_NAMESPACE_TABLE, XML_PROTECTION_KEY, aBuffer.makeStringAndClear());
  							}
@@ -3664,7 +3705,7 @@
  
  	rImport.UnlockSolarMutex();
 diff --git sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
-index 8b9b366..3127e4d 100644
+index 8b9b366..a5801d9 100644
 --- sc/source/ui/docshell/docfunc.cxx
 +++ sc/source/ui/docshell/docfunc.cxx
 @@ -92,7 +92,12 @@
@@ -3688,93 +3729,62 @@
 -						const String& rPassword,
 -						uno::Sequence<sal_Int8>* pReturnOld = NULL )
 +void ScDocFunc::ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect )
- {
--	uno::Sequence<sal_Int8> aOldPassword;
--	if ( nTab == TABLEID_DOC )
++{
 +    ScDocument* pDoc = rDocShell.GetDocument();
 +
 +    pDoc->SetTabProtection(nTab, &rProtect);
 +    if (pDoc->IsUndoEnabled())
- 	{
--		if (pDoc->IsDocProtected())
--			aOldPassword = pDoc->GetDocPassword();
--	}
--	else
++    {
 +        ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
 +        DBG_ASSERT(pProtect, "ScDocFunc::Unprotect: ScTableProtection pointer is NULL!");
 +        if (pProtect)
- 	{
--		if (pDoc->IsTabProtected(nTab))
--			aOldPassword = pDoc->GetTabPassword(nTab);
--	}
++        {
 +            ::std::auto_ptr<ScTableProtection> p(new ScTableProtection(*pProtect));
 +            p->setProtected(true); // just in case ...
 +            rDocShell.GetUndoManager()->AddUndoAction(
 +                new ScUndoTabProtect(&rDocShell, nTab, p) );
- 
--	if (pReturnOld)
--		*pReturnOld = aOldPassword;
++
 +            // ownership of auto_ptr now transferred to ScUndoTabProtect.
 +        }
 +    }
- 
--	return ((aOldPassword.getLength() == 0) || SvPasswordHelper::CompareHashPassword(aOldPassword, rPassword));
++
 +    rDocShell.PostPaintGridAll();
 +    ScDocShellModificator aModificator(rDocShell);
 +    aModificator.SetDocumentModified();
- }
- 
--BOOL ScDocFunc::Protect( SCTAB nTab, const String& rPassword, BOOL bApi )
++}
++
 +BOOL ScDocFunc::Protect( SCTAB nTab, const String& rPassword, BOOL /*bApi*/ )
  {
--	ScDocShellModificator aModificator( rDocShell );
--
- 	ScDocument* pDoc = rDocShell.GetDocument();
--	BOOL bUndo(pDoc->IsUndoEnabled());
--	BOOL bOk = lcl_ValidPassword( pDoc, nTab, rPassword);
--	if ( bOk )
+-	uno::Sequence<sal_Int8> aOldPassword;
+-	if ( nTab == TABLEID_DOC )
++    ScDocument* pDoc = rDocShell.GetDocument();
 +    if (nTab == TABLEID_DOC)
- 	{
--	    uno::Sequence<sal_Int8> aPass;
--	    if (rPassword.Len())
--	        SvPasswordHelper::GetHashPassword(aPass, rPassword);
++    {
 +        // document protection
- 
--		if (bUndo)
++
 +        pDoc->SetDocProtection(true, rPassword);
 +        if (pDoc->IsUndoEnabled())
-+	{
+ 	{
+-		if (pDoc->IsDocProtected())
+-			aOldPassword = pDoc->GetDocPassword();
 +            ScDocProtection* pProtect = pDoc->GetDocProtection();
 +            DBG_ASSERT(pProtect, "ScDocFunc::Unprotect: ScDocProtection pointer is NULL!");
 +            if (pProtect)
- 		{
++            {
 +                ::std::auto_ptr<ScDocProtection> p(new ScDocProtection(*pProtect));
 +                p->setProtected(true); // just in case ...
- 			rDocShell.GetUndoManager()->AddUndoAction(
--						new ScUndoProtect( &rDocShell, nTab, TRUE, aPass ) );
++                rDocShell.GetUndoManager()->AddUndoAction(
 +                    new ScUndoDocProtect(&rDocShell, p) );
 +                // ownership of auto_ptr is transferred to ScUndoDocProtect.
- 		}
--
--		if ( nTab == TABLEID_DOC )
--			pDoc->SetDocProtection( TRUE, aPass );
--		else
--			pDoc->SetTabProtection( nTab, TRUE, aPass );
--
--		rDocShell.PostPaintGridAll();
--		aModificator.SetDocumentModified();
++            }
++        }
  	}
--	else if (!bApi)
-+	}
-+	else
+ 	else
  	{
--		//	different password was set before
--
--//!		rDocShell.ErrorMessage(...);
+-		if (pDoc->IsTabProtected(nTab))
+-			aOldPassword = pDoc->GetTabPassword(nTab);
 +        // sheet protection
- 
--		InfoBox aBox( rDocShell.GetActiveDialogParent(), String( ScResId( SCSTR_WRONGPASSWORD ) ) );
--		aBox.Execute();
++
 +        pDoc->SetTabProtection(nTab, true, rPassword);
 +        if (pDoc->IsUndoEnabled())
 +        {
@@ -3791,58 +3801,70 @@
 +        }
  	}
  
--	return bOk;
+-	if (pReturnOld)
+-		*pReturnOld = aOldPassword;
 +    rDocShell.PostPaintGridAll();
 +    ScDocShellModificator aModificator( rDocShell );
 +    aModificator.SetDocumentModified();
-+
+ 
+-	return ((aOldPassword.getLength() == 0) || SvPasswordHelper::CompareHashPassword(aOldPassword, rPassword));
 +    return true;
  }
  
- BOOL ScDocFunc::Unprotect( SCTAB nTab, const String& rPassword, BOOL bApi )
+-BOOL ScDocFunc::Protect( SCTAB nTab, const String& rPassword, BOOL bApi )
++BOOL ScDocFunc::Unprotect( SCTAB nTab, const String& rPassword, BOOL bApi )
  {
 -	ScDocShellModificator aModificator( rDocShell );
 -
  	ScDocument* pDoc = rDocShell.GetDocument();
 -	BOOL bUndo(pDoc->IsUndoEnabled());
--	uno::Sequence<sal_Int8> aOldPassword;
--	uno::Sequence<sal_Int8> aPass;
--	BOOL bOk = lcl_ValidPassword( pDoc, nTab, rPassword, &aOldPassword );
+-	BOOL bOk = lcl_ValidPassword( pDoc, nTab, rPassword);
 -	if ( bOk )
 -	{
--		uno::Sequence<sal_Int8> aEmptyPass;
--		if ( nTab == TABLEID_DOC )
--			pDoc->SetDocProtection( FALSE, aEmptyPass );
--		else
--			pDoc->SetTabProtection( nTab, FALSE, aEmptyPass );
+-	    uno::Sequence<sal_Int8> aPass;
+-	    if (rPassword.Len())
+-	        SvPasswordHelper::GetHashPassword(aPass, rPassword);
  
 -		if (bUndo)
 +    if (nTab == TABLEID_DOC)
-+	{
+ 		{
+-			rDocShell.GetUndoManager()->AddUndoAction(
+-						new ScUndoProtect( &rDocShell, nTab, TRUE, aPass ) );
+-		}
 +        // document protection
-+
+ 
+-		if ( nTab == TABLEID_DOC )
+-			pDoc->SetDocProtection( TRUE, aPass );
+-		else
+-			pDoc->SetTabProtection( nTab, TRUE, aPass );
 +        ScDocProtection* pDocProtect = pDoc->GetDocProtection();
 +        if (!pDocProtect || !pDocProtect->isProtected())
 +            // already unprotected (should not happen)!
 +            return true;
-+
+ 
+-		rDocShell.PostPaintGridAll();
+-		aModificator.SetDocumentModified();
+-	}
+-	else if (!bApi)
+-	{
+-		//	different password was set before
+-
+-//!		rDocShell.ErrorMessage(...);
 +        // save the protection state before unprotect (for undo).
 +        ::std::auto_ptr<ScDocProtection> pProtectCopy(new ScDocProtection(*pDocProtect));
-+
+ 
 +        if (!pDocProtect->verifyPassword(rPassword))
- 		{
--			rDocShell.GetUndoManager()->AddUndoAction(
--						new ScUndoProtect( &rDocShell, nTab, FALSE, aOldPassword ) );
++        {
 +            if (!bApi)
 +            {
-+		InfoBox aBox( rDocShell.GetActiveDialogParent(), String( ScResId( SCSTR_WRONGPASSWORD ) ) );
-+		aBox.Execute();
-+	}
+ 		InfoBox aBox( rDocShell.GetActiveDialogParent(), String( ScResId( SCSTR_WRONGPASSWORD ) ) );
+ 		aBox.Execute();
+ 	}
 +            return false;
- 		}
++        }
  
--		rDocShell.PostPaintGridAll();
--		aModificator.SetDocumentModified();
+-	return bOk;
+-}
 +        pDoc->SetDocProtection(NULL);
 +        if (pDoc->IsUndoEnabled())
 +        {
@@ -3850,45 +3872,68 @@
 +            rDocShell.GetUndoManager()->AddUndoAction(
 +                new ScUndoDocProtect(&rDocShell, pProtectCopy) );
 +            // ownership of auto_ptr now transferred to ScUndoTabProtect.
- 	}
--	else if (!bApi)
++        }
 +    }
 +    else
- 	{
--//!		rDocShell.ErrorMessage(...);
++    {
 +        // sheet protection
-+
+ 
+-BOOL ScDocFunc::Unprotect( SCTAB nTab, const String& rPassword, BOOL bApi )
+-{
+-	ScDocShellModificator aModificator( rDocShell );
 +        ScTableProtection* pTabProtect = pDoc->GetTabProtection(nTab);
 +        if (!pTabProtect || !pTabProtect->isProtected())
 +            // already unprotected (should not happen)!
 +            return true;
-+
+ 
+-	ScDocument* pDoc = rDocShell.GetDocument();
+-	BOOL bUndo(pDoc->IsUndoEnabled());
+-	uno::Sequence<sal_Int8> aOldPassword;
+-	uno::Sequence<sal_Int8> aPass;
+-	BOOL bOk = lcl_ValidPassword( pDoc, nTab, rPassword, &aOldPassword );
+-	if ( bOk )
+-	{
+-		uno::Sequence<sal_Int8> aEmptyPass;
+-		if ( nTab == TABLEID_DOC )
+-			pDoc->SetDocProtection( FALSE, aEmptyPass );
+-		else
+-			pDoc->SetTabProtection( nTab, FALSE, aEmptyPass );
 +        // save the protection state before unprotect (for undo).
 +        ::std::auto_ptr<ScTableProtection> pProtectCopy(new ScTableProtection(*pTabProtect));
  
+-		if (bUndo)
 +        if (!pTabProtect->verifyPassword(rPassword))
 +	{
 +            if (!bApi)
 +            {
- 		InfoBox aBox( rDocShell.GetActiveDialogParent(), String( ScResId( SCSTR_WRONGPASSWORD ) ) );
- 		aBox.Execute();
- 	}
++                InfoBox aBox( rDocShell.GetActiveDialogParent(), String( ScResId( SCSTR_WRONGPASSWORD ) ) );
++                aBox.Execute();
++            }
 +            return false;
 +        }
 +
 +        pDoc->SetTabProtection(nTab, NULL);
 +        if (pDoc->IsUndoEnabled())
-+		{
+ 		{
 +            pProtectCopy->setProtected(false);
-+			rDocShell.GetUndoManager()->AddUndoAction(
+ 			rDocShell.GetUndoManager()->AddUndoAction(
+-						new ScUndoProtect( &rDocShell, nTab, FALSE, aOldPassword ) );
 +                new ScUndoTabProtect(&rDocShell, nTab, pProtectCopy) );
 +            // ownership of auto_ptr now transferred to ScUndoTabProtect.
 +        }
-+		}
-+
-+		rDocShell.PostPaintGridAll();
+ 		}
+ 
+ 		rDocShell.PostPaintGridAll();
 +    ScDocShellModificator aModificator( rDocShell );
-+		aModificator.SetDocumentModified();
+ 		aModificator.SetDocumentModified();
+-	}
+-	else if (!bApi)
+-	{
+-//!		rDocShell.ErrorMessage(...);
+-
+-		InfoBox aBox( rDocShell.GetActiveDialogParent(), String( ScResId( SCSTR_WRONGPASSWORD ) ) );
+-		aBox.Execute();
+-	}
  
 -	return bOk;
 +    return true;
@@ -3896,7 +3941,7 @@
  
  //------------------------------------------------------------------------
 diff --git sc/source/ui/docshell/docsh.cxx sc/source/ui/docshell/docsh.cxx
-index 8591efa..fd8e065 100644
+index 8591efa..65f9b8b 100644
 --- sc/source/ui/docshell/docsh.cxx
 +++ sc/source/ui/docshell/docsh.cxx
 @@ -79,11 +79,6 @@
@@ -3927,44 +3972,34 @@
  
  #include "docsh.hxx"
  #include "docshimp.hxx"
-@@ -1970,6 +1965,32 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
- 	rStream.SetNumberFormatInt( nOldNumberFormatInt );
- }
+@@ -1496,6 +1491,14 @@ BOOL __EXPORT ScDocShell::SaveAs( SfxMedium& rMedium )
+ {
+ 	RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::SaveAs" );
  
-+/** Check for the compatibility of all password hashes.  If there is at
-+    least one hash that needs to be regenerated, it returns true.  If all
-+    hash values are Excel-compatible, then it returns false. */
-+bool lcl_NeedHashRegen(const ScDocument& rDoc, ScPasswordHash eHash)
-+{
-+    if (rDoc.IsDocProtected())
++    ScTabViewShell* pViewShell = GetBestViewShell();
++    if (pViewShell && ScPassHashHelper::needsPassHashRegen(aDocument, PASSHASH_OOO))
 +    {
-+        const ScDocProtection* p = rDoc.GetDocProtection();
-+        if (!p->isPasswordEmpty() && !p->hasPasswordHash(eHash))
-+            return true;
-+    }
-+
-+    SCTAB nTabCount = rDoc.GetTableCount();
-+    for (SCTAB i = 0; i < nTabCount; ++i)
-+    {
-+        const ScTableProtection* p = rDoc.GetTabProtection(i);
-+        if (!p || !p->isProtected())
-+            // Sheet not protected.  Skip it.
-+            continue;
-+
-+        if (!p->isPasswordEmpty() && !p->hasPasswordHash(eHash))
-+            return true;
++        if (!pViewShell->ExecuteRetypePassDlg(PASSHASH_OOO))
++            // password re-type cancelled.  Don't save the document.
++            return false;
 +    }
 +
-+    return false;
-+}
+ 	ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
  
+ 	//	DoEnterHandler hier nicht (wegen AutoSave), ist im ExecuteSave
+@@ -1970,7 +1973,6 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
+ 	rStream.SetNumberFormatInt( nOldNumberFormatInt );
+ }
+ 
+-
  BOOL __EXPORT ScDocShell::ConvertTo( SfxMedium &rMed )
  {
-@@ -2023,6 +2044,14 @@ BOOL __EXPORT ScDocShell::ConvertTo( SfxMedium &rMed )
+ 	RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ConvertTo" );
+@@ -2023,6 +2025,14 @@ BOOL __EXPORT ScDocShell::ConvertTo( SfxMedium &rMed )
                  aDocument.SetExtDocOptions( pExtDocOpt = new ScExtDocOptions );
              pViewShell->GetViewData()->WriteExtOptions( *pExtDocOpt );
  
-+            bool bNeedRetypePassDlg = lcl_NeedHashRegen(aDocument, PASSHASH_XL);
++            bool bNeedRetypePassDlg = ScPassHashHelper::needsPassHashRegen(aDocument, PASSHASH_XL);
 +            if (bNeedRetypePassDlg && !pViewShell->ExecuteRetypePassDlg(PASSHASH_XL))
 +            {
 +                SetError( ERRCODE_ABORT );
@@ -3975,7 +4010,7 @@
              /*  #115980 #If the imported document contained an encrypted password -
                  determine if we should save without it. */
              ScExtDocSettings& rDocSett = pExtDocOpt->GetDocSettings();
-@@ -2032,6 +2061,7 @@ BOOL __EXPORT ScDocShell::ConvertTo( SfxMedium &rMed )
+@@ -2032,6 +2042,7 @@ BOOL __EXPORT ScDocShell::ConvertTo( SfxMedium &rMed )
                  // #i42858# warn only on time
                  rDocSett.mbEncrypted = false;
              }
@@ -4426,7 +4461,7 @@
 +
 +#endif
 diff --git sc/source/ui/inc/tabvwsh.hxx sc/source/ui/inc/tabvwsh.hxx
-index c6dd6a5..91059f7 100644
+index da23875..e966fa6 100644
 --- sc/source/ui/inc/tabvwsh.hxx
 +++ sc/source/ui/inc/tabvwsh.hxx
 @@ -38,6 +38,7 @@
@@ -4437,7 +4472,7 @@
  
  class FmFormShell;
  class SbxObject;
-@@ -430,6 +431,8 @@ public:
+@@ -431,6 +432,8 @@ public:
  	void	BroadcastAccessibility( const SfxHint &rHint );
  	BOOL	HasAccessibilityObjects();
  
@@ -4548,7 +4583,7 @@
  	BOOL			Unprotect( SCTAB nTab, const String& rPassword );
  
 diff --git sc/source/ui/miscdlgs/makefile.mk sc/source/ui/miscdlgs/makefile.mk
-index bb81bba..aac2608 100644
+index bb81bba..c24e83d 100644
 --- sc/source/ui/miscdlgs/makefile.mk
 +++ sc/source/ui/miscdlgs/makefile.mk
 @@ -79,7 +79,9 @@ SLOFILES =  \
@@ -4589,9 +4624,9 @@
  	$(SLO)$/sharedocdlg.obj     \
  	$(SLO)$/scuiautofmt.obj			\
 -	$(SLO)$/strindlg.obj            
-+	$(SLO)$/strindlg.obj \
-+    $(SLO)$/protectiondlg.obj \
-+    $(SLO)$/retypepassdlg.obj
++	$(SLO)$/strindlg.obj 			\
++	$(SLO)$/protectiondlg.obj \
++	$(SLO)$/retypepassdlg.obj
  
  # --- Tagets -------------------------------------------------------
  
@@ -6678,7 +6713,7 @@
 +
 +#endif
 diff --git sc/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx
-index cb57c92..89228b5 100644
+index cb57c92..b44c164 100644
 --- sc/source/ui/view/gridwin.cxx
 +++ sc/source/ui/view/gridwin.cxx
 @@ -140,6 +140,7 @@
@@ -6689,7 +6724,7 @@
  
  // #114409#
  #include <vcl/salbtype.hxx>		// FRound
-@@ -2033,11 +2034,12 @@ void __EXPORT ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
+@@ -2033,8 +2034,9 @@ void __EXPORT ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
  		Point aPos = rMEvt.GetPosPixel();
          SCsCOL nPosX;
          SCsROW nPosY;
@@ -6699,12 +6734,8 @@
 +		ScDPObject*	pDPObj	= pDoc->GetDPAtCursor( nPosX, nPosY, nTab );
  		if ( pDPObj && pDPObj->GetSaveData()->GetDrillDown() )
  		{
--			ScAddress aCellPos( nPosX, nPosY, pViewData->GetTabNo() );
-+			ScAddress aCellPos( nPosX, nPosY, nTab );
- 
-             // Check for header drill-down first.
-             sheet::DataPilotTableHeaderData aData;
-@@ -2076,17 +2078,35 @@ void __EXPORT ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
+ 			ScAddress aCellPos( nPosX, nPosY, pViewData->GetTabNo() );
+@@ -2076,19 +2078,37 @@ void __EXPORT ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
  			return;
  		}
  
@@ -6749,8 +6780,11 @@
 +            }
 +        }
          return;
- 	}
+-	}
++    }
  
+ 			//
+ 			//		Links in edit cells
 diff --git sc/source/ui/view/scextopt.cxx sc/source/ui/view/scextopt.cxx
 index 8ac6382..586f934 100644
 --- sc/source/ui/view/scextopt.cxx
@@ -6767,7 +6801,7 @@
  }
  
 diff --git sc/source/ui/view/select.cxx sc/source/ui/view/select.cxx
-index 9d4cdfd..d5e2257 100644
+index f6d5704..fdc4fc5 100644
 --- sc/source/ui/view/select.cxx
 +++ sc/source/ui/view/select.cxx
 @@ -47,6 +47,7 @@
@@ -6803,9 +6837,9 @@
 +    }
 +
  	ScModule* pScMod = SC_MOD();
- 	BOOL bRefMode = pScMod->IsFormulaMode();
- 
-@@ -374,7 +395,6 @@ BOOL ScViewFunctionSet::SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, BOOL bScrol
+     ScTabViewShell* pViewShell = pViewData->GetViewShell();
+     bool bRefMode = ( pViewShell ? pViewShell->IsRefInputMode() : false );
+@@ -375,7 +396,6 @@ BOOL ScViewFunctionSet::SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, BOOL bScrol
  
  		ScRange aDelRange;
  		BOOL bOldDelMark = pViewData->GetDelMark( aDelRange );
@@ -6813,7 +6847,7 @@
  
  		if ( nPosX+1 >= (SCsCOL) nStartX && nPosX <= (SCsCOL) nEndX &&
  			 nPosY+1 >= (SCsROW) nStartY && nPosY <= (SCsROW) nEndY &&
-@@ -510,7 +530,6 @@ BOOL ScViewFunctionSet::SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, BOOL bScrol
+@@ -511,7 +531,6 @@ BOOL ScViewFunctionSet::SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, BOOL bScrol
  		BYTE nMode = pViewData->GetFillMode();
  		if ( nMode == SC_FILL_EMBED_LT || nMode == SC_FILL_EMBED_RB )
  		{
@@ -6822,18 +6856,18 @@
              ScRange aRange;
  			pDoc->GetEmbedded( aRange);
 diff --git sc/source/ui/view/tabview3.cxx sc/source/ui/view/tabview3.cxx
-index dff3854..187adb5 100644
+index f36d6ee..3830de6 100644
 --- sc/source/ui/view/tabview3.cxx
 +++ sc/source/ui/view/tabview3.cxx
-@@ -68,6 +68,7 @@
- #include "inputopt.hxx"
- #include "rfindlst.hxx"
- #include "hiranges.hxx"
+@@ -79,6 +79,7 @@
+ #include "AccessibilityHints.hxx"
+ #include "rangeutl.hxx"
+ #include "client.hxx"
 +#include "tabprotection.hxx"
- #include "viewuno.hxx"
- #include "chartarr.hxx"
- #include "anyrefdg.hxx"
-@@ -1020,6 +1021,17 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+ 
+ #include <com/sun/star/chart2/data/HighlightedRange.hpp>
+ 
+@@ -1023,6 +1024,17 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
  	ScDocument* pDoc = aViewData.GetDocument();
  	SCTAB nTab = aViewData.GetTabNo();
  
@@ -6851,7 +6885,7 @@
  	SCsCOL nOldX;
  	SCsROW nOldY;
  	SCsCOL nCurX;
-@@ -1039,7 +1051,7 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+@@ -1042,7 +1054,7 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
  		nCurY = (nMovY != 0) ? nOldY+nMovY : (SCsROW) aViewData.GetOldCurY();
  	}
  
@@ -6860,7 +6894,7 @@
  	aViewData.ResetOldCursor();
  
  	if (nMovX != 0 && VALIDCOLROW(nCurX,nCurY))
-@@ -1048,15 +1060,20 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+@@ -1051,15 +1063,20 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
  		do
  		{
  			BYTE nColFlags = pDoc->GetColFlags( nCurX, nTab );
@@ -6884,7 +6918,7 @@
  					}
  					else
  					{
-@@ -1069,7 +1086,8 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+@@ -1072,7 +1089,8 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
  					if (nMovX > 0) ++nCurX; else --nCurX;
  			}
  		}
@@ -6894,7 +6928,7 @@
  		if (pDoc->IsVerOverlapped( nCurX, nCurY, nTab ))
  		{
  			aViewData.SetOldCursor( nCurX,nCurY );
-@@ -1084,15 +1102,20 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+@@ -1087,15 +1105,20 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
  		do
  		{
  			BYTE nRowFlags = pDoc->GetRowFlags( nCurY, nTab );
@@ -6918,7 +6952,7 @@
  					}
  					else
  					{
-@@ -1105,7 +1128,8 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+@@ -1108,7 +1131,8 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
  					if (nMovY > 0) ++nCurY; else --nCurY;
  			}
  		}
@@ -7193,10 +7227,10 @@
  				nDestTab1++;
  			}
 diff --git sc/source/ui/view/viewfunc.cxx sc/source/ui/view/viewfunc.cxx
-index d0362e5..666b939 100644
+index f49b6cd..46a9b7c 100644
 --- sc/source/ui/view/viewfunc.cxx
 +++ sc/source/ui/view/viewfunc.cxx
-@@ -2396,6 +2396,36 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, BOOL bOptimal )
+@@ -2400,6 +2400,36 @@ void ScViewFunc::ModifyCellSize( ScDirection eDir, BOOL bOptimal )
  	ShowAllCursors();
  }
  



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]