You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ja...@apache.org on 2013/01/24 13:21:39 UTC

svn commit: r1437973 [9/11] - in /openoffice/branches/l10n/main/l10ntools/source: ./ filter/ filter/merge/ filter/utils/ help/

Added: openoffice/branches/l10n/main/l10ntools/source/merge.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/merge.cxx?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/merge.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/merge.cxx Thu Jan 24 12:21:38 2013
@@ -0,0 +1,382 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_l10ntools.hxx"
+#include <stdio.h>
+#include <tools/fsys.hxx>
+#include "export.hxx"
+#include "utf8conv.hxx"
+#include <iostream>
+
+using namespace std;
+
+namespace
+{
+    static ::rtl::OString lcl_NormalizeFilename(const ::rtl::OString& rFilename)
+    {
+        return rFilename.copy(
+            ::std::max(
+                rFilename.lastIndexOf( "\\" ),
+                rFilename.lastIndexOf( "/" ))+1);
+    };
+}
+
+extern void ConvertHalfwitdhToFullwidth( String& rString );
+
+//
+// class PFormEntrys
+//
+
+ByteString PFormEntrys::Dump()
+{
+    ByteString sRet( "PFormEntrys\n" );
+    ByteString a("sText");
+    if(sText.size())
+        Export::DumpMap(a , sText);
+    return sRet;
+}
+
+sal_Bool PFormEntrys::GetTransex3Text( ByteString &rReturn,
+    sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel )
+{
+    sal_Bool rc = GetText( rReturn , nTyp , nLangIndex , bDel );
+    ByteString test( rReturn );
+    for( sal_uInt16 idx = 0; idx < rReturn.Len(); idx++ )
+    {
+        if( rReturn.GetChar( idx ) == '\"' && ( idx >= 1 )  &&  rReturn.GetChar( idx-1 ) == '\\' )  
+        {  
+            rReturn.Erase( idx-1 , 1 );
+        }
+    }
+    //if( !rReturn.Equals( test ) )
+    //    printf("*CHANGED******************\n%s\n%s\n",test.GetBuffer(),rReturn.GetBuffer()); 
+    return rc;
+}
+/*****************************************************************************/
+sal_Bool PFormEntrys::GetText( ByteString &rReturn,
+    sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel )
+{
+
+    sal_Bool bReturn=sal_True;
+    switch ( nTyp ) {
+        case STRING_TYP_TEXT :
+            rReturn = sText[ nLangIndex ];
+            if ( bDel )
+                sText[ nLangIndex ] = "";
+            bReturn = bTextFirst[ nLangIndex ];
+            bTextFirst[ nLangIndex ] = sal_False;
+            break;
+        case STRING_TYP_HELPTEXT :
+            rReturn = sHelpText;
+            break;
+        case STRING_TYP_QUICKHELPTEXT :
+            rReturn = sQuickHelpText[ nLangIndex ];
+            if ( bDel )
+                sQuickHelpText[ nLangIndex ] = "";
+            bReturn = bQuickHelpTextFirst[ nLangIndex ];
+            bQuickHelpTextFirst[ nLangIndex ] = sal_False;
+            break;
+        case STRING_TYP_TITLE :
+            rReturn = sTitle[ nLangIndex ];
+            if ( bDel )
+                sTitle[ nLangIndex ] = "";
+            bReturn = bTitleFirst[ nLangIndex ];
+            bTitleFirst[ nLangIndex ] = sal_False;
+            break;
+    }
+    return bReturn;
+}
+
+
+//
+// class MergeData
+//
+
+MergeData::~MergeData()
+{
+}
+
+PFormEntrys* MergeData::GetPFormEntrys(ResData*)
+{
+    if( aMap.find( ByteString("HACK") ) != aMap.end() )
+        return aMap[ ByteString("HACK") ];
+    return NULL;
+}
+
+void MergeData::Insert(const ByteString&, PFormEntrys* pfEntrys )
+{
+    aMap.insert( PFormEntrysHashMap::value_type( ByteString("HACK") , pfEntrys ) );
+}
+
+ByteString MergeData::Dump(){
+    ByteString sRet( "MergeData\n" );
+
+    printf("MergeData sTyp = %s , sGid = %s , sLid =%s , sFilename = %s\n",sTyp.GetBuffer(),sGID.GetBuffer(),sLID.GetBuffer(), sFilename.GetBuffer() );
+
+    PFormEntrysHashMap::const_iterator idbg;
+    for( idbg = aMap.begin() ; idbg != aMap.end(); ++idbg )
+    {
+        printf("aMap[ %s ] = " ,idbg->first.GetBuffer());
+        ( (PFormEntrys*)(idbg->second) )->Dump();
+        printf("\n");
+    }
+    printf("\n");
+    return sRet;
+}
+
+PFormEntrys* MergeData::GetPFObject( const ByteString& rPFO ){
+    if( aMap.find( ByteString("HACK") ) != aMap.end() )
+        return aMap[ rPFO ];
+    return NULL;
+}
+
+
+PFormEntrys *MergeData::InsertEntry( const ByteString &rPForm )
+{
+    PFormEntrys* pFEntrys = new PFormEntrys( rPForm );
+    aMap.insert( PFormEntrysHashMap::value_type( rPForm , pFEntrys ) );
+    return pFEntrys;
+}
+
+sal_Bool MergeData::operator==( ResData *pData )
+{
+    ByteString sResTyp_upper( pData->sResTyp );
+    sResTyp_upper.ToUpperAscii();
+    ByteString sTyp_upper( sTyp );
+    sTyp_upper.ToUpperAscii();
+
+    return (( pData->sId == sLID ) &&
+            ( pData->sGId == sGID ) &&
+            ( sResTyp_upper  ==  sTyp_upper )
+            );
+}
+
+//
+// class MergeDataFile
+//
+
+#define FFORMAT_UNKNOWN 0x0000
+#define FFORMAT_NEW     0x0001
+#define FFORMAT_OLD     0x0002
+
+
+MergeDataFile::MergeDataFile(
+    const ByteString &rFileName,
+    const ByteString& sFile,
+    sal_Bool bErrLog,
+    CharSet aCharSet,
+    bool bCaseSensitive)
+    : bErrorLog( bErrLog )
+{
+    SvFileStream aInputStream( String( rFileName, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_READ );
+    aInputStream.SetStreamCharSet( aCharSet );
+    ByteString sLine;
+    const ByteString sHACK("HACK");
+    const ::rtl::OString sFileNormalized(lcl_NormalizeFilename(sFile));
+    const bool isFileEmpty = sFileNormalized.getLength();
+
+    if( !aInputStream.IsOpen() )
+    {
+        printf("Warning : Can't open %s\n", rFileName.GetBuffer());
+        return;
+    }
+    while ( !aInputStream.IsEof())
+    {
+        xub_StrLen nToks;
+        aInputStream.ReadLine( sLine );
+        sLine = sLine.Convert( RTL_TEXTENCODING_MS_1252, aCharSet );
+
+        nToks = sLine.GetTokenCount( '\t' );
+        if ( nToks == 15 )
+        {
+            // Skip all wrong filenames
+            const ::rtl::OString filename = lcl_NormalizeFilename(sLine.GetToken( 1 , '\t' ));
+            if(isFileEmpty || sFileNormalized.equals("") || (!isFileEmpty && filename.equals(sFileNormalized)) )
+            {
+                xub_StrLen rIdx = 0;
+                const ByteString sTYP = sLine.GetToken( 3, '\t', rIdx );
+                const ByteString sGID = sLine.GetToken( 0, '\t', rIdx ); // 4
+                const ByteString sLID = sLine.GetToken( 0, '\t', rIdx ); // 5
+                ByteString sPFO = sLine.GetToken( 1, '\t', rIdx ); // 7
+                sPFO = sHACK;
+                ByteString nLANG = sLine.GetToken( 1, '\t', rIdx ); // 9
+                nLANG.EraseLeadingAndTrailingChars();
+                const ByteString sTEXT = sLine.GetToken( 0, '\t', rIdx ); // 10
+                const ByteString sQHTEXT = sLine.GetToken( 1, '\t', rIdx ); // 12
+                const ByteString sTITLE = sLine.GetToken( 0, '\t', rIdx );  // 13
+
+
+#ifdef MERGE_SOURCE_LANGUAGES
+                if( true )
+#else
+                if( !nLANG.EqualsIgnoreCaseAscii("en-US") )
+#endif
+                {
+                    aLanguageSet.insert(nLANG);
+                    InsertEntry( sTYP, sGID, sLID, sPFO, nLANG, sTEXT, sQHTEXT, sTITLE, filename, bCaseSensitive );
+                }
+            }
+        }
+        else if ( nToks == 10 )
+        {
+            printf("ERROR: File format is obsolete and no longer supported!\n");
+        }
+    }
+    aInputStream.Close();
+}
+
+MergeDataFile::~MergeDataFile()
+{
+}
+
+ByteString MergeDataFile::Dump(){
+    ByteString sRet( "MergeDataFile\n" );
+
+    printf("MergeDataFile\n");
+    MergeDataHashMap::const_iterator idbg;
+    for( idbg = aMap.begin() ; idbg != aMap.end(); ++idbg )
+    {
+        printf("aMap[ %s ] = ",idbg->first.GetBuffer());
+        ((MergeData*) (idbg->second))->Dump();
+        printf("\n");
+    }
+    printf("\n");
+    return sRet;
+}
+
+void MergeDataFile::WriteError( const ByteString &rLine )
+{
+    if ( bErrorLog )
+    {
+        if ( !aErrLog.IsOpen())
+            aErrLog.Open( String( sErrorLog, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_WRITE | STREAM_TRUNC );
+        aErrLog.WriteLine( rLine );
+    }
+    else
+        fprintf( stderr, "%s\n", rLine.GetBuffer());
+}
+
+std::vector<ByteString> MergeDataFile::GetLanguages(){
+    return std::vector<ByteString>(aLanguageSet.begin(),aLanguageSet.end());
+}
+
+MergeData *MergeDataFile::GetMergeData( ResData *pResData , bool bCaseSensitive )
+{
+    ByteString sOldG = pResData->sGId;
+    ByteString sOldL = pResData->sId;
+    ByteString sGID = pResData->sGId;
+    ByteString sLID;
+    if(!sGID.Len())
+        sGID = pResData->sId;
+    else
+        sLID = pResData->sId;
+    pResData->sGId = sGID;
+    pResData->sId = sLID;
+
+    ByteString sKey = CreateKey( pResData->sResTyp , pResData->sGId , pResData->sId , pResData->sFilename , bCaseSensitive );
+
+    if(aMap.find( sKey ) != aMap.end())
+    {
+        pResData->sGId = sOldG;
+        pResData->sId = sOldL;
+        return aMap[ sKey ];
+    }
+    pResData->sGId = sOldG;
+    pResData->sId = sOldL;
+    return NULL;
+}
+
+
+PFormEntrys *MergeDataFile::GetPFormEntrys( ResData *pResData )
+{
+    // search for requested PFormEntrys
+    MergeData *pData = GetMergeData( pResData );
+    if ( pData )
+        return pData->GetPFormEntrys( pResData );
+    return NULL;
+}
+
+PFormEntrys *MergeDataFile::GetPFormEntrysCaseSensitive( ResData *pResData )
+{
+    // search for requested PFormEntrys
+    MergeData *pData = GetMergeData( pResData , true );
+    if ( pData )
+        return pData->GetPFormEntrys( pResData );
+    return NULL;
+}
+
+void MergeDataFile::InsertEntry(
+    const ByteString &rTYP, const ByteString &rGID,
+    const ByteString &rLID, const ByteString &rPFO,
+    const ByteString &nLANG, const ByteString &rTEXT,
+    const ByteString &rQHTEXT, const ByteString &rTITLE ,
+    const ByteString &rInFilename , bool bCaseSensitive
+    )
+{
+    MergeData *pData;
+
+    // search for MergeData
+    ByteString sKey = CreateKey( rTYP , rGID , rLID , rInFilename , bCaseSensitive );
+    MergeDataHashMap::const_iterator mit;
+    mit = aMap.find( sKey );
+    if( mit != aMap.end() )
+    {
+        pData = mit->second;
+    }
+    else
+    {
+        pData = new MergeData( rTYP, rGID, rLID, rInFilename );
+        aMap.insert( MergeDataHashMap::value_type( sKey, pData ) );
+    }
+
+    PFormEntrys *pFEntrys = 0;
+
+    // search for PFormEntrys
+    pFEntrys = pData->GetPFObject( rPFO );
+    if( !pFEntrys )
+    {
+        // create new PFormEntrys, cause no one exists with current properties
+        pFEntrys = new PFormEntrys( rPFO );
+        pData->Insert( rPFO , pFEntrys );
+    }
+
+    // finaly insert the cur string
+    pFEntrys->InsertEntry( nLANG , rTEXT, rQHTEXT, rTITLE );
+}
+
+ByteString MergeDataFile::CreateKey( const ByteString& rTYP , const ByteString& rGID , const ByteString& rLID , const ByteString& rFilename , bool bCaseSensitive )
+{
+    static const ::rtl::OString sStroke('-');
+    ::rtl::OString sKey( rTYP );
+    sKey += sStroke;
+    sKey += rGID;
+    sKey += sStroke;
+    sKey += rLID;
+    sKey += sStroke;
+    sKey += lcl_NormalizeFilename(rFilename);
+    OSL_TRACE("created key: %s", sKey.getStr());
+    if(bCaseSensitive)
+        return sKey;         // officecfg case sensitive identifier
+    return sKey.toAsciiUpperCase();
+}

Propchange: openoffice/branches/l10n/main/l10ntools/source/merge.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n/main/l10ntools/source/src_yy_wrapper.c
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/src_yy_wrapper.c?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/src_yy_wrapper.c (added)
+++ openoffice/branches/l10n/main/l10ntools/source/src_yy_wrapper.c Thu Jan 24 12:21:38 2013
@@ -0,0 +1,23 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+// Helper to suppress warnings in lex generated c code, see #i57362#
+#include "src_yy.c"

Propchange: openoffice/branches/l10n/main/l10ntools/source/src_yy_wrapper.c
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n/main/l10ntools/source/srciter.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/srciter.cxx?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/srciter.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/srciter.cxx Thu Jan 24 12:21:38 2013
@@ -0,0 +1,136 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_l10ntools.hxx"
+
+#include "srciter.hxx"
+#include <stdio.h>
+#include <tools/fsys.hxx>
+
+//
+// class SourceTreeIterator
+//
+
+/*****************************************************************************/
+SourceTreeIterator::SourceTreeIterator(
+	const ByteString &rRootDirectory, const ByteString &rVersion , bool bLocal_in )
+/*****************************************************************************/
+				: bInExecute( sal_False ) , bLocal( bLocal_in ) 
+{
+	(void) rVersion ;
+
+    if(!bLocal){
+        rtl::OUString sRootDirectory( rRootDirectory.GetBuffer() , rRootDirectory.Len() , RTL_TEXTENCODING_UTF8 );
+        aRootDirectory = transex::Directory( sRootDirectory );
+	}
+}
+
+/*****************************************************************************/
+SourceTreeIterator::~SourceTreeIterator()
+/*****************************************************************************/
+{
+}
+
+/*****************************************************************************/
+void SourceTreeIterator::ExecuteDirectory( transex::Directory& aDirectory )
+/*****************************************************************************/
+{
+    if ( bInExecute ) {
+		rtl::OUString sDirName = aDirectory.getDirectoryName();
+		
+		static rtl::OUString WCARD1 ( rtl::OUString::createFromAscii( "unxlng" ) );
+		static rtl::OUString WCARD2 ( rtl::OUString::createFromAscii( "unxsol" ) );
+		static rtl::OUString WCARD3 ( rtl::OUString::createFromAscii( "wntmsc" ) );
+		static rtl::OUString WCARD4 ( rtl::OUString::createFromAscii( "common" ) );
+		static rtl::OUString WCARD5 ( rtl::OUString::createFromAscii( "unxmac" ) );
+		static rtl::OUString WCARD6 ( rtl::OUString::createFromAscii( "unxubt" ) );
+		static rtl::OUString WCARD7 ( rtl::OUString::createFromAscii( ".svn" ) );
+		static rtl::OUString WCARD8 ( rtl::OUString::createFromAscii( ".hg" ) );
+
+		
+		if( sDirName.indexOf( WCARD1 , 0 ) > -1 ||
+			sDirName.indexOf( WCARD2 , 0 ) > -1 ||
+			sDirName.indexOf( WCARD3 , 0 ) > -1 ||
+			sDirName.indexOf( WCARD4 , 0 ) > -1 ||
+			sDirName.indexOf( WCARD5 , 0 ) > -1 ||
+			sDirName.indexOf( WCARD6 , 0 ) > -1 ||
+			sDirName.indexOf( WCARD7 , 0 ) > -1 ||
+			sDirName.indexOf( WCARD8 , 0 ) > -1 
+		   )	return;
+		//printf("**** %s \n", OUStringToOString( sDirName , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() );
+   	
+        rtl::OUString sDirNameTmp = aDirectory.getFullName();
+        ByteString sDirNameTmpB( rtl::OUStringToOString( sDirNameTmp , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() );
+        
+#ifdef WNT
+        sDirNameTmpB.Append( ByteString("\\no_localization") );
+#else
+        sDirNameTmpB.Append( ByteString("/no_localization") );
+#endif
+        //printf("**** %s \n", OUStringToOString( sDirNameTmp , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() );
+
+        DirEntry aDE( sDirNameTmpB.GetBuffer() ); 
+        if( aDE.Exists() )
+        {
+            //printf("#### no_localization file found ... skipping");
+            return;
+        }
+ 
+        aDirectory.setSkipLinks( bSkipLinks );
+        aDirectory.readDirectory();
+        OnExecuteDirectory( aDirectory.getFullName() );
+        if ( aDirectory.getSubDirectories().size() )
+			for ( sal_uLong i=0;i < aDirectory.getSubDirectories().size();i++ )
+				ExecuteDirectory( aDirectory.getSubDirectories()[ i ] );
+	}
+}
+
+/*****************************************************************************/
+sal_Bool SourceTreeIterator::StartExecute()
+/*****************************************************************************/
+{
+        
+	bInExecute = sal_True;                  // FIXME
+	ExecuteDirectory( aRootDirectory );
+
+	if ( bInExecute ) {                 // FIXME
+		bInExecute = sal_False;
+		return sal_True;
+	}
+	return sal_False;
+}
+
+/*****************************************************************************/
+void SourceTreeIterator::EndExecute()
+/*****************************************************************************/
+{
+	bInExecute = sal_False;
+}
+
+/*****************************************************************************/
+void SourceTreeIterator::OnExecuteDirectory( const rtl::OUString &rDirectory )
+/*****************************************************************************/
+{
+	fprintf( stdout, "%s\n", rtl::OUStringToOString( rDirectory, RTL_TEXTENCODING_UTF8, rDirectory.getLength() ).getStr() );
+}

Propchange: openoffice/branches/l10n/main/l10ntools/source/srciter.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n/main/l10ntools/source/srclex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/srclex.l?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/srclex.l (added)
+++ openoffice/branches/l10n/main/l10ntools/source/srclex.l Thu Jan 24 12:21:38 2013
@@ -0,0 +1,322 @@
+
+%{
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+/*
+ * lexer for parsing ressource source files (*.src)
+ *
+ */
+
+
+/* enlarge token buffer to tokenize whole strings */
+#undef YYLMAX
+#define YYLMAX 64000
+
+/* to enable debug output define LEXDEBUG */
+#define LEXDEBUG		1
+#ifdef LEXDEBUG
+#define OUTPUT	fprintf
+#else
+#define OUTPUT(Par1,Par2);
+#endif
+
+/* table of possible token ids */
+#include "tokens.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+#if defined __GNUC__
+#pragma GCC system_header
+#elif defined __SINPRO_CC
+#pragma disable_warn
+#elif defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+
+/* external functions (C++ code, declared as extren "C" */
+extern int WorkOnTokenSet( int, char* );
+extern int InitExport( char * , char * );
+extern int Parse( int nTyp, char *pTokenText );
+extern int EndExport();
+extern int SetError();
+extern int GetError();
+extern char *GetOutputFile( int argc, char* argv[]);
+extern FILE *GetNextFile();
+extern int isQuiet();
+extern void Close();
+extern char* getFilename();
+
+/* forwards */
+void YYWarning();
+%}
+
+%p 24000
+%e 1200
+%n 500
+
+%%
+
+^[\t ]*"#pragma".*	{
+	WorkOnTokenSet( PRAGMA, yytext );
+}
+
+^[ \t]*\n {
+	WorkOnTokenSet( EMPTYLINE, yytext );
+}
+
+[\t ]+ 				|
+^[\t ]*"#include".*	|
+^[\t ]*"#undef".* 	|
+"//".*				|
+";" 				|
+"<"					|
+">"					|
+\n	{
+	WorkOnTokenSet( IGNOREDTOKENS, yytext );
+}
+"/*"	{
+	char c1 = 0, c2 = input();
+	char pChar[2];
+	pChar[1] = 0x00;
+	pChar[0] = c2;
+
+	WorkOnTokenSet( COMMEND, yytext );
+	WorkOnTokenSet( COMMEND, pChar );
+	for(;;) {
+		if ( c2 == EOF )
+			break;
+		if ( c1 == '*' && c2 == '/' )
+			break;
+		c1 = c2;
+		c2 = input();
+		pChar[0] = c2;
+		WorkOnTokenSet( COMMEND, pChar );
+	}
+}
+
+^[\t ]*"#ifndef".+$	|
+^[\t ]*"#ifdef".+$	|
+^[\t ]*"#if".+$		|
+^[\t ]*"#elif".*$	|
+^[\t ]*"#else".*$	|
+^[\t ]*"#endif".*$	{
+	WorkOnTokenSet( CONDITION, yytext );
+}
+
+[a-zA-Z]+[\t ]+[^={\n]+[\t ] {
+/* defined Res */
+	WorkOnTokenSet( DEFINEDRES, yytext );
+}
+
+[a-zA-Z]+[ \t]+[^={;\n]+\n[ \t]*"#".*\n[ \t]*"{"	|
+[a-zA-Z]+[ \t]+[^={;\n]+\n?([ \t]*"//".*\n)*[ \t]*"{"	{
+/* RESSOURCE // String TTT_XX ... */
+	WorkOnTokenSet( RESSOURCE, yytext );
+}
+
+^[\t ]*[a-zA-Z_]+[\t ]*"\\"?[\t ]*\n?[ \t]*"{"[\t ]*"\\"?	{
+/* SMALRESSOURCE // String ... */
+	WorkOnTokenSet( SMALRESSOURCE, yytext );
+}
+
+[\t ]*[a-zA-Z0-9_]+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?=[ \t]*L?\".*\".*\n?	{
+/* TEXTLINE // TextTyp = "A Text" */
+	WorkOnTokenSet( TEXTLINE, yytext );
+}
+
+[\t ]*[a-zA-Z0-9_]+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?(\n[ \t]*)?=([ \t]*\n)?(([a-zA-Z0-9_]+)|(\".*\")|([ \t\n]*))*\".*\"(([a-zA-Z0-9_]+)|(\".*\")|([ \t\n]*))*;	{
+/* LONGTEXTLINE // TextTyp = "A Text" HHH_XXX "A Text" ZZZ_TTT ... */
+	WorkOnTokenSet( LONGTEXTLINE, yytext );
+}
+
+\".*\" {
+/* TEXT // "A Text" */
+	WorkOnTokenSet( TEXT, yytext );
+}
+
+"{"[ \t]*\\?	{
+/* LEVELUP */
+	WorkOnTokenSet( LEVELUP, yytext );
+}
+
+"}"[ \t]*;([ \t]*\\)?	{
+/* LEVELDOWN */
+	WorkOnTokenSet( LEVELDOWN, yytext );
+}
+
+[a-zA-Z0-9_]+[ \t]*"="[ \t]*"MAP_APPFONT"[ \t]*"(".+")".*	{
+/* APPFONTMAPPING  Typ = MAP_APPFONT( ... ) */
+	WorkOnTokenSet( APPFONTMAPPING, yytext );
+}
+
+[ \t]*[a-zA-Z0-9_]+[ \t]*=[ \t]*[0123456789]{1,5}[ \t]*";"?\\? {
+/* TEXTREFID // TextTyp = 12345 */
+	WorkOnTokenSet( TEXTREFID, yytext );
+}
+
+[a-zA-Z0-9_]+[ \t]*"="[\t ]*([ \t]*"//".*\n)*.*	| 
+[a-zA-Z0-9_]+[ \t]*"=".*	{ 
+/* ASSIGNMENT  Typ = ...  */
+ WorkOnTokenSet( ASSIGNMENT, yytext );
+}
+
+
+
+[a-zA-Z0-9_]+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?"="[ \t]*(\\[ \t]*)?\n?[ \t]*"{"[ \t]*(\\[ \t]*)?\n?[ \t]*"<"	{
+/* LISTASSIGNMENT  Typ [ ... ] = ... */
+	WorkOnTokenSet( LISTASSIGNMENT, yytext );
+}
+
+"StringList"+[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?"="[ \t]*(\\[ \t]*)?\n?[ \t]*"{"[ \t]*(\\[ \t]*)?\n?[ \t]*	{
+/* LISTASSIGNMENT  Typ [ ... ] = ... */
+	WorkOnTokenSet( LISTASSIGNMENT, yytext );
+}
+
+"UIEntries"[ \t]*("["[ \t]*[a-zA-Z0-9_\-]+[ \t]*"]"[ \t]*)?"="[ \t]*(\\[ \t]*)?\n?[ \t]*"{"	{
+/* UIENTRIES */
+	WorkOnTokenSet( UIENTRIES, yytext );
+}
+
+"<"?[ \t]*L?\".*\".*">" {
+/* LISTTEXT */
+	WorkOnTokenSet( LISTTEXT, yytext );
+}
+
+[ \t]*"#define"[ \t]+[a-zA-Z0-9_]+.*"\\"	{
+/* RSCDEFINE  #define ... */
+	WorkOnTokenSet( RSCDEFINE, yytext );
+}
+
+[ \t]*"#define"[ \t]+[a-zA-Z0-9_]+.+ {
+/* #define ... */
+	WorkOnTokenSet( NORMDEFINE, yytext );
+}
+
+"\\" {
+/* RSCDEFINELEND */
+	WorkOnTokenSet( RSCDEFINELEND, yytext );
+}
+
+[a-zA-Z0-9_]+[ \t]*; {
+/* allowed other tokens like "49 ;" or "SFX_... ;" */
+	WorkOnTokenSet( ANYTOKEN, yytext );
+}
+
+.	{
+	WorkOnTokenSet( UNKNOWNCHAR, yytext );
+/*	YYWarning( "Unknown Char" ); */
+}
+
+"{"?[ \t]*\".*\"[ \t]*";"[ \t]*"}" {
+/* _LISTTEXT */
+	WorkOnTokenSet( _LISTTEXT, yytext );
+}
+
+%%
+
+/*****************************************************************************/
+int	yywrap(void)
+/*****************************************************************************/
+{
+	FILE *pFile;
+	pFile = GetNextFile();
+	if ( pFile ) {
+		yyin = pFile;
+		yylineno = 0;
+		return 0;
+	}
+
+   /* end of input reached */
+	return 1;
+}
+
+/*****************************************************************************/
+void YYWarning( char *s )
+/*****************************************************************************/
+{
+	/* write warning to stderr */
+	fprintf( stderr, "Warning: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext  );
+}
+
+/*****************************************************************************/
+void yyerror( char *s )
+/*****************************************************************************/
+{
+	/* write error to stderr */
+	fprintf( stderr, "Error: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext  );
+	SetError();
+}
+
+/*****************************************************************************/
+int
+#ifdef WNT
+_cdecl
+#endif
+main( int argc, char* argv[])
+/*****************************************************************************/
+{
+	/* error level */
+	int nRetValue = 0;
+	char *pOutput;
+	FILE *pFile;
+    
+	pOutput = GetOutputFile( argc, argv );
+
+    if ( !pOutput ) {
+		fprintf( stdout, "Syntax:TRANSEX[-p Prj][-r PrjRoot]-i FileIn...[-o FileOut][-m DataBase][-e][-b][-u][-L l1,l2,...]\n" );
+		fprintf( stdout, " Prj:      Project\n" );
+		fprintf( stdout, " PrjRoot:  Path to project root (..\\.. etc.)\n" );
+		fprintf( stdout, " FileIn:   Source files (*.src)\n" );
+		fprintf( stdout, " FileOut:  Destination file (*.*)\n" );
+		fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
+		fprintf( stdout, " -QQ: quiet output\n" );
+        fprintf( stdout, " -e: Disable writing errorlog\n" );
+		fprintf( stdout, " -b: Break when Token \"HelpText\" found in source\n" );
+		fprintf( stdout, " -u: [english] and [german] are allowed, Id is Taken from DataBase \n" );
+		fprintf( stdout, " -NOUTF8: disable UTF8 as language independent encoding\n" );
+		fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
+		fprintf( stdout, "     A fallback language can be defined like this: l1=f1.\n" );
+		fprintf( stdout, "     f1, f2,... are also elements of (de,en-US...)\n" );
+		fprintf( stdout, "     Example: -L de,es=en-US\n" );
+		fprintf( stdout, "              Restriction to de and es, en-US will be fallback for es\n" );
+		return 1;
+	}
+    
+	InitExport( pOutput , getFilename() );
+	pFile = GetNextFile();
+	if ( !pFile )
+		return 1;
+    
+   	yyin = pFile;
+
+	/* create global instance of class Export */
+
+	/* start parser */
+   	yylex();
+   	Close();
+
+	/* get error info. and end export */
+	nRetValue = GetError();
+	EndExport();
+
+	/* return error level */
+	return nRetValue;
+}

Propchange: openoffice/branches/l10n/main/l10ntools/source/srclex.l
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n/main/l10ntools/source/tagtest.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/tagtest.cxx?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/tagtest.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/tagtest.cxx Thu Jan 24 12:21:38 2013
@@ -0,0 +1,1570 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_l10ntools.hxx"
+#include <tools/string.hxx>
+#include "tagtest.hxx"
+
+#if OSL_DEBUG_LEVEL > 1
+#include <stdio.h>
+#endif
+
+#include "gsicheck.hxx"
+
+#define HAS_FLAG( nFlags, nFlag )		( ( nFlags & nFlag ) != 0 )
+#define SET_FLAG( nFlags, nFlag )		( nFlags |= nFlag )
+#define RESET_FLAG( nFlags, nFlag )		( nFlags &= ~nFlag )	// ~ = Bitweises NOT
+
+
+
+TokenInfo::TokenInfo( TokenId pnId, sal_uInt16 nP, String paStr, ParserMessageList &rErrorList )
+: bClosed(sal_False)
+, bCloseTag(sal_False)
+, bIsBroken(sal_False)
+, bHasBeenFixed(sal_False)
+, bDone(sal_False)
+, aTokenString( paStr )
+, nId( pnId )
+, nPos(nP)
+{
+    if ( nId == TAG_COMMONSTART || nId == TAG_COMMONEND )
+        SplitTag( rErrorList );
+}
+
+enum tagcheck { TC_START, TC_HAS_TAG_NAME, TC_HAS_PROP_NAME_EQ, TC_HAS_PROP_NAME_EQ_SP, TC_HAS_PROP_NAME_SP, TC_INSIDE_STRING, TC_PROP_FINISHED, TC_CLOSED, TC_CLOSED_SPACE, TC_CLOSETAG, TC_CLOSETAG_HAS_TAG_NAME, TC_FINISHED, TC_ERROR };
+
+/*
+                                                      \<  link  href  =  \"text\"  name  =  \"C\"  \>
+START               ' ' ->  HAS_TAG_NAME
+START               '/' ->  CLOSED
+START               '/' ->  CLOSETAG    - no Portion (starting with /)
+START               '>' ->  FINISHED
+HAS_TAG_NAME        '=' ->  HAS_PROP_NAME_EQ
+HAS_TAG_NAME        ' ' ->  HAS_PROP_NAME_SP
+HAS_TAG_NAME        '/' ->  CLOSED
+HAS_TAG_NAME        '>' ->  FINISHED
+HAS_PROP_NAME_SP    '=' ->  HAS_PROP_NAME_EQ
+HAS_PROP_NAME_EQ    ' ' ->  HAS_PROP_NAME_EQ_SP
+HAS_PROP_NAME_EQ    '"' ->  INSIDE_STRING
+HAS_PROP_NAME_EQ_SP '"' ->  INSIDE_STRING
+INSIDE_STRING       ' ' ->  INSIDE_STRING
+INSIDE_STRING       '=' ->  INSIDE_STRING
+INSIDE_STRING       '>' ->  INSIDE_STRING
+INSIDE_STRING       '"' ->  PROP_FINISHED
+PROP_FINISHED       ' ' ->  HAS_TAG_NAME
+PROP_FINISHED       '/' ->  CLOSED
+PROP_FINISHED       '>' ->  FINISHED
+CLOSED              ' ' ->  CLOSED_SPACE
+CLOSED              '>' ->  FINISHED
+CLOSED_SPACE        '>' ->  FINISHED
+
+CLOSETAG            ' ' ->  CLOSETAG_HAS_TAG_NAME
+CLOSETAG            '>' ->  FINISHED
+CLOSETAG_HAS_TAG_NAME  '>' ->  FINISHED
+
+*/
+void TokenInfo::SplitTag( ParserMessageList &rErrorList )
+{
+    sal_uInt16 nLastPos = 2;    // skip initial  \<
+    sal_uInt16 nCheckPos = nLastPos;
+    String aDelims( String::CreateFromAscii( " \\=>/" ) );
+    String aPortion;
+    String aValue;      // store the value of a property
+    ByteString aName;   // store the name of a property/tag 
+    sal_Bool bCheckName = sal_False;
+    sal_Bool bCheckEmpty = sal_False;
+    sal_Unicode cDelim;
+    tagcheck aState = TC_START;
+
+    // skip blanks
+    while ( nLastPos < aTokenString.Len() && aTokenString.GetChar( nLastPos ) == ' ')
+        nLastPos++;
+
+    nCheckPos = aTokenString.SearchChar( aDelims.GetBuffer(), nLastPos );
+    while ( nCheckPos != STRING_NOTFOUND && !( aState == TC_FINISHED || aState == TC_ERROR ) )
+    {
+        aPortion = aTokenString.Copy( nLastPos, nCheckPos-nLastPos );
+
+        if ( aTokenString.GetChar( nCheckPos ) == '\\' )
+            nCheckPos++;         
+
+        cDelim = aTokenString.GetChar( nCheckPos );
+        nCheckPos++;
+
+        switch ( aState )
+        {
+//            START           ' ' ->  HAS_TAG_NAME
+//            START           '/' ->  CLOSED
+//            START           '>' ->  FINISHED
+            case TC_START:
+                aTagName = aPortion;
+                switch ( cDelim )
+                {
+                    case ' ':  aState = TC_HAS_TAG_NAME;
+                               bCheckName = sal_True;
+                               break;
+                    case '/':  
+                        {
+                            if ( aPortion.Len() == 0 )
+                            {
+                                aState = TC_CLOSETAG;
+                            }
+                            else
+                            {
+                                aState = TC_CLOSED;
+                                bCheckName = sal_True;
+                            }
+                        }
+                        break;
+                    case '>':  aState = TC_FINISHED;
+                               bCheckName = sal_True;
+                               break;
+                    default:   aState = TC_ERROR;
+                }
+                break;
+
+//            HAS_TAG_NAME    '=' ->  HAS_PROP_NAME_EQ
+//            HAS_TAG_NAME    ' ' ->  HAS_PROP_NAME_SP
+//            HAS_TAG_NAME    '/' ->  CLOSED
+//            HAS_TAG_NAME    '>' ->  FINISHED
+            case TC_HAS_TAG_NAME:
+                switch ( cDelim )
+                {
+                    case '=':  aState = TC_HAS_PROP_NAME_EQ;
+                               bCheckName = sal_True;
+                               break;
+                    case ' ':  aState = TC_HAS_PROP_NAME_SP;
+                               bCheckName = sal_True;
+                               break;
+                    case '/':  aState = TC_CLOSED;
+                               bCheckEmpty = sal_True;
+                               break;
+                    case '>':  aState = TC_FINISHED;
+                               bCheckEmpty = sal_True;
+                               break;
+                    default:   aState = TC_ERROR;
+                }
+                break;
+
+//            HAS_PROP_NAME_SP    '=' ->  HAS_PROP_NAME_EQ
+            case TC_HAS_PROP_NAME_SP:
+                switch ( cDelim )
+                {
+                    case '=':  aState = TC_HAS_PROP_NAME_EQ;
+                               bCheckEmpty = sal_True;
+                               break;
+                    default:   aState = TC_ERROR;
+                }
+                break;
+
+//            HAS_PROP_NAME_EQ    ' ' ->  HAS_PROP_NAME_EQ_SP
+//            HAS_PROP_NAME_EQ    '"' ->  INSIDE_STRING
+            case TC_HAS_PROP_NAME_EQ:
+                switch ( cDelim )
+                {
+                    case ' ':  aState = TC_HAS_PROP_NAME_EQ_SP;
+                               bCheckEmpty = sal_True;
+                               break;
+                    case '\"': aState = TC_INSIDE_STRING;
+                               bCheckEmpty = sal_True;
+                               aValue.Erase();
+                               break;
+                    default:   aState = TC_ERROR;
+                }
+                break;
+
+//            HAS_PROP_NAME_EQ_SP '"' ->  INSIDE_STRING
+            case TC_HAS_PROP_NAME_EQ_SP:
+                switch ( cDelim )
+                {
+                    case '\"': aState = TC_INSIDE_STRING;
+                               bCheckEmpty = sal_True;
+                               aValue.Erase();
+                               break;
+                    default:   aState = TC_ERROR;
+                }
+                break;
+
+//            INSIDE_STRING    *  ->  INSIDE_STRING
+//            INSIDE_STRING   '"' ->  PROP_FINISHED
+            case TC_INSIDE_STRING:
+                switch ( cDelim )
+                {
+                    case '\"': 
+                        {
+                            aState = TC_PROP_FINISHED;
+                            aValue += aPortion;
+                            if ( aProperties.find( aName ) == aProperties.end() )
+                            {
+                                if ( !IsPropertyValueValid( aName, aValue ) )
+                                {
+                                    rErrorList.AddError( 25, ByteString("Property '").Append(aName).Append("' has invalid value '").Append(ByteString( aValue, RTL_TEXTENCODING_UTF8 )).Append("' "), *this );
+                                    bIsBroken = sal_True;
+                                }
+                                aProperties[ aName ] = aValue;
+                            }
+                            else
+                            {
+                                rErrorList.AddError( 25, ByteString("Property '").Append(aName).Append("' defined twice "), *this );
+                                bIsBroken = sal_True;
+                            }
+                        }
+                               break;
+                    default:   
+                        {
+                            aState = TC_INSIDE_STRING;
+                            aValue += aPortion;
+                            aValue += cDelim;
+                        }
+                }
+                break;
+
+//            PROP_FINISHED   ' ' ->  HAS_TAG_NAME
+//            PROP_FINISHED   '/' ->  CLOSED
+//            PROP_FINISHED   '>' ->  FINISHED
+            case TC_PROP_FINISHED:
+                switch ( cDelim )
+                {
+                    case ' ': aState = TC_HAS_TAG_NAME;
+                               bCheckEmpty = sal_True;
+                               break;
+                    case '/': aState = TC_CLOSED;
+                               bCheckEmpty = sal_True;
+                               break;
+                    case '>': aState = TC_FINISHED;
+                               bCheckEmpty = sal_True;
+                               break;
+                    default:   aState = TC_ERROR;
+                }
+                break;
+
+//            CLOSED          ' ' ->  CLOSED_SPACE
+//            CLOSED          '>' ->  FINISHED
+            case TC_CLOSED:
+                switch ( cDelim )
+                {
+                    case ' ': aState = TC_CLOSED_SPACE;
+                               bCheckEmpty = sal_True;
+                               bClosed = sal_True;
+                               break;
+                    case '>': aState = TC_FINISHED;
+                               bCheckEmpty = sal_True;
+                               break;
+                    default:   aState = TC_ERROR;
+                }
+                break;
+
+//            CLOSED_SPACE    '>' ->  FINISHED
+            case TC_CLOSED_SPACE:
+                switch ( cDelim )
+                {
+                    case '>': aState = TC_FINISHED;
+                               bCheckEmpty = sal_True;
+                               break;
+                    default:   aState = TC_ERROR;
+                }
+                break;
+
+// CLOSETAG            ' ' ->  CLOSETAG_HAS_TAG_NAME
+// CLOSETAG            '>' ->  FINISHED
+            case TC_CLOSETAG:
+                bCloseTag = sal_True;
+                switch ( cDelim )
+                {
+                    case ' ': aState = TC_CLOSETAG_HAS_TAG_NAME;
+                               aTagName = aPortion;
+                               bCheckName = sal_True;
+                               break;
+                    case '>': aState = TC_FINISHED;
+                               aTagName = aPortion;
+                               bCheckName = sal_True;
+                               break;
+                    default:   aState = TC_ERROR;
+                }
+                break;
+
+// CLOSETAG_HAS_TAG_NAME       '>' ->  FINISHED
+            case TC_CLOSETAG_HAS_TAG_NAME:
+                switch ( cDelim )
+                {
+                    case '>': aState = TC_FINISHED;
+                               bCheckEmpty = sal_True;
+                               break;
+                    default:   aState = TC_ERROR;
+                }
+                break;
+
+
+            default: rErrorList.AddError( 99, "Internal error Parsing Tag ", *this );
+                     bIsBroken = sal_True;
+
+        }
+
+        if ( bCheckName )
+        {
+            if ( aPortion.Len() == 0 )
+            {
+                rErrorList.AddError( 25, "Tag/Property name missing ", *this );
+                bIsBroken = sal_True;
+            }
+            else
+            {
+                aName = ByteString( aPortion, RTL_TEXTENCODING_UTF8 );
+                // "a-zA-Z_-.0-9" 
+                xub_StrLen nCount;
+                sal_Bool bBroken = sal_False;
+                const sal_Char* aBuf = aName.GetBuffer();
+                for ( nCount = 0 ; !bBroken && nCount < aName.Len() ; nCount++ )
+                {
+                    bBroken = ! (   ( aBuf[nCount] >= 'a' && aBuf[nCount] <= 'z' )
+                                ||( aBuf[nCount] >= 'A' && aBuf[nCount] <= 'Z' )
+                                ||( aBuf[nCount] >= '0' && aBuf[nCount] <= '9' )
+                                ||( aBuf[nCount] == '_' )
+                                ||( aBuf[nCount] == '-' )
+                                ||( aBuf[nCount] == '.' )
+                                );
+                }
+
+                if ( bBroken )
+                {
+                    rErrorList.AddError( 25, "Found illegal character in Tag/Property name ", *this );
+                    bIsBroken = sal_True;
+                }
+            }
+
+            bCheckName = sal_False;
+        }
+
+        if ( bCheckEmpty )
+        {
+            if ( aPortion.Len() )
+            {
+                rErrorList.AddError( 25, ByteString("Found displaced characters '").Append(ByteString( aPortion, RTL_TEXTENCODING_UTF8 )).Append("' in Tag "), *this );
+                bIsBroken = sal_True;
+            }
+            bCheckEmpty = sal_False;
+        }
+
+
+        nLastPos = nCheckPos;
+
+        // skip further blanks
+        if ( cDelim == ' ' && aState != TC_INSIDE_STRING )
+            while ( nLastPos < aTokenString.Len() && aTokenString.GetChar( nLastPos ) == ' ')
+                nLastPos++;
+
+        nCheckPos = aTokenString.SearchChar( aDelims.GetBuffer(), nLastPos );
+    }
+    if ( aState != TC_FINISHED )
+    {
+        rErrorList.AddError( 25, "Parsing error in Tag ", *this );
+        bIsBroken = sal_True;
+    }
+}
+
+sal_Bool TokenInfo::IsPropertyRelevant( const ByteString &aName, const String &aValue ) const
+{
+    if ( aTagName.EqualsAscii( "alt" ) && aName.Equals( "xml-lang" ) )
+        return sal_False;
+    if ( aTagName.EqualsAscii( "ahelp" ) && aName.Equals( "visibility" ) && aValue.EqualsAscii("visible") )
+        return sal_False;
+    if ( aTagName.EqualsAscii( "image" ) && (aName.Equals( "width" ) || aName.Equals( "height" )) )
+        return sal_False;
+    
+    return sal_True;
+}
+
+sal_Bool TokenInfo::IsPropertyValueValid( const ByteString &aName, const String &aValue ) const
+{
+/*  removed due to i56740
+    if ( aTagName.EqualsAscii( "switchinline" ) && aName.Equals( "select" ) )
+    {
+        return aValue.EqualsAscii("sys") ||
+               aValue.EqualsAscii("appl") ||
+               aValue.EqualsAscii("distrib");
+    } */
+    if ( aTagName.EqualsAscii( "caseinline" ) && aName.Equals( "select" ) )
+    {
+        return /*!aValue.EqualsAscii("OS2") &&  removed due to i56740 */
+               !aValue.EqualsAscii("");
+    }
+
+    // we don't know any better so we assume it to be OK
+    return sal_True;
+}
+
+sal_Bool TokenInfo::IsPropertyInvariant( const ByteString &aName, const String &aValue ) const
+{
+    if ( aTagName.EqualsAscii( "link" ) && aName.Equals( "name" ) )
+        return sal_False;
+    if ( aTagName.EqualsAscii( "link" ) && aName.Equals( "href" ) )
+    {   // check for external reference
+        if (  aValue.Copy( 0, 5 ).EqualsIgnoreCaseAscii( "http:" )
+           || aValue.Copy( 0, 6 ).EqualsIgnoreCaseAscii( "https:" )
+           || aValue.Copy( 0, 4 ).EqualsIgnoreCaseAscii( "ftp:" ) )
+            return sal_False;
+        else
+            return sal_True;
+    }
+    return sal_True;
+}
+
+sal_Bool TokenInfo::IsPropertyFixable( const ByteString &aName ) const
+{
+    // name everything that is allowed to be fixed automatically here
+    if ( (aTagName.EqualsAscii( "ahelp" ) && aName.Equals( "hid" )) 
+      || (aTagName.EqualsAscii( "link" ) && aName.Equals( "href" )) 
+      || (aTagName.EqualsAscii( "alt" ) && aName.Equals( "id" )) 
+      || (aTagName.EqualsAscii( "variable" ) && aName.Equals( "id" )) 
+      || (aTagName.EqualsAscii( "image" ) && aName.Equals( "src" ))
+      || (aTagName.EqualsAscii( "image" ) && aName.Equals( "id" ) ))
+        return sal_True;
+    return sal_False;
+}
+
+sal_Bool TokenInfo::MatchesTranslation( TokenInfo& rInfo, sal_Bool bGenErrors, ParserMessageList &rErrorList, sal_Bool bFixTags ) const
+{
+    // check if tags are equal
+    // check if all existing properties are in the translation as well and
+    // wether they have a matching content (the same in most cases)
+
+    if ( nId != rInfo.nId )
+        return sal_False;
+
+    if ( !aTagName.Equals( rInfo.aTagName ) )
+        return sal_False;
+
+    // If one of the tags has formating errors already it does make no sense to check here, so return right away
+    if ( bGenErrors && ( bIsBroken || rInfo.bIsBroken ) )
+        return sal_True;
+
+	StringHashMap::const_iterator iProp;
+	for( iProp = aProperties.begin() ; iProp != aProperties.end(); ++iProp )
+    {
+        if ( rInfo.aProperties.find( iProp->first ) != rInfo.aProperties.end() )
+        {
+            if ( IsPropertyRelevant( iProp->first, iProp->second ) || IsPropertyRelevant( iProp->first, rInfo.aProperties.find( iProp->first )->second ) )
+            {
+                if ( IsPropertyInvariant( iProp->first, iProp->second ) )
+                {
+                    if ( !rInfo.aProperties.find( iProp->first )->second.Equals( iProp->second ) )
+                    {
+                        if ( bGenErrors )
+                        {
+                            if ( bFixTags && IsPropertyFixable( iProp->first ) )
+                            {
+                                rInfo.aProperties.find( iProp->first )->second = iProp->second;
+                                rInfo.SetHasBeenFixed();
+                                rErrorList.AddWarning( 25, ByteString("Property '").Append(iProp->first).Append("': FIXED different value in Translation "), *this );
+                            }
+                            else
+                                rErrorList.AddError( 25, ByteString("Property '").Append(iProp->first).Append("': value different in Translation "), *this );
+                        }
+                        else return sal_False;
+                    }
+                }
+            }
+        }
+        else
+        {
+            if ( IsPropertyRelevant( iProp->first, iProp->second ) )
+            {
+                if ( bGenErrors )
+                    rErrorList.AddError( 25, ByteString("Property '").Append(iProp->first).Append("' missing in Translation "), *this );
+                else return sal_False;
+            }
+        }
+	}
+	for( iProp = rInfo.aProperties.begin() ; iProp != rInfo.aProperties.end(); ++iProp )
+    {
+        if ( aProperties.find( iProp->first ) == aProperties.end() )
+        {
+            if ( IsPropertyRelevant( iProp->first, iProp->second ) )
+            {
+                if ( bGenErrors )
+                    rErrorList.AddError( 25, ByteString("Extra Property '").Append(iProp->first).Append("' in Translation "), rInfo );
+                else return sal_False;
+            }
+        }
+	}
+
+    // if we reach here eather 
+    //   the tags match completely or
+    //   the tags match but not the properties and we generated errors for that
+    return sal_True;
+}
+
+String TokenInfo::GetTagName() const
+{
+    return aTagName;
+}
+
+String TokenInfo::MakeTag() const
+{
+    String aRet;
+    aRet.AppendAscii("\\<");
+    if ( bCloseTag )
+        aRet.AppendAscii("/");
+    aRet.Append( GetTagName() );
+	StringHashMap::const_iterator iProp;
+
+	for( iProp = aProperties.begin() ; iProp != aProperties.end(); ++iProp )
+    {
+        aRet.AppendAscii(" ");
+        aRet.Append( String( iProp->first, RTL_TEXTENCODING_UTF8 ) );
+        aRet.AppendAscii("=\\\"");
+        aRet.Append( iProp->second );
+        aRet.AppendAscii("\\\"");
+    }
+    if ( bClosed )
+        aRet.AppendAscii("/");
+    aRet.AppendAscii("\\>");
+    return aRet;
+}
+
+
+void ParserMessageList::AddError( sal_uInt16 nErrorNr, ByteString aErrorText, const TokenInfo &rTag )
+{
+    Insert( new ParserError( nErrorNr, aErrorText, rTag ), LIST_APPEND );
+}
+
+void ParserMessageList::AddWarning( sal_uInt16 nErrorNr, ByteString aErrorText, const TokenInfo &rTag )
+{
+    Insert( new ParserWarning( nErrorNr, aErrorText, rTag ), LIST_APPEND );
+}
+
+sal_Bool ParserMessageList::HasErrors()
+{
+    sal_uInt16 i;
+    for ( i=0 ; i < Count() ; i++ )
+        if ( GetObject( i )->IsError() )
+            return sal_True;
+    return sal_False;
+}
+
+struct Tag
+{
+    String GetName() const { return String::CreateFromAscii( pName ); };
+	const char* pName;
+	TokenId nTag;
+};
+
+
+static const Tag aKnownTags[] =
+{
+/*  commenting oldstyle tags
+//	{ "<#GROUP_FORMAT>", TAG_GROUP_FORMAT },
+	{ "<#BOLD>", TAG_BOLDON },
+	{ "<#/BOLD>", TAG_BOLDOFF },
+	{ "<#ITALIC>", TAG_ITALICON },
+	{ "<#/ITALIC>", TAG_ITALICOFF },
+	{ "<#UNDER>", TAG_UNDERLINEON },
+	{ "<#/UNDER>", TAG_UNDERLINEOFF },
+
+//	{ "<#GROUP_NOTALLOWED>", TAG_GROUP_NOTALLOWED },
+	{ "<#HELPID>", TAG_HELPID },
+	{ "<#MODIFY>", TAG_MODIFY },
+	{ "<#REFNR>", TAG_REFNR },
+
+//	{ "<#GROUP_STRUCTURE>", TAG_GROUP_STRUCTURE },
+	{ "<#NAME>", TAG_NAME },
+	{ "<#HREF>", TAG_HREF },
+	{ "<#AVIS>", TAG_AVIS },
+	{ "<#AHID>", TAG_AHID },
+	{ "<#AEND>", TAG_AEND },
+
+	{ "<#TITEL>", TAG_TITEL },
+	{ "<#KEY>", TAG_KEY },
+	{ "<#INDEX>", TAG_INDEX },
+
+	{ "<#REFSTART>", TAG_REFSTART },
+
+	{ "<#GRAPHIC>", TAG_GRAPHIC },
+	{ "<#NEXTVERSION>", TAG_NEXTVERSION },
+
+    //	{ "<#GROUP_SYSSWITCH>", TAG_GROUP_SYSSWITCH },
+	{ "<#WIN>", TAG_WIN },
+	{ "<#UNIX>", TAG_UNIX },
+	{ "<#MAC>", TAG_MAC },
+	{ "<#OS2>", TAG_OS2 },
+
+//	{ "<#GROUP_PROGSWITCH>", TAG_GROUP_PROGSWITCH },
+	{ "<#WRITER>", TAG_WRITER },
+	{ "<#CALC>", TAG_CALC },
+	{ "<#DRAW>", TAG_DRAW },
+	{ "<#IMPRESS>", TAG_IMPRESS },
+	{ "<#SCHEDULE>", TAG_SCHEDULE },
+	{ "<#IMAGE>", TAG_IMAGE },
+	{ "<#MATH>", TAG_MATH },
+	{ "<#CHART>", TAG_CHART },
+	{ "<#OFFICE>", TAG_OFFICE },
+  */
+//	{ "<#TAG_GROUP_META>", TAG_GROUP_META },
+	{ "$[officefullname]", TAG_OFFICEFULLNAME },
+	{ "$[officename]", TAG_OFFICENAME },
+	{ "$[officepath]", TAG_OFFICEPATH },
+	{ "$[officeversion]", TAG_OFFICEVERSION },
+	{ "$[portalname]", TAG_PORTALNAME },
+	{ "$[portalfullname]", TAG_PORTALFULLNAME },
+	{ "$[portalpath]", TAG_PORTALPATH },
+	{ "$[portalversion]", TAG_PORTALVERSION },
+	{ "$[portalshortname]", TAG_PORTALSHORTNAME },
+/*  commenting oldstyle tags
+//	{ "<#TAG_GROUP_SINGLE>", TAG_GROUP_SINGLE },
+	{ "<#REFINSERT>", TAG_REFINSERT },
+
+//	{ "<#GROUP_MULTI>", TAG_GROUP_MULTI },
+	{ "<#END>", TAG_END },
+	{ "<#ELSE>", TAG_ELSE },
+	{ "<#VERSIONEND>", TAG_VERSIONEND },
+	{ "<#ENDGRAPHIC>", TAG_ENDGRAPHIC },*/
+	{ "<Common Tag>", TAG_COMMONSTART },
+	{ "</Common Tag>", TAG_COMMONEND },
+
+    { "<no more tags>", TAG_NOMORETAGS },
+	{ "", TAG_UNKNOWN_TAG },
+};
+
+
+SimpleParser::SimpleParser()
+: nPos( 0 )
+, aNextTag( TAG_NOMORETAGS, TOK_INVALIDPOS )
+{
+}
+
+void SimpleParser::Parse( String PaSource )
+{
+    aSource = PaSource;
+	nPos = 0;
+	aLastToken.Erase();
+    aNextTag = TokenInfo( TAG_NOMORETAGS, TOK_INVALIDPOS );
+	aTokenList.Clear();
+};
+
+TokenInfo SimpleParser::GetNextToken( ParserMessageList &rErrorList )
+{
+    TokenInfo aResult;
+    sal_uInt16 nTokenStartPos = 0;
+    if ( aNextTag.nId != TAG_NOMORETAGS )
+    {
+        aResult = aNextTag;
+        aNextTag = TokenInfo( TAG_NOMORETAGS, TOK_INVALIDPOS );
+    }
+    else
+    {
+	    aLastToken = GetNextTokenString( rErrorList, nTokenStartPos );
+	    if ( aLastToken.Len() == 0 )
+		    return TokenInfo( TAG_NOMORETAGS, TOK_INVALIDPOS );
+
+        // do we have a \< ... \> style tag?
+        if ( aLastToken.Copy(0,2).EqualsAscii( "\\<" ) )
+        {
+            // check for paired \" \"
+            bool bEven = true;
+            sal_uInt16 nQuotePos = 0;
+    	    sal_uInt16 nQuotedQuotesPos = aLastToken.SearchAscii( "\\\"" );
+    	    sal_uInt16 nQuotedBackPos = aLastToken.SearchAscii( "\\\\" );    // this is only to kick out quoted backslashes
+            while ( nQuotedQuotesPos != STRING_NOTFOUND )
+            {
+                if ( nQuotedBackPos <= nQuotedQuotesPos )
+                    nQuotePos = nQuotedBackPos+2;
+                else
+                {
+                    nQuotePos = nQuotedQuotesPos+2;
+                    bEven = !bEven;
+                }
+		        nQuotedQuotesPos = aLastToken.SearchAscii( "\\\"", nQuotePos );
+    	        nQuotedBackPos = aLastToken.SearchAscii( "\\\\", nQuotePos );    // this is only to kick out quoted backslashes
+            }
+            if ( !bEven )
+            {
+        		rErrorList.AddError( 24, "Missing quotes ( \\\" ) in Tag", TokenInfo( TAG_UNKNOWN_TAG, nTokenStartPos, aLastToken ) );
+            }
+
+            // check if we have an end-tag or a start-tag
+            sal_uInt16 nNonBlankStartPos,nNonBlankEndPos;
+            nNonBlankStartPos = 2;
+            while ( aLastToken.GetChar(nNonBlankStartPos) == ' ' )
+                nNonBlankStartPos++;
+            if ( aLastToken.GetChar(nNonBlankStartPos) == '/' )
+                aResult = TokenInfo( TAG_COMMONEND, nTokenStartPos, aLastToken, rErrorList );
+            else
+            {
+                aResult = TokenInfo( TAG_COMMONSTART, nTokenStartPos, aLastToken, rErrorList );
+                nNonBlankEndPos = aLastToken.Len() -3;
+                while ( aLastToken.GetChar(nNonBlankEndPos) == ' ' )
+                    nNonBlankEndPos--;
+                if ( aLastToken.GetChar( nNonBlankEndPos ) == '/' )
+                    aNextTag = TokenInfo( TAG_COMMONEND, nTokenStartPos, String::CreateFromAscii("\\</").Append(aResult.GetTagName()).AppendAscii("\\>"), rErrorList );
+            }
+        }
+        else
+        {
+	        sal_uInt16 i = 0;
+	        while ( aKnownTags[i].nTag != TAG_UNKNOWN_TAG &&
+		        aLastToken != aKnownTags[i].GetName() )
+		        i++;
+            aResult = TokenInfo( aKnownTags[i].nTag, nTokenStartPos );
+        }
+    }
+
+    if ( aResult.nId == TAG_UNKNOWN_TAG )
+        aResult = TokenInfo( TAG_UNKNOWN_TAG, nTokenStartPos, aLastToken );
+	aTokenList.Insert( aResult, LIST_APPEND );
+	return aResult;
+}
+
+String SimpleParser::GetNextTokenString( ParserMessageList &rErrorList, sal_uInt16 &rTagStartPos )
+{
+//	sal_uInt16 nStyle1StartPos = aSource.SearchAscii( "<#", nPos );
+	sal_uInt16 nStyle2StartPos = aSource.SearchAscii( "$[", nPos );
+	sal_uInt16 nStyle3StartPos = aSource.SearchAscii( "\\<", nPos );
+	sal_uInt16 nStyle4StartPos = aSource.SearchAscii( "\\\\", nPos );    // this is only to kick out quoted backslashes
+
+    rTagStartPos = 0;
+
+/* removing since a \<... is not likely
+    // check if the tag starts with a letter to avoid things like <> <= ... >
+    while ( STRING_NOTFOUND != nStyle3StartPos && !( aSource.Copy( nStyle3StartPos+2, 1 ).IsAlphaAscii() || aSource.GetChar( nStyle3StartPos+2 ) == '/' ) )
+    	nStyle3StartPos = aSource.SearchAscii( "\\<", nStyle3StartPos+1 );
+*/
+    if ( STRING_NOTFOUND == nStyle2StartPos && STRING_NOTFOUND == nStyle3StartPos )
+        return String();  // no more tokens
+
+	if ( nStyle4StartPos < nStyle2StartPos && nStyle4StartPos <= nStyle3StartPos )  // <= to make sure \\ is always handled first
+    {   // Skip quoted Backslash
+        nPos = nStyle4StartPos +2;
+        return GetNextTokenString( rErrorList, rTagStartPos );
+    }
+
+/*	if ( nStyle1StartPos < nStyle2StartPos && nStyle1StartPos <= nStyle3StartPos )  // <= to make sure our spechial tags are recognized before all others
+    {	// test for <# ... > style tokens
+	    sal_uInt16 nEndPos = aSource.SearchAscii( ">", nStyle1StartPos );
+        if ( nEndPos == STRING_NOTFOUND )
+        {   // Token is incomplete. Skip start and search for better ones
+            nPos = nStyle1StartPos +2;
+            return GetNextTokenString( rErrorList, rTagStartPos );
+        }
+	    nPos = nEndPos;
+        rTagStartPos = nStyle1StartPos;
+	    return aSource.Copy( nStyle1StartPos, nEndPos-nStyle1StartPos +1 ).ToUpperAscii();
+    }
+    else*/ if ( nStyle2StartPos < nStyle3StartPos )
+	{	// test for $[ ... ] style tokens
+		sal_uInt16 nEndPos = aSource.SearchAscii( "]", nStyle2StartPos);
+        if ( nEndPos == STRING_NOTFOUND )
+        {   // Token is incomplete. Skip start and search for better ones
+            nPos = nStyle2StartPos +2;
+            return GetNextTokenString( rErrorList, rTagStartPos );
+        }
+		nPos = nEndPos;
+        rTagStartPos = nStyle2StartPos;
+		return aSource.Copy( nStyle2StartPos, nEndPos-nStyle2StartPos +1 );
+	}
+    else
+	{	// test for \< ... \> style tokens
+    	sal_uInt16 nEndPos = aSource.SearchAscii( "\\>", nStyle3StartPos);
+    	sal_uInt16 nQuotedBackPos = aSource.SearchAscii( "\\\\", nStyle3StartPos );    // this is only to kick out quoted backslashes
+        while ( nQuotedBackPos <= nEndPos && nQuotedBackPos != STRING_NOTFOUND )
+        {
+		    nEndPos = aSource.SearchAscii( "\\>", nQuotedBackPos +2);
+    	    nQuotedBackPos = aSource.SearchAscii( "\\\\", nQuotedBackPos +2 );    // this is only to kick out quoted backslashes
+        }
+        if ( nEndPos == STRING_NOTFOUND )
+        {   // Token is incomplete. Skip start and search for better ones
+            nPos = nStyle3StartPos +2;
+		    ByteString sTmp( "Tag Start '\\<' without Tag End '\\>': " );
+        	rErrorList.AddError( 24, "Tag Start '\\<' without Tag End '\\>'", TokenInfo( TAG_UNKNOWN_TAG, nStyle3StartPos, aSource.Copy( nStyle3StartPos-10, 20 ) ) );
+            return GetNextTokenString( rErrorList, rTagStartPos );
+        }
+        // check for paired quoted "    -->   \"sometext\"
+
+        nPos = nEndPos;
+        rTagStartPos = nStyle3StartPos;
+		return aSource.Copy( nStyle3StartPos, nEndPos-nStyle3StartPos +2 );
+	}
+}
+
+String SimpleParser::GetLexem( TokenInfo const &aToken )
+{
+    if ( aToken.aTokenString.Len() )
+        return aToken.aTokenString;
+    else
+    {
+        sal_uInt16 i = 0;
+	    while ( aKnownTags[i].nTag != TAG_UNKNOWN_TAG &&
+		    aKnownTags[i].nTag != aToken.nId )
+		    i++;
+
+        return aKnownTags[i].GetName();
+    }
+}
+
+TokenParser::TokenParser()
+: pErrorList( NULL )
+{}
+
+void TokenParser::Parse( const String &aCode, ParserMessageList* pList )
+{
+    pErrorList = pList;
+
+	//Scanner initialisieren
+	aParser.Parse( aCode );
+
+	//erstes Symbol holen
+	aTag = aParser.GetNextToken( *pErrorList );
+
+	nPfCaseOptions = 0;
+	nAppCaseOptions = 0;
+	bPfCaseActive = sal_False;
+	bAppCaseActive = sal_False;
+
+	nActiveRefTypes = 0;
+
+    //Ausfuehren der Start-Produktion
+	Paragraph();
+
+	//Es wurde nicht die ganze Kette abgearbeitet, bisher ist aber
+	//kein Fehler aufgetreten
+	//=> es wurde ein einleitendes Tag vergessen
+	if ( aTag.nId != TAG_NOMORETAGS )
+	{
+		switch ( aTag.nId )
+		{
+			case TAG_END:
+				{
+					ParseError( 3, "Extra Tag <#END>. Switch or <#HREF> expected.", aTag );
+				}
+				break;
+			case TAG_BOLDOFF:
+				{
+					ParseError( 4, "<#BOLD> expected before <#/BOLD>.", aTag );
+				}
+				break;
+			case TAG_ITALICOFF:
+				{
+					ParseError( 5, "<#ITALIC> expected before <#/ITALIC>.", aTag );
+				}
+				break;
+			case TAG_UNDERLINEOFF:
+				{
+					ParseError( 17, "<#UNDER> expected before <#/UNDER>.", aTag );
+				}
+				break;
+/*			case TAG_MISSPARENTHESIS:
+				{
+					ParseError( 14, "missing closing parenthesis '>'", aTag );
+				}
+				break;*/
+			case TAG_AEND:
+				{
+					ParseError( 5, "Extra Tag <#AEND>. <#AVIS> or <#AHID> expected.", aTag );
+				}
+				break;
+			case TAG_ELSE:
+				{
+					ParseError( 16, "Application-tag or platform-tag expected before <#ELSE>.", aTag );
+				}
+				break;
+			case TAG_UNKNOWN_TAG:
+				{
+					ParseError( 6, "unknown Tag", aTag );
+				}
+				break;
+			default:
+				{
+					ParseError( 6, "unexpected Tag", aTag );
+				}
+		}
+	}
+    pErrorList = NULL;
+}
+
+void TokenParser::Paragraph()
+{
+	switch ( aTag.nId )
+	{
+		case TAG_GRAPHIC:
+		case TAG_NEXTVERSION:
+			{
+				TagRef();
+				Paragraph();
+			}
+			break;
+		case TAG_AVIS:
+		case TAG_AHID:
+			{
+				TagRef();
+				Paragraph();
+			}
+			break;
+		case TAG_HELPID:
+			{
+				SimpleTag();
+				Paragraph();
+			}
+			break;
+		case TAG_OFFICEFULLNAME:
+		case TAG_OFFICENAME:
+		case TAG_OFFICEPATH:
+		case TAG_OFFICEVERSION:
+		case TAG_PORTALNAME:
+		case TAG_PORTALFULLNAME:
+		case TAG_PORTALPATH:
+		case TAG_PORTALVERSION:
+		case TAG_PORTALSHORTNAME:
+			{
+				SimpleTag();
+				Paragraph();
+			}
+			break;
+		case TAG_REFINSERT:
+			{
+				SimpleTag();
+				Paragraph();
+			}
+			break;
+		case TAG_BOLDON:
+		case TAG_ITALICON:
+		case TAG_UNDERLINEON:
+		case TAG_COMMONSTART:
+			{
+				TagPair();
+				Paragraph();
+			}
+			break;
+		case TAG_HREF:
+		case TAG_NAME:
+		case TAG_KEY:
+		case TAG_INDEX:
+        case TAG_TITEL:
+        case TAG_REFSTART:
+            {
+				TagRef();
+				Paragraph();
+			}
+			break;
+		case TAG_OS2:
+		case TAG_WIN:
+		case TAG_UNIX:
+		case TAG_MAC: //...
+			{
+				if ( ! bPfCaseActive )
+				{
+                    //PfCases duerfen nicht verschachtelt sein:
+					bPfCaseActive = sal_True;
+					PfCase();
+
+					//So jetzt kann wieder ein PfCase kommen:
+					bPfCaseActive = sal_False;
+					Paragraph();
+				}
+			}
+			break;
+		case TAG_WRITER:
+		case TAG_CALC:
+		case TAG_DRAW:
+		case TAG_IMPRESS:
+		case TAG_SCHEDULE:
+		case TAG_IMAGE:
+		case TAG_MATH:
+		case TAG_CHART:
+		case TAG_OFFICE:
+			{
+				if ( !bAppCaseActive )
+				{
+                    //AppCases duerfen nicht verschachtelt sein:
+					bAppCaseActive = sal_True;
+					AppCase();
+
+                    //jetzt koennen wieder AppCases kommen:
+					bAppCaseActive = sal_False;
+					Paragraph();
+				}
+			}
+			break;
+
+		//Case TAG_BOLDOFF, TAG_ITALICOFF, TAG_BUNDERLINE, TAG_END
+			//nichts tun wg. epsilon-Prod.
+	}
+}
+
+void TokenParser::PfCase()
+{
+
+	//Produktion:
+	//PfCase -> PfCaseBegin Paragraph (PfCase | PfCaseEnd)
+
+	PfCaseBegin();
+
+	//Jetzt ist eine PfCase-Produktion aktiv:
+	Paragraph();
+	switch ( aTag.nId )
+	{
+		case TAG_ELSE:
+		case TAG_END:
+			{
+				CaseEnd();
+			}
+			break;
+		case TAG_OS2:
+		case TAG_WIN:
+		case TAG_UNIX:
+		case TAG_MAC: //First (PfBegin)
+			{
+				PfCase();
+			}
+			break;
+		default:
+			ParseError( 8, "<#ELSE> or <#END> or platform-tag expected.", aTag );
+	}
+    //Die gemerkten Tags wieder loeschen fuer naechstes PfCase:
+	nPfCaseOptions = 0;
+}
+
+void TokenParser::PfCaseBegin()
+{
+	switch ( aTag.nId )
+	{
+		case TAG_OS2:
+		case TAG_WIN:
+		case TAG_UNIX:
+		case TAG_MAC:
+			{
+				//Token darf noch nicht vorgekommen sein im
+				//aktuellen Plattform-Case:
+				if ( !HAS_FLAG( nPfCaseOptions, TAG_NOGROUP( aTag.nId ) ) )
+				{
+					SET_FLAG( nPfCaseOptions, TAG_NOGROUP( aTag.nId ) );
+					match( aTag, aTag );
+				}
+				else {
+					ParseError( 9, "Tag defined twice in the same platform-case", aTag );
+				}
+			}
+	}
+}
+
+void TokenParser::AppCase()
+{
+
+	//Produktion:
+	//AppCase -> AppCaseBegin Paragraph (AppCase | AppCaseEnd)
+
+
+	AppCaseBegin();
+
+	Paragraph();
+
+	switch ( aTag.nId )
+	{
+		case TAG_ELSE:
+		case TAG_END:
+			{
+				CaseEnd();
+			}
+			break;
+		case TAG_WRITER:
+		case TAG_DRAW:
+		case TAG_CALC:
+		case TAG_IMAGE:
+		case TAG_MATH:
+		case TAG_CHART:
+		case TAG_OFFICE:
+		case TAG_IMPRESS:
+		case TAG_SCHEDULE: //First (AppBegin)
+			{
+				AppCase();
+			}
+			break;
+		default:
+			ParseError( 1, "<#ELSE> or <#END> or application-case-tag expected.", aTag );
+		}
+
+    //Die gemerkten Tags wieder loeschen fuer naechstes AppCase:
+	nAppCaseOptions = 0;
+}
+
+void TokenParser::AppCaseBegin()
+{
+	switch ( aTag.nId )
+	{
+		case TAG_WRITER:
+		case TAG_DRAW:
+		case TAG_CALC:
+		case TAG_IMAGE:
+		case TAG_MATH:
+		case TAG_CHART:
+		case TAG_OFFICE:
+		case TAG_IMPRESS:
+		case TAG_SCHEDULE:
+			{
+				//Token darf noch nicht vorgekommen sein im
+				//aktuellen Plattform-Case:
+				if ( !HAS_FLAG( nAppCaseOptions, TAG_NOGROUP( aTag.nId ) ) )
+				{
+					SET_FLAG( nAppCaseOptions, TAG_NOGROUP( aTag.nId ) );
+					match( aTag, aTag );
+				}
+				else {
+					ParseError( 13, "Tag defined twice in the same application-case.", aTag );
+				}
+			}
+	}
+}
+
+void TokenParser::CaseEnd()
+{
+	//Produktion:
+	//CaseEnd -> <#ELSE> Paragraph <#END> | <#END>
+
+	switch ( aTag.nId )
+	{
+		case TAG_ELSE:
+		{
+			match( aTag, TAG_ELSE );
+			Paragraph();
+			match( aTag, TAG_END );
+		}
+		break;
+		case TAG_END:
+		{
+			match( aTag, TAG_END );
+		}
+		break;
+		default:
+			ParseError( 2, "<#ELSE> or <#END> expected.", aTag );
+	}
+}
+
+void TokenParser::SimpleTag()
+{
+
+	switch ( aTag.nId )
+	{
+		case TAG_HELPID:
+			{
+				match( aTag, TAG_HELPID );
+    		}
+			break;
+		case TAG_OFFICEFULLNAME:
+		case TAG_OFFICENAME:
+		case TAG_OFFICEPATH:
+		case TAG_OFFICEVERSION:
+		case TAG_PORTALNAME:
+		case TAG_PORTALFULLNAME:
+		case TAG_PORTALPATH:
+		case TAG_PORTALVERSION:
+		case TAG_PORTALSHORTNAME:
+
+        case TAG_REFINSERT:
+			{
+				match( aTag, aTag );
+    		}
+			break;
+		default:
+			ParseError( 15, "[<#SimpleTag>] expected.", aTag );
+	}
+}
+
+void TokenParser::TagPair()
+{
+	switch ( aTag.nId )
+	{
+		case TAG_BOLDON:
+			{
+				match( aTag, TAG_BOLDON );
+				Paragraph();
+				match( aTag, TAG_BOLDOFF );
+			}
+			break;
+		case TAG_ITALICON:
+			{
+				match( aTag, TAG_ITALICON );
+				Paragraph();
+				match( aTag, TAG_ITALICOFF );
+			}
+			break;
+		case TAG_UNDERLINEON:
+			{
+				match( aTag, TAG_UNDERLINEON );
+				Paragraph();
+				match( aTag, TAG_UNDERLINEOFF );
+			}
+			break;
+		case TAG_COMMONSTART:
+			{
+                //remember tag so we can give the original tag in case of an error
+                TokenInfo aEndTag( aTag );
+                aEndTag.nId = TAG_COMMONEND;
+				match( aTag, TAG_COMMONSTART );
+				Paragraph();
+				match( aTag, aEndTag );
+			}
+			break;
+		default:
+			ParseError( 10, "<#BOLD>, <#ITALIC>, <#UNDER> expected.", aTag );
+	}
+}
+
+
+void TokenParser::TagRef()
+{
+	switch ( aTag.nId )
+	{
+		case TAG_GRAPHIC:
+		case TAG_NEXTVERSION:
+            {
+				if ( !HAS_FLAG( nActiveRefTypes, TAG_NOGROUP( aTag.nId ) ) )
+				{
+					TokenId aThisToken = aTag.nId;
+					SET_FLAG( nActiveRefTypes, TAG_NOGROUP( aThisToken ) );
+					match( aTag, aTag );
+					Paragraph();
+                    if ( aThisToken == TAG_GRAPHIC )
+    					match( aTag, TAG_ENDGRAPHIC );
+                    else
+    					match( aTag, TAG_VERSIONEND );
+                    // don't reset since alowed only once per paragraph
+					// RESET_FLAG( nActiveRefTypes, TAG_NOGROUP( aThisToken ) );
+				}
+				else
+				{
+					ParseError( 11, "Tags <#GRAPHIC>,<#NEXTVERSION> allowed only once per paragraph at", aTag );
+				}
+            }
+			break;
+		case TAG_AVIS:
+		case TAG_AHID:
+			{
+				if ( !HAS_FLAG( nActiveRefTypes, TAG_NOGROUP( aTag.nId ) ) )
+				{
+					TokenId aThisToken = aTag.nId;
+					SET_FLAG( nActiveRefTypes, TAG_NOGROUP( aThisToken ) );
+					match( aTag, aTag );
+					Paragraph();
+					match( aTag, TAG_AEND );
+					RESET_FLAG( nActiveRefTypes, TAG_NOGROUP( aThisToken ) );
+				}
+				else
+				{
+					ParseError( 11, "Nested <#AHID>,<#AVIS> not allowed.", aTag );
+				}
+			}
+			break;
+		case TAG_HREF:
+		case TAG_NAME:
+			{
+
+			}
+			// NOBREAK
+		case TAG_KEY:
+		case TAG_INDEX:
+		case TAG_TITEL:
+        case TAG_REFSTART:
+			{
+				if ( !HAS_FLAG( nActiveRefTypes, TAG_NOGROUP( aTag.nId ) ) )
+				{
+					TokenId aThisToken = aTag.nId;
+					match( aTag, aTag );
+					if ( aThisToken != TAG_NAME )
+					{	// TAG_NAME has no TAG_END
+						SET_FLAG( nActiveRefTypes, TAG_NOGROUP( aThisToken ) );
+						Paragraph();
+						match( aTag, TAG_END );
+						RESET_FLAG( nActiveRefTypes, TAG_NOGROUP( aThisToken ) );
+					}
+				}
+				else
+				{
+					ParseError( 11, "Nested <#HREF>,<#NAME> or <#KEY> not allowed.", aTag );
+				}
+			}
+			break;
+		default:
+			ParseError( 12, "<#HREF>,<#NAME> or <#KEY> expected.", aTag );
+	}
+}
+
+sal_Bool TokenParser::match( const TokenInfo &aCurrentToken, const TokenId &aExpectedToken )
+{
+    return match( aCurrentToken, TokenInfo( aExpectedToken, TOK_INVALIDPOS ) );
+}
+
+sal_Bool TokenParser::match( const TokenInfo &aCurrentToken, const TokenInfo &rExpectedToken )
+{
+    TokenInfo aExpectedToken( rExpectedToken );
+	if ( aCurrentToken.nId == aExpectedToken.nId )
+	{
+        if ( ( aCurrentToken.nId == TAG_COMMONEND
+               && aCurrentToken.GetTagName().Equals( aExpectedToken.GetTagName() ) )
+             || aCurrentToken.nId != TAG_COMMONEND )
+        {
+		    aTag = aParser.GetNextToken( *pErrorList );
+		    return sal_True;
+        }
+	}
+
+    if ( aExpectedToken.nId == TAG_COMMONEND )
+    {
+        aExpectedToken.aTokenString.Insert( String::CreateFromAscii( "Close tag for " ), 0 );
+    }
+
+    ByteString sTmp( "Expected Symbol" );
+    if ( aCurrentToken.nId == TAG_NOMORETAGS )
+    {
+		ParseError( 7, sTmp, aExpectedToken );
+    }
+    else
+    {
+		sTmp += ": ";
+		sTmp += ByteString( aParser.GetLexem( aExpectedToken ), RTL_TEXTENCODING_UTF8 );
+		sTmp += " near ";
+		ParseError( 7, sTmp, aCurrentToken );
+    }
+	return sal_False;
+}
+
+void TokenParser::ParseError( sal_uInt16 nErrNr, ByteString aErrMsg, const TokenInfo &rTag )
+{
+	pErrorList->AddError( nErrNr, aErrMsg, rTag);
+
+    // Das Fehlerhafte Tag ueberspringen
+	aTag = aParser.GetNextToken( *pErrorList );
+}
+
+
+ParserMessage::ParserMessage( sal_uInt16 PnErrorNr, ByteString PaErrorText, const TokenInfo &rTag )
+		: nErrorNr( PnErrorNr )
+		, aErrorText( PaErrorText )
+		, nTagBegin( 0 )
+		, nTagLength( 0 )
+{
+    String aLexem( SimpleParser::GetLexem( rTag ) );
+    aErrorText.Append(": ");
+	aErrorText += ByteString( aLexem, RTL_TEXTENCODING_UTF8 );
+    if ( rTag.nId == TAG_NOMORETAGS )
+        aErrorText.Append(" at end of line ");
+    else if ( rTag.nPos != TOK_INVALIDPOS )
+    {
+        aErrorText.Append(" at Position ");
+        aErrorText.Append( ByteString::CreateFromInt32( rTag.nPos ) );
+    }
+    nTagBegin = rTag.nPos;
+	nTagLength = aLexem.Len();
+}
+
+ParserError::ParserError( sal_uInt16 ErrorNr, ByteString ErrorText, const TokenInfo &rTag )
+: ParserMessage( ErrorNr, ErrorText, rTag )
+{}
+
+ParserWarning::ParserWarning( sal_uInt16 ErrorNr, ByteString ErrorText, const TokenInfo &rTag )
+: ParserMessage( ErrorNr, ErrorText, rTag )
+{}
+
+sal_Bool LingTest::IsTagMandatory( TokenInfo const &aToken, TokenId &aMetaTokens )
+{
+	TokenId aTokenId = aToken.nId;
+	TokenId aTokenGroup = TAG_GROUP( aTokenId );
+	if ( TAG_GROUP_PROGSWITCH == aTokenGroup
+		|| TAG_REFINSERT == aTokenId
+		|| TAG_REFSTART == aTokenId
+		|| TAG_NAME == aTokenId
+		|| TAG_HREF == aTokenId
+		|| TAG_AVIS == aTokenId
+		|| TAG_AHID == aTokenId
+		|| TAG_GRAPHIC == aTokenId
+		|| TAG_NEXTVERSION == aTokenId
+        || ( TAG_GROUP_META == aTokenGroup && (aMetaTokens & aTokenId) == aTokenId ) )
+    {
+        if ( TAG_GROUP_META == aTokenGroup )
+            aMetaTokens |= aTokenId;
+        return sal_True;
+    }
+    else if (   TAG_COMMONSTART == aTokenId
+		     || TAG_COMMONEND == aTokenId )
+    {
+        String aTagName = aToken.GetTagName();
+        return !(aTagName.EqualsIgnoreCaseAscii( "comment" )
+              || aTagName.EqualsIgnoreCaseAscii( "bookmark_value" )
+              || aTagName.EqualsIgnoreCaseAscii( "emph" )
+              || aTagName.EqualsIgnoreCaseAscii( "item" )
+              || aTagName.EqualsIgnoreCaseAscii( "br" ) );
+    }
+    return sal_False;
+}
+
+void LingTest::CheckTags( TokenList &aReference, TokenList &aTestee, sal_Bool bFixTags )
+{
+	sal_uLong i=0,j=0;
+	// Clean old Warnings
+	while ( aCompareWarningList.Count() )
+	{
+		delete aCompareWarningList.GetCurObject();
+		aCompareWarningList.Remove();
+	}
+
+    /* in xml tags, do not require the following tags
+        comment
+        bookmark_value
+        emph
+        item
+        br
+    */
+
+    // filter uninteresting Tags
+    TokenId aMetaTokens = 0;
+	for ( i=0 ; i < aReference.Count() ; i++ )
+	{
+		if ( !IsTagMandatory( aReference.GetObject( i ), aMetaTokens ) )
+			aReference.GetObject( i ).SetDone();
+	}
+
+    aMetaTokens = 0;
+	for ( i=0 ; i < aTestee.Count() ; i++ )
+	{
+		if ( !IsTagMandatory( aTestee.GetObject( i ), aMetaTokens ) )
+			aTestee.GetObject( i ).SetDone();
+	}
+
+    // remove all matching tags
+	for ( i=0 ; i < aReference.Count() ; i++ )
+    {
+        if ( aReference.GetObject( i ).IsDone() )
+            continue;
+
+    	sal_Bool bTagFound = sal_False;
+    	for ( j=0 ; j < aTestee.Count() && !bTagFound ; j++ )
+        {
+            if ( aTestee.GetObject( j ).IsDone() )
+                continue;
+
+		    if ( aReference.GetObject( i ).MatchesTranslation( aTestee.GetObject( j ), sal_False, aCompareWarningList ) )
+            {
+			    aReference.GetObject( i ).SetDone();
+			    aTestee.GetObject( j ).SetDone();
+                bTagFound = sal_True;
+            }
+        }
+    }
+
+    sal_Bool bCanFix = sal_True;
+
+    if ( bFixTags )
+    {
+        // we fix only if its a really simple case
+        sal_uInt16 nTagCount = 0;
+	    for ( i=0 ; i < aReference.Count() ; i++ )
+            if ( !aReference.GetObject( i ).IsDone() )
+                nTagCount++;
+        if ( nTagCount > 1 )
+            bCanFix = sal_False;
+
+        nTagCount = 0;
+	    for ( i=0 ; i < aTestee.Count() ; i++ )
+            if ( !aTestee.GetObject( i ).IsDone() )
+                nTagCount++;
+        if ( nTagCount > 1 )
+            bCanFix = sal_False;
+    }
+
+    // generate errors for tags that have differing attributes
+	for ( i=0 ; i < aReference.Count() ; i++ )
+    {
+        if ( aReference.GetObject( i ).IsDone() )
+            continue;
+
+    	sal_Bool bTagFound = sal_False;
+    	for ( j=0 ; j < aTestee.Count() && !bTagFound ; j++ )
+        {
+            if ( aTestee.GetObject( j ).IsDone() )
+                continue;
+
+		    if ( aReference.GetObject( i ).MatchesTranslation( aTestee.GetObject( j ), sal_True, aCompareWarningList, bCanFix && bFixTags ) )
+            {
+			    aReference.GetObject( i ).SetDone();
+			    aTestee.GetObject( j ).SetDone();
+                bTagFound = sal_True;
+            }
+        }
+    }
+
+    // list remaining tags as errors
+	for ( i=0 ; i < aReference.Count() ; i++ )
+    {
+        if ( aReference.GetObject( i ).IsDone() )
+            continue;
+
+        aCompareWarningList.AddError( 20, "Missing Tag in Translation", aReference.GetObject( i ) );
+    }
+	for ( i=0 ; i < aTestee.Count() ; i++ )
+    {
+        if ( aTestee.GetObject( i ).IsDone() )
+            continue;
+
+		aCompareWarningList.AddError( 21, "Extra Tag in Translation", aTestee.GetObject( i ) );
+    }
+
+	for ( i=0 ; i < aReference.Count() ; i++ )
+        aReference.GetObject( i ).SetDone( sal_False );
+
+	for ( i=0 ; i < aTestee.Count() ; i++ )
+        aTestee.GetObject( i ).SetDone( sal_False );
+}
+
+void LingTest::CheckReference( GSILine *aReference )
+{
+	aReferenceParser.Parse( aReference->GetUText(), aReference->GetMessageList() );
+}
+
+void LingTest::CheckTestee( GSILine *aTestee, sal_Bool bHasSourceLine, sal_Bool bFixTags )
+{
+    aFixedTestee = aTestee->GetUText();
+	aTesteeParser.Parse( aFixedTestee, aTestee->GetMessageList() );
+
+    if ( bHasSourceLine )
+	    CheckTags( aReferenceParser.GetTokenList(), aTesteeParser.GetTokenList(), bFixTags );
+
+    if ( bFixTags )
+    {
+        TokenList& aTesteeTokens = aTesteeParser.GetTokenList();
+        sal_Bool bFixesDone = sal_False;
+        // count backwards to allow replacing from right to left
+        int i;
+	    for ( i=aTesteeTokens.Count()-1 ; i>=0 ; i-- )
+        {
+            if ( aTesteeTokens.GetObject( i ).HasBeenFixed() )
+            {
+                bFixesDone = sal_True;
+                aFixedTestee.Replace( aTesteeTokens.GetObject( i ).nPos, aTesteeTokens.GetObject( i ).aTokenString.Len(), aTesteeTokens.GetObject( i ).MakeTag() );
+            }
+        }
+        if ( bFixesDone )
+        {
+            aTestee->SetUText( aFixedTestee );
+            aTestee->SetFixed();
+        }
+    }
+}
+

Propchange: openoffice/branches/l10n/main/l10ntools/source/tagtest.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n/main/l10ntools/source/treeconfig.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/treeconfig.cxx?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/treeconfig.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/treeconfig.cxx Thu Jan 24 12:21:38 2013
@@ -0,0 +1,149 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#include <vector>
+#include <string>
+#include <iostream>
+#include "treeconfig.hxx"
+#include "export.hxx"
+#ifdef WNT
+#include <direct.h>
+#include <io.h>
+#else
+#include <dirent.h>
+#endif
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+using namespace std;
+
+namespace transex3
+{
+
+bool Treeconfig::parseConfig(){
+    
+    string source_config_file = string( static_cast<ByteString>( Export::GetEnv("SOURCE_ROOT_DIR") ).GetBuffer() );
+    if( source_config_file.empty() )
+    {
+        cerr << "Error: no suitable environment set?!?";
+        exit( -1 );
+    }
+    source_config_file += string("/source_config");
+    if( isConfigFilePresent() )
+    {
+        inireader.read( map , source_config_file );
+        return true;
+    }
+    else return false;
+}
+
+// ALWAYS add all repositories from source_config file to the container active_repos
+// if a config_file is present ALWAYS return false
+// if you are in the root of a repository also add it to the container active_repos
+// if you are far inside a repository /my/path/ooo/sw/source then don't add it to the container but return true
+// if you are in some misc place like /tmp then return true
+// => the application can decide what to do in case the function returns true thus how to handle pwd() path
+bool Treeconfig::getActiveRepositories( vector<string>& active_repos ){
+    
+    bool isPresent = isConfigFilePresent();
+    bool hasPath   = false;
+    string pwd;
+    string guessedRepo;
+    Export::getCurrentDir( pwd );
+    string source_root = Export::GetEnv( "SOURCE_ROOT_DIR" );
+    string solarsrc    = Export::GetEnv( "SOLARSRC" );
+    string partial;
+
+    // if we are inside of a repository root then active it otherwise let the app handle the return!
+    string::size_type pos = pwd.find_first_of( source_root );
+    if( pos != string::npos && ( pos + source_root.length() +1 ) < pwd.length()){  // I am within SOURCE_ROOT_DIR
+        partial = pwd.substr( pos + source_root.length() +1  , pwd.length());
+        string::size_type nextPart = partial.find_first_of( "/" );
+        if( nextPart != string::npos )
+            hasPath = true;
+        else
+            guessedRepo = partial;
+    }
+    else                              // I am NOT within SOURCE_ROOT_DIR
+        hasPath = true;
+    
+    if( isPresent )
+    {
+        hasPath = false;                // if config_file is present don't care about pwd
+        stringmap* repos = static_cast<stringmap*>( map[ string("repositories") ] );
+        if( repos != 0 )
+        {
+            for( stringmap::iterator iter = repos->begin() ; iter != repos->end() ; ++iter )
+            {
+                if( static_cast<string>( iter->second ) == string( "active" ) )
+                {
+                    active_repos.push_back( iter->first );
+                    if( static_cast<string>( iter->first ) == guessedRepo )
+                    {
+                        guessedRepo.clear();            // don't add double in case it is present in config_file
+                    }
+                }
+            }
+        }
+        else
+        {
+            cerr << "Error: source_config files doesn't contain a 'repositories' section ?!?";
+            exit( -1 );
+        }
+    }
+    if( !guessedRepo.empty() ){
+        active_repos.push_back( guessedRepo );          // add myrepo
+    }
+    return hasPath;                                     // are we deep inside of a source tree or outside of SOURCE_ROOT_DIR?
+}
+
+void Treeconfig::getCurrentDir( string& dir )
+{
+    char buffer[64000];
+    if( getcwd( buffer , sizeof( buffer ) ) == 0 ){
+        cerr << "Error: getcwd failed!\n";
+        exit( -1 );
+    }
+    dir = string( buffer );
+}
+
+bool Treeconfig::isConfigFilePresent()
+{
+    string config_file = Export::GetEnv( "SOURCE_ROOT_DIR" );
+    config_file += "/source_config";
+    
+    struct stat status;
+    if( stat( config_file.c_str() , &status ) < 0 )
+    {
+        return false; 
+    }
+#ifdef WNT
+    return ( status.st_mode & _S_IFREG ) && ( _access( config_file.c_str() , 4 ) >= 0 ) ;
+#else
+    return ( status.st_mode & S_IFREG ) && ( access( config_file.c_str() , R_OK ) >= 0 ) ;
+#endif
+}
+
+
+
+}

Propchange: openoffice/branches/l10n/main/l10ntools/source/treeconfig.cxx
------------------------------------------------------------------------------
    svn:executable = *

Added: openoffice/branches/l10n/main/l10ntools/source/utf8conv.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/utf8conv.cxx?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/utf8conv.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/utf8conv.cxx Thu Jan 24 12:21:38 2013
@@ -0,0 +1,70 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_l10ntools.hxx"
+#include "utf8conv.hxx"
+
+//
+// class UTF8Converter
+//
+
+#define MAX_CONV_BUFFER_SIZE	0xFF00
+
+#define TO_CVTFLAGS		(RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |\
+			 			 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |\
+			 			 RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT)
+
+#define FROM_CVTFLAGS  	(RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |\
+			 		   	 RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |\
+					   	 RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |\
+					   	 RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0)
+
+/*****************************************************************************/
+void UTF8Converter::Convert( ByteString &rBuffer,
+	rtl_TextEncoding nSourceENC, rtl_TextEncoding nDestENC )
+/*****************************************************************************/
+{
+	String sTemp( rBuffer, nSourceENC );
+	rBuffer = ByteString( sTemp, nDestENC );
+}
+
+/*****************************************************************************/
+ByteString UTF8Converter::ConvertToUTF8(
+	const ByteString &rASCII, rtl_TextEncoding nEncoding )
+/*****************************************************************************/
+{
+	ByteString sReturn( rASCII );
+	Convert( sReturn, nEncoding, RTL_TEXTENCODING_UTF8 );
+	return sReturn;
+}
+
+/*****************************************************************************/
+ByteString UTF8Converter::ConvertFromUTF8(
+	const ByteString &rUTF8, rtl_TextEncoding nEncoding )
+/*****************************************************************************/
+{
+	ByteString sReturn( rUTF8 );
+	Convert( sReturn, RTL_TEXTENCODING_UTF8, nEncoding );
+	return sReturn;
+}

Propchange: openoffice/branches/l10n/main/l10ntools/source/utf8conv.cxx
------------------------------------------------------------------------------
    svn:executable = *