diff options
author | Rachit Gupta <rachitgupta1792@gmail.com> | 2014-06-15 10:05:34 +0530 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-08-14 19:43:27 +0200 |
commit | ad9bfe8ff76bd8e3f6011d827e63c9ad676a0f00 (patch) | |
tree | e095ca95301924cc4b99b2d67fb2fc366fb9dde0 /cui | |
parent | 2304f034779d805aa1cc834cf888f98f4a74a6ac (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
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/options/personalization.cxx | 11 | ||||
-rw-r--r-- | cui/source/options/personasdochandler.cxx | 15 | ||||
-rw-r--r-- | cui/source/options/personasdochandler.hxx | 6 |
3 files changed, 25 insertions, 7 deletions
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index 4d6702c8edca..52e52b314f38 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; |