diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-04-11 00:23:45 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-04-13 01:54:38 -0400 |
commit | ee5e495aa46bd73bcbfd77fc651cca8e7990b84a (patch) | |
tree | f70790ffa8d1b14cb56624b59697f8cbab1e16b0 | |
parent | b894370445ce740c8a416aa04f88431d158b4f74 (diff) |
Reduce indentation by early bail-out.
Change-Id: Iaf2fed36b33d44f06f2c2750f800da5a6dd454ab
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 188 |
1 files changed, 94 insertions, 94 deletions
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 5b28cc23b589..84e34e265a1c 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -1843,125 +1843,125 @@ void SAL_CALL SfxBaseModel::load( const Sequence< beans::PropertyValue >& seqA // the object shell should exist always DBG_ASSERT( m_pData->m_pObjectShell.Is(), "Model is useless without an ObjectShell" ); - if ( m_pData->m_pObjectShell.Is() ) - { - if( m_pData->m_pObjectShell->GetMedium() ) - // if a Medium is present, the document is already initialized - throw frame::DoubleInitializationException(); + if (!m_pData->m_pObjectShell.Is()) + return; - SfxMedium* pMedium = new SfxMedium( seqArguments ); + if( m_pData->m_pObjectShell->GetMedium() ) + // if a Medium is present, the document is already initialized + throw frame::DoubleInitializationException(); - sal_uInt32 nError = ERRCODE_NONE; - OUString aFilterProvider = getFilterProvider(seqArguments); - if (!aFilterProvider.isEmpty()) - { - if (!m_pData->m_pObjectShell->DoLoadExternal(pMedium)) - nError = ERRCODE_IO_GENERAL; + SfxMedium* pMedium = new SfxMedium( seqArguments ); - handleLoadError(nError, pMedium); - pMedium->SetUpdatePickList(false); - return; - } + sal_uInt32 nError = ERRCODE_NONE; + OUString aFilterProvider = getFilterProvider(seqArguments); + if (!aFilterProvider.isEmpty()) + { + if (!m_pData->m_pObjectShell->DoLoadExternal(pMedium)) + nError = ERRCODE_IO_GENERAL; - String aFilterName; - SFX_ITEMSET_ARG( pMedium->GetItemSet(), pFilterNameItem, SfxStringItem, SID_FILTER_NAME, sal_False ); - if( pFilterNameItem ) - aFilterName = pFilterNameItem->GetValue(); - if( !m_pData->m_pObjectShell->GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName ) ) - { - // filtername is not valid - delete pMedium; - throw frame::IllegalArgumentIOException(); - } + handleLoadError(nError, pMedium); + pMedium->SetUpdatePickList(false); + return; + } - SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSalvageItem, SfxStringItem, SID_DOC_SALVAGE, sal_False ); - sal_Bool bSalvage = pSalvageItem ? sal_True : sal_False; + String aFilterName; + SFX_ITEMSET_ARG( pMedium->GetItemSet(), pFilterNameItem, SfxStringItem, SID_FILTER_NAME, sal_False ); + if( pFilterNameItem ) + aFilterName = pFilterNameItem->GetValue(); + if( !m_pData->m_pObjectShell->GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName ) ) + { + // filtername is not valid + delete pMedium; + throw frame::IllegalArgumentIOException(); + } - // load document - if ( !m_pData->m_pObjectShell->DoLoad(pMedium) ) - nError=ERRCODE_IO_GENERAL; + SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSalvageItem, SfxStringItem, SID_DOC_SALVAGE, sal_False ); + sal_Bool bSalvage = pSalvageItem ? sal_True : sal_False; - // QUESTION: if the following happens outside of DoLoad, something important is missing there! - Reference< task::XInteractionHandler > xHandler = pMedium->GetInteractionHandler(); - if( m_pData->m_pObjectShell->GetErrorCode() ) + // load document + if ( !m_pData->m_pObjectShell->DoLoad(pMedium) ) + nError=ERRCODE_IO_GENERAL; + + // QUESTION: if the following happens outside of DoLoad, something important is missing there! + Reference< task::XInteractionHandler > xHandler = pMedium->GetInteractionHandler(); + if( m_pData->m_pObjectShell->GetErrorCode() ) + { + nError = m_pData->m_pObjectShell->GetErrorCode(); + if ( nError == ERRCODE_IO_BROKENPACKAGE && xHandler.is() ) { - nError = m_pData->m_pObjectShell->GetErrorCode(); - if ( nError == ERRCODE_IO_BROKENPACKAGE && xHandler.is() ) + OUString aDocName = pMedium->GetURLObject().getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); + SFX_ITEMSET_ARG( pMedium->GetItemSet(), pRepairItem, SfxBoolItem, SID_REPAIRPACKAGE, sal_False ); + if ( !pRepairItem || !pRepairItem->GetValue() ) { - OUString aDocName = pMedium->GetURLObject().getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); - SFX_ITEMSET_ARG( pMedium->GetItemSet(), pRepairItem, SfxBoolItem, SID_REPAIRPACKAGE, sal_False ); - if ( !pRepairItem || !pRepairItem->GetValue() ) + RequestPackageReparation aRequest( aDocName ); + xHandler->handle( aRequest.GetRequest() ); + if( aRequest.isApproved() ) { - RequestPackageReparation aRequest( aDocName ); - xHandler->handle( aRequest.GetRequest() ); - if( aRequest.isApproved() ) - { - // broken package: try second loading and allow repair - pMedium->GetItemSet()->Put( SfxBoolItem( SID_REPAIRPACKAGE, sal_True ) ); - pMedium->GetItemSet()->Put( SfxBoolItem( SID_TEMPLATE, sal_True ) ); - pMedium->GetItemSet()->Put( SfxStringItem( SID_DOCINFO_TITLE, aDocName ) ); - - // the error must be reset and the storage must be reopened in new mode - pMedium->ResetError(); - pMedium->CloseStorage(); - m_pData->m_pObjectShell->PrepareSecondTryLoad_Impl(); - if ( !m_pData->m_pObjectShell->DoLoad(pMedium) ) - nError=ERRCODE_IO_GENERAL; - nError = m_pData->m_pObjectShell->GetErrorCode(); - } + // broken package: try second loading and allow repair + pMedium->GetItemSet()->Put( SfxBoolItem( SID_REPAIRPACKAGE, sal_True ) ); + pMedium->GetItemSet()->Put( SfxBoolItem( SID_TEMPLATE, sal_True ) ); + pMedium->GetItemSet()->Put( SfxStringItem( SID_DOCINFO_TITLE, aDocName ) ); + + // the error must be reset and the storage must be reopened in new mode + pMedium->ResetError(); + pMedium->CloseStorage(); + m_pData->m_pObjectShell->PrepareSecondTryLoad_Impl(); + if ( !m_pData->m_pObjectShell->DoLoad(pMedium) ) + nError=ERRCODE_IO_GENERAL; + nError = m_pData->m_pObjectShell->GetErrorCode(); } + } - if ( nError == ERRCODE_IO_BROKENPACKAGE ) - { - // repair either not allowed or not successful - NotifyBrokenPackage aRequest( aDocName ); - xHandler->handle( aRequest.GetRequest() ); - } + if ( nError == ERRCODE_IO_BROKENPACKAGE ) + { + // repair either not allowed or not successful + NotifyBrokenPackage aRequest( aDocName ); + xHandler->handle( aRequest.GetRequest() ); } } + } - if( m_pData->m_pObjectShell->IsAbortingImport() ) - nError = ERRCODE_ABORT; + if( m_pData->m_pObjectShell->IsAbortingImport() ) + nError = ERRCODE_ABORT; - if( bSalvage ) - { - // file recovery: restore original filter - SFX_ITEMSET_ARG( pMedium->GetItemSet(), pFilterItem, SfxStringItem, SID_FILTER_NAME, sal_False ); - SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher(); - const SfxFilter* pSetFilter = rMatcher.GetFilter4FilterName( pFilterItem->GetValue() ); - pMedium->SetFilter( pSetFilter ); - m_pData->m_pObjectShell->SetModified(sal_True); - } + if( bSalvage ) + { + // file recovery: restore original filter + SFX_ITEMSET_ARG( pMedium->GetItemSet(), pFilterItem, SfxStringItem, SID_FILTER_NAME, sal_False ); + SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher(); + const SfxFilter* pSetFilter = rMatcher.GetFilter4FilterName( pFilterItem->GetValue() ); + pMedium->SetFilter( pSetFilter ); + m_pData->m_pObjectShell->SetModified(sal_True); + } - // TODO/LATER: may be the mode should be retrieved from outside and the preused filter should not be set - if ( m_pData->m_pObjectShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) - { - SFX_ITEMSET_ARG( pMedium->GetItemSet(), pFilterItem, SfxStringItem, SID_FILTER_NAME, sal_False ); - if ( pFilterItem ) - m_pData->m_aPreusedFilterName = pFilterItem->GetValue(); - } + // TODO/LATER: may be the mode should be retrieved from outside and the preused filter should not be set + if ( m_pData->m_pObjectShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) + { + SFX_ITEMSET_ARG( pMedium->GetItemSet(), pFilterItem, SfxStringItem, SID_FILTER_NAME, sal_False ); + if ( pFilterItem ) + m_pData->m_aPreusedFilterName = pFilterItem->GetValue(); + } - if ( !nError ) - nError = pMedium->GetError(); + if ( !nError ) + nError = pMedium->GetError(); - m_pData->m_pObjectShell->ResetError(); + m_pData->m_pObjectShell->ResetError(); - handleLoadError(nError, pMedium); + handleLoadError(nError, pMedium); - loadCmisProperties( ); + loadCmisProperties( ); - sal_Bool bHidden = sal_False; - SFX_ITEMSET_ARG( pMedium->GetItemSet(), pHidItem, SfxBoolItem, SID_HIDDEN, sal_False); - if ( pHidItem ) - bHidden = pHidItem->GetValue(); + sal_Bool bHidden = sal_False; + SFX_ITEMSET_ARG( pMedium->GetItemSet(), pHidItem, SfxBoolItem, SID_HIDDEN, sal_False); + if ( pHidItem ) + bHidden = pHidItem->GetValue(); #if OSL_DEBUG_LEVEL > 0 - SFX_ITEMSET_ARG( pMedium->GetItemSet(), pPasswdItem, SfxStringItem, SID_PASSWORD, sal_False); - OSL_ENSURE( !pPasswdItem, "There should be no Password property in the document MediaDescriptor!" ); + SFX_ITEMSET_ARG( pMedium->GetItemSet(), pPasswdItem, SfxStringItem, SID_PASSWORD, sal_False); + OSL_ENSURE( !pPasswdItem, "There should be no Password property in the document MediaDescriptor!" ); #endif - // !TODO: will be done by Framework! - pMedium->SetUpdatePickList( !bHidden ); - } + // !TODO: will be done by Framework! + pMedium->SetUpdatePickList( !bHidden ); } //________________________________________________________________________________________________________ |