summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRachit Gupta <rachitgupta1792@gmail.com>2014-06-15 10:05:34 +0530
committerRachit Gupta <rachitgupta1792@gmail.com>2014-06-15 10:30:50 +0530
commitff69ba7d792eed61eff517bbd947fd721382a8d3 (patch)
tree6cfea92d8d7cb14a5ef595fe1a6b9cdd428a1215
parentc57b0961cf9337436f14a4d6c51619bfe4924325 (diff)
Added check for no results.
The XML root node contains total_results attribute. If there are no results matching the search term, then the user is notified of it. Change-Id: I4b2ae5efe4af700dbc7a554a22a558f94c56e3bc
-rw-r--r--cui/source/options/personalization.cxx11
-rw-r--r--cui/source/options/personasdochandler.cxx15
-rw-r--r--cui/source/options/personasdochandler.hxx6
3 files changed, 25 insertions, 7 deletions
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index 2cc6cf8e303a..0379a47610bb 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -223,6 +223,8 @@ void SelectPersonaDialog::ClearSearchResults()
{
m_vPersonaSettings.clear();
m_aSelectedPersona = "";
+ for( sal_Int32 nIndex = 0; nIndex < 9; nIndex++ )
+ m_vResultList[nIndex]->Hide();
}
SvxPersonalizationTabPage::SvxPersonalizationTabPage( Window *pParent, const SfxItemSet &rSet )
@@ -435,6 +437,13 @@ void SearchAndParseThread::execute()
aParserInput.aInputStream = xStream;
xParser->parseStream( aParserInput );
+ if( !pHandler->hasResults() )
+ {
+ sProgress = "No results found.";
+ m_pPersonaDialog->SetProgress( sProgress );
+ return;
+ }
+
std::vector<OUString> vLearnmoreURLs = pHandler->getLearnmoreURLs();
std::vector<OUString>::iterator it;
std::vector<Image> vResultList;
@@ -537,7 +546,7 @@ void SearchAndParseThread::getPreviewFile( const OUString& rURL, OUString *pHead
}
catch (...)
{
- sProgress = "Something went wrong. Please try again.";
+ OUString sProgress = "Something went wrong. Please try again.";
m_pPersonaDialog->SetProgress( sProgress );
return;
}
diff --git a/cui/source/options/personasdochandler.cxx b/cui/source/options/personasdochandler.cxx
index 521b561bca70..020b9fc170b3 100644
--- a/cui/source/options/personasdochandler.cxx
+++ b/cui/source/options/personasdochandler.cxx
@@ -29,7 +29,7 @@ void SAL_CALL
PersonasDocHandler::characters( const OUString & aChars)
throw ( xml::sax::SAXException, RuntimeException, std::exception )
{
- if( m_bLearnmoreTag )
+ if( m_isLearnmoreTag )
m_vLearnmoreURLs.push_back( aChars );
}
@@ -55,14 +55,21 @@ PersonasDocHandler::setDocumentLocator(
void SAL_CALL
PersonasDocHandler::startElement( const OUString& aName,
- const Reference< xml::sax::XAttributeList > & )
+ const Reference< xml::sax::XAttributeList > &xAttribs )
throw ( xml::sax::SAXException,
RuntimeException, std::exception )
{
+ if( aName == "searchresults" )
+ {
+ OUString aTotalResults = xAttribs->getValueByName( "total_results" );
+ if( !aTotalResults.equals( "0" ) )
+ m_hasResults = true;
+ }
+
if ( aName == "learnmore" )
- m_bLearnmoreTag = true;
+ m_isLearnmoreTag = true;
else
- m_bLearnmoreTag = false;
+ m_isLearnmoreTag = false;
}
void SAL_CALL PersonasDocHandler::endElement( const OUString & )
diff --git a/cui/source/options/personasdochandler.hxx b/cui/source/options/personasdochandler.hxx
index d38f0f3c6ed3..238345246803 100644
--- a/cui/source/options/personasdochandler.hxx
+++ b/cui/source/options/personasdochandler.hxx
@@ -19,10 +19,12 @@ class PersonasDocHandler : public ::cppu::WeakImplHelper1< css::xml::sax::XDocum
{
private:
std::vector<OUString> m_vLearnmoreURLs;
- bool m_bLearnmoreTag;
+ bool m_isLearnmoreTag, m_hasResults;
public:
- PersonasDocHandler(){ m_bLearnmoreTag = false; }
+ PersonasDocHandler(){ m_isLearnmoreTag = false; m_hasResults = false; }
std::vector<OUString> getLearnmoreURLs() { return m_vLearnmoreURLs; }
+ bool hasResults() { return m_hasResults; }
+
// XDocumentHandler
virtual void SAL_CALL startDocument()
throw ( css::xml::sax::SAXException, css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;