diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-07-27 22:14:39 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-09-07 09:10:34 -0400 |
commit | a6639312005763d19e877bc61e6a844c09f5fb23 (patch) | |
tree | a955fe459e1eb82957100dd1c397ee3a31c32fdd /sfx2 | |
parent | WaE: member init order (diff) | |
download | core-a6639312005763d19e877bc61e6a844c09f5fb23.tar.gz core-a6639312005763d19e877bc61e6a844c09f5fb23.zip |
First cut on integrating liborcus into libreoffice tree....
It introduces the 'FilterProvider' property in the media descriptor
to optionally bypass the normal loading process and let the external
filter provider to handle the loading.
For now I'm overwriting the csv import filter just to see how this
could work just as an experiment.
Orcus still needs a lot of work, and it crashes very often at the
moment.
Change-Id: I11b34572c71073144804a7d0dd5176c8067d8deb
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/objsh.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 12 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 31 | ||||
-rw-r--r-- | sfx2/source/view/frmload.cxx | 4 |
4 files changed, 45 insertions, 4 deletions
diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 4b1c16bc2970..331553db46a4 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -294,6 +294,7 @@ public: sal_Bool DoInitNew( SfxMedium* pMedium=0 ); sal_Bool DoLoad( SfxMedium* pMedium ); + bool DoLoadExternal(SfxMedium* pMed, const rtl::OUString& rProvider); sal_Bool DoSave(); sal_Bool DoSaveAs( SfxMedium &rNewStor ); sal_Bool DoSaveObjectAs( SfxMedium &rNewStor, sal_Bool bCommit ); @@ -314,6 +315,7 @@ public: virtual sal_Bool SwitchPersistance( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); virtual void UpdateLinks(); + virtual bool LoadExternal(SfxMedium& rMedium, const rtl::OUString& rProvider); /** * Called when the Options dialog is dismissed with the OK button, to * handle potentially conflicting option settings. diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index e3ffae4bca9f..bebe6b0bb823 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -821,6 +821,12 @@ sal_Bool SfxObjectShell::DoLoad( SfxMedium *pMed ) return bOk; } +bool SfxObjectShell::DoLoadExternal(SfxMedium *pMed, const OUString& rProvider) +{ + pMedium = pMed; + return LoadExternal(*pMedium, rProvider); +} + sal_uInt32 SfxObjectShell::HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDoc ) { sal_uInt32 nError = ERRCODE_NONE; @@ -3511,6 +3517,12 @@ void SfxObjectShell::UpdateLinks() { } +bool SfxObjectShell::LoadExternal(SfxMedium&, const OUString&) +{ + // Not implemented. It's an error if the code path ever comes here. + return false; +} + void SfxObjectShell::CheckConfigOptions() { // not handled. Each app's shell needs to overwrite this method to add handler. diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 75bf08b627c1..b2b6e20439e6 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -1831,9 +1831,23 @@ void SAL_CALL SfxBaseModel::initNew() } } -//________________________________________________________________________________________________________ -// XLoadable -//________________________________________________________________________________________________________ +namespace { + +OUString getFilterProvider(const uno::Sequence<beans::PropertyValue>& rArgs) +{ + OUString aStr; + for (sal_Int32 i = 0, n = rArgs.getLength(); i < n; ++i) + { + if (rArgs[i].Name == "FilterProvider") + { + rArgs[i].Value >>= aStr; + return aStr; + } + } + return aStr; +} + +} void SAL_CALL SfxBaseModel::load( const uno::Sequence< beans::PropertyValue >& seqArguments ) throw (::com::sun::star::frame::DoubleInitializationException, @@ -1855,6 +1869,17 @@ void SAL_CALL SfxBaseModel::load( const uno::Sequence< beans::PropertyValue >& throw frame::DoubleInitializationException(); SfxMedium* pMedium = new SfxMedium( seqArguments ); + + OUString aFilterProvider = getFilterProvider(seqArguments); + if (!aFilterProvider.isEmpty()) + { + if (!m_pData->m_pObjectShell->DoLoadExternal(pMedium, aFilterProvider)) + delete pMedium; + + pMedium->SetUpdatePickList(false); + return; + } + String aFilterName; SFX_ITEMSET_ARG( pMedium->GetItemSet(), pFilterNameItem, SfxStringItem, SID_FILTER_NAME, sal_False ); if( pFilterNameItem ) diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index 61ab9f35a113..e213986706dd 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -519,6 +519,8 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA ::comphelper::NamedValueCollection aDescriptor( rArgs ); + bool bLoadWithOrcus = aDescriptor.getOrDefault<OUString>("FilterProvider", OUString()) == "orcus"; + // ensure the descriptor contains a referrer if ( !aDescriptor.has( "Referer" ) ) aDescriptor.put( "Referer", ::rtl::OUString() ); @@ -577,7 +579,7 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA if ( !xModel.is() ) { // beforehand, determine the filter to use, and update the descriptor with its information - if ( !bInitNewModel ) + if ( !bInitNewModel && !bLoadWithOrcus ) { impl_determineFilter( aDescriptor ); } |