sfx2/source/control/templatesearchview.cxx | 27 ++++++++++++++++++++++++++- sfx2/source/inc/templatesearchview.hxx | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-)
New commits: commit 72ffb6f590293fb8d3ba428f1700dc05703b014f Author: Akshay Deep <akshaydeepi...@gmail.com> Date: Sat May 21 13:03:17 2016 +0530 New Template Manager: Default Thumbnails in TemplateSearchView Change-Id: Iff0cb63defaf3bb98022d891f91339044931cb39 Reviewed-on: https://gerrit.libreoffice.org/25251 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx index 15e0857..3819013 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 30b1223..129b7da 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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits