diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-04 10:22:34 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-04 16:03:21 +0200 |
commit | 3ff4800fe400de916c97f587322104af06cc0879 (patch) | |
tree | 0e7b2d29b6998445da0cec98bd924e5178a4ef60 /sfx2 | |
parent | 265e1305e4f9bf8a4897069a020c9c65e8047f58 (diff) |
weld SvInsertOleDlg
and
weld SfxInsertFloatingFrameDialog
and smuggle in the parent widget for the Gtk File dialog via
an XWindow interface
Change-Id: I971b3a0ffe661c9268115fd5d00bf8eee80e77b3
Reviewed-on: https://gerrit.libreoffice.org/52373
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/shutdownicon.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/dinfdlg.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 76 | ||||
-rw-r--r-- | sfx2/source/dialog/filedlgimpl.hxx | 14 | ||||
-rw-r--r-- | sfx2/source/doc/iframe.cxx | 2 |
5 files changed, 71 insertions, 26 deletions
diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index be129dabac5f..60b279fe2d0a 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -329,7 +329,7 @@ void ShutdownIcon::StartFileDialog() if ( !m_pFileDlg ) m_pFileDlg = new FileDialogHelper( ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION, - FileDialogFlags::MultiSelection, OUString(), SfxFilterFlags::NONE, SfxFilterFlags::NONE, nullptr ); + FileDialogFlags::MultiSelection, OUString(), SfxFilterFlags::NONE, SfxFilterFlags::NONE, static_cast<const vcl::Window*>(nullptr) ); m_pFileDlg->StartExecuteModal( LINK( this, ShutdownIcon, DialogClosedHdl_Impl ) ); } diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index 78d5a3a409a4..d0f87eda0829 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -30,6 +30,7 @@ #include <unotools/useroptions.hxx> #include <svtools/controldims.hxx> #include <svtools/imagemgr.hxx> +#include <toolkit/helper/vclunohelper.hxx> #include <memory> @@ -869,7 +870,7 @@ IMPL_LINK_NOARG(SfxDocumentPage, ChangePassHdl, Button*, void) if (!pFilter) break; - sfx2::RequestPassword(pFilter, OUString(), pMedSet, GetParentDialog()); + sfx2::RequestPassword(pFilter, OUString(), pMedSet, VCLUnoHelper::GetInterface(GetParentDialog())); pShell->SetModified(); } while (false); diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 8c2e0ecc4175..c8f2ad762e85 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -847,12 +847,22 @@ static open_or_save_t lcl_OpenOrSave(sal_Int16 const nDialogType) // FileDialogHelper_Impl +css::uno::Reference<css::awt::XWindow> FileDialogHelper_Impl::GetFrameInterface() +{ + if (mpFrameWeld) + return mpFrameWeld->GetXWindow(); + if (mpPreferredParentWindow) + return VCLUnoHelper::GetInterface(mpPreferredParentWindow); + return css::uno::Reference<css::awt::XWindow>(); +} + FileDialogHelper_Impl::FileDialogHelper_Impl( FileDialogHelper* _pAntiImpl, sal_Int16 nDialogType, FileDialogFlags nFlags, sal_Int16 nDialog, - const vcl::Window* _pPreferredParentWindow, + const vcl::Window* pPreferredParentWindow, + weld::Window* pFrameWeld, const OUString& sStandardDir, const css::uno::Sequence< OUString >& rBlackList ) @@ -881,7 +891,8 @@ FileDialogHelper_Impl::FileDialogHelper_Impl( // create the file open dialog // the flags can be SFXWB_INSERT or SFXWB_MULTISELECTION - mpPreferredParentWindow = _pPreferredParentWindow ? _pPreferredParentWindow->GetSystemWindow() : nullptr; + mpPreferredParentWindow = pPreferredParentWindow ? pPreferredParentWindow->GetSystemWindow() : nullptr; + mpFrameWeld = pFrameWeld; mpAntiImpl = _pAntiImpl; mbHasAutoExt = false; mbHasPassword = false; @@ -1035,7 +1046,9 @@ FileDialogHelper_Impl::FileDialogHelper_Impl( maPreviewIdle.SetInvokeHandler( LINK( this, FileDialogHelper_Impl, TimeOutHdl_Impl ) ); } - Sequence < Any > aInitArguments( !mpPreferredParentWindow ? 3 : 4 ); + auto xWindow = GetFrameInterface(); + + Sequence < Any > aInitArguments(!xWindow.is() ? 3 : 4); // This is a hack. We currently know that the internal file picker implementation // supports the extended arguments as specified below. @@ -1045,8 +1058,8 @@ FileDialogHelper_Impl::FileDialogHelper_Impl( if ( mbSystemPicker ) { aInitArguments[0] <<= nTemplateDescription; - if ( mpPreferredParentWindow ) - aInitArguments[1] <<= VCLUnoHelper::GetInterface( mpPreferredParentWindow ); + if (xWindow.is()) + aInitArguments[1] <<= xWindow; } else { @@ -1066,11 +1079,8 @@ FileDialogHelper_Impl::FileDialogHelper_Impl( ); - if ( mpPreferredParentWindow ) - aInitArguments[3] <<= NamedValue( - "ParentWindow", - makeAny( VCLUnoHelper::GetInterface( mpPreferredParentWindow ) ) - ); + if (xWindow.is()) + aInitArguments[3] <<= NamedValue("ParentWindow", makeAny(xWindow)); } try @@ -1513,7 +1523,7 @@ ErrCode FileDialogHelper_Impl::execute( std::vector<OUString>& rpURLList, { // ask for a password OUString aDocName(rpURLList[0]); - ErrCode errCode = RequestPassword(pCurrentFilter, aDocName, rpSet, mpPreferredParentWindow); + ErrCode errCode = RequestPassword(pCurrentFilter, aDocName, rpSet, GetFrameInterface()); if (errCode != ERRCODE_NONE) return errCode; } @@ -1540,7 +1550,7 @@ ErrCode FileDialogHelper_Impl::execute( std::vector<OUString>& rpURLList, } catch( const IllegalArgumentException& ) { - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(mpPreferredParentWindow ? mpPreferredParentWindow->GetFrameWeld() : nullptr, + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, SfxResId(RID_SVXSTR_GPG_ENCRYPT_FAILURE))); xBox->run(); @@ -2274,9 +2284,25 @@ FileDialogHelper::FileDialogHelper( const OUString& rFact, SfxFilterFlags nMust, SfxFilterFlags nDont, - const vcl::Window* _pPreferredParent) + const vcl::Window* pPreferredParent) + : m_nError(0), + mpImpl(new FileDialogHelper_Impl(this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, pPreferredParent, nullptr)) +{ + + // create the list of filters + mpImpl->addFilters( + SfxObjectShell::GetServiceNameFromFactory(rFact), nMust, nDont ); +} + +FileDialogHelper::FileDialogHelper( + sal_Int16 nDialogType, + FileDialogFlags nFlags, + const OUString& rFact, + SfxFilterFlags nMust, + SfxFilterFlags nDont, + weld::Window* pPreferredParent) : m_nError(0), - mpImpl(new FileDialogHelper_Impl(this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, _pPreferredParent)) + mpImpl(new FileDialogHelper_Impl(this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, nullptr, pPreferredParent)) { // create the list of filters @@ -2293,9 +2319,9 @@ FileDialogHelper::FileDialogHelper( SfxFilterFlags nDont, const OUString& rStandardDir, const css::uno::Sequence< OUString >& rBlackList, - const vcl::Window* _pPreferredParent) + const vcl::Window* pPreferredParent) : m_nError(0), - mpImpl( new FileDialogHelper_Impl( this, nDialogType, nFlags, nDialog, _pPreferredParent, rStandardDir, rBlackList ) ) + mpImpl( new FileDialogHelper_Impl( this, nDialogType, nFlags, nDialog, pPreferredParent, nullptr, rStandardDir, rBlackList ) ) { // create the list of filters mpImpl->addFilters( @@ -2305,9 +2331,15 @@ FileDialogHelper::FileDialogHelper( FileDialogHelper::FileDialogHelper( sal_Int16 nDialogType, FileDialogFlags nFlags, - const vcl::Window* _pPreferredParent ) + const vcl::Window* pPreferredParent ) + : m_nError(0), + mpImpl( new FileDialogHelper_Impl( this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, pPreferredParent, nullptr ) ) +{ +} + +FileDialogHelper::FileDialogHelper(sal_Int16 nDialogType, FileDialogFlags nFlags, weld::Window* pPreferredParent) : m_nError(0), - mpImpl( new FileDialogHelper_Impl( this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, _pPreferredParent ) ) + mpImpl( new FileDialogHelper_Impl( this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, nullptr, pPreferredParent ) ) { } @@ -2318,9 +2350,9 @@ FileDialogHelper::FileDialogHelper( const OUString& aExtName, const OUString& rStandardDir, const css::uno::Sequence< OUString >& rBlackList, - const vcl::Window* _pPreferredParent ) + const vcl::Window* pPreferredParent ) : m_nError(0), - mpImpl( new FileDialogHelper_Impl( this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, _pPreferredParent,rStandardDir, rBlackList ) ) + mpImpl( new FileDialogHelper_Impl( this, nDialogType, nFlags, SFX2_IMPL_DIALOG_CONFIG, pPreferredParent, nullptr, rStandardDir, rBlackList ) ) { // the wildcard here is expected in form "*.extension" OUString aWildcard; @@ -2662,9 +2694,9 @@ ErrCode FileOpenDialog_Impl( const vcl::Window* pParent, return nRet; } -ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, OUString const & aURL, SfxItemSet* pSet, vcl::Window* pPreferredParentWindow) +ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter, OUString const & aURL, SfxItemSet* pSet, const css::uno::Reference<css::awt::XWindow>& rParent) { - uno::Reference<task::XInteractionHandler2> xInteractionHandler = task::InteractionHandler::createWithParent(::comphelper::getProcessComponentContext(), VCLUnoHelper::GetInterface(pPreferredParentWindow)); + uno::Reference<task::XInteractionHandler2> xInteractionHandler = task::InteractionHandler::createWithParent(::comphelper::getProcessComponentContext(), rParent); // TODO: need a save way to distinguish MS filters from other filters // for now MS-filters are the only alien filters that support encryption bool bMSType = !pCurrentFilter->IsOwnFormat(); diff --git a/sfx2/source/dialog/filedlgimpl.hxx b/sfx2/source/dialog/filedlgimpl.hxx index 38a894e0d42e..0d7de0b2cf22 100644 --- a/sfx2/source/dialog/filedlgimpl.hxx +++ b/sfx2/source/dialog/filedlgimpl.hxx @@ -53,6 +53,7 @@ namespace sfx2 std::unique_ptr<GraphicFilter> mpGraphicFilter; FileDialogHelper* mpAntiImpl; VclPtr<vcl::Window> mpPreferredParentWindow; + weld::Window* mpFrameWeld; ::std::vector< OUString > mlLastURLs; @@ -171,7 +172,7 @@ namespace sfx2 const short nDialogType, FileDialogFlags nFlags, sal_Int16 nDialog, - const vcl::Window* _pPreferredParentWindow, + const vcl::Window* _pPreferredParentWindow, weld::Window* pFrameWeld, const OUString& sStandardDir = OUString(), const css::uno::Sequence< OUString >& rBlackList = css::uno::Sequence< OUString >() ); @@ -209,6 +210,17 @@ namespace sfx2 bool isSystemFilePicker() const { return mbSystemPicker; } bool isPasswordEnabled() const { return mbIsPwdEnabled; } + + weld::Window* GetFrameWeld() + { + if (mpFrameWeld) + return mpFrameWeld; + if (mpPreferredParentWindow) + return mpPreferredParentWindow->GetFrameWeld(); + return nullptr; + } + + css::uno::Reference<css::awt::XWindow> GetFrameInterface(); }; } // end of namespace sfx2 diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx index 5a05e36aeec4..ccc726dbc865 100644 --- a/sfx2/source/doc/iframe.cxx +++ b/sfx2/source/doc/iframe.cxx @@ -393,7 +393,7 @@ void SAL_CALL IFrameObject::removeVetoableChangeListener(const OUString&, const ::sal_Int16 SAL_CALL IFrameObject::execute() { SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); - ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateEditObjectDialog( ".uno:InsertObjectFloatingFrame", mxObj )); + ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateEditObjectDialog(nullptr, ".uno:InsertObjectFloatingFrame", mxObj)); //TODO if ( pDlg ) pDlg->Execute(); return 0; |