Author: orw
Date: Tue Jun 26 15:10:23 2012
New Revision: 1354054
URL: http://svn.apache.org/viewvc?rev=1354054&view=rev
Log:
#119366# - assure that password can be removed from a document via "Save As..."
Found by: DonJaime <donjaime at freenet dot de>
Patch by: zhengfan <zheng.easyfan at gmail dot com>
Review by: Oliver <orw at apache dot org>
Merged from trunk
Modified:
incubator/ooo/branches/AOO34/ (props changed)
incubator/ooo/branches/AOO34/main/ (props changed)
incubator/ooo/branches/AOO34/main/sfx2/source/doc/objstor.cxx
incubator/ooo/branches/AOO34/main/sfx2/source/doc/sfxbasemodel.cxx
Propchange: incubator/ooo/branches/AOO34/
------------------------------------------------------------------------------
Merged /incubator/ooo/trunk:r1354039
Propchange: incubator/ooo/branches/AOO34/main/
------------------------------------------------------------------------------
Merged /incubator/ooo/trunk/main:r1354039
Modified: incubator/ooo/branches/AOO34/main/sfx2/source/doc/objstor.cxx
URL:
http://svn.apache.org/viewvc/incubator/ooo/branches/AOO34/main/sfx2/source/doc/objstor.cxx?rev=1354054&r1=1354053&r2=1354054&view=diff
==============================================================================
--- incubator/ooo/branches/AOO34/main/sfx2/source/doc/objstor.cxx (original)
+++ incubator/ooo/branches/AOO34/main/sfx2/source/doc/objstor.cxx Tue Jun 26
15:10:23 2012
@@ -2897,6 +2897,9 @@ sal_Bool SfxObjectShell::PreDoSaveAs_Imp
// in "SaveAs" title and password will be cleared ( maybe the new itemset
contains new values, otherwise they will be empty )
pMergedParams->ClearItem( SID_PASSWORD );
+ // 119366 - As the SID_ENCRYPTIONDATA and SID_PASSWORD are using for
setting passward together, we need to clear them both.
+ // Also, ( maybe the new itemset contains new values, otherwise they will
be empty )
+ pMergedParams->ClearItem( SID_ENCRYPTIONDATA );
pMergedParams->ClearItem( SID_DOCINFO_TITLE );
pMergedParams->ClearItem( SID_INPUTSTREAM );
Modified: incubator/ooo/branches/AOO34/main/sfx2/source/doc/sfxbasemodel.cxx
URL:
http://svn.apache.org/viewvc/incubator/ooo/branches/AOO34/main/sfx2/source/doc/sfxbasemodel.cxx?rev=1354054&r1=1354053&r2=1354054&view=diff
==============================================================================
--- incubator/ooo/branches/AOO34/main/sfx2/source/doc/sfxbasemodel.cxx
(original)
+++ incubator/ooo/branches/AOO34/main/sfx2/source/doc/sfxbasemodel.cxx Tue Jun
26 15:10:23 2012
@@ -2788,41 +2788,53 @@ void SfxBaseModel::impl_store( const
const SfxFilter* pFilter = pMedium->GetFilter();
if ( pFilter && aFilterName.equals( pFilter->GetFilterName() )
)
{
- aArgHash.erase( aFilterString );
- aArgHash.erase( ::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "URL" ) ) );
-
- try
+ // 119366 - If the former file saving with password, do
not trying in StoreSelf anyway...
+ bool bFormerPassword = false;
{
- storeSelf( aArgHash.getAsConstPropertyValueList() );
- bSaved = sal_True;
+ uno::Sequence< beans::NamedValue > aOldEncryptionData;
+ if (GetEncryptionData_Impl( pMedium->GetItemSet(),
aOldEncryptionData ))
+ {
+ bFormerPassword = true;
+ }
}
- catch( const lang::IllegalArgumentException& )
+ if ( !bFormerPassword )
{
- // some additional arguments do not allow to use
saving, SaveAs should be done
- // but only for normal documents, the shared documents
would be overwritten in this case
- // that would mean an information loss
- // TODO/LATER: need a new interaction for this case
- if ( m_pData->m_pObjectShell->IsDocShared() )
- {
- m_pData->m_pObjectShell->AddLog( ::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't store shared document!" ) )
);
- m_pData->m_pObjectShell->StoreLog();
+ aArgHash.erase( aFilterString );
+ aArgHash.erase( ::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "URL" ) ) );
- uno::Sequence< beans::NamedValue >
aNewEncryptionData = aArgHash.getUnpackedValueOrDefault( ::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "EncryptionData" ) ), uno::Sequence<
beans::NamedValue >() );
- if ( !aNewEncryptionData.getLength() )
+ try
+ {
+ storeSelf( aArgHash.getAsConstPropertyValueList()
);
+ bSaved = sal_True;
+ }
+ catch( const lang::IllegalArgumentException& )
+ {
+ // some additional arguments do not allow to use
saving, SaveAs should be done
+ // but only for normal documents, the shared
documents would be overwritten in this case
+ // that would mean an information loss
+ // TODO/LATER: need a new interaction for this case
+ if ( m_pData->m_pObjectShell->IsDocShared() )
{
- ::rtl::OUString aNewPassword =
aArgHash.getUnpackedValueOrDefault( ::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "Password" ) ), ::rtl::OUString() );
- aNewEncryptionData =
::comphelper::OStorageHelper::CreatePackageEncryptionData( aNewPassword );
- }
+ m_pData->m_pObjectShell->AddLog(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't store
shared document!" ) ) );
+ m_pData->m_pObjectShell->StoreLog();
- uno::Sequence< beans::NamedValue >
aOldEncryptionData;
- GetEncryptionData_Impl( pMedium->GetItemSet(),
aOldEncryptionData );
+ uno::Sequence< beans::NamedValue >
aNewEncryptionData = aArgHash.getUnpackedValueOrDefault( ::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "EncryptionData" ) ), uno::Sequence<
beans::NamedValue >() );
+ if ( !aNewEncryptionData.getLength() )
+ {
+ ::rtl::OUString aNewPassword =
aArgHash.getUnpackedValueOrDefault( ::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "Password" ) ), ::rtl::OUString() );
+ aNewEncryptionData =
::comphelper::OStorageHelper::CreatePackageEncryptionData( aNewPassword );
+ }
- if ( !aOldEncryptionData.getLength() &&
!aNewEncryptionData.getLength() )
- throw;
- else
- {
- // if the password is changed a special error
should be used in case of shared document
- throw task::ErrorCodeIOException(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cant change password for shared
document." ) ), uno::Reference< uno::XInterface >(),
ERRCODE_SFX_SHARED_NOPASSWORDCHANGE );
+ uno::Sequence< beans::NamedValue >
aOldEncryptionData;
+ GetEncryptionData_Impl( pMedium->GetItemSet(),
aOldEncryptionData );
+
+ if ( !aOldEncryptionData.getLength() &&
!aNewEncryptionData.getLength() )
+ throw;
+ else
+ {
+ // if the password is changed a special
error should be used in case of shared document
+ throw task::ErrorCodeIOException(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cant change password for shared
document." ) ), uno::Reference< uno::XInterface >(),
ERRCODE_SFX_SHARED_NOPASSWORDCHANGE );
+ }
}
}
}