sfx2/inc/sfx2/templateabstractview.hxx | 17 +++++++ sfx2/inc/sfx2/templateonlineview.hxx | 5 -- sfx2/inc/sfx2/templateonlineviewitem.hxx | 8 +++ sfx2/source/control/templateabstractview.cxx | 13 ++++++ sfx2/source/control/templateonlineview.cxx | 20 ++++++--- sfx2/source/doc/templatedlg.cxx | 58 +++++++++++++++++---------- 6 files changed, 92 insertions(+), 29 deletions(-)
New commits: commit 393e7add0b2c7f4f96dc309f7dcdf8d82e0ff813 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Aug 2 21:27:00 2012 -0430 Display all templates in the overlay if we hide the search bar. Change-Id: I4af95a758912e5d4c885f889fd2dedb48472f7b6 diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 9982f5d..96ab14b 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -792,6 +792,10 @@ void SfxTemplateManagerDlg::OnTemplateSearch () mpSearchEdit->Show(!bVisible); mpSearchEdit->SetText(rtl::OUString()); + + // display all templates if we hide the search bar + if (bVisible && mpCurView->isOverlayVisible()) + mpCurView->filterTemplatesByApp(FILTER_APP_NONE); } void SfxTemplateManagerDlg::OnTemplateEdit () commit 5918b4b1808afdf85682d471024d6ae1f20fd8eb Author: Rafael Dominguez <venccsra...@gmail.com> Date: Thu Aug 2 21:11:18 2012 -0430 Filter overlay templates by a search keyword. Change-Id: I8bcb193d1400c32b6292fd109422d22dbf8b1eb9 diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx index a4b1daf..1907e5c 100644 --- a/sfx2/inc/sfx2/templateabstractview.hxx +++ b/sfx2/inc/sfx2/templateabstractview.hxx @@ -40,6 +40,21 @@ private: FILTER_APPLICATION mApp; }; +class ViewFilter_Keyword +{ +public: + + ViewFilter_Keyword (const OUString &rKeyword) + : maKeyword(rKeyword) + {} + + bool operator () (const ThumbnailViewItem *pItem); + +private: + + OUString maKeyword; +}; + class SFX2_DLLPUBLIC TemplateAbstractView : public ThumbnailView { public: @@ -65,6 +80,8 @@ public: void sortOverlayItems (const boost::function<bool (const ThumbnailViewItem*, const ThumbnailViewItem*) > &func); + virtual void filterTemplatesByKeyword (const OUString &rKeyword); + void setOverlayItemStateHdl (const Link &aLink) { maOverlayItemStateHdl = aLink; } void setOverlayDblClickHdl (const Link &rLink); diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index fbe2378..0554c9d 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -49,6 +49,13 @@ bool ViewFilter_Application::operator () (const ThumbnailViewItem *pItem) return true; } +bool ViewFilter_Keyword::operator ()(const ThumbnailViewItem *pItem) +{ + assert(pItem); + + return pItem->maTitle.matchIgnoreAsciiCase(maKeyword); +} + TemplateAbstractView::TemplateAbstractView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren) : ThumbnailView(pParent,nWinStyle,bDisableTransientChildren), mpItemView(new TemplateView(this)) @@ -84,6 +91,12 @@ void TemplateAbstractView::sortOverlayItems(const boost::function<bool (const Th mpItemView->sortItems(func); } +void TemplateAbstractView::filterTemplatesByKeyword(const OUString &rKeyword) +{ + if (mpItemView->IsVisible()) + mpItemView->filterItems(ViewFilter_Keyword(rKeyword)); +} + void TemplateAbstractView::setOverlayDblClickHdl(const Link &rLink) { mpItemView->setDblClickHdl(rLink); diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index d3eff74..9982f5d 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -624,7 +624,7 @@ IMPL_LINK(SfxTemplateManagerDlg, OpenTemplateHdl, ThumbnailViewItem*, pItem) IMPL_LINK_NOARG(SfxTemplateManagerDlg, SearchUpdateHdl) { // if the search view is hidden, hide the folder view and display search one - if (!mpSearchView->IsVisible()) + if (!mpCurView->isOverlayVisible() && !mpSearchView->IsVisible()) { mpSearchView->Clear(); mpSearchView->Show(); @@ -635,30 +635,44 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, SearchUpdateHdl) if (!aKeyword.isEmpty()) { - mpSearchView->Clear(); - - std::vector<TemplateItemProperties> aItems = - maView->getFilteredItems(SearchView_Keyword(aKeyword)); - - size_t nCounter = 0; - for (size_t i = 0; i < aItems.size(); ++i) + if (mpCurView->isOverlayVisible()) { - TemplateItemProperties *pItem = &aItems[i]; - - mpSearchView->AppendItem(++nCounter,pItem->nRegionId, - pItem->nId-1, - pItem->aName, - maView->GetItemText(pItem->nRegionId+1), - pItem->aPath, - pItem->aThumbnail); + mpCurView->filterTemplatesByKeyword(aKeyword); } + else + { + mpSearchView->Clear(); + + std::vector<TemplateItemProperties> aItems = + maView->getFilteredItems(SearchView_Keyword(aKeyword)); + + size_t nCounter = 0; + for (size_t i = 0; i < aItems.size(); ++i) + { + TemplateItemProperties *pItem = &aItems[i]; + + mpSearchView->AppendItem(++nCounter,pItem->nRegionId, + pItem->nId-1, + pItem->aName, + maView->GetItemText(pItem->nRegionId+1), + pItem->aPath, + pItem->aThumbnail); + } - mpSearchView->Invalidate(); + mpSearchView->Invalidate(); + } } else { - mpSearchView->Hide(); - mpCurView->Show(); + if (mpCurView->isOverlayVisible()) + { + mpCurView->filterTemplatesByApp(FILTER_APP_NONE); + } + else + { + mpSearchView->Hide(); + mpCurView->Show(); + } } return 0; commit 3fa5a70375083e5f201d6b62f418e9778446e2f5 Author: Rafael Dominguez <venccsra...@gmail.com> Date: Wed Aug 1 07:13:38 2012 -0430 Cache results for remote repositories. - Only fetch template list when its the first time or when specified. Change-Id: I922e97dfcbf67cebdd66a85bd7ff204896757e52 diff --git a/sfx2/inc/sfx2/templateonlineview.hxx b/sfx2/inc/sfx2/templateonlineview.hxx index 36372e8..0354560 100644 --- a/sfx2/inc/sfx2/templateonlineview.hxx +++ b/sfx2/inc/sfx2/templateonlineview.hxx @@ -11,6 +11,7 @@ #define __SFX2_TEMPLATEONLINEVIEW_HXX__ #include <sfx2/templateabstractview.hxx> +#include <sfx2/templateproperties.hxx> #include <com/sun/star/ucb/XCommandEnvironment.hpp> @@ -31,7 +32,7 @@ public: virtual void showOverlay (bool bVisible); - bool loadRepository (const sal_uInt16 nRepositoryId); + bool loadRepository (const sal_uInt16 nRepositoryId, bool bRefresh); const std::vector<TemplateOnlineViewItem*>& getRepositories () const { return maRepositories; } diff --git a/sfx2/inc/sfx2/templateonlineviewitem.hxx b/sfx2/inc/sfx2/templateonlineviewitem.hxx index 1d9f9cd..07996b3 100644 --- a/sfx2/inc/sfx2/templateonlineviewitem.hxx +++ b/sfx2/inc/sfx2/templateonlineviewitem.hxx @@ -11,6 +11,7 @@ #define __SFX2_TEMPLATEONLINEVIEWITEM_HXX__ #include <sfx2/thumbnailviewitem.hxx> +#include <sfx2/templateproperties.hxx> class TemplateOnlineViewItem : public ThumbnailViewItem { @@ -24,9 +25,16 @@ public: const rtl::OUString& getURL () const { return maUrl; } + void insertTemplate (const TemplateItemProperties &prop) { maTemplates.push_back(prop); } + + void clearTemplates () { maTemplates.clear(); } + + const std::vector<TemplateItemProperties>& getTemplates () const { return maTemplates; } + private: rtl::OUString maUrl; + std::vector<TemplateItemProperties> maTemplates; }; #endif // __SFX2_TEMPLATEONLINEVIEWITEM_HXX__ diff --git a/sfx2/source/control/templateonlineview.cxx b/sfx2/source/control/templateonlineview.cxx index 7087b35..b8b978f 100644 --- a/sfx2/source/control/templateonlineview.cxx +++ b/sfx2/source/control/templateonlineview.cxx @@ -113,7 +113,7 @@ void TemplateOnlineView::showOverlay (bool bVisible) } } -bool TemplateOnlineView::loadRepository (const sal_uInt16 nRepositoryId) +bool TemplateOnlineView::loadRepository (const sal_uInt16 nRepositoryId, bool bRefresh) { TemplateOnlineViewItem *pItem = NULL; @@ -129,6 +129,9 @@ bool TemplateOnlineView::loadRepository (const sal_uInt16 nRepositoryId) if (!pItem) return false; + if (!pItem->getTemplates().empty() && !bRefresh) + return true; + rtl::OUString aURL = static_cast<TemplateOnlineViewItem*>(pItem)->getURL(); try @@ -158,6 +161,7 @@ bool TemplateOnlineView::loadRepository (const sal_uInt16 nRepositoryId) if ( xResultSet.is() ) { + pItem->clearTemplates(); mpItemView->Clear(); uno::Reference< XRow > xRow( xResultSet, UNO_QUERY ); @@ -217,6 +221,7 @@ bool TemplateOnlineView::loadRepository (const sal_uInt16 nRepositoryId) aTemplateItem.aType = SvFileInformationManager::GetFileDescription(INetURLObject(sRealURL)); + pItem->insertTemplate(aTemplateItem); aItems.push_back(aTemplateItem); ++nIdx; } diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 765f664..d3eff74 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -590,7 +590,7 @@ IMPL_LINK(SfxTemplateManagerDlg, RepositoryMenuSelectHdl, Menu*, pMenu) { sal_uInt16 nRepoId = nMenuId - MNI_REPOSITORY_BASE; - if (mpOnlineView->loadRepository(nRepoId)) + if (mpOnlineView->loadRepository(nRepoId,false)) { switchMainView(false); mpOnlineView->showOverlay(true); commit f36adaa38ca7a04144c18902343ab52784f4fbae Author: Rafael Dominguez <venccsra...@gmail.com> Date: Tue Jul 31 18:20:54 2012 -0430 Dont store repository information twice. Change-Id: Iaf15cd383abec092932b2b024142d959794f0fdb diff --git a/sfx2/inc/sfx2/templateonlineview.hxx b/sfx2/inc/sfx2/templateonlineview.hxx index d60e048..36372e8 100644 --- a/sfx2/inc/sfx2/templateonlineview.hxx +++ b/sfx2/inc/sfx2/templateonlineview.hxx @@ -43,8 +43,6 @@ private: private: - com::sun::star::uno::Sequence< rtl::OUString > maUrls; - com::sun::star::uno::Sequence< rtl::OUString > maNames; std::vector<TemplateOnlineViewItem*> maRepositories; com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xCmdEnv; }; diff --git a/sfx2/source/control/templateonlineview.cxx b/sfx2/source/control/templateonlineview.cxx index f33d0bd..7087b35 100644 --- a/sfx2/source/control/templateonlineview.cxx +++ b/sfx2/source/control/templateonlineview.cxx @@ -75,16 +75,19 @@ void TemplateOnlineView::Populate() uno::Reference < uno::XComponentContext > m_context(comphelper::getProcessComponentContext()); // Load from user settings - maUrls = officecfg::Office::Common::Misc::FilePickerPlacesUrls::get(m_context); - maNames = officecfg::Office::Common::Misc::FilePickerPlacesNames::get(m_context); + com::sun::star::uno::Sequence< rtl::OUString > aUrls = + officecfg::Office::Common::Misc::FilePickerPlacesUrls::get(m_context); - for (sal_Int32 i = 0; i < maUrls.getLength() && i < maNames.getLength(); ++i) + com::sun::star::uno::Sequence< rtl::OUString > aNames = + officecfg::Office::Common::Misc::FilePickerPlacesNames::get(m_context); + + for (sal_Int32 i = 0; i < aUrls.getLength() && i < aNames.getLength(); ++i) { TemplateOnlineViewItem *pItem = new TemplateOnlineViewItem(*this,this); pItem->mnId = i+1; - pItem->maTitle = maNames[i]; - pItem->setURL(maUrls[i]); + pItem->maTitle = aNames[i]; + pItem->setURL(aUrls[i]); maRepositories.push_back(pItem); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits