summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-04-11 00:18:40 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-04-13 01:54:38 -0400
commitb894370445ce740c8a416aa04f88431d158b4f74 (patch)
tree7e7c41eaa8b9ca4f14f0ffe3c6ac66485113875f /sfx2
parentddd2a00ef18e7c8865dc5888d54f99d08aa4063f (diff)
Share error handling code between DoLoad() and DoLoadExternal().
Change-Id: I34167b80e9ac31b32639cd3be903ba9edbdfa41a
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sfx2/sfxbasemodel.hxx3
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx78
2 files changed, 44 insertions, 37 deletions
diff --git a/sfx2/inc/sfx2/sfxbasemodel.hxx b/sfx2/inc/sfx2/sfxbasemodel.hxx
index 9c15b500cd79..524c86b0b99d 100644
--- a/sfx2/inc/sfx2/sfxbasemodel.hxx
+++ b/sfx2/inc/sfx2/sfxbasemodel.hxx
@@ -91,6 +91,7 @@
#include <svl/lstner.hxx>
+class SfxMedium;
class SfxPrinter;
class SfxViewShell;
class SfxObjectShell ;
@@ -1456,6 +1457,8 @@ private:
SAL_DLLPRIVATE void loadCmisProperties();
+ SAL_DLLPRIVATE void handleLoadError( sal_uInt32 nError, SfxMedium* pMedium );
+
//________________________________________________________________________________________________________
// private variables and methods
//________________________________________________________________________________________________________
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index c84e2ad75eb3..5b28cc23b589 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1851,15 +1851,14 @@ void SAL_CALL SfxBaseModel::load( const Sequence< beans::PropertyValue >& seqA
SfxMedium* pMedium = new SfxMedium( seqArguments );
+ sal_uInt32 nError = ERRCODE_NONE;
OUString aFilterProvider = getFilterProvider(seqArguments);
if (!aFilterProvider.isEmpty())
{
if (!m_pData->m_pObjectShell->DoLoadExternal(pMedium))
- {
- throw task::ErrorCodeIOException(
- OUString(), Reference<XInterface>(), ERRCODE_IO_CANTREAD);
- }
+ nError = ERRCODE_IO_GENERAL;
+ handleLoadError(nError, pMedium);
pMedium->SetUpdatePickList(false);
return;
}
@@ -1879,7 +1878,6 @@ void SAL_CALL SfxBaseModel::load( const Sequence< beans::PropertyValue >& seqA
sal_Bool bSalvage = pSalvageItem ? sal_True : sal_False;
// load document
- sal_uInt32 nError = ERRCODE_NONE;
if ( !m_pData->m_pObjectShell->DoLoad(pMedium) )
nError=ERRCODE_IO_GENERAL;
@@ -1948,38 +1946,7 @@ void SAL_CALL SfxBaseModel::load( const Sequence< beans::PropertyValue >& seqA
m_pData->m_pObjectShell->ResetError();
- if ( nError )
- {
- sal_Bool bSilent = sal_False;
- SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSilentItem, SfxBoolItem, SID_SILENT, sal_False);
- if( pSilentItem )
- bSilent = pSilentItem->GetValue();
-
- sal_Bool bWarning = ((nError & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK);
- if ( nError != ERRCODE_IO_BROKENPACKAGE && !bSilent )
- {
- // broken package was handled already
- if ( SfxObjectShell::UseInteractionToHandleError( xHandler, nError ) && !bWarning )
- {
- // abort loading (except for warnings)
- nError = ERRCODE_IO_ABORT;
- }
- }
-
- if ( m_pData->m_pObjectShell->GetMedium() != pMedium )
- {
- // for whatever reason document now has another medium
- OSL_FAIL("Document has rejected the medium?!");
- delete pMedium;
- }
-
- if ( !bWarning ) // #i30711# don't abort loading if it's only a warning
- {
- throw task::ErrorCodeIOException( OUString(),
- Reference< XInterface >(),
- nError ? nError : ERRCODE_IO_CANTREAD );
- }
- }
+ handleLoadError(nError, pMedium);
loadCmisProperties( );
@@ -2711,6 +2678,43 @@ void SfxBaseModel::loadCmisProperties( )
}
}
+void SfxBaseModel::handleLoadError( sal_uInt32 nError, SfxMedium* pMedium )
+{
+ if (!nError)
+ // No error condition.
+ return;
+
+ bool bSilent = false;
+ SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSilentItem, SfxBoolItem, SID_SILENT, false);
+ if( pSilentItem )
+ bSilent = pSilentItem->GetValue();
+
+ bool bWarning = ((nError & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK);
+ if ( nError != ERRCODE_IO_BROKENPACKAGE && !bSilent )
+ {
+ // broken package was handled already
+ if ( SfxObjectShell::UseInteractionToHandleError(pMedium->GetInteractionHandler(), nError) && !bWarning)
+ {
+ // abort loading (except for warnings)
+ nError = ERRCODE_IO_ABORT;
+ }
+ }
+
+ if ( m_pData->m_pObjectShell->GetMedium() != pMedium )
+ {
+ // for whatever reason document now has another medium
+ OSL_FAIL("Document has rejected the medium?!");
+ delete pMedium;
+ }
+
+ if ( !bWarning ) // #i30711# don't abort loading if it's only a warning
+ {
+ throw task::ErrorCodeIOException( OUString(),
+ Reference< XInterface >(),
+ nError ? nError : ERRCODE_IO_CANTREAD );
+ }
+}
+
//________________________________________________________________________________________________________
// SfxListener
//________________________________________________________________________________________________________