diff options
author | Akshay Deep <akshaydeepiitr@gmail.com> | 2016-05-21 13:03:17 +0530 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-05-23 07:04:03 +0000 |
commit | 72ffb6f590293fb8d3ba428f1700dc05703b014f (patch) | |
tree | cad616d138ae69340c4dcd37e7c527716518b1fe /sfx2 | |
parent | 66a953bf3aa6cb1abd55380d846accd68981537a (diff) |
New Template Manager: Default Thumbnails in TemplateSearchView
Change-Id: Iff0cb63defaf3bb98022d891f91339044931cb39
Reviewed-on: https://gerrit.libreoffice.org/25251
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/templatesearchview.cxx | 27 | ||||
-rw-r--r-- | sfx2/source/inc/templatesearchview.hxx | 2 |
2 files changed, 28 insertions, 1 deletions
diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx index 15e0857bad10..38190135b01d 100644 --- a/sfx2/source/control/templatesearchview.cxx +++ b/sfx2/source/control/templatesearchview.cxx @@ -9,7 +9,9 @@ #include "templatesearchview.hxx" #include "templatesearchviewitem.hxx" +#include <sfx2/templateabstractview.hxx> #include <sfx2/sfxresid.hxx> +#include <tools/urlobj.hxx> #include "../doc/doc.hrc" @@ -127,7 +129,12 @@ void TemplateSearchView::AppendItem(sal_uInt16 nAssocItemId, sal_uInt16 nRegionI pItem->mnAssocId = nAssocItemId; pItem->mnDocId = nIdx; pItem->mnRegionId = nRegionId; - pItem->maPreview1 = rImage; + + if(!rImage.IsEmpty()) + pItem->maPreview1 = rImage; + else + pItem->maPreview1 = getDefaultThumbnail(rPath); + pItem->maTitle = rTitle; pItem->setSubTitle(rSubtitle); pItem->setPath(rPath); @@ -137,6 +144,24 @@ void TemplateSearchView::AppendItem(sal_uInt16 nAssocItemId, sal_uInt16 nRegionI CalculateItemPositions(); } +BitmapEx TemplateSearchView::getDefaultThumbnail( const OUString& rPath ) +{ + BitmapEx aImg; + INetURLObject aUrl(rPath); + OUString aExt = aUrl.getExtension(); + + if ( ViewFilter_Application::isFilteredExtension( FILTER_APPLICATION::WRITER, aExt) ) + aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_TEXT ) ); + else if ( ViewFilter_Application::isFilteredExtension( FILTER_APPLICATION::CALC, aExt) ) + aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_SHEET ) ); + else if ( ViewFilter_Application::isFilteredExtension( FILTER_APPLICATION::IMPRESS, aExt) ) + aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_PRESENTATION ) ); + else if ( ViewFilter_Application::isFilteredExtension( FILTER_APPLICATION::DRAW, aExt) ) + aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_DRAWING ) ); + + return aImg; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/inc/templatesearchview.hxx b/sfx2/source/inc/templatesearchview.hxx index 30b1223c944a..129b7da30042 100644 --- a/sfx2/source/inc/templatesearchview.hxx +++ b/sfx2/source/inc/templatesearchview.hxx @@ -39,6 +39,8 @@ public: const OUString &rTitle, const OUString &rSubtitle, const OUString &rPath, const BitmapEx &rImage ); + BitmapEx getDefaultThumbnail( const OUString& rPath ); + protected: virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override; |