From 8e594b080d8d542b1cdd9a2b90bd79215fb72ff8 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 ++- sfx2/sdi/sfx.sdi | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'sfx2') diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index bcbb39c96638..8ec890d3f2c4 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) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 26f55ccdd178..29797a258ea2 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3993,6 +3993,33 @@ SfxVoidItem MacroOrganizer SID_MACROORGANIZER GroupId = GID_MACRO; ] +//-------------------------------------------------------------------------- +SfxInt32Item ModifyPasswordHash 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 = ; +] + //-------------------------------------------------------------------------- SfxVoidItem RunMacro SID_RUNMACRO () -- cgit From 54499ed54bd760755e4d172417f0cc849fc47d1e 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 + 9 files changed, 660 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 (limited to 'sfx2') diff --git a/sfx2/inc/sfx2/securitypage.hxx b/sfx2/inc/sfx2/securitypage.hxx new file mode 100755 index 000000000000..616f11d3b6d1 --- /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 83f20874c324..5e64bdf4ca7b --- 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 0f778a94f091..e592eae82b08 --- 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 eaa691fe3eff..f32bc768e846 --- 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 87ef0f1a7af1..b344170fd39c --- 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 000000000000..affebc8615cb --- /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 000000000000..820dab538b9f --- /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 000000000000..32f5fac704a4 --- /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 29ad461d18da..f09ac7e94ecc --- 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) -- cgit From 9ed2bd2cd955daefa3eed53466dc63e8ded60d17 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Fri, 26 Mar 2010 09:35:04 +0100 Subject: tl78: #i105076# add ENCRYPTION and PASSWORDTOMODIFY filter flags --- sfx2/source/dialog/filedlghelper.cxx | 46 ++++++++++++++++++++---------------- sfx2/source/doc/docfilt.cxx | 14 ----------- 2 files changed, 26 insertions(+), 34 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 5270eb5d4207..5e4e7d88258c 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -466,23 +466,14 @@ sal_Bool FileDialogHelper_Impl::isInOpenMode() const namespace { -bool lclCheckODFPasswordCapability( const SfxFilter* pFilter ) +sal_Bool lclCheckPasswordCapability( const SfxFilter* pFilter ) { - return pFilter && pFilter->IsOwnFormat() && pFilter->UsesStorage() && (pFilter->GetVersion() >= SOFFICE_FILEFORMAT_60); + return pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_ENCRYPTION ); } -bool lclCheckMSPasswordCapability( const SfxFilter* pFilter ) +sal_Bool lclCheckPasswordToModifyCapability( const SfxFilter* pFilter ) { - // TODO #i105076# this should be in the filter configuration!!! - return pFilter && CheckMSPasswordCapabilityForExport( pFilter->GetFilterName() ); -} - -bool lclCheckPasswordCapability( const SfxFilter* pFilter ) -{ - return - lclCheckODFPasswordCapability( pFilter ) || - // TODO #i105076# this should be in the filter configuration!!! - lclCheckMSPasswordCapability( pFilter ); + return pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ); } } @@ -546,7 +537,7 @@ void FileDialogHelper_Impl::updateSelectionBox() return; // Does the selection box exist? - bool bSelectionBoxFound = false; + sal_Bool bSelectionBoxFound = sal_False; uno::Reference< XControlInformation > xCtrlInfo( mxFileDlg, UNO_QUERY ); if ( xCtrlInfo.is() ) { @@ -555,7 +546,7 @@ void FileDialogHelper_Impl::updateSelectionBox() for ( sal_uInt32 nCtrl = 0; nCtrl < nCount; ++nCtrl ) if ( aCtrlList[ nCtrl ].equalsAscii("SelectionBox") ) { - bSelectionBoxFound = true; + bSelectionBoxFound = sal_False; break; } } @@ -1550,6 +1541,10 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, { SFX_ITEMSET_ARG( rpSet, pPassItem, SfxStringItem, SID_PASSWORD, FALSE ); 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 ); + mbPwdCheckBoxState |= ( pPassToModifyItem && pPassToModifyItem->GetValue() ); } SFX_ITEMSET_ARG( rpSet, pSelectItem, SfxBoolItem, SID_SELECTION, FALSE ); @@ -1560,6 +1555,9 @@ 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 ); + } if ( mbHasPassword && !mbPwdCheckBoxState ) @@ -1656,18 +1654,26 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, if( xInteractionHandler.is() ) { // TODO: need a save way to distinguish MS filters from other filters - bool bMSType = CheckMSPasswordCapabilityForExport( rFilter ); + sal_Bool bMSType = CheckMSPasswordCapabilityForExport( rFilter ); ::comphelper::DocPasswordRequestType eType = bMSType ? ::comphelper::DocPasswordRequestType_MS : ::comphelper::DocPasswordRequestType_STANDARD; - ::comphelper::DocPasswordRequest* pPasswordRequest = new ::comphelper::DocPasswordRequest( - eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)) ); + ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), lclCheckPasswordToModifyCapability( getCurentSfxFilter() ) ) ); uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest ); xInteractionHandler->handle( rRequest ); - if ( pPasswordRequest->isPassword() ) - rpSet->Put( SfxStringItem( SID_PASSWORD, pPasswordRequest->getPassword() ) ); + if ( pPasswordRequest->isSelected() ) + { + if ( pPasswordRequest->isPassword() ) + rpSet->Put( SfxStringItem( SID_PASSWORD, pPasswordRequest->getPassword() ) ); + + if ( pPasswordRequest->isRecommendReadOnly() ) + rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); + + if ( pPasswordRequest->getPasswordToModify().getLength() ) + rpSet->Put( SfxStringItem( SID_PASSWORDTOMODIFY, pPasswordRequest->getPasswordToModify() ) ); + } else return ERRCODE_ABORT; } diff --git a/sfx2/source/doc/docfilt.cxx b/sfx2/source/doc/docfilt.cxx index e955c43af705..1219d30d7b27 100644 --- a/sfx2/source/doc/docfilt.cxx +++ b/sfx2/source/doc/docfilt.cxx @@ -49,20 +49,6 @@ using namespace ::com::sun::star; -namespace sfx2 { - -// TODO #i105076# this should be in the filter configuration!!! -bool CheckMSPasswordCapabilityForExport( const String& rFilterName ) -{ - return - rFilterName.EqualsAscii( "MS Word 97" ) || - rFilterName.EqualsAscii( "MS Word 97 Vorlage" ) || - rFilterName.EqualsAscii( "MS Excel 97" ) || - rFilterName.EqualsAscii( "MS Excel 97 Vorlage/Template" ); -} - -} // namespace sfx2 - // STATIC DATA ----------------------------------------------------------- DBG_NAME(SfxFilter) -- cgit From a6c29b00be50f9b48c56903d5764518b7b3aced9 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') diff --git a/sfx2/inc/sfx2/docfilt.hxx b/sfx2/inc/sfx2/docfilt.hxx index b4118272bb88..f024fdb07c06 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 From d160fd054bc4e8c02152d7ce55f7eddbd611e01f 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') diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index a7c73d3e14d8..64bb5692cf09 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 1b59c639a17d..9df71c085b25 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 5e4e7d88258c..adca8cdb7922 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 cbd269b41516..4993e96b40bb 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(); } @@ -916,6 +1012,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 ); GetMediaDescr() << aPropsFromDialog; @@ -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 593de3d181f1..b710a4b0fbfe 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 From 0e95d8378a6f670993a3d408d3bfe313385379e8 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') diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index e0142e9ba140..99161cb5b36c 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 adca8cdb7922..c1b9aaf7838d 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 207a5096a89a..b1a5968b2b5a 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 e3e3a36505a5..0ed230dd9dd9 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 e015058ae280..a97018e4b3f6 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 From 9ace57ec709cd618b5401da6f1ebacba5a07c1c0 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 1 Apr 2010 15:31:41 +0200 Subject: tl78: #i110383# allow to change the hash always for now --- sfx2/source/doc/objcont.cxx | 15 +++++++++------ sfx2/source/doc/objxtor.cxx | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index b1a5968b2b5a..5d14007ec169 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -1486,13 +1486,16 @@ sal_uInt16 SfxObjectShell::GetModifyPasswordHash() const sal_Bool SfxObjectShell::SetModifyPasswordHash( sal_uInt16 nHash ) { - if ( !IsReadOnly() && !IsReadOnlyUI() ) - { - // the hash can be changed only in editable documents, +// 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 pImp->m_nModifyPasswordHash = nHash; return sal_True; - } - - return sal_False; +// } +// +// return sal_False; } diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 0ed230dd9dd9..0b0c356b65ed 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -261,6 +261,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,m_bCreateTempStor( sal_False ) ,m_xDocInfoListener() ,m_bIsInit( sal_False ) + ,m_bUIStoring( sal_False ) ,m_bIncomplEncrWarnShown( sal_False ) ,m_nModifyPasswordHash( 0 ) { -- cgit From 62eee956dbb05c25600030ab47310bf39db0c7ee Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 1 Apr 2010 15:37:38 +0200 Subject: tl78: #i110383# fix typo --- sfx2/source/doc/objxtor.cxx | 1 - 1 file changed, 1 deletion(-) (limited to 'sfx2') diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 0b0c356b65ed..0ed230dd9dd9 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -261,7 +261,6 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,m_bCreateTempStor( sal_False ) ,m_xDocInfoListener() ,m_bIsInit( sal_False ) - ,m_bUIStoring( sal_False ) ,m_bIncomplEncrWarnShown( sal_False ) ,m_nModifyPasswordHash( 0 ) { -- cgit From e0986b3290e9c73116d86f9ae3b8e35f94aadc2b 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 | 3 + 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 +++++++++++++++++++++-------------- 9 files changed, 275 insertions(+), 171 deletions(-) (limited to 'sfx2') diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx index 03bcfec5818f..01494f751773 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 99161cb5b36c..e932f0f87477 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -294,6 +294,7 @@ 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 ); @@ -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 c1b9aaf7838d..d7109496d670 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 0b535088b0bd..1740d2703ed1 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 5d14007ec169..0a02a7f8df49 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 1cb88e98f59f..a7adf530afc9 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 0ed230dd9dd9..cc983e5eb543 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 a97018e4b3f6..04df263a3de8 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 2291e8079b3a..1d61b09fdd63 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 )); -- cgit From b74d54d62a0162c490c5fe833f937120c8795680 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') diff --git a/sfx2/inc/sfx2/securitypage.hxx b/sfx2/inc/sfx2/securitypage.hxx index 616f11d3b6d1..8b2ca43fc945 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 From 65cf934efc6f8958d9c024ee965685cfd6cac704 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 ++++---- 5 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 sfx2/inc/sfx2/htmlmode.hxx (limited to 'sfx2') diff --git a/sfx2/inc/sfx2/htmlmode.hxx b/sfx2/inc/sfx2/htmlmode.hxx new file mode 100644 index 000000000000..51f341c5c3c0 --- /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 8b2ca43fc945..d25f0ee0b967 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 bc4c11b53184..74210ba680ef 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 1495a560965b..f8da760bc12d 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 affebc8615cb..d6351143c51e 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 -- cgit From 2005bc7b8b04f6eaa3d4636a3a1df1d6ff02f550 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Mon, 3 May 2010 09:08:38 +0200 Subject: cws tl78: build issues after merging with DEV300_m77 --- sfx2/source/view/viewfrm.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index aedd383b042a..c8cf7bd8c6c8 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -82,6 +82,7 @@ #include #include #include +#include #include #include @@ -183,9 +184,6 @@ static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteracti 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( -- cgit From e8f78faa415a94dda55b8cd3249d3586d36dc119 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 7 May 2010 10:40:12 +0200 Subject: cws tl78: fixing windows specific build problems after merging with DEV300_m77 --- sfx2/inc/brokenpackageint.hxx | 18 ++++++++++++++++-- sfx2/source/appl/appuno.cxx | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) mode change 100644 => 100755 sfx2/inc/brokenpackageint.hxx mode change 100644 => 100755 sfx2/source/appl/appuno.cxx (limited to 'sfx2') diff --git a/sfx2/inc/brokenpackageint.hxx b/sfx2/inc/brokenpackageint.hxx old mode 100644 new mode 100755 index e39c92c599ae..16f332480cf6 --- a/sfx2/inc/brokenpackageint.hxx +++ b/sfx2/inc/brokenpackageint.hxx @@ -36,7 +36,9 @@ using namespace ::framework; typedef ContinuationBase< ::com::sun::star::task::XInteractionApprove > SfxContinuationApprove; typedef ContinuationBase< ::com::sun::star::task::XInteractionDisapprove > SfxContinuationDisapprove; -class SFX2_DLLPUBLIC RequestPackageReparation : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest > +class SFX2_DLLPUBLIC RequestPackageReparation : + public ::com::sun::star::task::XInteractionRequest, + public ::cppu::OWeakObject { ::com::sun::star::uno::Any m_aRequest; @@ -50,6 +52,11 @@ class SFX2_DLLPUBLIC RequestPackageReparation : public ::cppu::WeakImplHelper1< public: RequestPackageReparation( ::rtl::OUString aName ); + // XInterface / OWeakObject + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire( ) throw (); + virtual void SAL_CALL release( ) throw (); + sal_Bool isApproved() { return m_pApprove->isSelected(); } virtual ::com::sun::star::uno::Any SAL_CALL getRequest() @@ -61,7 +68,9 @@ public: throw( ::com::sun::star::uno::RuntimeException ); }; -class SFX2_DLLPUBLIC NotifyBrokenPackage : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest > +class SFX2_DLLPUBLIC NotifyBrokenPackage : + public ::com::sun::star::task::XInteractionRequest, + public ::cppu::OWeakObject { ::com::sun::star::uno::Any m_aRequest; @@ -74,6 +83,11 @@ class SFX2_DLLPUBLIC NotifyBrokenPackage : public ::cppu::WeakImplHelper1< ::com public: NotifyBrokenPackage( ::rtl::OUString aName ); + // XInterface / OWeakObject + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire( ) throw (); + virtual void SAL_CALL release( ) throw (); + sal_Bool isAborted() { return m_pAbort->isSelected(); } virtual ::com::sun::star::uno::Any SAL_CALL getRequest() diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx old mode 100644 new mode 100755 index fd33e21ea645..66452f10bbfb --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -2411,6 +2411,26 @@ RequestPackageReparation::RequestPackageReparation( ::rtl::OUString aName ) m_lContinuations[1] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pDisapprove ); } +/*uno::*/Any SAL_CALL RequestPackageReparation::queryInterface( const /*uno::*/Type& rType ) throw (RuntimeException) +{ + return ::cppu::queryInterface ( rType, + // OWeakObject interfaces + dynamic_cast< XInterface* > ( (XInteractionRequest *) this ), + static_cast< XWeak* > ( this ), + // my own interfaces + static_cast< XInteractionRequest* > ( this ) ); +} + +void SAL_CALL RequestPackageReparation::acquire( ) throw () +{ + OWeakObject::acquire(); +} + +void SAL_CALL RequestPackageReparation::release( ) throw () +{ + OWeakObject::release(); +} + ::com::sun::star::uno::Any SAL_CALL RequestPackageReparation::getRequest() throw( ::com::sun::star::uno::RuntimeException ) { @@ -2442,6 +2462,26 @@ NotifyBrokenPackage::NotifyBrokenPackage( ::rtl::OUString aName ) m_lContinuations[0] = ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >( m_pAbort ); } +/*uno::*/Any SAL_CALL NotifyBrokenPackage::queryInterface( const /*uno::*/Type& rType ) throw (RuntimeException) +{ + return ::cppu::queryInterface ( rType, + // OWeakObject interfaces + dynamic_cast< XInterface* > ( (XInteractionRequest *) this ), + static_cast< XWeak* > ( this ), + // my own interfaces + static_cast< XInteractionRequest* > ( this ) ); +} + +void SAL_CALL NotifyBrokenPackage::acquire( ) throw () +{ + OWeakObject::acquire(); +} + +void SAL_CALL NotifyBrokenPackage::release( ) throw () +{ + OWeakObject::release(); +} + ::com::sun::star::uno::Any SAL_CALL NotifyBrokenPackage::getRequest() throw( ::com::sun::star::uno::RuntimeException ) { -- cgit From 0e1079119202c55866d01479e913a30bf7513ce6 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Mon, 10 May 2010 13:58:03 +0200 Subject: CWS mba33issues01: #i109842#: delete global resources in pro version also --- sfx2/source/appl/appquit.cxx | 50 -------------------------------------------- 1 file changed, 50 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/appl/appquit.cxx b/sfx2/source/appl/appquit.cxx index 4da32cf9f566..d615d90ff37a 100644 --- a/sfx2/source/appl/appquit.cxx +++ b/sfx2/source/appl/appquit.cxx @@ -74,57 +74,11 @@ using ::basic::BasicManagerRepository; -#ifdef DBG_UTIL -DECLARE_LIST( SfxFrameWindowFactoryArray_Impl, SfxFrameWindowFactory* ) -SV_DECL_PTRARR(SfxInitLinkList, Link*, 2, 2) -#endif - //=================================================================== BOOL SfxApplication::QueryExit_Impl() { BOOL bQuit = TRUE; -/* - BOOL bPrinting = FALSE; - for ( SfxViewShell *pViewSh = SfxViewShell::GetFirst(); - !bPrinting && pViewSh; - pViewSh = SfxViewShell::GetNext(*pViewSh) ) - { - SfxPrinter *pPrinter = pViewSh->GetPrinter(); - bPrinting = pPrinter && pPrinter->IsPrinting(); - } - - if ( bPrinting ) - { - // Benutzer fragen, ob abgebrochen werden soll - if ( RET_OK == QueryBox( 0, SfxResId( MSG_ISPRINTING_QUERYABORT ) ).Execute() ) - { - // alle Jobs canceln - for ( SfxViewShell *pViewSh = SfxViewShell::GetFirst(); - !bPrinting && pViewSh; - pViewSh = SfxViewShell::GetNext(*pViewSh) ) - { - SfxPrinter *pPrinter = pViewSh->GetPrinter(); - if ( pPrinter && pPrinter->IsPrinting() ) - pPrinter->AbortJob(); - } - - // da das Canceln asynchron ist, Quit erstmal wieder verlassen - GetDispatcher_Impl()->Execute( SID_QUITAPP, SFX_CALLMODE_ASYNCHRON ); - DBG_TRACE( "QueryExit => FALSE (printing)" ); - return FALSE; - } - } -*/ -/* - SfxObjectShell *pLastDocSh = SfxObjectShell::GetFirst(); - if ( bQuit ) - { - // Jetzt zur Sicherheit auch hidden Frames abr"aumen - SfxViewFrame::CloseHiddenFrames_Impl(); - pLastDocSh = SfxObjectShell::GetFirst(); - } -*/ // will trotzdem noch jemand, den man nicht abschiessen kann, die App haben? if ( !bQuit ) { @@ -197,22 +151,18 @@ void SfxApplication::Deinitialize() delete pAppData_Impl->pLabelResMgr; -#ifdef DBG_UTIL DELETEX(pAppData_Impl->pSlotPool); DELETEX(pAppData_Impl->pEventConfig); SfxMacroConfig::Release_Impl(); DELETEX(pAppData_Impl->pFactArr); DELETEX(pAppData_Impl->pInitLinkList); -#endif -#ifdef DBG_UTIL DELETEX(pAppData_Impl->pTbxCtrlFac); DELETEX(pAppData_Impl->pStbCtrlFac); DELETEX(pAppData_Impl->pMenuCtrlFac); DELETEX(pAppData_Impl->pViewFrames); DELETEX(pAppData_Impl->pViewShells); DELETEX(pAppData_Impl->pObjShells); -#endif //TODO/CLEANTUP //ReleaseArgs could be used instead! -- cgit From cd50d383f645aa1d188331039d334faebfa1add0 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') diff --git a/sfx2/inc/sfx2/app.hxx b/sfx2/inc/sfx2/app.hxx index 17b2dee417cd..e38a2e9dbe7f 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 a07623df46b1..38ea69280c49 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 3cdc3064fb81..07eb47bd92ad 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 71c0b371f796..4edba523ed30 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 649ae121c274..3af0ba2b0a6f 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 d2ad8c645eb7..e53f1766b7b9 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 66af0d7ac8ba..0d3c1f727e5b 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 From d310e6479f4db1c86629ca98f6e0f7480a0fa5e4 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Tue, 18 May 2010 17:10:29 +0200 Subject: CWS mba33issues01: #i109842#: missing typedef --- sfx2/source/appl/appmain.cxx | 3 --- 1 file changed, 3 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/appl/appmain.cxx b/sfx2/source/appl/appmain.cxx index 020f68d01e8d..cf097b900b52 100644 --- a/sfx2/source/appl/appmain.cxx +++ b/sfx2/source/appl/appmain.cxx @@ -93,9 +93,6 @@ static SfxItemInfo __READONLY_DATA aItemInfos[] = //=================================================================== -typedef Link* LinkPtr; -SV_DECL_PTRARR(SfxInitLinkList, LinkPtr, 4, 4) - TYPEINIT2(SfxApplication,SfxShell,SfxBroadcaster); //-------------------------------------------------------------------- -- cgit From 74efe21718537220ec16adab9964a00fc13cd9fd Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Tue, 18 May 2010 17:10:57 +0200 Subject: CWS mba33issues01: #i109842#: missing typedef --- sfx2/source/inc/appdata.hxx | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sfx2') diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx index 91305eb95cce..bd12f3db80dc 100644 --- a/sfx2/source/inc/appdata.hxx +++ b/sfx2/source/inc/appdata.hxx @@ -82,6 +82,9 @@ class SfxBasicManagerCreationListener; namespace sfx2 { namespace appl { class ImeStatusWindow; } } +typedef Link* LinkPtr; +SV_DECL_PTRARR(SfxInitLinkList, LinkPtr, 4, 4) + //========================================================================= // SfxAppData_Impl //========================================================================= -- cgit From 9a4d07cc52534a40cf1cd68efdef1464475e694b Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Tue, 18 May 2010 17:19:21 +0200 Subject: CWS mba33issues01: #i107576#: make code safe against releasing of external references to client site --- sfx2/source/view/ipclient.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sfx2') diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index 6d61f4182bbb..328d88d8b2b9 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -131,6 +131,8 @@ public: , m_bResizeNoScale( sal_False ) {} + ~SfxInPlaceClient_Impl(); + void SizeHasChanged(); DECL_LINK (TimerHdl, Timer*); uno::Reference < frame::XFrame > GetFrame() const; @@ -168,6 +170,10 @@ public: virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); }; +SfxInPlaceClient_Impl::~SfxInPlaceClient_Impl() +{ +} + void SAL_CALL SfxInPlaceClient_Impl::changingState( const ::com::sun::star::lang::EventObject& /*aEvent*/, ::sal_Int32 /*nOldState*/, @@ -645,6 +651,7 @@ SfxInPlaceClient::SfxInPlaceClient( SfxViewShell* pViewShell, Window *pDraw, sal m_pViewSh( pViewShell ), m_pEditWin( pDraw ) { + m_pImp->acquire(); m_pImp->m_pClient = this; m_pImp->m_nAspect = nAspect; m_pImp->m_aScaleWidth = m_pImp->m_aScaleHeight = Fraction(1,1); @@ -668,6 +675,7 @@ SfxInPlaceClient::~SfxInPlaceClient() // the next call will destroy m_pImp if no other reference to it exists m_pImp->m_xClient = uno::Reference < embed::XEmbeddedClient >(); + m_pImp->release(); // TODO/LATER: // the class is not intended to be used in multithreaded environment; -- cgit From 4659d84eb4e0e8038ac21044ddd3c390e2585581 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' --- sfx2/inc/sfx2/objsh.hxx | 7 + sfx2/inc/sfx2/sfx.hrc | 2 + sfx2/sdi/sfx.sdi | 2 +- sfx2/source/dialog/securitypage.cxx | 320 ++++++++++++++++++++++++------------ sfx2/source/dialog/securitypage.hrc | 6 +- sfx2/source/dialog/securitypage.src | 19 ++- sfx2/source/doc/objxtor.cxx | 24 +++ 7 files changed, 261 insertions(+), 119 deletions(-) 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') diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx old mode 100644 new mode 100755 index 5fc5a641fd44..7984fae956cb --- 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 137218e3c117..3ed7f34ee3b8 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 10a920852848..e4ff0dc8d2b5 --- 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 d6351143c51e..d4f217671d6e 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 @@ -218,30 +228,46 @@ 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; @@ -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; + + // the push button text is always the opposite of the current state. Thus: + const bool bCurrentProtection = m_aChangeProtectionPB.GetText() != m_aProtectSTR; - if (QueryRecordChangesProtectionState( m_eRedlingMode, bProt )) + // 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; } @@ -378,3 +485,4 @@ void SfxSecurityPage::Reset( const SfxItemSet & rItemSet ) ////////////////////////////////////////////////////////////////////// + diff --git a/sfx2/source/dialog/securitypage.hrc b/sfx2/source/dialog/securitypage.hrc index 820dab538b9f..d425131b4772 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 32f5fac704a4..4bf8cdaf58a9 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 6502eeaeb78c..751525910958 --- 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 From 1778298eb695174aad2f6a981f560f0e4e2b229a Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 19 May 2010 14:59:46 +0200 Subject: cws tl79 : random typo in sfx.sdi fixed --- sfx2/sdi/sfx.sdi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sfx2') diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index e4ff0dc8d2b5..10a920852848 100755 --- 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, -- cgit From 3ff45fd2d5b0bbf8318a5559fa66aba45b5c4040 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Thu, 20 May 2010 11:04:13 +0200 Subject: cws tl79: #i111422# pre-notify for 'Toggle' of check box --- sfx2/source/dialog/securitypage.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index d4f217671d6e..f88525107f1c 100755 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -175,7 +175,7 @@ struct SfxSecurityPage_Impl String m_aEndRedliningWarning; bool m_bEndRedliningWarningDone; - DECL_LINK( RecordChangesCBHdl, void* ); + DECL_LINK( RecordChangesCBToggleHdl, void* ); DECL_LINK( ChangeProtectionPBHdl, void* ); SfxSecurityPage_Impl( SfxSecurityPage &rDlg, const SfxItemSet &rItemSet ); @@ -218,7 +218,9 @@ SfxSecurityPage_Impl::SfxSecurityPage_Impl( SfxSecurityPage &rTabPage, const Sfx if (nTemp > nBtnTextWidth) nBtnTextWidth = nTemp; - m_aRecordChangesCB.SetClickHdl( LINK( this, SfxSecurityPage_Impl, RecordChangesCBHdl ) ); + // force toggle hdl called before visual change of checkbox + m_aRecordChangesCB.SetStyle( m_aRecordChangesCB.GetStyle() | WB_EARLYTOGGLE ); + m_aRecordChangesCB.SetToggleHdl( LINK( this, SfxSecurityPage_Impl, RecordChangesCBToggleHdl ) ); m_aChangeProtectionPB.SetClickHdl( LINK( this, SfxSecurityPage_Impl, ChangeProtectionPBHdl ) ); } @@ -348,7 +350,7 @@ void SfxSecurityPage_Impl::Reset_Impl( const SfxItemSet & ) } -IMPL_LINK( SfxSecurityPage_Impl, RecordChangesCBHdl, void*, EMPTYARG ) +IMPL_LINK( SfxSecurityPage_Impl, RecordChangesCBToggleHdl, void*, EMPTYARG ) { // when change recording gets disabled protection must be disabled as well if (!m_aRecordChangesCB.IsChecked()) // the new check state is already present, thus the '!' -- cgit From de8796345a26ebc4607cfd0fd10b303c20b866e9 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') diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 7984fae956cb..3e3448de4753 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 3ed7f34ee3b8..a49b003b5b49 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 f88525107f1c..0c6688ab1229 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; + + // 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" ); - // no change recording should imply no password protection - if (!bDoRecordChanges && (!m_bNewPasswordIsValid || m_aNewPassword.Len() != 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 4bf8cdaf58a9..7c0fffd96057 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 751525910958..fdbd2b6a5cf0 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 From 6b4917460417793350ed406aa0742ec31ef6ca3c Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Wed, 26 May 2010 08:13:07 +0200 Subject: cws tl79: warning-free code --- sfx2/source/dialog/securitypage.cxx | 2 +- sfx2/source/doc/objxtor.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index 0c6688ab1229..d32ee843cbf2 100755 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -149,7 +149,7 @@ static bool lcl_IsPasswordCorrect( const String &rPassword ) SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); uno::Sequence< sal_Int8 > aPasswordHash; - bool bHasPassword = pCurDocShell->GetProtectionHash( aPasswordHash ); + pCurDocShell->GetProtectionHash( aPasswordHash ); // check if supplied password was correct uno::Sequence< sal_Int8 > aNewPasswd( aPasswordHash ); diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index fdbd2b6a5cf0..217faeca2e55 100755 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -1099,7 +1099,7 @@ void SfxObjectShell::SetChangeRecording( bool /*bActivate*/ ) } -bool SfxObjectShell::SetProtectionPassword( const String &rPassword ) +bool SfxObjectShell::SetProtectionPassword( const String & /*rPassword*/ ) { // currently this function needs to be overwritten by Writer and Calc only DBG_ASSERT( 0, "function not implemented" ); -- cgit From 720cb002b90767f097bed1ee63f61337632b731d Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Mon, 31 May 2010 12:59:01 +0200 Subject: fwk143: #i111516# Support language argument and configuration item for dictionary repository URL. --- sfx2/source/appl/appserv.cxx | 63 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 8 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 14789100bb24..bd9efc9bca1e 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -51,20 +51,15 @@ #include #include -#ifndef _UNOTOOLS_PROCESSFACTORY_HXX #include -#endif #include +#include "comphelper/configurationhelper.hxx" -#ifndef _SVT_DOC_ADDRESSTEMPLATE_HXX_ #include -#endif #include #include -#ifndef _UNOTOOLS_CONFIGMGR_HXX_ #include -#endif #include #include #include @@ -90,6 +85,7 @@ #include #include #include +#include #include #include @@ -879,6 +875,31 @@ namespace } } +static ::rtl::OUString getConfigurationStringValue( + const ::rtl::OUString& rPackage, + const ::rtl::OUString& rRelPath, + const ::rtl::OUString& rKey, + const ::rtl::OUString& rDefaultValue ) +{ + ::rtl::OUString aDefVal( rDefaultValue ); + + try + { + ::comphelper::ConfigurationHelper::readDirectKey( + comphelper::getProcessServiceFactory(), + rPackage, + rRelPath, + rKey, + ::comphelper::ConfigurationHelper::E_READONLY) >>= aDefVal; + } + catch(const com::sun::star::uno::RuntimeException& exRun) + { throw exRun; } + catch(const com::sun::star::uno::Exception&) + {} + + return aDefVal; +} + void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) { DBG_MEMTEST(); @@ -924,8 +945,34 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) uno::Reference< css::system::XSystemShellExecute > xSystemShell( xSMGR->createInstance( DEFINE_CONST_UNICODE("com.sun.star.system.SystemShellExecute" ) ), uno::UNO_QUERY_THROW ); - if ( xSystemShell.is() ) - xSystemShell->execute( DEFINE_CONST_UNICODE("http://extensions.services.openoffice.org/dictionary?cid=926385"), ::rtl::OUString(), css::system::SystemShellExecuteFlags::DEFAULTS ); + + // read repository URL from configuration + ::rtl::OUString sTemplRepoURL = + getConfigurationStringValue( + ::rtl::OUString::createFromAscii("org.openoffice.Office.Common"), + ::rtl::OUString::createFromAscii("Dictionaries"), + ::rtl::OUString::createFromAscii("RepositoryURL"), + ::rtl::OUString()); + + if ( xSystemShell.is() && sTemplRepoURL.getLength() > 0 ) + { + ::rtl::OUStringBuffer aURLBuf( sTemplRepoURL ); + aURLBuf.appendAscii( "?" ); + aURLBuf.appendAscii( "lang=" ); + + // read locale from configuration + ::rtl::OUString sLocale = getConfigurationStringValue( + ::rtl::OUString::createFromAscii("org.openoffice.Setup"), + ::rtl::OUString::createFromAscii("L10N"), + ::rtl::OUString::createFromAscii("ooLocale"), + ::rtl::OUString::createFromAscii("en-US")); + + aURLBuf.append( sLocale ); + xSystemShell->execute( + aURLBuf.makeStringAndClear(), + ::rtl::OUString(), + css::system::SystemShellExecuteFlags::DEFAULTS ); + } } catch( const ::com::sun::star::uno::Exception& ) { -- cgit From 3655eab4df54f47e8821db8aed9b90fa7fab33bd Mon Sep 17 00:00:00 2001 From: tono Date: Mon, 31 May 2010 21:53:32 +0900 Subject: i#111958: MinGW port enhancement: runtime-pseude-reloc-v2 --- sfx2/source/bastyp/sfxhtml.cxx | 4 ---- 1 file changed, 4 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx index 6132e958b900..8a4b434f460b 100644 --- a/sfx2/source/bastyp/sfxhtml.cxx +++ b/sfx2/source/bastyp/sfxhtml.cxx @@ -62,11 +62,7 @@ sal_Char __FAR_DATA sHTML_MIME_application[] = "application/"; sal_Char __FAR_DATA sHTML_MIME_experimental[] = "x-"; // -#ifdef __MINGW32__ // for runtime pseudo reloc -static HTMLOptionEnum aAreaShapeOptEnums[] = -#else static HTMLOptionEnum __READONLY_DATA aAreaShapeOptEnums[] = -#endif { { OOO_STRING_SVTOOLS_HTML_SH_rect, IMAP_OBJ_RECTANGLE }, { OOO_STRING_SVTOOLS_HTML_SH_rectangle, IMAP_OBJ_RECTANGLE }, -- cgit From d90913a6131cd829292e7f13cc6c9b28120a5e43 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Wed, 2 Jun 2010 10:16:03 +0200 Subject: CWS mba33issues01: #i112021#: remove obsolete code --- sfx2/source/dialog/about.cxx | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/dialog/about.cxx b/sfx2/source/dialog/about.cxx index 66d4146d9e62..02f05c773f73 100644 --- a/sfx2/source/dialog/about.cxx +++ b/sfx2/source/dialog/about.cxx @@ -130,20 +130,6 @@ AboutDialog::AboutDialog( Window* pParent, const ResId& rId, const String& rVerS rtl::OUString sProduct; utl::ConfigManager::GetDirectConfigProperty(utl::ConfigManager::PRODUCTNAME) >>= sProduct; - if ( sProduct.equals( rtl::OUString::createFromAscii("StarOffice") ) || - sProduct.equals( rtl::OUString::createFromAscii("StarSuite") ) ) - { - // --> PB 2004-11-18 #118455# new copyright text (only in french version show a french text) - ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale(); - ::rtl::OUString sFrenchLang( DEFINE_CONST_OUSTRING( "fr" ) ); - if ( aLocale.Language.equals( sFrenchLang ) ) - { - String sNewCopyrightText( ResId( ABOUT_STR_FRENCH_COPYRIGHT, *rId.GetResMgr() ) ); - aCopyrightText.SetText( sNewCopyrightText ); - } - // <-- - } - // load image from module path rtl::OUString aAbouts( RTL_CONSTASCII_USTRINGPARAM( ABOUT_BITMAP_STRINGLIST ) ); bool bLoaded = false; @@ -289,22 +275,6 @@ AboutDialog::AboutDialog( Window* pParent, const ResId& rId, const String& rVerS // explizite Help-Id SetHelpId( SID_ABOUT ); - - //#112429# replace occurences of "StarOffice" in the "StarSuite" version - String sCopyright( aCopyrightText.GetText() ); - if(sProduct.equals(rtl::OUString::createFromAscii("StarSuite"))) - { - String sSO(String::CreateFromAscii("StarOffice")); - sCopyright.SearchAndReplaceAll(sSO, sProduct); - } - - String sNewYear( DEFINE_CONST_UNICODE("2005") ); - xub_StrLen nIdx = sCopyright.SearchAndReplace( DEFINE_CONST_UNICODE("2002"), sNewYear ); - if ( STRING_NOTFOUND == nIdx ) - nIdx = sCopyright.SearchAndReplace( DEFINE_CONST_UNICODE("2003"), sNewYear ); - if ( STRING_NOTFOUND == nIdx ) - nIdx = sCopyright.SearchAndReplace( DEFINE_CONST_UNICODE("2004"), sNewYear ); - aCopyrightText.SetText( sCopyright ); } // ----------------------------------------------------------------------- -- cgit From b1ec4b2cd5a9e6ece0e2a928cc0a11fef6bbe818 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') diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx index 7c702c838629..e4d3ff023b3b 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 a769fce4d26e..3b35886bc45d 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 a24c91e60060..5492c76a7e7e 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 98c89663a9ae..1fc2cc16962d 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 d7109496d670..759c47598f9f 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 bb30670162fd..1dea202e0d0e 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 4993e96b40bb..d68fd9dd2bad 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 4cf5a5e7ad51..dc834debd533 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 e1b37c119f1a..d3707636d5ea 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 5aa0c793e12b..e170a7c27240 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 c8cf7bd8c6c8..ca95475cabe6 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 From ba8229cc9d9a4c48a9e0a01611354f64ab5fd069 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 8 Jun 2010 12:35:50 +0200 Subject: tl78: #i105076# fix typo --- sfx2/sdi/sfx.sdi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sfx2') diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 1fc2cc16962d..a19ea0fb8dfc 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3594,7 +3594,7 @@ SfxVoidItem MacroOrganizer SID_MACROORGANIZER ] //-------------------------------------------------------------------------- -SfxUInt16Item PasswordToModifyHash SID_MODIFYPASSWORDHASH +SfxInt32Item PasswordToModifyHash SID_MODIFYPASSWORDHASH [ /* flags: */ -- cgit From db2236600ffc64b188d23f43fb88ee0bf13a680a 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') diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index d8a8ea2f678a..95e8f21c8d86 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 759c47598f9f..072729648628 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 dc834debd533..547198f60ace 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 76aed9d11ed1..afcaa1614f2c 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 ca95475cabe6..a80741df13a6 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 From d148b9b253a4dc439d7572877afd7b43aa943ca8 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 8 Jun 2010 18:04:16 +0200 Subject: cws tl79: #i110254# help ids added --- sfx2/source/dialog/securitypage.src | 15 ++++++++++++--- sfx2/source/inc/helpid.hrc | 10 +++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/dialog/securitypage.src b/sfx2/source/dialog/securitypage.src index 7c0fffd96057..fee60404d01c 100755 --- a/sfx2/source/dialog/securitypage.src +++ b/sfx2/source/dialog/securitypage.src @@ -54,6 +54,7 @@ TabPage TP_DOCINFOSECURITY }; Edit PASSWORD_TO_OPEN_ED { + HelpId = HID_SECURITYTAB_PASSWORD_TO_OPEN; Pos = MAP_APPFONT( 100, 18 ); Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); Border = TRUE; @@ -67,6 +68,7 @@ TabPage TP_DOCINFOSECURITY }; Edit CONFIRM_PASSWORD_TO_OPEN_ED { + HelpId = HID_SECURITYTAB_CONFIRM_PASSWORD_TO_OPEN; Pos = MAP_APPFONT( 100, 32 ); Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); Border = TRUE; @@ -76,9 +78,11 @@ TabPage TP_DOCINFOSECURITY { 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."; + Text [ en-US ] = + "Note: After a password has been set, the document will only open "\ + "with the password. Should you lose the password, there will be "\ + "no way to recover the document. Please also note that this password "\ + "is case-sensitive."; WordBreak = TRUE; }; FixedLine PASSWORD_TO_MODIFY_FL @@ -95,6 +99,7 @@ TabPage TP_DOCINFOSECURITY }; Edit PASSWORD_TO_MODIFY_ED { + HelpId = HID_SECURITYTAB_PASSWORD_TO_MODIFY; Pos = MAP_APPFONT( 100, 90 ); Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); Border = TRUE; @@ -108,6 +113,7 @@ TabPage TP_DOCINFOSECURITY }; Edit CONFIRM_PASSWORD_TO_MODIFY_ED { + HelpId = HID_SECURITYTAB_CONFIRM_PASSWORD_TO_MODIFY; Pos = MAP_APPFONT( 100, 104 ); Size = MAP_APPFONT( 88, RSC_CD_TEXTBOX_HEIGHT ); Border = TRUE; @@ -121,18 +127,21 @@ TabPage TP_DOCINFOSECURITY }; CheckBox OPEN_READONLY_CB { + HelpId = HID_SECURITYTAB_OPEN_FILE_READONLY; Pos = MAP_APPFONT( 12, 133 ); Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); Text [ en-US ] = "~Open file read-only"; }; CheckBox RECORD_CHANGES_CB { + HelpId = HID_SECURITYTAB_RECORD_CHANGES; Pos = MAP_APPFONT( 12, 147 ); Size = MAP_APPFONT( 176, RSC_CD_CHECKBOX_HEIGHT ); Text [ en-US ] = "Record ~changes"; }; PushButton CHANGE_PROTECTION_PB { + HelpId = HID_SECURITYTAB_PROTECTION; Pos = MAP_APPFONT( 194, 145 ); Size = MAP_APPFONT( 60, RSC_CD_PUSHBUTTON_HEIGHT ); }; diff --git a/sfx2/source/inc/helpid.hrc b/sfx2/source/inc/helpid.hrc index f09ac7e94ecc..4c9aa3fd7f63 100755 --- a/sfx2/source/inc/helpid.hrc +++ b/sfx2/source/inc/helpid.hrc @@ -346,7 +346,15 @@ #define HID_CTRL_CUSTOMPROPS_YES_NO (HID_SFX_START + 326) #define HID_DLG_CUSTOMPROPS_DURATION (HID_SFX_START + 327) -#define ACT_SFX_HID_END HID_DLG_CUSTOMPROPS_DURATION +#define HID_SECURITYTAB_PASSWORD_TO_OPEN (HID_SFX_START + 328) +#define HID_SECURITYTAB_CONFIRM_PASSWORD_TO_OPEN (HID_SFX_START + 329) +#define HID_SECURITYTAB_PASSWORD_TO_MODIFY (HID_SFX_START + 330) +#define HID_SECURITYTAB_CONFIRM_PASSWORD_TO_MODIFY (HID_SFX_START + 331) +#define HID_SECURITYTAB_OPEN_FILE_READONLY (HID_SFX_START + 332) +#define HID_SECURITYTAB_RECORD_CHANGES (HID_SFX_START + 333) +#define HID_SECURITYTAB_PROTECTION (HID_SFX_START + 334) + +#define ACT_SFX_HID_END HID_SECURITYTAB_PROTECTION // "Uberlaufpr"ufung -------------------------------------------------------- -- cgit From dad227c459a2329bf6da8eec4847ce8fca228575 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Wed, 9 Jun 2010 14:04:54 +0200 Subject: tl78: #i110383# fix condition --- sfx2/source/dialog/filedlghelper.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sfx2') diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 072729648628..569c0ddb163e 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1647,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)), ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ) ) ); + ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ) != 0 ) ); uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() ); xInteractionHandler->handle( rRequest ); -- cgit From 09733434899d23c04e60d4caa18765b4bed87f3a Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 10 Jun 2010 19:17:08 +0200 Subject: tl78: #i110383# fix reload functionality --- sfx2/source/view/viewfrm.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index a80741df13a6..47f0926d00b6 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -382,12 +382,17 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) // Speichern und Readonly Reloaden if( pSh->IsModified() ) { - if ( !pSh->PrepareClose() ) + if ( pSh->PrepareClose() ) + { + // the storing could let the medium be changed + pMed = pSh->GetMedium(); + bNeedsReload = sal_True; + } + else { rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), sal_False ) ); return; } - else bNeedsReload = sal_True; } nOpenMode = SFX_STREAM_READONLY; } -- cgit From c44ba0727fecc1a1a70f525e72b0854527ab3e22 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 14 Jun 2010 20:07:33 +0200 Subject: tl78: #i111065# let the model be correctly loaded into a frame --- sfx2/source/view/viewfrm.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 47f0926d00b6..08c4980881f7 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -2113,9 +2113,7 @@ SfxViewShell* SfxViewFrame::LoadViewIntoFrame_Impl( const SfxObjectShell& i_rDoc else aTransformLoadArgs.remove( "Hidden" ); - ::rtl::OUString sURL( xDocument->getURL() ); - if ( !sURL.getLength() ) - sURL = i_rDoc.GetFactory().GetFactoryURL(); + ::rtl::OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "private:object" ) ); Reference< XComponentLoader > xLoader( i_rFrame, UNO_QUERY_THROW ); xLoader->loadComponentFromURL( sURL, ::rtl::OUString::createFromAscii( "_self" ), 0, -- cgit From 9d31e5d3ca564c719f94810fd93825131a14699c Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 15 Jun 2010 13:02:12 +0200 Subject: cws tl79: #i110254# security tab hid added to hidother.src --- sfx2/util/hidother.src | 1 + 1 file changed, 1 insertion(+) (limited to 'sfx2') diff --git a/sfx2/util/hidother.src b/sfx2/util/hidother.src index 72b178b2d629..3ef31046bb00 100644 --- a/sfx2/util/hidother.src +++ b/sfx2/util/hidother.src @@ -165,3 +165,4 @@ hidspecial HID_DID_SAVE_PACKED_XML { HelpID = HID_DID_SAVE_PACKED_X hidspecial HID_HELP_ONHELP { HelpID = HID_HELP_ONHELP; }; hidspecial HID_HELP_TEXT_SELECTION_MODE { HelpID = HID_HELP_TEXT_SELECTION_MODE; }; hidspecial HID_DLG_CHECKFORONLINEUPDATE { HelpID = HID_DLG_CHECKFORONLINEUPDATE; }; +hidspecial HID_DOCINFOSECURITY { HelpID = HID_DOCINFOSECURITY; }; -- cgit From 7b4fd03cc280edac58705d047566e30d0b41bae0 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 | 18 +++++++++++++++--- sfx2/source/inc/objshimp.hxx | 2 ++ 8 files changed, 83 insertions(+), 50 deletions(-) (limited to 'sfx2') diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 95e8f21c8d86..6d2b6611991e 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 5492c76a7e7e..b7a3ddf8347d 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 a19ea0fb8dfc..241f3900c09b 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 66452f10bbfb..6f9d3b258745 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 569c0ddb163e..dba0da93208d 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 547198f60ace..451e33084c07 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 d3707636d5ea..96f44169bfd0 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -2732,11 +2732,21 @@ 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 @@ -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 e170a7c27240..b5087fb46294 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 From 3d2a51111ac8e45f6eae9d1fd9e52ee8c4cb35d0 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Wed, 16 Jun 2010 10:36:38 +0200 Subject: tl78v2: #i112427# Support password to modify in calc and writer ODF documents --- sfx2/source/doc/objmisc.cxx | 2 +- sfx2/source/doc/sfxbasemodel.cxx | 4 +++- sfx2/source/view/viewfrm.cxx | 22 +++++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index afcaa1614f2c..addb648ef2e9 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() && !IsModifyPasswordEntered() ) + if ( ( GetModifyPasswordHash() || GetModifyPasswordInfo().getLength() ) && !IsModifyPasswordEntered() ) SetReadOnly(); // Salvage diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 96f44169bfd0..b5a9536b12c5 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -2739,7 +2739,9 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL { // 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; + sal_Int32 nMPHTmp = 0; + pModifyPasswordInfoItem->GetValue() >>= nMPHTmp; + nModifyPasswordHash = (sal_uInt32)nMPHTmp; pModifyPasswordInfoItem->GetValue() >>= aModifyPasswordInfo; } aParams->ClearItem( SID_MODIFYPASSWORDINFO ); diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 08c4980881f7..1dbd3aed623f 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -83,6 +83,7 @@ #include #include #include +#include #include #include @@ -170,9 +171,10 @@ TYPEINIT1(SfxViewFrameItem, SfxPoolItem); //========================================================================= //------------------------------------------------------------------------- -static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const ::rtl::OUString& aPath, const SfxFilter* pFilter, sal_uInt32 nPasswordHash ) +static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteractionHandler >& xHandler, const ::rtl::OUString& aPath, const SfxFilter* pFilter, sal_uInt32 nPasswordHash, const uno::Sequence< beans::PropertyValue > aInfo ) { - sal_Bool bResult = !nPasswordHash; + // TODO/LATER: In future the info should replace the direct hash completely + sal_Bool bResult = ( !nPasswordHash && !aInfo.getLength() ); OSL_ENSURE( pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ), "PasswordToModify feature is active for a filter that does not support it!" ); @@ -196,7 +198,17 @@ static sal_Bool AskPasswordToModify_Impl( const uno::Reference< task::XInteracti xHandler->handle( rRequest ); if ( pPasswordRequest->isPassword() ) - bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pFilter->GetServiceName() ) ) == nPasswordHash ); + { + if ( aInfo.getLength() ) + { + bResult = ::comphelper::DocPasswordHelper::IsModifyPasswordCorrect( pPasswordRequest->getPasswordToModify(), aInfo ); + } + else + { + // the binary format + bResult = ( SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pFilter->GetServiceName() ) ) == nPasswordHash ); + } + } else bCancel = sal_True; @@ -399,11 +411,11 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) else { if ( pSh->IsReadOnlyMedium() - && pSh->GetModifyPasswordHash() + && ( pSh->GetModifyPasswordHash() || pSh->GetModifyPasswordInfo().getLength() ) && !pSh->IsModifyPasswordEntered() ) { ::rtl::OUString aDocumentName = INetURLObject( pMed->GetOrigURL() ).GetMainURL( INetURLObject::DECODE_WITH_CHARSET ); - if( !AskPasswordToModify_Impl( pMed->GetInteractionHandler(), aDocumentName, pMed->GetOrigFilter(), pSh->GetModifyPasswordHash() ) ) + if( !AskPasswordToModify_Impl( pMed->GetInteractionHandler(), aDocumentName, pMed->GetOrigFilter(), pSh->GetModifyPasswordHash(), pSh->GetModifyPasswordInfo() ) ) { // this is a read-only document, if it has "Password to modify" // the user should enter password before he can edit the document -- cgit