From e9dad737b086537803210987ccbd9a59651c4613 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 18 Oct 2019 16:43:47 +0200 Subject: Simplify MediaWindow::getMediaFilters Change-Id: I6c2ed432d2d5472ec984ea6e48aa3435c464067f Reviewed-on: https://gerrit.libreoffice.org/81053 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- avmedia/source/viewer/mediawindow.cxx | 69 +++++++++++++++-------------------- cui/source/dialogs/cuigaldlg.cxx | 3 +- include/avmedia/mediawindow.hxx | 2 +- 3 files changed, 31 insertions(+), 43 deletions(-) diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx index 81b8d968a36e..521c4151f98f 100644 --- a/avmedia/source/viewer/mediawindow.cxx +++ b/avmedia/source/viewer/mediawindow.cxx @@ -173,41 +173,34 @@ vcl::Window* MediaWindow::getWindow() const } -void MediaWindow::getMediaFilters( FilterNameVector& rFilterNameVector ) +FilterNameVector MediaWindow::getMediaFilters() { - static const char* pFilters[] = { "Advanced Audio Coding", "aac", - "AIF Audio", "aif;aiff", - "Advanced Systems Format", "asf;wma;wmv", - "AU Audio", "au", - "AC3 Audio", "ac3", - "AVI", "avi", - "CD Audio", "cda", - "Digital Video", "dv", - "FLAC Audio", "flac", - "Flash Video", "flv", - "Matroska Media", "mkv", - "MIDI Audio", "mid;midi", - "MPEG Audio", "mp2;mp3;mpa;m4a", - "MPEG Video", "mpg;mpeg;mpv;mp4;m4v", - "Ogg Audio", "ogg;oga;opus", - "Ogg Video", "ogv;ogx", - "Real Audio", "ra", - "Real Media", "rm", - "RMI MIDI Audio", "rmi", - "SND (SouND) Audio", "snd", - "Quicktime Video", "mov", - "Vivo Video", "viv", - "WAVE Audio", "wav", - "WebM Video", "webm", - "Windows Media Audio", "wma", - "Windows Media Video", "wmv"}; - - for( size_t i = 0; i < SAL_N_ELEMENTS(pFilters); i += 2 ) - { - rFilterNameVector.push_back( std::make_pair< OUString, OUString >( - OUString::createFromAscii(pFilters[i]), - OUString::createFromAscii(pFilters[i+1]) ) ); - } + return {{"Advanced Audio Coding", "aac"}, + {"AIF Audio", "aif;aiff"}, + {"Advanced Systems Format", "asf;wma;wmv"}, + {"AU Audio", "au"}, + {"AC3 Audio", "ac3"}, + {"AVI", "avi"}, + {"CD Audio", "cda"}, + {"Digital Video", "dv"}, + {"FLAC Audio", "flac"}, + {"Flash Video", "flv"}, + {"Matroska Media", "mkv"}, + {"MIDI Audio", "mid;midi"}, + {"MPEG Audio", "mp2;mp3;mpa;m4a"}, + {"MPEG Video", "mpg;mpeg;mpv;mp4;m4v"}, + {"Ogg Audio", "ogg;oga;opus"}, + {"Ogg Video", "ogv;ogx"}, + {"Real Audio", "ra"}, + {"Real Media", "rm"}, + {"RMI MIDI Audio", "rmi"}, + {"SND (SouND) Audio", "snd"}, + {"Quicktime Video", "mov"}, + {"Vivo Video", "viv"}, + {"WAVE Audio", "wav"}, + {"WebM Video", "webm"}, + {"Windows Media Audio", "wma"}, + {"Windows Media Video", "wmv"}}; } @@ -218,15 +211,13 @@ bool MediaWindow::executeMediaURLDialog(weld::Window* pParent, OUString& rURL, b : ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, pParent); static const char aWildcard[] = "*."; - FilterNameVector aFilters; + FilterNameVector aFilters = getMediaFilters(); static const char aSeparator[] = ";"; OUStringBuffer aAllTypes; aDlg.SetTitle( AvmResId( o_pbLink != nullptr ? AVMEDIA_STR_INSERTMEDIA_DLG : AVMEDIA_STR_OPENMEDIA_DLG ) ); - getMediaFilters( aFilters ); - for( FilterNameVector::size_type i = 0; i < aFilters.size(); ++i ) { for( sal_Int32 nIndex = 0; nIndex >= 0; ) @@ -337,11 +328,9 @@ bool MediaWindow::isMediaURL( const OUString& rURL, const OUString& rReferer, bo } else { - FilterNameVector aFilters; + FilterNameVector aFilters = getMediaFilters(); const OUString aExt( aURL.getExtension() ); - getMediaFilters( aFilters ); - for( FilterNameVector::size_type i = 0; i < aFilters.size(); ++i ) { for( sal_Int32 nIndex = 0; nIndex >= 0; ) diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx index acac953f5a36..ab63f7073a7e 100644 --- a/cui/source/dialogs/cuigaldlg.cxx +++ b/cui/source/dialogs/cuigaldlg.cxx @@ -711,8 +711,7 @@ void TPGalleryThemeProperties::FillFilterList() #if HAVE_FEATURE_AVMEDIA // media filters static const char aWildcard[] = "*."; - ::avmedia::FilterNameVector aFilters; - ::avmedia::MediaWindow::getMediaFilters( aFilters ); + ::avmedia::FilterNameVector aFilters= ::avmedia::MediaWindow::getMediaFilters(); for(const std::pair & aFilter : aFilters) { diff --git a/include/avmedia/mediawindow.hxx b/include/avmedia/mediawindow.hxx index 1a84a810576d..78e0b1a299a3 100644 --- a/include/avmedia/mediawindow.hxx +++ b/include/avmedia/mediawindow.hxx @@ -93,7 +93,7 @@ namespace avmedia public: - static void getMediaFilters( FilterNameVector& rFilterNameVector ); + static FilterNameVector getMediaFilters(); /// @param o_pbLink if not 0, this is an "insert" dialog: display link /// checkbox and store its state in *o_pbLink static bool executeMediaURLDialog(weld::Window* pParent, OUString& rURL, bool *const o_pbLink); -- cgit