include/sfx2/docinsert.hxx | 2 +- sfx2/source/doc/docinsert.cxx | 16 ++++++++++------ sw/source/ui/dialog/uiregionsw.cxx | 4 ++-- sw/source/uibase/app/docsh2.cxx | 4 +++- 4 files changed, 16 insertions(+), 10 deletions(-)
New commits: commit e0d373bf5328bfe84079f094dd605bb8f4337330 Author: Michael Stahl <[email protected]> Date: Thu Oct 6 15:50:13 2016 +0200 tdf#101813 sw,sfx2: enable inserting master document as section Traditionally only ordinary com.sun.star.text.TextDocument could be inserted as a section but then commit 3da8f3680556e0163f660a0a159930337c8c32ff unintentionally enabled inserting everything, including master documents (com.sun.star.text.GlobalDocument). I'm really not sure if this should be allowed or not but apparently somebody finds it useful so here we add some crude hacks to enable it (to be reverted in case it causes trouble). (regression? from 805fd1ca343d6295b8114a24cc29bdac332f266d) Change-Id: I439b2516fcbe54977ff04e487a920acd38c27152 diff --git a/include/sfx2/docinsert.hxx b/include/sfx2/docinsert.hxx index 5d6ea0a..abd448d 100644 --- a/include/sfx2/docinsert.hxx +++ b/include/sfx2/docinsert.hxx @@ -57,7 +57,7 @@ public: ~DocumentInserter(); void StartExecuteModal( const Link<sfx2::FileDialogHelper*,void>& _rDialogClosedLink ); - SfxMedium* CreateMedium(); + SfxMedium* CreateMedium(char const* pFallbackHack = 0); SfxMediumList* CreateMediumList(); }; diff --git a/sfx2/source/doc/docinsert.cxx b/sfx2/source/doc/docinsert.cxx index 4ef731a..d1f0382 100644 --- a/sfx2/source/doc/docinsert.cxx +++ b/sfx2/source/doc/docinsert.cxx @@ -79,7 +79,7 @@ void DocumentInserter::StartExecuteModal( const Link<sfx2::FileDialogHelper*,voi m_pFileDlg->StartExecuteModal( LINK( this, DocumentInserter, DialogClosedHdl ) ); } -SfxMedium* DocumentInserter::CreateMedium() +SfxMedium* DocumentInserter::CreateMedium(char const*const pFallbackHack) { std::unique_ptr<SfxMedium> pMedium; if (!m_nError && m_pItemSet && !m_pURLList.empty()) @@ -90,14 +90,20 @@ SfxMedium* DocumentInserter::CreateMedium() sURL, SFX_STREAM_READONLY, SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), m_pItemSet )); pMedium->UseInteractionHandler( true ); - SfxFilterMatcher* pMatcher = nullptr; + std::unique_ptr<SfxFilterMatcher> pMatcher; if ( !m_sDocFactory.isEmpty() ) - pMatcher = new SfxFilterMatcher( m_sDocFactory ); + pMatcher.reset(new SfxFilterMatcher(m_sDocFactory)); else - pMatcher = new SfxFilterMatcher(); + pMatcher.reset(new SfxFilterMatcher()); std::shared_ptr<const SfxFilter> pFilter; sal_uInt32 nError = pMatcher->DetectFilter( *pMedium, pFilter ); + // tdf#101813 hack: check again if it's a global document + if (ERRCODE_NONE != nError && pFallbackHack) + { + pMatcher.reset(new SfxFilterMatcher(OUString::createFromAscii(pFallbackHack))); + nError = pMatcher->DetectFilter( *pMedium, pFilter ); + } if ( nError == ERRCODE_NONE && pFilter ) pMedium->SetFilter( pFilter ); else @@ -105,8 +111,6 @@ SfxMedium* DocumentInserter::CreateMedium() if ( pMedium && CheckPasswd_Impl( nullptr, SfxGetpApp()->GetPool(), pMedium.get() ) == ERRCODE_ABORT ) pMedium.reset(); - - DELETEZ( pMatcher ); } return pMedium.release(); diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx index 51f1c74..496654a 100644 --- a/sw/source/ui/dialog/uiregionsw.cxx +++ b/sw/source/ui/dialog/uiregionsw.cxx @@ -1316,7 +1316,7 @@ IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, v OUString sFileName, sFilterName, sPassword; if ( _pFileDlg->GetError() == ERRCODE_NONE ) { - std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium()); + std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal")); if ( pMedium ) { sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); @@ -1783,7 +1783,7 @@ IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFil { if ( _pFileDlg->GetError() == ERRCODE_NONE ) { - std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium()); + std::unique_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium("sglobal")); if ( pMedium ) { m_sFileName = pMedium->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index 92c6b1b..8b5a6d9 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -1574,7 +1574,9 @@ int SwFindDocShell( SfxObjectShellRef& xDocSh, std::shared_ptr<const SfxFilter> pSfxFlt; if (!xMed->GetError()) { - SfxFilterMatcher aMatcher( OUString::createFromAscii(SwDocShell::Factory().GetShortName()) ); + SfxFilterMatcher aMatcher( rFilter == "writerglobal8" + ? OUString::createFromAscii(SwGlobalDocShell::Factory().GetShortName()) + : OUString::createFromAscii(SwDocShell::Factory().GetShortName()) ); // No Filter, so search for it. Else test if the one passed is a valid one if( !rFilter.isEmpty() ) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
