Kaydet (Commit) 28c7911d authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Remove the preprocessor guard for sheet protection options.

This feature is now universally enabled, removing the unnecessary
guard.
üst d127768d
......@@ -35,8 +35,6 @@
#include "global.hxx"
#include <boost/shared_ptr.hpp>
#define ENABLE_SHEET_PROTECTION 1
class ScDocument;
class ScTableProtectionImpl;
......
......@@ -132,9 +132,7 @@ static void lcl_AddWorkbookProtection( XclExpRecordList<>& aRecList, ExcTable& s
{
aRecList.AppendNewRecord( new XclExpWindowProtection(pProtect->isOptionEnabled(ScDocProtection::WINDOWS)) );
aRecList.AppendNewRecord( new XclExpProtection(pProtect->isOptionEnabled(ScDocProtection::STRUCTURE)) );
#if ENABLE_SHEET_PROTECTION
aRecList.AppendNewRecord( new XclExpPassHash(pProtect->getPasswordHash(PASSHASH_XL)) );
#endif
}
aRecList.AppendNewRecord( new XclExpXmlEndSingleElementRecord() ); // XML_workbookProtection
......@@ -474,9 +472,7 @@ void ExcTable::FillAsTable( SCTAB nCodeNameIdx )
Add( new XclExpProtection(true) );
Add( new XclExpBoolRecord(0x00DD, pTabProtect->isOptionEnabled(ScTableProtection::SCENARIOS)) );
Add( new XclExpBoolRecord(0x0063, pTabProtect->isOptionEnabled(ScTableProtection::OBJECTS)) );
#if ENABLE_SHEET_PROTECTION
Add( new XclExpPassHash(pTabProtect->getPasswordHash(PASSHASH_XL)) );
#endif
}
// local link table: EXTERNCOUNT, EXTERNSHEET
......
......@@ -1167,7 +1167,6 @@ void XclImpDocProtectBuffer::Apply() const
auto_ptr<ScDocProtection> pProtect(new ScDocProtection);
pProtect->setProtected(true);
#if ENABLE_SHEET_PROTECTION
if (mnPassHash)
{
// 16-bit password pash.
......@@ -1176,7 +1175,6 @@ void XclImpDocProtectBuffer::Apply() const
aPass[1] = mnPassHash & 0xFF;
pProtect->setPasswordHash(aPass, PASSHASH_XL);
}
#endif
// document protection options
pProtect->setOption(ScDocProtection::STRUCTURE, mbDocProtect);
......@@ -1272,7 +1270,6 @@ void XclImpSheetProtectBuffer::Apply() const
auto_ptr<ScTableProtection> pProtect(new ScTableProtection);
pProtect->setProtected(true);
#if ENABLE_SHEET_PROTECTION
// 16-bit hash password
const sal_uInt16 nHash = itr->second.mnPasswordHash;
if (nHash)
......@@ -1282,7 +1279,6 @@ void XclImpSheetProtectBuffer::Apply() const
aPass[1] = nHash & 0xFF;
pProtect->setPasswordHash(aPass, PASSHASH_XL);
}
#endif
// sheet protection options
const sal_uInt16 nOptions = itr->second.mnOptions;
......
......@@ -1577,7 +1577,6 @@ BOOL __EXPORT ScDocShell::SaveAs( SfxMedium& rMedium )
{
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::SaveAs" );
#if ENABLE_SHEET_PROTECTION
ScTabViewShell* pViewShell = GetBestViewShell();
bool bNeedsRehash = ScPassHashHelper::needsPassHashRegen(aDocument, PASSHASH_SHA1);
if (bNeedsRehash)
......@@ -1590,7 +1589,6 @@ BOOL __EXPORT ScDocShell::SaveAs( SfxMedium& rMedium )
// password re-type cancelled. Don't save the document.
return false;
}
#endif
ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
......@@ -2125,13 +2123,11 @@ BOOL __EXPORT ScDocShell::ConvertTo( SfxMedium &rMed )
}
}
#if ENABLE_SHEET_PROTECTION
if( bDoSave )
{
bool bNeedRetypePassDlg = ScPassHashHelper::needsPassHashRegen( aDocument, PASSHASH_XL );
bDoSave = !bNeedRetypePassDlg || pViewShell->ExecuteRetypePassDlg( PASSHASH_XL );
}
#endif
}
if( bDoSave )
......
......@@ -1065,8 +1065,6 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
SCTAB nTab = GetViewData()->GetTabNo();
bool bOldProtection = pDoc->IsTabProtected(nTab);
#if ENABLE_SHEET_PROTECTION
if( pReqArgs )
{
const SfxPoolItem* pItem;
......@@ -1134,85 +1132,6 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
}
}
}
#else
auto_ptr<SfxPasswordDialog> pDlg;
String aPassword;
BOOL bCancel = FALSE;
bool bNewProtection = ! bOldProtection;
if( pReqArgs )
{
const SfxPoolItem* pItem;
if( IS_AVAILABLE( FID_PROTECT_TABLE, &pItem ) )
bNewProtection = ((const SfxBoolItem*)pItem)->GetValue();
if( bNewProtection == bOldProtection )
{
rReq.Ignore();
break;
}
}
if ( bOldProtection)
{
// Unprotect a protected sheet.
ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
if (pProtect && pProtect->isProtectedWithPass())
{
String aText( ScResId(SCSTR_PASSWORDOPT) );
pDlg.reset(new SfxPasswordDialog(GetDialogParent(), &aText));
pDlg->SetText( ScResId(SCSTR_UNPROTECTTAB) );
pDlg->SetMinLen( 0 );
pDlg->SetHelpId( FID_PROTECT_TABLE );
pDlg->SetEditHelpId( HID_PASSWD_TABLE );
if (pDlg->Execute() == RET_OK)
aPassword = pDlg->GetPassword();
else
bCancel = TRUE;
}
if (!pReqArgs)
{
rReq.AppendItem( SfxBoolItem(FID_PROTECT_TABLE, false) );
rReq.Done();
}
}
else
{
String aText( ScResId(SCSTR_PASSWORDOPT) );
pDlg.reset(new SfxPasswordDialog(GetDialogParent(), &aText));
pDlg->SetText( ScResId(SCSTR_PROTECTTAB) );
pDlg->SetMinLen( 0 );
pDlg->SetHelpId( FID_PROTECT_TABLE );
pDlg->SetEditHelpId( HID_PASSWD_TABLE );
pDlg->ShowExtras( SHOWEXTRAS_CONFIRM );
if (pDlg->Execute() == RET_OK)
aPassword = pDlg->GetPassword();
else
bCancel = TRUE;
}
if( !bCancel )
{
if ( bOldProtection )
Unprotect( nTab, aPassword );
else
{
pScMod->InputEnterHandler();
Protect( nTab, aPassword );
}
if( !pReqArgs )
{
rReq.AppendItem( SfxBoolItem( FID_PROTECT_TABLE, bNewProtection ) );
rReq.Done();
}
}
#endif
TabChanged();
UpdateInputHandler(true); // damit sofort wieder eingegeben werden kann
SelectionChanged();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment