diff options
author | Rafael Dominguez <venccsralph@gmail.com> | 2013-03-27 13:38:57 -0430 |
---|---|---|
committer | Rafael Dominguez <venccsralph@gmail.com> | 2013-03-28 00:21:13 -0430 |
commit | 4c29d595b620b80fb3b913611f724376e5aa9dc4 (patch) | |
tree | 7a7dd7f369c7a8d77f480811257a8c8b2ffdaf92 | |
parent | c2f47cf1576ddcf5d7bd63e252b8bc0f61f5f10b (diff) |
Filter search results by type and keyword in Template Manager.
Change-Id: I549d349b9be3a36c35f50ae614a12fcf09315b08
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index c0beedf88762..29aca67044b2 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -86,18 +86,41 @@ class SearchView_Keyword { public: - SearchView_Keyword (const OUString &rKeyword) - : maKeyword(rKeyword) + SearchView_Keyword (const OUString &rKeyword, FILTER_APPLICATION App) + : maKeyword(rKeyword), meApp(App) {} bool operator() (const TemplateItemProperties &rItem) { - return rItem.aName.matchIgnoreAsciiCase(maKeyword); + bool bRet = true; + + INetURLObject aUrl(rItem.aPath); + OUString aExt = aUrl.getExtension(); + + if (meApp == FILTER_APP_WRITER) + { + bRet = aExt == "ott" || aExt == "stw" || aExt == "oth" || aExt == "dot" || aExt == "dotx"; + } + else if (meApp == FILTER_APP_CALC) + { + bRet = aExt == "ots" || aExt == "stc" || aExt == "xlt" || aExt == "xltm" || aExt == "xltx"; + } + else if (meApp == FILTER_APP_IMPRESS) + { + bRet = aExt == "otp" || aExt == "sti" || aExt == "pot" || aExt == "potm" || aExt == "potx"; + } + else if (meApp == FILTER_APP_DRAW) + { + bRet = aExt == "otg" || aExt == "std"; + } + + return bRet && rItem.aName.matchIgnoreAsciiCase(maKeyword); } private: OUString maKeyword; + FILTER_APPLICATION meApp; }; /*** @@ -668,8 +691,25 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, SearchUpdateHdl) bool bDisplayFolder = !mpCurView->isNonRootRegionVisible(); + FILTER_APPLICATION eFilter = FILTER_APP_NONE; + switch (maTabControl.GetCurPageId()) + { + case FILTER_DOCS: + eFilter = FILTER_APP_WRITER; + break; + case FILTER_PRESENTATIONS: + eFilter = FILTER_APP_IMPRESS; + break; + case FILTER_SHEETS: + eFilter = FILTER_APP_CALC; + break; + case FILTER_DRAWS: + eFilter = FILTER_APP_DRAW; + break; + } + std::vector<TemplateItemProperties> aItems = - maView->getFilteredItems(SearchView_Keyword(aKeyword)); + maView->getFilteredItems(SearchView_Keyword(aKeyword,eFilter)); for (size_t i = 0; i < aItems.size(); ++i) { |