Rebased ref, commits from common ancestor: commit 8ac9ac5016436e08609b4c183725729680739dbd Author: Douglas Mencken <dougmenc...@gmail.com> Date: Wed Oct 21 16:50:40 2015 -0400
Fix âGuÃa problemâ âGuÃa problemâ is actually an unability (i.e. crash) to add new formula or to open existing file with formulas ... ... terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' program received signal SIGABRT, aborted b a c k t r a c e 0 __kill 1 abort ... 5 __cxa_throw 6 com::sun::star::uno::BaseReference::iquery_throw 7 SfxObjectShell::SetupStorage 8 SfxBaseModel::storeToStorage 9 OCommonEmbeddedObject::StoreDocToStorage_Impl 10 OCommonEmbeddedObject::storeAsEntry 11 comphelper::EmbeddedObjectContainer::StoreEmbeddedObject 12 comphelper::EmbeddedObjectContainer::InsertEmbeddedObject ... Fantastically enough that exception cannot be caught even with `catch (...)' What's interesting introduced by this patch ⢠make ``uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY );'' not to be a first line in SfxObjectShell::SetupStorage ⢠add SAL_INFOs to know how the code flows ⢠use `catch ( ... )' here and there ⢠don't throw exceptions from OStorageHelper::GetXStorageFormat in the case when media type returned from xStorProps->getPropertyValue("MediaType") is empty ⢠`return' instead of throwing an exception for the case when `!xStorage.is()' in OCommonEmbeddedObject::StoreDocToStorage_Impl Change-Id: I1241518a7ce87f68da71655f6f7f0a9ab9cb6bdb diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx index caa2d25..c8e2fa1 100644 --- a/comphelper/source/container/embeddedobjectcontainer.cxx +++ b/comphelper/source/container/embeddedobjectcontainer.cxx @@ -467,6 +467,8 @@ bool EmbeddedObjectContainer::StoreEmbeddedObject( const uno::Reference < embed::XEmbeddedObject >& xObj, OUString& rName, bool bCopy, const OUString& rSrcShellID, const OUString& rDestShellID ) { + SAL_INFO( "comphelper.container", "entering >>EmbeddedObjectContainer::StoreEmbeddedObject<<" ); + uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY ); if ( rName.isEmpty() ) rName = CreateUniqueObjectName(); @@ -500,9 +502,9 @@ bool EmbeddedObjectContainer::StoreEmbeddedObject( } } } - catch (uno::Exception const& e) + catch ( uno::Exception const& ex ) { - SAL_WARN("comphelper.container", "EmbeddedObjectContainer::StoreEmbeddedObject: exception caught: " << e.Message); + SAL_WARN( "comphelper.container", "EmbeddedObjectContainer::StoreEmbeddedObject: exception caught: " << ex.Message ); // TODO/LATER: better error recovery should keep storage intact return false; } @@ -512,6 +514,8 @@ bool EmbeddedObjectContainer::StoreEmbeddedObject( bool EmbeddedObjectContainer::InsertEmbeddedObject( const uno::Reference < embed::XEmbeddedObject >& xObj, OUString& rName ) { + SAL_INFO( "comphelper.container", "entering >>bool EmbeddedObjectContainer::InsertEmbeddedObject( const uno::Reference < embed::XEmbeddedObject >& xObj, OUString& rName )<<" ); + // store it into the container storage if (StoreEmbeddedObject(xObj, rName, false, OUString(), OUString())) { @@ -519,12 +523,14 @@ bool EmbeddedObjectContainer::InsertEmbeddedObject( const uno::Reference < embed AddEmbeddedObject( xObj, rName ); return true; } - else - return false; + + return false; } uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::InsertEmbeddedObject( const uno::Reference < io::XInputStream >& xStm, OUString& rNewName ) { + SAL_INFO( "comphelper.container", "entering >>uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::InsertEmbeddedObject( const uno::Reference < io::XInputStream >& xStm, OUString& rNewName )<<" ); + if ( rNewName.isEmpty() ) rNewName = CreateUniqueObjectName(); @@ -585,6 +591,8 @@ uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::InsertEmbedde uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::InsertEmbeddedObject( const css::uno::Sequence < css::beans::PropertyValue >& aMedium, OUString& rNewName ) { + SAL_INFO( "comphelper.container", "entering >>uno::Reference < embed::XEmbeddedObject > EmbeddedObjectContainer::InsertEmbeddedObject( const css::uno::Sequence < css::beans::PropertyValue >& aMedium, OUString& rNewName )<<" ); + if ( rNewName.isEmpty() ) rNewName = CreateUniqueObjectName(); diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx index b2fe5d9..95d386f 100644 --- a/comphelper/source/misc/storagehelper.cxx +++ b/comphelper/source/misc/storagehelper.cxx @@ -231,11 +231,19 @@ sal_Int32 OStorageHelper::GetXStorageFormat( const uno::Reference< embed::XStorage >& xStorage ) throw ( uno::Exception, std::exception ) { + SAL_INFO( "comphelper.misc", "entering >>OStorageHelper::GetXStorageFormat<<" ); + uno::Reference< beans::XPropertySet > xStorProps( xStorage, uno::UNO_QUERY_THROW ); OUString aMediaType; xStorProps->getPropertyValue("MediaType") >>= aMediaType; + if ( aMediaType.getLength() == 0 ) + { + // media type is empty '' string + return SOFFICE_FILEFORMAT_CURRENT; + } + sal_Int32 nResult = 0; // TODO/LATER: the filter configuration could be used to detect it later, or batter a special service @@ -278,13 +286,18 @@ sal_Int32 OStorageHelper::GetXStorageFormat( else { // the mediatype is not known - OUString aMsg(BOOST_CURRENT_FUNCTION); - aMsg += ":"; - aMsg += OUString::number(__LINE__); - aMsg += ": unknown media type '"; - aMsg += aMediaType; - aMsg += "'"; - throw beans::IllegalTypeException(aMsg); + OUString msg(BOOST_CURRENT_FUNCTION); + msg += ":"; + msg += OUString::number(__LINE__); + //msg += ": unknown media type '"; + //msg += aMediaType; + //msg += "'"; + OString oMediaType = OUStringToOString( aMediaType, RTL_TEXTENCODING_ASCII_US ); + SAL_INFO( "comphelper.misc", + msg << ": unknown media type" << + " \'" << oMediaType.pData->buffer << "\'" ); + // assume it fits to format which is used now + return SOFFICE_FILEFORMAT_CURRENT; } return nResult; diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index 5b84c98..0df19ba 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -754,10 +754,13 @@ void OCommonEmbeddedObject::StoreDocToStorage_Impl( const OUString& aHierarchName, bool bAttachToTheStorage ) { - SAL_WARN_IF( !xStorage.is(), "embeddedobj.common", "No storage is provided for storing!" ); + SAL_INFO( "embeddedobj.common", "entering >>OCommonEmbeddedObject::StoreDocToStorage_Impl<<" ); if ( !xStorage.is() ) - throw uno::RuntimeException(); // TODO: + { + SAL_WARN( "embeddedobj.common", "No storage is provided for storing" ); + return; // just return enjoying the silence + } uno::Reference< document::XStorageBasedDocument > xDoc; { @@ -792,7 +795,12 @@ void OCommonEmbeddedObject::StoreDocToStorage_Impl( aArgs[4].Name = "DestinationShellID"; aArgs[4].Value <<= getStringPropertyValue(rObjArgs, "DestinationShellID"); - xDoc->storeToStorage( xStorage, aArgs ); + try + { + xDoc->storeToStorage( xStorage, aArgs ); + } + catch ( ... ) { } + if ( bAttachToTheStorage ) SwitchDocToStorage_Impl( xDoc, xStorage ); } @@ -1162,6 +1170,8 @@ void SAL_CALL OCommonEmbeddedObject::storeToEntry( const uno::Reference< embed:: uno::Exception, uno::RuntimeException, std::exception ) { + SAL_INFO( "embeddedobj.common", "entering >>OCommonEmbeddedObject::storeToEntry<<" ); + ::osl::ResettableMutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); // TODO @@ -1293,6 +1303,8 @@ void SAL_CALL OCommonEmbeddedObject::storeAsEntry( const uno::Reference< embed:: uno::Exception, uno::RuntimeException, std::exception ) { + SAL_INFO( "embeddedobj.common", "entering >>OCommonEmbeddedObject::storeAsEntry<<" ); + // TODO: use lObjArgs ::osl::ResettableMutexGuard aGuard( m_aMutex ); diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index d9c733e..f7212eb 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -338,94 +338,97 @@ SotClipboardFormatId GetChartVersion( sal_Int32 nVersion, bool bTemplate ) void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xStorage, sal_Int32 nVersion, bool bTemplate, bool bChart ) const { - uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY ); + SAL_INFO( "sfx2.doc", "entering >>SfxObjectShell::SetupStorage<<" ); - if ( xProps.is() ) - { - SvGlobalName aName; - OUString aFullTypeName, aShortTypeName, aAppName; - SotClipboardFormatId nClipFormat = SotClipboardFormatId::NONE; + SvGlobalName aName; + OUString aFullTypeName, aShortTypeName, aAppName; + SotClipboardFormatId nClipFormat = GetChartVersion( nVersion, bTemplate ); //SotClipboardFormatId::NONE; - if(!bChart) - FillClass( &aName, &nClipFormat, &aAppName, &aFullTypeName, &aShortTypeName, nVersion, bTemplate ); - else - nClipFormat = GetChartVersion(nVersion, bTemplate); + if (!bChart) + { + FillClass( &aName, &nClipFormat, &aAppName, &aFullTypeName, &aShortTypeName, nVersion, bTemplate ); + } - if ( nClipFormat != SotClipboardFormatId::NONE ) + if ( nClipFormat != SotClipboardFormatId::NONE ) + { + // basic doesn't have a ClipFormat + // without MediaType the storage is not really usable, but currently the BasicIDE still + // is an SfxObjectShell and so we can't take this as an error + datatransfer::DataFlavor aDataFlavor; + SotExchange::GetFormatDataFlavor( nClipFormat, aDataFlavor ); + if ( !aDataFlavor.MimeType.isEmpty() ) { - // basic doesn't have a ClipFormat - // without MediaType the storage is not really usable, but currently the BasicIDE still - // is an SfxObjectShell and so we can't take this as an error - datatransfer::DataFlavor aDataFlavor; - SotExchange::GetFormatDataFlavor( nClipFormat, aDataFlavor ); - if ( !aDataFlavor.MimeType.isEmpty() ) + uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY ); + if ( !xProps.is() ) return; + + try { - try - { - xProps->setPropertyValue("MediaType", uno::makeAny( aDataFlavor.MimeType ) ); - } - catch( uno::Exception& ) - { - const_cast<SfxObjectShell*>( this )->SetError( ERRCODE_IO_GENERAL, OUString( OSL_LOG_PREFIX ) ); - } + xProps->setPropertyValue("MediaType", uno::makeAny( aDataFlavor.MimeType ) ); + } + catch( ... ) + { + const_cast<SfxObjectShell*>( this )->SetError( ERRCODE_IO_GENERAL, OUString( OSL_LOG_PREFIX ) ); + } - SvtSaveOptions::ODFDefaultVersion nDefVersion = SvtSaveOptions::ODFVER_012; - bool bUseSHA1InODF12 = false; - bool bUseBlowfishInODF12 = false; + SvtSaveOptions::ODFDefaultVersion nDefVersion = SvtSaveOptions::ODFVER_012; + bool bUseSHA1InODF12 = false; + bool bUseBlowfishInODF12 = false; - if (!utl::ConfigManager::IsAvoidConfig()) - { - SvtSaveOptions aSaveOpt; - nDefVersion = aSaveOpt.GetODFDefaultVersion(); - bUseSHA1InODF12 = aSaveOpt.IsUseSHA1InODF12(); - bUseBlowfishInODF12 = aSaveOpt.IsUseBlowfishInODF12(); - } + if (!utl::ConfigManager::IsAvoidConfig()) + { + SvtSaveOptions aSaveOpt; + nDefVersion = aSaveOpt.GetODFDefaultVersion(); + bUseSHA1InODF12 = aSaveOpt.IsUseSHA1InODF12(); + bUseBlowfishInODF12 = aSaveOpt.IsUseBlowfishInODF12(); + } - uno::Sequence< beans::NamedValue > aEncryptionAlgs( 3 ); - aEncryptionAlgs[0].Name = "StartKeyGenerationAlgorithm"; - aEncryptionAlgs[1].Name = "EncryptionAlgorithm"; - aEncryptionAlgs[2].Name = "ChecksumAlgorithm"; - // the default values, that should be used for ODF1.1 and older formats - aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA1; - aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8; - aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA1_1K; + uno::Sequence< beans::NamedValue > aEncryptionAlgs( 3 ); + aEncryptionAlgs[0].Name = "StartKeyGenerationAlgorithm"; + aEncryptionAlgs[1].Name = "EncryptionAlgorithm"; + aEncryptionAlgs[2].Name = "ChecksumAlgorithm"; + // the default values, that should be used for ODF1.1 and older formats + aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA1; + aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8; + aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA1_1K; - if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) + if ( nDefVersion >= SvtSaveOptions::ODFVER_012 ) + { + try { - try - { - // older versions can not have this property set, it exists only starting from ODF1.2 - xProps->setPropertyValue("Version", uno::makeAny<OUString>( ODFVER_012_TEXT ) ); - } - catch( uno::Exception& ) - { - } - - if ( !bUseSHA1InODF12 && nDefVersion != SvtSaveOptions::ODFVER_012_EXT_COMPAT ) - { - aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA256; - aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA256_1K; - } - if ( !bUseBlowfishInODF12 && nDefVersion != SvtSaveOptions::ODFVER_012_EXT_COMPAT ) - aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; + // older versions can not have this property set, it exists only starting from ODF1.2 + xProps->setPropertyValue("Version", uno::makeAny<OUString>( ODFVER_012_TEXT ) ); } - - try + catch( ... ) { - // set the encryption algorithms accordingly; - // the setting does not trigger encryption, - // it just provides the format for the case that contents should be encrypted - uno::Reference< embed::XEncryptionProtectedStorage > xEncr( xStorage, uno::UNO_QUERY_THROW ); - xEncr->setEncryptionAlgorithms( aEncryptionAlgs ); } - catch( uno::Exception& ) + + if ( !bUseSHA1InODF12 && nDefVersion != SvtSaveOptions::ODFVER_012_EXT_COMPAT ) { - const_cast<SfxObjectShell*>( this )->SetError( ERRCODE_IO_GENERAL, OUString( OSL_LOG_PREFIX ) ); + aEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA256; + aEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA256_1K; } + if ( !bUseBlowfishInODF12 && nDefVersion != SvtSaveOptions::ODFVER_012_EXT_COMPAT ) + aEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; + } + try + { + // set the encryption algorithms accordingly; + // the setting does not trigger encryption, + // it just provides the format for the case that contents should be encrypted + uno::Reference< embed::XEncryptionProtectedStorage > xEncr( xStorage, uno::UNO_QUERY_THROW ); + xEncr->setEncryptionAlgorithms( aEncryptionAlgs ); + } + catch( ... ) + { + const_cast<SfxObjectShell*>( this )->SetError( ERRCODE_IO_GENERAL, OUString( OSL_LOG_PREFIX ) ); } + } } + + //SAL_INFO( "sfx2.doc", "leaving >>SfxObjectShell::SetupStorage<<" ); + return; } diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 5263318..859f099 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -3763,6 +3763,8 @@ void SAL_CALL SfxBaseModel::storeToStorage( const Reference< embed::XStorage >& Exception, RuntimeException, std::exception ) { + SAL_INFO( "sfx2.doc", "entering >>SfxBaseModel::storeToStorage<<" ); + SfxModelGuard aGuard( *this ); Reference< embed::XStorage > xResult; @@ -3789,11 +3791,13 @@ void SAL_CALL SfxBaseModel::storeToStorage( const Reference< embed::XStorage >& // storing to the own storage bSuccess = m_pData->m_pObjectShell->DoSave(); } - else + else /* xStorage != m_pData->m_pObjectShell->GetStorage() */ { // TODO/LATER: if the provided storage has some data inside the storing might fail, probably the storage must be truncated // TODO/LATER: is it possible to have a template here? - m_pData->m_pObjectShell->SetupStorage( xStorage, nVersion, false ); + try { + m_pData->m_pObjectShell->SetupStorage( xStorage, nVersion, false ); + } catch ( ... ) { } // BaseURL is part of the ItemSet SfxMedium aMedium( xStorage, OUString(), &aSet ); @@ -3814,8 +3818,8 @@ void SAL_CALL SfxBaseModel::storeToStorage( const Reference< embed::XStorage >& { nError = nError ? nError : ERRCODE_IO_GENERAL; throw task::ErrorCodeIOException( - "SfxBaseModel::storeToStorage: 0x" + OUString::number(nError, 16), - Reference< XInterface >(), nError); + "SfxBaseModel::storeToStorage: $" + OUString::number(nError, 16), + Reference< XInterface >(), nError ); } }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits