void ShowUsage()
{
std::cout << "Usage: -ulf ulf_file -rc rc_output_file -rct rc_template_file -rch rch_file -rcf rcf_file" << std::endl;
std::cout << "-ulf Name of the ulf file" << std::endl;
std::cout << "-rc Name of the resulting resource file" << std::endl;
std::cout << "-rct Name of the resource template file" << std::endl;
std::cout << "-rch Name of the resource file header" << std::endl;
std::cout << "-rcf Name of the resource file footer" << std::endl;
}
/** Get the directory where the module islocatedassystemdirectory,the
returned directory has a trailing '\' */
OUString get_module_path()
{
OUString cwd_url;
OUString module_path; if (osl_Process_E_None == osl_getProcessWorkingDir(&cwd_url.pData))
osl::FileBase::getSystemPathFromFileURL(cwd_url, module_path);
return module_path;
}
/** Make the absolute directory of a base and arelativedirectory,iftherelative directoryisabsolutetherelative directorywillbereturnedunchanged. Baseandrelativedirectoryshouldbe systempathsthereturneddirectoryis
a system path too */
OUString get_absolute_path( const OUString& BaseDir, const OUString& RelDir)
{
OUString base_url;
OUString rel_url;
/** A replacement table contains pairs of
placeholders and the appropriate substitute */ class Substitutor
{ private: typedef std::map<std::string, std::string> replacement_table_t; typedef std::map<std::string, replacement_table_t> iso_lang_replacement_table_t;
// If Text is a placeholder substitute it with //its substitute else leave it unchanged void substitute(std::string& Text)
{
replacement_table_t& prt = get_replacement_table(active_iso_lang_.make_std_string());
replacement_table_t::iterator iter = prt.find(Text); if (iter != prt.end())
Text = iter->second;
}
private: // Return the replacement table for the iso lang id // create a new one if not already present
replacement_table_t& get_replacement_table(const std::string& iso_lang)
{ return iso_lang_replacement_table_[iso_lang];
}
Substitutor.add_substitution(
std::string(GroupName), make_winrc_unicode_string(key_value_utf16));
map[ ltype ] = std::string( iso_lang );
} else
{ if( !map[ ltype ].empty() )
{
printf("ERROR: Duplicated ms id %d found for the languages %s and %s !!!! This does not work in microsoft resources\nPlease remove one!\n", static_cast<sal_uInt16>(ltype) , map[ ltype ].c_str() , iso_lang.getStr()); exit( -1 );
}
}
}
}
// as the Config class is currently not able to deal correctly with // UTF8 files starting with a byte-order-mark we create a copy of the // original file without the byte-order-mark
OUString tmpfile_url;
osl_createTempFile(nullptr, nullptr, &tmpfile_url.pData);
try
{
std::string line; while (std::getline(file, line))
string_container.push_back(line);
} catch(const std::ios::failure&)
{ if (!file.eof()) throw;
}
}
/** A simple helper function that happens the
content of one file to another one */ void concatenate_files(std::ostream& os, std::istream& is)
{
StreamExceptionsEnabler os_sexc(os);
StreamExceptionsEnabler is_sexc(is);
try
{
std::string line; while (std::getline(is, line))
os << line << std::endl;
} catch(const std::ios::failure&)
{ if (!is.eof()) throw;
}
}
char buff[10]; int primLangID = PRIMARYLANGID(ltype); int subLangID = SUBLANGID(ltype); // Our resources are normally not sub language dependent. // Esp. for spanish we don't want to distinguish between trad. // and international sorting (which leads to two different sub languages) // Setting the sub language to neutral allows us to use one // stringlist for all spanish variants if ( ( primLangID == LANG_SPANISH ) &&
( subLangID == SUBLANG_SPANISH ) )
subLangID = SUBLANG_NEUTRAL;
/** Iterate all languages in the substitutor, replacetheallplaceholderandappendthe
result to the output file */ void inflate_rc_template_to_file(
std::ostream& os, const std::vector<std::string>& rctmpl, Substitutor& substitutor)
{
StreamExceptionsEnabler sexc(os);
Substitutor::const_iterator iter = substitutor.begin();
Substitutor::const_iterator iter_end = substitutor.end();
std::ostream_iterator<std::string> oi(os, "\n");
for ( /**/ ;iter != iter_end; ++iter)
{
substitutor.set_language(iso_lang_identifier(iter->first));
if (!rctmpl.empty())
start_language_section(oi, iso_lang_identifier(iter->first));
while (iss)
{
std::string token;
iss >> token;
substitutor.substitute(token);
// HACK for partially merged // *.lng files where some strings have // a particular language that others // don't have in order to keep the // build // coverity[tainted_data] - trusted data source if (is_placeholder(token))
token = make_winrc_unicode_string(token);
line += token;
line += " ";
}
oi = line;
}
}
}
} // namespace /* private */
/* MAIN Thefilenamesprovidedviacommandlineshouldbe absoluteorrelativetothedirectoryofthismodule.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.