diff options
-rw-r--r-- | include/sfx2/templatelocalview.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/templatelocalview.cxx | 16 | ||||
-rw-r--r-- | sfx2/source/dialog/backingwindow.cxx | 16 |
3 files changed, 30 insertions, 4 deletions
diff --git a/include/sfx2/templatelocalview.hxx b/include/sfx2/templatelocalview.hxx index 139fa70850c3..02cc26a352ab 100644 --- a/include/sfx2/templatelocalview.hxx +++ b/include/sfx2/templatelocalview.hxx @@ -37,6 +37,8 @@ public: // Fill view with template folders thumbnails virtual void Populate (); + bool HasUnfilteredItems(FILTER_APPLICATION App); + virtual void reload (); virtual void showRootRegion (); diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index a6933a372f9a..4d85a202ff74 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -59,6 +59,22 @@ TemplateLocalView::~TemplateLocalView() delete mpDocTemplates; } +bool TemplateLocalView::HasUnfilteredItems(FILTER_APPLICATION App) +{ + ViewFilter_Application aFilter(App); + bool bFound = false; + for (size_t i = 0; !bFound && i < maRegions.size(); ++i) + { + TemplateContainerItem *pFolderItem = maRegions[i]; + + for (size_t j = 0; !bFound && j < pFolderItem->maTemplates.size(); ++j) + { + bFound = aFilter.isValid(pFolderItem->maTemplates[j].aPath); + } + } + return bFound; +} + void TemplateLocalView::Populate () { for (size_t i = 0; i < maRegions.size(); ++i) diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index 4bff268a6bdb..4b6d7490d2cc 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -369,11 +369,19 @@ void BackingWindow::setupTemplateView( TemplateLocalView* pView, FILTER_APPLICAT pView->showRootRegion(); pView->setOpenTemplateHdl( LINK( this, BackingWindow, OpenTemplateHdl ) ); - // setup buttons - pRecentButton->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) ); - pTemplateButton->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) ); + if( pView->HasUnfilteredItems(eFilter) ) + { + // setup buttons + pRecentButton->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) ); + pTemplateButton->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) ); - pRecentButton->Hide(); // hidden by default + pRecentButton->Hide(); // hidden by default + } + else // no templates, hide toggle button + { + pTemplateButton->Hide(); + pRecentButton->Hide(); + } } void BackingWindow::Paint( const Rectangle& ) { |