summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorRafael Dominguez <venccsralph@gmail.com>2013-03-27 13:38:57 -0430
committerMiklos Vajna <vmiklos@suse.cz>2013-04-08 07:37:53 +0000
commitde1da2122210c8bc4649071e231bbb0bd53e31d3 (patch)
treead633fa277b221039bc0e4230eff604203466d8f /sfx2
parented5525620852afabbe1a36f84ea65a025c11c146 (diff)
Filter search results by type and keyword in Template Manager.
Change-Id: I612b0b87340a50f0e5ec69ec4e8b2beba13cab36 Reviewed-on: https://gerrit.libreoffice.org/3244 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/templatedlg.cxx48
1 files changed, 44 insertions, 4 deletions
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 825147a8b0f2..f4465dd49ef9 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -85,18 +85,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;
};
/***
@@ -664,8 +687,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)
{