[PATCH] Reduced duplicate code (simian) / l10ntools
Christina Rossmanith
ChrRossmanith at web.de
Sun Feb 5 06:03:30 PST 2012
---
l10ntools/inc/export.hxx | 2 +-
l10ntools/source/export.cxx | 222 ++++++++++++++++---------------------------
2 files changed, 81 insertions(+), 143 deletions(-)
diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx
index e0fcf05..e427bb8 100644
--- a/l10ntools/inc/export.hxx
+++ b/l10ntools/inc/export.hxx
@@ -354,7 +354,7 @@ private:
sal_Bool PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp,
rtl::OString &rLangIndex, ResData *pResData);
-
+ void ResData2Output( PFormEntrys *pEntry, ResData *pResData );
void MergeRest( ResData *pResData, sal_uInt16 nMode = MERGE_MODE_NORMAL );
void ConvertMergeContent( ByteString &rText );
diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx
index 8909a1e..2df9ab6 100644
--- a/l10ntools/source/export.cxx
+++ b/l10ntools/source/export.cxx
@@ -1891,6 +1891,79 @@ sal_Bool Export::PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp,
return sal_True;
}
+void Export::ResData2Output( PFormEntrys *pEntry, ResData *pResData )
+{
+ sal_Bool bAddSemikolon = sal_False;
+ sal_Bool bFirst = sal_True;
+ ByteString sCur;
+ ByteString sTmp = Export::sLanguages;
+ sal_uInt16 nType;
+ bool bWriteNoSlash = false; // could be removed if if-statement below is removed
+
+ for( unsigned int n = 0; n < aLanguages.size(); n++ ){
+ sCur = aLanguages[ n ];
+
+ ByteString sText;
+ if ( pResData->bText )
+ nType = STRING_TYP_TEXT;
+ if ( pResData->bQuickHelpText )
+ nType = STRING_TYP_QUICKHELPTEXT;
+ if ( pResData->bTitle )
+ nType = STRING_TYP_TITLE;
+
+ sal_Bool bText = pEntry->GetTransex3Text( sText, nType, sCur , sal_True );
+ if ( bText && sText.Len() && sText != "-" ) {
+ ByteString sOutput;
+ if ( bNextMustBeDefineEOL) {
+ if ( bFirst )
+ sOutput += "\t\\\n";
+ else
+ sOutput += ";\t\\\n";
+ }
+ bFirst=sal_False;
+ sOutput += "\t";
+
+ if ( pResData->bText )
+ sOutput += pResData->sTextTyp;
+ else if ( pResData->bQuickHelpText )
+ sOutput += "QuickHelpText";
+ else if ( pResData->bTitle )
+ sOutput += "Title";
+
+ if ( ! Export::isSourceLanguage( sCur ) ) {
+ sOutput += "[ ";
+ sOutput += sCur;
+ sOutput += " ] ";
+ }
+ sOutput += "= ";
+ ConvertMergeContent( sText );
+ sOutput += sText;
+
+ if ( pResData->bText ) {
+ if ( bDefine && bWriteNoSlash ) // bWriteNoSlash seems to be always false
+ sOutput += ";\n";
+ }
+ if ( bDefine )
+ sOutput += ";\\\n";
+ else if ( !bNextMustBeDefineEOL )
+ sOutput += ";\n";
+ else
+ bAddSemikolon = sal_True;
+ for ( sal_uInt16 j = 1; j < nLevel; j++ )
+ sOutput += "\t";
+ WriteToMerged( sOutput , true );
+ }
+ }
+
+
+ if ( bAddSemikolon ) {
+ ByteString sOutput( ";" );
+ WriteToMerged( sOutput , false );
+ }
+
+ return;
+}
+
/*****************************************************************************/
void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
/*****************************************************************************/
@@ -1909,152 +1982,17 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
case MERGE_MODE_NORMAL : {
PFormEntrys *pEntry = pMergeDataFile->GetPFormEntrys( pResData );
- bool bWriteNoSlash = false;
- if ( pEntry && pResData->bText ) {
-
- sal_Bool bAddSemikolon = sal_False;
- sal_Bool bFirst = sal_True;
- ByteString sCur;
- ByteString sTmp = Export::sLanguages;
+ if ( pEntry ) {
+ if ( pResData->bText )
+ ResData2Output( pEntry, pResData );
- for( unsigned int n = 0; n < aLanguages.size(); n++ ){
- sCur = aLanguages[ n ];
+ if ( pResData->bQuickHelpText )
+ ResData2Output( pEntry, pResData );
- ByteString sText;
- sal_Bool bText = pEntry->GetTransex3Text( sText, STRING_TYP_TEXT, sCur , sal_True );
- if ( bText && sText.Len() && sText != "-" ) {
- ByteString sOutput;
- if ( bNextMustBeDefineEOL) {
- if ( bFirst )
- sOutput += "\t\\\n";
- else
- sOutput += ";\t\\\n";
- }
- bFirst=sal_False;
- sOutput += "\t";
- sOutput += pResData->sTextTyp;
- if ( ! Export::isSourceLanguage( sCur ) ) {
- sOutput += "[ ";
- sOutput += sCur;
- sOutput += " ] ";
- }
- sOutput += "= ";
- ConvertMergeContent( sText );
- sOutput += sText;
-
- if ( bDefine && bWriteNoSlash )
- sOutput += ";\n";
-
- if ( bDefine )
- sOutput += ";\\\n";
- else if ( !bNextMustBeDefineEOL )
- sOutput += ";\n";
- else
- bAddSemikolon = sal_True;
- for ( sal_uInt16 j = 1; j < nLevel; j++ )
- sOutput += "\t";
- WriteToMerged( sOutput , true );
- }
- }
-
-
- if ( bAddSemikolon ) {
- ByteString sOutput( ";" );
- WriteToMerged( sOutput , false );
- }
- }
-
- if ( pEntry && pResData->bQuickHelpText ) {
- sal_Bool bAddSemikolon = sal_False;
- sal_Bool bFirst = sal_True;
- ByteString sCur;
-
- for( unsigned int n = 0; n < aLanguages.size(); n++ ){
- sCur = aLanguages[ n ];
-
- ByteString sText;
- sal_Bool bText = pEntry->GetTransex3Text( sText, STRING_TYP_QUICKHELPTEXT, sCur, sal_True );
- if ( bText && sText.Len() && sText != "-" ) {
- ByteString sOutput;
- if ( bNextMustBeDefineEOL) {
- if ( bFirst )
- sOutput += "\t\\\n";
- else
- sOutput += ";\t\\\n";
- }
- bFirst=sal_False;
- sOutput += "\t";
- sOutput += "QuickHelpText";
- if ( ! Export::isSourceLanguage( sCur ) ) {
- sOutput += "[ ";
- sOutput += sCur;
- sOutput += " ] ";
- }
- sOutput += "= ";
- ConvertMergeContent( sText );
- sOutput += sText;
- if ( bDefine )
- sOutput += ";\\\n";
- else if ( !bNextMustBeDefineEOL )
- sOutput += ";\n";
- else
- bAddSemikolon = sal_True;
- for ( sal_uInt16 j = 1; j < nLevel; j++ )
- sOutput += "\t";
- WriteToMerged( sOutput ,true );
- }
- }
- if ( bAddSemikolon ) {
- ByteString sOutput( ";" );
- WriteToMerged( sOutput , false );
- }
+ if ( pResData->bTitle )
+ ResData2Output( pEntry, pResData );
}
- if ( pEntry && pResData->bTitle ) {
- sal_Bool bAddSemikolon = sal_False;
- sal_Bool bFirst = sal_True;
- ByteString sCur;
-
- for( unsigned int n = 0; n < aLanguages.size(); n++ ){
- sCur = aLanguages[ n ];
-
- ByteString sText;
- sal_Bool bText = pEntry->GetTransex3Text( sText, STRING_TYP_TITLE, sCur, sal_True );
- if ( bText && sText.Len() && sText != "-" ) {
- ByteString sOutput;
- if ( bNextMustBeDefineEOL) {
- if ( bFirst )
- sOutput += "\t\\\n";
- else
- sOutput += ";\t\\\n";
- }
- bFirst=sal_False;
- sOutput += "\t";
- sOutput += "Title";
- if ( ! Export::isSourceLanguage( sCur ) ) {
- sOutput += "[ ";
- sOutput += sCur;
- sOutput += " ] ";
- }
- sOutput += "= ";
- ConvertMergeContent( sText );
- sOutput += sText;
- if ( bDefine )
- sOutput += ";\\\n";
- else if ( !bNextMustBeDefineEOL )
- sOutput += ";\n";
- else
- bAddSemikolon = sal_True;
- for ( sal_uInt16 j = 1; j < nLevel; j++ )
- sOutput += "\t";
- WriteToMerged( sOutput ,true );
- }
- }
- if ( bAddSemikolon ) {
- ByteString sOutput( ";" );
- WriteToMerged( sOutput ,false);
- }
- }
// Merge Lists
if ( pResData->bList ) {
--
1.7.4.1
--------------040309080502020705070802--
More information about the LibreOffice
mailing list