summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorAndras Timar <atimar@suse.com>2011-10-05 21:54:56 +0200
committerAndras Timar <atimar@suse.com>2011-10-05 22:04:05 +0200
commita8fa695f8d327f7ae770d1fc0bb2bb27a5f2be11 (patch)
treea408e137899fab5e937df8053c50607bf6c346b1 /l10ntools
parent3086838ebffe99cdcec41b927378cdb5e1b5c0e0 (diff)
merge strings to description.xml files
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/inc/xrmmerge.hxx12
-rw-r--r--l10ntools/source/xrmmerge.cxx133
2 files changed, 112 insertions, 33 deletions
diff --git a/l10ntools/inc/xrmmerge.hxx b/l10ntools/inc/xrmmerge.hxx
index f0b213a54ce3..496adc16615c 100644
--- a/l10ntools/inc/xrmmerge.hxx
+++ b/l10ntools/inc/xrmmerge.hxx
@@ -54,6 +54,10 @@ protected:
void Error( const ByteString &rError );
virtual void Output( const ByteString& rOutput )=0;
+ virtual void WorkOnDesc(
+ const ByteString &rOpenTag,
+ ByteString &rText
+ )=0;
virtual void WorkOnText(
const ByteString &rOpenTag,
ByteString &rText
@@ -107,6 +111,10 @@ private:
std::vector<ByteString> aLanguages;
protected:
+ void WorkOnDesc(
+ const ByteString &rOpenTag,
+ ByteString &rText
+ );
void WorkOnText(
const ByteString &rOpenTag,
ByteString &rText
@@ -139,6 +147,10 @@ private:
std::vector<ByteString> aLanguages;
protected:
+ void WorkOnDesc(
+ const ByteString &rOpenTag,
+ ByteString &rText
+ );
void WorkOnText(
const ByteString &rOpenTag,
ByteString &rText
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index 8a0ca9881c22..e30a3e10648c 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -318,7 +318,6 @@ int XRMResParser::Execute( int nToken, char * pToken )
sCurrentCloseTag = rToken;
sResourceType = ByteString ( "readmeitem" );
sLangAttribute = ByteString ( "xml:lang" );
- ByteString sLang = GetAttribute( sCurrentOpenTag, sLangAttribute );
WorkOnText( sCurrentOpenTag, sCurrentText );
Output( sCurrentText );
EndOfText( sCurrentOpenTag, sCurrentCloseTag );
@@ -354,7 +353,6 @@ int XRMResParser::Execute( int nToken, char * pToken )
sCurrentCloseTag = rToken;
sResourceType = ByteString ( "description" );
sLangAttribute = ByteString ( "lang" );
- ByteString sLang = GetAttribute( sCurrentOpenTag, sLangAttribute );
WorkOnText( sCurrentOpenTag, sCurrentText );
Output( sCurrentText );
EndOfText( sCurrentOpenTag, sCurrentCloseTag );
@@ -383,29 +381,9 @@ int XRMResParser::Execute( int nToken, char * pToken )
sCurrentOpenTag = rToken;
sCurrentText = ByteString("");
Output( rToken );
- DirEntry aEntry( String( sInputFileName, RTL_TEXTENCODING_ASCII_US ));
- aEntry.ToAbs();
- ByteString sDescFileName( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
- sDescFileName.SearchAndReplaceAll( "description.xml", "" );
- sDescFileName += GetAttribute( sCurrentOpenTag, "xlink:href" );
- ifstream::pos_type size;
- char * memblock;
- ifstream file (sDescFileName.GetBuffer(), ios::in|ios::binary|ios::ate);
- if (file.is_open()) {
- size = file.tellg();
- memblock = new char [size];
- file.seekg (0, ios::beg);
- file.read (memblock, size);
- file.close();
- sCurrentText = ByteString(memblock);
- sCurrentText.SearchAndReplaceAll( "\n", "\\n" );
- delete[] memblock;
- }
- ByteString sLang = GetAttribute( sCurrentOpenTag, sLangAttribute );
- WorkOnText( sCurrentOpenTag, sCurrentText );
+ WorkOnDesc( sCurrentOpenTag, sCurrentText );
sCurrentCloseTag = rToken;
Output( sCurrentText );
- EndOfText( sCurrentOpenTag, sCurrentCloseTag );
rToken = ByteString("");
sCurrentText = ByteString("");
}
@@ -543,6 +521,35 @@ void XRMResExport::Output( const ByteString& rOutput )
}
/*****************************************************************************/
+void XRMResExport::WorkOnDesc(
+ const ByteString &rOpenTag,
+ ByteString &rText
+)
+/*****************************************************************************/
+{
+ DirEntry aEntry( String( sInputFileName, RTL_TEXTENCODING_ASCII_US ));
+ aEntry.ToAbs();
+ ByteString sDescFileName( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
+ sDescFileName.SearchAndReplaceAll( "description.xml", "" );
+ sDescFileName += GetAttribute( rOpenTag, "xlink:href" );
+ ifstream::pos_type size;
+ char * memblock;
+ ifstream file (sDescFileName.GetBuffer(), ios::in|ios::binary|ios::ate);
+ if (file.is_open()) {
+ size = file.tellg();
+ memblock = new char [size];
+ file.seekg (0, ios::beg);
+ file.read (memblock, size);
+ file.close();
+ rText = ByteString(memblock);
+ rText.SearchAndReplaceAll( "\n", "\\n" );
+ delete[] memblock;
+ }
+ WorkOnText( rOpenTag, rText );
+ EndOfText( rOpenTag, rOpenTag );
+}
+
+//*****************************************************************************/
void XRMResExport::WorkOnText(
const ByteString &rOpenTag,
ByteString &rText
@@ -643,21 +650,84 @@ XRMResMerge::~XRMResMerge()
}
/*****************************************************************************/
+void XRMResMerge::WorkOnDesc(
+ const ByteString &rOpenTag,
+ ByteString &rText
+)
+/*****************************************************************************/
+{
+ WorkOnText( rOpenTag, rText);
+ if ( pMergeDataFile && pResData ) {
+ PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrys( pResData );
+ if ( pEntrys ) {
+ ByteString sCur;
+ ByteString sDescFilename = GetAttribute ( rOpenTag, "xlink:href" );
+ for( unsigned int n = 0; n < aLanguages.size(); n++ ){
+ sCur = aLanguages[ n ];
+ ByteString sContent;
+ if ( !sCur.EqualsIgnoreCaseAscii("en-US") &&
+ ( pEntrys->GetText(
+ sContent, STRING_TYP_TEXT, sCur, sal_True )) &&
+ ( sContent != "-" ) && ( sContent.Len()))
+ {
+ ByteString sText( sContent );
+ ByteString sAdditionalLine( "\n" );
+ sAdditionalLine += rOpenTag;
+ ByteString sSearch = sLangAttribute;
+ sSearch += "=\"";
+ ByteString sReplace( sSearch );
+
+ sSearch += GetAttribute( rOpenTag, sLangAttribute );
+ sReplace += sCur;
+ sAdditionalLine.SearchAndReplace( sSearch, sReplace );
+
+ sSearch = ByteString("xlink:href=\"");
+ sReplace = sSearch;
+
+ ByteString sLocDescFilename = sCur;
+ sLocDescFilename += ByteString("-");
+ sLocDescFilename += sDescFilename;
+
+ sSearch += sDescFilename;
+ sReplace += sLocDescFilename;
+ sAdditionalLine.SearchAndReplace( sSearch, sReplace );
+
+ Output( sAdditionalLine );
+
+ DirEntry aEntry( String( sOutputFile, RTL_TEXTENCODING_ASCII_US ));
+ aEntry.ToAbs();
+ ByteString sOutputDescFile( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
+ sOutputDescFile.SearchAndReplaceAll( "description.xml", "" );
+ sOutputDescFile += sLocDescFilename;
+ sText.SearchAndReplaceAll( "\\n", "\n" );
+ ofstream file ( sOutputDescFile.GetBuffer() );
+ if (file.is_open()) {
+ file << sText.GetBuffer();
+ file.close();
+ }
+ }
+ }
+ }
+ }
+ delete pResData;
+ pResData = NULL;
+}
+
+/*****************************************************************************/
void XRMResMerge::WorkOnText(
const ByteString &rOpenTag,
ByteString &rText
)
/*****************************************************************************/
{
- ByteString sLang( GetAttribute( rOpenTag, "xml:lang" ));
+ ByteString sLang( GetAttribute( rOpenTag, sLangAttribute ));
if ( pMergeDataFile ) {
if ( !pResData ) {
ByteString sPlatform( "" );
pResData = new ResData( sPlatform, GetLID() , sFilename );
pResData->sId = GetLID();
-
- pResData->sResTyp = "readmeitem";
+ pResData->sResTyp = sResourceType;
}
PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrys( pResData );
@@ -707,22 +777,19 @@ void XRMResMerge::EndOfText(
( sContent != "-" ) && ( sContent.Len()))
{
ByteString sText( sContent );
- ByteString sAdditionalLine( "\t" );
+ ByteString sAdditionalLine( "\n" );
sAdditionalLine += rOpenTag;
- ByteString sSearch = "xml:lang=\"";
+ ByteString sSearch = sLangAttribute;
+ sSearch += "=\"";
ByteString sReplace( sSearch );
- sSearch += GetAttribute( rOpenTag, "xml:lang" );
+ sSearch += GetAttribute( rOpenTag, sLangAttribute );
sReplace += sCur;
sAdditionalLine.SearchAndReplace( sSearch, sReplace );
sAdditionalLine += sText;
sAdditionalLine += rCloseTag;
- sAdditionalLine += "\n";
-
- for ( sal_uInt16 i = 0; i + 1 < GetGID().GetTokenCount( '.' ); i++ )
- sAdditionalLine += "\t";
Output( sAdditionalLine );
}