Author: jani
Date: Thu Jan 24 12:21:38 2013
New Revision: 1437973

URL: http://svn.apache.org/viewvc?rev=1437973&view=rev
Log:
allowed old code to coexist for a while (needs to update makefiles)

Added:
    openoffice/branches/l10n/main/l10ntools/source/cfg_yy_wrapper.c   (with 
props)
    openoffice/branches/l10n/main/l10ntools/source/cfglex.l   (with props)
    openoffice/branches/l10n/main/l10ntools/source/cfgmerge.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/directory.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/export.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/export2.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/file.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/filter/
    openoffice/branches/l10n/main/l10ntools/source/filter/merge/
    openoffice/branches/l10n/main/l10ntools/source/filter/merge/FCFGMerge.cfg   
(with props)
    openoffice/branches/l10n/main/l10ntools/source/filter/merge/FCFGMerge.java  
 (with props)
    openoffice/branches/l10n/main/l10ntools/source/filter/merge/Manifest.mf   
(with props)
    openoffice/branches/l10n/main/l10ntools/source/filter/merge/Merger.java   
(with props)
    openoffice/branches/l10n/main/l10ntools/source/filter/merge/makefile.mk   
(with props)
    openoffice/branches/l10n/main/l10ntools/source/filter/utils/
    
openoffice/branches/l10n/main/l10ntools/source/filter/utils/AnalyzeStartupLog.java
   (with props)
    openoffice/branches/l10n/main/l10ntools/source/filter/utils/Cache.java   
(with props)
    
openoffice/branches/l10n/main/l10ntools/source/filter/utils/ConfigHelper.java   
(with props)
    openoffice/branches/l10n/main/l10ntools/source/filter/utils/FileHelper.java 
  (with props)
    openoffice/branches/l10n/main/l10ntools/source/filter/utils/Logger.java   
(with props)
    
openoffice/branches/l10n/main/l10ntools/source/filter/utils/MalformedCommandLineException.java
   (with props)
    openoffice/branches/l10n/main/l10ntools/source/filter/utils/XMLHelper.java  
 (with props)
    openoffice/branches/l10n/main/l10ntools/source/filter/utils/makefile.mk   
(with props)
    openoffice/branches/l10n/main/l10ntools/source/gsicheck.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/gsiconv.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/help/
    openoffice/branches/l10n/main/l10ntools/source/help/HelpCompiler.cxx   
(with props)
    openoffice/branches/l10n/main/l10ntools/source/help/HelpCompiler.hxx   
(with props)
    openoffice/branches/l10n/main/l10ntools/source/help/HelpFileDocument.java   
(with props)
    openoffice/branches/l10n/main/l10ntools/source/help/HelpIndexerTool.java   
(with props)
    openoffice/branches/l10n/main/l10ntools/source/help/HelpLinker.cxx   (with 
props)
    openoffice/branches/l10n/main/l10ntools/source/help/compilehelp.hxx   (with 
props)
    openoffice/branches/l10n/main/l10ntools/source/help/helplinker.pmk   (with 
props)
    openoffice/branches/l10n/main/l10ntools/source/help/makefile.mk   (with 
props)
    openoffice/branches/l10n/main/l10ntools/source/helpex.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/helpmerge.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/inireader.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/lngex.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/lngmerge.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/localize.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/merge.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/src_yy_wrapper.c   (with 
props)
    openoffice/branches/l10n/main/l10ntools/source/srciter.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/srclex.l   (with props)
    openoffice/branches/l10n/main/l10ntools/source/tagtest.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/treeconfig.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/utf8conv.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/wtranode.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/wtratree.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/xgfconv.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/xmlparse.cxx   (with props)
    openoffice/branches/l10n/main/l10ntools/source/xrm_yy_wrapper.c   (with 
props)
    openoffice/branches/l10n/main/l10ntools/source/xrmlex.l   (with props)
    openoffice/branches/l10n/main/l10ntools/source/xrmmerge.cxx   (with props)
Modified:
    openoffice/branches/l10n/main/l10ntools/source/makefile.mk

Added: openoffice/branches/l10n/main/l10ntools/source/cfg_yy_wrapper.c
URL: 
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/cfg_yy_wrapper.c?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/cfg_yy_wrapper.c (added)
+++ openoffice/branches/l10n/main/l10ntools/source/cfg_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 "cfg_yy.c"

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

Added: openoffice/branches/l10n/main/l10ntools/source/cfglex.l
URL: 
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/cfglex.l?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/cfglex.l (added)
+++ openoffice/branches/l10n/main/l10ntools/source/cfglex.l Thu Jan 24 12:21:38 
2013
@@ -0,0 +1,237 @@
+%{
+/**************************************************************
+ * 
+ * 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 cfg source files
+ *
+ */
+
+
+/* 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 InitCfgExport( char * , char *);
+extern int EndCfgExport();
+extern int GetError();
+extern int SetError();
+extern char *GetOutputFile( int argc, char* argv[]);
+extern FILE *GetCfgFile();
+extern int isQuiet();
+extern void removeTempFile();
+extern char* getFilename();
+/* forwards */
+void YYWarning();
+
+int bText=0;
+%}
+
+%p 24000
+%e 1200
+%n 500
+
+%%
+
+\<[^\>]*"xml:lang="\""x-no-translate"\"[^\<]*\/\>      {
+       bText = 0;
+       WorkOnTokenSet( CFG_TOKEN_NO_TRANSLATE, yytext );
+}
+
+\<.*\/\> {
+       bText = 0;
+       WorkOnTokenSet( ANYTOKEN, yytext );
+}
+
+\<[^\>]*"xml:lang="\".*\"[^\<]*\>      {
+       bText = 1;
+       WorkOnTokenSet( CFG_TEXT_START, yytext );
+}
+
+
+\<[^\/\!][^\>]*\>      {
+       bText = 0;
+       WorkOnTokenSet( CFG_TAG, yytext );
+}
+
+"<!"DOCTYPE[^\>]*\>    {
+       bText = 0;
+       WorkOnTokenSet( CFG_TAG, yytext );
+}
+
+
+\<\!\-\-       {
+       char c1 = 0, c2 = 0, c3 = input();
+       char pChar[2];
+       pChar[1] = 0x00;
+       pChar[0] = c3;
+
+       WorkOnTokenSet( COMMEND, yytext );
+       WorkOnTokenSet( COMMEND, pChar );
+
+       for(;;) {
+               if ( c3 == EOF )
+                       break;
+               if ( c1 == '-' && c2 == '-' && c3 == '>' )
+                       break;
+               c1 = c2;
+               c2 = c3;
+               c3 = input();
+               pChar[0] = c3;
+               WorkOnTokenSet( COMMEND, pChar );
+       }
+}
+
+\<\/[^\>]*\> {
+       bText = 0;
+       WorkOnTokenSet( CFG_CLOSETAG, yytext );
+}
+
+\<[^\>\!]*\> {
+       bText = 0;
+       if ( yytext[ 1 ] == '!' && yytext[ 2 ] == '-' && yytext[ 3 ] == '-' )
+               WorkOnTokenSet( COMMEND, yytext );
+       else
+               WorkOnTokenSet( CFG_UNKNOWNTAG, yytext );
+}
+
+.|\n {
+       if ( bText == 1 )
+               WorkOnTokenSet( CFG_TEXTCHAR, yytext );
+       else
+               WorkOnTokenSet( UNKNOWNCHAR, yytext );
+}
+
+
+%%
+
+/*****************************************************************************/
+int    yywrap(void)
+/*****************************************************************************/
+{
+       return 1;
+}
+
+/*****************************************************************************/
+void YYWarning( char *s )
+/*****************************************************************************/
+{
+       /* write warning to stderr */
+       fprintf( stderr,
+               "Warning: \"%s\" in line %d: \"%s\"\n", s, yylineno, yytext  );
+}
+
+/*****************************************************************************/
+#ifdef GCC
+void yyerror ( char *s, ... )
+#else
+void yyerror ( char *s )
+#endif
+/*****************************************************************************/
+{
+       /* 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: CFGEX[-p Prj][-r PrjRoot]-i FileIn 
[-o FileOut][-m DataBase][-e][-b][-u][-f][-d DoneFile][-g[:dtd] ][-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, " -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, " -f: force extraction and merge even if only 
one language is existent\n" );
+               fprintf( stdout, " -g[:dtd]: enables generation of properties 
(dtds if :dtd is set) - in this case FileOut is the output path\n" );
+               fprintf( stdout, " -d: enables generation of *.don if work is 
done\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;
+       }
+
+       pFile = GetCfgFile();
+       InitCfgExport( pOutput , getFilename() );
+       if ( !pFile )
+               return 1;
+
+       yyin = pFile;
+
+       /* create global instance of class CfgExport */
+       //InitCfgExport( pOutput );
+
+       /* start parser */
+       yylex();
+
+       /* get error info. and end export */
+       nRetValue = GetError();
+       EndCfgExport();
+
+    
+    removeTempFile();
+/* return error level */
+       return nRetValue;
+}
+
+

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

Added: openoffice/branches/l10n/main/l10ntools/source/cfgmerge.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/cfgmerge.cxx?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/cfgmerge.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/cfgmerge.cxx Thu Jan 24 
12:21:38 2013
@@ -0,0 +1,868 @@
+/**************************************************************
+ * 
+ * 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/string.hxx>
+#include <tools/fsys.hxx>
+
+// local includes
+#include "export.hxx"
+#include "cfgmerge.hxx"
+#include "tokens.h"
+#include "utf8conv.hxx"
+
+extern "C" { int yyerror( char * ); }
+extern "C" { int YYWarning( char * ); }
+
+// defines to parse command line
+#define STATE_NON              0x0001
+#define STATE_INPUT            0x0002
+#define STATE_OUTPUT   0x0003
+#define STATE_PRJ              0x0004
+#define STATE_ROOT             0x0005
+#define STATE_MERGESRC 0x0006
+#define STATE_ERRORLOG 0x0007
+#define STATE_UTF8             0x0008
+#define STATE_LANGUAGES        0X0009
+#define STATE_ISOCODE99        0x000A
+#define STATE_FORCE            0x000B
+
+// set of global variables
+sal_Bool bEnableExport;
+sal_Bool bMergeMode;
+sal_Bool bErrorLog;
+sal_Bool bForce;
+sal_Bool bUTF8;
+ByteString sPrj;
+ByteString sPrjRoot;
+ByteString sInputFileName;
+ByteString sActFileName;
+ByteString sFullEntry;
+ByteString sOutputFile;
+ByteString sMergeSrc;
+String sUsedTempFile;
+
+CfgParser *pParser;
+
+extern "C" {
+// the whole interface to lexer is in this extern "C" section
+
+/*****************************************************************************/
+extern char *GetOutputFile( int argc, char* argv[])
+/*****************************************************************************/
+{
+       bEnableExport   = sal_False;
+       bMergeMode      = sal_False;
+       bErrorLog       = sal_True;
+       bForce          = sal_False;
+       bUTF8           = sal_True;
+    sPrj            = "";
+       sPrjRoot        = "";
+       sInputFileName  = "";
+       sActFileName    = "";
+
+       sal_uInt16 nState = STATE_NON;
+       sal_Bool bInput = sal_False;
+
+       // parse command line
+       for( int i = 1; i < argc; i++ ) {
+        ByteString sSwitch( argv[ i ] );
+        sSwitch.ToUpperAscii();
+        
+        if ( sSwitch == "-I" ) {
+                       nState = STATE_INPUT; // next token specifies source 
file
+               }
+               else if ( sSwitch == "-O" ) {
+                       nState = STATE_OUTPUT; // next token specifies the dest 
file
+               }
+               else if ( sSwitch == "-P" ) {
+                       nState = STATE_PRJ; // next token specifies the cur. 
project
+               }
+               else if ( sSwitch == "-R" ) {
+                       nState = STATE_ROOT; // next token specifies path to 
project root
+               }
+               else if ( sSwitch == "-M" ) {
+                       nState = STATE_MERGESRC; // next token specifies the 
merge database
+               }
+               else if ( sSwitch == "-E" ) {
+                       nState = STATE_ERRORLOG;
+                       bErrorLog = sal_False;
+               }
+               else if ( sSwitch == "-UTF8" ) {
+                       nState = STATE_UTF8;
+                       bUTF8 = sal_True;
+               }
+               else if ( sSwitch == "-NOUTF8" ) {
+                       nState = STATE_UTF8;
+                       bUTF8 = sal_False;
+               }
+               else if ( sSwitch == "-F" ) {
+                       nState = STATE_FORCE;
+                       bForce = sal_True;
+               }
+        else if ( sSwitch == "-L" ) {
+                       nState = STATE_LANGUAGES;
+               }
+               else if ( sSwitch.ToUpperAscii() == "-ISO99" ) {
+                       nState = STATE_ISOCODE99;
+               }
+               else {
+                       switch ( nState ) {
+                               case STATE_NON: {
+                                       return NULL;    // no valid command line
+                               }
+                               case STATE_INPUT: {
+                                       sInputFileName = argv[ i ];
+                                       bInput = sal_True; // source file found
+                               }
+                               break;
+                               case STATE_OUTPUT: {
+                                       sOutputFile = argv[ i ]; // the dest. 
file
+                               }
+                               break;
+                               case STATE_PRJ: {
+                                       sPrj = ByteString( argv[ i ]);
+//                                     sPrj.ToLowerAscii(); // the project
+                               }
+                               break;
+                               case STATE_ROOT: {
+                                       sPrjRoot = ByteString( argv[ i ]); // 
path to project root
+                               }
+                               break;
+                               case STATE_MERGESRC: {
+                                       sMergeSrc = ByteString( argv[ i ]);
+                                       bMergeMode = sal_True; // activate 
merge mode, cause merge database found
+                               }
+                               break;
+                               case STATE_LANGUAGES: {
+                                       Export::sLanguages = ByteString( argv[ 
i ]);
+                               }
+                               break;
+                       }
+               }
+       }
+
+       if ( bInput ) {
+               // command line is valid
+               bEnableExport = sal_True;
+               char *pReturn = new char[ sOutputFile.Len() + 1 ];
+               strcpy( pReturn, sOutputFile.GetBuffer());  // #100211# - 
checked
+               return pReturn;
+       }
+
+       // command line is not valid
+       return NULL;
+}
+/*****************************************************************************/
+int InitCfgExport( char *pOutput , char* pFilename )
+/*****************************************************************************/
+{
+       // instanciate Export
+       ByteString sOutput( pOutput );
+       ByteString sFilename( pFilename );
+    Export::InitLanguages();
+
+       if ( bMergeMode )
+               pParser = new CfgMerge( sMergeSrc, sOutputFile, sFilename );
+       else if ( sOutputFile.Len()) 
+               pParser = new CfgExport( sOutputFile, sPrj, sActFileName );
+       
+       return 1;
+}
+
+/*****************************************************************************/
+int EndCfgExport()
+/*****************************************************************************/
+{
+       delete pParser;
+
+       return 1;
+}
+
+void removeTempFile(){
+    if( !sUsedTempFile.EqualsIgnoreCaseAscii( "" ) ){
+        DirEntry aTempFile( sUsedTempFile );
+        aTempFile.Kill();
+    }
+}
+extern const char* getFilename()
+{
+       return sInputFileName.GetBuffer(); 
+}
+/*****************************************************************************/
+extern FILE *GetCfgFile()
+/*****************************************************************************/
+{
+       FILE *pFile = 0;
+    // look for valid filename
+       if ( sInputFileName.Len()) {
+        if( Export::fileHasUTF8ByteOrderMarker( sInputFileName ) ){
+            DirEntry aTempFile = Export::GetTempFile();
+            DirEntry aSourceFile( String( sInputFileName , 
RTL_TEXTENCODING_ASCII_US ) );
+            aSourceFile.CopyTo( aTempFile , FSYS_ACTION_COPYFILE );
+            String sTempFile = aTempFile.GetFull();
+            Export::RemoveUTF8ByteOrderMarkerFromFile( ByteString( sTempFile , 
RTL_TEXTENCODING_ASCII_US ) );
+            pFile = fopen( ByteString( sTempFile , RTL_TEXTENCODING_ASCII_US 
).GetBuffer(), "r" );
+            sUsedTempFile = sTempFile;
+        }else{
+            // able to open file?
+            pFile = fopen( sInputFileName.GetBuffer(), "r" );
+            sUsedTempFile = String::CreateFromAscii("");
+        }
+               if ( !pFile ){
+                       fprintf( stderr, "Error: Could not open file %s\n",
+                               sInputFileName.GetBuffer());
+            exit( -13 );
+        }
+               else {
+                       // this is a valid file which can be opened, so
+                       // create path to project root
+                       DirEntry aEntry( String( sInputFileName, 
RTL_TEXTENCODING_ASCII_US ));
+                       aEntry.ToAbs();
+                       sFullEntry= ByteString( aEntry.GetFull(), 
RTL_TEXTENCODING_ASCII_US );
+                       aEntry += DirEntry( String( "..", 
RTL_TEXTENCODING_ASCII_US ));
+                       aEntry += DirEntry( sPrjRoot );
+                       ByteString sPrjEntry( aEntry.GetFull(), 
RTL_TEXTENCODING_ASCII_US );
+
+                       // create file name, beginnig with project root
+                       // (e.g.: source\ui\src\menue.src)
+//                     printf("sFullEntry = %s\n",sFullEntry.GetBuffer());
+            sActFileName = sFullEntry.Copy( sPrjEntry.Len() + 1 );
+//            printf("sActFileName = %s\n",sActFileName.GetBuffer());    
+
+                       sActFileName.SearchAndReplaceAll( "/", "\\" );
+
+                       return pFile;
+               }
+       }
+       // this means the file could not be opened
+       return NULL;
+}
+
+/*****************************************************************************/
+int WorkOnTokenSet( int nTyp, char *pTokenText )
+/*****************************************************************************/
+{
+       pParser->Execute( nTyp, pTokenText );
+
+       return 1;
+}
+
+
+/*****************************************************************************/
+int SetError()
+/*****************************************************************************/
+{
+       return 1;
+}
+
+/*****************************************************************************/
+int GetError()
+/*****************************************************************************/
+{
+       return 0;
+}
+}
+
+//
+// class CfgStackData
+//
+
+CfgStackData* CfgStack::Push( const ByteString &rTag, const ByteString &rId )
+{ 
+    CfgStackData *pD = new CfgStackData( rTag, rId ); 
+    Insert( pD, LIST_APPEND ); 
+    return pD; 
+}
+            
+//
+// class CfgStack
+//
+
+/*****************************************************************************/
+CfgStack::~CfgStack()
+/*****************************************************************************/
+{
+       for ( sal_uLong i = 0; i < Count(); i++ )
+               delete GetObject( i );
+}
+
+/*****************************************************************************/
+ByteString CfgStack::GetAccessPath( sal_uLong nPos )
+/*****************************************************************************/
+{
+       if ( nPos == LIST_APPEND )
+               nPos = Count() - 1;
+
+       ByteString sReturn;
+       for ( sal_uLong i = 0; i <= nPos; i++ ) {
+               if ( i )
+                       sReturn += ".";
+               sReturn += GetStackData( i )->GetIdentifier();
+       }
+
+       return sReturn;
+}
+
+/*****************************************************************************/
+CfgStackData *CfgStack::GetStackData( sal_uLong nPos )
+/*****************************************************************************/
+{
+       if ( nPos == LIST_APPEND )
+               nPos = Count() - 1;
+
+       return GetObject( nPos );
+}
+
+//
+// class CfgParser
+//
+
+/*****************************************************************************/
+CfgParser::CfgParser()
+/*****************************************************************************/
+                               : pStackData( NULL ),
+                               bLocalize( sal_False )
+{
+}
+
+/*****************************************************************************/
+CfgParser::~CfgParser()
+/*****************************************************************************/
+{
+}
+
+
+/*****************************************************************************/
+sal_Bool CfgParser::IsTokenClosed( const ByteString &rToken )
+/*****************************************************************************/
+{
+       return rToken.GetChar( rToken.Len() - 2 ) == '/';
+}
+
+/*****************************************************************************/
+void CfgParser::AddText(
+       ByteString &rText,
+       const ByteString &rIsoLang,
+       const ByteString &rResTyp
+)
+/*****************************************************************************/
+{
+               sal_uInt16 nTextLen = 0;
+               while ( rText.Len() != nTextLen ) {
+                       nTextLen = rText.Len();
+                       rText.SearchAndReplaceAll( "\n", " " );
+                       rText.SearchAndReplaceAll( "\r", " " );
+                       rText.SearchAndReplaceAll( "\t", " " );
+                       rText.SearchAndReplaceAll( "  ", " " );
+               }
+               pStackData->sResTyp = rResTyp;
+        WorkOnText( rText, rIsoLang );
+
+        pStackData->sText[ rIsoLang ] = rText;
+}
+
+
+/*****************************************************************************/
+void CfgParser::WorkOnRessourceEnd()
+/*****************************************************************************/
+{
+}
+
+/*****************************************************************************/
+int CfgParser::ExecuteAnalyzedToken( int nToken, char *pToken )
+/*****************************************************************************/
+{
+       ByteString sToken( pToken );
+
+       if ( sToken == " " || sToken == "\t" )
+               sLastWhitespace += sToken;
+
+       ByteString sTokenName;
+       ByteString sTokenId;
+
+       sal_Bool bOutput = sal_True;
+
+       switch ( nToken ) {
+               case CFG_TOKEN_PACKAGE:
+               case CFG_TOKEN_COMPONENT:
+               case CFG_TOKEN_TEMPLATE:
+               case CFG_TOKEN_CONFIGNAME:
+               case CFG_TOKEN_OORNAME:
+               case CFG_TOKEN_OORVALUE:
+               case CFG_TAG:
+               case ANYTOKEN:
+               case CFG_TEXT_START:
+               {
+                       sTokenName = sToken.GetToken( 1, '<' ).GetToken( 0, '>' 
).GetToken( 0, ' ' );
+
+                       if ( !IsTokenClosed( sToken )) {
+                               ByteString sSearch;
+                               switch ( nToken ) {
+                                       case CFG_TOKEN_PACKAGE:
+                                               sSearch = "package-id=";
+                                       break;
+                                       case CFG_TOKEN_COMPONENT:
+                                               sSearch = "component-id=";
+                                       break;
+                                       case CFG_TOKEN_TEMPLATE:
+                                               sSearch = "template-id=";
+                                       break;
+                                       case CFG_TOKEN_CONFIGNAME:
+                                               sSearch = "cfg:name=";
+                                       break;
+                                       case CFG_TOKEN_OORNAME:
+                                               sSearch = "oor:name=";
+                                               bLocalize = sal_True;
+                                       break;
+                                       case CFG_TOKEN_OORVALUE:
+                                               sSearch = "oor:value=";
+                                       break;
+                                       case CFG_TEXT_START: {
+                                               if ( sCurrentResTyp != 
sTokenName ) {
+                                                       WorkOnRessourceEnd();
+                            ByteString sCur;
+                            for( unsigned int n = 0; n < aLanguages.size(); 
n++ ){
+                                sCur = aLanguages[ n ];
+                                pStackData->sText[ sCur ] = ByteString("");
+                            }
+                       }
+                                               sCurrentResTyp = sTokenName;
+
+                                               ByteString sTemp = sToken.Copy( 
sToken.Search( "xml:lang=" ));
+                                               sCurrentIsoLang = 
sTemp.GetToken( 1, '\"' ).GetToken( 0, '\"' );
+
+                                               if ( sCurrentIsoLang == 
NO_TRANSLATE_ISO )
+                                                       bLocalize = sal_False;
+
+                                               pStackData->sTextTag = sToken;
+
+                                               sCurrentText = "";
+                                       }
+                                       break;
+                               }
+                               if ( sSearch.Len()) {
+                                       ByteString sTemp = sToken.Copy( 
sToken.Search( sSearch ));
+                                       sTokenId = sTemp.GetToken( 1, '\"' 
).GetToken( 0, '\"' );
+                               }
+                               pStackData = aStack.Push( sTokenName, sTokenId 
);
+
+                               if ( sSearch == "cfg:name=" ) {
+                                       ByteString sTemp( sToken );
+                                       sTemp.ToUpperAscii();
+                                       bLocalize = (( sTemp.Search( 
"CFG:TYPE=\"STRING\"" ) != STRING_NOTFOUND ) &&
+                                               ( sTemp.Search( 
"CFG:LOCALIZED=\"sal_True\"" ) != STRING_NOTFOUND ));
+                               }
+                       }
+                       else if ( sTokenName == "label" ) {
+                               if ( sCurrentResTyp != sTokenName ) {
+                                       WorkOnRessourceEnd();
+                    ByteString sCur;
+                    for( unsigned int n = 0; n < aLanguages.size(); n++ ){
+                        sCur = aLanguages[ n ];
+                        pStackData->sText[ sCur ] = ByteString("");
+                    }
+                       }
+                               sCurrentResTyp = sTokenName;
+                       }
+               }
+               break;
+               case CFG_CLOSETAG:
+                       sTokenName = sToken.GetToken( 1, '/' ).GetToken( 0, '>' 
).GetToken( 0, ' ' );
+                       if ( aStack.GetStackData() && ( 
aStack.GetStackData()->GetTagType() == sTokenName )) {
+                               if ( ! sCurrentText.Len())
+                                       WorkOnRessourceEnd();
+                               aStack.Pop();
+                               pStackData = aStack.GetStackData();
+                       }
+                       else {
+                               ByteString sError( "Missplaced close tag: " );
+                ByteString sInFile(" in file ");
+                sError += sToken;
+                sError += sInFile;
+                sError += sFullEntry;
+                               Error( sError );
+                exit ( 13 );
+                       }
+               break;
+
+               case CFG_TEXTCHAR:
+                       sCurrentText += sToken;
+                       bOutput = sal_False;
+               break;
+
+               case CFG_TOKEN_NO_TRANSLATE:
+                       bLocalize = sal_False;
+               break;
+       }
+
+       if ( sCurrentText.Len() && nToken != CFG_TEXTCHAR ) {
+               AddText( sCurrentText, sCurrentIsoLang, sCurrentResTyp );
+               Output( sCurrentText );
+               sCurrentText = "";
+               pStackData->sEndTextTag = sToken;
+       }
+
+       if ( bOutput )
+               Output( sToken );
+
+       if ( sToken != " " && sToken != "\t" )
+               sLastWhitespace = "";
+
+       return 1;
+}
+
+/*****************************************************************************/
+void CfgExport::Output( const ByteString& rOutput )
+/*****************************************************************************/
+{
+    // Dummy operation to suppress warnings caused by poor class design
+    ByteString a( rOutput );
+}
+
+/*****************************************************************************/
+int CfgParser::Execute( int nToken, char * pToken )
+/*****************************************************************************/
+{
+       ByteString sToken( pToken );
+
+       switch ( nToken ) {
+               case CFG_TAG:
+                       if ( sToken.Search( "package-id=" ) != STRING_NOTFOUND )
+                               return ExecuteAnalyzedToken( CFG_TOKEN_PACKAGE, 
pToken );
+                       else if ( sToken.Search( "component-id=" ) != 
STRING_NOTFOUND )
+                               return ExecuteAnalyzedToken( 
CFG_TOKEN_COMPONENT, pToken );
+                       else if ( sToken.Search( "template-id=" ) != 
STRING_NOTFOUND )
+                               return ExecuteAnalyzedToken( 
CFG_TOKEN_TEMPLATE, pToken );
+                       else if ( sToken.Search( "cfg:name=" ) != 
STRING_NOTFOUND )
+                               return ExecuteAnalyzedToken( CFG_TOKEN_OORNAME, 
pToken );
+                       else if ( sToken.Search( "oor:name=" ) != 
STRING_NOTFOUND )
+                               return ExecuteAnalyzedToken( CFG_TOKEN_OORNAME, 
pToken );
+                       else if ( sToken.Search( "oor:value=" ) != 
STRING_NOTFOUND )
+                               return ExecuteAnalyzedToken( 
CFG_TOKEN_OORVALUE, pToken );
+               break;
+       }
+       return ExecuteAnalyzedToken( nToken, pToken );
+}
+
+
+/*****************************************************************************/
+void CfgParser::Error( const ByteString &rError )
+/*****************************************************************************/
+{
+//     ByteString sError( rError );
+//    sError.Append("Error: In file ");
+//    sError.Append( sActFileName );
+    yyerror(( char * ) rError.GetBuffer());
+}
+
+
+//
+// class CfgOutputParser
+//
+
+/*****************************************************************************/
+CfgOutputParser::CfgOutputParser( const ByteString &rOutputFile )
+/*****************************************************************************/
+{
+       pOutputStream =
+               new SvFileStream(
+                       String( rOutputFile, RTL_TEXTENCODING_ASCII_US ),
+                       STREAM_STD_WRITE | STREAM_TRUNC
+               );
+    pOutputStream->SetStreamCharSet( RTL_TEXTENCODING_UTF8 );
+
+       if ( !pOutputStream->IsOpen()) {
+               ByteString sError( "ERROR: Unable to open output file: " );
+               sError += rOutputFile;
+               Error( sError );
+               delete pOutputStream;
+               pOutputStream = NULL;
+        exit( -13 );
+       }
+}
+
+/*****************************************************************************/
+CfgOutputParser::~CfgOutputParser()
+/*****************************************************************************/
+{
+       if ( pOutputStream ) {
+               pOutputStream->Close();
+               delete pOutputStream;
+       }
+}
+
+//
+// class CfgExport
+//
+
+/*****************************************************************************/
+CfgExport::CfgExport(
+               const ByteString &rOutputFile,
+               const ByteString &rProject,
+               const ByteString &rFilePath
+)
+/*****************************************************************************/
+                               : CfgOutputParser( rOutputFile ),
+                               sPrj( rProject ),
+                               sPath( rFilePath )
+{
+    Export::InitLanguages( false );
+    aLanguages = Export::GetLanguages();
+}
+
+/*****************************************************************************/
+CfgExport::~CfgExport()
+/*****************************************************************************/
+{
+}
+
+/*****************************************************************************/
+void CfgExport::WorkOnRessourceEnd()
+/*****************************************************************************/
+{
+       if ( pOutputStream && bLocalize ) {
+       if (( pStackData->sText[ ByteString("en-US") ].Len()
+        ) ||
+                       ( bForce &&
+                               ( pStackData->sText[ ByteString("de") ].Len() ||
+                    pStackData->sText[ ByteString("en-US") ].Len() )))
+               {
+            ByteString sFallback = pStackData->sText[ ByteString("en-US") ];
+
+            //if ( pStackData->sText[ ByteString("en-US") ].Len())
+                       //      sFallback = pStackData->sText[ 
ByteString("en-US") ];
+
+                       ByteString sLocalId = pStackData->sIdentifier;
+                       ByteString sGroupId;
+                       if ( aStack.Count() == 1 ) {
+                               sGroupId = sLocalId;
+                               sLocalId = "";
+                       }
+                       else {
+                               sGroupId = aStack.GetAccessPath( aStack.Count() 
- 2 );
+                       }
+
+                       ByteString sTimeStamp( Export::GetTimeStamp());
+
+            ByteString sCur;
+            for( unsigned int n = 0; n < aLanguages.size(); n++ ){
+                sCur = aLanguages[ n ];
+
+                                       ByteString sText = pStackData->sText[ 
sCur ];
+                                       if ( !sText.Len())
+                                               sText = sFallback;
+
+                    Export::UnquotHTML( sText );
+
+                                       ByteString sOutput( sPrj ); sOutput += 
"\t";
+                                       sOutput += sPath;
+                                       sOutput += "\t0\t";
+                                       sOutput += pStackData->sResTyp; sOutput 
+= "\t";
+                                       sOutput += sGroupId; sOutput += "\t";
+                                       sOutput += sLocalId; sOutput += 
"\t\t\t0\t";
+                    sOutput += sCur;
+                                       sOutput += "\t";
+
+                    sOutput += sText; sOutput += "\t\t\t\t";
+                                       sOutput += sTimeStamp;
+
+                    //if( !sCur.EqualsIgnoreCaseAscii("de") ||( 
sCur.EqualsIgnoreCaseAscii("de") && !Export::isMergingGermanAllowed( sPrj ) ) )
+                                       pOutputStream->WriteLine( sOutput );
+                       }
+               }
+       }
+}
+
+/*****************************************************************************/
+void CfgExport::WorkOnText(
+       ByteString &rText,
+    const ByteString &rIsoLang
+)
+/*****************************************************************************/
+{
+    if( rIsoLang.Len() ) Export::UnquotHTML( rText );
+}
+
+
+//
+// class CfgMerge
+//
+
+/*****************************************************************************/
+CfgMerge::CfgMerge(
+       const ByteString &rMergeSource, const ByteString &rOutputFile,
+       ByteString &rFilename )
+/*****************************************************************************/
+                               : CfgOutputParser( rOutputFile ),
+                               pMergeDataFile( NULL ),
+                               pResData( NULL ),
+                               bGerman( sal_False ),
+                               sFilename( rFilename ),
+                               bEnglish( sal_False )
+{
+    if ( rMergeSource.Len()){
+               pMergeDataFile = new MergeDataFile(
+               rMergeSource, sInputFileName  , bErrorLog, 
RTL_TEXTENCODING_MS_1252, true ); 
+        if( Export::sLanguages.EqualsIgnoreCaseAscii("ALL") ){
+            Export::SetLanguages( pMergeDataFile->GetLanguages() );
+            aLanguages = pMergeDataFile->GetLanguages();
+        }
+        else aLanguages = Export::GetLanguages();
+    }else
+        aLanguages = Export::GetLanguages();
+}
+
+/*****************************************************************************/
+CfgMerge::~CfgMerge()
+/*****************************************************************************/
+{
+       delete pMergeDataFile;
+       delete pResData;
+}
+
+/*****************************************************************************/
+void CfgMerge::WorkOnText(
+       ByteString &rText,
+    const ByteString& nLangIndex
+)
+/*****************************************************************************/
+{
+
+    if ( pMergeDataFile && bLocalize ) {
+               if ( !pResData ) {
+                       ByteString sLocalId = pStackData->sIdentifier;
+                       ByteString sGroupId;
+                       if ( aStack.Count() == 1 ) {
+                               sGroupId = sLocalId;
+                               sLocalId = "";
+                       }
+                       else {
+                               sGroupId = aStack.GetAccessPath( aStack.Count() 
- 2 );
+                       }
+
+                       ByteString sPlatform( "" );
+
+                       pResData = new ResData( sPlatform, sGroupId , sFilename 
);
+                       pResData->sId = sLocalId;
+                       pResData->sResTyp = pStackData->sResTyp;
+               }
+
+        //if ( nLangIndex.EqualsIgnoreCaseAscii("de") )
+               //      bGerman = sal_True;
+               if (( nLangIndex.EqualsIgnoreCaseAscii("en-US") ))
+                       bEnglish = sal_True;
+
+               PFormEntrys *pEntrys = 
pMergeDataFile->GetPFormEntrysCaseSensitive( pResData );
+               if ( pEntrys ) {
+                       ByteString sContent;
+            pEntrys->GetText( sContent, STRING_TYP_TEXT, nLangIndex );
+            
+                       if ( Export::isAllowed( nLangIndex ) &&
+                               ( sContent != "-" ) && ( sContent.Len()))
+                       {
+#ifdef MERGE_SOURCE_LANGUAGES 
+                    if( nLangIndex.EqualsIgnoreCaseAscii("de") || 
nLangIndex.EqualsIgnoreCaseAscii("en-US") )
+                        rText = sContent;
+#endif
+                Export::QuotHTML( rText );
+                       }
+               }
+       }
+}
+
+/*****************************************************************************/
+void CfgMerge::Output( const ByteString& rOutput )
+/*****************************************************************************/
+{
+       if ( pOutputStream )
+               pOutputStream->Write( rOutput.GetBuffer(), rOutput.Len());
+}
+
+sal_uLong CfgStack::Push( CfgStackData *pStackData )
+{ 
+    Insert( pStackData, LIST_APPEND ); 
+    return Count() - 1; 
+}
+
+/*****************************************************************************/
+void CfgMerge::WorkOnRessourceEnd()
+/*****************************************************************************/
+{
+
+       if ( pMergeDataFile && pResData && bLocalize && (( bEnglish ) || bForce 
)) {
+               PFormEntrys *pEntrys = 
pMergeDataFile->GetPFormEntrysCaseSensitive( pResData );
+               if ( pEntrys ) {
+            ByteString sCur;
+
+            for( unsigned int n = 0; n < aLanguages.size(); n++ ){
+                sCur = aLanguages[ n ];
+
+                               ByteString sContent;
+                pEntrys->GetText( sContent, STRING_TYP_TEXT, sCur , sal_True );
+                if ( 
+                    // (!sCur.EqualsIgnoreCaseAscii("de") )    &&
+                                       ( !sCur.EqualsIgnoreCaseAscii("en-US") 
) &&
+
+                                       ( sContent != "-" ) && ( 
sContent.Len()))
+                               {
+                    
+                                       ByteString sText = sContent;
+                    Export::QuotHTML( sText );
+
+                                       ByteString sAdditionalLine( "\t" );
+
+                                       ByteString sTextTag = 
pStackData->sTextTag;
+                                       ByteString sTemp = sTextTag.Copy( 
sTextTag.Search( "xml:lang=" ));
+
+                                       ByteString sSearch = sTemp.GetToken( 0, 
'\"' );
+                                       sSearch += "\"";
+                                       sSearch += sTemp.GetToken( 1, '\"' );
+                                       sSearch += "\"";
+
+                                       ByteString sReplace = sTemp.GetToken( 
0, '\"' );
+                                       sReplace += "\"";
+                    sReplace += sCur;
+                                       sReplace += "\"";
+
+                                       sTextTag.SearchAndReplace( sSearch, 
sReplace );
+
+                                       sAdditionalLine += sTextTag;
+                                       sAdditionalLine += sText;
+                                       sAdditionalLine += 
pStackData->sEndTextTag;
+
+                                       sAdditionalLine += "\n";
+                                       sAdditionalLine += sLastWhitespace;
+
+                                       Output( sAdditionalLine );
+                               }
+                       }
+               }
+       }
+       delete pResData;
+       pResData = NULL;
+       bGerman = sal_False;
+       bEnglish = sal_False;
+}

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

Added: openoffice/branches/l10n/main/l10ntools/source/directory.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/directory.cxx?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/directory.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/directory.cxx Thu Jan 24 
12:21:38 2013
@@ -0,0 +1,266 @@
+/**************************************************************
+ * 
+ * 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 <l10ntools/directory.hxx>
+#include "tools/string.hxx"
+#include <iostream>
+#include <vector>
+#include <algorithm>
+
+namespace transex 
+{
+
+Directory::Directory( const rtl::OUString sFullpath ) : bSkipLinks( false )
+{
+    sFullName = sFullpath;
+}
+
+Directory::Directory( const rtl::OUString sFullPath , const rtl::OUString 
sEntry ) : bSkipLinks( false )
+{
+    sFullName       = sFullPath;
+    sDirectoryName  = sEntry;
+}
+
+
+Directory::Directory( const ByteString sFullPath ) : bSkipLinks( false )
+{
+    sDirectoryName = rtl::OUString( sFullPath.GetBuffer() , 
RTL_TEXTENCODING_UTF8 , sFullPath.Len() );
+}
+
+bool Directory::lessDir ( const Directory& rKey1, const Directory& rKey2 )
+{
+    rtl::OUString sName1( ( static_cast< Directory >( rKey1 ) 
).getDirectoryName() ); 
+    rtl::OUString sName2( ( static_cast< Directory >( rKey2 ) 
).getDirectoryName() ); 
+            
+    return sName1.compareTo( sName2 ) < 0 ;
+}
+
+
+void Directory::dump()
+{
+   
+    for( std::vector< transex::File >::iterator iter = aFileVec.begin() ; iter 
!= aFileVec.end() ; ++iter )
+    {
+        std::cout << "FILE " << rtl::OUStringToOString( 
(*iter).getFullName().getStr() , RTL_TEXTENCODING_UTF8 , 
(*iter).getFullName().getLength() ).getStr() << "\n";
+    }
+
+    for( std::vector< transex::Directory >::iterator iter = aDirVec.begin() ; 
iter != aDirVec.end() ; ++iter )
+    {
+        std::cout << "DIR " << rtl::OUStringToOString( 
(*iter).getFullName().getStr() , RTL_TEXTENCODING_UTF8 , 
(*iter).getFullName().getLength() ).getStr() << "\n";
+    }
+    
+}
+
+void Directory::scanSubDir( int nLevels )
+{
+    readDirectory( sFullName );
+    dump();
+    if( nLevels > 0 ) {
+        for( std::vector< transex::Directory >::iterator iter = 
aDirVec.begin() ; iter != aDirVec.end() || nLevels > 0 ; ++iter , nLevels-- )
+        {
+            ( *iter ).scanSubDir();
+        }
+    }
+}
+
+void Directory::setSkipLinks( bool is_skipped )
+{
+    bSkipLinks = is_skipped;
+}
+
+void Directory::readDirectory()
+{
+    readDirectory( sFullName );
+}
+
+#ifdef WNT
+#include <tools/prewin.h>
+#include <windows.h>
+#include <tools/postwin.h>
+
+void Directory::readDirectory ( const rtl::OUString& sFullpath )
+{
+    sal_Bool            fFinished;
+    HANDLE          hList;
+    TCHAR           szDir[MAX_PATH+1];
+    TCHAR           szSubDir[MAX_PATH+1];
+    WIN32_FIND_DATA FileData;
+
+    rtl::OString sFullpathext = rtl::OUStringToOString( sFullpath , 
RTL_TEXTENCODING_UTF8 , sFullpath.getLength() );
+    const char *dirname = sFullpathext.getStr();
+    
+    // Get the proper directory path
+       sprintf(szDir, "%s\\*", dirname);
+        
+    // Get the first file
+    hList = FindFirstFile(szDir, &FileData);
+    if (hList == INVALID_HANDLE_VALUE)
+    { 
+        //FindClose(hList);
+        //printf("No files found %s\n", szDir ); return;
+    }
+    else
+    {
+        fFinished = sal_False;
+        while (!fFinished)
+        {
+            
+                       sprintf(szSubDir, "%s\\%s", dirname, 
FileData.cFileName);
+                       rtl::OString myfile( FileData.cFileName );
+                       rtl::OString mydir( szSubDir );
+
+            if (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+            {
+                if ( (strcmp(FileData.cFileName, ".") != 0 ) &&
+                                        (strcmp(FileData.cFileName, "..") != 0 
) )
+                {
+                       //sprintf(szSubDir, "%s\\%s", dirname, 
FileData.cFileName);
+                                       transex::Directory aDir(        
rtl::OStringToOUString( mydir , RTL_TEXTENCODING_UTF8 , mydir.getLength() ),
+                                                                               
                rtl::OStringToOUString( myfile , RTL_TEXTENCODING_UTF8 , 
myfile.getLength() ) );
+                                       aDirVec.push_back( aDir );
+                }
+            }
+                       else
+                       {
+                               transex::File aFile(    rtl::OStringToOUString( 
mydir , RTL_TEXTENCODING_UTF8 , mydir.getLength() ),
+                                                                               
rtl::OStringToOUString( myfile , RTL_TEXTENCODING_UTF8 , myfile.getLength() ) );
+                aFileVec.push_back( aFile );
+                       }
+            if (!FindNextFile(hList, &FileData))
+            {
+                if (GetLastError() == ERROR_NO_MORE_FILES)
+                {
+                    fFinished = sal_True;
+                }
+            }
+        }
+    }
+
+    FindClose(hList);
+    
+    ::std::sort( aFileVec.begin() , aFileVec.end() , File::lessFile );
+    ::std::sort( aDirVec.begin()  , aDirVec.end()  , Directory::lessDir  );
+}
+
+#else
+
+class dirholder
+{
+private:
+    DIR *mpDir;
+public:
+    dirholder(DIR *pDir) : mpDir(pDir) {}
+    int close() { int nRet = mpDir ? closedir(mpDir) : 0; mpDir = NULL; return 
nRet; }
+    ~dirholder() { close(); }
+};
+
+void Directory::readDirectory( const rtl::OUString& sFullpath )
+{
+    struct stat     statbuf;
+    struct stat     statbuf2;
+    struct dirent   *dirp;
+    DIR             *dir;
+
+    if( sFullpath.getLength() < 1 ) return;
+
+    rtl::OString   sFullpathext = rtl::OUStringToOString( sFullpath , 
RTL_TEXTENCODING_UTF8 , sFullpath.getLength() ).getStr();
+    
+    // stat
+       if( stat( sFullpathext.getStr()  , &statbuf ) < 0 ){   printf("warning: 
Can not stat %s" , sFullpathext.getStr() ); return; }// error }
+   
+    if( S_ISDIR(statbuf.st_mode ) == 0 ) {  return; }// error }   return; // 
not dir
+
+    if( (dir = opendir( sFullpathext.getStr() ) ) == NULL  ) 
{printf("readerror 2 in %s \n",sFullpathext.getStr()); return; } // error } 
return; // error
+
+    dirholder aHolder(dir);
+   
+    sFullpathext += rtl::OString( "/" );
+
+    const rtl::OString sDot ( "." ) ;
+    const rtl::OString sDDot( ".." );
+  
+    if ( chdir( sFullpathext.getStr() ) == -1 ) { printf("chdir error in %s 
\n",sFullpathext.getStr()); return; } // error
+    
+    while(  ( dirp = readdir( dir ) ) != NULL )
+    {
+        rtl::OString sEntryName(  dirp->d_name );
+
+        if( sEntryName.equals( sDot )  || sEntryName.equals( sDDot ) )
+            continue;
+            
+        // add dir entry
+        rtl::OString sEntity = sFullpathext;
+        sEntity += sEntryName;
+        
+        // stat new entry
+        if( lstat( sEntity.getStr() , &statbuf2 ) < 0 )
+        {
+            printf("error on entry %s\n" , sEntity.getStr() ) ; // error
+            continue;
+        }
+
+        // add file / dir to vector
+        switch( statbuf2.st_mode & S_IFMT )
+        {
+            case S_IFREG:
+                                               {   
+                            rtl::OString sFile = sFullpathext;
+                            sFile += sEntryName ;
+                            transex::File aFile( rtl::OStringToOUString( 
sEntity , RTL_TEXTENCODING_UTF8 , sEntity.getLength() ) , 
+                                                 rtl::OStringToOUString( 
sEntryName , RTL_TEXTENCODING_UTF8 , sEntryName.getLength() )               
+                                               );
+
+                                                       aFileVec.push_back( 
aFile ) ;   
+                            break; 
+                         }  
+            case S_IFLNK:
+                        {   
+                            if( bSkipLinks )    break;
+                        }
+            case S_IFDIR:
+                                               {   
+                            rtl::OString sDir = sFullpathext;
+                            sDir += sEntryName ;
+
+                            transex::Directory aDir( 
+                                                     rtl::OStringToOUString( 
sEntity , RTL_TEXTENCODING_UTF8 , sEntity.getLength() ) ,
+                                                     rtl::OStringToOUString( 
sEntryName , RTL_TEXTENCODING_UTF8 , sEntryName.getLength() )               
+                                                   ) ; 
+                            aDirVec.push_back( aDir ) ;     
+                            break; 
+                         }
+        }
+    }
+    if ( chdir( ".." ) == -1 ) { printf("chdir error in .. \n"); return; } // 
error
+    if( aHolder.close() < 0 )   return ; // error
+
+    std::sort( aFileVec.begin() , aFileVec.end() , File::lessFile );
+    std::sort( aDirVec.begin()  , aDirVec.end()  , Directory::lessDir  );
+
+}
+
+#endif
+}

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


Reply via email to