diff options
Diffstat (limited to 'l10ntools/source/xrmmerge.cxx')
-rw-r--r-- | l10ntools/source/xrmmerge.cxx | 131 |
1 files changed, 29 insertions, 102 deletions
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx index a22996d8db43..5b562ea7f627 100644 --- a/l10ntools/source/xrmmerge.cxx +++ b/l10ntools/source/xrmmerge.cxx @@ -27,6 +27,7 @@ #include "export.hxx" #include "xrmmerge.hxx" #include "tokens.h" +#include "helper.hxx" #include <iostream> #include <fstream> #include <vector> @@ -36,20 +37,8 @@ using namespace std; void yyerror( const char * ); void YYWarning( const char * ); -// defines to parse command line -#define STATE_NON 0x0001 -#define STATE_INPUT 0x0002 -#define STATE_OUTPUT 0x0003 -#define STATE_PRJ 0x0004 -#define STATE_ROOT 0x0005 -#define STATE_MERGESRC 0x0006 -#define STATE_ERRORLOG 0x0007 -#define STATE_LANGUAGES 0x000C - // set of global variables -sal_Bool bEnableExport; -sal_Bool bMergeMode; -sal_Bool bUTF8; +bool bMergeMode; sal_Bool bDisplayName; sal_Bool bExtensionDescription; rtl::OString sPrj; @@ -69,87 +58,30 @@ extern "C" { extern char *GetOutputFile( int argc, char* argv[]) /*****************************************************************************/ { - bEnableExport = sal_False; - bMergeMode = sal_False; - bUTF8 = sal_True; bDisplayName = sal_False; bExtensionDescription = sal_False; - sPrj = ""; - sPrjRoot = ""; - sInputFileName = ""; sActFileName = ""; - Export::sLanguages = ""; - sal_uInt16 nState = STATE_NON; - sal_Bool bInput = sal_False; - - // parse command line - for( int i = 1; i < argc; i++ ) { - if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-I" ) { - nState = STATE_INPUT; // next token specifies source file - } - else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-O" ) { - nState = STATE_OUTPUT; // next token specifies the dest file - } - else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-P" ) { - nState = STATE_PRJ; // next token specifies the cur. project - } - else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-R" ) { - nState = STATE_ROOT; // next token specifies path to project root - } - else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-M" ) { - nState = STATE_MERGESRC; // next token specifies the merge database - } - else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-E" ) { - nState = STATE_ERRORLOG; - } - else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-L" ) { - nState = STATE_LANGUAGES; - } - else { - switch ( nState ) { - case STATE_NON: { - return NULL; // no valid command line - } - case STATE_INPUT: { - sInputFileName = argv[ i ]; - bInput = sal_True; // source file found - } - break; - case STATE_OUTPUT: { - sOutputFile = argv[ i ]; // the dest. file - } - break; - case STATE_PRJ: { - sPrj = rtl::OString( argv[ i ]); - } - break; - case STATE_ROOT: { - sPrjRoot = rtl::OString( argv[ i ]); // path to project root - } - break; - case STATE_MERGESRC: { - sMergeSrc = rtl::OString( argv[ i ]); - bMergeMode = sal_True; // activate merge mode, cause merge database found - } - break; - case STATE_LANGUAGES: { - Export::sLanguages = rtl::OString( argv[ i ]); - } - break; - } - } - } - if ( bInput ) { + HandledArgs aArgs; + if ( Export::handleArguments(argc, argv, aArgs) ) + { // command line is valid - bEnableExport = sal_True; + bMergeMode = aArgs.m_bMergeMode; + sPrj = aArgs.m_sPrj; + sPrjRoot = aArgs.m_sPrjRoot; + sInputFileName = aArgs.m_sInputFile; + sOutputFile = aArgs.m_sOutputFile; + sMergeSrc = aArgs.m_sMergeSrc; char *pReturn = new char[ sOutputFile.getLength() + 1 ]; std::strcpy( pReturn, sOutputFile.getStr()); // #100211# - checked return pReturn; } - - // command line is not valid - return NULL; + else + { + // command line is not valid + Export::writeUsage("xrmex","xrm/xml"); + return NULL; + } } /*****************************************************************************/ @@ -261,9 +193,9 @@ int XRMResParser::Execute( int nToken, char * pToken ) switch ( nToken ) { case XRM_TEXT_START:{ - rtl::OString sNewLID = GetAttribute( rToken, "id" ); - if ( sNewLID != sLID ) { - sLID = sNewLID; + rtl::OString sNewGID = GetAttribute( rToken, "id" ); + if ( sNewGID != sGID ) { + sGID = sNewGID; } bText = sal_True; sCurrentText = ""; @@ -297,7 +229,7 @@ int XRMResParser::Execute( int nToken, char * pToken ) case DESC_TEXT_START:{ if (bDisplayName) { - sLID = rtl::OString("dispname"); + sGID = rtl::OString("dispname"); bText = sal_True; sCurrentText = ""; sCurrentOpenTag = rToken; @@ -333,7 +265,7 @@ int XRMResParser::Execute( int nToken, char * pToken ) case DESC_EXTENSION_DESCRIPTION_SRC: { if (bExtensionDescription) { - sLID = rtl::OString("extdesc"); + sGID = rtl::OString("extdesc"); sResourceType = rtl::OString ( "description" ); sLangAttribute = rtl::OString ( "lang" ); sCurrentOpenTag = rToken; @@ -498,7 +430,6 @@ void XRMResExport::WorkOnText( { rtl::OString sPlatform( "" ); pResData = new ResData( sPlatform, GetGID() ); - pResData->sId = GetLID(); } rtl::OString sText(rText); @@ -528,12 +459,8 @@ void XRMResExport::EndOfText( sOutput += "\t0\t"; sOutput += sResourceType; sOutput += "\t"; - sOutput += pResData->sId; - // USE LID AS GID OR MERGE DON'T WORK - //sOutput += pResData->sGId; - sOutput += "\t"; - sOutput += pResData->sId; - sOutput += "\t\t\t0\t"; + sOutput += pResData->sGId; + sOutput += "\t\t\t\t0\t"; sOutput += sCur; sOutput += "\t"; @@ -670,8 +597,7 @@ void XRMResMerge::WorkOnText( if ( pMergeDataFile ) { if ( !pResData ) { rtl::OString sPlatform( "" ); - pResData = new ResData( sPlatform, GetLID() , sFilename ); - pResData->sId = GetLID(); + pResData = new ResData( sPlatform, GetGID() , sFilename ); pResData->sResTyp = sResourceType; } @@ -681,8 +607,8 @@ void XRMResMerge::WorkOnText( if ( Export::isAllowed( sLang ) && ( pEntrys->GetText( sContent, STRING_TYP_TEXT, sLang )) && - ( sContent != "-" ) && !sContent.isEmpty()) - + ( sContent != "-" ) && !sContent.isEmpty() && + helper::isWellFormedXML( sContent )) { rText = sContent; ConvertStringToXMLFormat( rText ); @@ -718,7 +644,8 @@ void XRMResMerge::EndOfText( if (!sCur.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("en-US")) && ( pEntrys->GetText( sContent, STRING_TYP_TEXT, sCur, sal_True )) && - ( sContent != "-" ) && !sContent.isEmpty()) + ( sContent != "-" ) && !sContent.isEmpty() && + helper::isWellFormedXML( sContent )) { rtl::OString sText( sContent ); rtl::OString sAdditionalLine( "\n " ); |