Kaydet (Commit) e63b59c7 authored tarafından Rafael Dominguez's avatar Rafael Dominguez Kaydeden (comit) Miklos Vajna

Merge TemplateView into TemplateAbstractView class.

Refactor TemplateView class into TemplateAbstractView so we
only have one class that display template thumbnails and not
a separate for folders and another for files. This will let
us in the future be able to display file system hierarchies in
case of the remote repositories and simplify the view handing
logic.

(cherry picked from commit 448cc5e8)

Conflicts:
	sfx2/Library_sfx.mk
	sfx2/inc/sfx2/templateabstractview.hxx
	sfx2/inc/sfx2/templateview.hxx
	sfx2/inc/templatedlg.hxx
	sfx2/source/control/templateabstractview.cxx

Change-Id: Iafc246eeff4c50c12ac9ebec9fe95dcc84991e9e
Reviewed-on: https://gerrit.libreoffice.org/3088Reviewed-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
Tested-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
üst 14fb3c4c
...@@ -71,7 +71,7 @@ $(eval $(call gb_Library_use_libraries,sfx,\ ...@@ -71,7 +71,7 @@ $(eval $(call gb_Library_use_libraries,sfx,\
ucbhelper \ ucbhelper \
utl \ utl \
vcl \ vcl \
$(gb_UWINAPI) \ $(gb_UWINAPI) \
)) ))
$(eval $(call gb_Library_use_external,sfx,libxml2)) $(eval $(call gb_Library_use_external,sfx,libxml2))
...@@ -138,7 +138,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ ...@@ -138,7 +138,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/control/sorgitm \ sfx2/source/control/sorgitm \
sfx2/source/control/statcach \ sfx2/source/control/statcach \
sfx2/source/control/templateabstractview \ sfx2/source/control/templateabstractview \
sfx2/source/control/templateview \
sfx2/source/control/templateviewitem \ sfx2/source/control/templateviewitem \
sfx2/source/control/templatelocalview \ sfx2/source/control/templatelocalview \
sfx2/source/control/templatecontaineritem \ sfx2/source/control/templatecontaineritem \
...@@ -150,7 +149,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ ...@@ -150,7 +149,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/control/unoctitm \ sfx2/source/control/unoctitm \
sfx2/source/dialog/alienwarn \ sfx2/source/dialog/alienwarn \
sfx2/source/dialog/basedlgs \ sfx2/source/dialog/basedlgs \
sfx2/source/dialog/checkin \ sfx2/source/dialog/checkin \
sfx2/source/dialog/dinfdlg \ sfx2/source/dialog/dinfdlg \
sfx2/source/dialog/dinfedt \ sfx2/source/dialog/dinfedt \
sfx2/source/dialog/dockwin \ sfx2/source/dialog/dockwin \
...@@ -295,11 +294,11 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ ...@@ -295,11 +294,11 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
)) ))
$(eval $(call gb_Library_use_system_win32_libs,sfx,\ $(eval $(call gb_Library_use_system_win32_libs,sfx,\
advapi32 \ advapi32 \
gdi32 \ gdi32 \
ole32 \ ole32 \
shell32 \ shell32 \
uuid \ uuid \
)) ))
endif endif
......
...@@ -120,7 +120,6 @@ $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templdlg.hxx,sfx2/templdlg.h ...@@ -120,7 +120,6 @@ $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templdlg.hxx,sfx2/templdlg.h
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatelocnames.hrc,sfx2/templatelocnames.hrc)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatelocnames.hrc,sfx2/templatelocnames.hrc))
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateabstractview.hxx,sfx2/templateabstractview.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateabstractview.hxx,sfx2/templateabstractview.hxx))
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateinfodlg.hxx,sfx2/templateinfodlg.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateinfodlg.hxx,sfx2/templateinfodlg.hxx))
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateview.hxx,sfx2/templateview.hxx))
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatelocalview.hxx,sfx2/templatelocalview.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatelocalview.hxx,sfx2/templatelocalview.hxx))
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatecontaineritem.hxx,sfx2/templatecontaineritem.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templatecontaineritem.hxx,sfx2/templatecontaineritem.hxx))
$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateremoteview.hxx,sfx2/templateremoteview.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/templateremoteview.hxx,sfx2/templateremoteview.hxx))
......
...@@ -10,7 +10,10 @@ ...@@ -10,7 +10,10 @@
#ifndef __SFX2_TEMPLATEABSTRACTVIEW_HXX__ #ifndef __SFX2_TEMPLATEABSTRACTVIEW_HXX__
#define __SFX2_TEMPLATEABSTRACTVIEW_HXX__ #define __SFX2_TEMPLATEABSTRACTVIEW_HXX__
#include <sfx2/templateproperties.hxx>
#include <sfx2/thumbnailview.hxx> #include <sfx2/thumbnailview.hxx>
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
//template thumbnail item defines //template thumbnail item defines
#define TEMPLATE_ITEM_MAX_WIDTH 160 #define TEMPLATE_ITEM_MAX_WIDTH 160
...@@ -23,7 +26,6 @@ ...@@ -23,7 +26,6 @@
#define TEMPLATE_THUMBNAIL_MAX_HEIGHT TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT - 2*TEMPLATE_ITEM_PADDING #define TEMPLATE_THUMBNAIL_MAX_HEIGHT TEMPLATE_ITEM_THUMBNAIL_MAX_HEIGHT - 2*TEMPLATE_ITEM_PADDING
#define TEMPLATE_THUMBNAIL_MAX_WIDTH TEMPLATE_ITEM_MAX_WIDTH - 2*TEMPLATE_ITEM_PADDING #define TEMPLATE_THUMBNAIL_MAX_WIDTH TEMPLATE_ITEM_MAX_WIDTH - 2*TEMPLATE_ITEM_PADDING
class TemplateView;
class SfxDocumentTemplates; class SfxDocumentTemplates;
enum FILTER_APPLICATION enum FILTER_APPLICATION
...@@ -80,63 +82,51 @@ public: ...@@ -80,63 +82,51 @@ public:
virtual ~TemplateAbstractView (); virtual ~TemplateAbstractView ();
// Fill view with template folders thumbnails // Fill view with new item list
virtual void Populate () { }; void insertItems (const std::vector<TemplateItemProperties> &rTemplates);
virtual void reload () { };
virtual void filterTemplatesByApp (const FILTER_APPLICATION &eApp);
void showOverlay (bool bVisible);
void setItemDimensions (long ItemWidth, long ThumbnailHeight, long DisplayHeight, int itemPadding);
sal_uInt16 getOverlayRegionId () const;
const OUString& getOverlayName () const; // Fill view with template folders thumbnails
virtual void Populate () { }
// Check if the overlay is visible or not. virtual void reload () { }
bool isOverlayVisible () const;
void deselectOverlayItems (); virtual void showRootRegion () = 0;
void deselectOverlayItem (const sal_uInt16 nItemId); virtual void showRegion (ThumbnailViewItem *pItem) = 0;
void sortOverlayItems (const boost::function<bool (const ThumbnailViewItem*, sal_uInt16 getCurRegionId () const;
const ThumbnailViewItem*) > &func);
virtual void filterTemplatesByKeyword (const OUString &rKeyword); const OUString& getCurRegionName () const;
void setOverlayItemStateHdl (const Link &aLink) { maOverlayItemStateHdl = aLink; } // Check if the root region is visible or not.
bool isNonRootRegionVisible () const;
void setOpenHdl (const Link &rLink); void setOpenRegionHdl(const Link &rLink);
void setOverlayCloseHdl (const Link &rLink); void setOpenTemplateHdl (const Link &rLink);
static BitmapEx scaleImg (const BitmapEx &rImg, long width, long height); static BitmapEx scaleImg (const BitmapEx &rImg, long width, long height);
static BitmapEx fetchThumbnail (const OUString &msURL, long width, long height); static BitmapEx getDefaultThumbnail( const rtl::OUString& rPath );
virtual void Resize(); static BitmapEx fetchThumbnail (const OUString &msURL, long width, long height);
protected: protected:
virtual void Paint( const Rectangle& rRect ); DECL_LINK(ShowRootRegionHdl, void*);
virtual void DrawItem (ThumbnailViewItem *pItem);
DECL_LINK(OverlayItemStateHdl, const ThumbnailViewItem*);
virtual void OnItemDblClicked(ThumbnailViewItem *pItem); virtual void OnItemDblClicked(ThumbnailViewItem *pItem);
protected: protected:
TemplateView *mpItemView; sal_uInt16 mnCurRegionId;
Link maOverlayItemStateHdl; OUString maCurRegionName;
Link maOpenHdl;
PushButton maAllButton;
FixedText maFTName;
bool mbFilteredResults; // Flag keep track if overlay has been filtered so folders can get filtered too afterwards Link maOpenRegionHdl;
FILTER_APPLICATION meFilterOption; Link maOpenTemplateHdl;
}; };
#endif // __SFX2_TEMPLATEABSTRACTVIEW_HXX__ #endif // __SFX2_TEMPLATEABSTRACTVIEW_HXX__
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <set> #include <set>
#include <sfx2/templateabstractview.hxx> #include <sfx2/templateabstractview.hxx>
#include <sfx2/templateproperties.hxx>
class SfxDocumentTemplates; class SfxDocumentTemplates;
class TemplateContainerItem; class TemplateContainerItem;
...@@ -26,6 +25,8 @@ namespace com { ...@@ -26,6 +25,8 @@ namespace com {
class SFX2_DLLPUBLIC TemplateLocalView : public TemplateAbstractView class SFX2_DLLPUBLIC TemplateLocalView : public TemplateAbstractView
{ {
typedef bool (*selection_cmp_fn)(const ThumbnailViewItem*,const ThumbnailViewItem*);
public: public:
TemplateLocalView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren = false ); TemplateLocalView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren = false );
...@@ -37,6 +38,12 @@ public: ...@@ -37,6 +38,12 @@ public:
virtual void reload (); virtual void reload ();
virtual void showRootRegion ();
virtual void showRegion (ThumbnailViewItem *pItem);
sal_uInt16 getRegionId (size_t pos) const;
std::vector<OUString> getFolderNames (); std::vector<OUString> getFolderNames ();
std::vector<TemplateItemProperties> std::vector<TemplateItemProperties>
...@@ -51,7 +58,7 @@ public: ...@@ -51,7 +58,7 @@ public:
bool moveTemplate (const ThumbnailViewItem* pItem, const sal_uInt16 nSrcItem, bool moveTemplate (const ThumbnailViewItem* pItem, const sal_uInt16 nSrcItem,
const sal_uInt16 nTargetItem, bool bCopy); const sal_uInt16 nTargetItem, bool bCopy);
bool moveTemplates (std::set<const ThumbnailViewItem*> &rItems, const sal_uInt16 nTargetItem, bool bCopy); bool moveTemplates (const std::set<const ThumbnailViewItem*,selection_cmp_fn> &rItems, const sal_uInt16 nTargetItem, bool bCopy);
bool copyFrom (const sal_uInt16 nRegionItemId, const BitmapEx &rThumbnail, const OUString &rPath); bool copyFrom (const sal_uInt16 nRegionItemId, const BitmapEx &rThumbnail, const OUString &rPath);
...@@ -74,6 +81,7 @@ public: ...@@ -74,6 +81,7 @@ public:
private: private:
SfxDocumentTemplates *mpDocTemplates; SfxDocumentTemplates *mpDocTemplates;
std::vector<TemplateContainerItem* > maRegions;
}; };
#endif // TEMPLATEFOLDERVIEW_HXX #endif // TEMPLATEFOLDERVIEW_HXX
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
struct TemplateItemProperties struct TemplateItemProperties
{ {
bool aIsFolder;
sal_uInt16 nId; ///< Index for ThumbnailView sal_uInt16 nId; ///< Index for ThumbnailView
sal_uInt16 nDocId; ///< Index based on SfxTemplateDocument sal_uInt16 nDocId; ///< Index based on SfxTemplateDocument
sal_uInt16 nRegionId; sal_uInt16 nRegionId;
......
...@@ -25,6 +25,10 @@ public: ...@@ -25,6 +25,10 @@ public:
virtual ~TemplateRemoteView (); virtual ~TemplateRemoteView ();
virtual void showRootRegion ();
virtual void showRegion (ThumbnailViewItem *pItem);
bool loadRepository (TemplateRepository* pRepository, bool bRefresh); bool loadRepository (TemplateRepository* pRepository, bool bRefresh);
private: private:
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright 2012 LibreOffice contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef TEMPLATEVIEW_HXX
#define TEMPLATEVIEW_HXX
#include <sfx2/templateproperties.hxx>
#include <sfx2/thumbnailview.hxx>
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
class Edit;
class TemplateViewItem;
class TemplateView : public ThumbnailView
{
public:
TemplateView (Window *pParent);
virtual ~TemplateView ();
void setId (const sal_uInt16 nId) { mnId = nId; }
sal_uInt16 getId () const { return mnId; }
void setName (const OUString &rName);
const OUString& getName () const { return maName; }
void InsertItems (const std::vector<TemplateItemProperties> &rTemplates);
void setCloseHdl (const Link &rLink) { maAllButton.SetClickHdl(rLink); }
void setMasterView(TemplateAbstractView* pMasterView) { mpMasterView = pMasterView; }
virtual bool renameItem(ThumbnailViewItem* pItem, rtl::OUString sNewTitle);
// FIXME Kept only during the refactoring
void setOpenHdl (const Link &rLink) { maOpenHdl = rLink; }
virtual void OnItemDblClicked(ThumbnailViewItem *pItem) { maOpenHdl.Call(pItem); }
protected:
virtual void Resize ();
private:
TemplateAbstractView* mpMasterView;
Link maOpenHdl;
PushButton maAllButton;
FixedText maFTName;
sal_uInt16 mnId;
OUString maName;
};
#endif // TEMPLATEVIEW_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -183,6 +183,9 @@ public: ...@@ -183,6 +183,9 @@ public:
void Clear(); void Clear();
// Change current thumbnail item list with new one (invalidates all pointers to a thumbnail item)
void updateItems(const std::vector<ThumbnailViewItem *> &items);
size_t GetItemPos( sal_uInt16 nItemId ) const; size_t GetItemPos( sal_uInt16 nItemId ) const;
sal_uInt16 GetItemId( size_t nPos ) const; sal_uInt16 GetItemId( size_t nPos ) const;
......
...@@ -38,6 +38,8 @@ namespace com { ...@@ -38,6 +38,8 @@ namespace com {
class SfxTemplateManagerDlg : public ModelessDialog class SfxTemplateManagerDlg : public ModelessDialog
{ {
typedef bool (*selection_cmp_fn)(const ThumbnailViewItem*,const ThumbnailViewItem*);
public: public:
SfxTemplateManagerDlg (Window *parent = DIALOG_NO_PARENT); SfxTemplateManagerDlg (Window *parent = DIALOG_NO_PARENT);
...@@ -50,29 +52,23 @@ public: ...@@ -50,29 +52,23 @@ public:
DECL_LINK(ActivatePageHdl, void*); DECL_LINK(ActivatePageHdl, void*);
static BitmapEx getDefaultThumbnail( const rtl::OUString& rPath );
private: private:
virtual void MouseButtonDown( const MouseEvent& rMEvt );
virtual void Resize (); virtual void Resize ();
DECL_LINK(CloseOverlayHdl, void*);
DECL_LINK(TBXViewHdl, void*); DECL_LINK(TBXViewHdl, void*);
DECL_LINK(TBXActionHdl, void*); DECL_LINK(TBXActionHdl, void*);
DECL_LINK(TBXTemplateHdl, void*); DECL_LINK(TBXTemplateHdl, void*);
DECL_LINK(TBXDropdownHdl, ToolBox*); DECL_LINK(TBXDropdownHdl, ToolBox*);
DECL_LINK(TVFolderStateHdl, const ThumbnailViewItem*); DECL_LINK(TVItemStateHdl, const ThumbnailViewItem*);
DECL_LINK(TVTemplateStateHdl, const ThumbnailViewItem*);
DECL_LINK(MenuSelectHdl, Menu*); DECL_LINK(MenuSelectHdl, Menu*);
DECL_LINK(MoveMenuSelectHdl, Menu*); DECL_LINK(MoveMenuSelectHdl, Menu*);
DECL_LINK(RepositoryMenuSelectHdl, Menu*); DECL_LINK(RepositoryMenuSelectHdl, Menu*);
DECL_LINK(DefaultTemplateMenuSelectHdl, Menu*); DECL_LINK(DefaultTemplateMenuSelectHdl, Menu*);
DECL_LINK(OpenRegionHdl, void*);
DECL_LINK(OpenTemplateHdl, ThumbnailViewItem*); DECL_LINK(OpenTemplateHdl, ThumbnailViewItem*);
DECL_LINK(SearchUpdateHdl, void*); DECL_LINK(SearchUpdateHdl, void*);
...@@ -84,7 +80,13 @@ private: ...@@ -84,7 +80,13 @@ private:
void OnTemplateDelete (); void OnTemplateDelete ();
void OnTemplateAsDefault (); void OnTemplateAsDefault ();
void OnTemplateExport (); void OnTemplateExport ();
void OnTemplateState (const ThumbnailViewItem *pItem);
void OnFolderDelete (); void OnFolderDelete ();
void OnRegionState (const ThumbnailViewItem *pItem);
void OnRepositoryDelete (); void OnRepositoryDelete ();
void OnTemplateSaveAs (); void OnTemplateSaveAs ();
...@@ -141,8 +143,8 @@ private: ...@@ -141,8 +143,8 @@ private:
PopupMenu *mpRepositoryMenu; PopupMenu *mpRepositoryMenu;
PopupMenu *mpTemplateDefaultMenu; PopupMenu *mpTemplateDefaultMenu;
std::set<const ThumbnailViewItem*> maSelTemplates; std::set<const ThumbnailViewItem*,selection_cmp_fn> maSelTemplates;
std::set<const ThumbnailViewItem*> maSelFolders; std::set<const ThumbnailViewItem*,selection_cmp_fn> maSelFolders;
bool mbIsSaveMode; ///< Flag that indicates if we are in save mode or not. bool mbIsSaveMode; ///< Flag that indicates if we are in save mode or not.
com::sun::star::uno::Reference< com::sun::star::frame::XModel > m_xModel; com::sun::star::uno::Reference< com::sun::star::frame::XModel > m_xModel;
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
*/ */
#include <sfx2/templateabstractview.hxx> #include <sfx2/templateabstractview.hxx>
#include <sfx2/templatecontaineritem.hxx>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <sfx2/templateview.hxx> #include <sfx2/sfxresid.hxx>
#include <sfx2/templatecontaineritem.hxx>
#include <sfx2/templateviewitem.hxx> #include <sfx2/templateviewitem.hxx>
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
#include <unotools/ucbstreamhelper.hxx> #include <unotools/ucbstreamhelper.hxx>
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include "../doc/doc.hrc"
#include "templateview.hrc"
bool ViewFilter_Application::isValid (const OUString &rPath) const bool ViewFilter_Application::isValid (const OUString &rPath) const
{ {
bool bRet = true; bool bRet = true;
...@@ -114,118 +117,85 @@ bool ViewFilter_Keyword::operator ()(const ThumbnailViewItem *pItem) ...@@ -114,118 +117,85 @@ bool ViewFilter_Keyword::operator ()(const ThumbnailViewItem *pItem)
TemplateAbstractView::TemplateAbstractView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren) TemplateAbstractView::TemplateAbstractView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren)
: ThumbnailView(pParent,nWinStyle,bDisableTransientChildren), : ThumbnailView(pParent,nWinStyle,bDisableTransientChildren),
mpItemView(new TemplateView(pParent)), mnCurRegionId(0),
mbFilteredResults(false), maAllButton(this, SfxResId(BTN_ALL_TEMPLATES)),
meFilterOption(FILTER_APP_WRITER) maFTName(this, SfxResId(FT_NAME))
{ {
mpItemView->setItemStateHdl(LINK(this,TemplateAbstractView,OverlayItemStateHdl)); maAllButton.Hide();
maAllButton.SetStyle(maAllButton.GetStyle() | WB_FLATBUTTON);
maAllButton.SetClickHdl(LINK(this,TemplateAbstractView,ShowRootRegionHdl));
maFTName.Hide();
} }
TemplateAbstractView::TemplateAbstractView(Window *pParent, const ResId &rResId, bool bDisableTransientChildren) TemplateAbstractView::TemplateAbstractView(Window *pParent, const ResId &rResId, bool bDisableTransientChildren)
: ThumbnailView(pParent,rResId,bDisableTransientChildren), : ThumbnailView(pParent,rResId,bDisableTransientChildren),
mpItemView(new TemplateView(pParent)), mnCurRegionId(0),
mbFilteredResults(false), maAllButton(this, SfxResId(BTN_ALL_TEMPLATES)),
meFilterOption(FILTER_APP_WRITER) maFTName(this, SfxResId(FT_NAME))
{ {
mpItemView->setItemStateHdl(LINK(this,TemplateAbstractView,OverlayItemStateHdl)); maAllButton.Hide();
maAllButton.SetStyle(maAllButton.GetStyle() | WB_FLATBUTTON);
maAllButton.SetClickHdl(LINK(this,TemplateAbstractView,ShowRootRegionHdl));
maFTName.Hide();
} }
TemplateAbstractView::~TemplateAbstractView () TemplateAbstractView::~TemplateAbstractView ()
{ {
delete mpItemView;
}
void TemplateAbstractView::setItemDimensions(long ItemWidth, long ThumbnailHeight, long DisplayHeight, int itemPadding)
{
ThumbnailView::setItemDimensions(ItemWidth,ThumbnailHeight,DisplayHeight,itemPadding);
mpItemView->setItemDimensions(ItemWidth,ThumbnailHeight,DisplayHeight,itemPadding);
}
sal_uInt16 TemplateAbstractView::getOverlayRegionId() const
{
return mpItemView->getId();
}
const OUString &TemplateAbstractView::getOverlayName() const
{
return mpItemView->getName();
} }
bool TemplateAbstractView::isOverlayVisible () const void TemplateAbstractView::insertItems(const std::vector<TemplateItemProperties> &rTemplates)
{ {
return mpItemView->IsVisible(); std::vector<ThumbnailViewItem*> aItems(rTemplates.size());
} for (size_t i = 0, n = rTemplates.size(); i < n; ++i )
{
//TODO: CHECK IF THE ITEM IS A FOLDER OR NOT
TemplateViewItem *pChild = new TemplateViewItem(*this);
const TemplateItemProperties *pCur = &rTemplates[i];
pChild->mnId = pCur->nId;
pChild->mnDocId = pCur->nDocId;
pChild->mnRegionId = pCur->nRegionId;
pChild->maTitle = pCur->aName;
pChild->setPath(pCur->aPath);
pChild->maPreview1 = pCur->aThumbnail;
if ( pCur->aThumbnail.IsEmpty() )
{
// Use the default thumbnail if we have nothing else
pChild->maPreview1 = TemplateAbstractView::getDefaultThumbnail(pCur->aPath);
}
void TemplateAbstractView::deselectOverlayItems() pChild->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected));
{
mpItemView->deselectItems();
}
void TemplateAbstractView::deselectOverlayItem(const sal_uInt16 nItemId) aItems[i] = pChild;
{ }
mpItemView->deselectItem(nItemId);
}
void TemplateAbstractView::sortOverlayItems(const boost::function<bool (const ThumbnailViewItem*, updateItems(aItems);
const ThumbnailViewItem*) > &func)
{
mpItemView->sortItems(func);
} }
void TemplateAbstractView::filterTemplatesByApp (const FILTER_APPLICATION &eApp) sal_uInt16 TemplateAbstractView::getCurRegionId() const
{ {
meFilterOption = eApp; return mnCurRegionId;
if (mpItemView->IsVisible())
{
mbFilteredResults = true;
mpItemView->filterItems(ViewFilter_Application(eApp));
}
else
{
filterItems(ViewFilter_Application(eApp));
}
} }
void TemplateAbstractView::showOverlay (bool bVisible) const OUString &TemplateAbstractView::getCurRegionName() const
{ {
Show(!bVisible); return maCurRegionName;
mpItemView->Show(bVisible);
mpItemView->SetPosSizePixel(GetPosPixel(), GetSizePixel());
mpItemView->SetStyle(GetStyle());
mpItemView->GrabFocus();
// Clear items is the overlay is closed.
if (!bVisible)
{
// Check if the folder view needs to be filtered
if (mbFilteredResults)
{
filterItems(ViewFilter_Application(meFilterOption));
}
mpItemView->Clear();
}
} }
void TemplateAbstractView::filterTemplatesByKeyword(const OUString &rKeyword) bool TemplateAbstractView::isNonRootRegionVisible () const
{ {
if (mpItemView->IsVisible()) return mnCurRegionId;
mpItemView->filterItems(ViewFilter_Keyword(rKeyword));
} }
void TemplateAbstractView::setOpenHdl(const Link &rLink) void TemplateAbstractView::setOpenRegionHdl(const Link &rLink)
{ {
maOpenHdl = rLink; maOpenRegionHdl = rLink;
mpItemView->setOpenHdl(rLink);
} }
void TemplateAbstractView::setOverlayCloseHdl(const Link &rLink) void TemplateAbstractView::setOpenTemplateHdl(const Link &rLink)
{ {
mpItemView->setCloseHdl(rLink); maOpenTemplateHdl = rLink;
} }
BitmapEx TemplateAbstractView::scaleImg (const BitmapEx &rImg, long width, long height) BitmapEx TemplateAbstractView::scaleImg (const BitmapEx &rImg, long width, long height)
...@@ -263,6 +233,31 @@ BitmapEx TemplateAbstractView::scaleImg (const BitmapEx &rImg, long width, long ...@@ -263,6 +233,31 @@ BitmapEx TemplateAbstractView::scaleImg (const BitmapEx &rImg, long width, long
return aImg; return aImg;
} }
BitmapEx TemplateAbstractView::getDefaultThumbnail( const OUString& rPath )
{
INetURLObject aUrl(rPath);
OUString aExt = aUrl.getExtension();
BitmapEx aImg;
if ( aExt == "ott" || aExt == "stw" || aExt == "oth" || aExt == "dot" || aExt == "dotx" )
{
aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_TEXT ) );
}
else if ( aExt == "ots" || aExt == "stc" || aExt == "xlt" || aExt == "xltm" || aExt == "xltx" )
{
aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_SHEET ) );
}
else if ( aExt == "otp" || aExt == "sti" || aExt == "pot" || aExt == "potm" || aExt == "potx" )
{
aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_PRESENTATION ) );
}
else if ( aExt == "otg" || aExt == "std" )
{
aImg = BitmapEx ( SfxResId( SFX_THUMBNAIL_DRAWING ) );
}
return aImg;
}
BitmapEx TemplateAbstractView::fetchThumbnail (const OUString &msURL, long width, long height) BitmapEx TemplateAbstractView::fetchThumbnail (const OUString &msURL, long width, long height)
{ {
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -372,49 +367,29 @@ BitmapEx TemplateAbstractView::fetchThumbnail (const OUString &msURL, long width ...@@ -372,49 +367,29 @@ BitmapEx TemplateAbstractView::fetchThumbnail (const OUString &msURL, long width
return TemplateAbstractView::scaleImg(aThumbnail,width,height); return TemplateAbstractView::scaleImg(aThumbnail,width,height);
} }
void TemplateAbstractView::Resize() IMPL_LINK_NOARG(TemplateAbstractView, ShowRootRegionHdl)
{
mpItemView->SetSizePixel(GetSizePixel());
ThumbnailView::Resize();
}
void TemplateAbstractView::Paint(const Rectangle &rRect)
{
if (!mpItemView->IsVisible())
ThumbnailView::Paint(rRect);
}
void TemplateAbstractView::DrawItem(ThumbnailViewItem *pItem)
{
if (!mpItemView->IsVisible())
ThumbnailView::DrawItem(pItem);
}
IMPL_LINK(TemplateAbstractView, OverlayItemStateHdl, const ThumbnailViewItem*, pItem)
{ {
maOverlayItemStateHdl.Call((void*)pItem); showRootRegion();
return 0; return 0;
} }
void TemplateAbstractView::OnItemDblClicked (ThumbnailViewItem *pItem) void TemplateAbstractView::OnItemDblClicked (ThumbnailViewItem *pItem)
{ {
//Check if the item is a TemplateContainerItem (Folder) or a TemplateViewItem (File)
TemplateContainerItem* pContainerItem = dynamic_cast<TemplateContainerItem*>(pItem); TemplateContainerItem* pContainerItem = dynamic_cast<TemplateContainerItem*>(pItem);
if ( pContainerItem ) if ( pContainerItem )
{ {
// Fill templates // Fill templates
sal_uInt16 nRegionId = pContainerItem->mnId-1;
mpItemView->setId(nRegionId);
mpItemView->setName(pContainerItem->maTitle);
mpItemView->InsertItems(pContainerItem->maTemplates);
mpItemView->filterItems(ViewFilter_Application(meFilterOption));
showOverlay(true); mnCurRegionId = pContainerItem->mnId-1;
maCurRegionName = pContainerItem->maTitle;
maFTName.SetText(maCurRegionName);
showRegion(pItem);
} }
else else
{ {
maOpenHdl.Call(pItem); maOpenTemplateHdl.Call(pItem);
} }
} }
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <sfx2/templaterepository.hxx> #include <sfx2/templaterepository.hxx>
#include <sfx2/templateview.hxx>
#include <sfx2/templateviewitem.hxx> #include <sfx2/templateviewitem.hxx>
#include <svtools/imagemgr.hxx> #include <svtools/imagemgr.hxx>
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
...@@ -47,8 +46,6 @@ enum ...@@ -47,8 +46,6 @@ enum
TemplateRemoteView::TemplateRemoteView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren) TemplateRemoteView::TemplateRemoteView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren)
: TemplateAbstractView(pParent,nWinStyle,bDisableTransientChildren) : TemplateAbstractView(pParent,nWinStyle,bDisableTransientChildren)
{ {
mpItemView->SetColor(Color(COL_WHITE));
Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
Reference< XInteractionHandler > xGlobalInteractionHandler( Reference< XInteractionHandler > xGlobalInteractionHandler(
InteractionHandler::createWithParent(xContext, 0), UNO_QUERY_THROW ); InteractionHandler::createWithParent(xContext, 0), UNO_QUERY_THROW );
...@@ -60,6 +57,16 @@ TemplateRemoteView::~TemplateRemoteView () ...@@ -60,6 +57,16 @@ TemplateRemoteView::~TemplateRemoteView ()
{ {
} }
void TemplateRemoteView::showRootRegion()
{
//TODO:
}
void TemplateRemoteView::showRegion(ThumbnailViewItem */*pItem*/)
{
//TODO:
}
bool TemplateRemoteView::loadRepository (TemplateRepository* pItem, bool bRefresh) bool TemplateRemoteView::loadRepository (TemplateRepository* pItem, bool bRefresh)
{ {
if (!pItem) if (!pItem)
...@@ -67,13 +74,13 @@ bool TemplateRemoteView::loadRepository (TemplateRepository* pItem, bool bRefres ...@@ -67,13 +74,13 @@ bool TemplateRemoteView::loadRepository (TemplateRepository* pItem, bool bRefres
if (!pItem->getTemplates().empty() && !bRefresh) if (!pItem->getTemplates().empty() && !bRefresh)
{ {
mpItemView->InsertItems(pItem->getTemplates()); insertItems(pItem->getTemplates());
return true; return true;
} }
mpItemView->Clear(); mnCurRegionId = pItem->mnId;
mpItemView->setId(pItem->mnId); maCurRegionName = pItem->maTitle;
mpItemView->setName(pItem->maTitle); maFTName.SetText(maCurRegionName);
OUString aURL = pItem->getURL(); OUString aURL = pItem->getURL();
...@@ -167,7 +174,7 @@ bool TemplateRemoteView::loadRepository (TemplateRepository* pItem, bool bRefres ...@@ -167,7 +174,7 @@ bool TemplateRemoteView::loadRepository (TemplateRepository* pItem, bool bRefres
} }
} }
mpItemView->InsertItems(aItems); insertItems(aItems);
} }
} }
catch( ucb::CommandAbortedException& ) catch( ucb::CommandAbortedException& )
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright 2012 LibreOffice contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "templatedlg.hxx"
#include <sfx2/templateview.hxx>
#include <sfx2/templateabstractview.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/range/b2drange.hxx>
#include <basegfx/vector/b2dvector.hxx>
#include <drawinglayer/attribute/fillbitmapattribute.hxx>
#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
#include <drawinglayer/primitive2d/textprimitive2d.hxx>
#include <drawinglayer/processor2d/baseprocessor2d.hxx>
#include <sfx2/sfxresid.hxx>
#include <sfx2/templateviewitem.hxx>
#include <vcl/edit.hxx>
#include "templateview.hrc"
#define EDIT_HEIGHT 30
using namespace basegfx;
using namespace basegfx::tools;
using namespace drawinglayer::attribute;
using namespace drawinglayer::primitive2d;
TemplateView::TemplateView (Window *pParent)
: ThumbnailView(pParent,WB_VSCROLL | WB_TABSTOP),
mpMasterView(NULL),
maAllButton(this, SfxResId(BTN_ALL_TEMPLATES)),
maFTName(this, SfxResId(FT_NAME)),
mnId(0)
{
mnHeaderHeight = maAllButton.GetSizePixel().getHeight() + maAllButton.GetPosPixel().Y() * 2;
maAllButton.SetStyle(maAllButton.GetStyle() | WB_FLATBUTTON);
}
TemplateView::~TemplateView ()
{
}
void TemplateView::setName (const OUString &rName)
{
maName = rName;
maFTName.SetText(maName);
}
void TemplateView::InsertItems (const std::vector<TemplateItemProperties> &rTemplates)
{
for (size_t i = 0, n = rTemplates.size(); i < n; ++i )
{
TemplateViewItem *pItem = new TemplateViewItem(*this);
const TemplateItemProperties *pCur = &rTemplates[i];
pItem->mnId = pCur->nId;
pItem->mnDocId = pCur->nDocId;
pItem->mnRegionId = pCur->nRegionId;
pItem->maTitle = pCur->aName;
pItem->setPath(pCur->aPath);
pItem->maPreview1 = pCur->aThumbnail;
if ( pCur->aThumbnail.IsEmpty() )
{
// Use the default thumbnail if we have nothing else
pItem->maPreview1 = SfxTemplateManagerDlg::getDefaultThumbnail( pItem->getPath() );
}
pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnItemSelected));
mItemList.push_back(pItem);
}
CalculateItemPositions();
Invalidate();
}
void TemplateView::Resize()
{
Size aWinSize = GetOutputSize();
// Set the buttons panel and buttons size
Size aNameSize = maFTName.GetSizePixel();
aNameSize.setWidth( aWinSize.getWidth() - maFTName.GetPosPixel().X());
maFTName.SetSizePixel(aNameSize);
ThumbnailView::Resize();
}
bool TemplateView::renameItem(ThumbnailViewItem* pItem, rtl::OUString sNewTitle)
{
if (mpMasterView)
return mpMasterView->renameItem(pItem, sNewTitle);
return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -257,9 +257,6 @@ void ThumbnailView::CalculateItemPositions () ...@@ -257,9 +257,6 @@ void ThumbnailView::CalculateItemPositions ()
if ( !mnLines ) if ( !mnLines )
mnLines = 1; mnLines = 1;
// check if scroll is needed
mbScroll = mnLines > mnVisLines;
if ( mnLines <= mnVisLines ) if ( mnLines <= mnVisLines )
mnFirstLine = 0; mnFirstLine = 0;
else else
...@@ -373,7 +370,11 @@ void ThumbnailView::CalculateItemPositions () ...@@ -373,7 +370,11 @@ void ThumbnailView::CalculateItemPositions ()
// arrange ScrollBar, set values and show it // arrange ScrollBar, set values and show it
if ( mpScrBar ) if ( mpScrBar )
{ {
long nLines = (nCurCount+mnCols-1)/mnCols; mnLines = (nCurCount+mnCols-1)/mnCols;
// check if scroll is needed
mbScroll = mnLines > mnVisLines;
Point aPos( aWinSize.Width() - nScrBarWidth - mnScrBarOffset, mnHeaderHeight ); Point aPos( aWinSize.Width() - nScrBarWidth - mnScrBarOffset, mnHeaderHeight );
Size aSize( nScrBarWidth - mnScrBarOffset, aWinSize.Height() - mnHeaderHeight ); Size aSize( nScrBarWidth - mnScrBarOffset, aWinSize.Height() - mnHeaderHeight );
...@@ -386,7 +387,7 @@ void ThumbnailView::CalculateItemPositions () ...@@ -386,7 +387,7 @@ void ThumbnailView::CalculateItemPositions ()
if ( nPageSize < 1 ) if ( nPageSize < 1 )
nPageSize = 1; nPageSize = 1;
mpScrBar->SetPageSize( nPageSize ); mpScrBar->SetPageSize( nPageSize );
mpScrBar->Show( nLines > mnVisLines ); mpScrBar->Show( mbScroll );
} }
// delete ScrollBar // delete ScrollBar
...@@ -599,12 +600,13 @@ void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -599,12 +600,13 @@ void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt )
if ( rMEvt.GetClicks() == 1 ) if ( rMEvt.GetClicks() == 1 )
{ {
if (pItem->isSelected() && rMEvt.IsMod1()) if (pItem->isSelected() && rMEvt.IsMod1())
DeselectItem( pItem->mnId ); pItem->setSelection(false);
else else
{ {
if (!pItem->isSelected() && !rMEvt.IsMod1()) if (!pItem->isSelected() && !rMEvt.IsMod1())
deselectItems( ); deselectItems( );
SelectItem( pItem->mnId );
pItem->setSelection(true);
bool bClickOnTitle = pItem->getTextArea().IsInside(rMEvt.GetPosPixel()); bool bClickOnTitle = pItem->getTextArea().IsInside(rMEvt.GetPosPixel());
pItem->setEditTitle(bClickOnTitle); pItem->setEditTitle(bClickOnTitle);
...@@ -806,6 +808,13 @@ void ThumbnailView::RemoveItem( sal_uInt16 nItemId ) ...@@ -806,6 +808,13 @@ void ThumbnailView::RemoveItem( sal_uInt16 nItemId )
if ( nPos < mItemList.size() ) { if ( nPos < mItemList.size() ) {
ValueItemList::iterator it = mItemList.begin(); ValueItemList::iterator it = mItemList.begin();
::std::advance( it, nPos ); ::std::advance( it, nPos );
if ((*it)->isSelected())
{
(*it)->setSelection(false);
maItemStateHdl.Call(*it);
}
delete *it; delete *it;
mItemList.erase( it ); mItemList.erase( it );
} }
...@@ -836,6 +845,21 @@ void ThumbnailView::Clear() ...@@ -836,6 +845,21 @@ void ThumbnailView::Clear()
Invalidate(); Invalidate();
} }
void ThumbnailView::updateItems (const std::vector<ThumbnailViewItem*> &items)
{
ImplDeleteItems();
// reset variables
mnFirstLine = 0;
mnHighItemId = 0;
mItemList = items;
CalculateItemPositions();
Invalidate();
}
size_t ThumbnailView::GetItemPos( sal_uInt16 nItemId ) const size_t ThumbnailView::GetItemPos( sal_uInt16 nItemId ) const
{ {
for ( size_t i = 0, n = mItemList.size(); i < n; ++i ) { for ( size_t i = 0, n = mItemList.size(); i < n; ++i ) {
......
This diff is collapsed.
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