From 32fde82cb84fd34cd5f51d1f5e9978aebe5654df Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 4 Mar 2010 13:39:59 +0100 Subject: tl78: #i109779# add SID_MODIFYPASSWORDHASH --- sfx2/inc/sfx2/sfxsids.hrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index 525916f8d3..b4cbbf37df 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -575,7 +575,8 @@ #define SID_ACTIVATE_STYLE_APPLY (SID_SFX_START + 1715) #define SID_FONT_NAME (SID_SFX_START + 1716) #define SID_DEFAULTFILENAME (SID_SFX_START + 1717) -#define SID_SFX_free_START (SID_SFX_START + 1718) +#define SID_MODIFYPASSWORDHASH (SID_SFX_START + 1718) +#define SID_SFX_free_START (SID_SFX_START + 1719) #define SID_SFX_free_END (SID_SFX_START + 3999) #define SID_OPEN_NEW_VIEW (SID_SFX_START + 520) -- cgit v1.2.3 From ab747b666331b6e0d80d4ed8ac08f6b5773d6dc6 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 19 Mar 2010 11:13:29 +0100 Subject: cws tl79: #i110254# new 'Security' tab page --- sfx2/inc/sfx2/securitypage.hxx | 57 ++++++ sfx2/inc/sfx2/sfx.hrc | 1 + sfx2/source/dialog/dinfdlg.cxx | 4 +- sfx2/source/dialog/dinfdlg.src | 11 +- sfx2/source/dialog/makefile.mk | 6 +- sfx2/source/dialog/securitypage.cxx | 379 ++++++++++++++++++++++++++++++++++++ sfx2/source/dialog/securitypage.hrc | 52 +++++ sfx2/source/dialog/securitypage.src | 156 +++++++++++++++ sfx2/source/inc/helpid.hrc | 1 + svx/inc/svx/svxids.hrc | 1 + 10 files changed, 661 insertions(+), 7 deletions(-) create mode 100755 sfx2/inc/sfx2/securitypage.hxx mode change 100644 => 100755 sfx2/inc/sfx2/sfx.hrc mode change 100644 => 100755 sfx2/source/dialog/dinfdlg.cxx mode change 100644 => 100755 sfx2/source/dialog/dinfdlg.src mode change 100644 => 100755 sfx2/source/dialog/makefile.mk create mode 100755 sfx2/source/dialog/securitypage.cxx create mode 100755 sfx2/source/dialog/securitypage.hrc create mode 100755 sfx2/source/dialog/securitypage.src mode change 100644 => 100755 sfx2/source/inc/helpid.hrc mode change 100644 => 100755 svx/inc/svx/svxids.hrc (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/securitypage.hxx b/sfx2/inc/sfx2/securitypage.hxx new file mode 100755 index 0000000000..431b566d79 --- /dev/null +++ b/sfx2/inc/sfx2/securitypage.hxx @@ -0,0 +1,57 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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 + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SECURITYPAGE_HXX_ +#define _SECURITYPAGE_HXX_ + +#include "sfx2/tabdlg.hxx " + +#include + + +////////////////////////////////////////////////////////////////////// + +struct SfxSecurityPage_Impl; + +class SfxSecurityPage : public SfxTabPage +{ + std::auto_ptr< SfxSecurityPage_Impl > m_pImpl; + +protected: + SfxSecurityPage( Window* pParent, const SfxItemSet& ); + virtual ~SfxSecurityPage(); + + virtual BOOL FillItemSet( SfxItemSet& ); + virtual void Reset( const SfxItemSet& ); + +public: + static SfxTabPage* Create( Window* pParent, const SfxItemSet& ); +}; + +////////////////////////////////////////////////////////////////////// + +#endif // #ifndef _SECURITYPAGE_HXX_ + diff --git a/sfx2/inc/sfx2/sfx.hrc b/sfx2/inc/sfx2/sfx.hrc old mode 100644 new mode 100755 index 573b6944e1..f9010d7625 --- a/sfx2/inc/sfx2/sfx.hrc +++ b/sfx2/inc/sfx2/sfx.hrc @@ -228,6 +228,7 @@ #define TP_DOCINFOUSER (RID_SFX_START+5) #define TP_DOCINFORELOAD (RID_SFX_START+13) #define TP_CUSTOMPROPERTIES (RID_SFX_START+14) +#define TP_DOCINFOSECURITY (RID_SFX_START+215) #define DLG_DOCINFO_EDT (RID_SFX_START+6) #define TP_MANAGE_STYLES (RID_SFX_START+7) #define DLG_STYLE_DESIGNER (RID_SFX_START+8) diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx old mode 100644 new mode 100755 index e1d0307af7..ac4a3b763a --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -58,7 +58,8 @@ #include #include -#include +#include "sfx2/dinfdlg.hxx" +#include "sfx2/securitypage.hxx" #include "sfxresid.hxx" #include "dinfedt.hxx" #include @@ -1554,6 +1555,7 @@ SfxDocumentInfoDialog::SfxDocumentInfoDialog( Window* pParent, AddTabPage(TP_DOCINFODOC, SfxDocumentPage::Create, 0); AddTabPage(TP_CUSTOMPROPERTIES, SfxCustomPropertiesPage::Create, 0); AddTabPage(TP_DOCINFORELOAD, SfxInternetPage::Create, 0); + AddTabPage(TP_DOCINFOSECURITY, SfxSecurityPage::Create, 0); } // ----------------------------------------------------------------------- diff --git a/sfx2/source/dialog/dinfdlg.src b/sfx2/source/dialog/dinfdlg.src old mode 100644 new mode 100755 index 84a5b55ba3..2311b5a8db --- a/sfx2/source/dialog/dinfdlg.src +++ b/sfx2/source/dialog/dinfdlg.src @@ -27,11 +27,11 @@ // include --------------------------------------------------------------- -#include +#include "sfx2/sfx.hrc" #include "helpid.hrc" #include "sfxlocal.hrc" #include "dinfdlg.hrc" -#include +#include "dialog.hrc" // TP_DOCINFODESC -------------------------------------------------------- String STR_SFX_NEWOFFICEDOC @@ -685,8 +685,6 @@ QueryBox SFX_QB_WRONG_TYPE Message [ en-US ] = "The value entered does not match the specified type.\nThe value will be stored as text." ; }; - // SID_DOCINFO ----------------------------------------------------------- - TabDialog SID_DOCINFO { OutputSize = TRUE ; @@ -718,6 +716,11 @@ TabDialog SID_DOCINFO Identifier = TP_DOCINFORELOAD ; Text [ en-US ] = "Internet" ; }; + PageItem + { + Identifier = TP_DOCINFOSECURITY ; + Text [ en-US ] = "Security" ; + }; }; }; }; diff --git a/sfx2/source/dialog/makefile.mk b/sfx2/source/dialog/makefile.mk old mode 100644 new mode 100755 index 87ef0f1a7a..b344170fd3 --- a/sfx2/source/dialog/makefile.mk +++ b/sfx2/source/dialog/makefile.mk @@ -68,7 +68,8 @@ SLOFILES =\ $(SLO)$/tabdlg.obj \ $(SLO)$/tplcitem.obj \ $(SLO)$/tplpitem.obj \ - $(SLO)$/versdlg.obj + $(SLO)$/versdlg.obj \ + $(SLO)$/securitypage.obj SRS1NAME=$(TARGET) SRC1FILES =\ @@ -85,7 +86,8 @@ SRC1FILES =\ templdlg.src \ versdlg.src \ printopt.src \ - srchdlg.src + srchdlg.src \ + securitypage.src .IF "$(BUILD_VER_STRING)"!="" .IF "$(GUI)"=="UNX" diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx new file mode 100755 index 0000000000..8c2e042b4b --- /dev/null +++ b/sfx2/source/dialog/securitypage.cxx @@ -0,0 +1,379 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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 + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sfx2.hxx" + +#include "sfx2/securitypage.hxx" +#include "sfx2/sfx.hrc" +#include "securitypage.hrc" +#include "sfxresid.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +////////////////////////////////////////////////////////////////////// + +namespace +{ + enum RedliningMode { RL_NONE, RL_WRITER, RL_CALC }; + + enum RedlineFunc { RF_ON, RF_PROTECT }; + + const SfxBoolItem* ExecuteRecordChangesFunc( RedliningMode _eMode, RedlineFunc _eFunc, BOOL _bVal, Window* _pParent = NULL ) + { + const SfxBoolItem* pRet = NULL; + + if (_eMode != RL_NONE) + { + USHORT nSlot; + if (_eMode == RL_WRITER) + nSlot = _eFunc == RF_ON ? FN_REDLINE_ON : FN_REDLINE_PROTECT; + else + nSlot = _eFunc == RF_ON ? FID_CHG_RECORD : SID_CHG_PROTECT; + + // execute + SfxViewShell* pViewSh = SfxViewShell::Current(); + if (pViewSh) + { + bool bNeedItem = _eMode == RL_WRITER || _eFunc != RF_ON; + SfxBoolItem* pItem = bNeedItem ? new SfxBoolItem( nSlot, _bVal ) : NULL; + SfxDispatcher* pDisp = pViewSh->GetDispatcher(); + if (_pParent) + { + XWindowItem aParentItem( SID_ATTR_XWINDOW, _pParent ); + pRet = static_cast< const SfxBoolItem* >( + pDisp->Execute( nSlot, SFX_CALLMODE_SYNCHRON, &aParentItem, pItem, 0L ) ); + } + else + pRet = static_cast< const SfxBoolItem* >( + pDisp->Execute( nSlot, SFX_CALLMODE_SYNCHRON, pItem, 0L ) ); + delete pItem; + } + } + + return pRet; + } + + bool QueryState( USHORT _nSlot, bool& _rValue ) + { + bool bRet = false; + + SfxViewShell* pViewSh = SfxViewShell::Current(); + if (pViewSh) + { + const SfxPoolItem* pItem; + SfxDispatcher* pDisp = pViewSh->GetDispatcher(); + bRet = SFX_ITEM_AVAILABLE <= pDisp->QueryState( _nSlot, pItem ); + if (bRet) + _rValue = ( static_cast< const SfxBoolItem* >( pItem ) )->GetValue(); + } + + return bRet; + } + + bool QueryRecordChangesProtectionState( RedliningMode _eMode, bool& _rValue ) + { + bool bRet = false; + + if (_eMode != RL_NONE) + { + USHORT nSlot = _eMode == RL_WRITER ? FN_REDLINE_PROTECT : SID_CHG_PROTECT; + bRet = QueryState( nSlot, _rValue ); + } + + return bRet; + } + + bool QueryRecordChangesState( RedliningMode _eMode, bool& _rValue ) + { + bool bRet = false; + + if (_eMode != RL_NONE) + { + USHORT nSlot = _eMode == RL_WRITER ? FN_REDLINE_ON : FID_CHG_RECORD; + bRet = QueryState( nSlot, _rValue ); + } + + return bRet; + } +} + + +////////////////////////////////////////////////////////////////////// + + +struct SfxSecurityPage_Impl +{ + SfxSecurityPage & m_rDialog; + + FixedLine m_aPasswordToOpenFL; + FixedText m_aPasswordToOpenFT; + Edit m_aPasswordToOpenED; + FixedText m_aConfirmPasswordToOpenFT; + Edit m_aConfirmPasswordToOpenED; + FixedText m_aPasswordInfoFT; + + FixedLine m_aPasswordToModifyFL; + FixedText m_aPasswordToModifyFT; + Edit m_aPasswordToModifyED; + FixedText m_aConfirmPasswordToModifyFT; + Edit m_aConfirmPasswordToModifyED; + + FixedLine m_aOptionsFL; + CheckBox m_aOpenReadonlyCB; + CheckBox m_aRemoveInfoOnSavingCB; + CheckBox m_aRecordChangesCB; // for record changes + PushButton m_aChangeProtectionPB; // for record changes + String m_aProtectSTR; // for record changes + String m_aUnProtectSTR; // for record changes + RedliningMode m_eRedlingMode; // for record changes + + DECL_LINK( RecordChangesCBHdl, void* ); + DECL_LINK( ChangeProtectionPBHdl, void* ); + + SfxSecurityPage_Impl( SfxSecurityPage &rDlg, const SfxItemSet &rItemSet ); + ~SfxSecurityPage_Impl(); + + void CheckRecordChangesState( void ); + + BOOL FillItemSet_Impl( SfxItemSet & ); + void Reset_Impl( const SfxItemSet & ); +}; + + +SfxSecurityPage_Impl::SfxSecurityPage_Impl( SfxSecurityPage &rDlg, const SfxItemSet & ) : + m_rDialog (rDlg), + m_aPasswordToOpenFL (&rDlg, SfxResId( PASSWORD_TO_OPEN_FL ) ), + m_aPasswordToOpenFT (&rDlg, SfxResId( PASSWORD_TO_OPEN_FT ) ), + m_aPasswordToOpenED (&rDlg, SfxResId( PASSWORD_TO_OPEN_ED ) ), + m_aConfirmPasswordToOpenFT (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_OPEN_FT ) ), + m_aConfirmPasswordToOpenED (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_OPEN_ED ) ), + m_aPasswordInfoFT (&rDlg, SfxResId( PASSWORD_INFO_FT ) ), + m_aPasswordToModifyFL (&rDlg, SfxResId( PASSWORD_TO_MODIFY_FL ) ), + m_aPasswordToModifyFT (&rDlg, SfxResId( PASSWORD_TO_MODIFY_FT ) ), + m_aPasswordToModifyED (&rDlg, SfxResId( PASSWORD_TO_MODIFY_ED ) ), + m_aConfirmPasswordToModifyFT (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_FT ) ), + m_aConfirmPasswordToModifyED (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_ED ) ), + m_aOptionsFL (&rDlg, SfxResId( OPTIONS_FL ) ), + m_aOpenReadonlyCB (&rDlg, SfxResId( OPEN_READONLY_CB ) ), + m_aRemoveInfoOnSavingCB (&rDlg, SfxResId( REMOVE_INFO_ON_SAVING_CB ) ), + m_aRecordChangesCB (&rDlg, SfxResId( RECORD_CHANGES_CB ) ), + m_aChangeProtectionPB (&rDlg, SfxResId( CHANGE_PROTECTION_PB ) ), + m_aProtectSTR ( SfxResId( STR_PROTECT ) ), + m_aUnProtectSTR ( SfxResId( STR_UNPROTECT ) ), + m_eRedlingMode ( RL_NONE ) +{ + m_aChangeProtectionPB.SetText( m_aProtectSTR ); + // adjust button width if necessary + long nBtnTextWidth = 0; + long nTemp = m_aChangeProtectionPB.GetCtrlTextWidth( m_aChangeProtectionPB.GetText() ); + if (nTemp > nBtnTextWidth) + nBtnTextWidth = nTemp; + + m_aRecordChangesCB.SetClickHdl( LINK( this, SfxSecurityPage_Impl, RecordChangesCBHdl ) ); + m_aChangeProtectionPB.SetClickHdl( LINK( this, SfxSecurityPage_Impl, ChangeProtectionPBHdl ) ); +} + + +SfxSecurityPage_Impl::~SfxSecurityPage_Impl() +{ +} + + +void SfxSecurityPage_Impl::CheckRecordChangesState( void ) +{ + bool bVal; + if (QueryRecordChangesState( m_eRedlingMode, bVal )) + { + m_aRecordChangesCB.Enable(); + m_aRecordChangesCB.Check( bVal ); + } + else + m_aRecordChangesCB.Disable(); // because now we don't know the state! + + m_aChangeProtectionPB.Enable( QueryRecordChangesProtectionState( m_eRedlingMode, bVal ) ); +} + + +BOOL SfxSecurityPage_Impl::FillItemSet_Impl( SfxItemSet & ) +{ + BOOL bModified = FALSE; + + SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); + if (pCurDocShell) + { + if (pCurDocShell->HasSecurityOptOpenReadOnly()) + pCurDocShell->SetSecurityOptOpenReadOnly( m_aOpenReadonlyCB.IsChecked() ); + } + + return bModified; +} + + +void SfxSecurityPage_Impl::Reset_Impl( const SfxItemSet & ) +{ + SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); + + String sNewText = m_aProtectSTR; + if (!pCurDocShell) + { + // no doc -> hide document settings + m_aOpenReadonlyCB.Disable(); + m_aRecordChangesCB.Disable(); + m_aChangeProtectionPB.Disable(); + } + else + { + bool bIsHTMLDoc = false; + SfxViewShell* pViewSh = SfxViewShell::Current(); + if (pViewSh) + { + const SfxPoolItem* pItem; + SfxDispatcher* pDisp = pViewSh->GetDispatcher(); + if (SFX_ITEM_AVAILABLE <= pDisp->QueryState( SID_HTML_MODE, pItem )) + { + USHORT nMode = static_cast< const SfxUInt16Item* >( pItem )->GetValue(); + bIsHTMLDoc = ( ( nMode & HTMLMODE_ON ) != 0 ); + } + } + + sal_Bool bIsReadonly = pCurDocShell->IsReadOnly(); + if (pCurDocShell->HasSecurityOptOpenReadOnly() && !bIsHTMLDoc) + { + m_aOpenReadonlyCB.Check( pCurDocShell->IsSecurityOptOpenReadOnly() ); + m_aOpenReadonlyCB.Enable( !bIsReadonly ); + } + else + m_aOpenReadonlyCB.Disable(); + + bool bVal; + if (QueryRecordChangesState( RL_WRITER, bVal ) && !bIsHTMLDoc) + m_eRedlingMode = RL_WRITER; + else if (QueryRecordChangesState( RL_CALC, bVal )) + m_eRedlingMode = RL_CALC; + else + m_eRedlingMode = RL_NONE; + + if (m_eRedlingMode != RL_NONE) + { + m_aRecordChangesCB.Check( bVal ); + m_aRecordChangesCB.Enable( !bVal && !bIsReadonly ); + m_aChangeProtectionPB.Enable( + QueryRecordChangesProtectionState( m_eRedlingMode, bVal ) && !bIsReadonly ); + // set the right text + if (bVal) + sNewText = m_aUnProtectSTR; + } + } + + m_aChangeProtectionPB.SetText( sNewText ); +} + + +IMPL_LINK( SfxSecurityPage_Impl, RecordChangesCBHdl, void*, EMPTYARG ) +{ + ExecuteRecordChangesFunc( m_eRedlingMode, RF_ON, m_aRecordChangesCB.IsChecked(), &m_rDialog ); + CheckRecordChangesState(); + return 0; +} + + +IMPL_LINK( SfxSecurityPage_Impl, ChangeProtectionPBHdl, void*, EMPTYARG ) +{ + bool bProt; + QueryRecordChangesProtectionState( m_eRedlingMode, bProt ); + ExecuteRecordChangesFunc( m_eRedlingMode, RF_PROTECT, !bProt, &m_rDialog ); + CheckRecordChangesState(); + + if (QueryRecordChangesProtectionState( m_eRedlingMode, bProt )) + { + // RecordChangesCB is enabled if protection is off + m_aRecordChangesCB.Enable( !bProt ); + // toggle text of button "Protect" <-> "Unprotect" + String sNewText = bProt ? m_aUnProtectSTR : m_aProtectSTR; + m_aChangeProtectionPB.SetText( sNewText ); + } + return 0; +} + + +////////////////////////////////////////////////////////////////////// + + +SfxTabPage* SfxSecurityPage::Create( Window * pParent, const SfxItemSet & rItemSet ) +{ + return new SfxSecurityPage( pParent, rItemSet ); +} + + +SfxSecurityPage::SfxSecurityPage( Window* pParent, const SfxItemSet& rItemSet ) : + SfxTabPage( pParent, SfxResId( TP_DOCINFOSECURITY ), rItemSet ) +{ + m_pImpl = std::auto_ptr< SfxSecurityPage_Impl >(new SfxSecurityPage_Impl( *this, rItemSet )); + + FreeResource(); +} + + +SfxSecurityPage::~SfxSecurityPage() +{ +} + + +BOOL SfxSecurityPage::FillItemSet( SfxItemSet & rItemSet ) +{ + bool bModified = false; + DBG_ASSERT( m_pImpl.get(), "implementation pointer is 0. Still in c-tor?" ); + if (m_pImpl.get() != 0) + bModified = m_pImpl->FillItemSet_Impl( rItemSet ); + return bModified; +} + + +void SfxSecurityPage::Reset( const SfxItemSet & rItemSet ) +{ + DBG_ASSERT( m_pImpl.get(), "implementation pointer is 0. Still in c-tor?" ); + if (m_pImpl.get() != 0) + m_pImpl->Reset_Impl( rItemSet ); +} + + +////////////////////////////////////////////////////////////////////// + diff --git a/sfx2/source/dialog/securitypage.hrc b/sfx2/source/dialog/securitypage.hrc new file mode 100755 index 0000000000..74586a6d4c --- /dev/null +++ b/sfx2/source/dialog/securitypage.hrc @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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 + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SECURITYPAGE_HRC_ +#define _SECURITYPAGE_HRC_ + + +#define PASSWORD_TO_OPEN_FL 1 +#define PASSWORD_TO_OPEN_FT 2 +#define PASSWORD_TO_OPEN_ED 3 +#define CONFIRM_PASSWORD_TO_OPEN_FT 4 +#define CONFIRM_PASSWORD_TO_OPEN_ED 5 +#define PASSWORD_INFO_FT 6 +#define PASSWORD_TO_MODIFY_FL 7 +#define PASSWORD_TO_MODIFY_FT 8 +#define PASSWORD_TO_MODIFY_ED 9 +#define CONFIRM_PASSWORD_TO_MODIFY_FT 10 +#define CONFIRM_PASSWORD_TO_MODIFY_ED 11 +#define OPTIONS_FL 12 +#define OPEN_READONLY_CB 13 +#define REMOVE_INFO_ON_SAVING_CB 14 +#define RECORD_CHANGES_CB 15 +#define CHANGE_PROTECTION_PB 16 + +#define STR_PROTECT 101 +#define STR_UNPROTECT 102 + +#endif + diff --git a/sfx2/source/dialog/securitypage.src b/sfx2/source/dialog/securitypage.src new file mode 100755 index 0000000000..bf2b0a18d4 --- /dev/null +++ b/sfx2/source/dialog/securitypage.src @@ -0,0 +1,156 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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 + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "sfx2/sfx.hrc" +#include "securitypage.hrc" +#include "helpid.hrc" +#include "dialog.hrc" +#include "sfxlocal.hrc" + +#include + + +TabPage TP_DOCINFOSECURITY +{ + HelpId = HID_DOCINFOSECURITY ; + Hide = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + + FixedLine PASSWORD_TO_OPEN_FL + { + Pos = MAP_APPFONT( 6, 6 ); + Size = MAP_APPFONT( 248, RSC_CD_FIXEDLINE_HEIGHT ); + Text [ en-US ] = "File encryption password"; + }; + FixedText PASSWORD_TO_OPEN_FT + { + Pos = MAP_APPFONT( 12, 20 ); + Size = MAP_APPFONT( 82, RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "~Enter password to open"; + }; + Edit PASSWORD_TO_OPEN_ED + { + Pos = MAP_APPFONT( 100, 18 ); + Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); + Border = TRUE; + PassWord = TRUE; + }; + FixedText CONFIRM_PASSWORD_TO_OPEN_FT + { + Pos = MAP_APPFONT( 12, 34 ); + Size = MAP_APPFONT( 82, RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "~Reenter password to open"; + }; + Edit CONFIRM_PASSWORD_TO_OPEN_ED + { + Pos = MAP_APPFONT( 100, 32 ); + Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); + Border = TRUE; + PassWord = TRUE; + }; + FixedText PASSWORD_INFO_FT + { + Pos = MAP_APPFONT( 12, 48 ); + Size = MAP_APPFONT( 236, 3 * RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "Note: If you lose or forget the password, it cannot be recovered."\ + "It is advisable to keep passwords in a safe place."\ + "Passwords are case-sensitive."; + WordBreak = TRUE; + }; + FixedLine PASSWORD_TO_MODIFY_FL + { + Pos = MAP_APPFONT( 6, 78 ); + Size = MAP_APPFONT( 248, RSC_CD_FIXEDLINE_HEIGHT ); + Text [ en-US ] = "File sharing password"; + }; + FixedText PASSWORD_TO_MODIFY_FT + { + Pos = MAP_APPFONT( 12, 92 ); + Size = MAP_APPFONT( 82, RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "Enter password to modify"; + }; + Edit PASSWORD_TO_MODIFY_ED + { + Pos = MAP_APPFONT( 100, 90 ); + Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); + Border = TRUE; + PassWord = TRUE; + }; + FixedText CONFIRM_PASSWORD_TO_MODIFY_FT + { + Pos = MAP_APPFONT( 12, 106 ); + Size = MAP_APPFONT( 82, RSC_CD_FIXEDTEXT_HEIGHT ); + Text [ en-US ] = "Reenter password to modify"; + }; + Edit CONFIRM_PASSWORD_TO_MODIFY_ED + { + Pos = MAP_APPFONT( 100, 104 ); + Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); + Border = TRUE; + PassWord = TRUE; + }; + FixedLine OPTIONS_FL + { + Pos = MAP_APPFONT( 6, 120 ); + Size = MAP_APPFONT( 248, RSC_CD_FIXEDLINE_HEIGHT ); + Text [ en-US ] = "File sharing options"; + }; + CheckBox OPEN_READONLY_CB + { + Pos = MAP_APPFONT( 12, 133 ); + Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); + Text [ en-US ] = "~Open file read-only"; + }; + CheckBox REMOVE_INFO_ON_SAVING_CB + { + Pos = MAP_APPFONT( 12, 147 ); + Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); + Text [ en-US ] = "Remove personal ~information on saving"; + }; + CheckBox RECORD_CHANGES_CB + { + Pos = MAP_APPFONT( 12, 162 ); + Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); + Text [ en-US ] = "Record ~changes"; + }; + PushButton CHANGE_PROTECTION_PB + { + Pos = MAP_APPFONT( 194, 160 ); + Size = MAP_APPFONT( 60, RSC_CD_PUSHBUTTON_HEIGHT ); + }; + String STR_PROTECT + { + Text [ en-US ] = "~Protect..."; + }; + String STR_UNPROTECT + { + Text [ en-US ] = "~Unprotect..."; + }; + +}; + + diff --git a/sfx2/source/inc/helpid.hrc b/sfx2/source/inc/helpid.hrc old mode 100644 new mode 100755 index 618b61b54c..92fd998d92 --- a/sfx2/source/inc/helpid.hrc +++ b/sfx2/source/inc/helpid.hrc @@ -46,6 +46,7 @@ #define HID_DOCINFODESC (HID_SFX_START + 8) #define HID_DOCINFODOC (HID_SFX_START + 9) #define HID_DOCINFOUSER (HID_SFX_START + 10) +#define HID_DOCINFOSECURITY (HID_SFX_START + 11) #define HID_BOOKMARKPROPS (HID_SFX_START + 14) #define HID_BOOKGROUPPROPS (HID_SFX_START + 15) #define HID_BOOKFILEPROPS (HID_SFX_START + 16) diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc old mode 100644 new mode 100755 index 665ee7fba6..560c7409bb --- a/svx/inc/svx/svxids.hrc +++ b/svx/inc/svx/svxids.hrc @@ -182,6 +182,7 @@ #define RID_OFA_TP_INTERNATIONAL_IMPR (RID_OFA_START + 254) // 4 impress */ +#define SID_ATTR_XWINDOW (RID_OFA_START + 250) #define SID_ATTR_PARENTWINDOW (RID_OFA_START + 255) // -------------------------------------------------------------------------- -- cgit v1.2.3 From 334005d6914b4c9c0cbdf4c214603f5b6a34283e Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Fri, 26 Mar 2010 09:35:40 +0100 Subject: tl78: #i105076# add ENCRYPTION and PASSWORDTOMODIFY filter flags --- sfx2/inc/sfx2/docfilt.hxx | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/docfilt.hxx b/sfx2/inc/sfx2/docfilt.hxx index f7ed7db1af..9c6c0b18ac 100644 --- a/sfx2/inc/sfx2/docfilt.hxx +++ b/sfx2/inc/sfx2/docfilt.hxx @@ -37,6 +37,7 @@ #include #include +// TODO/LATER: The flags should be part of the UNO specification #define SFX_FILTER_IMPORT 0x00000001L #define SFX_FILTER_EXPORT 0x00000002L #define SFX_FILTER_TEMPLATE 0x00000004L @@ -45,13 +46,13 @@ #define SFX_FILTER_OWN 0x00000020L #define SFX_FILTER_ALIEN 0x00000040L #define SFX_FILTER_USESOPTIONS 0x00000080L -#define SFX_FILTER_NOTINFILEDLG 0x00001000L -#define SFX_FILTER_NOTINCHOOSER 0x00002000L #define SFX_FILTER_DEFAULT 0x00000100L #define SFX_FILTER_EXECUTABLE 0x00000200L #define SFX_FILTER_SUPPORTSSELECTION 0x00000400L #define SFX_FILTER_MAPTOAPPPLUG 0x00000800L +#define SFX_FILTER_NOTINFILEDLG 0x00001000L +#define SFX_FILTER_NOTINCHOOSER 0x00002000L #define SFX_FILTER_ASYNC 0x00004000L // Legt Objekt nur an, kein Laden #define SFX_FILTER_CREATOR 0x00008000L @@ -64,6 +65,10 @@ #define SFX_FILTER_SILENTEXPORT 0x00200000L #define SFX_FILTER_BROWSERPREFERED 0x00400000L + +#define SFX_FILTER_ENCRYPTION 0x01000000L +#define SFX_FILTER_PASSWORDTOMODIFY 0x02000000L + #define SFX_FILTER_PREFERED 0x10000000L #define SFX_FILTER_VERSION_NONE 0 @@ -71,20 +76,6 @@ #include -//======================================================================== - -namespace sfx2 { - -/** Returns true if the passed string is the name of a Microsoft Office file - format filter supporting export of password protected documents. - - This function is just a hack for #i105076# is fixed and needs to be removed - then. - */ -SFX2_DLLPUBLIC bool CheckMSPasswordCapabilityForExport( const String& rFilterName ); - -} // namespace sfx2 - //======================================================================== class SfxFilterContainer; class SotStorage; -- cgit v1.2.3 From dc532ca2b5eb66787eda9b39f25b02aef2b7749f Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 30 Mar 2010 16:47:18 +0200 Subject: tl78: #i110383# support password to modify --- sfx2/inc/sfx2/sfxsids.hrc | 5 +- sfx2/sdi/sfx.sdi | 30 +++++++++- sfx2/source/dialog/filedlghelper.cxx | 51 ++++++++++++++-- sfx2/source/doc/guisaveas.cxx | 109 +++++++++++++++++++++++++++++++++++ sfx2/source/doc/objstor.cxx | 51 +--------------- 5 files changed, 188 insertions(+), 58 deletions(-) (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index 9866d4ae96..eeffb2cb5d 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -505,8 +505,9 @@ #define SID_ACTIVATE_STYLE_APPLY (SID_SFX_START + 1715) #define SID_FONT_NAME (SID_SFX_START + 1716) #define SID_DEFAULTFILENAME (SID_SFX_START + 1717) -#define SID_MODIFYPASSWORDHASH (SID_SFX_START + 1718) -#define SID_SFX_free_START (SID_SFX_START + 1719) +#define SID_PASSWORDTOMODIFYHASH (SID_SFX_START + 1718) +#define SID_RECOMMENDREADONLY (SID_SFX_START + 1719) +#define SID_SFX_free_START (SID_SFX_START + 1720) #define SID_SFX_free_END (SID_SFX_START + 3999) #define SID_OPEN_NEW_VIEW (SID_SFX_START + 520) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index d9eb331b20..3b81127ddc 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3990,7 +3990,7 @@ SfxVoidItem MacroOrganizer SID_MACROORGANIZER ] //-------------------------------------------------------------------------- -SfxInt32Item ModifyPasswordHash SID_MODIFYPASSWORDHASH +SfxUInt16Item PasswordToModifyHash SID_PASSWORDTOMODIFYHASH [ /* flags: */ @@ -4016,6 +4016,34 @@ SfxInt32Item ModifyPasswordHash SID_MODIFYPASSWORDHASH GroupId = ; ] +//-------------------------------------------------------------------------- +SfxBoolItem ReccomendReadonly SID_RECOMMENDREADONLY + +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = TRUE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + Readonly = TRUE, + + /* config: */ + AccelConfig = FALSE, + MenuConfig = FALSE, + StatusBarConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = ; +] + + //-------------------------------------------------------------------------- SfxVoidItem RunMacro SID_RUNMACRO () diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 8ff4895366..64d06957d2 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -80,6 +80,7 @@ #include #include #include +#include #include #include #include @@ -1543,7 +1544,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, mbPwdCheckBoxState = ( pPassItem != NULL ); // in case the document has password to modify, the dialog should be shown - SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxStringItem, SID_PASSWORDTOMODIFY, FALSE ); + SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUInt16Item, SID_PASSWORDTOMODIFYHASH, FALSE ); mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue() ); } @@ -1556,7 +1557,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // the password will be set in case user decide so rpSet->ClearItem( SID_PASSWORD ); rpSet->ClearItem( SID_RECOMMENDREADONLY ); - rpSet->ClearItem( SID_PASSWORDTOMODIFY ); + rpSet->ClearItem( SID_PASSWORDTOMODIFYHASH ); } @@ -1634,8 +1635,10 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // set the filter getRealFilter( rFilter ); + SfxFilter* pCurrentFilter = getCurentSfxFilter(); + // fill the rpURLList - implGetAndCacheFiles(mxFileDlg, rpURLList, getCurentSfxFilter()); + implGetAndCacheFiles( mxFileDlg, rpURLList, pCurrentFilter ); if ( rpURLList == NULL || rpURLList->GetObject(0) == NULL ) return ERRCODE_ABORT; @@ -1654,12 +1657,13 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, if( xInteractionHandler.is() ) { // TODO: need a save way to distinguish MS filters from other filters - sal_Bool bMSType = CheckMSPasswordCapabilityForExport( rFilter ); + // for now MS-filters are the only alien filters that support encryption + sal_Bool bMSType = !pCurrentFilter->isOwn(); ::comphelper::DocPasswordRequestType eType = bMSType ? ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD; - ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), lclCheckPasswordToModifyCapability( getCurentSfxFilter() ) ) ); + ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), lclCheckPasswordToModifyCapability( pCurrentFilter ) ) ); uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest ); xInteractionHandler->handle( rRequest ); @@ -1672,7 +1676,42 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); if ( pPasswordRequest->getPasswordToModify().getLength() ) - rpSet->Put( SfxStringItem( SID_PASSWORDTOMODIFY, pPasswordRequest->getPasswordToModify() ) ); + { + rtl_TextEncoding nEncoding = RTL_TEXTENCOFING_UTF8; + if ( bMSType ) + { + // if the MS-filter should be used + // use the inconsistent algorithm to find the encoding specified by MS + nEncoding = rtl_getThreadTextEncoding(); + switch( nEncoding ) + { + case RTL_TEXTENCODING_ISO_8859_15: + case RTL_TEXTENCODING_MS_874: + case RTL_TEXTENCODING_MS_1250: + case RTL_TEXTENCODING_MS_1251: + case RTL_TEXTENCODING_MS_1252: + case RTL_TEXTENCODING_MS_1253: + case RTL_TEXTENCODING_MS_1254: + case RTL_TEXTENCODING_MS_1255: + case RTL_TEXTENCODING_MS_1256: + case RTL_TEXTENCODING_MS_1257: + case RTL_TEXTENCODING_MS_1258: + case RTL_TEXTENCODING_SHIFT_JIS: + case RTL_TEXTENCODING_GB_2312: + case RTL_TEXTENCODING_BIG5: + // in case the system uses an encoding from the list above, it should be used + break; + + default: + // in case other encoding is used, use one of the encodings from the list + nEncoding = RTL_TEXTENCODING_MS_1250; + break; + } + } + + sal_uInt16 nHash = ::comphelper::DocPasswordHelper::GetXLHashAsUINT16( pPasswordRequest->getPasswordToModify(), nEncoding ); + rpSet->Put( SfxUInt16Item( SID_PASSWORDTOMODIFYHASH, nHash ) ); + } } else return ERRCODE_ABORT; diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index cbbed369fc..b8e775801a 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -62,6 +62,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -80,6 +83,7 @@ #include #include #include +#include #include #include "alienwarn.hxx" @@ -108,6 +112,7 @@ const ::rtl::OUString aFilterFlagsString = ::rtl::OUString::createFromAscii( " using namespace ::com::sun::star; +namespace { //------------------------------------------------------------------------- static sal_uInt16 getSlotIDFromMode( sal_Int8 nStoreMode ) { @@ -167,6 +172,88 @@ static sal_Int32 getDontFlags( sal_Int8 nStoreMode ) | ( ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) ) ? SFX_FILTER_IMPORT : 0 ) ); } +//========================================================================= +// class DocumentSettingsGuard +//========================================================================= + +class DocumentSettingsGuard +{ + uno::Reference< beans::XPropertySet > m_xDocumentSettings; + sal_Bool m_bPreserveReadOnly; + sal_uInt16 m_nPreserveHash; + + sal_Bool m_bReadOnlySupported; + sal_Bool m_bModifyPasswordHashSupported; + + sal_Bool m_bRestoreSettings; +public: + DocumentSettingsGuard( const uno::Reference< frame::XModel >& xModel, sal_Bool bReadOnly, sal_uInt16 nHash, sal_Bool bRestore ) + : m_bPreserveReadOnly( sal_False ) + , m_nPreserveHash( 0 ) + , m_bReadOnlySupported( sal_False ) + , m_bModifyPasswordHashSupported( sal_False ) + , m_bRestoreSettings( bRestore ) + { + try + { + uno::Reference< lang::XMultiServiceFactory > xDocSettingsSupplier( xModel, uno::UNO_QUERY_THROW ); + m_xDocumentSettings.set( + xDocSettingsSupplier->createInstance( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.Settings" ) ) ), + uno::UNO_QUERY_THROW ); + + ::rtl::OUString aLoadReadonlyString( RTL_CONSTASCII_USTRINGPARAM( "LoadReadonly" ) ); + ::rtl::OUString aModifyPasswordHashString( RTL_CONSTASCII_USTRINGPARAM( "ModifyPasswordHash" ) ); + + try + { + m_xDocumentSettings->getPropertyValue( aLoadReadonlyString ) >>= m_bPreserveReadOnly; + m_xDocumentSettings->setPropertyValue( aLoadReadonlyString, uno::makeAny( bReadOnly ) ); + m_bReadOnlySupported = sal_True; + } + catch( uno::Exception& ) + {} + + try + { + m_xDocumentSettings->getPropertyValue( aModifyPasswordHashString ) >>= m_nPreserveHash; + m_xDocumentSettings->setPropertyValue( aModifyPasswordHashString, uno::makeAny( nHash ) ); + m_bModifyPasswordHashSupported = sal_True; + } + catch( uno::Exception& ) + {} + } + catch( uno::Exception& ) + {} + + if ( ( bReadOnly && !m_bReadOnlySupported ) || ( nHash && !m_bModifyPasswordHashSupported ) ) + throw uno::RuntimeException(); // the user could provide the data, so it must be stored + } + + ~DocumentSettingsGuard() + { + if ( m_bRestoreSettings ) + { + ::rtl::OUString aLoadReadonlyString( RTL_CONSTASCII_USTRINGPARAM( "LoadReadonly" ) ); + ::rtl::OUString aModifyPasswordHashString( RTL_CONSTASCII_USTRINGPARAM( "ModifyPasswordHash" ) ); + + try + { + if ( m_bReadOnlySupported ) + m_xDocumentSettings->setPropertyValue( aLoadReadonlyString, uno::makeAny( m_bPreserveReadOnly ) ); + + if ( m_bModifyPasswordHashSupported ) + m_xDocumentSettings->setPropertyValue( aModifyPasswordHashString, uno::makeAny( m_nPreserveHash ) ); + } + catch( uno::Exception& ) + { + OSL_ASSERT( "Unexpected exception!" ); + } + } + } +}; +} // anonymous namespace + //========================================================================= // class ModelData_Impl //========================================================================= @@ -184,6 +271,9 @@ class ModelData_Impl ::comphelper::SequenceAsHashMap m_aMediaDescrHM; + sal_Bool m_bRecommendReadOnly; + sal_uInt16 m_nPasswordToModifyHash; + public: ModelData_Impl( SfxStoringHelper& aOwner, const uno::Reference< frame::XModel >& xModel, @@ -200,6 +290,9 @@ public: ::comphelper::SequenceAsHashMap& GetMediaDescr() { return m_aMediaDescrHM; } + sal_Bool IsRecommendReadOnly() { return m_bRecommendReadOnly; } + sal_uInt16 GetPasswordToModifyHash() { return m_nPasswordToModifyHash; } + const ::comphelper::SequenceAsHashMap& GetDocProps(); ::rtl::OUString GetModuleName(); @@ -252,6 +345,9 @@ ModelData_Impl::ModelData_Impl( SfxStoringHelper& aOwner, , m_pDocumentPropsHM( NULL ) , m_pModulePropsHM( NULL ) , m_aMediaDescrHM( aMediaDescr ) +, m_bRecommendReadOnly( sal_False ) +, m_nPasswordToModifyHash( 0 ) + { CheckInteractionHandler(); } @@ -915,6 +1011,17 @@ sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode, } ::rtl::OUString aFilterName = aStringTypeFN; + + // the following two arguments can not be converted in MediaDescriptor, + // so they should be removed from the ItemSet after retrieving + SFX_ITEMSET_ARG( pDialogParams, pRecommendReadOnly, SfxBoolItem, SID_RECOMMENDREADONLY, sal_False ); + m_bRecommendReadOnly = ( pRecommendReadOnly && pRecommendReadOnly->GetValue() ); + pDialogParams->ClearItem( SID_RECOMMENDREADONLY ); + + SFX_ITEMSET_ARG( pDialogParams, pPassToModifyItem, SfxUInt16Item, SID_PASSWORDTOMODIFYHASH, sal_False ); + if ( pPassToModifyItem ) + m_nPasswordToModifyHash = pPassToModifyItem->GetValue(); + pDialogParams->ClearItem( SID_PASSWORDTOMODIFYHASH ); uno::Sequence< beans::PropertyValue > aPropsFromDialog; TransformItems( nSlotID, *pDialogParams, aPropsFromDialog, NULL ); @@ -1500,6 +1607,8 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& // store the document and handle it's docinfo SvtSaveOptions aOptions; + DocumentSettingsGuard aSettingsGuard( aModelData.GetModel(), aModelData.IsRecommendReadOnly(), aModelData.GetPasswordToModifyHash(), nStoreMode & EXPORT_REQUESTED ); + if ( aOptions.IsDocInfoSave() && ( !aModelData.GetStorable()->hasLocation() || INetURLObject( aModelData.GetStorable()->getLocation() ) != aURL ) ) diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 22fb955887..740728d72a 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -1376,7 +1376,6 @@ sal_Bool SfxObjectShell::SaveTo_Impl { if ( pFilt->GetServiceName() != rMedium.GetFilter()->GetServiceName() ) { -//REMOVE rMedium.GetStorage()->SetClass( SvFactory::GetServerName( nFormat ), nFormat, pFilt->GetTypeName() ); datatransfer::DataFlavor aDataFlavor; SotExchange::GetFormatDataFlavor( nFormat, aDataFlavor ); @@ -2093,9 +2092,6 @@ sal_Bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed ) } else { -//REMOVE if( pFilter->UsesStorage() ) -//REMOVE pMedium->GetStorage(); -//REMOVE else if( pMedium->GetOpenMode() & STREAM_WRITE ) if( pMedium->GetOpenMode() & STREAM_WRITE ) pMedium->GetInStream(); xStorage = GetStorage(); @@ -2632,9 +2628,6 @@ sal_Bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs ) SetError(pMediumTmp->GetErrorCode(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); -//REMOVE if ( !IsHandsOff() ) -//REMOVE pMediumTmp->Close(); - sal_Bool bOpen( sal_False ); bOpen = DoSaveCompleted( pMediumTmp ); DBG_ASSERT(bOpen,"Fehlerbehandlung fuer DoSaveCompleted nicht implementiert"); @@ -2645,13 +2638,7 @@ sal_Bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs ) SetError( pMediumTmp->GetError(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); // reconnect to object storage -//REMOVE if ( IsHandsOff() ) -//REMOVE { -//REMOVE if ( !DoSaveCompleted( pRetrMedium ) ) -//REMOVE DBG_ERROR("Case not handled - no way to get a storage!"); -//REMOVE } -//REMOVE else - DoSaveCompleted( 0 ); + DoSaveCompleted( 0 ); if( pRetrMedium->GetItemSet() ) { @@ -2910,8 +2897,6 @@ sal_Bool SfxObjectShell::PreDoSaveAs_Impl else pNewFile->SetFilter( GetFactory().GetFilterContainer()->GetAnyFilter( SFX_FILTER_IMPORT | SFX_FILTER_EXPORT ) ); -//REMOVE // saving is alway done using a temporary file -//REMOVE pNewFile->CreateTempFileNoCopy(); if ( pNewFile->GetErrorCode() != ERRCODE_NONE ) { // creating temporary file failed ( f.e. floppy disk not inserted! ) @@ -2948,18 +2933,8 @@ sal_Bool SfxObjectShell::PreDoSaveAs_Impl SetError( pNewFile->GetErrorCode(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); // notify the document that saving was done successfully -//REMOVE if ( bCopyTo ) -//REMOVE { -//REMOVE if ( IsHandsOff() ) -//REMOVE bOk = DoSaveCompleted( pMedium ); -//REMOVE } -//REMOVE else if ( !bCopyTo ) { - // Muss !!! -//REMOVE if ( bToOwnFormat ) -//REMOVE SetFileName( pNewFile->GetPhysicalName() ); - bOk = DoSaveCompleted( pNewFile ); } else @@ -2991,31 +2966,12 @@ sal_Bool SfxObjectShell::PreDoSaveAs_Impl // by the storage DELETEZ( pNewFile ); } - - // TODO/LATER: there is no need in the following code in case HandsOff is not used, - // hope we will not have to introduce it back -//REMOVE String aPasswd; -//REMOVE if ( IsOwnStorageFormat_Impl( *GetMedium() ) && GetPasswd_Impl( GetMedium()->GetItemSet(), aPasswd ) ) -//REMOVE { -//REMOVE try -//REMOVE { -//REMOVE // the following code must throw an exception in case of failure -//REMOVE ::comphelper::OStorageHelper::SetCommonStoragePassword( GetMedium->GetStorage(), aPasswd ); -//REMOVE } -//REMOVE catch( uno::Exception& ) -//REMOVE { -//REMOVE // TODO: handle the error -//REMOVE } -//REMOVE } } else { SetError( pNewFile->GetErrorCode(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); -//REMOVE // reconnect to the old storage -//REMOVE if ( IsHandsOff() ) -//REMOVE DoSaveCompleted( pMedium ); -//REMOVE else + // reconnect to the old storage DoSaveCompleted( 0 ); DELETEZ( pNewFile ); @@ -3196,9 +3152,6 @@ sal_Bool SfxObjectShell::LoadOwnFormat( SfxMedium& rMedium ) uno::Reference< embed::XStorage > xStorage = rMedium.GetStorage(); if ( xStorage.is() ) { -//REMOVE if ( rMedium.GetFileVersion() ) -//REMOVE xStor->SetVersion( rMedium.GetFileVersion() ); - // Password SFX_ITEMSET_ARG( rMedium.GetItemSet(), pPasswdItem, SfxStringItem, SID_PASSWORD, sal_False ); if ( pPasswdItem || ERRCODE_IO_ABORT != CheckPasswd_Impl( this, SFX_APP()->GetPool(), pMedium ) ) -- cgit v1.2.3 From 21b7c4d2c4d6eae9274511360b36448834696766 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 30 Mar 2010 16:34:51 +0200 Subject: tl78: #i110383# support password to modify --- sfx2/inc/sfx2/objsh.hxx | 3 +++ sfx2/source/dialog/filedlghelper.cxx | 16 ++++++++-------- sfx2/source/doc/objcont.cxx | 17 +++++++++++++++++ sfx2/source/doc/objxtor.cxx | 1 + sfx2/source/inc/objshimp.hxx | 2 ++ 5 files changed, 31 insertions(+), 8 deletions(-) (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index c73e373d57..c4f51e464a 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -444,6 +444,9 @@ public: void SetSaveVersionOnClose( sal_Bool bSet ); void ResetFromTemplate( const String& rTemplateName, const String& rFileName ); + sal_uInt16 GetModifyPasswordHash() const; + sal_Bool SetModifyPasswordHash( sal_uInt16 nHash ); + static sal_uInt32 HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDoc ); virtual void ViewAssigned(); diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 64d06957d2..7228a6973a 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1635,7 +1635,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // set the filter getRealFilter( rFilter ); - SfxFilter* pCurrentFilter = getCurentSfxFilter(); + const SfxFilter* pCurrentFilter = getCurentSfxFilter(); // fill the rpURLList implGetAndCacheFiles( mxFileDlg, rpURLList, pCurrentFilter ); @@ -1658,31 +1658,31 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, { // TODO: need a save way to distinguish MS filters from other filters // for now MS-filters are the only alien filters that support encryption - sal_Bool bMSType = !pCurrentFilter->isOwn(); + sal_Bool bMSType = !pCurrentFilter->IsOwnFormat(); ::comphelper::DocPasswordRequestType eType = bMSType ? ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD; ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), lclCheckPasswordToModifyCapability( pCurrentFilter ) ) ); - uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest ); + uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() ); xInteractionHandler->handle( rRequest ); - if ( pPasswordRequest->isSelected() ) + if ( pPasswordRequest->isPassword() ) { - if ( pPasswordRequest->isPassword() ) + if ( pPasswordRequest->getPassword().getLength() ) rpSet->Put( SfxStringItem( SID_PASSWORD, pPasswordRequest->getPassword() ) ); - if ( pPasswordRequest->isRecommendReadOnly() ) + if ( pPasswordRequest->getRecommendReadOnly() ) rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); if ( pPasswordRequest->getPasswordToModify().getLength() ) { - rtl_TextEncoding nEncoding = RTL_TEXTENCOFING_UTF8; + rtl_TextEncoding nEncoding = RTL_TEXTENCODING_UTF8; if ( bMSType ) { // if the MS-filter should be used // use the inconsistent algorithm to find the encoding specified by MS - nEncoding = rtl_getThreadTextEncoding(); + nEncoding = osl_getThreadTextEncoding(); switch( nEncoding ) { case RTL_TEXTENCODING_ISO_8859_15: diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index c25b0d79b0..d8b396f1ed 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1479,3 +1479,20 @@ void SfxObjectShell::SetSaveVersionOnClose( sal_Bool bNew ) pImp->bSaveVersionOnClose = bNew; } +sal_uInt16 SfxObjectShell::GetModifyPasswordHash() const +{ + return pImp->m_nModifyPasswordHash; +} + +sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt16 nHash ) +{ + if ( !IsReadOnly() && !IsReadOnlyUI() ) + { + // the hash can be changed only in editable documents, + pImp->m_nModifyPasswordHash = nHash; + return sal_True; + } + + return sal_False; +} + diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index b114960b20..70ef0edcab 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -262,6 +262,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,m_xDocInfoListener() ,m_bIsInit( sal_False ) ,m_bIncomplEncrWarnShown( sal_False ) + ,m_nModifyPasswordHash( 0 ) { } diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index 1c60561c49..64cf1922be 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -170,6 +170,8 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess sal_Bool m_bIncomplEncrWarnShown; + sal_uInt16 m_nModifyPasswordHash; + SfxObjectShell_Impl( SfxObjectShell& _rDocShell ); virtual ~SfxObjectShell_Impl(); -- cgit v1.2.3 From 7d0ebb5b2f5427a1afbdf543f1321d6c6a75eed7 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 22 Apr 2010 12:51:04 +0200 Subject: tl78: #i110383# password to modify support --- sfx2/inc/sfx2/docfile.hxx | 2 + sfx2/inc/sfx2/objsh.hxx | 5 +- sfx2/source/dialog/filedlghelper.cxx | 63 +------- sfx2/source/doc/docfile.cxx | 50 ++++++ sfx2/source/doc/objcont.cxx | 10 ++ sfx2/source/doc/objmisc.cxx | 29 ++++ sfx2/source/doc/objxtor.cxx | 1 + sfx2/source/inc/objshimp.hxx | 2 +- sfx2/source/view/viewfrm.cxx | 286 +++++++++++++++++++++-------------- uui/source/iahndl-authentication.cxx | 21 ++- uui/source/loginerr.hxx | 154 +++++++++---------- 11 files changed, 368 insertions(+), 255 deletions(-) (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx index 12e3b3dcee..25c8acabf4 100644 --- a/sfx2/inc/sfx2/docfile.hxx +++ b/sfx2/inc/sfx2/docfile.hxx @@ -166,6 +166,7 @@ public: const SfxFilter * GetFilter() const { return pFilter; } const SfxFilter * GetOrigFilter( sal_Bool bNotCurrent = sal_False ) const; const String& GetOrigURL() const; + SfxItemSet * GetItemSet() const; void SetItemSet(SfxItemSet *pSet); void Close(); @@ -342,6 +343,7 @@ public: static sal_Bool CallApproveHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler, ::com::sun::star::uno::Any aRequest, sal_Bool bAllowAbort ); static sal_Bool SetWritableForUserOnly( const ::rtl::OUString& aURL ); + static sal_uInt16 CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bMSType ); }; SV_DECL_IMPL_REF( SfxMedium ) diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index c4f51e464a..2e3618ecc0 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -294,9 +294,10 @@ public: sal_Bool HasName() const { return bHasName; } virtual String GetAPIName() const; void SetHasName( sal_Bool bSet = sal_True ) { bHasName = bSet; } + void SetReadOnly(); sal_Bool IsReadOnly() const; sal_Bool IsReadOnlyMedium() const; - void SetReadOnlyUI( sal_Bool bReadOnly = sal_True ); + void SetReadOnlyUI( sal_Bool bReadOnly = sal_True ); sal_Bool IsReadOnlyUI() const; void SetNoName(); sal_Bool IsInModalMode() const; @@ -736,6 +737,8 @@ public: SAL_DLLPRIVATE sal_uInt16 ImplCheckSignaturesInformation( const ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation >& aInfos ); SAL_DLLPRIVATE void CheckEncryption_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); + SAL_DLLPRIVATE void SetModifyPasswordEntered(); + SAL_DLLPRIVATE sal_Bool IsModifyPasswordEntered(); SAL_DLLPRIVATE SEQUENCE< OUSTRING > GetEventNames_Impl(); SAL_DLLPRIVATE void InitBasicManager_Impl(); diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 7228a6973a..337e9bc634 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -80,7 +80,6 @@ #include #include #include -#include #include #include #include @@ -465,22 +464,6 @@ sal_Bool FileDialogHelper_Impl::isInOpenMode() const // ------------------------------------------------------------------------ -namespace { - -sal_Bool lclCheckPasswordCapability( const SfxFilter* pFilter ) -{ - return pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_ENCRYPTION ); -} - -sal_Bool lclCheckPasswordToModifyCapability( const SfxFilter* pFilter ) -{ - return pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ); -} - -} - -// ------------------------------------------------------------------------ - void FileDialogHelper_Impl::updateFilterOptionsBox() { if ( !m_bHaveFilterOptions ) @@ -571,9 +554,10 @@ void FileDialogHelper_Impl::enablePasswordBox( sal_Bool bInit ) sal_Bool bWasEnabled = mbIsPwdEnabled; + const SfxFilter* pCurrentFilter = getCurentSfxFilter(); mbIsPwdEnabled = updateExtendedControl( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, - lclCheckPasswordCapability( getCurentSfxFilter() ) + pCurrentFilter && ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_ENCRYPTION ) ); if( bInit ) @@ -1643,7 +1627,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, return ERRCODE_ABORT; // check, wether or not we have to display a password box - if ( mbHasPassword && mbIsPwdEnabled && xCtrlAccess.is() ) + if ( pCurrentFilter && mbHasPassword && mbIsPwdEnabled && xCtrlAccess.is() ) { try { @@ -1663,7 +1647,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD; - ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), lclCheckPasswordToModifyCapability( pCurrentFilter ) ) ); + ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ) ) ); uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() ); xInteractionHandler->handle( rRequest ); @@ -1675,43 +1659,10 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, if ( pPasswordRequest->getRecommendReadOnly() ) rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); - if ( pPasswordRequest->getPasswordToModify().getLength() ) - { - rtl_TextEncoding nEncoding = RTL_TEXTENCODING_UTF8; - if ( bMSType ) - { - // if the MS-filter should be used - // use the inconsistent algorithm to find the encoding specified by MS - nEncoding = osl_getThreadTextEncoding(); - switch( nEncoding ) - { - case RTL_TEXTENCODING_ISO_8859_15: - case RTL_TEXTENCODING_MS_874: - case RTL_TEXTENCODING_MS_1250: - case RTL_TEXTENCODING_MS_1251: - case RTL_TEXTENCODING_MS_1252: - case RTL_TEXTENCODING_MS_1253: - case RTL_TEXTENCODING_MS_1254: - case RTL_TEXTENCODING_MS_1255: - case RTL_TEXTENCODING_MS_1256: - case RTL_TEXTENCODING_MS_1257: - case RTL_TEXTENCODING_MS_1258: - case RTL_TEXTENCODING_SHIFT_JIS: - case RTL_TEXTENCODING_GB_2312: - case RTL_TEXTENCODING_BIG5: - // in case the system uses an encoding from the list above, it should be used - break; - - default: - // in case other encoding is used, use one of the encodings from the list - nEncoding = RTL_TEXTENCODING_MS_1250; - break; - } - } - - sal_uInt16 nHash = ::comphelper::DocPasswordHelper::GetXLHashAsUINT16( pPasswordRequest->getPasswordToModify(), nEncoding ); + // the empty password has 0 as Hash + sal_uInt16 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), bMSType ); + if ( nHash ) rpSet->Put( SfxUInt16Item( SID_PASSWORDTOMODIFYHASH, nHash ) ); - } } else return ERRCODE_ABORT; diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index df9477c489..43666afd48 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -115,6 +115,7 @@ using namespace ::com::sun::star::io; #include #include #include +#include #include #include #include @@ -2671,18 +2672,67 @@ void SfxMedium::SetFilter( const SfxFilter* pFilterP, sal_Bool /*bResetOrig*/ ) pFilter = pFilterP; pImp->nFileVersion = 0; } + //---------------------------------------------------------------- const SfxFilter* SfxMedium::GetOrigFilter( sal_Bool bNotCurrent ) const { return ( pImp->pOrigFilter || bNotCurrent ) ? pImp->pOrigFilter : pFilter; } + //---------------------------------------------------------------- void SfxMedium::SetOrigFilter_Impl( const SfxFilter* pOrigFilter ) { pImp->pOrigFilter = pOrigFilter; } + +//------------------------------------------------------------------ + +sal_uInt16 SfxMedium::CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bMSType ) +{ + sal_uInt16 nHash = 0; + + if ( aPasswd.getLength() ) + { + rtl_TextEncoding nEncoding = RTL_TEXTENCODING_UTF8; + if ( bMSType ) + { + // if the MS-filter should be used + // use the inconsistent algorithm to find the encoding specified by MS + nEncoding = osl_getThreadTextEncoding(); + switch( nEncoding ) + { + case RTL_TEXTENCODING_ISO_8859_15: + case RTL_TEXTENCODING_MS_874: + case RTL_TEXTENCODING_MS_1250: + case RTL_TEXTENCODING_MS_1251: + case RTL_TEXTENCODING_MS_1252: + case RTL_TEXTENCODING_MS_1253: + case RTL_TEXTENCODING_MS_1254: + case RTL_TEXTENCODING_MS_1255: + case RTL_TEXTENCODING_MS_1256: + case RTL_TEXTENCODING_MS_1257: + case RTL_TEXTENCODING_MS_1258: + case RTL_TEXTENCODING_SHIFT_JIS: + case RTL_TEXTENCODING_GB_2312: + case RTL_TEXTENCODING_BIG5: + // in case the system uses an encoding from the list above, it should be used + break; + + default: + // in case other encoding is used, use one of the encodings from the list + nEncoding = RTL_TEXTENCODING_MS_1250; + break; + } + } + + nHash = ::comphelper::DocPasswordHelper::GetXLHashAsUINT16( aPasswd, nEncoding ); + } + + return nHash; +} + //------------------------------------------------------------------ void SfxMedium::Close() diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index b714f76cd1..1f251f9913 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1499,3 +1499,13 @@ sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt16 nHash ) // return sal_False; } +void SfxObjectShell::SetModifyPasswordEntered() +{ + pImp->m_bModifyPasswordEntered = sal_True; +} + +sal_Bool SfxObjectShell::IsModifyPasswordEntered() +{ + return pImp->m_bModifyPasswordEntered; +} + diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 9373cdef27..c83a94609a 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -476,6 +476,32 @@ void SfxObjectShell::SetReadOnlyUI( sal_Bool bReadOnly ) //------------------------------------------------------------------------- +void SfxObjectShell::SetReadOnly() +{ + // Let the document be completely readonly, means that the + // medium open mode is adjusted accordingly, and the write lock + // on the file is removed. + + if ( pMedium && !IsReadOnlyMedium() ) + { + sal_Bool bWasROUI = IsReadOnly(); + + pMedium->UnlockFile( sal_False ); + + // the storage-based mediums are already based on the temporary file + // so UnlockFile has already closed the locking stream + if ( !pMedium->HasStorage_Impl() && IsLoadingFinished() ) + pMedium->CloseInStream(); + + pMedium->SetOpenMode( SFX_STREAM_READONLY, pMedium->IsDirect(), sal_True ); + pMedium->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) ); + + if ( !bWasROUI ) + Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) ); + } +} +//------------------------------------------------------------------------- + sal_Bool SfxObjectShell::IsReadOnly() const { return pImp->bReadOnlyUI || IsReadOnlyMedium(); @@ -1370,6 +1396,9 @@ void SfxObjectShell::FinishedLoading( sal_uInt16 nFlags ) if( !IsAbortingImport() ) PositionView_Impl(); + if ( GetModifyPasswordHash() ) + SetReadOnly(); + // Salvage if ( pSalvageItem ) bSetModifiedTRUE = sal_True; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 70ef0edcab..589974298f 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -263,6 +263,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,m_bIsInit( sal_False ) ,m_bIncomplEncrWarnShown( sal_False ) ,m_nModifyPasswordHash( 0 ) + ,m_bModifyPasswordEntered( sal_False ) { } diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index 64cf1922be..98357b4759 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -171,7 +171,7 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess sal_Bool m_bIncomplEncrWarnShown; sal_uInt16 m_nModifyPasswordHash; - + sal_Bool m_bModifyPasswordEntered; SfxObjectShell_Impl( SfxObjectShell& _rDocShell ); virtual ~SfxObjectShell_Impl(); diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index ad2bf643ca..638229e0e9 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -71,6 +71,7 @@ #include #include #include +#include #include #include @@ -86,6 +87,7 @@ #include #include #include +#include #include #include @@ -113,6 +115,7 @@ namespace css = ::com::sun::star; #include "sfxtypes.hxx" #include #include +#include #include #include "sfxresid.hxx" #include "appbas.hxx" @@ -158,6 +161,48 @@ TYPEINIT1(SfxViewFrameItem, SfxPoolItem); //========================================================================= +static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const ::rtl::OUString& aPath, const SfxFilter* pFilter, sal_uInt16 nPasswordHash ) +{ + sal_Bool bResult = !nPasswordHash; + + OSL_ENSURE( pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ), "PasswordToModify feature is active for a filter that does not support it!" ); + + if ( pFilter && xHandler.is() ) + { + sal_Bool bCancel = sal_False; + sal_Bool bFirstTime = sal_True; + + while ( !bResult && !bCancel ) + { + sal_Bool bMSType = !pFilter->IsOwnFormat(); + ::comphelper::DocPasswordRequestType nType = bMSType ? + ::comphelper::DocPasswordRequestType_MS : + ::comphelper::DocPasswordRequestType_STANDARD; + + ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( + new ::comphelper::DocPasswordRequest( + bMSType ? ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD, + bFirstTime ? ::com::sun::star::task::PasswordRequestMode_PASSWORD_ENTER : ::com::sun::star::task::PasswordRequestMode_PASSWORD_REENTER, + aPath, + sal_True ) ); + + uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() ); + xHandler->handle( rRequest ); + + if ( pPasswordRequest->isPassword() ) + bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), bMSType ) == nPasswordHash ); + else + bCancel = sal_True; + + bFirstTime = sal_False; + } + } + + return bResult; +} + +//========================================================================= + struct SfxViewFrame_Impl { SvBorder aBorder; @@ -371,10 +416,11 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SFX_LOADED_MAINDOCUMENT )) break; + SfxMedium* pMed = pSh->GetMedium(); + SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pItem, SfxBoolItem, SID_VIEWONLY, sal_False ); if ( pItem && pItem->GetValue() ) { - SfxMedium* pMed = pSh->GetMedium(); SfxApplication* pApp = SFX_APP(); SfxAllItemSet aSet( pApp->GetPool() ); aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetURLObject().GetMainURL(INetURLObject::NO_DECODE) ) ); @@ -417,6 +463,22 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) } else { + if ( pSh->IsReadOnlyMedium() + && pSh->GetModifyPasswordHash() + && !pSh->IsModifyPasswordEntered() ) + { + ::rtl::OUString aDocumentName = INetURLObject( pMed->GetOrigURL() ).GetMainURL( INetURLObject::DECODE_WITH_CHARSET ); + if( !AskPasswordToModify_Impl( pMed->GetInteractionHandler(), aDocumentName, pMed->GetOrigFilter(), pSh->GetModifyPasswordHash() ) ) + { + // this is a read-only document, if it has "Password to modify" + // the user should enter password before he can edit the document + rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_False ) ); + return; + } + + pSh->SetModifyPasswordEntered(); + } + nOpenMode = SFX_STREAM_READWRITE; pSh->SetReadOnlyUI( sal_False ); @@ -436,142 +498,138 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) } // doing - if( pSh ) + String aTemp; + utl::LocalFileHelper::ConvertPhysicalNameToURL( pMed->GetPhysicalName(), aTemp ); + INetURLObject aPhysObj( aTemp ); + SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), + pVersionItem, SfxInt16Item, SID_VERSION, sal_False ); + + INetURLObject aMedObj( pMed->GetName() ); + + // the logic below is following, if the document seems not to need to be reloaded and the physical name is different + // to the logical one, then on file system it can be checked that the copy is still newer than the original and no document reload is required + if ( ( !bNeedsReload && ( (aMedObj.GetProtocol() == INET_PROT_FILE && + aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) && + !::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) )) + || pMed->IsRemote() ) ) + || pVersionItem ) { - SfxMedium* pMed = pSh->GetMedium(); - String aTemp; - utl::LocalFileHelper::ConvertPhysicalNameToURL( pMed->GetPhysicalName(), aTemp ); - INetURLObject aPhysObj( aTemp ); - SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), - pVersionItem, SfxInt16Item, SID_VERSION, sal_False ); - - INetURLObject aMedObj( pMed->GetName() ); - - // the logic below is following, if the document seems not to need to be reloaded and the physical name is different - // to the logical one, then on file system it can be checked that the copy is still newer than the original and no document reload is required - if ( ( !bNeedsReload && ( (aMedObj.GetProtocol() == INET_PROT_FILE && - aMedObj.getFSysPath(INetURLObject::FSYS_DETECT) != aPhysObj.getFSysPath(INetURLObject::FSYS_DETECT) && - !::utl::UCBContentHelper::IsYounger( aMedObj.GetMainURL( INetURLObject::NO_DECODE ), aPhysObj.GetMainURL( INetURLObject::NO_DECODE ) )) - || pMed->IsRemote() ) ) - || pVersionItem ) + sal_Bool bOK = sal_False; + if ( !pVersionItem ) { - sal_Bool bOK = sal_False; - if ( !pVersionItem ) + sal_Bool bHasStorage = pMed->HasStorage_Impl(); + // switching edit mode could be possible without reload + if ( bHasStorage && pMed->GetStorage() == pSh->GetStorage() ) { - sal_Bool bHasStorage = pMed->HasStorage_Impl(); - // switching edit mode could be possible without reload - if ( bHasStorage && pMed->GetStorage() == pSh->GetStorage() ) - { - // TODO/LATER: faster creation of copy - if ( !pSh->ConnectTmpStorage_Impl( pMed->GetStorage(), pMed ) ) - return; - } + // TODO/LATER: faster creation of copy + if ( !pSh->ConnectTmpStorage_Impl( pMed->GetStorage(), pMed ) ) + return; + } - pMed->CloseAndRelease(); - pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) ); - pMed->SetOpenMode( nOpenMode, pMed->IsDirect() ); + pMed->CloseAndRelease(); + pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) ); + pMed->SetOpenMode( nOpenMode, pMed->IsDirect() ); - pMed->CompleteReOpen(); - if ( nOpenMode & STREAM_WRITE ) - pMed->LockOrigFileOnDemand( sal_False, sal_True ); + pMed->CompleteReOpen(); + if ( nOpenMode & STREAM_WRITE ) + pMed->LockOrigFileOnDemand( sal_False, sal_True ); - // LockOrigFileOnDemand might set the readonly flag itself, it should be set back - pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) ); + // LockOrigFileOnDemand might set the readonly flag itself, it should be set back + pMed->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, !( nOpenMode & STREAM_WRITE ) ) ); - if ( !pMed->GetErrorCode() ) - bOK = sal_True; - } + if ( !pMed->GetErrorCode() ) + bOK = sal_True; + } - if( !bOK ) + if( !bOK ) + { + ErrCode nErr = pMed->GetErrorCode(); + if ( pVersionItem ) + nErr = ERRCODE_IO_ACCESSDENIED; + else { - ErrCode nErr = pMed->GetErrorCode(); - if ( pVersionItem ) - nErr = ERRCODE_IO_ACCESSDENIED; - else - { - pMed->ResetError(); - pMed->SetOpenMode( SFX_STREAM_READONLY, pMed->IsDirect() ); - pMed->ReOpen(); - pSh->DoSaveCompleted( pMed ); - } + pMed->ResetError(); + pMed->SetOpenMode( SFX_STREAM_READONLY, pMed->IsDirect() ); + pMed->ReOpen(); + pSh->DoSaveCompleted( pMed ); + } - // r/o-Doc kann nicht in Editmode geschaltet werden? - rReq.Done( sal_False ); + // r/o-Doc kann nicht in Editmode geschaltet werden? + rReq.Done( sal_False ); - SFX_REQUEST_ARG( rReq, pFSetItem, SfxBoolItem, SID_EDIT_FRAMESET, sal_False); - if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() ) + SFX_REQUEST_ARG( rReq, pFSetItem, SfxBoolItem, SID_EDIT_FRAMESET, sal_False); + if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() ) + { + // dem ::com::sun::star::sdbcx::User anbieten, als Vorlage zu oeffnen + QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) ); + if ( !pFSetItem && RET_YES == aBox.Execute() ) { - // dem ::com::sun::star::sdbcx::User anbieten, als Vorlage zu oeffnen - QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) ); - if ( !pFSetItem && RET_YES == aBox.Execute() ) + SfxApplication* pApp = SFX_APP(); + SfxAllItemSet aSet( pApp->GetPool() ); + aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) ); + SFX_ITEMSET_ARG( pMed->GetItemSet(), pReferer, SfxStringItem, SID_REFERER, sal_False ); + if ( pReferer ) + aSet.Put( *pReferer ); + aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) ); + if ( pVersionItem ) + aSet.Put( *pVersionItem ); + + if( pMed->GetFilter() ) { - SfxApplication* pApp = SFX_APP(); - SfxAllItemSet aSet( pApp->GetPool() ); - aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) ); - SFX_ITEMSET_ARG( pMed->GetItemSet(), pReferer, SfxStringItem, SID_REFERER, sal_False ); - if ( pReferer ) - aSet.Put( *pReferer ); - aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) ); - if ( pVersionItem ) - aSet.Put( *pVersionItem ); - - if( pMed->GetFilter() ) - { - aSet.Put( SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) ); - SFX_ITEMSET_ARG( pMed->GetItemSet(), pOptions, - SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False ); - if ( pOptions ) - aSet.Put( *pOptions ); - } - - GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, aSet ); - return; + aSet.Put( SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) ); + SFX_ITEMSET_ARG( pMed->GetItemSet(), pOptions, + SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False ); + if ( pOptions ) + aSet.Put( *pOptions ); } - else - nErr = 0; - } - ErrorHandler::HandleError( nErr ); - rReq.SetReturnValue( - SfxBoolItem( rReq.GetSlot(), sal_False ) ); - return; - } - else - { - pSh->DoSaveCompleted( pMed ); - pSh->Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) ); - rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_True ) ); - rReq.Done( sal_True ); - // if( nOpenMode == SFX_STREAM_READONLY ) - // pMed->Close(); - - // ReloadForEdit bei Framesets schaltet auch FramesetEditmode - sal_Bool bIsReadonly = GetObjectShell()->IsReadOnly(); - if ( bIsReadonly != bWasReadonly && !GetFrame()->GetParentFrame() ) - { - SfxBoolItem aItem( SID_EDIT_FRAMESET, !bIsReadonly ); - GetDispatcher()->Execute( SID_EDIT_FRAMESET, - SFX_CALLMODE_RECORD, &aItem, 0L ); - pSh->Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) ); + GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, aSet ); + return; } - return; + else + nErr = 0; } - } - /* - if ( !bReload ) - { - // Es soll nicht reloaded werden - SfxErrorContext aEc( ERRCODE_SFX_NODOCRELOAD ); - ErrorHandler::HandleError( ERRCODE_SFX_NODOCRELOAD ); + ErrorHandler::HandleError( nErr ); rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_False ) ); return; } - */ - // Ansonsten ( lokal und arbeiten auf Kopie ) muss gereloaded - // werden. + else + { + pSh->DoSaveCompleted( pMed ); + pSh->Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) ); + rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_True ) ); + rReq.Done( sal_True ); + // if( nOpenMode == SFX_STREAM_READONLY ) + // pMed->Close(); + + // ReloadForEdit bei Framesets schaltet auch FramesetEditmode + sal_Bool bIsReadonly = GetObjectShell()->IsReadOnly(); + if ( bIsReadonly != bWasReadonly && !GetFrame()->GetParentFrame() ) + { + SfxBoolItem aItem( SID_EDIT_FRAMESET, !bIsReadonly ); + GetDispatcher()->Execute( SID_EDIT_FRAMESET, + SFX_CALLMODE_RECORD, &aItem, 0L ); + pSh->Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) ); + } + return; + } + } + + /* + if ( !bReload ) + { + // Es soll nicht reloaded werden + SfxErrorContext aEc( ERRCODE_SFX_NODOCRELOAD ); + ErrorHandler::HandleError( ERRCODE_SFX_NODOCRELOAD ); + rReq.SetReturnValue( + SfxBoolItem( rReq.GetSlot(), sal_False ) ); + return; } + */ + // Ansonsten ( lokal und arbeiten auf Kopie ) muss gereloaded + // werden. rReq.AppendItem( SfxBoolItem( SID_FORCERELOAD, sal_True) ); rReq.AppendItem( SfxBoolItem( SID_SILENT, sal_True )); diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index b2ec40e9c9..1673be41de 100755 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -32,6 +32,7 @@ #include "com/sun/star/task/MasterPasswordRequest.hpp" #include "com/sun/star/task/XInteractionAbort.hpp" #include "com/sun/star/task/XInteractionPassword.hpp" +#include "com/sun/star/task/XInteractionPassword2.hpp" #include "com/sun/star/task/XInteractionRetry.hpp" #include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp" #include "com/sun/star/ucb/URLAuthenticationRequest.hpp" @@ -431,7 +432,7 @@ executePasswordDialog( pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen ) ); rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); - rInfo.SetPasswordToOpen( pDialog->GetPasswordToOpen() ); + rInfo.SetPassword( pDialog->GetPasswordToOpen() ); rInfo.SetPasswordToModify( pDialog->GetPasswordToModify() ); rInfo.SetRecommendToOpenReadonly( pDialog->IsRecommendToOpenReadonly() ); } @@ -441,7 +442,7 @@ executePasswordDialog( new PasswordDialog( pParent, nMode, xManager.get(), aDocName, bIsPasswordToModify ) ); rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL ); - rInfo.SetPasswordToOpen( bIsPasswordToModify ? String() : pDialog->GetPassword() ); + rInfo.SetPassword( bIsPasswordToModify ? String() : pDialog->GetPassword() ); rInfo.SetPasswordToModify( bIsPasswordToModify ? pDialog->GetPassword() : String() ); } } @@ -467,7 +468,12 @@ handlePasswordRequest_( uno::Reference< task::XInteractionRetry > xRetry; uno::Reference< task::XInteractionAbort > xAbort; uno::Reference< task::XInteractionPassword > xPassword; - getContinuations(rContinuations, &xRetry, &xAbort, &xPassword); + uno::Reference< task::XInteractionPassword2 > xPassword2; + getContinuations(rContinuations, &xRetry, &xAbort, &xPassword2, &xPassword); + + if ( xPassword2.is() && !xPassword.is() ) + xPassword.set( xPassword2, uno::UNO_QUERY_THROW ); + LoginErrorInfo aInfo; executePasswordDialog( pParent, aInfo, nMode, @@ -476,8 +482,15 @@ handlePasswordRequest_( switch (aInfo.GetResult()) { case ERRCODE_BUTTON_OK: + OSL_ENSURE( !bIsPasswordToModify || xPassword2.is(), "PasswordToModify is requested, but there is no Interaction!" ); if (xPassword.is()) { + if (xPassword2.is()) + { + xPassword2->setPasswordToModify( aInfo.GetPasswordToModify() ); + xPassword2->setRecommendReadOnly( aInfo.IsRecommendToOpenReadonly() ); + } + xPassword->setPassword(aInfo.GetPassword()); xPassword->select(); } @@ -593,7 +606,7 @@ UUIInteractionHelper::handlePasswordRequest( nMode = aDocumentMSPasswordRequest2.Mode; aDocumentName = aDocumentMSPasswordRequest2.Name; bMSCryptoMode = true; - bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify; + bIsPasswordToModify = aDocumentMSPasswordRequest2.IsRequestPasswordToModify; bDoHandleRequest = true; } diff --git a/uui/source/loginerr.hxx b/uui/source/loginerr.hxx index 9173122562..1653c773dc 100755 --- a/uui/source/loginerr.hxx +++ b/uui/source/loginerr.hxx @@ -25,143 +25,139 @@ * ************************************************************************/ -#ifndef _LOGINERR_HXX -#define _LOGINERR_HXX +#ifndef m_LOGINERR_HXX +#define m_LOGINERR_HXX #include //========================================================================= -#define LOGINERROR_FLAG_SET_SAVE_PASSWORD 1 -#define LOGINERROR_FLAG_MODIFY_ACCOUNT 2 -#define LOGINERROR_FLAG_MODIFY_USER_NAME 4 -#define LOGINERROR_FLAG_PERSISTENT_PASSWORD 8 -#define LOGINERROR_FLAG_CAN_USE_SYSCREDS 16 -#define LOGINERROR_FLAG_IS_USE_SYSCREDS 32 +#define LOGINERROR_FLAG_SET_SAVE_PASSWORD 1 +#define LOGINERROR_FLAG_MODIFY_ACCOUNT 2 +#define LOGINERROR_FLAG_MODIFY_USER_NAME 4 +#define LOGINERROR_FLAG_PERSISTENT_PASSWORD 8 +#define LOGINERROR_FLAG_CAN_USE_SYSCREDS 16 +#define LOGINERROR_FLAG_IS_USE_SYSCREDS 32 class LoginErrorInfo { private: - String _aTitle; - String _aServer; - String _aAccount; - String _aUserName; - String _aPassword; - String _aPasswordToOpen; - String _aPasswordToModify; - String _aPath; - String _aErrorText; - BYTE _nFlags; - USHORT _nRet; - bool _bRecommendToOpenReadonly; + String m_aTitle; + String m_aServer; + String m_aAccount; + String m_aUserName; + String m_aPassword; + String m_aPasswordToModify; + String m_aPath; + String m_aErrorText; + BYTE m_nFlags; + USHORT m_nRet; + bool m_bRecommendToOpenReadonly; public: LoginErrorInfo() - : _nFlags( LOGINERROR_FLAG_MODIFY_USER_NAME ), - _nRet( ERRCODE_BUTTON_CANCEL ) + : m_nFlags( LOGINERROR_FLAG_MODIFY_USER_NAME ), + m_nRet( ERRCODE_BUTTON_CANCEL ) { } - const String& GetTitle() const { return _aTitle; } - const String& GetServer() const { return _aServer; } - const String& GetAccount() const { return _aAccount; } - const String& GetUserName() const { return _aUserName; } - const String& GetPassword() const { return _aPassword; } - const String& GetPasswordToOpen() const { return _aPasswordToOpen; } - const String& GetPasswordToModify() const { return _aPasswordToModify; } - const bool IsRecommendToOpenReadonly() const { return _bRecommendToOpenReadonly; } - const String& GetPath() const { return _aPath; } - const String& GetErrorText() const { return _aErrorText; } - BOOL GetIsPersistentPassword() const - { return ( _nFlags & LOGINERROR_FLAG_PERSISTENT_PASSWORD ); } - BOOL GetIsSavePassword() const - { return ( _nFlags & LOGINERROR_FLAG_SET_SAVE_PASSWORD ); } + const String& GetTitle() const { return m_aTitle; } + const String& GetServer() const { return m_aServer; } + const String& GetAccount() const { return m_aAccount; } + const String& GetUserName() const { return m_aUserName; } + const String& GetPassword() const { return m_aPassword; } + const String& GetPasswordToModify() const { return m_aPasswordToModify; } + const bool IsRecommendToOpenReadonly() const { return m_bRecommendToOpenReadonly; } + const String& GetPath() const { return m_aPath; } + const String& GetErrorText() const { return m_aErrorText; } + BOOL GetIsPersistentPassword() const + { return ( m_nFlags & LOGINERROR_FLAG_PERSISTENT_PASSWORD ); } + BOOL GetIsSavePassword() const + { return ( m_nFlags & LOGINERROR_FLAG_SET_SAVE_PASSWORD ); } BOOL GetCanUseSystemCredentials() const - { return ( _nFlags & LOGINERROR_FLAG_CAN_USE_SYSCREDS ); } + { return ( m_nFlags & LOGINERROR_FLAG_CAN_USE_SYSCREDS ); } BOOL GetIsUseSystemCredentials() const - { return ( _nFlags & LOGINERROR_FLAG_IS_USE_SYSCREDS ) == + { return ( m_nFlags & LOGINERROR_FLAG_IS_USE_SYSCREDS ) == LOGINERROR_FLAG_IS_USE_SYSCREDS; } - BYTE GetFlags() const { return _nFlags; } - USHORT GetResult() const { return _nRet; } + BYTE GetFlags() const { return m_nFlags; } + USHORT GetResult() const { return m_nRet; } - void SetTitle( const String& aTitle ) - { _aTitle = aTitle; } - void SetServer( const String& aServer ) - { _aServer = aServer; } - void SetAccount( const String& aAccount ) - { _aAccount = aAccount; } - void SetUserName( const String& aUserName ) - { _aUserName = aUserName; } + void SetTitle( const String& aTitle ) + { m_aTitle = aTitle; } + void SetServer( const String& aServer ) + { m_aServer = aServer; } + void SetAccount( const String& aAccount ) + { m_aAccount = aAccount; } + void SetUserName( const String& aUserName ) + { m_aUserName = aUserName; } void SetPassword( const String& aPassword ) - { _aPassword = aPassword; } - void SetPasswordToOpen( const String& aPassword ) - { _aPasswordToOpen = aPassword; } + { m_aPassword = aPassword; } void SetPasswordToModify( const String& aPassword ) - { _aPasswordToModify = aPassword; } + { m_aPasswordToModify = aPassword; } void SetRecommendToOpenReadonly( bool bVal ) - { _bRecommendToOpenReadonly = bVal; } - void SetPath( const String& aPath ) - { _aPath = aPath; } - void SetErrorText( const String& aErrorText ) - { _aErrorText = aErrorText; } + { m_bRecommendToOpenReadonly = bVal; } + void SetPath( const String& aPath ) + { m_aPath = aPath; } + void SetErrorText( const String& aErrorText ) + { m_aErrorText = aErrorText; } void SetFlags( BYTE nFlags ) - { _nFlags = nFlags; } - inline void SetSavePassword( BOOL bSet ); - inline void SetPersistentPassword( BOOL bSet ); + { m_nFlags = nFlags; } + inline void SetSavePassword( BOOL bSet ); + inline void SetPersistentPassword( BOOL bSet ); inline void SetCanUseSystemCredentials( BOOL bSet ); inline void SetIsUseSystemCredentials( BOOL bSet ); - inline void SetModifyAccount( BOOL bSet ); - inline void SetModifyUserName( BOOL bSet ); + inline void SetModifyAccount( BOOL bSet ); + inline void SetModifyUserName( BOOL bSet ); void SetResult( USHORT nRet ) - { _nRet = nRet; } + { m_nRet = nRet; } }; -inline void LoginErrorInfo::SetSavePassword( BOOL bSet ) +inline void LoginErrorInfo::SetSavePassword( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_SET_SAVE_PASSWORD; + m_nFlags |= LOGINERROR_FLAG_SET_SAVE_PASSWORD; else - _nFlags &= ~LOGINERROR_FLAG_SET_SAVE_PASSWORD; + m_nFlags &= ~LOGINERROR_FLAG_SET_SAVE_PASSWORD; } -inline void LoginErrorInfo::SetPersistentPassword( BOOL bSet ) +inline void LoginErrorInfo::SetPersistentPassword( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_PERSISTENT_PASSWORD; + m_nFlags |= LOGINERROR_FLAG_PERSISTENT_PASSWORD; else - _nFlags &= ~LOGINERROR_FLAG_PERSISTENT_PASSWORD; + m_nFlags &= ~LOGINERROR_FLAG_PERSISTENT_PASSWORD; } -inline void LoginErrorInfo::SetCanUseSystemCredentials( BOOL bSet ) +inline void LoginErrorInfo::SetCanUseSystemCredentials( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_CAN_USE_SYSCREDS; + m_nFlags |= LOGINERROR_FLAG_CAN_USE_SYSCREDS; else - _nFlags &= ~LOGINERROR_FLAG_CAN_USE_SYSCREDS; + m_nFlags &= ~LOGINERROR_FLAG_CAN_USE_SYSCREDS; } -inline void LoginErrorInfo::SetIsUseSystemCredentials( BOOL bSet ) +inline void LoginErrorInfo::SetIsUseSystemCredentials( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_IS_USE_SYSCREDS; + m_nFlags |= LOGINERROR_FLAG_IS_USE_SYSCREDS; else - _nFlags &= ~LOGINERROR_FLAG_IS_USE_SYSCREDS; + m_nFlags &= ~LOGINERROR_FLAG_IS_USE_SYSCREDS; } inline void LoginErrorInfo::SetModifyAccount( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_MODIFY_ACCOUNT; + m_nFlags |= LOGINERROR_FLAG_MODIFY_ACCOUNT; else - _nFlags &= ~LOGINERROR_FLAG_MODIFY_ACCOUNT; + m_nFlags &= ~LOGINERROR_FLAG_MODIFY_ACCOUNT; } inline void LoginErrorInfo::SetModifyUserName( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_MODIFY_USER_NAME; + m_nFlags |= LOGINERROR_FLAG_MODIFY_USER_NAME; else - _nFlags &= ~LOGINERROR_FLAG_MODIFY_USER_NAME; + m_nFlags &= ~LOGINERROR_FLAG_MODIFY_USER_NAME; } #endif -- cgit v1.2.3 From 23a5e6bff70891250a1a208f6f2461daeaa19881 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 28 Apr 2010 16:47:08 +0200 Subject: cws tl79: include fixed --- sfx2/inc/sfx2/securitypage.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/securitypage.hxx b/sfx2/inc/sfx2/securitypage.hxx index 431b566d79..c8117d1fa8 100755 --- a/sfx2/inc/sfx2/securitypage.hxx +++ b/sfx2/inc/sfx2/securitypage.hxx @@ -27,7 +27,7 @@ #ifndef _SECURITYPAGE_HXX_ #define _SECURITYPAGE_HXX_ -#include "sfx2/tabdlg.hxx " +#include "sfx2/tabdlg.hxx" #include -- cgit v1.2.3 From b8d165095d823afb3c751512c74e043e7ef37963 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 29 Apr 2010 13:02:24 +0200 Subject: cws tl79: fixed problems after merging with DEV300_m77 --- sfx2/inc/sfx2/htmlmode.hxx | 68 +++++++++++++++++++++++++++++++++++++ sfx2/inc/sfx2/securitypage.hxx | 1 + sfx2/inc/sfx2/sfxsids.hrc | 26 ++++++++++++++ sfx2/source/dialog/dinfdlg.cxx | 1 + sfx2/source/dialog/securitypage.cxx | 15 ++++---- svx/inc/htmlmode.hxx | 23 +------------ svx/inc/svx/svxids.hrc | 43 ++++++++++++----------- 7 files changed, 129 insertions(+), 48 deletions(-) create mode 100644 sfx2/inc/sfx2/htmlmode.hxx (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/htmlmode.hxx b/sfx2/inc/sfx2/htmlmode.hxx new file mode 100644 index 0000000000..f02de328db --- /dev/null +++ b/sfx2/inc/sfx2/htmlmode.hxx @@ -0,0 +1,68 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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 + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SFX_HTMLMODE_HXX_ +#define _SFX_HTMLMODE_HXX_ + + +#define HTMLMODE_ON 0x0001 +#define HTMLMODE_PARA_BORDER 0x0002 /* Absatzumrandungen */ +#define HTMLMODE_PARA_DISTANCE 0x0004 /* bestimmte Absatzabstaende */ +#define HTMLMODE_SMALL_CAPS 0x0008 /* Kapitaelchen */ +#define HTMLMODE_FRM_COLUMNS 0x0010 /* spaltige Rahmen */ +#define HTMLMODE_SOME_STYLES 0x0020 /* mind. MS IE */ +#define HTMLMODE_FULL_STYLES 0x0040 /* == SW */ +#define HTMLMODE_BLINK 0x0080 /* blinkende Zeichen*/ +#define HTMLMODE_PARA_BLOCK 0x0100 /* Blocksatz */ +#define HTMLMODE_DROPCAPS 0x0200 /* Initialen*/ +#define HTMLMODE_FIRSTLINE 0x0400 /* Erstzeileneinzug mit Spacer == NS 3.0 */ +#define HTMLMODE_GRAPH_POS 0x0800 /* Grafikpositionen Hintergrund */ +#define HTMLMODE_FULL_ABS_POS 0x1000 /* abs. Rahmenpositionierung */ +#define HTMLMODE_SOME_ABS_POS 0x2000 /* abs. Rahmenpositionierung vollst.*/ +#define HTMLMODE_RESERVED1 0x4000 +#define HTMLMODE_RESERVED0 0x8000 + + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/sfx2/inc/sfx2/securitypage.hxx b/sfx2/inc/sfx2/securitypage.hxx index c8117d1fa8..ade48ac8f4 100755 --- a/sfx2/inc/sfx2/securitypage.hxx +++ b/sfx2/inc/sfx2/securitypage.hxx @@ -28,6 +28,7 @@ #define _SECURITYPAGE_HXX_ #include "sfx2/tabdlg.hxx" +#include "sfx2/htmlmode.hxx" #include diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index 3d6f742a81..b2a0a5fcaf 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -155,6 +155,7 @@ #define SID_RELOAD (SID_SFX_START + 508) #define SID_PRINTDOCDIRECT (SID_SFX_START + 509) #define SID_PICKLIST (SID_SFX_START + 510) +#define SID_ATTR_XWINDOW (SID_SFX_START + 777) #define SID_PLUGIN_MODE (SID_SFX_START + 827) #define SID_EXPORTDOC (SID_SFX_START + 829) #define SID_EXPORTDOCASPDF (SID_SFX_START + 1673) @@ -998,5 +999,30 @@ #endif // #ifndef _SFXSIDS_HRC +//----------------------------------------------------------------------- +// SfxSecurityPage related stuff + +#define FN_EDIT2 (SID_SW_START + 1800) +#define FN_REDLINE_PROTECT (FN_EDIT2 + 23) +#define FN_REDLINE_ON (FN_EDIT2 + 25) + +#define SID_HTML_MODE (SID_SVX_START + 414) + +// Calc-Id's used for SfxSecurityPage +#ifndef SC_FUNCTION_START +#define SC_FUNCTION_START (SID_SC_START + 200) +#endif +#ifndef FILE_MENU_END +#define FILE_MENU_END (SC_FUNCTION_START + 20) +#endif +#ifndef EDIT_MENU_START +#define EDIT_MENU_START (FILE_MENU_END) +#endif +#ifndef SC_VIEW_START +#define SC_VIEW_START (SID_SC_START) +#endif +#define FID_CHG_RECORD (EDIT_MENU_START + 18) +#define SID_CHG_PROTECT (SC_VIEW_START + 84) + // eof ------------------------------------------------------------------------ diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 65f3364de9..30df811513 100755 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sfx2.hxx" + #include #include #include diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index 8c2e042b4b..0d66ffd841 100755 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -29,22 +29,23 @@ #include "precompiled_sfx2.hxx" #include "sfx2/securitypage.hxx" -#include "sfx2/sfx.hrc" + #include "securitypage.hrc" #include "sfxresid.hxx" +#include +#include +#include +#include +#include + #include #include #include #include -#include -#include -#include #include -#include -#include #include -#include +#include diff --git a/svx/inc/htmlmode.hxx b/svx/inc/htmlmode.hxx index 41440388c6..a701d03d39 100644 --- a/svx/inc/htmlmode.hxx +++ b/svx/inc/htmlmode.hxx @@ -27,28 +27,7 @@ #ifndef _SVX_HTMLMODE_HXX #define _SVX_HTMLMODE_HXX -// include --------------------------------------------------------------- - -// define ---------------------------------------------------------------- - -#define HTMLMODE_ON 0x0001 -#define HTMLMODE_PARA_BORDER 0x0002 /* Absatzumrandungen */ -#define HTMLMODE_PARA_DISTANCE 0x0004 /* bestimmte Absatzabstaende */ -#define HTMLMODE_SMALL_CAPS 0x0008 /* Kapitaelchen */ -#define HTMLMODE_FRM_COLUMNS 0x0010 /* spaltige Rahmen */ -#define HTMLMODE_SOME_STYLES 0x0020 /* mind. MS IE */ -#define HTMLMODE_FULL_STYLES 0x0040 /* == SW */ -#define HTMLMODE_BLINK 0x0080 /* blinkende Zeichen*/ -#define HTMLMODE_PARA_BLOCK 0x0100 /* Blocksatz */ -#define HTMLMODE_DROPCAPS 0x0200 /* Initialen*/ -#define HTMLMODE_FIRSTLINE 0x0400 /* Erstzeileneinzug mit Spacer == NS 3.0 */ -#define HTMLMODE_GRAPH_POS 0x0800 /* Grafikpositionen Hintergrund */ -#define HTMLMODE_FULL_ABS_POS 0x1000 /* abs. Rahmenpositionierung */ -#define HTMLMODE_SOME_ABS_POS 0x2000 /* abs. Rahmenpositionierung vollst.*/ -#define HTMLMODE_RESERVED1 0x4000 -#define HTMLMODE_RESERVED0 0x8000 - - +#include #endif diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc index 560c7409bb..753aef477d 100755 --- a/svx/inc/svx/svxids.hrc +++ b/svx/inc/svx/svxids.hrc @@ -182,7 +182,6 @@ #define RID_OFA_TP_INTERNATIONAL_IMPR (RID_OFA_START + 254) // 4 impress */ -#define SID_ATTR_XWINDOW (RID_OFA_START + 250) #define SID_ATTR_PARENTWINDOW (RID_OFA_START + 255) // -------------------------------------------------------------------------- @@ -343,18 +342,19 @@ // Calc-Id's // -------------------------------------------------------------------------- -#ifndef SC_FUNCTION_START -#define SC_FUNCTION_START (SID_SC_START + 200) -#endif -#ifndef FILE_MENU_END -#define FILE_MENU_END (SC_FUNCTION_START + 20) -#endif -#ifndef EDIT_MENU_START -#define EDIT_MENU_START (FILE_MENU_END) -#endif -#ifndef SC_VIEW_START -#define SC_VIEW_START (SID_SC_START) -#endif +//! moved to sfx2, still in use: +//#ifndef SC_FUNCTION_START +//#define SC_FUNCTION_START (SID_SC_START + 200) +//#endif +//#ifndef FILE_MENU_END +//#define FILE_MENU_END (SC_FUNCTION_START + 20) +//#endif +//#ifndef EDIT_MENU_START +//#define EDIT_MENU_START (FILE_MENU_END) +//#endif +//#ifndef SC_VIEW_START +//#define SC_VIEW_START (SID_SC_START) +//#endif #define SID_OUTLINE_HIDE (SID_SC_START + 329) #define SID_OUTLINE_SHOW (SID_SC_START + 330) @@ -366,8 +366,9 @@ #define SID_ATTR_SECIALCHAR (SID_SC_START + 581) #define SID_ATTR_SPECIALCHAR (SID_SC_START + 581) -#define FID_CHG_RECORD (EDIT_MENU_START + 18) -#define SID_CHG_PROTECT (SC_VIEW_START + 84) +//! moved to sfx2, still in use: +//#define FID_CHG_RECORD (EDIT_MENU_START + 18) +//#define SID_CHG_PROTECT (SC_VIEW_START + 84) // -------------------------------------------------------------------------- // Writer-Id's @@ -402,9 +403,10 @@ #define FN_PGPREVIEW (SID_SW_START + 1250) #define FN_SHOW_MULTIPLE_PAGES (FN_PGPREVIEW + 2) -#define FN_EDIT2 (SID_SW_START + 1800) -#define FN_REDLINE_PROTECT (FN_EDIT2 + 23) -#define FN_REDLINE_ON (FN_EDIT2 + 25) +//! moved to sfx2, still in use: +//#define FN_EDIT2 (SID_SW_START + 1800) +//#define FN_REDLINE_PROTECT (FN_EDIT2 + 23) +//#define FN_REDLINE_ON (FN_EDIT2 + 25) // -------------------------------------------------------------------------- // Svx-Id's @@ -748,7 +750,10 @@ #define SID_ATTR_3D_AMBIENTINTENSITY ( SID_SVX_START + 410 ) /* --> Slots mit --> koennen demnaechst entfallen ( heute 12.03.1998 ) */ #define SID_ATTR_3D_AMBIENTCOLOR ( SID_SVX_START + 411 ) #define SID_IMPORT_GRAPH_LINK ( SID_SVX_START + 412 ) -#define SID_HTML_MODE ( SID_SVX_START + 414 ) + +//! moved to sfx2, still in use: +//#define SID_HTML_MODE ( SID_SVX_START + 414 ) + #define SID_RULER_PROTECT ( SID_SVX_START + 415 ) //#define SID_INET_DLG ( SID_SVX_START + 416 ) -> sfxsids.hrc #define SID_COLOR_CONTROL ( SID_SVX_START + 417 ) -- cgit v1.2.3 From e017544b280a27329028edee7b05f9bc56663338 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Wed, 12 May 2010 08:38:13 +0200 Subject: CWS mba33issues01: #i105239#: safe way to access SfxApplication in IMEStatusWindow --- sfx2/inc/sfx2/app.hxx | 2 +- sfx2/source/appl/appdata.cxx | 5 ++--- sfx2/source/appl/imestatuswindow.cxx | 6 +++--- sfx2/source/appl/imestatuswindow.hxx | 7 +------ sfx2/source/bastyp/progress.cxx | 2 +- sfx2/source/control/unoctitm.cxx | 2 +- sfx2/source/view/viewfrm.cxx | 2 +- 7 files changed, 10 insertions(+), 16 deletions(-) (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/app.hxx b/sfx2/inc/sfx2/app.hxx index 18c3735d1c..3e11e34256 100644 --- a/sfx2/inc/sfx2/app.hxx +++ b/sfx2/inc/sfx2/app.hxx @@ -258,7 +258,7 @@ public: void ResetLastDir(); //#if 0 // _SOLAR__PRIVATE - SAL_DLLPRIVATE static SfxApplication* Is_Impl() { return pApp;} + SAL_DLLPRIVATE static SfxApplication* Get() { return pApp;} SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl(); SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl(); diff --git a/sfx2/source/appl/appdata.cxx b/sfx2/source/appl/appdata.cxx index 7936110356..148f44cc1c 100644 --- a/sfx2/source/appl/appdata.cxx +++ b/sfx2/source/appl/appdata.cxx @@ -89,7 +89,7 @@ void SfxBasicManagerCreationListener::onBasicManagerCreated( const Reference< XM m_rAppData.OnApplicationBasicManagerCreated( _rBasicManager ); } -SfxAppData_Impl::SfxAppData_Impl( SfxApplication* pApp ) : +SfxAppData_Impl::SfxAppData_Impl( SfxApplication* ) : pDdeService( 0 ), pDocTopics( 0 ), pTriggerTopic(0), @@ -116,8 +116,7 @@ SfxAppData_Impl::SfxAppData_Impl( SfxApplication* pApp ) : nRescheduleLocks(0), nInReschedule(0), nAsynchronCalls(0), - m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow( - *pApp, comphelper::getProcessServiceFactory())) + m_xImeStatusWindow(new sfx2::appl::ImeStatusWindow(comphelper::getProcessServiceFactory())) , pTbxCtrlFac(0) , pStbCtrlFac(0) , pViewFrames(0) diff --git a/sfx2/source/appl/imestatuswindow.cxx b/sfx2/source/appl/imestatuswindow.cxx index 2885f60bb9..53639a65df 100644 --- a/sfx2/source/appl/imestatuswindow.cxx +++ b/sfx2/source/appl/imestatuswindow.cxx @@ -57,10 +57,8 @@ namespace css = com::sun::star; using sfx2::appl::ImeStatusWindow; ImeStatusWindow::ImeStatusWindow( - SfxApplication & rApplication, css::uno::Reference< css::lang::XMultiServiceFactory > const & rServiceFactory): - m_rApplication(rApplication), m_xServiceFactory(rServiceFactory), m_bDisposed(false) {} @@ -161,7 +159,9 @@ ImeStatusWindow::propertyChange(css::beans::PropertyChangeEvent const & ) throw (css::uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - m_rApplication.Invalidate(SID_SHOW_IME_STATUS_WINDOW); + SfxApplication* pApp = SfxApplication::Get(); + if (pApp) + pApp->Invalidate(SID_SHOW_IME_STATUS_WINDOW); } css::uno::Reference< css::beans::XPropertySet > ImeStatusWindow::getConfig() diff --git a/sfx2/source/appl/imestatuswindow.hxx b/sfx2/source/appl/imestatuswindow.hxx index cbfe2c4748..2d310c60c7 100644 --- a/sfx2/source/appl/imestatuswindow.hxx +++ b/sfx2/source/appl/imestatuswindow.hxx @@ -37,7 +37,6 @@ namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } namespace lang { class XMultiServiceFactory; } } } } -class SfxApplication; namespace sfx2 { namespace appl { @@ -56,10 +55,7 @@ ImeStatusWindow_Impl; class ImeStatusWindow: private ImeStatusWindow_Impl { public: - ImeStatusWindow(SfxApplication & rApplication, - com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > const & - rServiceFactory); + ImeStatusWindow( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > const& rServiceFactory ); /** Set up VCL according to the configuration. @@ -115,7 +111,6 @@ private: com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > getConfig(); - SfxApplication & m_rApplication; com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory; diff --git a/sfx2/source/bastyp/progress.cxx b/sfx2/source/bastyp/progress.cxx index 9fd7a95a3c..1e3f5dde97 100644 --- a/sfx2/source/bastyp/progress.cxx +++ b/sfx2/source/bastyp/progress.cxx @@ -706,7 +706,7 @@ SfxProgress* SfxProgress::GetActiveProgress */ { - if ( !SfxApplication::Is_Impl() ) + if ( !SfxApplication::Get() ) return 0; SfxProgress *pProgress = 0; diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 8159fc8430..14b3fe06e9 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -823,7 +823,7 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const ::com::sun::star::util pItem = pDispatcher->Execute( GetId(), nCall, 0, &aInternalSet, nModifier ); // no bindings, no invalidate ( usually done in SfxDispatcher::Call_Impl()! ) - if ( SfxApplication::Is_Impl() ) + if ( SfxApplication::Get() ) { SfxDispatcher* pAppDispat = SFX_APP()->GetAppDispatcher_Impl(); if ( pAppDispat ) diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 8eb2fcfa4f..013b594970 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1510,7 +1510,7 @@ void SfxViewFrame::KillDispatcher_Impl() //------------------------------------------------------------------------ SfxViewFrame* SfxViewFrame::Current() { - return SfxApplication::Is_Impl() ? SFX_APP()->Get_Impl()->pViewFrame : NULL; + return SfxApplication::Get() ? SFX_APP()->Get_Impl()->pViewFrame : NULL; } //-------------------------------------------------------------------- -- cgit v1.2.3 From 900415b37ce9f68eb9cd4be4bb655cbd1797f874 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 19 May 2010 14:28:33 +0200 Subject: cws tl79: #i110254# new security tap page in 'File/Properties' --- desktop/source/migration/migration.cxx | 1 + sfx2/inc/sfx2/objsh.hxx | 7 + sfx2/inc/sfx2/sfx.hrc | 2 + sfx2/sdi/sfx.sdi | 2 +- sfx2/source/dialog/securitypage.cxx | 324 ++++++++++++++++++++++----------- sfx2/source/dialog/securitypage.hrc | 6 +- sfx2/source/dialog/securitypage.src | 19 +- sfx2/source/doc/objxtor.cxx | 24 +++ 8 files changed, 264 insertions(+), 121 deletions(-) mode change 100644 => 100755 desktop/source/migration/migration.cxx mode change 100644 => 100755 sfx2/inc/sfx2/objsh.hxx mode change 100644 => 100755 sfx2/sdi/sfx.sdi mode change 100644 => 100755 sfx2/source/doc/objxtor.cxx (limited to 'sfx2/inc/sfx2') diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx old mode 100644 new mode 100755 index ede233edd2..80f9b53681 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -232,6 +232,7 @@ static void insertSorted(migrations_available& rAvailableMigrations, supported_m { rAvailableMigrations.insert(pIter, aSupportedMigration ); bInserted = true; + break; } ++pIter; } diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx old mode 100644 new mode 100755 index 97196ad3c4..1447c7fe58 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -683,6 +683,13 @@ public: sal_Int32 nVersion, sal_Bool bTemplate = sal_False) const = 0; + // change recording and respective passwword protection for Writer and Calc + // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON + // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT + virtual void SetChangeRecording( bool bActivate ); + virtual bool SetProtectionPassword( const String &rPassword ); + virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ); + // ================================= //#if 0 // _SOLAR__PRIVATE diff --git a/sfx2/inc/sfx2/sfx.hrc b/sfx2/inc/sfx2/sfx.hrc index 8407ecaf44..5c7e370619 100755 --- a/sfx2/inc/sfx2/sfx.hrc +++ b/sfx2/inc/sfx2/sfx.hrc @@ -234,6 +234,8 @@ #define TP_MANAGE_STYLES (RID_SFX_START+7) #define DLG_STYLE_DESIGNER (RID_SFX_START+8) +#define RID_SFX_INCORRECT_PASSWORD (RID_SFX_START+216) + #define STR_STYLE_FILTER_AUTO (RID_SFX_START+9) #define STR_STYLE_FILTER_USED (RID_SFX_START+10) #define STR_STYLE_FILTER_USERDEF (RID_SFX_START+11) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi old mode 100644 new mode 100755 index 7bc57471c9..e20e97865c --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -31,7 +31,7 @@ SfxBoolItem _SwitchViewShell0 SID_VIEWSHELL0 [ /* flags: */ AutoUpdate = FALSE, - Cachable = Cachable, + Cachable = Cachable,  FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index 0d66ffd841..af19f4a9e4 100755 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -38,64 +38,70 @@ #include #include #include +#include #include #include #include +#include #include #include #include +#include #include +using namespace ::com::sun::star; ////////////////////////////////////////////////////////////////////// -namespace +static short lcl_GetPassword( Window *pParent, bool bShowConfirm, /*out*/String &rPassword ) { - enum RedliningMode { RL_NONE, RL_WRITER, RL_CALC }; + bool bRes = false; + SfxPasswordDialog aPasswdDlg( pParent ); + if (bShowConfirm) + aPasswdDlg.ShowExtras( SHOWEXTRAS_CONFIRM ); + if (RET_OK == aPasswdDlg.Execute() && aPasswdDlg.GetPassword().Len() > 0) + { + rPassword = aPasswdDlg.GetPassword(); + bRes = true; + } + return bRes; +} - enum RedlineFunc { RF_ON, RF_PROTECT }; - const SfxBoolItem* ExecuteRecordChangesFunc( RedliningMode _eMode, RedlineFunc _eFunc, BOOL _bVal, Window* _pParent = NULL ) - { - const SfxBoolItem* pRet = NULL; +static bool lcl_IsPasswordCorrect( const String &rPassword ) +{ + bool bRes = false; - if (_eMode != RL_NONE) - { - USHORT nSlot; - if (_eMode == RL_WRITER) - nSlot = _eFunc == RF_ON ? FN_REDLINE_ON : FN_REDLINE_PROTECT; - else - nSlot = _eFunc == RF_ON ? FID_CHG_RECORD : SID_CHG_PROTECT; + SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); + uno::Sequence< sal_Int8 > aPasswordHash; + bool bHasPassword = pCurDocShell->GetProtectionHash( aPasswordHash ); + + // check if supplied password was correct + uno::Sequence< sal_Int8 > aNewPasswd( aPasswordHash ); + SvPasswordHelper::GetHashPassword( aNewPasswd, rPassword ); + if (SvPasswordHelper::CompareHashPassword( aPasswordHash, rPassword )) + bRes = true; // password was correct + else + InfoBox( NULL, String( SfxResId( RID_SFX_INCORRECT_PASSWORD ) ) ).Execute(); - // execute - SfxViewShell* pViewSh = SfxViewShell::Current(); - if (pViewSh) - { - bool bNeedItem = _eMode == RL_WRITER || _eFunc != RF_ON; - SfxBoolItem* pItem = bNeedItem ? new SfxBoolItem( nSlot, _bVal ) : NULL; - SfxDispatcher* pDisp = pViewSh->GetDispatcher(); - if (_pParent) - { - XWindowItem aParentItem( SID_ATTR_XWINDOW, _pParent ); - pRet = static_cast< const SfxBoolItem* >( - pDisp->Execute( nSlot, SFX_CALLMODE_SYNCHRON, &aParentItem, pItem, 0L ) ); - } - else - pRet = static_cast< const SfxBoolItem* >( - pDisp->Execute( nSlot, SFX_CALLMODE_SYNCHRON, pItem, 0L ) ); - delete pItem; - } - } + return bRes; +} + + +////////////////////////////////////////////////////////////////////// + + +namespace +{ + enum RedliningMode { RL_NONE, RL_WRITER, RL_CALC }; + enum RedlineFunc { RF_ON, RF_PROTECT }; - return pRet; - } bool QueryState( USHORT _nSlot, bool& _rValue ) { bool bRet = false; - SfxViewShell* pViewSh = SfxViewShell::Current(); if (pViewSh) { @@ -105,33 +111,30 @@ namespace if (bRet) _rValue = ( static_cast< const SfxBoolItem* >( pItem ) )->GetValue(); } - return bRet; } + bool QueryRecordChangesProtectionState( RedliningMode _eMode, bool& _rValue ) { bool bRet = false; - if (_eMode != RL_NONE) { USHORT nSlot = _eMode == RL_WRITER ? FN_REDLINE_PROTECT : SID_CHG_PROTECT; bRet = QueryState( nSlot, _rValue ); } - return bRet; } + bool QueryRecordChangesState( RedliningMode _eMode, bool& _rValue ) { bool bRet = false; - if (_eMode != RL_NONE) { USHORT nSlot = _eMode == RL_WRITER ? FN_REDLINE_ON : FID_CHG_RECORD; bRet = QueryState( nSlot, _rValue ); } - return bRet; } } @@ -142,64 +145,71 @@ namespace struct SfxSecurityPage_Impl { - SfxSecurityPage & m_rDialog; + SfxSecurityPage & m_rMyTabPage; - FixedLine m_aPasswordToOpenFL; - FixedText m_aPasswordToOpenFT; - Edit m_aPasswordToOpenED; + FixedLine m_aNewPasswordToOpenFL; + FixedText m_aNewPasswordToOpenFT; + Edit m_aNewPasswordToOpenED; FixedText m_aConfirmPasswordToOpenFT; Edit m_aConfirmPasswordToOpenED; - FixedText m_aPasswordInfoFT; + FixedText m_aNewPasswordInfoFT; - FixedLine m_aPasswordToModifyFL; - FixedText m_aPasswordToModifyFT; - Edit m_aPasswordToModifyED; + FixedLine m_aNewPasswordToModifyFL; + FixedText m_aNewPasswordToModifyFT; + Edit m_aNewPasswordToModifyED; FixedText m_aConfirmPasswordToModifyFT; Edit m_aConfirmPasswordToModifyED; FixedLine m_aOptionsFL; CheckBox m_aOpenReadonlyCB; - CheckBox m_aRemoveInfoOnSavingCB; CheckBox m_aRecordChangesCB; // for record changes PushButton m_aChangeProtectionPB; // for record changes String m_aProtectSTR; // for record changes String m_aUnProtectSTR; // for record changes RedliningMode m_eRedlingMode; // for record changes + bool m_bOrigPasswordIsConfirmed; + bool m_bNewPasswordIsValid; + String m_aNewPassword; + + String m_aEndRedliningWarning; + bool m_bEndRedliningWarningDone; + DECL_LINK( RecordChangesCBHdl, void* ); DECL_LINK( ChangeProtectionPBHdl, void* ); SfxSecurityPage_Impl( SfxSecurityPage &rDlg, const SfxItemSet &rItemSet ); ~SfxSecurityPage_Impl(); - void CheckRecordChangesState( void ); - BOOL FillItemSet_Impl( SfxItemSet & ); void Reset_Impl( const SfxItemSet & ); }; -SfxSecurityPage_Impl::SfxSecurityPage_Impl( SfxSecurityPage &rDlg, const SfxItemSet & ) : - m_rDialog (rDlg), - m_aPasswordToOpenFL (&rDlg, SfxResId( PASSWORD_TO_OPEN_FL ) ), - m_aPasswordToOpenFT (&rDlg, SfxResId( PASSWORD_TO_OPEN_FT ) ), - m_aPasswordToOpenED (&rDlg, SfxResId( PASSWORD_TO_OPEN_ED ) ), - m_aConfirmPasswordToOpenFT (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_OPEN_FT ) ), - m_aConfirmPasswordToOpenED (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_OPEN_ED ) ), - m_aPasswordInfoFT (&rDlg, SfxResId( PASSWORD_INFO_FT ) ), - m_aPasswordToModifyFL (&rDlg, SfxResId( PASSWORD_TO_MODIFY_FL ) ), - m_aPasswordToModifyFT (&rDlg, SfxResId( PASSWORD_TO_MODIFY_FT ) ), - m_aPasswordToModifyED (&rDlg, SfxResId( PASSWORD_TO_MODIFY_ED ) ), - m_aConfirmPasswordToModifyFT (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_FT ) ), - m_aConfirmPasswordToModifyED (&rDlg, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_ED ) ), - m_aOptionsFL (&rDlg, SfxResId( OPTIONS_FL ) ), - m_aOpenReadonlyCB (&rDlg, SfxResId( OPEN_READONLY_CB ) ), - m_aRemoveInfoOnSavingCB (&rDlg, SfxResId( REMOVE_INFO_ON_SAVING_CB ) ), - m_aRecordChangesCB (&rDlg, SfxResId( RECORD_CHANGES_CB ) ), - m_aChangeProtectionPB (&rDlg, SfxResId( CHANGE_PROTECTION_PB ) ), +SfxSecurityPage_Impl::SfxSecurityPage_Impl( SfxSecurityPage &rTabPage, const SfxItemSet & ) : + m_rMyTabPage (rTabPage), + m_aNewPasswordToOpenFL (&rTabPage, SfxResId( PASSWORD_TO_OPEN_FL ) ), + m_aNewPasswordToOpenFT (&rTabPage, SfxResId( PASSWORD_TO_OPEN_FT ) ), + m_aNewPasswordToOpenED (&rTabPage, SfxResId( PASSWORD_TO_OPEN_ED ) ), + m_aConfirmPasswordToOpenFT (&rTabPage, SfxResId( CONFIRM_PASSWORD_TO_OPEN_FT ) ), + m_aConfirmPasswordToOpenED (&rTabPage, SfxResId( CONFIRM_PASSWORD_TO_OPEN_ED ) ), + m_aNewPasswordInfoFT (&rTabPage, SfxResId( PASSWORD_INFO_FT ) ), + m_aNewPasswordToModifyFL (&rTabPage, SfxResId( PASSWORD_TO_MODIFY_FL ) ), + m_aNewPasswordToModifyFT (&rTabPage, SfxResId( PASSWORD_TO_MODIFY_FT ) ), + m_aNewPasswordToModifyED (&rTabPage, SfxResId( PASSWORD_TO_MODIFY_ED ) ), + m_aConfirmPasswordToModifyFT (&rTabPage, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_FT ) ), + m_aConfirmPasswordToModifyED (&rTabPage, SfxResId( CONFIRM_PASSWORD_TO_MODIFY_ED ) ), + m_aOptionsFL (&rTabPage, SfxResId( OPTIONS_FL ) ), + m_aOpenReadonlyCB (&rTabPage, SfxResId( OPEN_READONLY_CB ) ), + m_aRecordChangesCB (&rTabPage, SfxResId( RECORD_CHANGES_CB ) ), + m_aChangeProtectionPB (&rTabPage, SfxResId( CHANGE_PROTECTION_PB ) ), m_aProtectSTR ( SfxResId( STR_PROTECT ) ), m_aUnProtectSTR ( SfxResId( STR_UNPROTECT ) ), - m_eRedlingMode ( RL_NONE ) + m_eRedlingMode ( RL_NONE ), + m_bOrigPasswordIsConfirmed ( false ), + m_bNewPasswordIsValid ( false ), + m_aEndRedliningWarning ( SfxResId( STR_END_REDLINING_WARNING ) ), + m_bEndRedliningWarningDone ( false ) { m_aChangeProtectionPB.SetText( m_aProtectSTR ); // adjust button width if necessary @@ -216,32 +226,48 @@ SfxSecurityPage_Impl::SfxSecurityPage_Impl( SfxSecurityPage &rDlg, const SfxItem SfxSecurityPage_Impl::~SfxSecurityPage_Impl() { } - - -void SfxSecurityPage_Impl::CheckRecordChangesState( void ) -{ - bool bVal; - if (QueryRecordChangesState( m_eRedlingMode, bVal )) - { - m_aRecordChangesCB.Enable(); - m_aRecordChangesCB.Check( bVal ); - } - else - m_aRecordChangesCB.Disable(); // because now we don't know the state! - - m_aChangeProtectionPB.Enable( QueryRecordChangesProtectionState( m_eRedlingMode, bVal ) ); -} BOOL SfxSecurityPage_Impl::FillItemSet_Impl( SfxItemSet & ) { - BOOL bModified = FALSE; + bool bModified = false; SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); if (pCurDocShell) { + if (m_eRedlingMode != RL_NONE && !pCurDocShell->IsReadOnly()) + { + // change recording + const bool bDoRecordChanges = m_aRecordChangesCB.IsChecked(); + pCurDocShell->SetChangeRecording( bDoRecordChanges ); + + // no change recording should imply no password protection + if (!bDoRecordChanges && (!m_bNewPasswordIsValid || m_aNewPassword.Len() != 0)) + { + // actually this should not be possible. Thus just as 'coded comment': + DBG_ASSERT( 0, "unexpected state of UI" ); + m_bNewPasswordIsValid = true; + m_aNewPassword = String(); + } + + // change record protection + if (m_bNewPasswordIsValid) + { + const bool bDoChangeProtection = m_aChangeProtectionPB.GetText() != m_aProtectSTR; + DBG_ASSERT( !bDoChangeProtection || bDoRecordChanges, + "change protection requires record changes to be active!" ); + pCurDocShell->SetProtectionPassword( m_aNewPassword ); + } + + bModified = true; + } + + // open read-only? if (pCurDocShell->HasSecurityOptOpenReadOnly()) + { pCurDocShell->SetSecurityOptOpenReadOnly( m_aOpenReadonlyCB.IsChecked() ); + bModified = true; + } } return bModified; @@ -251,7 +277,7 @@ BOOL SfxSecurityPage_Impl::FillItemSet_Impl( SfxItemSet & ) void SfxSecurityPage_Impl::Reset_Impl( const SfxItemSet & ) { SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); - + String sNewText = m_aProtectSTR; if (!pCurDocShell) { @@ -284,23 +310,37 @@ void SfxSecurityPage_Impl::Reset_Impl( const SfxItemSet & ) else m_aOpenReadonlyCB.Disable(); - bool bVal; - if (QueryRecordChangesState( RL_WRITER, bVal ) && !bIsHTMLDoc) + bool bRecordChanges; + if (QueryRecordChangesState( RL_WRITER, bRecordChanges ) && !bIsHTMLDoc) m_eRedlingMode = RL_WRITER; - else if (QueryRecordChangesState( RL_CALC, bVal )) + else if (QueryRecordChangesState( RL_CALC, bRecordChanges )) m_eRedlingMode = RL_CALC; else m_eRedlingMode = RL_NONE; if (m_eRedlingMode != RL_NONE) { - m_aRecordChangesCB.Check( bVal ); - m_aRecordChangesCB.Enable( !bVal && !bIsReadonly ); - m_aChangeProtectionPB.Enable( - QueryRecordChangesProtectionState( m_eRedlingMode, bVal ) && !bIsReadonly ); + bool bProtection; + QueryRecordChangesProtectionState( m_eRedlingMode, bProtection ); + + m_aChangeProtectionPB.Enable( !bIsReadonly ); // set the right text - if (bVal) + if (bProtection) sNewText = m_aUnProtectSTR; + + m_aRecordChangesCB.Check( bRecordChanges ); + m_aRecordChangesCB.Enable( /*!bProtection && */!bIsReadonly ); + + DBG_ASSERT( pCurDocShell, "doc shell missing" ); + if (pCurDocShell) + { + m_bOrigPasswordIsConfirmed = true; // default case if no password is set + uno::Sequence< sal_Int8 > aPasswordHash; + // check if password is available + if (pCurDocShell->GetProtectionHash( aPasswordHash ) && + aPasswordHash.getLength() > 0) + m_bOrigPasswordIsConfirmed = false; // password found, needs to be confirmed later on + } } } @@ -310,27 +350,94 @@ void SfxSecurityPage_Impl::Reset_Impl( const SfxItemSet & ) IMPL_LINK( SfxSecurityPage_Impl, RecordChangesCBHdl, void*, EMPTYARG ) { - ExecuteRecordChangesFunc( m_eRedlingMode, RF_ON, m_aRecordChangesCB.IsChecked(), &m_rDialog ); - CheckRecordChangesState(); + // when change recording gets disabled protection must be disabled as well + if (!m_aRecordChangesCB.IsChecked()) // the new check state is already present, thus the '!' + { + bool bAlreadyDone = false; + if (!m_bEndRedliningWarningDone) + { + WarningBox aBox( m_rMyTabPage.GetParent(), WinBits(WB_YES_NO | WB_DEF_NO), + m_aEndRedliningWarning ); + if (aBox.Execute() != RET_YES) + bAlreadyDone = true; + else + m_bEndRedliningWarningDone = true; + } + + const bool bNeedPasssword = !m_bOrigPasswordIsConfirmed + && m_aChangeProtectionPB.GetText() != m_aProtectSTR; + if (!bAlreadyDone && bNeedPasssword) + { + String aPasswordText; + + // dialog canceled or no password provided + if (!lcl_GetPassword( m_rMyTabPage.GetParent(), false, aPasswordText )) + bAlreadyDone = true; + + // ask for password and if dialog is canceled or no password provided return + if (lcl_IsPasswordCorrect( aPasswordText )) + m_bOrigPasswordIsConfirmed = true; + else + bAlreadyDone = true; + } + + if (bAlreadyDone) + m_aRecordChangesCB.Check( true ); // restore original state + else + { + // remember required values to change protection and change recording in + // FillItemSet_Impl later on if password was correct. + m_bNewPasswordIsValid = true; + m_aNewPassword = String(); + + m_aChangeProtectionPB.SetText( m_aProtectSTR ); + } + } + return 0; } IMPL_LINK( SfxSecurityPage_Impl, ChangeProtectionPBHdl, void*, EMPTYARG ) { - bool bProt; - QueryRecordChangesProtectionState( m_eRedlingMode, bProt ); - ExecuteRecordChangesFunc( m_eRedlingMode, RF_PROTECT, !bProt, &m_rDialog ); - CheckRecordChangesState(); + if (m_eRedlingMode == RL_NONE) + return 0; - if (QueryRecordChangesProtectionState( m_eRedlingMode, bProt )) + // the push button text is always the opposite of the current state. Thus: + const bool bCurrentProtection = m_aChangeProtectionPB.GetText() != m_aProtectSTR; + + // ask user for password (if still necessary) + String aPasswordText; + bool bNewProtection = !bCurrentProtection; + const bool bNeedPassword = bNewProtection || !m_bOrigPasswordIsConfirmed; + if (bNeedPassword) { - // RecordChangesCB is enabled if protection is off - m_aRecordChangesCB.Enable( !bProt ); - // toggle text of button "Protect" <-> "Unprotect" - String sNewText = bProt ? m_aUnProtectSTR : m_aProtectSTR; - m_aChangeProtectionPB.SetText( sNewText ); + // ask for password and if dialog is canceled or no password provided return + if (!lcl_GetPassword( m_rMyTabPage.GetParent(), bNewProtection, aPasswordText )) + return 0; + + // provided password still needs to be checked? + if (!bNewProtection && !m_bOrigPasswordIsConfirmed) + { + if (lcl_IsPasswordCorrect( aPasswordText )) + m_bOrigPasswordIsConfirmed = true; + else + return 0; + } } + DBG_ASSERT( m_bOrigPasswordIsConfirmed, "ooops... this should not have happened!" ); + + // remember required values to change protection and change recording in + // FillItemSet_Impl later on if password was correct. + m_bNewPasswordIsValid = true; + m_aNewPassword = bNewProtection? aPasswordText : String(); + +// // RecordChangesCB is enabled if protection is off +// m_aRecordChangesCB.Enable( !bNewProtection ); + m_aRecordChangesCB.Check( bNewProtection ); + // toggle text of button "Protect" <-> "Unprotect" + m_aChangeProtectionPB.SetText( bNewProtection ? m_aUnProtectSTR : m_aProtectSTR ); + return 0; } @@ -375,6 +482,7 @@ void SfxSecurityPage::Reset( const SfxItemSet & rItemSet ) m_pImpl->Reset_Impl( rItemSet ); } - + ////////////////////////////////////////////////////////////////////// + diff --git a/sfx2/source/dialog/securitypage.hrc b/sfx2/source/dialog/securitypage.hrc index 74586a6d4c..4890b8e54a 100755 --- a/sfx2/source/dialog/securitypage.hrc +++ b/sfx2/source/dialog/securitypage.hrc @@ -41,12 +41,12 @@ #define CONFIRM_PASSWORD_TO_MODIFY_ED 11 #define OPTIONS_FL 12 #define OPEN_READONLY_CB 13 -#define REMOVE_INFO_ON_SAVING_CB 14 -#define RECORD_CHANGES_CB 15 -#define CHANGE_PROTECTION_PB 16 +#define RECORD_CHANGES_CB 14 +#define CHANGE_PROTECTION_PB 15 #define STR_PROTECT 101 #define STR_UNPROTECT 102 +#define STR_END_REDLINING_WARNING 103 #endif diff --git a/sfx2/source/dialog/securitypage.src b/sfx2/source/dialog/securitypage.src index bf2b0a18d4..7952bea923 100755 --- a/sfx2/source/dialog/securitypage.src +++ b/sfx2/source/dialog/securitypage.src @@ -125,21 +125,15 @@ TabPage TP_DOCINFOSECURITY Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); Text [ en-US ] = "~Open file read-only"; }; - CheckBox REMOVE_INFO_ON_SAVING_CB - { - Pos = MAP_APPFONT( 12, 147 ); - Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); - Text [ en-US ] = "Remove personal ~information on saving"; - }; CheckBox RECORD_CHANGES_CB { - Pos = MAP_APPFONT( 12, 162 ); + Pos = MAP_APPFONT( 12, 147 ); Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); Text [ en-US ] = "Record ~changes"; }; PushButton CHANGE_PROTECTION_PB { - Pos = MAP_APPFONT( 194, 160 ); + Pos = MAP_APPFONT( 194, 145 ); Size = MAP_APPFONT( 60, RSC_CD_PUSHBUTTON_HEIGHT ); }; String STR_PROTECT @@ -150,7 +144,14 @@ TabPage TP_DOCINFOSECURITY { Text [ en-US ] = "~Unprotect..."; }; - + String STR_END_REDLINING_WARNING + { + Text [ en-US ] = "This action will exit the change recording mode.\nAny information about changes will be lost.\n\nExit change recording mode?\n\n" ; + }; }; +String RID_SFX_INCORRECT_PASSWORD +{ + Text [ en-US ] = "Incorrect password" ; +}; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx old mode 100644 new mode 100755 index 2298b93486..9f30d2f3dd --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -1074,3 +1074,27 @@ void SfxObjectShell::SetInitialized_Impl( const bool i_fromInitNew ) SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(STR_EVENT_LOADFINISHED), this ) ); } } + + +void SfxObjectShell::SetChangeRecording( bool /*bActivate*/ ) +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); +} + + +bool SfxObjectShell::SetProtectionPassword( const String &rPassword ) +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); + return false; +} + + +bool SfxObjectShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > & /*rPasswordHash*/ ) +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); + return false; +} + -- cgit v1.2.3 From 760ca6ad7439194dc9dc2e137e78af248df2c208 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 25 May 2010 11:45:06 +0200 Subject: cws tl79: #i110254# security tab page in 'File/Properties' --- sfx2/inc/sfx2/objsh.hxx | 2 + sfx2/inc/sfx2/sfx.hrc | 4 +- sfx2/source/dialog/securitypage.cxx | 163 ++++++++++++++++++++++-------------- sfx2/source/dialog/securitypage.src | 8 ++ sfx2/source/doc/objxtor.cxx | 16 ++++ 5 files changed, 127 insertions(+), 66 deletions(-) (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 1447c7fe58..f87b540878 100755 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -686,6 +686,8 @@ public: // change recording and respective passwword protection for Writer and Calc // slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON // slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT + virtual bool IsChangeRecording() const; + virtual bool HasChangeRecordProtection() const; virtual void SetChangeRecording( bool bActivate ); virtual bool SetProtectionPassword( const String &rPassword ); virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ); diff --git a/sfx2/inc/sfx2/sfx.hrc b/sfx2/inc/sfx2/sfx.hrc index 5c7e370619..4dc2fc575f 100755 --- a/sfx2/inc/sfx2/sfx.hrc +++ b/sfx2/inc/sfx2/sfx.hrc @@ -234,7 +234,9 @@ #define TP_MANAGE_STYLES (RID_SFX_START+7) #define DLG_STYLE_DESIGNER (RID_SFX_START+8) -#define RID_SFX_INCORRECT_PASSWORD (RID_SFX_START+216) +#define RID_SFX_PROTECT_RECORDS (RID_SFX_START+216) +#define RID_SFX_UNPROTECT_RECORDS (RID_SFX_START+217) +#define RID_SFX_INCORRECT_PASSWORD (RID_SFX_START+218) #define STR_STYLE_FILTER_AUTO (RID_SFX_START+9) #define STR_STYLE_FILTER_USED (RID_SFX_START+10) diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index 59424d0176..bfe7ac5d3d 100755 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -53,43 +53,6 @@ using namespace ::com::sun::star; -////////////////////////////////////////////////////////////////////// - -static short lcl_GetPassword( Window *pParent, bool bShowConfirm, /*out*/String &rPassword ) -{ - bool bRes = false; - SfxPasswordDialog aPasswdDlg( pParent ); - if (bShowConfirm) - aPasswdDlg.ShowExtras( SHOWEXTRAS_CONFIRM ); - if (RET_OK == aPasswdDlg.Execute() && aPasswdDlg.GetPassword().Len() > 0) - { - rPassword = aPasswdDlg.GetPassword(); - bRes = true; - } - return bRes; -} - - -static bool lcl_IsPasswordCorrect( const String &rPassword ) -{ - bool bRes = false; - - SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); - uno::Sequence< sal_Int8 > aPasswordHash; - bool bHasPassword = pCurDocShell->GetProtectionHash( aPasswordHash ); - - // check if supplied password was correct - uno::Sequence< sal_Int8 > aNewPasswd( aPasswordHash ); - SvPasswordHelper::GetHashPassword( aNewPasswd, rPassword ); - if (SvPasswordHelper::CompareHashPassword( aPasswordHash, rPassword )) - bRes = true; // password was correct - else - InfoBox( NULL, String( SfxResId( RID_SFX_INCORRECT_PASSWORD ) ) ).Execute(); - - return bRes; -} - - ////////////////////////////////////////////////////////////////////// @@ -98,6 +61,21 @@ namespace enum RedliningMode { RL_NONE, RL_WRITER, RL_CALC }; enum RedlineFunc { RF_ON, RF_PROTECT }; +/* + bool QueryIsEnabled( USHORT _nSlot ) + { + bool bRes = false; + SfxViewShell* pViewSh = SfxViewShell::Current(); + if (pViewSh) + { + const SfxPoolItem* pItem; + SfxDispatcher* pDisp = pViewSh->GetDispatcher(); + SfxItemState eState = pDisp->QueryState( _nSlot, pItem ); + bRes = (eState & SFX_ITEM_DISABLED) == 0; + } + return bRes; + } +*/ bool QueryState( USHORT _nSlot, bool& _rValue ) { @@ -107,7 +85,8 @@ namespace { const SfxPoolItem* pItem; SfxDispatcher* pDisp = pViewSh->GetDispatcher(); - bRet = SFX_ITEM_AVAILABLE <= pDisp->QueryState( _nSlot, pItem ); + SfxItemState nState = pDisp->QueryState( _nSlot, pItem ); + bRet = SFX_ITEM_AVAILABLE <= nState; if (bRet) _rValue = ( static_cast< const SfxBoolItem* >( pItem ) )->GetValue(); } @@ -143,6 +122,50 @@ namespace ////////////////////////////////////////////////////////////////////// +static short lcl_GetPassword( + Window *pParent, + bool bProtect, + /*out*/String &rPassword ) +{ + bool bRes = false; + SfxPasswordDialog aPasswdDlg( pParent ); + const String aTitle( SfxResId( bProtect ? RID_SFX_PROTECT_RECORDS : RID_SFX_UNPROTECT_RECORDS ) ); + aPasswdDlg.SetText( aTitle ); + aPasswdDlg.SetMinLen( 1 ); + if (bProtect) + aPasswdDlg.ShowExtras( SHOWEXTRAS_CONFIRM ); + if (RET_OK == aPasswdDlg.Execute() && aPasswdDlg.GetPassword().Len() > 0) + { + rPassword = aPasswdDlg.GetPassword(); + bRes = true; + } + return bRes; +} + + +static bool lcl_IsPasswordCorrect( const String &rPassword ) +{ + bool bRes = false; + + SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); + uno::Sequence< sal_Int8 > aPasswordHash; + bool bHasPassword = pCurDocShell->GetProtectionHash( aPasswordHash ); + + // check if supplied password was correct + uno::Sequence< sal_Int8 > aNewPasswd( aPasswordHash ); + SvPasswordHelper::GetHashPassword( aNewPasswd, rPassword ); + if (SvPasswordHelper::CompareHashPassword( aPasswordHash, rPassword )) + bRes = true; // password was correct + else + InfoBox( NULL, String( SfxResId( RID_SFX_INCORRECT_PASSWORD ) ) ).Execute(); + + return bRes; +} + + +////////////////////////////////////////////////////////////////////// + + struct SfxSecurityPage_Impl { SfxSecurityPage & m_rMyTabPage; @@ -235,39 +258,43 @@ BOOL SfxSecurityPage_Impl::FillItemSet_Impl( SfxItemSet & ) bool bModified = false; SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); - if (pCurDocShell) + if (pCurDocShell&& !pCurDocShell->IsReadOnly()) { - if (m_eRedlingMode != RL_NONE && !pCurDocShell->IsReadOnly()) + if (m_eRedlingMode != RL_NONE ) { - // change recording - const bool bDoRecordChanges = m_aRecordChangesCB.IsChecked(); - pCurDocShell->SetChangeRecording( bDoRecordChanges ); + const bool bDoRecordChanges = m_aRecordChangesCB.IsChecked(); + const bool bDoChangeProtection = m_aChangeProtectionPB.GetText() != m_aProtectSTR; - // no change recording should imply no password protection - if (!bDoRecordChanges && (!m_bNewPasswordIsValid || m_aNewPassword.Len() != 0)) + // sanity checks + DBG_ASSERT( bDoRecordChanges || !bDoChangeProtection, "no change recording should imply no change protection" ); + DBG_ASSERT( bDoChangeProtection || !bDoRecordChanges, "no change protection should imply no change recording" ); + DBG_ASSERT( !bDoChangeProtection || m_aNewPassword.Len() > 0, "change protection should imply password length is > 0" ); + DBG_ASSERT( bDoChangeProtection || m_aNewPassword.Len() == 0, "no change protection should imply password length is 0" ); + + // change recording + if (bDoRecordChanges != pCurDocShell->IsChangeRecording()) { - // actually this should not be possible. Thus just as 'coded comment': - DBG_ASSERT( 0, "unexpected state of UI" ); - m_bNewPasswordIsValid = true; - m_aNewPassword = String(); + pCurDocShell->SetChangeRecording( bDoRecordChanges ); + bModified = true; } // change record protection - if (m_bNewPasswordIsValid) + if (m_bNewPasswordIsValid && + bDoChangeProtection != pCurDocShell->HasChangeRecordProtection()) { - const bool bDoChangeProtection = m_aChangeProtectionPB.GetText() != m_aProtectSTR; DBG_ASSERT( !bDoChangeProtection || bDoRecordChanges, "change protection requires record changes to be active!" ); pCurDocShell->SetProtectionPassword( m_aNewPassword ); + bModified = true; } - - bModified = true; } // open read-only? - if (pCurDocShell->HasSecurityOptOpenReadOnly()) + const sal_Bool bDoOpenReadonly = m_aOpenReadonlyCB.IsChecked(); + if (pCurDocShell->HasSecurityOptOpenReadOnly() && + bDoOpenReadonly != pCurDocShell->IsSecurityOptOpenReadOnly()) { - pCurDocShell->SetSecurityOptOpenReadOnly( m_aOpenReadonlyCB.IsChecked() ); + pCurDocShell->SetSecurityOptOpenReadOnly( bDoOpenReadonly ); bModified = true; } } @@ -333,16 +360,22 @@ void SfxSecurityPage_Impl::Reset_Impl( const SfxItemSet & ) m_aRecordChangesCB.Check( bRecordChanges ); m_aRecordChangesCB.Enable( /*!bProtection && */!bIsReadonly ); - DBG_ASSERT( pCurDocShell, "doc shell missing" ); - if (pCurDocShell) - { - m_bOrigPasswordIsConfirmed = true; // default case if no password is set - uno::Sequence< sal_Int8 > aPasswordHash; - // check if password is available - if (pCurDocShell->GetProtectionHash( aPasswordHash ) && - aPasswordHash.getLength() > 0) - m_bOrigPasswordIsConfirmed = false; // password found, needs to be confirmed later on - } + m_bOrigPasswordIsConfirmed = true; // default case if no password is set + uno::Sequence< sal_Int8 > aPasswordHash; + // check if password is available + if (pCurDocShell->GetProtectionHash( aPasswordHash ) && + aPasswordHash.getLength() > 0) + m_bOrigPasswordIsConfirmed = false; // password found, needs to be confirmed later on + } + else + { + // A Calc document that is shared will have 'm_eRedlingMode == RL_NONE' + // In shared documents change recording and protection must be disabled, + // similar to documents that do not support change recording at all. + m_aRecordChangesCB.Check( FALSE ); + m_aRecordChangesCB.Disable(); + m_aChangeProtectionPB.Check( FALSE ); + m_aChangeProtectionPB.Disable(); } } diff --git a/sfx2/source/dialog/securitypage.src b/sfx2/source/dialog/securitypage.src index 7952bea923..dc76da8a58 100755 --- a/sfx2/source/dialog/securitypage.src +++ b/sfx2/source/dialog/securitypage.src @@ -150,6 +150,14 @@ TabPage TP_DOCINFOSECURITY }; }; +String RID_SFX_PROTECT_RECORDS +{ + Text [ en-US ] = "Protect Records" ; +}; +String RID_SFX_UNPROTECT_RECORDS +{ + Text [ en-US ] = "Unprotect Records" ; +}; String RID_SFX_INCORRECT_PASSWORD { Text [ en-US ] = "Incorrect password" ; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 9f30d2f3dd..48f70e4e06 100755 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -1076,6 +1076,22 @@ void SfxObjectShell::SetInitialized_Impl( const bool i_fromInitNew ) } +bool SfxObjectShell::IsChangeRecording() const +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); + return false; +} + + +bool SfxObjectShell::HasChangeRecordProtection() const +{ + // currently this function needs to be overwritten by Writer and Calc only + DBG_ASSERT( 0, "function not implemented" ); + return false; +} + + void SfxObjectShell::SetChangeRecording( bool /*bActivate*/ ) { // currently this function needs to be overwritten by Writer and Calc only -- cgit v1.2.3 From 54506d201e055ec183c6a33fec701aa67fe912ed Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 3 Jun 2010 00:10:45 +0200 Subject: tl78: #i110383# password to modify support for binary types only --- sfx2/inc/sfx2/docfile.hxx | 2 +- sfx2/inc/sfx2/objsh.hxx | 4 ++-- sfx2/inc/sfx2/sfxsids.hrc | 2 +- sfx2/sdi/sfx.sdi | 4 ++-- sfx2/source/dialog/filedlghelper.cxx | 8 ++++---- sfx2/source/doc/docfile.cxx | 17 +++++++++++------ sfx2/source/doc/guisaveas.cxx | 34 +++------------------------------- sfx2/source/doc/objcont.cxx | 4 ++-- sfx2/source/doc/sfxbasemodel.cxx | 14 ++++++++++++++ sfx2/source/inc/objshimp.hxx | 2 +- sfx2/source/view/viewfrm.cxx | 4 ++-- 11 files changed, 43 insertions(+), 52 deletions(-) (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx index f19d2845fa..cd43e0989d 100644 --- a/sfx2/inc/sfx2/docfile.hxx +++ b/sfx2/inc/sfx2/docfile.hxx @@ -328,7 +328,7 @@ public: static sal_Bool CallApproveHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler, ::com::sun::star::uno::Any aRequest, sal_Bool bAllowAbort ); static sal_Bool SetWritableForUserOnly( const ::rtl::OUString& aURL ); - static sal_uInt16 CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bMSType ); + static sal_uInt32 CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bWriter ); }; SV_DECL_IMPL_REF( SfxMedium ) diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 111b91f758..4c133689cd 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -437,8 +437,8 @@ public: void SetSaveVersionOnClose( sal_Bool bSet ); void ResetFromTemplate( const String& rTemplateName, const String& rFileName ); - sal_uInt16 GetModifyPasswordHash() const; - sal_Bool SetModifyPasswordHash( sal_uInt16 nHash ); + sal_uInt32 GetModifyPasswordHash() const; + sal_Bool SetModifyPasswordHash( sal_uInt32 nHash ); static sal_uInt32 HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDoc ); diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index fcc821f71f..ca5ee9fba1 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -306,7 +306,7 @@ #define SID_ACTIVATE_STYLE_APPLY (SID_SFX_START + 1715) #define SID_FONT_NAME (SID_SFX_START + 1716) #define SID_DEFAULTFILENAME (SID_SFX_START + 1717) -#define SID_PASSWORDTOMODIFYHASH (SID_SFX_START + 1718) +#define SID_MODIFYPASSWORDHASH (SID_SFX_START + 1718) #define SID_RECOMMENDREADONLY (SID_SFX_START + 1719) #define SID_SFX_free_START (SID_SFX_START + 1720) #define SID_SFX_free_END (SID_SFX_START + 3999) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index fcefd7bacb..13cfa2e531 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3594,7 +3594,7 @@ SfxVoidItem MacroOrganizer SID_MACROORGANIZER ] //-------------------------------------------------------------------------- -SfxUInt16Item PasswordToModifyHash SID_PASSWORDTOMODIFYHASH +SfxUInt16Item PasswordToModifyHash SID_MODIFYPASSWORDHASH [ /* flags: */ @@ -5317,7 +5317,7 @@ SfxBoolItem SaveAll SID_SAVEDOCS //-------------------------------------------------------------------------- SfxBoolItem SaveAs SID_SAVEASDOC -(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO) +(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO,SfxInt32Item ModifyPasswordHash SID_MODIFYPASSWORDHASH) [ /* flags: */ AutoUpdate = FALSE, diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 337e9bc634..87fa88484c 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1528,7 +1528,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, mbPwdCheckBoxState = ( pPassItem != NULL ); // in case the document has password to modify, the dialog should be shown - SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUInt16Item, SID_PASSWORDTOMODIFYHASH, FALSE ); + SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUInt32Item, SID_MODIFYPASSWORDHASH, FALSE ); mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue() ); } @@ -1541,7 +1541,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // the password will be set in case user decide so rpSet->ClearItem( SID_PASSWORD ); rpSet->ClearItem( SID_RECOMMENDREADONLY ); - rpSet->ClearItem( SID_PASSWORDTOMODIFYHASH ); + rpSet->ClearItem( SID_MODIFYPASSWORDHASH ); } @@ -1660,9 +1660,9 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); // the empty password has 0 as Hash - sal_uInt16 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), bMSType ); + sal_uInt16 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) ); if ( nHash ) - rpSet->Put( SfxUInt16Item( SID_PASSWORDTOMODIFYHASH, nHash ) ); + rpSet->Put( SfxInt32Item( SID_MODIFYPASSWORDHASH, (sal_Int32)nHash ) ); } else return ERRCODE_ABORT; diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 4c7b9f91dc..43d98d1c04 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -2576,15 +2576,20 @@ void SfxMedium::SetOrigFilter_Impl( const SfxFilter* pOrigFilter ) //------------------------------------------------------------------ -sal_uInt16 SfxMedium::CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bMSType ) +sal_uInt32 SfxMedium::CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd, sal_Bool bWriter ) { - sal_uInt16 nHash = 0; + sal_uInt32 nHash = 0; if ( aPasswd.getLength() ) { - rtl_TextEncoding nEncoding = RTL_TEXTENCODING_UTF8; - if ( bMSType ) + if ( bWriter ) { + nHash = ::comphelper::DocPasswordHelper::GetWordHashAsUINT32( aPasswd ); + } + else + { + rtl_TextEncoding nEncoding = RTL_TEXTENCODING_UTF8; + // if the MS-filter should be used // use the inconsistent algorithm to find the encoding specified by MS nEncoding = osl_getThreadTextEncoding(); @@ -2612,9 +2617,9 @@ sal_uInt16 SfxMedium::CreatePasswordToModifyHash( const ::rtl::OUString& aPasswd nEncoding = RTL_TEXTENCODING_MS_1250; break; } - } - nHash = ::comphelper::DocPasswordHelper::GetXLHashAsUINT16( aPasswd, nEncoding ); + nHash = ::comphelper::DocPasswordHelper::GetXLHashAsUINT16( aPasswd, nEncoding ); + } } return nHash; diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index b8e775801a..534cccdcd4 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -180,18 +180,13 @@ class DocumentSettingsGuard { uno::Reference< beans::XPropertySet > m_xDocumentSettings; sal_Bool m_bPreserveReadOnly; - sal_uInt16 m_nPreserveHash; - sal_Bool m_bReadOnlySupported; - sal_Bool m_bModifyPasswordHashSupported; sal_Bool m_bRestoreSettings; public: - DocumentSettingsGuard( const uno::Reference< frame::XModel >& xModel, sal_Bool bReadOnly, sal_uInt16 nHash, sal_Bool bRestore ) + DocumentSettingsGuard( const uno::Reference< frame::XModel >& xModel, sal_Bool bReadOnly, sal_Bool bRestore ) : m_bPreserveReadOnly( sal_False ) - , m_nPreserveHash( 0 ) , m_bReadOnlySupported( sal_False ) - , m_bModifyPasswordHashSupported( sal_False ) , m_bRestoreSettings( bRestore ) { try @@ -203,7 +198,6 @@ public: uno::UNO_QUERY_THROW ); ::rtl::OUString aLoadReadonlyString( RTL_CONSTASCII_USTRINGPARAM( "LoadReadonly" ) ); - ::rtl::OUString aModifyPasswordHashString( RTL_CONSTASCII_USTRINGPARAM( "ModifyPasswordHash" ) ); try { @@ -213,20 +207,11 @@ public: } catch( uno::Exception& ) {} - - try - { - m_xDocumentSettings->getPropertyValue( aModifyPasswordHashString ) >>= m_nPreserveHash; - m_xDocumentSettings->setPropertyValue( aModifyPasswordHashString, uno::makeAny( nHash ) ); - m_bModifyPasswordHashSupported = sal_True; - } - catch( uno::Exception& ) - {} } catch( uno::Exception& ) {} - if ( ( bReadOnly && !m_bReadOnlySupported ) || ( nHash && !m_bModifyPasswordHashSupported ) ) + if ( ( bReadOnly && !m_bReadOnlySupported ) ) throw uno::RuntimeException(); // the user could provide the data, so it must be stored } @@ -235,15 +220,11 @@ public: if ( m_bRestoreSettings ) { ::rtl::OUString aLoadReadonlyString( RTL_CONSTASCII_USTRINGPARAM( "LoadReadonly" ) ); - ::rtl::OUString aModifyPasswordHashString( RTL_CONSTASCII_USTRINGPARAM( "ModifyPasswordHash" ) ); try { if ( m_bReadOnlySupported ) m_xDocumentSettings->setPropertyValue( aLoadReadonlyString, uno::makeAny( m_bPreserveReadOnly ) ); - - if ( m_bModifyPasswordHashSupported ) - m_xDocumentSettings->setPropertyValue( aModifyPasswordHashString, uno::makeAny( m_nPreserveHash ) ); } catch( uno::Exception& ) { @@ -272,7 +253,6 @@ class ModelData_Impl ::comphelper::SequenceAsHashMap m_aMediaDescrHM; sal_Bool m_bRecommendReadOnly; - sal_uInt16 m_nPasswordToModifyHash; public: ModelData_Impl( SfxStoringHelper& aOwner, @@ -291,7 +271,6 @@ public: ::comphelper::SequenceAsHashMap& GetMediaDescr() { return m_aMediaDescrHM; } sal_Bool IsRecommendReadOnly() { return m_bRecommendReadOnly; } - sal_uInt16 GetPasswordToModifyHash() { return m_nPasswordToModifyHash; } const ::comphelper::SequenceAsHashMap& GetDocProps(); @@ -346,8 +325,6 @@ ModelData_Impl::ModelData_Impl( SfxStoringHelper& aOwner, , m_pModulePropsHM( NULL ) , m_aMediaDescrHM( aMediaDescr ) , m_bRecommendReadOnly( sal_False ) -, m_nPasswordToModifyHash( 0 ) - { CheckInteractionHandler(); } @@ -1018,11 +995,6 @@ sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode, m_bRecommendReadOnly = ( pRecommendReadOnly && pRecommendReadOnly->GetValue() ); pDialogParams->ClearItem( SID_RECOMMENDREADONLY ); - SFX_ITEMSET_ARG( pDialogParams, pPassToModifyItem, SfxUInt16Item, SID_PASSWORDTOMODIFYHASH, sal_False ); - if ( pPassToModifyItem ) - m_nPasswordToModifyHash = pPassToModifyItem->GetValue(); - pDialogParams->ClearItem( SID_PASSWORDTOMODIFYHASH ); - uno::Sequence< beans::PropertyValue > aPropsFromDialog; TransformItems( nSlotID, *pDialogParams, aPropsFromDialog, NULL ); GetMediaDescr() << aPropsFromDialog; @@ -1607,7 +1579,7 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& // store the document and handle it's docinfo SvtSaveOptions aOptions; - DocumentSettingsGuard aSettingsGuard( aModelData.GetModel(), aModelData.IsRecommendReadOnly(), aModelData.GetPasswordToModifyHash(), nStoreMode & EXPORT_REQUESTED ); + DocumentSettingsGuard aSettingsGuard( aModelData.GetModel(), aModelData.IsRecommendReadOnly(), nStoreMode & EXPORT_REQUESTED ); if ( aOptions.IsDocInfoSave() && ( !aModelData.GetStorable()->hasLocation() diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 46435f6b90..1066149e50 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1242,12 +1242,12 @@ void SfxObjectShell::SetSaveVersionOnClose( sal_Bool bNew ) pImp->bSaveVersionOnClose = bNew; } -sal_uInt16 SfxObjectShell::GetModifyPasswordHash() const +sal_uInt32 SfxObjectShell::GetModifyPasswordHash() const { return pImp->m_nModifyPasswordHash; } -sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt16 nHash ) +sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt32 nHash ) { // Commented out before the solution for Saving process is found // if ( ( !IsReadOnly() && !IsReadOnlyUI() ) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 7a5f630659..d253cd8741 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -74,6 +74,7 @@ #include #include #include +#include #include #include #include @@ -2731,6 +2732,12 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL uno::Reference< uno::XInterface >() ); } + SFX_ITEMSET_ARG( aParams, pModifyPasswordHashItem, SfxInt32Item, SID_MODIFYPASSWORDHASH, sal_False ); + sal_uInt32 nModifyPasswordHash = pModifyPasswordHashItem ? pModifyPasswordHashItem->GetValue() : 0; + aParams->ClearItem( SID_MODIFYPASSWORDHASH ); + sal_uInt32 nOldModifyPasswordHash = m_pData->m_pObjectShell->GetModifyPasswordHash(); + m_pData->m_pObjectShell->SetModifyPasswordHash( nModifyPasswordHash ); + // since saving a document modifies its DocumentInfo, the current // DocumentInfo must be saved on "SaveTo", so it can be restored // after saving @@ -2809,10 +2816,14 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL if ( !bSaveTo ) { m_pData->m_aPreusedFilterName = GetMediumFilterName_Impl(); + m_pData->m_pObjectShell->SetModifyPasswordEntered(); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEASDOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVEASDOCDONE), m_pData->m_pObjectShell ) ); } else { + m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVETODOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVETODOCDONE), m_pData->m_pObjectShell ) ); } } @@ -2822,6 +2833,9 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL m_pData->m_pObjectShell->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Storing failed!" ) ) ); m_pData->m_pObjectShell->StoreLog(); + m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash ); + + SFX_APP()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOCFAILED : SFX_EVENT_SAVEASDOCFAILED, GlobalEventConfig::GetEventName( bSaveTo ? STR_EVENT_SAVETODOCFAILED : STR_EVENT_SAVEASDOCFAILED), m_pData->m_pObjectShell ) ); diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index 3290ef1e38..a5e3435568 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -149,7 +149,7 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess sal_Bool m_bIncomplEncrWarnShown; - sal_uInt16 m_nModifyPasswordHash; + sal_uInt32 m_nModifyPasswordHash; sal_Bool m_bModifyPasswordEntered; SfxObjectShell_Impl( SfxObjectShell& _rDocShell ); diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index eb51ae1213..ddf97635a0 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -170,7 +170,7 @@ TYPEINIT1(SfxViewFrameItem, SfxPoolItem); //========================================================================= //------------------------------------------------------------------------- -static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const ::rtl::OUString& aPath, const SfxFilter* pFilter, sal_uInt16 nPasswordHash ) +static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const ::rtl::OUString& aPath, const SfxFilter* pFilter, sal_uInt32 nPasswordHash ) { sal_Bool bResult = !nPasswordHash; @@ -196,7 +196,7 @@ static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteracti xHandler->handle( rRequest ); if ( pPasswordRequest->isPassword() ) - bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), bMSType ) == nPasswordHash ); + bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pFilter->GetServiceName() ) ) == nPasswordHash ); else bCancel = sal_True; -- cgit v1.2.3 From 0893452dec2be9b98c2e0ad6b6148271aff28bd5 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 8 Jun 2010 17:01:41 +0200 Subject: tl78: #i110383# fix reload functionality --- sfx2/inc/sfx2/objsh.hxx | 2 +- sfx2/source/dialog/filedlghelper.cxx | 6 +++--- sfx2/source/doc/objcont.cxx | 4 ++-- sfx2/source/doc/objmisc.cxx | 2 +- sfx2/source/view/viewfrm.cxx | 13 ++++++++++--- 5 files changed, 17 insertions(+), 10 deletions(-) (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index e1a0dca272..0d4dec522c 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -717,7 +717,7 @@ public: SAL_DLLPRIVATE sal_uInt16 ImplCheckSignaturesInformation( const ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation >& aInfos ); SAL_DLLPRIVATE void CheckEncryption_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); - SAL_DLLPRIVATE void SetModifyPasswordEntered(); + SAL_DLLPRIVATE void SetModifyPasswordEntered( sal_Bool bEntered = sal_True ); SAL_DLLPRIVATE sal_Bool IsModifyPasswordEntered(); SAL_DLLPRIVATE void InitBasicManager_Impl(); diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 87fa88484c..040fbb787e 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1528,7 +1528,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, mbPwdCheckBoxState = ( pPassItem != NULL ); // in case the document has password to modify, the dialog should be shown - SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUInt32Item, SID_MODIFYPASSWORDHASH, FALSE ); + SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxInt32Item, SID_MODIFYPASSWORDHASH, FALSE ); mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue() ); } @@ -1660,9 +1660,9 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); // the empty password has 0 as Hash - sal_uInt16 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) ); + sal_Int32 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) ); if ( nHash ) - rpSet->Put( SfxInt32Item( SID_MODIFYPASSWORDHASH, (sal_Int32)nHash ) ); + rpSet->Put( SfxInt32Item( SID_MODIFYPASSWORDHASH, nHash ) ); } else return ERRCODE_ABORT; diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 1066149e50..7f09c18e88 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1262,9 +1262,9 @@ sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt32 nHash ) // return sal_False; } -void SfxObjectShell::SetModifyPasswordEntered() +void SfxObjectShell::SetModifyPasswordEntered( sal_Bool bEntered ) { - pImp->m_bModifyPasswordEntered = sal_True; + pImp->m_bModifyPasswordEntered = bEntered; } sal_Bool SfxObjectShell::IsModifyPasswordEntered() diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index df4a082b29..8fc989e91d 100755 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1389,7 +1389,7 @@ void SfxObjectShell::FinishedLoading( sal_uInt16 nFlags ) if( !IsAbortingImport() ) PositionView_Impl(); - if ( GetModifyPasswordHash() ) + if ( GetModifyPasswordHash() && !IsModifyPasswordEntered() ) SetReadOnly(); // Salvage diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index ddf97635a0..de94b081df 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -714,6 +714,10 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) } xNewObj = SfxObjectShell::CreateObject( pFilter->GetServiceName(), SFX_CREATE_MODE_STANDARD ); + + if ( xOldObj->IsModifyPasswordEntered() ) + xNewObj->SetModifyPasswordEntered(); + uno::Sequence < beans::PropertyValue > aLoadArgs; TransformItems( SID_OPENDOC, *pNewSet, aLoadArgs ); try @@ -769,6 +773,12 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) } else { + if ( xNewObj->GetModifyPasswordHash() && xNewObj->GetModifyPasswordHash() != xOldObj->GetModifyPasswordHash() ) + { + xNewObj->SetModifyPasswordEntered( sal_False ); + xNewObj->SetReadOnly(); + } + if ( xNewObj->IsDocShared() ) { // the file is shared but the closing can change the sharing control file @@ -781,10 +791,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) TransformItems( SID_OPENDOC, *xNewObj->GetMedium()->GetItemSet(), aLoadArgs ); UpdateDocument_Impl(); - } - if ( xNewObj.Is() ) - { try { while ( !aViewFrames.empty() ) -- cgit v1.2.3 From 43effdf73aa7b0e4d867a8b139334724b15bad89 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 15 Jun 2010 21:01:57 +0200 Subject: tl78v2: #i112427# Support password to modify in calc and writer ODF documents --- sfx2/inc/sfx2/objsh.hxx | 4 ++++ sfx2/inc/sfx2/sfxsids.hrc | 2 +- sfx2/sdi/sfx.sdi | 29 +---------------------------- sfx2/source/appl/appuno.cxx | 17 +++++++++++++++-- sfx2/source/dialog/filedlghelper.cxx | 25 ++++++++++++++++++------- sfx2/source/doc/objcont.cxx | 36 +++++++++++++++++++++++++++--------- sfx2/source/doc/sfxbasemodel.cxx | 20 ++++++++++++++++---- sfx2/source/inc/objshimp.hxx | 2 ++ 8 files changed, 84 insertions(+), 51 deletions(-) (limited to 'sfx2/inc/sfx2') diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 0d4dec522c..2a7a2c19b9 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -439,9 +439,13 @@ public: void SetSaveVersionOnClose( sal_Bool bSet ); void ResetFromTemplate( const String& rTemplateName, const String& rFileName ); + // TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future sal_uInt32 GetModifyPasswordHash() const; sal_Bool SetModifyPasswordHash( sal_uInt32 nHash ); + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > GetModifyPasswordInfo() const; + sal_Bool SetModifyPasswordInfo( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aInfo ); + static sal_uInt32 HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDoc ); virtual void ViewAssigned(); diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index ca5ee9fba1..572eda93aa 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -306,7 +306,7 @@ #define SID_ACTIVATE_STYLE_APPLY (SID_SFX_START + 1715) #define SID_FONT_NAME (SID_SFX_START + 1716) #define SID_DEFAULTFILENAME (SID_SFX_START + 1717) -#define SID_MODIFYPASSWORDHASH (SID_SFX_START + 1718) +#define SID_MODIFYPASSWORDINFO (SID_SFX_START + 1718) #define SID_RECOMMENDREADONLY (SID_SFX_START + 1719) #define SID_SFX_free_START (SID_SFX_START + 1720) #define SID_SFX_free_END (SID_SFX_START + 3999) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index b6e22899ea..be9689d401 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3593,33 +3593,6 @@ SfxVoidItem MacroOrganizer SID_MACROORGANIZER GroupId = GID_MACRO; ] -//-------------------------------------------------------------------------- -SfxInt32Item PasswordToModifyHash SID_MODIFYPASSWORDHASH - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - Readonly = TRUE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = ; -] - //-------------------------------------------------------------------------- SfxBoolItem ReccomendReadonly SID_RECOMMENDREADONLY @@ -5317,7 +5290,7 @@ SfxBoolItem SaveAll SID_SAVEDOCS //-------------------------------------------------------------------------- SfxBoolItem SaveAs SID_SAVEASDOC -(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO,SfxInt32Item ModifyPasswordHash SID_MODIFYPASSWORDHASH) +(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO) [ /* flags: */ AutoUpdate = FALSE, diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 8105d7bcba..2a7bb3f56d 100755 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -191,6 +191,7 @@ static char const sFolderName[] = "FolderName"; static char const sUseSystemDialog[] = "UseSystemDialog"; static char const sStandardDir[] = "StandardDir"; static char const sBlackList[] = "BlackList"; +static char const sModifyPasswordInfo[] = "ModifyPasswordInfo"; void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot ) { @@ -846,6 +847,10 @@ void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Seque if (bOK) rSet.Put( SfxBoolItem( SID_NOAUTOSAVE, bVal ) ); } + else if ( aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sModifyPasswordInfo)) ) + { + rSet.Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, rProp.Value ) ); + } #ifdef DBG_UTIL else --nFoundArgs; @@ -1058,6 +1063,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta nAdditional++; if ( rSet.GetItemState( SID_NOAUTOSAVE ) == SFX_ITEM_SET ) nAdditional++; + if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO ) == SFX_ITEM_SET ) + nAdditional++; // consider additional arguments nProps += nAdditional; @@ -1197,7 +1204,9 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta // used only internally if ( nId == SID_SAVETO ) continue; - } + if ( nId == SID_MODIFYPASSWORDINFO ) + continue; + } ByteString aDbg( "Unknown item detected: "); aDbg += ByteString::CreateFromInt32( nId ); @@ -1555,7 +1564,11 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sNoAutoSave)); pValue[nActProp++].Value <<= ( ((SfxBoolItem*)pItem)->GetValue() ); } - + if ( rSet.GetItemState( SID_MODIFYPASSWORDINFO, sal_False, &pItem ) == SFX_ITEM_SET ) + { + pValue[nActProp].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sModifyPasswordInfo)); + pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() ); + } } } diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index e1493aa8bb..6cbb5c1964 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -80,11 +80,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include "openflag.hxx" @@ -1528,8 +1530,8 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, mbPwdCheckBoxState = ( pPassItem != NULL ); // in case the document has password to modify, the dialog should be shown - SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxInt32Item, SID_MODIFYPASSWORDHASH, FALSE ); - mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue() ); + SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUnoAnyItem, SID_MODIFYPASSWORDINFO, FALSE ); + mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue().hasValue() ); } SFX_ITEMSET_ARG( rpSet, pSelectItem, SfxBoolItem, SID_SELECTION, FALSE ); @@ -1541,7 +1543,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // the password will be set in case user decide so rpSet->ClearItem( SID_PASSWORD ); rpSet->ClearItem( SID_RECOMMENDREADONLY ); - rpSet->ClearItem( SID_MODIFYPASSWORDHASH ); + rpSet->ClearItem( SID_MODIFYPASSWORDINFO ); } @@ -1659,10 +1661,19 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, if ( pPasswordRequest->getRecommendReadOnly() ) rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); - // the empty password has 0 as Hash - sal_Int32 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) ); - if ( nHash ) - rpSet->Put( SfxInt32Item( SID_MODIFYPASSWORDHASH, nHash ) ); + if ( bMSType ) + { + // the empty password has 0 as Hash + sal_Int32 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) ); + if ( nHash ) + rpSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( nHash ) ) ); + } + else + { + uno::Sequence< beans::PropertyValue > aModifyPasswordInfo = ::comphelper::DocPasswordHelper::GenerateNewModifyPasswordInfo( pPasswordRequest->getPasswordToModify() ); + if ( aModifyPasswordInfo.getLength() ) + rpSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( aModifyPasswordInfo ) ) ); + } } else return ERRCODE_ABORT; diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 7f09c18e88..910bf6f5d5 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1249,17 +1249,35 @@ sal_uInt32 SfxObjectShell::GetModifyPasswordHash() const sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt32 nHash ) { -// Commented out before the solution for Saving process is found -// if ( ( !IsReadOnly() && !IsReadOnlyUI() ) -// || !(pImp->nFlagsInProgress & SFX_LOADED_MAINDOCUMENT ) ) -// { -// // the hash can be changed only in editable documents, -// // or during loading of document + if ( ( !IsReadOnly() && !IsReadOnlyUI() ) + || !(pImp->nFlagsInProgress & SFX_LOADED_MAINDOCUMENT ) ) + { + // the hash can be changed only in editable documents, + // or during loading of document pImp->m_nModifyPasswordHash = nHash; return sal_True; -// } -// -// return sal_False; + } + + return sal_False; +} + +uno::Sequence< beans::PropertyValue > SfxObjectShell::GetModifyPasswordInfo() const +{ + return pImp->m_aModifyPasswordInfo; +} + +sal_Bool SfxObjectShell::SetModifyPasswordInfo( const uno::Sequence< beans::PropertyValue >& aInfo ) +{ + if ( ( !IsReadOnly() && !IsReadOnlyUI() ) + || !(pImp->nFlagsInProgress & SFX_LOADED_MAINDOCUMENT ) ) + { + // the hash can be changed only in editable documents, + // or during loading of document + pImp->m_aModifyPasswordInfo = aInfo; + return sal_True; + } + + return sal_False; } void SfxObjectShell::SetModifyPasswordEntered( sal_Bool bEntered ) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index d253cd8741..b81006337c 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -2732,12 +2732,22 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL uno::Reference< uno::XInterface >() ); } - SFX_ITEMSET_ARG( aParams, pModifyPasswordHashItem, SfxInt32Item, SID_MODIFYPASSWORDHASH, sal_False ); - sal_uInt32 nModifyPasswordHash = pModifyPasswordHashItem ? pModifyPasswordHashItem->GetValue() : 0; - aParams->ClearItem( SID_MODIFYPASSWORDHASH ); + sal_uInt32 nModifyPasswordHash = 0; + uno::Sequence< beans::PropertyValue > aModifyPasswordInfo; + SFX_ITEMSET_ARG( aParams, pModifyPasswordInfoItem, SfxUnoAnyItem, SID_MODIFYPASSWORDINFO, sal_False ); + if ( pModifyPasswordInfoItem ) + { + // it contains either a simple hash or a set of PropertyValues + // TODO/LATER: the sequence of PropertyValue should replace the hash completely in future + pModifyPasswordInfoItem->GetValue() >>= nModifyPasswordHash; + pModifyPasswordInfoItem->GetValue() >>= aModifyPasswordInfo; + } + aParams->ClearItem( SID_MODIFYPASSWORDINFO ); sal_uInt32 nOldModifyPasswordHash = m_pData->m_pObjectShell->GetModifyPasswordHash(); m_pData->m_pObjectShell->SetModifyPasswordHash( nModifyPasswordHash ); - + uno::Sequence< beans::PropertyValue > aOldModifyPasswordInfo = m_pData->m_pObjectShell->GetModifyPasswordInfo(); + m_pData->m_pObjectShell->SetModifyPasswordInfo( aModifyPasswordInfo ); + // since saving a document modifies its DocumentInfo, the current // DocumentInfo must be saved on "SaveTo", so it can be restored // after saving @@ -2823,6 +2833,7 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL else { m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash ); + m_pData->m_pObjectShell->SetModifyPasswordInfo( aOldModifyPasswordInfo ); SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVETODOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVETODOCDONE), m_pData->m_pObjectShell ) ); } @@ -2834,6 +2845,7 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL m_pData->m_pObjectShell->StoreLog(); m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash ); + m_pData->m_pObjectShell->SetModifyPasswordInfo( aOldModifyPasswordInfo ); SFX_APP()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOCFAILED : SFX_EVENT_SAVEASDOCFAILED, GlobalEventConfig::GetEventName( bSaveTo ? STR_EVENT_SAVETODOCFAILED : STR_EVENT_SAVEASDOCFAILED), diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index a5e3435568..c31a671f90 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -149,7 +149,9 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess sal_Bool m_bIncomplEncrWarnShown; + // TODO/LATER: m_aModifyPasswordInfo should completely replace m_nModifyPasswordHash in future sal_uInt32 m_nModifyPasswordHash; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aModifyPasswordInfo; sal_Bool m_bModifyPasswordEntered; SfxObjectShell_Impl( SfxObjectShell& _rDocShell ); -- cgit v1.2.3