Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Am 06.02.2012 11:50, schrieb Ivan Timofeev:
On 06.02.2012 13:34, Chr. Rossmanith wrote:
I have replaced parameter ResData *pResData (which became ununsed) with
parameter rtl::OString sTextType. Or should it be rtl::OString&
sTextType instead?

A reference is better, however it is not really performance-critical I think. But if so, reference variables are 'r'-prefixed.

And I'd remove the return statement at the end of the function, it is redundant there.

Now we have cbr, r-prefixed and no return at the end of the function.

Christina
From ae254b3692e516a342feee14b3f3ad27c921e59c Mon Sep 17 00:00:00 2001
From: Christina Rossmanith <ChrRossmanith@web.de>
Date: Sun, 5 Feb 2012 15:03:30 +0100
Subject: [PATCH] Reduced duplicate code (simian) / l10ntools

---
 l10ntools/inc/export.hxx    |    2 +-
 l10ntools/source/export.cxx |  201 +++++++++++++------------------------------
 2 files changed, 60 insertions(+), 143 deletions(-)

diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx
index e0fcf05..5473ed8 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, sal_uInt16 nType, const rtl::OString& rTextType );
     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..a5aa324 100644
--- a/l10ntools/source/export.cxx
+++ b/l10ntools/source/export.cxx
@@ -1891,6 +1891,58 @@ sal_Bool Export::PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp,
     return sal_True;
 }
 
+void Export::ResData2Output( PFormEntrys *pEntry, sal_uInt16 nType, const rtl::OString& rTextType )
+{
+    sal_Bool bAddSemicolon = 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, 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";
+
+            sOutput += rTextType;
+
+            if ( ! Export::isSourceLanguage( sCur ) ) {
+                sOutput += "[ ";
+                sOutput += sCur;
+                sOutput += " ] ";
+            }
+            sOutput += "= ";
+            ConvertMergeContent( sText );
+            sOutput += sText;
+
+            if ( bDefine )
+                sOutput += ";\\\n";
+            else if ( !bNextMustBeDefineEOL )
+                sOutput += ";\n";
+            else
+                bAddSemicolon = sal_True;
+            for ( sal_uInt16 j = 1; j < nLevel; j++ )
+                sOutput += "\t";
+            WriteToMerged( sOutput , true );
+        }
+    }
+
+
+    if ( bAddSemicolon ) {
+        ByteString sOutput( ";" );
+        WriteToMerged( sOutput , false );
+    }
+}
+
 /*****************************************************************************/
 void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
 /*****************************************************************************/
@@ -1909,152 +1961,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;
-
-                for( unsigned int n = 0; n < aLanguages.size(); n++ ){
-                    sCur = aLanguages[ n ];
-
-                    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 ( pEntry ) {
+                if ( pResData->bText )
+                    ResData2Output( pEntry, STRING_TYP_TEXT, pResData->sTextTyp );
 
+                if ( pResData->bQuickHelpText )
+                    ResData2Output( pEntry, STRING_TYP_QUICKHELPTEXT, 
rtl::OString("QuickHelpText") );
 
-                if ( bAddSemikolon ) {
-                    ByteString sOutput( ";" );
-                    WriteToMerged( sOutput , false );
-                }
+                if ( pResData->bTitle )
+                    ResData2Output( pEntry, STRING_TYP_TITLE, rtl::OString("Title") );
             }
 
-            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 ( 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


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.