diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-05-21 22:26:05 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-05-22 13:12:55 +0200 |
commit | 5246fa262450f686674850c53df666422f441c86 (patch) | |
tree | 2793175c788f1a097d0ff02cefcb0acff56ef8d5 /basic/source/uno | |
parent | 5ca4b9d51046b9b6a36b91c9abd0cc1e7c04b480 (diff) |
fdo#68983: basic: if the library is not loaded fully, copy source storage
Also fixes fdo#42899 and fdo#67685 in a different way; the previous fix
for fdo#42899 caused the problem with password-protected libraries for
which the password is not known: only the binary representation of the
BAISC module was stored, not the source code; by simply copying from the
source storage the problem can be avoided.
It would be possible to ask for the password when storing, but that
would not work when non-interactive (called via API).
An alternative fix would be to pass in the
SfxObjectShell::IsSetModifyEnabled() flag and actually reset the BASIC
library's modify flag correctly, but that requires adding a
parameter to XStorageBasedLibraryContainer::storeLibrariesToStorage().
(regression from af34774d260a68fc02cd78ba90dd8d4afaf1a2a4 )
Change-Id: I4701401f35171139fc2fe8d225d13d4e533091a0
Diffstat (limited to 'basic/source/uno')
-rw-r--r-- | basic/source/uno/namecont.cxx | 17 | ||||
-rw-r--r-- | basic/source/uno/scriptcont.cxx | 6 |
2 files changed, 18 insertions, 5 deletions
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index c3329d1c47e5..52d3494f23ef 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -1909,8 +1909,6 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto if( pImplLib->implIsModified() || bComplete ) { -// For the moment don't copy storage (as an optimisation ) -// but instead always write to storage from memory. // Testing pImplLib->implIsModified() is not reliable, // IMHO the value of pImplLib->implIsModified() should // reflect whether the library ( in-memory ) model @@ -1921,9 +1919,14 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto // temp storage when saving ( and later sets the root storage of the // library container ) and similar madness in dbaccess means some surgery // is required to make it possible to successfully use this optimisation -#if 0 +// It would be possible to do the implSetModified() call below only +// conditionally, but that would require an additional boolean to be +// passed in via the XStorageBasedDocument::storeLibrariesToStorage()... +// fdo#68983: If there's a password and the password is not known, only +// copying the storage works! // Can we simply copy the storage? - if( !mbOldInfoFormat && !pImplLib->implIsModified() && !mbOasis2OOoFormat && xSourceLibrariesStor.is() ) + if (!mbOldInfoFormat && !pImplLib->isLoadedStorable() && + !mbOasis2OOoFormat && xSourceLibrariesStor.is()) { try { @@ -1936,7 +1939,6 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto } } else -#endif { uno::Reference< embed::XStorage > xLibraryStor; if( bStorage ) @@ -3037,6 +3039,11 @@ SfxLibrary::SfxLibrary( ModifiableHelper& _rModifiable, const Type& aType, { } +bool SfxLibrary::isLoadedStorable() +{ + return mbLoaded && (!mbPasswordProtected || mbPasswordVerified); +} + void SfxLibrary::implSetModified( bool _bIsModified ) { if ( mbIsModified == _bIsModified ) diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index 574af686555d..1606bfc7b556 100644 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -1259,6 +1259,12 @@ SfxScriptLibrary::SfxScriptLibrary( ModifiableHelper& _rModifiable, { } +bool SfxScriptLibrary::isLoadedStorable() +{ + // note: mbLoadedSource can only be true for password-protected lib! + return SfxLibrary::isLoadedStorable() && (!mbPasswordProtected || mbLoadedSource); +} + // Provide modify state including resources bool SfxScriptLibrary::isModified( void ) { |