/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace ::com::sun::star; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::ui::dialogs; using namespace ::com::sun::star::uno; using namespace ::cppu; static const char* SvxOpenGrfErr2ResId( ErrCode err ) { if (err == ERRCODE_GRFILTER_OPENERROR) return RID_SVXSTR_GRFILTER_OPENERROR; else if (err == ERRCODE_GRFILTER_IOERROR) return RID_SVXSTR_GRFILTER_IOERROR; else if (err == ERRCODE_GRFILTER_VERSIONERROR) return RID_SVXSTR_GRFILTER_VERSIONERROR; else if (err == ERRCODE_GRFILTER_FILTERERROR) return RID_SVXSTR_GRFILTER_FILTERERROR; else return RID_SVXSTR_GRFILTER_FORMATERROR; } struct SvxOpenGrf_Impl { SvxOpenGrf_Impl(weld::Window* pPreferredParent, sal_Int16 nDialogType); sfx2::FileDialogHelper aFileDlg; OUString sDetectedFilter; uno::Reference < XFilePickerControlAccess > xCtrlAcc; }; SvxOpenGrf_Impl::SvxOpenGrf_Impl(weld::Window* pPreferredParent, sal_Int16 nDialogType) : aFileDlg(nDialogType, FileDialogFlags::Graphic, pPreferredParent) { uno::Reference < XFilePicker3 > xFP = aFileDlg.GetFilePicker(); xCtrlAcc.set(xFP, UNO_QUERY); } SvxOpenGraphicDialog::SvxOpenGraphicDialog(const OUString& rTitle, weld::Window* pPreferredParent) : mpImpl(new SvxOpenGrf_Impl(pPreferredParent, ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW)) { mpImpl->aFileDlg.SetTitle(rTitle); } SvxOpenGraphicDialog::SvxOpenGraphicDialog(const OUString& rTitle, weld::Window* pPreferredParent, sal_Int16 nDialogType) : mpImpl(new SvxOpenGrf_Impl(pPreferredParent, nDialogType)) { mpImpl->aFileDlg.SetTitle(rTitle); } SvxOpenGraphicDialog::~SvxOpenGraphicDialog() { } ErrCode SvxOpenGraphicDialog::Execute() { ErrCode nImpRet; bool bQuitLoop(false); while( !bQuitLoop && mpImpl->aFileDlg.Execute() == ERRCODE_NONE ) { if( !GetPath().isEmpty() ) { GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); INetURLObject aObj( GetPath() ); // check whether we can load the graphic OUString aCurFilter( GetCurrentFilter() ); sal_uInt16 nFormatNum = rFilter.GetImportFormatNumber( aCurFilter ); sal_uInt16 nRetFormat = 0; sal_uInt16 nFound = USHRT_MAX; // non-local? if ( INetProtocol::File != aObj.GetProtocol() ) { SfxMedium aMed( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ); aMed.Download(); SvStream* pStream = aMed.GetInStream(); if( pStream ) nImpRet = rFilter.CanImportGraphic( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), *pStream, nFormatNum, &nRetFormat ); else nImpRet = rFilter.CanImportGraphic( aObj, nFormatNum, &nRetFormat ); if ( ERRCODE_NONE != nImpRet ) { if ( !pStream ) nImpRet = rFilter.CanImportGraphic( aObj, GRFILTER_FORMAT_DONTKNOW, &nRetFormat ); else nImpRet = rFilter.CanImportGraphic( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), *pStream, GRFILTER_FORMAT_DONTKNOW, &nRetFormat ); } } else { if( (nImpRet=rFilter.CanImportGraphic( aObj, nFormatNum, &nRetFormat )) != ERRCODE_NONE ) nImpRet = rFilter.CanImportGraphic( aObj, GRFILTER_FORMAT_DONTKNOW, &nRetFormat ); } if ( ERRCODE_NONE == nImpRet ) nFound = nRetFormat; // could not load? if ( nFound == USHRT_MAX ) { std::unique_ptr xWarn(Application::CreateMessageDialog(nullptr, VclMessageType::Warning, VclButtonsType::NONE, SfxResId(SvxOpenGrfErr2ResId(nImpRet)))); xWarn->add_button(GetStandardText(StandardButtonType::Retry), RET_RETRY); xWarn->add_button(GetStandardText(StandardButtonType::Cancel), RET_CANCEL); bQuitLoop = xWarn->run() != RET_RETRY; } else { if( rFilter.GetImportFormatCount() ) { // store detected appropriate filter OUString aFormatName(rFilter.GetImportFormatName(nFound)); SetDetectedFilter(aFormatName); } else { SetDetectedFilter(mpImpl->aFileDlg.GetCurrentFilter()); } return nImpRet; } } } // cancel return ErrCode(sal_uInt32(-1)); } void SvxOpenGraphicDialog::SetPath( const OUString& rPath, bool bLinkState ) { mpImpl->aFileDlg.SetDisplayDirectory(rPath); AsLink(bLinkState); } void SvxOpenGraphicDialog::EnableLink( bool state ) { if( !mpImpl->xCtrlAcc.is() ) return; try { mpImpl->xCtrlAcc->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK, state ); } catch(const IllegalArgumentException&) { #ifdef DBG_UTIL OSL_FAIL( "Cannot enable \"link\" checkbox" ); #endif } } void SvxOpenGraphicDialog::AsLink(bool bState) { if( !mpImpl->xCtrlAcc.is() ) return; try { mpImpl->xCtrlAcc->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, Any(bState) ); } catch(const IllegalArgumentException&) { #ifdef DBG_UTIL OSL_FAIL( "Cannot check \"link\" checkbox" ); #endif } } bool SvxOpenGraphicDialog::IsAsLink() const { try { if( mpImpl->xCtrlAcc.is() ) { Any aVal = mpImpl->xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0 ); DBG_ASSERT(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found"); return aVal.hasValue() && *o3tl::doAccess(aVal); } } catch(const IllegalArgumentException&) { #ifdef DBG_UTIL OSL_FAIL( "Cannot access \"link\" checkbox" ); #endif } return false; } ErrCode SvxOpenGraphicDialog::GetGraphic(Graphic& rGraphic) const { return mpImpl->aFileDlg.GetGraphic(rGraphic); } OUString SvxOpenGraphicDialog::GetPath() const { return mpImpl->aFileDlg.GetPath(); } OUString SvxOpenGraphicDialog::GetCurrentFilter() const { return mpImpl->aFileDlg.GetCurrentFilter(); } OUString const & SvxOpenGraphicDialog::GetDetectedFilter() const { return mpImpl->sDetectedFilter; } void SvxOpenGraphicDialog::SetCurrentFilter(const OUString& rStr) { mpImpl->aFileDlg.SetCurrentFilter(rStr); } void SvxOpenGraphicDialog::SetDetectedFilter(const OUString& rStr) { mpImpl->sDetectedFilter = rStr; } Reference const & SvxOpenGraphicDialog::GetFilePickerControlAccess() const { return mpImpl->xCtrlAcc; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 24.2-release LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-12-15ucb: remove --with-webdav=neonMichael Stahl
Remove code in ucb/source/ucp/webdav-neon, and now unused external neon. The --with-webdav=no option is retained for now. Change-Id: I4ce429587e3991fa82009da2f8e4a068abe36435 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126839 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2019-07-21tdf#125922 rename kde5 to kf5 + plasma5Jan-Marek Glogowski
Just as the gtk3 plugin isn't named GNOME, rename kde5 to kf5, as it is based on the KDE frameworks 5 libraries. This also includes: * a convenience alias to load the kf5 VCL plugin in case someone requests the kde5 plugin. * keep convenience kde5 configure switch, but warn about it * rename detected desktop from kde5 to plasma5 Change-Id: I6764a05b81a5edbf284484c234fee2649aacf735 Reviewed-on: https://gerrit.libreoffice.org/75313 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2019-06-06distro-config: Drop '--enable-gstreamer-0-10' everywhereMichael Weghorn
This avoids the issue that build breaks when both gtk3 and gstreamer-0.10 are enabled, caused by commit 34bbf192a7753205bb64d14e4eec4ce303317396 ("Drop extra define ENABLE_GTKSINK"). gstreamer-0.10 related code will be removed in a subsequent step according to ESC decision (no longer needed). Change-Id: Ief07a797a3e52229da0ff7b23478108aac900841 Reviewed-on: https://gerrit.libreoffice.org/73608 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2018-12-17kde5: remove older kde/tde plugins, and references to thatThorsten Behrens
KDE4 is out of maintenance upstream since Nov. 2014, and binaries provided by TDF have switched to KDE5 as the official backend. Change-Id: I165465b56d3ba3a18912b203c06ae8fc6111c0c9 Reviewed-on: https://gerrit.libreoffice.org/60014 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>