Kaydet (Commit) 2e45813b authored tarafından Krisztian Pinter's avatar Krisztian Pinter Kaydeden (comit) Petr Mladek

Refactor TemplateAbstractView to define file exts. in one place

Change-Id: I5d799f51c41d9b4f5a0161cf49e76d9539826d8f
Reviewed-on: https://gerrit.libreoffice.org/5365Reviewed-by: 's avatarPetr Mladek <pmladek@suse.cz>
Tested-by: 's avatarPetr Mladek <pmladek@suse.cz>
üst b862b8d5
...@@ -53,6 +53,7 @@ public: ...@@ -53,6 +53,7 @@ public:
virtual bool operator () (const ThumbnailViewItem *pItem); virtual bool operator () (const ThumbnailViewItem *pItem);
static bool isFilteredExtension(FILTER_APPLICATION filter, const OUString &rExt);
bool isValid (const OUString& rPath) const; bool isValid (const OUString& rPath) const;
protected: protected:
......
...@@ -27,32 +27,36 @@ ...@@ -27,32 +27,36 @@
#include "../doc/doc.hrc" #include "../doc/doc.hrc"
#include "templateview.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; bool bRet = true;
INetURLObject aUrl(rPath); if (filter == FILTER_APP_WRITER)
OUString aExt = aUrl.getExtension();
if (mApp == 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; 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) bool ViewFilter_Application::operator () (const ThumbnailViewItem *pItem)
{ {
const TemplateViewItem *pTempItem = dynamic_cast<const TemplateViewItem*>(pItem); const TemplateViewItem *pTempItem = dynamic_cast<const TemplateViewItem*>(pItem);
...@@ -260,26 +264,19 @@ BitmapEx TemplateAbstractView::scaleImg (const BitmapEx &rImg, long width, long ...@@ -260,26 +264,19 @@ BitmapEx TemplateAbstractView::scaleImg (const BitmapEx &rImg, long width, long
BitmapEx TemplateAbstractView::getDefaultThumbnail( const OUString& rPath ) BitmapEx TemplateAbstractView::getDefaultThumbnail( const OUString& rPath )
{ {
BitmapEx aImg;
INetURLObject aUrl(rPath); INetURLObject aUrl(rPath);
OUString aExt = aUrl.getExtension(); OUString aExt = aUrl.getExtension();
BitmapEx aImg; if ( ViewFilter_Application::isFilteredExtension( FILTER_APP_WRITER, aExt) )
if ( aExt == "ott" || aExt == "stw" || aExt == "oth" || aExt == "dot" || aExt == "dotx" )
{
aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_TEXT ) ); aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_TEXT ) );
} else if ( ViewFilter_Application::isFilteredExtension( FILTER_APP_CALC, aExt) )
else if ( aExt == "ots" || aExt == "stc" || aExt == "xlt" || aExt == "xltm" || aExt == "xltx" )
{
aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_SHEET ) ); aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_SHEET ) );
} else if ( ViewFilter_Application::isFilteredExtension( FILTER_APP_IMPRESS, aExt) )
else if ( aExt == "otp" || aExt == "sti" || aExt == "pot" || aExt == "potm" || aExt == "potx" )
{
aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_PRESENTATION ) ); aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_PRESENTATION ) );
} else if ( ViewFilter_Application::isFilteredExtension( FILTER_APP_DRAW, aExt) )
else if ( aExt == "otg" || aExt == "std" )
{
aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_DRAWING ) ); aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_DRAWING ) );
}
return aImg; return aImg;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment