Kaydet (Commit) a6ea18a9 authored tarafından Akshay Deep's avatar Akshay Deep Kaydeden (comit) Samuel Mehrbrodt

Mark Default Templates in Template Manager

Change-Id: I1dff486605efce09e862d2924b24949601ae0f17
Reviewed-on: https://gerrit.libreoffice.org/25816Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
üst 268a518a
...@@ -112,6 +112,8 @@ public: ...@@ -112,6 +112,8 @@ public:
long getThumbnailWidth() const { return mnThumbnailWidth;} long getThumbnailWidth() const { return mnThumbnailWidth;}
long getThumbnailHeight() const {return mnThumbnailHeight;} long getThumbnailHeight() const {return mnThumbnailHeight;}
void RemoveDefaultTemplateIcon( OUString rPath);
static BitmapEx scaleImg (const BitmapEx &rImg, long width, long height); static BitmapEx scaleImg (const BitmapEx &rImg, long width, long height);
static BitmapEx getDefaultThumbnail( const OUString& rPath ); static BitmapEx getDefaultThumbnail( const OUString& rPath );
...@@ -122,6 +124,8 @@ protected: ...@@ -122,6 +124,8 @@ protected:
virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override; virtual void OnItemDblClicked(ThumbnailViewItem *pItem) override;
bool IsDefaultTemplate(const OUString& rPath);
protected: protected:
sal_uInt16 mnCurRegionId; sal_uInt16 mnCurRegionId;
......
...@@ -24,6 +24,10 @@ public: ...@@ -24,6 +24,10 @@ public:
const OUString& getPath () const { return maPath; } const OUString& getPath () const { return maPath; }
void showDefaultIcon(bool bVal) { mbIsDefaultTemplate = bVal; }
Rectangle getDefaultIconArea() const;
virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor, virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor,
const ThumbnailItemAttributes *pAttrs) override; const ThumbnailItemAttributes *pAttrs) override;
...@@ -33,6 +37,8 @@ public: ...@@ -33,6 +37,8 @@ public:
private: private:
OUString maPath; OUString maPath;
BitmapEx maDefaultBitmap;
bool mbIsDefaultTemplate;
}; };
#endif // INCLUDED_SFX2_TEMPLATEVIEWITEM_HXX #endif // INCLUDED_SFX2_TEMPLATEVIEWITEM_HXX
......
...@@ -13,9 +13,11 @@ ...@@ -13,9 +13,11 @@
#include <sfx2/templatecontaineritem.hxx> #include <sfx2/templatecontaineritem.hxx>
#include <sfx2/templateviewitem.hxx> #include <sfx2/templateviewitem.hxx>
#include <sfx2/sfxresid.hxx> #include <sfx2/sfxresid.hxx>
#include <sfx2/docfac.hxx>
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
#include <unotools/ucbstreamhelper.hxx> #include <unotools/ucbstreamhelper.hxx>
#include <vcl/pngread.hxx> #include <vcl/pngread.hxx>
#include <unotools/moduleoptions.hxx>
#include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygon.hxx>
#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
...@@ -34,6 +36,7 @@ ...@@ -34,6 +36,7 @@
using namespace basegfx; using namespace basegfx;
using namespace drawinglayer::primitive2d; using namespace drawinglayer::primitive2d;
using namespace ::com::sun::star::uno;
bool ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION filter, const OUString &rExt) bool ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION filter, const OUString &rExt)
{ {
...@@ -126,6 +129,9 @@ void TemplateAbstractView::insertItems(const std::vector<TemplateItemProperties> ...@@ -126,6 +129,9 @@ void TemplateAbstractView::insertItems(const std::vector<TemplateItemProperties>
pChild->setHelpText(pCur->aRegionName); pChild->setHelpText(pCur->aRegionName);
pChild->maPreview1 = pCur->aThumbnail; pChild->maPreview1 = pCur->aThumbnail;
if(IsDefaultTemplate(pCur->aPath))
pChild->showDefaultIcon(true);
if ( pCur->aThumbnail.IsEmpty() ) if ( pCur->aThumbnail.IsEmpty() )
{ {
// Use the default thumbnail if we have nothing else // Use the default thumbnail if we have nothing else
...@@ -245,6 +251,35 @@ BitmapEx TemplateAbstractView::scaleImg (const BitmapEx &rImg, long width, long ...@@ -245,6 +251,35 @@ BitmapEx TemplateAbstractView::scaleImg (const BitmapEx &rImg, long width, long
return aImg; return aImg;
} }
bool TemplateAbstractView::IsDefaultTemplate(const OUString& rPath)
{
SvtModuleOptions aModOpt;
std::vector<OUString> aList;
const css::uno::Sequence<OUString> &aServiceNames = aModOpt.GetAllServiceNames();
for( sal_Int32 i=0, nCount = aServiceNames.getLength(); i < nCount; ++i )
{
const OUString defaultPath = SfxObjectFactory::GetStandardTemplate( aServiceNames[i] );
if(defaultPath.match(rPath))
return true;
}
return false;
}
void TemplateAbstractView::RemoveDefaultTemplateIcon( OUString rPath)
{
for (ThumbnailViewItem* pItem : mItemList)
{
TemplateViewItem* pViewItem = dynamic_cast<TemplateViewItem*>(pItem);
if(pViewItem->getPath().match(rPath))
{
pViewItem->showDefaultIcon(false);
return;
}
}
}
BitmapEx TemplateAbstractView::getDefaultThumbnail( const OUString& rPath ) BitmapEx TemplateAbstractView::getDefaultThumbnail( const OUString& rPath )
{ {
BitmapEx aImg; BitmapEx aImg;
......
...@@ -14,5 +14,6 @@ ...@@ -14,5 +14,6 @@
#define IMG_WELCOME 261 #define IMG_WELCOME 261
#define IMG_RECENTDOC_REMOVE 262 #define IMG_RECENTDOC_REMOVE 262
#define IMG_RECENTDOC_REMOVE_HIGHLIGHTED 263 #define IMG_RECENTDOC_REMOVE_HIGHLIGHTED 263
#define IMG_DEFAULT 264
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -48,4 +48,9 @@ Bitmap IMG_RECENTDOC_REMOVE_HIGHLIGHTED ...@@ -48,4 +48,9 @@ Bitmap IMG_RECENTDOC_REMOVE_HIGHLIGHTED
File = "recentdoc_remove_highlighted.png"; File = "recentdoc_remove_highlighted.png";
}; };
Bitmap IMG_DEFAULT
{
File = "templatestar.png";
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -15,11 +15,15 @@ ...@@ -15,11 +15,15 @@
#include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx> #include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/discretebitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/textlayoutdevice.hxx> #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
#include <drawinglayer/primitive2d/textprimitive2d.hxx> #include <drawinglayer/primitive2d/textprimitive2d.hxx>
#include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <drawinglayer/processor2d/baseprocessor2d.hxx>
#include <vcl/button.hxx> #include <vcl/button.hxx>
#include <vcl/graph.hxx> #include <vcl/graph.hxx>
#include <sfx2/sfxresid.hxx>
#include <templateview.hrc>
using namespace basegfx; using namespace basegfx;
using namespace basegfx::tools; using namespace basegfx::tools;
...@@ -29,7 +33,9 @@ using namespace drawinglayer::primitive2d; ...@@ -29,7 +33,9 @@ using namespace drawinglayer::primitive2d;
TemplateViewItem::TemplateViewItem (ThumbnailView &rView, sal_uInt16 nId) TemplateViewItem::TemplateViewItem (ThumbnailView &rView, sal_uInt16 nId)
: ThumbnailViewItem(rView, nId), : ThumbnailViewItem(rView, nId),
mnRegionId(USHRT_MAX), mnRegionId(USHRT_MAX),
mnDocId(USHRT_MAX) mnDocId(USHRT_MAX),
maDefaultBitmap(SfxResId(IMG_DEFAULT)),
mbIsDefaultTemplate(false)
{ {
} }
...@@ -37,6 +43,16 @@ TemplateViewItem::~TemplateViewItem () ...@@ -37,6 +43,16 @@ TemplateViewItem::~TemplateViewItem ()
{ {
} }
Rectangle TemplateViewItem::getDefaultIconArea() const
{
Rectangle aArea(getDrawArea());
Size aSize(maDefaultBitmap.GetSizePixel());
return Rectangle(
Point(aArea.Left() + THUMBNAILVIEW_ITEM_CORNER, aArea.Top() + THUMBNAILVIEW_ITEM_CORNER),
aSize);
}
void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProcessor, void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProcessor,
const ThumbnailItemAttributes *pAttrs) const ThumbnailItemAttributes *pAttrs)
{ {
...@@ -90,6 +106,14 @@ void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProces ...@@ -90,6 +106,14 @@ void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProces
// draw thumbnail borders // draw thumbnail borders
aSeq[3] = drawinglayer::primitive2d::Primitive2DReference(createBorderLine(aBounds)); aSeq[3] = drawinglayer::primitive2d::Primitive2DReference(createBorderLine(aBounds));
if(mbIsDefaultTemplate)
{
Point aIconPos(getDefaultIconArea().TopLeft());
aSeq[4] = drawinglayer::primitive2d::Primitive2DReference(new DiscreteBitmapPrimitive2D( maDefaultBitmap,
B2DPoint(aIconPos.X(), aIconPos.Y())));
}
addTextPrimitives(maTitle, pAttrs, maTextPos, aSeq); addTextPrimitives(maTitle, pAttrs, maTextPos, aSeq);
pProcessor->process(aSeq); pProcessor->process(aSeq);
......
...@@ -855,7 +855,12 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, DefaultTemplateHdl, ThumbnailViewItem*, p ...@@ -855,7 +855,12 @@ IMPL_LINK_TYPED(SfxTemplateManagerDlg, DefaultTemplateHdl, ThumbnailViewItem*, p
OUString aServiceName; OUString aServiceName;
if (lcl_getServiceName(pViewItem->getPath(),aServiceName)) if (lcl_getServiceName(pViewItem->getPath(),aServiceName))
{ {
OUString sPrevDefault = SfxObjectFactory::GetStandardTemplate( aServiceName );
if(!sPrevDefault.isEmpty())
mpLocalView->RemoveDefaultTemplateIcon(sPrevDefault);
SfxObjectFactory::SetStandardTemplate(aServiceName,pViewItem->getPath()); SfxObjectFactory::SetStandardTemplate(aServiceName,pViewItem->getPath());
pViewItem->showDefaultIcon(true);
createDefaultTemplateMenu(); createDefaultTemplateMenu();
} }
......
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