summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorKrisztian Pinter <pin.terminator@gmail.com>2013-08-11 19:35:15 +0200
committerPetr Mladek <pmladek@suse.cz>2013-08-19 15:21:00 +0000
commit2e45813b7e5757bc050e121acfe942763b9544ff (patch)
treea0dd956d81cad4d64a2b42ba843b92d0be4d6db6 /sfx2
parentb862b8d5757cd031f361e5960dff8b149d16b615 (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>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/templateabstractview.cxx45
1 files changed, 21 insertions, 24 deletions
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;
}