diff options
author | Krisztian Pinter <pin.terminator@gmail.com> | 2013-08-11 19:35:15 +0200 |
---|---|---|
committer | Petr Mladek <pmladek@suse.cz> | 2013-08-19 15:21:00 +0000 |
commit | 2e45813b7e5757bc050e121acfe942763b9544ff (patch) | |
tree | a0dd956d81cad4d64a2b42ba843b92d0be4d6db6 | |
parent | b862b8d5757cd031f361e5960dff8b149d16b615 (diff) |
Refactor TemplateAbstractView to define file exts. in one place
Change-Id: I5d799f51c41d9b4f5a0161cf49e76d9539826d8f
Reviewed-on: https://gerrit.libreoffice.org/5365
Reviewed-by: Petr Mladek <pmladek@suse.cz>
Tested-by: Petr Mladek <pmladek@suse.cz>
-rw-r--r-- | include/sfx2/templateabstractview.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/control/templateabstractview.cxx | 45 |
2 files changed, 22 insertions, 24 deletions
diff --git a/include/sfx2/templateabstractview.hxx b/include/sfx2/templateabstractview.hxx index d101aff5f065..8dd602769245 100644 --- a/include/sfx2/templateabstractview.hxx +++ b/include/sfx2/templateabstractview.hxx @@ -53,6 +53,7 @@ public: virtual bool operator () (const ThumbnailViewItem *pItem); + static bool isFilteredExtension(FILTER_APPLICATION filter, const OUString &rExt); bool isValid (const OUString& rPath) const; protected: diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index cd6e77fd0521..d9119174ea52 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -27,32 +27,36 @@ #include "../doc/doc.hrc" #include "templateview.hrc" -bool ViewFilter_Application::isValid (const OUString &rPath) const +bool ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION filter, const OUString &rExt) { bool bRet = true; - INetURLObject aUrl(rPath); - OUString aExt = aUrl.getExtension(); - if (mApp == FILTER_APP_WRITER) + if (filter == FILTER_APP_WRITER) { - bRet = aExt == "ott" || aExt == "stw" || aExt == "oth" || aExt == "dot" || aExt == "dotx"; + bRet = rExt == "ott" || rExt == "stw" || rExt == "oth" || rExt == "dot" || rExt == "dotx"; } - else if (mApp == FILTER_APP_CALC) + else if (filter == FILTER_APP_CALC) { - bRet = aExt == "ots" || aExt == "stc" || aExt == "xlt" || aExt == "xltm" || aExt == "xltx"; + bRet = rExt == "ots" || rExt == "stc" || rExt == "xlt" || rExt == "xltm" || rExt == "xltx"; } - else if (mApp == FILTER_APP_IMPRESS) + else if (filter == FILTER_APP_IMPRESS) { - bRet = aExt == "otp" || aExt == "sti" || aExt == "pot" || aExt == "potm" || aExt == "potx"; + bRet = rExt == "otp" || rExt == "sti" || rExt == "pot" || rExt == "potm" || rExt == "potx"; } - else if (mApp == FILTER_APP_DRAW) + else if (filter == FILTER_APP_DRAW) { - bRet = aExt == "otg" || aExt == "std"; + bRet = rExt == "otg" || rExt == "std"; } return bRet; } +bool ViewFilter_Application::isValid (const OUString &rPath) const +{ + INetURLObject aUrl(rPath); + return isFilteredExtension(mApp, aUrl.getExtension()); +} + bool ViewFilter_Application::operator () (const ThumbnailViewItem *pItem) { const TemplateViewItem *pTempItem = dynamic_cast<const TemplateViewItem*>(pItem); @@ -260,26 +264,19 @@ BitmapEx TemplateAbstractView::scaleImg (const BitmapEx &rImg, long width, long BitmapEx TemplateAbstractView::getDefaultThumbnail( const OUString& rPath ) { + BitmapEx aImg; INetURLObject aUrl(rPath); OUString aExt = aUrl.getExtension(); - BitmapEx aImg; - if ( aExt == "ott" || aExt == "stw" || aExt == "oth" || aExt == "dot" || aExt == "dotx" ) - { + if ( ViewFilter_Application::isFilteredExtension( FILTER_APP_WRITER, aExt) ) aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_TEXT ) ); - } - else if ( aExt == "ots" || aExt == "stc" || aExt == "xlt" || aExt == "xltm" || aExt == "xltx" ) - { + else if ( ViewFilter_Application::isFilteredExtension( FILTER_APP_CALC, aExt) ) aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_SHEET ) ); - } - else if ( aExt == "otp" || aExt == "sti" || aExt == "pot" || aExt == "potm" || aExt == "potx" ) - { + else if ( ViewFilter_Application::isFilteredExtension( FILTER_APP_IMPRESS, aExt) ) aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_PRESENTATION ) ); - } - else if ( aExt == "otg" || aExt == "std" ) - { + else if ( ViewFilter_Application::isFilteredExtension( FILTER_APP_DRAW, aExt) ) aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_DRAWING ) ); - } + return aImg; } |