summaryrefslogtreecommitdiffstats
path: root/sfx2
diff options
context:
space:
mode:
authorRafael Dominguez <venccsralph@gmail.com>2012-07-29 23:30:47 -0430
committerRafael Dominguez <venccsralph@gmail.com>2012-07-29 23:34:34 -0430
commite09046cede7ae47615f404474fe289d89f91dac5 (patch)
tree205771d5ddc117c7a475f2fe0ab7bb6fa551ddfe /sfx2
parentDisplay overlay name for online view. (diff)
downloadcore-e09046cede7ae47615f404474fe289d89f91dac5.tar.gz
core-e09046cede7ae47615f404474fe289d89f91dac5.zip
Filter online view templates depending on their type.
- Moved ViewFilter_Application to TemplateAbstractView header. - Removed unused attribute in ViewFilter_Application. Change-Id: I569f6a0c7135781256e348b01cb45aad6b7dcee6
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sfx2/templateabstractview.hxx28
-rw-r--r--sfx2/inc/sfx2/templatelocalview.hxx11
-rw-r--r--sfx2/inc/sfx2/templateonlineview.hxx2
-rw-r--r--sfx2/source/control/templateabstractview.cxx29
-rw-r--r--sfx2/source/control/templatelocalview.cxx47
-rw-r--r--sfx2/source/control/templateonlineview.cxx6
-rw-r--r--sfx2/source/doc/templatedlg.cxx10
7 files changed, 73 insertions, 60 deletions
diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx
index 74dcd8a0ff6b..a4b1daf13ce7 100644
--- a/sfx2/inc/sfx2/templateabstractview.hxx
+++ b/sfx2/inc/sfx2/templateabstractview.hxx
@@ -13,6 +13,32 @@
#include <sfx2/thumbnailview.hxx>
class TemplateView;
+class SfxDocumentTemplates;
+
+enum FILTER_APPLICATION
+{
+ FILTER_APP_NONE,
+ FILTER_APP_WRITER,
+ FILTER_APP_CALC,
+ FILTER_APP_IMPRESS,
+ FILTER_APP_DRAW
+};
+
+// Display template items depending on the generator application
+class ViewFilter_Application
+{
+public:
+
+ ViewFilter_Application (FILTER_APPLICATION App)
+ : mApp(App)
+ {}
+
+ bool operator () (const ThumbnailViewItem *pItem);
+
+private:
+
+ FILTER_APPLICATION mApp;
+};
class SFX2_DLLPUBLIC TemplateAbstractView : public ThumbnailView
{
@@ -27,6 +53,8 @@ public:
// Fill view with template folders thumbnails
virtual void Populate () = 0;
+ virtual void filterTemplatesByApp (const FILTER_APPLICATION &eApp) = 0;
+
virtual void showOverlay (bool bVisible) = 0;
sal_uInt16 getOverlayRegionId () const;
diff --git a/sfx2/inc/sfx2/templatelocalview.hxx b/sfx2/inc/sfx2/templatelocalview.hxx
index f3161e7d3616..67a56ae5d5a9 100644
--- a/sfx2/inc/sfx2/templatelocalview.hxx
+++ b/sfx2/inc/sfx2/templatelocalview.hxx
@@ -18,15 +18,6 @@
class SfxDocumentTemplates;
class TemplateLocalViewItem;
-enum FILTER_APPLICATION
-{
- FILTER_APP_NONE,
- FILTER_APP_WRITER,
- FILTER_APP_CALC,
- FILTER_APP_IMPRESS,
- FILTER_APP_DRAW
-};
-
class SFX2_DLLPUBLIC TemplateLocalView : public TemplateAbstractView
{
public:
@@ -42,7 +33,7 @@ public:
virtual void showOverlay (bool bVisible);
- void filterTemplatesByApp (const FILTER_APPLICATION &eApp);
+ virtual void filterTemplatesByApp (const FILTER_APPLICATION &eApp);
std::vector<TemplateItemProperties>
getFilteredItems (const boost::function<bool (const TemplateItemProperties&) > &rFunc) const;
diff --git a/sfx2/inc/sfx2/templateonlineview.hxx b/sfx2/inc/sfx2/templateonlineview.hxx
index e868248e25d8..245da5f2d051 100644
--- a/sfx2/inc/sfx2/templateonlineview.hxx
+++ b/sfx2/inc/sfx2/templateonlineview.hxx
@@ -25,6 +25,8 @@ public:
// Load repositories from user settings.
virtual void Populate ();
+ virtual void filterTemplatesByApp (const FILTER_APPLICATION &eApp);
+
virtual void showOverlay (bool bVisible);
void setItemDimensions (long ItemWidth, long ThumbnailHeight, long DisplayHeight, int itemPadding);
diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx
index 8f8d78b5f67d..fbe2378f4298 100644
--- a/sfx2/source/control/templateabstractview.cxx
+++ b/sfx2/source/control/templateabstractview.cxx
@@ -11,6 +11,7 @@
#include <comphelper/processfactory.hxx>
#include <sfx2/templateview.hxx>
+#include <sfx2/templateviewitem.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <vcl/pngread.hxx>
@@ -20,6 +21,34 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+bool ViewFilter_Application::operator () (const ThumbnailViewItem *pItem)
+{
+ const TemplateViewItem *pTempItem = static_cast<const TemplateViewItem*>(pItem);
+
+ if (mApp == FILTER_APP_WRITER)
+ {
+ return pTempItem->getFileType() == "OpenDocument Text" ||
+ pTempItem->getFileType() == "OpenDocument Text Template";
+ }
+ else if (mApp == FILTER_APP_CALC)
+ {
+ return pTempItem->getFileType() == "OpenDocument Spreadsheet" ||
+ pTempItem->getFileType() == "OpenDocument Spreadsheet Template";
+ }
+ else if (mApp == FILTER_APP_IMPRESS)
+ {
+ return pTempItem->getFileType() == "OpenDocument Presentation" ||
+ pTempItem->getFileType() == "OpenDocument Presentation Template";
+ }
+ else if (mApp == FILTER_APP_DRAW)
+ {
+ return pTempItem->getFileType() == "OpenDocument Drawing" ||
+ pTempItem->getFileType() == "OpenDocument Drawing Template";
+ }
+
+ return true;
+}
+
TemplateAbstractView::TemplateAbstractView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren)
: ThumbnailView(pParent,nWinStyle,bDisableTransientChildren),
mpItemView(new TemplateView(this))
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index fa19d5463a44..e1916da1bd37 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -38,49 +38,6 @@
void lcl_updateThumbnails (TemplateLocalViewItem *pItem);
-// Display template items depending on the generator application
-class ViewFilter_Application
-{
-public:
-
- ViewFilter_Application (SfxDocumentTemplates *pDocTemplates, FILTER_APPLICATION App)
- : mApp(App), mpDocTemplates(pDocTemplates)
- {}
-
- bool operator () (const ThumbnailViewItem *pItem)
- {
- const TemplateViewItem *pTempItem = static_cast<const TemplateViewItem*>(pItem);
-
- if (mApp == FILTER_APP_WRITER)
- {
- return pTempItem->getFileType() == "OpenDocument Text" ||
- pTempItem->getFileType() == "OpenDocument Text Template";
- }
- else if (mApp == FILTER_APP_CALC)
- {
- return pTempItem->getFileType() == "OpenDocument Spreadsheet" ||
- pTempItem->getFileType() == "OpenDocument Spreadsheet Template";
- }
- else if (mApp == FILTER_APP_IMPRESS)
- {
- return pTempItem->getFileType() == "OpenDocument Presentation" ||
- pTempItem->getFileType() == "OpenDocument Presentation Template";
- }
- else if (mApp == FILTER_APP_DRAW)
- {
- return pTempItem->getFileType() == "OpenDocument Drawing" ||
- pTempItem->getFileType() == "OpenDocument Drawing Template";
- }
-
- return true;
- }
-
-private:
-
- FILTER_APPLICATION mApp;
- SfxDocumentTemplates *mpDocTemplates;
-};
-
class FolderFilter_Application
{
public:
@@ -266,7 +223,7 @@ void TemplateLocalView::filterTemplatesByApp (const FILTER_APPLICATION &eApp)
if (mpItemView->IsVisible())
{
mbFilteredResults = true;
- mpItemView->filterItems(ViewFilter_Application(mpDocTemplates,eApp));
+ mpItemView->filterItems(ViewFilter_Application(eApp));
}
else
{
@@ -642,7 +599,7 @@ void TemplateLocalView::OnItemDblClicked (ThumbnailViewItem *pRegionItem)
mpItemView->setSelectionMode(true);
if (meFilterOption != FILTER_APP_NONE)
- mpItemView->filterItems(ViewFilter_Application(mpDocTemplates,meFilterOption));
+ mpItemView->filterItems(ViewFilter_Application(meFilterOption));
mbActive = false;
mpItemView->Show();
diff --git a/sfx2/source/control/templateonlineview.cxx b/sfx2/source/control/templateonlineview.cxx
index 2f88ca040050..822145cff05e 100644
--- a/sfx2/source/control/templateonlineview.cxx
+++ b/sfx2/source/control/templateonlineview.cxx
@@ -93,6 +93,12 @@ void TemplateOnlineView::Populate()
Invalidate();
}
+void TemplateOnlineView::filterTemplatesByApp(const FILTER_APPLICATION &eApp)
+{
+ if (mpItemView->IsVisible())
+ mpItemView->filterItems(ViewFilter_Application(eApp));
+}
+
void TemplateOnlineView::showOverlay (bool bVisible)
{
mbActive = !bVisible;
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index f37130e77aea..28b7f8604b1e 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -264,31 +264,31 @@ SfxTemplateManagerDlg::~SfxTemplateManagerDlg ()
IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewAllHdl)
{
- maView->filterTemplatesByApp(FILTER_APP_NONE);
+ mpCurView->filterTemplatesByApp(FILTER_APP_NONE);
return 0;
}
IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewDocsHdl)
{
- maView->filterTemplatesByApp(FILTER_APP_WRITER);
+ mpCurView->filterTemplatesByApp(FILTER_APP_WRITER);
return 0;
}
IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewPresentsHdl)
{
- maView->filterTemplatesByApp(FILTER_APP_IMPRESS);
+ mpCurView->filterTemplatesByApp(FILTER_APP_IMPRESS);
return 0;
}
IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewSheetsHdl)
{
- maView->filterTemplatesByApp(FILTER_APP_CALC);
+ mpCurView->filterTemplatesByApp(FILTER_APP_CALC);
return 0;
}
IMPL_LINK_NOARG(SfxTemplateManagerDlg,ViewDrawsHdl)
{
- maView->filterTemplatesByApp(FILTER_APP_DRAW);
+ mpCurView->filterTemplatesByApp(FILTER_APP_DRAW);
return 0;
}