[Libreoffice-commits] core.git: include/sfx2 sfx2/source
Krisztian Pinter
pin.terminator at gmail.com
Mon Aug 19 08:21:22 PDT 2013
include/sfx2/templateabstractview.hxx | 1
sfx2/source/control/templateabstractview.cxx | 45 ++++++++++++---------------
2 files changed, 22 insertions(+), 24 deletions(-)
New commits:
commit 2e45813b7e5757bc050e121acfe942763b9544ff
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date: Sun Aug 11 19:35:15 2013 +0200
Refactor TemplateAbstractView to define file exts. in one place
Change-Id: I5d799f51c41d9b4f5a0161cf49e76d9539826d8f
Reviewed-on: https://gerrit.libreoffice.org/5365
Reviewed-by: Petr Mladek <pmladek at suse.cz>
Tested-by: Petr Mladek <pmladek at suse.cz>
diff --git a/include/sfx2/templateabstractview.hxx b/include/sfx2/templateabstractview.hxx
index d101aff..8dd6027 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 cd6e77f..d911917 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;
}
More information about the Libreoffice-commits
mailing list