Extended loplugin:ostr: l10ntools
Change-Id: I6c46535568ac6c29784e9336198b51c79c9e3859 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159695 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -52,7 +52,7 @@ FILE * init(int argc, char ** argv) {
|
||||
common::HandledArgs aArgs;
|
||||
if ( !common::handleArguments(argc, argv, aArgs) )
|
||||
{
|
||||
common::writeUsage("cfgex","*.xcu");
|
||||
common::writeUsage("cfgex"_ostr,"*.xcu"_ostr);
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
global::inputPathname = aArgs.m_sInputFile;
|
||||
@@ -365,10 +365,10 @@ void CfgExport::WorkOnResourceEnd()
|
||||
if ( !bLocalize )
|
||||
return;
|
||||
|
||||
if ( pStackData->sText["en-US"].isEmpty() )
|
||||
if ( pStackData->sText["en-US"_ostr].isEmpty() )
|
||||
return;
|
||||
|
||||
OString sXComment = pStackData->sText[OString("x-comment")];
|
||||
OString sXComment = pStackData->sText["x-comment"_ostr];
|
||||
OString sLocalId = pStackData->sIdentifier;
|
||||
OString sGroupId;
|
||||
if ( aStack.size() == 1 ) {
|
||||
@@ -380,11 +380,11 @@ void CfgExport::WorkOnResourceEnd()
|
||||
}
|
||||
|
||||
|
||||
OString sText = pStackData->sText[ "en-US" ];
|
||||
OString sText = pStackData->sText[ "en-US"_ostr ];
|
||||
sText = helper::UnQuotHTML( sText );
|
||||
|
||||
common::writePoEntry(
|
||||
"Cfgex", pOutputStream, sPath, pStackData->sResTyp,
|
||||
"Cfgex"_ostr, pOutputStream, sPath, pStackData->sResTyp,
|
||||
sGroupId, sLocalId, sXComment, sText);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,17 +108,17 @@ bool HelpParser::CreatePO(
|
||||
auto posm = aXMLStrHM->find(pos);
|
||||
LangHashMap* pElem = posm->second;
|
||||
|
||||
XMLElement* pXMLElement = (*pElem)[ "en-US" ];
|
||||
XMLElement* pXMLElement = (*pElem)[ "en-US"_ostr ];
|
||||
|
||||
if( pXMLElement != nullptr )
|
||||
{
|
||||
OString data(
|
||||
pXMLElement->ToOString().
|
||||
replaceAll("\n",OString()).
|
||||
replaceAll("\t",OString()).trim());
|
||||
replaceAll("\n"_ostr,OString()).
|
||||
replaceAll("\t"_ostr,OString()).trim());
|
||||
|
||||
common::writePoEntry(
|
||||
"Helpex", aPoOutput, sHelpFile, rGsi1,
|
||||
"Helpex"_ostr, aPoOutput, sHelpFile, rGsi1,
|
||||
posm->first, OString(), OString(), data);
|
||||
|
||||
pXMLElement=nullptr;
|
||||
@@ -158,7 +158,7 @@ void HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile* pMergeDataFile
|
||||
file->Extract();
|
||||
|
||||
XMLHashMap* aXMLStrHM = file->GetStrings();
|
||||
static ResData s_ResData("","");
|
||||
static ResData s_ResData(""_ostr,""_ostr);
|
||||
s_ResData.sResTyp = "help";
|
||||
|
||||
std::vector<OString> order = file->getOrder();
|
||||
@@ -190,7 +190,7 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const OString& sCur , ResDa
|
||||
if( sCur.equalsIgnoreAsciiCase("en-US") )
|
||||
return;
|
||||
|
||||
pXMLElement = (*aLangHM)[ "en-US" ];
|
||||
pXMLElement = (*aLangHM)[ "en-US"_ostr ];
|
||||
if( pXMLElement == nullptr )
|
||||
{
|
||||
printf("Error: Can't find en-US entry\n");
|
||||
@@ -202,10 +202,10 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const OString& sCur , ResDa
|
||||
OString sSourceText(
|
||||
pXMLElement->ToOString().
|
||||
replaceAll(
|
||||
"\n",
|
||||
"\n"_ostr,
|
||||
OString()).
|
||||
replaceAll(
|
||||
"\t",
|
||||
"\t"_ostr,
|
||||
OString()));
|
||||
// re-add spaces to the beginning of translated string,
|
||||
// important for indentation of Basic code examples
|
||||
|
||||
@@ -30,7 +30,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
|
||||
common::HandledArgs aArgs;
|
||||
if (!common::handleArguments(argc, argv, aArgs))
|
||||
{
|
||||
common::writeUsage("ulfex", "*.ulf");
|
||||
common::writeUsage("ulfex"_ostr, "*.ulf"_ostr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ void LngParser::CreatePO( const OString &rPOFile )
|
||||
else {
|
||||
WritePO( aPOStream , Text , sSource , sID );
|
||||
}
|
||||
Text.erase("x-comment");
|
||||
Text.erase("x-comment"_ostr);
|
||||
}
|
||||
aPOStream.close();
|
||||
}
|
||||
@@ -126,8 +126,8 @@ void LngParser::WritePO(PoOfstream &aPOStream,
|
||||
const OString &rID)
|
||||
{
|
||||
common::writePoEntry(
|
||||
"Ulfex", aPOStream, rActFileName, "LngText",
|
||||
rID, OString(), rText_inout.count("x-comment") ? rText_inout["x-comment"] : OString(), rText_inout["en-US"]);
|
||||
"Ulfex"_ostr, aPOStream, rActFileName, "LngText",
|
||||
rID, OString(), rText_inout.count("x-comment"_ostr) ? rText_inout["x-comment"_ostr] : OString(), rText_inout["en-US"_ostr]);
|
||||
}
|
||||
|
||||
bool LngParser::isNextGroup(OString &sGroup_out, std::string_view sLine_in)
|
||||
@@ -220,7 +220,7 @@ void LngParser::Merge(
|
||||
mvLines[ nPos ] = sLang
|
||||
+ " = \""
|
||||
// escape quotes, unescape double escaped quotes fdo#56648
|
||||
+ sNewText.replaceAll("\"","\\\"").replaceAll("\\\\\"","\\\"")
|
||||
+ sNewText.replaceAll("\""_ostr,"\\\""_ostr).replaceAll("\\\\\""_ostr,"\\\""_ostr)
|
||||
+ "\"";
|
||||
Text[ sLang ] = sNewText;
|
||||
}
|
||||
@@ -255,7 +255,7 @@ void LngParser::Merge(
|
||||
const OString sLine { sCur
|
||||
+ " = \""
|
||||
// escape quotes, unescape double escaped quotes fdo#56648
|
||||
+ sNewText.replaceAll("\"","\\\"").replaceAll("\\\\\"","\\\"")
|
||||
+ sNewText.replaceAll("\""_ostr,"\\\""_ostr).replaceAll("\\\\\""_ostr,"\\\""_ostr)
|
||||
+ "\"" };
|
||||
|
||||
nLastLangPos++;
|
||||
|
||||
@@ -70,7 +70,7 @@ ResData::ResData( OString _sGId )
|
||||
:
|
||||
sGId(std::move( _sGId ))
|
||||
{
|
||||
sGId = sGId.replaceAll("\r", OString());
|
||||
sGId = sGId.replaceAll("\r"_ostr, OString());
|
||||
}
|
||||
|
||||
ResData::ResData( OString _sGId, OString _sFilename)
|
||||
@@ -78,7 +78,7 @@ ResData::ResData( OString _sGId, OString _sFilename)
|
||||
sGId(std::move( _sGId )),
|
||||
sFilename(std::move( _sFilename ))
|
||||
{
|
||||
sGId = sGId.replaceAll("\r", OString());
|
||||
sGId = sGId.replaceAll("\r"_ostr, OString());
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace
|
||||
{
|
||||
//DOUBLE VERTICAL LINE instead of || because the translations make their
|
||||
//way into action_names under gtk3 where || is illegal
|
||||
return u8"\u2016";
|
||||
return u8"\u2016"_ostr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,10 +219,10 @@ MergeDataFile::MergeDataFile(
|
||||
if( bFirstLang && bWithQtz &&
|
||||
sEnableReleaseBuild != "TRUE" )
|
||||
{
|
||||
aLanguageSet.insert("qtz");
|
||||
aLanguageSet.insert("qtz"_ostr);
|
||||
InsertEntry(
|
||||
aActPo.getResourceType(), aActPo.getGroupId(),
|
||||
aActPo.getLocalId(), "qtz",
|
||||
aActPo.getLocalId(), "qtz"_ostr,
|
||||
sExText, sExQHText,
|
||||
sExTitle, aActPo.getSourceFile(),
|
||||
false, bCaseSensitive );
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace
|
||||
OString lcl_GenMsgString(std::string_view rString)
|
||||
{
|
||||
if ( rString.empty() )
|
||||
return "\"\"";
|
||||
return "\"\""_ostr;
|
||||
|
||||
OString sResult =
|
||||
"\"" +
|
||||
@@ -131,7 +131,7 @@ void GenPoEntry::writeToFile(std::ofstream& rOFStream) const
|
||||
if ( !m_sExtractCom.isEmpty() )
|
||||
rOFStream
|
||||
<< "#. "
|
||||
<< m_sExtractCom.toString().replaceAll("\n","\n#. ") << std::endl;
|
||||
<< m_sExtractCom.toString().replaceAll("\n"_ostr,"\n#. "_ostr) << std::endl;
|
||||
for(const auto& rReference : m_sReferences)
|
||||
rOFStream << "#: " << rReference << std::endl;
|
||||
if ( m_bFuzzy )
|
||||
|
||||
@@ -17,7 +17,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
|
||||
common::HandledArgs aArgs;
|
||||
if( !common::handleArguments(argc, argv, aArgs) )
|
||||
{
|
||||
common::writeUsage("propex","*.properties");
|
||||
common::writeUsage("propex"_ostr,"*.properties"_ostr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ void PropParser::Extract( const OString& rPOFile )
|
||||
OString sText = lcl_ConvertToUTF8( OString(o3tl::trim(sLine.subView( nEqualSign + 1 ))) );
|
||||
|
||||
common::writePoEntry(
|
||||
"Propex", aPOStream, m_sSource, "property",
|
||||
"Propex"_ostr, aPOStream, m_sSource, "property",
|
||||
OString(sID), OString(), OString(), sText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace
|
||||
xmlGetProp(pCurrent, reinterpret_cast<const xmlChar*>("title"));
|
||||
|
||||
common::writePoEntry(
|
||||
"Treex", rPOStream, pSource->name, helper::xmlStrToOString( pNodeName ),
|
||||
"Treex"_ostr, rPOStream, pSource->name, helper::xmlStrToOString( pNodeName ),
|
||||
helper::xmlStrToOString( pID ), OString(), OString(), helper::xmlStrToOString( pText ));
|
||||
|
||||
xmlFree( pID );
|
||||
@@ -114,8 +114,8 @@ namespace
|
||||
xmlNodeListGetString(pXhpFile, pXhpNode->children, 1);
|
||||
OString sNewTitle =
|
||||
helper::xmlStrToOString( sTitle ).
|
||||
replaceAll("$[officename]","%PRODUCTNAME").
|
||||
replaceAll("$[officeversion]","%PRODUCTVERSION");
|
||||
replaceAll("$[officename]"_ostr,"%PRODUCTNAME"_ostr).
|
||||
replaceAll("$[officeversion]"_ostr,"%PRODUCTVERSION"_ostr);
|
||||
xmlChar *xmlString = xmlEncodeSpecialChars(nullptr,
|
||||
reinterpret_cast<const xmlChar*>( sNewTitle.getStr() ));
|
||||
xmlNodeSetContent( pReturn, xmlString);
|
||||
|
||||
@@ -306,22 +306,22 @@ XMLFile::XMLFile( OString _sFileName ) // the file name, empty if created from m
|
||||
: XMLParentNode( nullptr )
|
||||
, m_sFileName(std::move( _sFileName ))
|
||||
{
|
||||
m_aNodes_localize.emplace( OString("bookmark") , true );
|
||||
m_aNodes_localize.emplace( OString("variable") , true );
|
||||
m_aNodes_localize.emplace( OString("paragraph") , true );
|
||||
m_aNodes_localize.emplace( OString("h1") , true );
|
||||
m_aNodes_localize.emplace( OString("h2") , true );
|
||||
m_aNodes_localize.emplace( OString("h3") , true );
|
||||
m_aNodes_localize.emplace( OString("h4") , true );
|
||||
m_aNodes_localize.emplace( OString("h5") , true );
|
||||
m_aNodes_localize.emplace( OString("h6") , true );
|
||||
m_aNodes_localize.emplace( OString("note") , true );
|
||||
m_aNodes_localize.emplace( OString("tip") , true );
|
||||
m_aNodes_localize.emplace( OString("warning") , true );
|
||||
m_aNodes_localize.emplace( OString("alt") , true );
|
||||
m_aNodes_localize.emplace( OString("caption") , true );
|
||||
m_aNodes_localize.emplace( OString("title") , true );
|
||||
m_aNodes_localize.emplace( OString("link") , true );
|
||||
m_aNodes_localize.emplace( "bookmark"_ostr , true );
|
||||
m_aNodes_localize.emplace( "variable"_ostr , true );
|
||||
m_aNodes_localize.emplace( "paragraph"_ostr , true );
|
||||
m_aNodes_localize.emplace( "h1"_ostr , true );
|
||||
m_aNodes_localize.emplace( "h2"_ostr , true );
|
||||
m_aNodes_localize.emplace( "h3"_ostr , true );
|
||||
m_aNodes_localize.emplace( "h4"_ostr , true );
|
||||
m_aNodes_localize.emplace( "h5"_ostr , true );
|
||||
m_aNodes_localize.emplace( "h6"_ostr , true );
|
||||
m_aNodes_localize.emplace( "note"_ostr , true );
|
||||
m_aNodes_localize.emplace( "tip"_ostr , true );
|
||||
m_aNodes_localize.emplace( "warning"_ostr , true );
|
||||
m_aNodes_localize.emplace( "alt"_ostr , true );
|
||||
m_aNodes_localize.emplace( "caption"_ostr , true );
|
||||
m_aNodes_localize.emplace( "title"_ostr , true );
|
||||
m_aNodes_localize.emplace( "link"_ostr , true );
|
||||
}
|
||||
|
||||
void XMLFile::Extract()
|
||||
@@ -332,7 +332,7 @@ void XMLFile::Extract()
|
||||
|
||||
void XMLFile::InsertL10NElement( XMLElement* pElement )
|
||||
{
|
||||
OString sId, sLanguage("en-US");
|
||||
OString sId, sLanguage("en-US"_ostr);
|
||||
LangHashMap* pElem;
|
||||
|
||||
if( pElement->GetAttributeList() != nullptr )
|
||||
|
||||
@@ -66,7 +66,7 @@ extern bool GetOutputFile( int argc, char* argv[])
|
||||
else
|
||||
{
|
||||
// command line is not valid
|
||||
common::writeUsage("xrmex","*.xrm/*.xml");
|
||||
common::writeUsage("xrmex"_ostr,"*.xrm/*.xml"_ostr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -167,8 +167,8 @@ void XRMResParser::Execute( int nToken, char * pToken )
|
||||
|
||||
case XRM_TEXT_END: {
|
||||
sCurrentCloseTag = rToken;
|
||||
sResourceType = OString ( "readmeitem" );
|
||||
sLangAttribute = OString ( "xml:lang" );
|
||||
sResourceType = "readmeitem"_ostr;
|
||||
sLangAttribute = "xml:lang"_ostr;
|
||||
WorkOnText( sCurrentOpenTag, sCurrentText );
|
||||
Output( sCurrentText );
|
||||
EndOfText( sCurrentOpenTag, sCurrentCloseTag );
|
||||
@@ -190,7 +190,7 @@ void XRMResParser::Execute( int nToken, char * pToken )
|
||||
|
||||
case DESC_TEXT_START:{
|
||||
if (bDisplayName) {
|
||||
sGID = OString("dispname");
|
||||
sGID = "dispname"_ostr;
|
||||
bText = true;
|
||||
sCurrentText = OString();
|
||||
sCurrentOpenTag = rToken;
|
||||
@@ -202,8 +202,8 @@ void XRMResParser::Execute( int nToken, char * pToken )
|
||||
case DESC_TEXT_END: {
|
||||
if (bDisplayName) {
|
||||
sCurrentCloseTag = rToken;
|
||||
sResourceType = OString ( "description" );
|
||||
sLangAttribute = OString ( "lang" );
|
||||
sResourceType = "description"_ostr;
|
||||
sLangAttribute = "lang"_ostr;
|
||||
WorkOnText( sCurrentOpenTag, sCurrentText );
|
||||
Output( sCurrentText );
|
||||
EndOfText( sCurrentOpenTag, sCurrentCloseTag );
|
||||
@@ -226,9 +226,9 @@ void XRMResParser::Execute( int nToken, char * pToken )
|
||||
|
||||
case DESC_EXTENSION_DESCRIPTION_SRC: {
|
||||
if (bExtensionDescription) {
|
||||
sGID = OString("extdesc");
|
||||
sResourceType = OString ( "description" );
|
||||
sLangAttribute = OString ( "lang" );
|
||||
sGID = "extdesc"_ostr;
|
||||
sResourceType = "description"_ostr;
|
||||
sLangAttribute = "lang"_ostr;
|
||||
sCurrentOpenTag = rToken;
|
||||
sCurrentText = OString();
|
||||
Output( rToken );
|
||||
@@ -297,7 +297,7 @@ void XRMResExport::WorkOnDesc(
|
||||
const OString &rOpenTag,
|
||||
OString &rText )
|
||||
{
|
||||
const OString sDescFileName{ sInputFileName.replaceAll("description.xml", OString())
|
||||
const OString sDescFileName{ sInputFileName.replaceAll("description.xml"_ostr, OString())
|
||||
+ GetAttribute( rOpenTag, "xlink:href" ) };
|
||||
std::ifstream file (sDescFileName.getStr(), std::ios::in|std::ios::binary|std::ios::ate);
|
||||
if (file.is_open()) {
|
||||
@@ -332,11 +332,11 @@ void XRMResExport::EndOfText(
|
||||
{
|
||||
if ( pResData )
|
||||
{
|
||||
OString sAct = pResData->sText["en-US"];
|
||||
OString sAct = pResData->sText["en-US"_ostr];
|
||||
|
||||
if( !sAct.isEmpty() )
|
||||
common::writePoEntry(
|
||||
"Xrmex", pOutputStream, sPath, sResourceType,
|
||||
"Xrmex"_ostr, pOutputStream, sPath, sResourceType,
|
||||
pResData->sGId, OString(), OString(), sAct );
|
||||
}
|
||||
pResData.reset();
|
||||
@@ -396,10 +396,10 @@ void XRMResMerge::WorkOnDesc(
|
||||
sAdditionalLine = sAdditionalLine.replaceFirst(
|
||||
sSearch, sReplace);
|
||||
|
||||
sSearch = OString("xlink:href=\"");
|
||||
sSearch = "xlink:href=\""_ostr;
|
||||
sReplace = sSearch;
|
||||
|
||||
const OString sLocDescFilename = sDescFilename.replaceFirst( "en-US", sCur);
|
||||
const OString sLocDescFilename = sDescFilename.replaceFirst( "en-US"_ostr, sCur);
|
||||
|
||||
sSearch += sDescFilename;
|
||||
sReplace += sLocDescFilename;
|
||||
|
||||
Reference in New Issue
Block a user