[Libreoffice-commits] .: l10ntools/inc l10ntools/source

Joseph Powers jpowers at kemper.freedesktop.org
Sun Jan 23 06:07:27 PST 2011


 l10ntools/inc/gsicheck.hxx    |   10 +++--
 l10ntools/source/gsicheck.cxx |   73 ++++++++++++++++++++----------------------
 2 files changed, 41 insertions(+), 42 deletions(-)

New commits:
commit 4aa6f662a0f93313eedc636269cf2c55fdcf2859
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Sun Jan 23 06:07:21 2011 -0800

    Remove DECLARE_LIST( GSIBlock_Impl, GSILine *)

diff --git a/l10ntools/inc/gsicheck.hxx b/l10ntools/inc/gsicheck.hxx
index 6af0eec..aff04fe 100644
--- a/l10ntools/inc/gsicheck.hxx
+++ b/l10ntools/inc/gsicheck.hxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -30,12 +30,13 @@
 #define _GSICHECK_HXX_
 
 #include "tagtest.hxx"
+#include <vector>
 
 //
 // class GSILine
 //
 enum LineFormat { FORMAT_GSI, FORMAT_SDF, FORMAT_UNKNOWN };
-             
+
 class GSILine : public ByteString
 {
 private:
@@ -88,13 +89,14 @@ public:
 // class GSIBlock
 //
 
-DECLARE_LIST( GSIBlock_Impl, GSILine * )
+typedef ::std::vector< GSILine* > GSIBlock_Impl;
 
 class LazySvFileStream;
 
-class GSIBlock : public GSIBlock_Impl
+class GSIBlock
 {
 private:
+    GSIBlock_Impl maList;
     GSILine *pSourceLine;
     GSILine *pReferenceLine;
     void PrintList( ParserMessageList *pList, ByteString aPrefix, GSILine *pLine );
diff --git a/l10ntools/source/gsicheck.cxx b/l10ntools/source/gsicheck.cxx
index b5ade0b..7b943f9 100644
--- a/l10ntools/source/gsicheck.cxx
+++ b/l10ntools/source/gsicheck.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -198,7 +198,6 @@ GSILine::GSILine( const ByteString &rLine, ULONG nLine )
         }
         if ( nPos != STRING_NOTFOUND )
         {
-//        	ByteString aStatus = sTmp.Copy( nStart, nPos - nStart );     // ext int ...
             nStart = nPos + 4;  // + length of the delemiter
         }
         if ( nPos != STRING_NOTFOUND )
@@ -277,7 +276,7 @@ void GSILine::ReassembleLine()
         else
             PrintError( "Cannot reassemble GSI line (internal Error).", "Line format", "", FALSE, GetLineNumber(), GetUniqId() );
     }
-    else 
+    else
         PrintError( "Cannot reassemble line of unknown type (internal Error).", "Line format", "", FALSE, GetLineNumber(), GetUniqId() );
 }
 
@@ -306,8 +305,9 @@ GSIBlock::~GSIBlock()
     delete pSourceLine;
     delete pReferenceLine;
 
-    for ( ULONG i = 0; i < Count(); i++ )
-        delete ( GetObject( i ));
+    for ( size_t i = 0, n = maList.size(); i < n; ++i )
+        delete maList[ i ];
+    maList.clear();
 }
 
 /*****************************************************************************/
@@ -332,20 +332,19 @@ void GSIBlock::InsertLine( GSILine* pLine, ByteString aSourceLang)
 
     if ( aSourceLang.Len() ) // only check blockstructure if source lang is given
     {
-        ULONG nPos = 0;
-        while ( nPos < Count() )
+        for ( size_t nPos = 0, n = maList.size(); nPos < n; ++nPos )
         {
-            if ( GetObject( nPos )->GetLanguageId().Equals( pLine->GetLanguageId() ) )
+            if ( maList[ nPos ]->GetLanguageId().Equals( pLine->GetLanguageId() ) )
             {
                 PrintError( "Translation Language entry double. Checking both.", "File format", "", pLine->GetLineNumber(), pLine->GetUniqId() );
                 bHasBlockError = TRUE;
-                GetObject( nPos )->NotOK();
+                maList[ nPos ]->NotOK();
                 pLine->NotOK();
             }
             nPos++;
         }
     }
-    Insert( pLine, LIST_APPEND );
+    maList.push_back( pLine );
 }
 
 /*****************************************************************************/
@@ -453,7 +452,7 @@ BOOL GSIBlock::IsUTF8( const ByteString &aTestee, BOOL bFixTags, USHORT &nErrorP
             nAfterID = nAfterID + aDelimiter.Len();
         }
         else if ( ( aID.GetChar(6) == '*' ) && aID.Equals( aDelimiter, 7, aDelimiter.Len() ) )
-        {   // New KeyId     6 Letters, digits and spechial chars followed by '*delimiter' to indicate translation in progress 
+        {   // New KeyId     6 Letters, digits and spechial chars followed by '*delimiter' to indicate translation in progress
             bNewId = TRUE;
             nErrorPos = 1;
             aID = aID.Copy( 0, 6 );
@@ -613,7 +612,7 @@ BOOL GSIBlock::CheckSyntax( ULONG nLine, BOOL bRequireSourceLine, BOOL bFixTags
             if ( pSourceLine )
                 pSource = pSourceLine;
             else
-                pSource = GetObject( 0 );   // get some other line
+                pSource = maList.empty() ? NULL : maList[ 0 ];   // get some other line
             if ( pSource )
                 PrintError( "No reference line found. Entry is new in source file", "File format", "", pSource->GetLineNumber(), pSource->GetUniqId() );
             else
@@ -637,21 +636,21 @@ BOOL GSIBlock::CheckSyntax( ULONG nLine, BOOL bRequireSourceLine, BOOL bFixTags
     if ( pSourceLine )
         bHasError |= !TestUTF8( pSourceLine, bFixTags );
 
-    ULONG i;
-    for ( i = 0; i < Count(); i++ )
+    for ( size_t i = 0, n = maList.size(); i < n; ++i )
     {
-        aTester.CheckTestee( GetObject( i ), pSourceLine != NULL, bFixTags );
-        if ( GetObject( i )->HasMessages() || aTester.HasCompareWarnings() )
+        GSILine* pItem = maList[ i ];
+        aTester.CheckTestee( pItem, pSourceLine != NULL, bFixTags );
+        if ( pItem->HasMessages() || aTester.HasCompareWarnings() )
         {
-            if ( GetObject( i )->HasMessages() || aTester.GetCompareWarnings().HasErrors() )
-                GetObject( i )->NotOK();
+            if ( pItem->HasMessages() || aTester.GetCompareWarnings().HasErrors() )
+                pItem->NotOK();
             bHasError = TRUE;
-            PrintList( GetObject( i )->GetMessageList(), "Translation", GetObject( i ) );
-            PrintList( &(aTester.GetCompareWarnings()), "Translation Tag Mismatch", GetObject( i ) );
+            PrintList( pItem->GetMessageList(), "Translation", pItem );
+            PrintList( &(aTester.GetCompareWarnings()), "Translation Tag Mismatch", pItem );
         }
-        bHasError |= !TestUTF8( GetObject( i ), bFixTags );
+        bHasError |= !TestUTF8( pItem, bFixTags );
         if ( pSourceLine )
-            bHasError |= HasSuspiciousChars( GetObject( i ), pSourceLine );
+            bHasError |= HasSuspiciousChars( pItem, pSourceLine );
     }
 
     return bHasError || bHasBlockError;
@@ -664,14 +663,14 @@ void GSIBlock::WriteError( LazySvFileStream &aErrOut, BOOL bRequireSourceLine  )
 
     BOOL bHasError = FALSE;
     BOOL bCopyAll = ( !pSourceLine && bRequireSourceLine ) || ( pSourceLine && !pSourceLine->IsOK() && !bCheckTranslationLang ) || bHasBlockError;
-    ULONG i;
-    for ( i = 0; i < Count(); i++ )
+    for ( size_t i = 0, n = maList.size(); i < n; ++i )
     {
-        if ( !GetObject( i )->IsOK() || bCopyAll )
+        GSILine* pItem = maList[ i ];
+        if ( !pItem->IsOK() || bCopyAll )
         {
             bHasError = TRUE;
             aErrOut.LazyOpen();
-            aErrOut.WriteLine( *GetObject( i ) );
+            aErrOut.WriteLine( *pItem );
         }
     }
 
@@ -688,18 +687,18 @@ void GSIBlock::WriteCorrect( LazySvFileStream &aOkOut, BOOL bRequireSourceLine )
         return;
 
     BOOL bHasOK = FALSE;
-    ULONG i;
-    for ( i = 0; i < Count(); i++ )
+    for ( size_t i = 0, n = maList.size(); i < n; ++i )
     {
-        if ( ( GetObject( i )->IsOK() || bCheckSourceLang ) && !bHasBlockError )
+        GSILine* pItem = maList[ i ];
+        if ( ( pItem->IsOK() || bCheckSourceLang ) && !bHasBlockError )
         {
             bHasOK = TRUE;
             aOkOut.LazyOpen();
-            aOkOut.WriteLine( *GetObject( i ) );
+            aOkOut.WriteLine( *pItem );
         }
     }
 
-    if ( ( pSourceLine && pSourceLine->IsOK() && ( Count() || !bCheckTranslationLang ) ) || ( bHasOK && bCheckTranslationLang ) )
+    if ( ( pSourceLine && pSourceLine->IsOK() && ( !maList.empty() || !bCheckTranslationLang ) ) || ( bHasOK && bCheckTranslationLang ) )
     {
         aOkOut.LazyOpen();
         aOkOut.WriteLine( *pSourceLine );
@@ -712,14 +711,14 @@ void GSIBlock::WriteFixed( LazySvFileStream &aFixOut, BOOL /*bRequireSourceLine*
         return;
 
     BOOL bHasFixes = FALSE;
-    ULONG i;
-    for ( i = 0; i < Count(); i++ )
+    for ( size_t i = 0, n = maList.size(); i < n; ++i )
     {
-        if ( GetObject( i )->IsFixed() )
+        GSILine* pItem = maList[ i ];
+        if ( pItem->IsFixed() )
         {
             bHasFixes = TRUE;
             aFixOut.LazyOpen();
-            aFixOut.WriteLine( *GetObject( i ) );
+            aFixOut.WriteLine( *pItem );
         }
     }
 
@@ -1108,15 +1107,13 @@ int _cdecl main( int argc, char *argv[] )
                             }
                             if ( pReferenceLine->GetLineFormat() != FORMAT_UNKNOWN )
                             {
-                                if ( pReferenceLine->GetUniqId() == aId && pReferenceLine->GetLanguageId().Equals( aSourceLang ) ) 
+                                if ( pReferenceLine->GetUniqId() == aId && pReferenceLine->GetLanguageId().Equals( aSourceLang ) )
                                 {
                                     pBlock->SetReferenceLine( pReferenceLine );
                                     pReferenceLine = NULL;
                                 }
                                 else if ( pReferenceLine->GetUniqId() > aId )
                                 {
-//                                    if ( pGSILine->GetLanguageId() == aSourceLang )
-//                    		            PrintError( "No reference line found. Entry is new in source file", "File format", "", bPrintContext, pGSILine->GetLineNumber(), aId );
                                     bContinueSearching = FALSE;
                                 }
                                 else


More information about the Libreoffice-commits mailing list