summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-07 10:58:29 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-07 13:11:10 +0200
commit6a2d03e7c796ad90c4d9d134ad1a91d527953c66 (patch)
treeff2d9c2ff86cf7af3047c70b18bf00c780272f0a /l10ntools
parent35f9dec3645f7a4a8d1f7f9dfb62e28d73bc5244 (diff)
loplugin:flatten in l10ntools
Change-Id: Ib1f698eddea1da2a6e06e17d1c4fec9ef717e132 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91804 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/source/cfgmerge.cxx77
-rw-r--r--l10ntools/source/helpmerge.cxx110
-rw-r--r--l10ntools/source/lngmerge.cxx34
-rw-r--r--l10ntools/source/xmlparse.cxx56
4 files changed, 139 insertions, 138 deletions
diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx
index ae75f973724f..e02e497d5d21 100644
--- a/l10ntools/source/cfgmerge.cxx
+++ b/l10ntools/source/cfgmerge.cxx
@@ -347,29 +347,30 @@ CfgExport::~CfgExport()
void CfgExport::WorkOnResourceEnd()
{
- if ( bLocalize ) {
- if ( !pStackData->sText["en-US"].isEmpty() )
- {
- OString sXComment = pStackData->sText[OString("x-comment")];
- OString sLocalId = pStackData->sIdentifier;
- OString sGroupId;
- if ( aStack.size() == 1 ) {
- sGroupId = sLocalId;
- sLocalId = "";
- }
- else {
- sGroupId = aStack.GetAccessPath( aStack.size() - 2 );
- }
+ if ( !bLocalize )
+ return;
+
+ if ( pStackData->sText["en-US"].isEmpty() )
+ return;
+
+ OString sXComment = pStackData->sText[OString("x-comment")];
+ OString sLocalId = pStackData->sIdentifier;
+ OString sGroupId;
+ if ( aStack.size() == 1 ) {
+ sGroupId = sLocalId;
+ sLocalId = "";
+ }
+ else {
+ sGroupId = aStack.GetAccessPath( aStack.size() - 2 );
+ }
- OString sText = pStackData->sText[ "en-US" ];
- sText = helper::UnQuotHTML( sText );
+ OString sText = pStackData->sText[ "en-US" ];
+ sText = helper::UnQuotHTML( sText );
- common::writePoEntry(
- "Cfgex", pOutputStream, sPath, pStackData->sResTyp,
- sGroupId, sLocalId, sXComment, sText);
- }
- }
+ common::writePoEntry(
+ "Cfgex", pOutputStream, sPath, pStackData->sResTyp,
+ sGroupId, sLocalId, sXComment, sText);
}
void CfgExport::WorkOnText(
@@ -418,27 +419,27 @@ CfgMerge::~CfgMerge()
void CfgMerge::WorkOnText(OString &, const OString& rLangIndex)
{
-
- if ( pMergeDataFile && bLocalize ) {
- if ( !pResData ) {
- OString sLocalId = pStackData->sIdentifier;
- OString sGroupId;
- if ( aStack.size() == 1 ) {
- sGroupId = sLocalId;
- sLocalId.clear();
- }
- else {
- sGroupId = aStack.GetAccessPath( aStack.size() - 2 );
- }
-
- pResData.reset( new ResData( sGroupId, sFilename ) );
- pResData->sId = sLocalId;
- pResData->sResTyp = pStackData->sResTyp;
+ if ( !(pMergeDataFile && bLocalize) )
+ return;
+
+ if ( !pResData ) {
+ OString sLocalId = pStackData->sIdentifier;
+ OString sGroupId;
+ if ( aStack.size() == 1 ) {
+ sGroupId = sLocalId;
+ sLocalId.clear();
+ }
+ else {
+ sGroupId = aStack.GetAccessPath( aStack.size() - 2 );
}
- if (rLangIndex.equalsIgnoreAsciiCase("en-US"))
- bEnglish = true;
+ pResData.reset( new ResData( sGroupId, sFilename ) );
+ pResData->sId = sLocalId;
+ pResData->sResTyp = pStackData->sResTyp;
}
+
+ if (rLangIndex.equalsIgnoreAsciiCase("en-US"))
+ bEnglish = true;
}
void CfgMerge::Output(const OString& rOutput)
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index ee442e91475b..abab8a5a03a1 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -194,67 +194,67 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const OString& sCur , ResDa
XMLElement* pXMLElement = nullptr;
MergeEntrys *pEntrys = nullptr;
- if( !sCur.equalsIgnoreAsciiCase("en-US") ){
- pXMLElement = (*aLangHM)[ "en-US" ];
- if( pXMLElement == nullptr )
+ if( sCur.equalsIgnoreAsciiCase("en-US") )
+ return;
+
+ pXMLElement = (*aLangHM)[ "en-US" ];
+ if( pXMLElement == nullptr )
+ {
+ printf("Error: Can't find en-US entry\n");
+ }
+ if( pXMLElement == nullptr )
+ return;
+
+ OString sNewText;
+ OString sNewdata;
+ OString sSourceText(
+ pXMLElement->ToOString().
+ replaceAll(
+ "\n",
+ OString()).
+ replaceAll(
+ "\t",
+ OString()));
+ // re-add spaces to the beginning of translated string,
+ // important for indentation of Basic code examples
+ sal_Int32 nPreSpaces = 0;
+ sal_Int32 nLen = sSourceText.getLength();
+ while ( (nPreSpaces < nLen) && (sSourceText[nPreSpaces] == ' ') )
+ nPreSpaces++;
+ if( sCur == "qtz" )
+ {
+ sNewText = MergeEntrys::GetQTZText(*pResData, sSourceText);
+ sNewdata = sNewText;
+ }
+ else if( pMergeDataFile )
+ {
+ pEntrys = pMergeDataFile->GetMergeEntrys( pResData );
+ if( pEntrys != nullptr)
{
- printf("Error: Can't find en-US entry\n");
+ pEntrys->GetText( sNewText, sCur, true );
+ if (helper::isWellFormedXML(XMLUtil::QuotHTML(sNewText)))
+ {
+ sNewdata = sSourceText.copy(0,nPreSpaces) + sNewText;
+ }
}
+ }
+ if (!sNewdata.isEmpty())
+ {
if( pXMLElement != nullptr )
{
- OString sNewText;
- OString sNewdata;
- OString sSourceText(
- pXMLElement->ToOString().
- replaceAll(
- "\n",
- OString()).
- replaceAll(
- "\t",
- OString()));
- // re-add spaces to the beginning of translated string,
- // important for indentation of Basic code examples
- sal_Int32 nPreSpaces = 0;
- sal_Int32 nLen = sSourceText.getLength();
- while ( (nPreSpaces < nLen) && (sSourceText[nPreSpaces] == ' ') )
- nPreSpaces++;
- if( sCur == "qtz" )
- {
- sNewText = MergeEntrys::GetQTZText(*pResData, sSourceText);
- sNewdata = sNewText;
- }
- else if( pMergeDataFile )
- {
- pEntrys = pMergeDataFile->GetMergeEntrys( pResData );
- if( pEntrys != nullptr)
- {
- pEntrys->GetText( sNewText, sCur, true );
- if (helper::isWellFormedXML(XMLUtil::QuotHTML(sNewText)))
- {
- sNewdata = sSourceText.copy(0,nPreSpaces) + sNewText;
- }
- }
- }
- if (!sNewdata.isEmpty())
- {
- if( pXMLElement != nullptr )
- {
- XMLData *data = new XMLData( sNewdata , nullptr ); // Add new one
- pXMLElement->RemoveAndDeleteAllChildren();
- pXMLElement->AddChild( data );
- aLangHM->erase( sCur );
- }
- }
- else
- {
- SAL_WARN(
- "l10ntools",
- "Can't find GID=" << pResData->sGId << " TYP=" << pResData->sResTyp);
- }
- pXMLElement->ChangeLanguageTag(sCur);
+ XMLData *data = new XMLData( sNewdata , nullptr ); // Add new one
+ pXMLElement->RemoveAndDeleteAllChildren();
+ pXMLElement->AddChild( data );
+ aLangHM->erase( sCur );
}
-
}
+ else
+ {
+ SAL_WARN(
+ "l10ntools",
+ "Can't find GID=" << pResData->sGId << " TYP=" << pResData->sResTyp);
+ }
+ pXMLElement->ChangeLanguageTag(sCur);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index 777154f57f4d..f0cdaa3ffb25 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -57,27 +57,27 @@ LngParser::LngParser(const OString &rLngFile)
: sSource( rLngFile )
{
std::ifstream aStream(sSource.getStr());
- if (aStream.is_open())
- {
- bool bFirstLine = true;
- std::string s;
- std::getline(aStream, s);
- while (!aStream.eof())
- {
- OString sLine(s.data(), s.length());
+ if (!aStream.is_open())
+ return;
- if( bFirstLine )
- {
- // Always remove UTF8 BOM from the first line
- lcl_RemoveUTF8ByteOrderMarker( sLine );
- bFirstLine = false;
- }
+ bool bFirstLine = true;
+ std::string s;
+ std::getline(aStream, s);
+ while (!aStream.eof())
+ {
+ OString sLine(s.data(), s.length());
- mvLines.push_back( sLine );
- std::getline(aStream, s);
+ if( bFirstLine )
+ {
+ // Always remove UTF8 BOM from the first line
+ lcl_RemoveUTF8ByteOrderMarker( sLine );
+ bFirstLine = false;
}
- mvLines.push_back( OString() );
+
+ mvLines.push_back( sLine );
+ std::getline(aStream, s);
}
+ mvLines.push_back( OString() );
}
LngParser::~LngParser()
diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx
index 10852fa0f043..54b9c6bf4d8e 100644
--- a/l10ntools/source/xmlparse.cxx
+++ b/l10ntools/source/xmlparse.cxx
@@ -79,26 +79,26 @@ XMLParentNode::~XMLParentNode()
XMLParentNode::XMLParentNode( const XMLParentNode& rObj)
: XMLChildNode( rObj )
{
- if( rObj.m_pChildList )
+ if( !rObj.m_pChildList )
+ return;
+
+ m_pChildList.reset( new XMLChildNodeList );
+ for ( size_t i = 0; i < rObj.m_pChildList->size(); i++ )
{
- m_pChildList.reset( new XMLChildNodeList );
- for ( size_t i = 0; i < rObj.m_pChildList->size(); i++ )
+ XMLChildNode* pNode = (*rObj.m_pChildList)[ i ];
+ if( pNode != nullptr)
{
- XMLChildNode* pNode = (*rObj.m_pChildList)[ i ];
- if( pNode != nullptr)
+ switch(pNode->GetNodeType())
{
- switch(pNode->GetNodeType())
- {
- case XMLNodeType::ELEMENT:
- AddChild( new XMLElement( *static_cast<XMLElement* >(pNode) ) ); break;
- case XMLNodeType::DATA:
- AddChild( new XMLData ( *static_cast<XMLData* > (pNode) ) ); break;
- case XMLNodeType::COMMENT:
- AddChild( new XMLComment( *static_cast<XMLComment* >(pNode) ) ); break;
- case XMLNodeType::DEFAULT:
- AddChild( new XMLDefault( *static_cast<XMLDefault* >(pNode) ) ); break;
- default: fprintf(stdout,"XMLParentNode::XMLParentNode( const XMLParentNode& rObj) strange obj");
- }
+ case XMLNodeType::ELEMENT:
+ AddChild( new XMLElement( *static_cast<XMLElement* >(pNode) ) ); break;
+ case XMLNodeType::DATA:
+ AddChild( new XMLData ( *static_cast<XMLData* > (pNode) ) ); break;
+ case XMLNodeType::COMMENT:
+ AddChild( new XMLComment( *static_cast<XMLComment* >(pNode) ) ); break;
+ case XMLNodeType::DEFAULT:
+ AddChild( new XMLDefault( *static_cast<XMLDefault* >(pNode) ) ); break;
+ default: fprintf(stdout,"XMLParentNode::XMLParentNode( const XMLParentNode& rObj) strange obj");
}
}
}
@@ -613,21 +613,21 @@ void XMLElement::ChangeLanguageTag( const OString &rValue )
}
XMLChildNodeList* pCList = GetChildList();
- if( pCList )
+ if( !pCList )
+ return;
+
+ for ( size_t i = 0; i < pCList->size(); i++ )
{
- for ( size_t i = 0; i < pCList->size(); i++ )
+ XMLChildNode* pNode = (*pCList)[ i ];
+ if( pNode && pNode->GetNodeType() == XMLNodeType::ELEMENT )
{
- XMLChildNode* pNode = (*pCList)[ i ];
- if( pNode && pNode->GetNodeType() == XMLNodeType::ELEMENT )
- {
- XMLElement* pElem = static_cast< XMLElement* >(pNode);
- pElem->ChangeLanguageTag( rValue );
- pElem = nullptr;
- pNode = nullptr;
- }
+ XMLElement* pElem = static_cast< XMLElement* >(pNode);
+ pElem->ChangeLanguageTag( rValue );
+ pElem = nullptr;
+ pNode = nullptr;
}
- pCList = nullptr;
}
+ pCList = nullptr;
}
XMLElement::~XMLElement()