Kaydet (Commit) 93f8b703 authored tarafından Julien Nabet's avatar Julien Nabet

Use for-range loops in helpcompiler

Change-Id: I787a5b43cb09ac308082cac0e66540f975d79ead
Reviewed-on: https://gerrit.libreoffice.org/51473Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJulien Nabet <serval2412@yahoo.fr>
üst ea01c61f
...@@ -82,7 +82,7 @@ void BasicCodeTagger::getBasicCodeContainerNodes() ...@@ -82,7 +82,7 @@ void BasicCodeTagger::getBasicCodeContainerNodes()
} }
while ( !m_pXmlTreeWalker->end() ) while ( !m_pXmlTreeWalker->end() )
{ {
m_pXmlTreeWalker->nextNode(); m_pXmlTreeWalker->nextNode();
if ( !( xmlStrcmp( m_pXmlTreeWalker->currentNode()->name, reinterpret_cast<const xmlChar*>("bascode") ) ) ) if ( !( xmlStrcmp( m_pXmlTreeWalker->currentNode()->name, reinterpret_cast<const xmlChar*>("bascode") ) ) )
{ //Found <bascode> { //Found <bascode>
m_BasicCodeContainerTags.push_back( m_pXmlTreeWalker->currentNode() ); //it goes to the end of the list m_BasicCodeContainerTags.push_back( m_pXmlTreeWalker->currentNode() ); //it goes to the end of the list
...@@ -139,14 +139,13 @@ void BasicCodeTagger::tagParagraph( xmlNodePtr paragraph ) ...@@ -139,14 +139,13 @@ void BasicCodeTagger::tagParagraph( xmlNodePtr paragraph )
RTL_TEXTENCODING_UTF8 ); RTL_TEXTENCODING_UTF8 );
std::vector<HighlightPortion> portions; std::vector<HighlightPortion> portions;
m_Highlighter.getHighlightPortions( strLine, portions ); m_Highlighter.getHighlightPortions( strLine, portions );
for (std::vector<HighlightPortion>::iterator i(portions.begin()); for (auto const& portion : portions)
i != portions.end(); ++i)
{ {
OString sToken(OUStringToOString(strLine.copy(i->nBegin, i->nEnd-i->nBegin), RTL_TEXTENCODING_UTF8)); OString sToken(OUStringToOString(strLine.copy(portion.nBegin, portion.nEnd-portion.nBegin), RTL_TEXTENCODING_UTF8));
xmlNodePtr text = xmlNewText(reinterpret_cast<const xmlChar*>(sToken.getStr())); xmlNodePtr text = xmlNewText(reinterpret_cast<const xmlChar*>(sToken.getStr()));
if ( i->tokenType != TokenType::Whitespace ) if ( portion.tokenType != TokenType::Whitespace )
{ {
xmlChar* typeStr = getTypeString( i->tokenType ); xmlChar* typeStr = getTypeString( portion.tokenType );
curNode = xmlNewTextChild( paragraph, nullptr, reinterpret_cast<xmlChar const *>("item"), nullptr ); curNode = xmlNewTextChild( paragraph, nullptr, reinterpret_cast<xmlChar const *>("item"), nullptr );
xmlNewProp( curNode, reinterpret_cast<xmlChar const *>("type"), typeStr ); xmlNewProp( curNode, reinterpret_cast<xmlChar const *>("type"), typeStr );
xmlAddChild( curNode, text ); xmlAddChild( curNode, text );
......
...@@ -418,10 +418,9 @@ void myparser::traverse( xmlNodePtr parentNode ) ...@@ -418,10 +418,9 @@ void myparser::traverse( xmlNodePtr parentNode )
//TODO: make these asserts and flush out all our broken help ids //TODO: make these asserts and flush out all our broken help ids
SAL_WARN_IF(hidstr.empty(), "helpcompiler", "hid='' for text:" << text); SAL_WARN_IF(hidstr.empty(), "helpcompiler", "hid='' for text:" << text);
SAL_WARN_IF(!hidstr.empty() && extendedHelpText.empty(), "helpcompiler", "hid='.' with no hid bookmark branches in file: " << fileName + " for text: " << text); SAL_WARN_IF(!hidstr.empty() && extendedHelpText.empty(), "helpcompiler", "hid='.' with no hid bookmark branches in file: " << fileName + " for text: " << text);
HashSet::const_iterator aEnd = extendedHelpText.end(); for (auto const& elem : extendedHelpText)
for (HashSet::const_iterator iter = extendedHelpText.begin(); iter != aEnd; ++iter)
{ {
std::string name = *iter; std::string name = elem;
(*helptexts)[name] = text; (*helptexts)[name] = text;
} }
} }
......
...@@ -60,8 +60,9 @@ bool HelpIndexer::indexDocuments() ...@@ -60,8 +60,9 @@ bool HelpIndexer::indexDocuments()
// Index the identified help files // Index the identified help files
Document doc; Document doc;
for (std::set<OUString>::iterator i = d_files.begin(); i != d_files.end(); ++i) { for (auto const& elem : d_files)
helpDocument(*i, &doc); {
helpDocument(elem, &doc);
writer.addDocument(&doc); writer.addDocument(&doc);
doc.clear(); doc.clear();
} }
......
...@@ -140,9 +140,8 @@ struct Data ...@@ -140,9 +140,8 @@ struct Data
std::string getString() const std::string getString() const
{ {
std::string ret; std::string ret;
cIter aEnd = _idList.end(); for (auto const& elem : _idList)
for (cIter aIter = _idList.begin(); aIter != aEnd; ++aIter) ret += elem + ";";
ret += *aIter + ";";
return ret; return ret;
} }
}; };
...@@ -190,9 +189,8 @@ public: ...@@ -190,9 +189,8 @@ public:
if( pFile == nullptr ) if( pFile == nullptr )
return; return;
DataHashtable::const_iterator aEnd = _hash.end(); for (auto const& elem : _hash)
for (DataHashtable::const_iterator aIter = _hash.begin(); aIter != aEnd; ++aIter) writeKeyValue_DBHelp( pFile, elem.first, elem.second.getString() );
writeKeyValue_DBHelp( pFile, aIter->first, aIter->second.getString() );
fclose( pFile ); fclose( pFile );
} }
...@@ -310,13 +308,12 @@ void HelpLinker::link() ...@@ -310,13 +308,12 @@ void HelpLinker::link()
initIndexerPreProcessor(); initIndexerPreProcessor();
// here we start our loop over the hzip files. // here we start our loop over the hzip files.
HashSet::iterator end = helpFiles.end(); for (auto const& helpFile : helpFiles)
for (HashSet::iterator iter = helpFiles.begin(); iter != end; ++iter)
{ {
// process one file // process one file
// streamTable contains the streams in the hzip file // streamTable contains the streams in the hzip file
StreamTable streamTable; StreamTable streamTable;
const std::string &xhpFileName = *iter; const std::string &xhpFileName = helpFile;
if (!bExtensionMode && xhpFileName.rfind(".xhp") != xhpFileName.length()-4) if (!bExtensionMode && xhpFileName.rfind(".xhp") != xhpFileName.length()-4)
{ {
...@@ -390,11 +387,9 @@ void HelpLinker::link() ...@@ -390,11 +387,9 @@ void HelpLinker::link()
if (hidlist && !hidlist->empty()) if (hidlist && !hidlist->empty())
{ {
// now iterate over all elements of the hidlist // now iterate over all elements of the hidlist
HashSet::const_iterator aEnd = hidlist->end(); for (auto & elem : *hidlist)
for (HashSet::const_iterator hidListIter = hidlist->begin();
hidListIter != aEnd; ++hidListIter)
{ {
std::string thishid = *hidListIter; std::string thishid = elem;
std::string anchorB; std::string anchorB;
size_t index = thishid.rfind('#'); size_t index = thishid.rfind('#');
...@@ -412,21 +407,17 @@ void HelpLinker::link() ...@@ -412,21 +407,17 @@ void HelpLinker::link()
if (anchorToLL && !anchorToLL->empty()) if (anchorToLL && !anchorToLL->empty())
{ {
std::string fakedHid = URLEncoder::encode(documentPath); std::string fakedHid = URLEncoder::encode(documentPath);
Hashtable::const_iterator aEnd = anchorToLL->end(); for (auto const& elemAnchor : *anchorToLL)
for (Hashtable::const_iterator enumer = anchorToLL->begin();
enumer != aEnd; ++enumer)
{ {
const std::string &anchor = enumer->first; const std::string &anchor = elemAnchor.first;
addBookmark(pFileDbBase_DBHelp, documentPath, fileB, addBookmark(pFileDbBase_DBHelp, documentPath, fileB,
anchor, jarfileB, titleB); anchor, jarfileB, titleB);
std::string totalId = fakedHid + "#" + anchor; std::string totalId = fakedHid + "#" + anchor;
// std::cerr << hzipFileName << std::endl; // std::cerr << hzipFileName << std::endl;
const LinkedList& ll = enumer->second; const LinkedList& ll = elemAnchor.second;
LinkedList::const_iterator aOtherEnd = ll.end(); for (auto const& elem : ll)
for (LinkedList::const_iterator llIter = ll.begin();
llIter != aOtherEnd; ++llIter)
{ {
helpKeyword.insert(*llIter, totalId); helpKeyword.insert(elem, totalId);
} }
} }
...@@ -436,12 +427,10 @@ void HelpLinker::link() ...@@ -436,12 +427,10 @@ void HelpLinker::link()
const Stringtable *helpTextHash = streamTable.appl_helptexts; const Stringtable *helpTextHash = streamTable.appl_helptexts;
if (helpTextHash && !helpTextHash->empty()) if (helpTextHash && !helpTextHash->empty())
{ {
Stringtable::const_iterator aEnd = helpTextHash->end(); for (auto const& elem : *helpTextHash)
for (Stringtable::const_iterator helpTextIter = helpTextHash->begin();
helpTextIter != aEnd; ++helpTextIter)
{ {
std::string helpTextId = helpTextIter->first; std::string helpTextId = elem.first;
const std::string& helpTextText = helpTextIter->second; const std::string& helpTextText = elem.second;
helpTextId = URLEncoder::encode(helpTextId); helpTextId = URLEncoder::encode(helpTextId);
...@@ -486,12 +475,10 @@ void HelpLinker::link() ...@@ -486,12 +475,10 @@ void HelpLinker::link()
if( !bExtensionMode ) if( !bExtensionMode )
{ {
// New index // New index
Stringtable::iterator aEnd = additionalFiles.end(); for (auto const& additionalFile : additionalFiles)
for (Stringtable::iterator enumer = additionalFiles.begin(); enumer != aEnd;
++enumer)
{ {
const std::string &additionalFileName = enumer->second; const std::string &additionalFileName = additionalFile.second;
const std::string &additionalFileKey = enumer->first; const std::string &additionalFileKey = additionalFile.first;
fs::path fsAdditionalFileName( additionalFileName, fs::native ); fs::path fsAdditionalFileName( additionalFileName, fs::native );
HCDBG({ HCDBG({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment