openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1437973 [10/11] - in /openoffice/branches/l10n/main/l10ntools/source: ./ filter/ filter/merge/ filter/utils/ help/
Date Thu, 24 Jan 2013 12:21:39 GMT
Added: openoffice/branches/l10n/main/l10ntools/source/wtranode.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/wtranode.cxx?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/wtranode.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/wtranode.cxx Thu Jan 24 12:21:38 2013
@@ -0,0 +1,104 @@
+/**************************************************************
+ * 
+ * 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 "wtranode.hxx"
+
+
+// NOT FULLY DECLARED SERVICES
+
+
+const ByteString	sEmptyString("");
+
+
+WTT_Node::WTT_Node( UINT8	   i_nValue,
+					WTT_Node * i_pDefaultBranch,
+					WTT_Node * i_pDefaultBranchForAlphas )
+	:	nValue(i_nValue),
+		eType(token_to_keep),
+		sReplaceString(sEmptyString),
+		// aBranches,
+		bIsOnDeleting(char(0))
+{
+	int i = 0;
+	for ( ; i < C_BR_ALPHABASE; i++ )
+	{
+		aBranches[i] = i_pDefaultBranch;
+	}  // end for
+	for ( ; i < C_NR_OF_BRANCHES; i++ )
+	{
+		aBranches[i] = i_pDefaultBranchForAlphas;
+	}
+}
+
+void
+WTT_Node::SetBranch( UINT8      i_cBranch,
+					 WTT_Node *	i_pNode )
+{
+	if (i_cBranch < C_NR_OF_BRANCHES)
+	{
+		aBranches[i_cBranch] = i_pNode;
+	}
+}
+
+void
+WTT_Node::SetAsTokenToReplace(const ByteString & i_sReplaceString)
+{
+	sReplaceString = i_sReplaceString;
+	eType = token_to_replace;
+}
+
+WTT_Node::~WTT_Node()
+{
+	// Delete the tree hanging below this node:
+
+	bIsOnDeleting = sal_True;	// Avoid double deleting of multiple used nodes.
+
+	for (int i = 0; i < C_NR_OF_BRANCHES; i++)
+	{
+		if (aBranches[i] != 0 ? ! aBranches[i]->IsOnDeleting() : sal_False)
+		{
+			delete aBranches[i];
+		}
+	}  // end for
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

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

Added: openoffice/branches/l10n/main/l10ntools/source/wtratree.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/wtratree.cxx?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/wtratree.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/wtratree.cxx Thu Jan 24 12:21:38 2013
@@ -0,0 +1,414 @@
+/**************************************************************
+ * 
+ * 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 "wtratree.hxx"
+
+
+
+/** @ATTENTION
+	For reasons of speed, class WordTransTree works with two simple
+	char arrays, sOutput and sInput, instead of secure containers or
+	streams. So be extremely careful, when changing this code!!!
+**/
+
+
+
+// NOT FULLY DECLARED SERVICES
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "wtranode.hxx"
+
+
+const BRANCH_T	BR_END			= 0;
+const BRANCH_T	BR_NONALPHA     = 1;
+const BRANCH_T	BR_HOTKEY       = 2;
+const BRANCH_T	BR_BACKSLASH    = 3;
+const BRANCH_T	BR_ALPHABASE    = 4;   	/// @ATTENTION  All branches not valid for words must be smaller than this value!
+const BRANCH_T	BR_AE           = 30;
+const BRANCH_T	BR_OE           = 31;
+const BRANCH_T	BR_UE           = 32;
+const BRANCH_T	BR_SZ           = 33;
+const BRANCH_T	BR_MAX          = 34;	/// @ATTENTION  Must be updated always!
+
+const BRANCH_T	BR_START 		= 0;
+
+
+
+
+
+WordTransTree::WordTransTree(CharSet  i_nWorkingCharSet)
+	:	sInput(0),
+		nInputLength(0),
+		pInputEnd(0),
+		sOutput(0),
+		nOutputMaxLength(0),
+		dpParsingTreeTop(0),
+		pUnknownAlpha(0),
+		// cChar2Branch
+        c_AE(u_char('\xC4')), c_OE(u_char('\xD6')), c_UE(u_char('\xDC')),
+        c_ae(u_char('\xE4')), c_oe(u_char('\xF6')), c_ue(u_char('\xFC')),
+		pInputCurTokenStart(0),
+		pInputPosition(0),
+		pOutputPosition(0),
+		pCurParseNode(0),
+		eCurResult(OK),
+		cCurHotkey(0),
+		cCurHotkeySign(u_char('~'))
+{
+	// Initialize parsing tree:
+	pUnknownAlpha = new WTT_Node(BR_ALPHABASE,0,0);	// This will be deleted as part of the parsing tree.
+	for ( UINT8 i = BR_ALPHABASE; i < C_NR_OF_BRANCHES; i++)
+	{
+		pUnknownAlpha->SetBranch(i,pUnknownAlpha);
+	}  // end for
+
+	dpParsingTreeTop = new WTT_Node(BR_START,0,pUnknownAlpha);
+
+	WTT_Node * dpNonAlpha = new WTT_Node(BR_NONALPHA,0,0);
+
+	dpNonAlpha->SetBranch(BR_NONALPHA,dpNonAlpha);
+	dpParsingTreeTop->SetBranch(BR_NONALPHA,dpNonAlpha);
+
+	WTT_Node * dpBackslash = new WTT_Node(BR_BACKSLASH,dpNonAlpha,dpNonAlpha);
+	dpBackslash->SetBranch(BR_END,0);
+
+	dpParsingTreeTop->SetBranch(BR_BACKSLASH,dpBackslash);
+	dpNonAlpha->SetBranch(BR_BACKSLASH,dpBackslash);
+
+
+	// Initialize character set:
+	SetCharSet(i_nWorkingCharSet);
+
+	if (C_BR_ALPHABASE != BR_ALPHABASE || C_NR_OF_BRANCHES != BR_MAX)
+	{
+		fprintf(stderr, "Assertion failed: file %s line %d.", __FILE__,  __LINE__);
+		exit(1);
+	}
+}
+
+void
+WordTransTree::SetCharSet(CharSet i_nWorkingCharSet)
+{
+    ByteString sConvert("\xC4\xD6\xDC\xE4\xF6\xFC\xDF");
+	const u_char * pConvert = (const u_char * ) ( sConvert.Convert(RTL_TEXTENCODING_MS_1252, i_nWorkingCharSet).GetBuffer() );
+
+	INT16 i = 0;
+	for ( ; i < C_NR_OF_POSSIBLE_CHARS; ++i )
+	{
+		cChar2Branch[i] = BR_NONALPHA;
+	}  // end for
+	for ( i = 'a'; i <= 'z'; ++i )
+	{
+		cChar2Branch[i] = BR_ALPHABASE + i - 'a';
+	}  // end for
+	for ( i = 'A'; i <= 'Z'; ++i )
+	{
+		cChar2Branch[i] = BR_ALPHABASE + i - 'A';
+	}  // end for
+	cChar2Branch[pConvert[0]] = BR_AE;
+	cChar2Branch[pConvert[1]] = BR_OE;
+	cChar2Branch[pConvert[2]] = BR_UE;
+	cChar2Branch[pConvert[3]] = BR_AE;
+	cChar2Branch[pConvert[4]] = BR_OE;
+	cChar2Branch[pConvert[5]] = BR_UE;
+	cChar2Branch[pConvert[6]] = BR_SZ;
+
+	cChar2Branch[u_char('~')] = BR_HOTKEY;
+	cChar2Branch[u_char('&')] = BR_HOTKEY;
+
+
+	c_AE = pConvert[0];
+	c_OE = pConvert[1];
+	c_UE = pConvert[2];
+	c_ae = pConvert[3];
+	c_oe = pConvert[4];
+	c_ue = pConvert[5];
+}
+
+WordTransTree::~WordTransTree()
+{
+	delete dpParsingTreeTop;
+	if (sOutput != 0)
+		delete [] sOutput;
+}
+
+void
+WordTransTree::AddWordPair(	const ByteString &		i_sOldString,
+							const ByteString &		i_sReplaceString )
+{
+	if (i_sOldString.Len() == 0)
+		return;
+
+	pCurParseNode = dpParsingTreeTop;
+	WTT_Node * pBranch = 0;
+	char cBranch = 0;
+
+	for ( constr pOld = i_sOldString.GetBuffer();
+		  *pOld != 0;
+		  pOld++ )
+	{
+		cBranch = CalculateBranch(*pOld);
+		pBranch = pCurParseNode->GetNextNode(cBranch);
+		if (pBranch == 0 || pBranch == pUnknownAlpha)
+		{
+			pBranch = new WTT_Node(cBranch,0,pUnknownAlpha);
+			pCurParseNode->SetBranch(cBranch,pBranch);
+		}
+		pCurParseNode = pBranch;
+	}	// end for
+	pCurParseNode->SetAsTokenToReplace(i_sReplaceString);
+}
+
+void
+WordTransTree::InitTransformation( const char *	i_sInput,
+								   UINT32		i_nInputLength,
+								   UINT32		i_nOutputMaxLength )
+{
+	sInput = (const u_char *)i_sInput;
+	nInputLength = i_nInputLength;
+	pInputEnd = &sInput[i_nInputLength];
+
+	pInputCurTokenStart = sInput;
+	pInputPosition = sInput;
+
+	if (nOutputMaxLength < i_nOutputMaxLength)
+	{
+		if (sOutput != 0)
+			delete [] sOutput;
+		sOutput = new unsigned char[i_nOutputMaxLength];
+		nOutputMaxLength = i_nOutputMaxLength;
+	}
+	pOutputPosition = sOutput;
+}
+
+/**	pInputCurTokenStart and CurParseNode are updated just when
+	starting this function. After its end they must not be changed
+	till this functon is called again.
+	Outside this function pInputPositon and pOutputPosition are both
+	on the first not transformed char in their respective array.
+**/
+WordTransTree::E_Result
+WordTransTree::TransformNextToken()
+{
+	pInputCurTokenStart = pInputPosition;
+	pCurParseNode = dpParsingTreeTop;
+	cCurHotkey = 0;
+    eCurResult = OK;
+
+	WTT_Node * pBranch = 0;
+	UINT8 cBranch = 0;
+
+	for ( pCurParseNode = dpParsingTreeTop;
+		  pInputPosition != pInputEnd;
+		  ++pInputPosition )
+	{
+		cBranch = CalculateBranch(*pInputPosition);
+		pBranch = pCurParseNode->GetNextNode( cBranch );
+		if (pBranch != 0)
+		{
+			pCurParseNode = pBranch;
+		}
+		else
+		{
+			if (cBranch == BR_HOTKEY)   // current letter is '~' or '&'.
+			{
+				// Logic of the following. There are 9 possible cases -
+				// A = alphabetic letter, NA = non alphabetic, TB = token begin,
+				// Eot = end of text:
+				//	 1.	A~A          set hotkey to following letter, continue
+				//	 2.	A~NA         token end
+				//	 3.	A~Eot        token end
+				//	 4.	NA~A         token end
+				//	 5.	NA~NA        continue
+				//	 6.	A~Eof        continue
+				//	 7.	TB~A         set hotkey to following letter, continue
+				//	 8.	TB~NA        continue
+				//	 9.	TB~Eot       continue
+
+				// bNext and Prev are true, if there are alphabetic letters:
+				sal_Bool bNext =  pInputPosition + 1 != pInputEnd
+									?   CalculateBranch(pInputPosition[1]) >= BR_ALPHABASE
+									: 	sal_False;
+				sal_Bool bPrev = pCurParseNode->Value() >= BR_ALPHABASE;
+
+				if ( bNext && (bPrev || pCurParseNode == dpParsingTreeTop) )
+				{   // case 1. and 7.
+					Handle_Hotkey();
+					continue;
+				}
+				else if  (!bPrev && !bNext)
+				{   // case 5.,6.,8.,9.
+					continue;
+				}
+
+				// Case 2.,3.,4. :
+				// 	so this should be handled as an end of a token.
+			}
+			if (pCurParseNode->TokenType() == WTT_Node::token_to_keep)
+			{
+				Handle_TokenToKeep();
+				return eCurResult;
+			}
+			else
+			{
+				Handle_TokenToTransform();
+				return eCurResult;
+			}	// endif (pCurParseNode->TokenType() == WTT_Node::token_to_keep)
+		} 	// endif (pBranch == 0) else
+	}	// end for
+
+	// If here, the text end is reached
+	if (pCurParseNode->TokenType() == WTT_Node::token_to_keep)
+	{
+		Handle_TokenToKeep();
+		return eCurResult;
+	}
+	else
+	{
+		Handle_TokenToTransform();
+		return eCurResult;
+	}
+}
+
+ByteString
+WordTransTree::CurReplacingString() const
+{
+	return pCurParseNode->ReplaceString();
+}
+
+void
+WordTransTree::Handle_Hotkey()
+{
+	if (cCurHotkey == 0) 	// Avoid to replace the first found hotkey by
+	                        //   a later one - though this shouldn't happen anyway.
+	{
+		cCurHotkey = (pInputPosition+1) != pInputEnd ? pInputPosition[1] : 0;
+		cCurHotkeySign = *pInputPosition;
+	}
+}
+
+void
+WordTransTree::Handle_TokenToKeep()
+{
+	UINT32 nTokenLength = pInputPosition-pInputCurTokenStart;
+
+	memcpy(pOutputPosition,pInputCurTokenStart,nTokenLength);
+
+	pOutputPosition += nTokenLength;
+	*pOutputPosition = '\0';
+}
+
+void
+WordTransTree::Handle_TokenToTransform()
+{
+	sal_Bool bHaveHotkey = CalculateBranch(cCurHotkey) >= BR_ALPHABASE;
+	const ByteString & rReplace = pCurParseNode->ReplaceString();
+
+	// Find position of hotkey in replace-string:
+	sal_uInt16 nHotkeyPos = bHaveHotkey
+							?	rReplace.Search(char(cCurHotkey))
+							:	STRING_NOTFOUND;
+	if (nHotkeyPos == STRING_NOTFOUND && bHaveHotkey)
+	{
+		if (cCurHotkey < 128)
+		{
+			if (islower(cCurHotkey))
+				nHotkeyPos = rReplace.Search(toupper(char(cCurHotkey)));
+			else
+				nHotkeyPos = rReplace.Search(tolower(char(cCurHotkey)));
+		}
+		else	// cCurHotkey >= 128
+		{
+			if (cCurHotkey == c_ae)
+				nHotkeyPos = rReplace.Search(char(c_AE));
+			else if (cCurHotkey == c_oe)
+				nHotkeyPos = rReplace.Search(char(c_OE));
+			else if (cCurHotkey == c_ue)
+				nHotkeyPos = rReplace.Search(char(c_UE));
+			else if (cCurHotkey == c_AE)
+				nHotkeyPos = rReplace.Search(char(c_ae));
+			else if (cCurHotkey == c_OE)
+				nHotkeyPos = rReplace.Search(char(c_oe));
+			else if (cCurHotkey == c_UE)
+				nHotkeyPos = rReplace.Search(char(c_ue));
+		}	// endif (cCurHotkey < 128) else
+
+		if (nHotkeyPos == STRING_NOTFOUND)
+		{
+			eCurResult = HOTKEY_LOST;
+			bHaveHotkey = sal_False;
+		}
+	} 	// endif (nHotkeyPos == STRING_NOT_FOUND && bHaveHotkey)
+
+
+	UINT32 nOutputTokenLength = rReplace.Len() + (bHaveHotkey ? 1 : 0);
+
+	if (bHaveHotkey)
+	{
+		memcpy( pOutputPosition,
+				pCurParseNode->ReplaceString().GetBuffer(),
+				nHotkeyPos );
+		*(pOutputPosition + nHotkeyPos) = cCurHotkeySign;
+		memcpy( pOutputPosition + nHotkeyPos + 1,
+				pCurParseNode->ReplaceString().GetBuffer() + nHotkeyPos,
+				nOutputTokenLength - nHotkeyPos - 1);
+	}
+	else
+	{
+		memcpy( pOutputPosition,
+				pCurParseNode->ReplaceString().GetBuffer(),
+				nOutputTokenLength );
+	}
+
+	// Convert first letter into upper if necessary:
+	u_char cInStart = CalculateBranch(*pInputCurTokenStart) == BR_HOTKEY
+							? 	pInputCurTokenStart[1]
+							:	pInputCurTokenStart[0] ;
+	u_char * pOutStart = nHotkeyPos == 0
+							? 	pOutputPosition + 1
+							:	pOutputPosition ;
+	if (isupper(cInStart) || cInStart > 127)
+	{   // Possibly cInStart is upper character:
+		if (isupper(cInStart) || cInStart == c_AE || cInStart == c_OE || cInStart == c_UE)
+		{	// Surely cInStart is upper character:
+			u_char cOutStart = *pOutStart;
+			if (cOutStart < 128)
+				*pOutStart = toupper(cOutStart);
+			else if (cOutStart == c_ae)
+				*pOutStart = c_AE;
+			else if (cOutStart == c_oe)
+				*pOutStart = c_OE;
+			else if (cOutStart == c_ue)
+				*pOutStart = c_UE;
+		}
+	}  	// endif (isupper(cInStart) || cInStart > 127)
+
+	pOutputPosition += nOutputTokenLength;
+	*pOutputPosition = '\0';
+}
+

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

Added: openoffice/branches/l10n/main/l10ntools/source/xgfconv.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/xgfconv.cxx?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/xgfconv.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/xgfconv.cxx Thu Jan 24 12:21:38 2013
@@ -0,0 +1,87 @@
+/**************************************************************
+ * 
+ * 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 <stdio.h>
+
+#include "export.hxx"
+#include "utf8conv.hxx"
+
+/*****************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_l10ntools.hxx"
+#if defined(UNX) || defined(OS2)
+int main( int argc, char *argv[] )
+#else
+int _cdecl main( int argc, char *argv[] )
+#endif
+/*****************************************************************************/
+{
+	if ( argc != 3 ) {
+		fprintf( stderr, "xgfconv InputFile OutputFile\n" );
+		return ( 5 );
+	}
+
+	ByteString sInput( argv[ 1 ] );
+	ByteString sOutput( argv[ 2 ] );
+	
+	SvFileStream aInput( String( sInput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_READ );
+	if ( !aInput.IsOpen()) {
+		fprintf( stderr, "ERROR: Unable to open input file!\n" );
+		return ( 5 );
+	}
+
+	SvFileStream aOutput( String( sOutput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_WRITE | STREAM_TRUNC );
+	if ( !aOutput.IsOpen()) {
+		fprintf( stderr, "ERROR: Unable to open output file!\n" );
+		aInput.Close();
+		return ( 5 );
+	}
+
+	ByteString sLine;
+	sal_Bool bFirst = sal_True;
+	while ( !aInput.IsEof()) {
+		aInput.ReadLine( sLine );
+		ByteString sLangId = sLine.GetToken( 0, '\t' );
+		ByteString sFile = sLine.GetToken( 1, '\t' );
+		ByteString sText = sLine.Copy( sLangId.Len() + sFile.Len() + 2 );
+
+		sal_uInt16 nLangId = sLangId.ToInt32();
+		CharSet aCharSet = Export::GetCharSet( nLangId );
+		if ( aCharSet != 0xFFFF && sText.Len()) {
+			sText = UTF8Converter::ConvertToUTF8( sText, aCharSet );
+			ByteString sOutput = sFile; 
+			sOutput += "\t";
+			sOutput += sText;
+			if ( !bFirst ) {
+				ByteString sEmpty;
+				aOutput.WriteLine( sEmpty );
+			}
+			else
+				bFirst = sal_False;
+			aOutput.Write( sOutput.GetBuffer(), sOutput.Len());
+		}
+	}
+	aInput.Close();
+	aOutput.Close();
+	return ( 0 );
+}
+

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

Added: openoffice/branches/l10n/main/l10ntools/source/xmlparse.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/xmlparse.cxx?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/xmlparse.cxx (added)
+++ openoffice/branches/l10n/main/l10ntools/source/xmlparse.cxx Thu Jan 24 12:21:38 2013
@@ -0,0 +1,1449 @@
+/**************************************************************
+ * 
+ * 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 <iterator> /* std::iterator*/
+
+#include <stdio.h>
+#include <sal/alloca.h>
+
+#include "xmlparse.hxx"
+#include <fstream>
+#include <iostream>
+#include <osl/mutex.hxx>
+#include <osl/thread.hxx>
+#ifdef __MINGW32__
+#include <tools/prewin.h>
+#include <tools/postwin.h>
+#endif
+using namespace std;
+using namespace osl;
+
+//
+// class XMLChildNode
+//
+ 
+/*****************************************************************************/
+XMLChildNode::XMLChildNode( XMLParentNode *pPar ) 
+/*****************************************************************************/
+				: pParent( pPar ) 
+{ 
+	if ( pParent )
+		pParent->AddChild( this ); 
+}
+
+
+/*****************************************************************************/
+XMLChildNode::XMLChildNode( const XMLChildNode& obj)
+/*****************************************************************************/
+:   XMLNode(obj),
+    pParent(obj.pParent){}
+
+/*****************************************************************************/
+XMLChildNode& XMLChildNode::operator=(const XMLChildNode& obj){
+/*****************************************************************************/
+	if(this != &obj){
+        pParent=obj.pParent;
+    }
+    return *this;
+}
+//
+// class XMLParentNode
+//
+
+
+/*****************************************************************************/
+XMLParentNode::~XMLParentNode()
+/*****************************************************************************/
+{
+	if( pChildList ){
+            RemoveAndDeleteAllChilds();
+            delete pChildList;
+			pChildList = NULL;
+    }
+	pChildList = NULL;
+}
+/*****************************************************************************/
+XMLParentNode::XMLParentNode( const XMLParentNode& obj)
+/*****************************************************************************/
+: XMLChildNode( obj )
+{
+	if( obj.pChildList ){
+        pChildList=new XMLChildNodeList();
+        XMLChildNode* pNode = NULL;
+        for ( sal_uLong i = 0; i < obj.pChildList->Count(); i++ ){
+			pNode = obj.pChildList->GetObject( i );
+            if( pNode != NULL){
+                switch(pNode->GetNodeType()){
+                    case XML_NODE_TYPE_ELEMENT: 
+                        AddChild( new XMLElement( *static_cast<XMLElement* >(pNode) ) ); break; 
+                    case XML_NODE_TYPE_DATA:    
+                        AddChild( new XMLData   ( *static_cast<XMLData* >   (pNode) ) ); break;
+                    case XML_NODE_TYPE_COMMENT: 
+                        AddChild( new XMLComment( *static_cast<XMLComment* >(pNode) ) ); break;
+                    case XML_NODE_TYPE_DEFAULT: 
+                        AddChild( new XMLDefault( *static_cast<XMLDefault* >(pNode) ) ); break;
+                    default:    fprintf(stdout,"XMLParentNode::XMLParentNode( const XMLParentNode& obj) strange obj");
+                }
+            }
+        }
+    }else pChildList = NULL;
+}
+/*****************************************************************************/
+XMLParentNode& XMLParentNode::operator=(const XMLParentNode& obj){
+/*****************************************************************************/
+	if(this!=&obj){
+        XMLChildNode::operator=(obj);
+        if( pChildList ){
+            RemoveAndDeleteAllChilds();
+            delete pChildList;
+			pChildList = NULL;
+        }
+        if( obj.pChildList ){
+            pChildList=new XMLChildNodeList();
+            for ( sal_uLong i = 0; i < obj.pChildList->Count(); i++ )
+			    AddChild( obj.pChildList->GetObject( i ) );
+        }else pChildList = NULL;
+
+    }
+    return *this;
+}
+/*****************************************************************************/
+void XMLParentNode::AddChild( XMLChildNode *pChild )
+/*****************************************************************************/
+{
+	if ( !pChildList )
+		pChildList = new XMLChildNodeList();
+	pChildList->Insert( pChild, LIST_APPEND );
+}
+
+/*****************************************************************************/
+void XMLParentNode::AddChild( XMLChildNode *pChild , int pos )
+/*****************************************************************************/
+{
+	if ( !pChildList )
+		pChildList = new XMLChildNodeList();
+    pChildList->Insert( pChild, pos );
+}
+
+/*****************************************************************************/
+int XMLParentNode::GetPosition( ByteString id ){
+/*****************************************************************************/
+    XMLElement* a;    
+
+    static const ByteString sEnusStr = ByteString(String::CreateFromAscii(ENGLISH_US_ISO).ToLowerAscii() , RTL_TEXTENCODING_ASCII_US ).ToLowerAscii();
+    static const ByteString sDeStr   = ByteString(String::CreateFromAscii(GERMAN_ISO2).ToLowerAscii()    , RTL_TEXTENCODING_ASCII_US ).ToLowerAscii();
+    
+    if ( pChildList ){
+        for ( sal_uLong i = 0; i < pChildList->Count(); i++ ) {
+		    XMLChildNode *pChild = pChildList->GetObject( i );
+            if ( pChild->GetNodeType() == XML_NODE_TYPE_ELEMENT ){
+			    a = static_cast<XMLElement* >(pChild);
+                ByteString elemid( a->GetId() );
+                elemid.ToLowerAscii();
+                if (   elemid.Equals( id.ToLowerAscii() ) ){
+                    ByteString elemLID( a->GetLanguageId() );
+                    elemLID.ToLowerAscii();
+                    if( elemLID.Equals( sEnusStr) ) {
+                        return i;
+                    }
+                    else if( elemLID.Equals( sDeStr) ) {
+                        return i;
+                    }
+                }
+            }
+        }
+    }
+    return -1;
+}
+
+/*****************************************************************************/
+int XMLParentNode::RemoveChild( XMLElement *pRefElement )
+/*****************************************************************************/
+{
+    XMLElement* a;
+    if ( pChildList ){
+        for ( sal_uLong i = 0; i < pChildList->Count(); i++ ) {
+		    XMLChildNode *pChild = pChildList->GetObject( i );
+            if ( pChild->GetNodeType() == XML_NODE_TYPE_ELEMENT ){
+			    a = static_cast<XMLElement* >(pChild);
+                ByteString elemid( a->GetId() );
+                elemid.ToLowerAscii();
+                ByteString elemLID( a->GetLanguageId() );
+                elemLID.ToLowerAscii();
+                ByteString pRefLID( pRefElement->GetLanguageId() );
+                pRefLID.ToLowerAscii();
+                if ( elemid.Equals(pRefElement->GetId()) 
+                    && elemLID.Equals( pRefLID ) ) 
+			    {
+                    if( pRefElement->ToOString().compareTo( a->ToOString() )==0 ){
+						pChildList->Remove( i );
+                        delete a; // Test
+                        return i;
+                    }
+                }                  
+            }
+    
+        }
+    }
+    return -1;
+}
+
+/*****************************************************************************/
+void XMLParentNode::RemoveAndDeleteAllChilds(){	
+/*****************************************************************************/
+	if ( pChildList ) {
+		for ( sal_uLong i = 0; i < pChildList->Count(); i++ )
+			delete pChildList->GetObject( i );
+		pChildList->Clear();
+	}
+}
+
+/*****************************************************************************/
+XMLElement *XMLParentNode::GetChildElement( XMLElement *pRefElement )
+/*****************************************************************************/
+{
+	for ( sal_uLong i = 0; i < pChildList->Count(); i++ ) {
+		XMLChildNode *pChild = pChildList->GetObject( i );
+		if ( pChild->GetNodeType() == XML_NODE_TYPE_ELEMENT )
+			if ((( XMLElement * ) pChild )->GetName() == 
+				pRefElement->GetName()) 
+			{
+				XMLAttributeList *pList = pRefElement->GetAttributeList();
+				if ( !pList )
+					return ( XMLElement * ) pChild;
+
+				sal_Bool bMatch = sal_False;
+				for ( sal_uLong j = 0; j < pList->Count() && bMatch; j++ ) {
+					XMLAttribute *pAttribute = pList->GetObject( j );
+					XMLAttribute *pCandidate = 
+						(( XMLElement * ) pChild )->GetAttribute( 
+							*pAttribute );
+					if ( !pCandidate || !pAttribute->IsEqual( *pCandidate ))
+						bMatch = sal_False;
+				}
+				if ( bMatch )
+					return ( XMLElement * ) pChild;
+			}
+	}
+	return NULL;
+}
+
+//
+// class XMLFile
+//
+
+/*****************************************************************************/
+sal_uInt16 XMLFile::GetNodeType()
+/*****************************************************************************/
+{
+	return XML_NODE_TYPE_FILE;
+}
+
+/*****************************************************************************/
+sal_Bool XMLFile::Write( ByteString &aFilename )
+/*****************************************************************************/
+{
+
+    if ( aFilename.Len()) {
+		// retry harder if there is a NFS problem,
+        for( int x = 1 ; x < 3 ; x++ ){	// this looks strange...yes!        
+			ofstream aFStream( aFilename.GetBuffer() , ios::out | ios::trunc ); 
+
+            if( !aFStream )		// From time to time the stream can not be opened the first time on NFS volumes, 
+			{					// I wasn't able to track this down. I think this is an NFS issue .....
+                //cerr << "ERROR: - helpex - Can't write to tempfile " << aFilename.GetBuffer() << " No#" << x << "\n";
+                TimeValue aTime;
+                aTime.Seconds = 3;
+                aTime.Nanosec = 0;
+
+                osl::Thread::wait( aTime );
+            }
+            else
+            {
+                // write out
+				Write( aFStream );
+                aFStream.close();
+                
+				// check!
+				DirEntry aTarget( aFilename );   
+                FileStat aFileStat( aTarget );  
+                
+				if( aFileStat.GetSize() < 1 )
+				{
+                    //retry
+					//cerr << "WARNING: - helpex - Can't create file " << aFilename.GetBuffer() << " No#" << x << "\n";
+                    aTarget.Kill();
+                }
+				else
+				{
+                    //everything ok!
+					return true;
+                }
+            }
+	    }
+		cerr << "ERROR: - helpex - Can't create file " << aFilename.GetBuffer() << "\nPossible reason: Disk full ? Mounted NFS volume broken ? Wrong permissions ?\n";
+        exit( -1 );
+    } 
+    cerr << "ERROR: - helpex - Empty file name\n";
+    exit( -1 );
+}
+
+
+
+void XMLFile::WriteString( ofstream &rStream, const String &sString )
+{
+	ByteString sText( sString, RTL_TEXTENCODING_UTF8 );
+	rStream << sText.GetBuffer();
+}
+
+
+sal_Bool XMLFile::Write( ofstream &rStream , XMLNode *pCur )
+{
+    XMLUtil& xmlutil = XMLUtil::Instance();
+    (void) xmlutil;
+
+    if ( !pCur )                
+		Write( rStream, this );
+	else {
+		switch( pCur->GetNodeType()) {
+			case XML_NODE_TYPE_FILE: {
+				if( GetChildList())
+					for ( sal_uLong i = 0; i < GetChildList()->Count(); i++ )
+						Write( rStream, GetChildList()->GetObject( i ));
+			}
+			break;
+			case XML_NODE_TYPE_ELEMENT: {
+				XMLElement *pElement = ( XMLElement * ) pCur;
+				rStream  << "<";
+				WriteString( rStream, pElement->GetName());
+				if ( pElement->GetAttributeList())
+					for ( sal_uLong j = 0; j < pElement->GetAttributeList()->Count(); j++ ) {
+						rStream << " ";
+						String sData(*pElement->GetAttributeList()->GetObject( j ));
+						xmlutil.QuotHTML( sData );
+						WriteString( rStream , sData );
+						rStream << "=\"";
+						sData=pElement->GetAttributeList()->GetObject( j )->GetValue();
+						xmlutil.QuotHTML(  sData );
+						WriteString( rStream , sData  );
+						rStream << "\"";
+					}
+				if ( !pElement->GetChildList())
+					rStream << "/>";
+				else {
+					rStream << ">";
+					for ( sal_uLong k = 0; k < pElement->GetChildList()->Count(); k++ )
+						Write( rStream, pElement->GetChildList()->GetObject( k ));
+					rStream << "</";
+					WriteString( rStream, pElement->GetName());
+					rStream << ">";
+   				}				   
+			}
+			break;
+			case XML_NODE_TYPE_DATA: {
+				XMLData *pData = ( XMLData * ) pCur;
+				String sData( pData->GetData());
+                xmlutil.QuotHTML( sData );
+				WriteString( rStream, sData );
+			}
+			break;
+			case XML_NODE_TYPE_COMMENT: {
+				XMLComment *pComment = ( XMLComment * ) pCur;
+				rStream << "<!--";
+				WriteString( rStream, pComment->GetComment());
+				rStream << "-->"; 
+			}
+			break;  
+			case XML_NODE_TYPE_DEFAULT: {
+				XMLDefault *pDefault = ( XMLDefault * ) pCur;
+				WriteString( rStream, pDefault->GetDefault());
+			}
+			break;  
+		}
+	}
+	return sal_True; 
+} 
+
+
+void XMLFile::Print( XMLNode *pCur, sal_uInt16 nLevel )
+{
+
+	if ( !pCur ) 
+		Print( this );
+	else {
+		switch( pCur->GetNodeType()) {
+			case XML_NODE_TYPE_FILE: {
+				if( GetChildList())
+					for ( sal_uLong i = 0; i < GetChildList()->Count(); i++ )
+						Print( GetChildList()->GetObject( i ));
+			}
+			break;
+			case XML_NODE_TYPE_ELEMENT: {
+				XMLElement *pElement = ( XMLElement * ) pCur;
+
+				fprintf( stdout, "<%s", ByteString( pElement->GetName(), RTL_TEXTENCODING_UTF8 ).GetBuffer());
+				if ( pElement->GetAttributeList())
+					for ( sal_uLong j = 0; j < pElement->GetAttributeList()->Count(); j++ ){
+						ByteString aAttrName( *pElement->GetAttributeList()->GetObject( j ), RTL_TEXTENCODING_UTF8 );
+                        if( !aAttrName.EqualsIgnoreCaseAscii( XML_LANG ) ) { 
+                            fprintf( stdout, " %s=\"%s\"", 
+                                aAttrName.GetBuffer(),
+							    ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),
+								    RTL_TEXTENCODING_UTF8 ).GetBuffer());
+                        }
+                    }
+				if ( !pElement->GetChildList())
+					fprintf( stdout, "/>" );
+				else {
+					fprintf( stdout, ">" );
+					for ( sal_uLong k = 0; k < pElement->GetChildList()->Count(); k++ )
+						Print( pElement->GetChildList()->GetObject( k ), nLevel + 1 );
+					fprintf( stdout, "</%s>", ByteString( pElement->GetName(), RTL_TEXTENCODING_UTF8 ).GetBuffer());
+				}				   
+			}
+			break;
+			case XML_NODE_TYPE_DATA: {
+				XMLData *pData = ( XMLData * ) pCur;
+				String sData = pData->GetData();
+				fprintf( stdout, "%s", ByteString( sData, RTL_TEXTENCODING_UTF8 ).GetBuffer());
+			}
+			break;
+			case XML_NODE_TYPE_COMMENT: {
+				XMLComment *pComment = ( XMLComment * ) pCur;
+				fprintf( stdout, "<!--%s-->", ByteString( pComment->GetComment(), RTL_TEXTENCODING_UTF8 ).GetBuffer());
+			}
+			break;
+			case XML_NODE_TYPE_DEFAULT: {
+				XMLDefault *pDefault = ( XMLDefault * ) pCur;
+				fprintf( stdout, "%s", ByteString( pDefault->GetDefault(), RTL_TEXTENCODING_UTF8 ).GetBuffer());
+			}
+			break;
+		}
+	}
+}
+XMLFile::~XMLFile()
+{
+	if( XMLStrings != NULL ){
+		XMLHashMap::iterator pos = XMLStrings->begin();
+		for( ; pos != XMLStrings->end() ; ++pos ){				
+			delete pos->second;				// Check and delete content also ?
+		}
+		delete XMLStrings;
+		XMLStrings = NULL;
+	}
+}
+/*****************************************************************************/
+XMLFile::XMLFile( const String &rFileName ) // the file name, empty if created from memory stream
+/*****************************************************************************/
+				: XMLParentNode( NULL ), 
+				  sFileName    ( rFileName ), 
+				  ID           ( "id" ),
+                  OLDREF       ( "oldref" ),
+				  XML_LANG     ( "xml-lang" ),
+				  XMLStrings   ( NULL )
+                  
+{
+//	nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("bookmark_value"),RTL_TEXTENCODING_ASCII_US) , sal_True) );
+	nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("bookmark"),RTL_TEXTENCODING_ASCII_US) , sal_True) );
+    nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("variable"),RTL_TEXTENCODING_ASCII_US) , sal_True) );
+	nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("paragraph"),RTL_TEXTENCODING_ASCII_US) , sal_True) );
+	nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("alt"),RTL_TEXTENCODING_ASCII_US) , sal_True) );
+	nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("caption"),RTL_TEXTENCODING_ASCII_US) , sal_True) );
+	nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("title"),RTL_TEXTENCODING_ASCII_US) , sal_True) );
+	nodes_localize.insert( TagMap::value_type(ByteString(String::CreateFromAscii("link"),RTL_TEXTENCODING_ASCII_US) , sal_True) );
+}
+/*****************************************************************************/
+void XMLFile::Extract( XMLFile *pCur )
+/*****************************************************************************/
+{
+	if( XMLStrings != NULL ) delete XMLStrings; // Elements ?
+	
+	XMLStrings = new XMLHashMap();
+   	if ( !pCur ) 
+        SearchL10NElements( this );
+	else {
+		if( pCur->GetNodeType()==XML_NODE_TYPE_FILE) {
+            SearchL10NElements(pCur);
+		}
+	}
+}
+
+/*****************************************************************************/
+void XMLFile::View(){
+/*****************************************************************************/
+	XMLElement* cur;
+	for(XMLHashMap::iterator pos=XMLStrings->begin(); pos!=XMLStrings->end();++pos){
+		fprintf(stdout,"\nid=%s\n",(pos->first).GetBuffer());
+		LangHashMap* elem=pos->second;
+		for(LangHashMap::iterator pos2=elem->begin(); pos2!=elem->end();++pos2){	
+			fprintf( stdout,"\nlanguage=%s\n",(pos2->first).GetBuffer() );
+			cur=pos2->second;
+			fprintf(stdout,"\n%s\n",((XMLElement*)cur)->ToOString().getStr());
+			
+		}
+	}
+}
+
+/*****************************************************************************/
+void XMLFile::InsertL10NElement( XMLElement* pElement ){
+/*****************************************************************************/
+	ByteString tmpStr,id,oldref,language("");
+	LangHashMap* elem;
+
+    if( pElement->GetAttributeList() != NULL ){
+        for ( sal_uLong j = 0; j < pElement->GetAttributeList()->Count(); j++ ){
+		    tmpStr=ByteString( *pElement->GetAttributeList()->GetObject( j ),RTL_TEXTENCODING_UTF8 );
+		    if( tmpStr.CompareTo(ID)==COMPARE_EQUAL  ){	// Get the "id" Attribute
+			    id = ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),RTL_TEXTENCODING_UTF8 );
+		    }
+		    if( tmpStr.CompareTo( XML_LANG ) == COMPARE_EQUAL ){	// Get the "xml-lang" Attribute
+			    language = ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),RTL_TEXTENCODING_UTF8 );
+		    }
+
+	    }
+    }else{ 
+        fprintf(stdout,"XMLFile::InsertL10NElement: No AttributeList found");
+        fprintf(stdout,"++++++++++++++++++++++++++++++++++++++++++++++++++");
+        Print( pElement , 0 );
+        fprintf(stdout,"++++++++++++++++++++++++++++++++++++++++++++++++++");
+    }
+
+	XMLHashMap::iterator pos = XMLStrings->find( id );
+	if( pos == XMLStrings->end() ){				// No instanze , create new one
+        elem = new LangHashMap();
+        (*elem)[ language ]=pElement;
+		XMLStrings->insert( XMLHashMap::value_type( id , elem ) );
+        order.push_back( id );
+	}else{									// Already there 
+        elem=pos->second;
+        if ( (*elem)[ language ] )
+        {
+            fprintf(stdout,"Error: Duplicated entry. ID = %s  LANG = %s in File %s\n", id.GetBuffer(), language.GetBuffer(), ByteString( sFullName,RTL_TEXTENCODING_ASCII_US ).GetBuffer() );
+            exit( -1 );
+        }
+        (*elem)[ language ]=pElement;
+	}
+}
+/*****************************************************************************/
+void XMLFile::showType(XMLParentNode* node){
+/*****************************************************************************/
+	switch (node->GetNodeType()){
+		case XML_NODE_TYPE_ELEMENT: fprintf(stdout,"ELEMENT\n") ;break;
+		case XML_NODE_TYPE_FILE:    fprintf(stdout,"FILE\n")    ;break;
+		case XML_NODE_TYPE_COMMENT: fprintf(stdout,"COMMENT\n") ;break;
+		case XML_NODE_TYPE_DATA:    fprintf(stdout,"DATA\n")    ;break;
+		case XML_NODE_TYPE_DEFAULT: fprintf(stdout,"DEFAULT\n") ;break;
+		default: break;	
+	}
+}
+XMLFile::XMLFile() 
+/*****************************************************************************/
+				: XMLParentNode( NULL ), 
+				  ID           ( "id" ),
+                  OLDREF       ( "oldref" ),
+				  XML_LANG     ( "xml-lang" ),
+				  XMLStrings   ( NULL ){};
+
+
+XMLFile::XMLFile( const XMLFile& obj ) 
+/*****************************************************************************/
+				: XMLParentNode( obj ), 
+				  sFileName    ( obj.sFileName ), 
+				  ID           ( "id" ),
+                  OLDREF       ( "oldref" ),
+				  XML_LANG     ( "xml-lang" ),
+				  XMLStrings   ( NULL )
+{
+	if( this!=&obj )
+	{
+        nodes_localize  =obj.nodes_localize;
+        order           =obj.order;
+        
+	}
+}
+/*****************************************************************************/
+XMLFile& XMLFile::operator=(const XMLFile& obj){
+/*****************************************************************************/
+    if( this!=&obj ){
+
+        XMLParentNode::operator=(obj);
+        
+        nodes_localize  =obj.nodes_localize;
+        order           =obj.order;
+        
+		if( XMLStrings )    delete XMLStrings;
+        
+		if( obj.XMLStrings )
+        {
+            XMLStrings = new XMLHashMap(); 
+	        for( XMLHashMap::iterator pos = obj.XMLStrings->begin() ; pos != obj.XMLStrings->end() ; ++pos )
+            {
+		        LangHashMap* elem=pos->second;
+		        LangHashMap* newelem = new LangHashMap();
+                for(LangHashMap::iterator pos2=elem->begin(); pos2!=elem->end();++pos2){	
+                    (*newelem)[ pos2->first ] = new XMLElement( *pos2->second );
+                    printf("*");
+		        }
+                (*XMLStrings)[ pos->first ] = newelem;
+            }
+        }                                                                                                                                    
+    }
+    printf("done!\n");
+    return *this;
+}
+
+
+/*****************************************************************************/
+void XMLFile::SearchL10NElements( XMLParentNode *pCur , int pos)
+/*****************************************************************************/
+{
+	static const ByteString LOCALIZE("localize");
+	static const ByteString THEID("id");
+	bool bInsert	= true;
+	if ( !pCur ) 
+		SearchL10NElements( this  );
+	else {
+		switch( pCur->GetNodeType()) {
+			case XML_NODE_TYPE_FILE: {
+                XMLParentNode* pElement;
+                if( GetChildList()){
+                    for ( sal_uLong i = 0; i < GetChildList()->Count(); i++ ){
+                        pElement = (XMLParentNode*) GetChildList()->GetObject( i );
+                        if( pElement->GetNodeType() ==  XML_NODE_TYPE_ELEMENT ) SearchL10NElements( pElement , i);
+                    }
+                }
+            }
+			break;
+			case XML_NODE_TYPE_ELEMENT: {
+				XMLElement *pElement = ( XMLElement * ) pCur;
+        		ByteString sName(pElement->GetName(),RTL_TEXTENCODING_ASCII_US);
+                ByteString language,tmpStrVal,oldref;					
+				if ( pElement->GetAttributeList()){
+					for ( sal_uLong j = 0 , cnt = pElement->GetAttributeList()->Count(); j < cnt && bInsert; j++ ){
+						const ByteString tmpStr( *pElement->GetAttributeList()->GetObject( j ),RTL_TEXTENCODING_UTF8 );
+						if( tmpStr.CompareTo(THEID)==COMPARE_EQUAL  ){	// Get the "id" Attribute
+							tmpStrVal=ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),RTL_TEXTENCODING_UTF8 );
+                            //printf("Checking id = %s\n",tmpStrVal.GetBuffer() );
+						}
+						if( tmpStr.CompareTo(LOCALIZE)==COMPARE_EQUAL  ){	// Get the "localize" Attribute
+							bInsert=false;
+						}
+						if( tmpStr.CompareTo(XML_LANG)==COMPARE_EQUAL ){	// Get the "xml-lang" Attribute
+							language=ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),RTL_TEXTENCODING_UTF8 );
+						}
+                        if( tmpStr.CompareTo(OLDREF)==COMPARE_EQUAL ){	// Get the "oldref" Attribute
+		                    oldref=ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),RTL_TEXTENCODING_UTF8 );
+		                }
+					}
+					pElement->SetLanguageId ( language );
+					pElement->SetId         ( tmpStrVal.GetBuffer() );
+                    pElement->SetOldRef     ( oldref  );
+                    pElement->SetPos( pos );
+				}
+						
+				if ( bInsert && ( nodes_localize.find( sName.ToLowerAscii() ) != nodes_localize.end() ) )									
+					InsertL10NElement(pElement);
+				else if ( bInsert && pElement->GetChildList() ){
+					for ( sal_uLong k = 0; k < pElement->GetChildList()->Count(); k++ )
+						SearchL10NElements( (XMLParentNode*) pElement->GetChildList()->GetObject( k ) , k);
+				}				   
+            }
+			break;
+			case XML_NODE_TYPE_DATA: {
+			}
+			break;
+			case XML_NODE_TYPE_COMMENT: {
+			}
+			break;
+			case XML_NODE_TYPE_DEFAULT: {
+			}
+			break;
+		}
+	}
+}
+
+/*****************************************************************************/
+bool XMLFile::CheckExportStatus( XMLParentNode *pCur )
+/*****************************************************************************/
+{
+    static bool bStatusExport = true;
+    const ByteString LOCALIZE("localize");
+    const ByteString STATUS("status");
+    const ByteString PUBLISH("PUBLISH");
+    const ByteString DEPRECATED("DEPRECATED");
+
+    const ByteString TOPIC("topic");
+	bool bInsert	= true;
+	if ( !pCur ) 
+		CheckExportStatus( this );
+	else {
+        switch( pCur->GetNodeType()) {
+			case XML_NODE_TYPE_FILE: {
+                XMLParentNode* pElement;
+                if( GetChildList()){
+                    for ( sal_uLong i = 0; i < GetChildList()->Count(); i++ ){
+                        pElement = (XMLParentNode*) GetChildList()->GetObject( i );
+                        if( pElement->GetNodeType() ==  XML_NODE_TYPE_ELEMENT ) CheckExportStatus( pElement );//, i);
+                    }
+                }
+            }
+			break;
+			case XML_NODE_TYPE_ELEMENT: {
+				XMLElement *pElement = ( XMLElement * ) pCur;
+        		ByteString sName(pElement->GetName(),RTL_TEXTENCODING_ASCII_US);
+                if( sName.EqualsIgnoreCaseAscii( TOPIC ) ){
+				    if ( pElement->GetAttributeList()){
+					    for ( sal_uLong j = 0 , cnt = pElement->GetAttributeList()->Count(); j < cnt && bInsert; j++ ){
+						    const ByteString tmpStr( *pElement->GetAttributeList()->GetObject( j ),RTL_TEXTENCODING_UTF8 );
+                            if( tmpStr.EqualsIgnoreCaseAscii( STATUS ) ){
+							    ByteString tmpStrVal=ByteString( pElement->GetAttributeList()->GetObject( j )->GetValue(),RTL_TEXTENCODING_UTF8 );
+                                if( !tmpStrVal.EqualsIgnoreCaseAscii( PUBLISH )  &&
+                                    !tmpStrVal.EqualsIgnoreCaseAscii( DEPRECATED )){
+                                    bStatusExport = false;
+                                }
+						    }
+
+                        }
+                    }
+                }
+				else if ( pElement->GetChildList() ){
+					for ( sal_uLong k = 0; k < pElement->GetChildList()->Count(); k++ )
+						CheckExportStatus( (XMLParentNode*) pElement->GetChildList()->GetObject( k ) );//, k);
+				}				   
+            }
+			break;
+		}
+	}
+    return bStatusExport;
+}
+
+/*****************************************************************************/
+sal_uInt16 XMLElement::GetNodeType()
+/*****************************************************************************/
+{
+	return XML_NODE_TYPE_ELEMENT;
+}
+
+/*****************************************************************************/
+XMLElement::XMLElement(const XMLElement& obj)
+/*****************************************************************************/
+	:  		
+                XMLParentNode   ( obj ),    
+				sElementName    ( obj.sElementName ), 
+				pAttributes     ( NULL ),
+				project         ( obj.project ), 
+				filename        ( obj.filename ), 
+				id              ( obj.id ), 
+				sOldRef         ( obj.sOldRef ), 
+				resourceType    ( obj.resourceType ), 
+				languageId      ( obj.languageId ),
+                nPos            ( obj.nPos )    
+	 
+{
+    if ( obj.pAttributes ){
+        pAttributes = new XMLAttributeList();
+        for ( sal_uLong i = 0; i < obj.pAttributes->Count(); i++ )
+			AddAttribute( *obj.pAttributes->GetObject( i ) , obj.pAttributes->GetObject( i )->GetValue() );
+    }
+}
+
+/*****************************************************************************/
+XMLElement& XMLElement::operator=(const XMLElement& obj){
+/*****************************************************************************/
+    if( this!=&obj ){
+        XMLParentNode::operator=(obj);
+        sElementName    =obj.sElementName; 
+		project         =obj.project; 
+		filename        =obj.filename; 
+		id              =obj.id; 
+		sOldRef         =obj.sOldRef; 
+		resourceType    =obj.resourceType; 
+		languageId      =obj.languageId;
+        nPos            =obj.nPos;
+
+        if ( pAttributes ){
+            for ( sal_uLong i = 0; i < pAttributes->Count(); i++ )
+			    delete pAttributes->GetObject( i );
+	        delete pAttributes;
+	    }
+        if ( obj.pAttributes ){
+            pAttributes         =new XMLAttributeList();
+            for ( sal_uLong i = 0; i < obj.pAttributes->Count(); i++ )
+			    AddAttribute( *obj.pAttributes->GetObject( i ) , obj.pAttributes->GetObject( i )->GetValue() );
+        }
+    }
+    return *this;
+}
+
+/*****************************************************************************/
+void XMLElement::AddAttribute( const String &rAttribute, const String &rValue )
+/*****************************************************************************/
+{
+	if ( !pAttributes )
+		pAttributes = new XMLAttributeList();
+	pAttributes->Insert( new XMLAttribute( rAttribute, rValue ), LIST_APPEND );
+}
+
+/*****************************************************************************/
+void XMLElement::ChangeLanguageTag( const String &rValue ){
+/*****************************************************************************/
+    static const String rName = String::CreateFromAscii("xml-lang");
+    SetLanguageId( ByteString(rValue,RTL_TEXTENCODING_UTF8) );
+    if ( pAttributes ){
+        for ( sal_uLong i = 0; i < pAttributes->Count(); i++ ){
+            if ( *pAttributes->GetObject( i ) == rName ){
+                pAttributes->GetObject( i )->setValue(rValue);
+            }
+        }
+    }
+    XMLChildNode* pNode  = NULL;
+    XMLElement*   pElem  = NULL;  
+    XMLChildNodeList* pCList = GetChildList();
+    
+    if( pCList != NULL ){
+        for ( sal_uLong i = 0; i < pCList->Count(); i++ ){
+			pNode = pCList->GetObject( i );
+            if( pNode != NULL && pNode->GetNodeType() == XML_NODE_TYPE_ELEMENT ){
+                pElem = static_cast< XMLElement* >(pNode);
+                pElem->ChangeLanguageTag( rValue );
+                pElem->SetLanguageId( ByteString(rValue,RTL_TEXTENCODING_UTF8) );
+                pElem  = NULL;
+                pNode  = NULL;
+            }
+        }
+        pCList = NULL;
+    }
+}
+/*****************************************************************************/
+XMLAttribute *XMLElement::GetAttribute( const String &rName	)
+/*****************************************************************************/
+{
+	if ( pAttributes )
+		for ( sal_uLong i = 0; i < pAttributes->Count(); i++ )
+			if ( *pAttributes->GetObject( i ) == rName )
+				return pAttributes->GetObject( i );
+	
+	return NULL;
+}
+
+/*****************************************************************************/
+XMLElement::~XMLElement()
+/*****************************************************************************/
+{
+	if ( pAttributes ) {
+		for ( sal_uLong i = 0; i < pAttributes->Count(); i++ )
+			delete pAttributes->GetObject( i );
+	
+		delete pAttributes;
+		pAttributes = NULL;
+	}
+}
+/*****************************************************************************/
+bool	XMLElement::Equals(OUString refStr){
+/*****************************************************************************/
+	return  refStr.equals( ToOUString() );
+}
+
+/*****************************************************************************/
+OString XMLElement::ToOString(){
+/*****************************************************************************/
+    OUString ouEmpty;
+
+	OUStringBuffer* buffer = new OUStringBuffer();
+	Print( this, *buffer , true );
+
+	OString result( (sal_Unicode* )buffer->getStr(), buffer->getLength() , RTL_TEXTENCODING_UTF8 );
+	delete buffer;
+	return result;
+}
+/*****************************************************************************/
+OUString XMLElement::ToOUString(){
+/*****************************************************************************/
+	OUStringBuffer* buffer = new OUStringBuffer();
+	Print(this,*buffer,true);
+	OUString result=buffer->makeStringAndClear();
+	String xy(result.getStr());
+    result=OUString(xy);
+	delete buffer;
+	return result;
+}
+/*****************************************************************************/		
+void XMLElement::Print(XMLNode *pCur, OUStringBuffer& buffer , bool rootelement ){
+/*****************************************************************************/
+    //YD FIXME somewhere COMMENT is defined as 4!
+    static const String _COMMENT = String::CreateFromAscii("comment");
+    static const OUString XML_LANG ( OUString::createFromAscii("xml-lang") );
+
+    if(pCur!=NULL){
+        if(rootelement){
+            XMLElement *pElement = ( XMLElement * ) pCur;
+            if ( pElement->GetAttributeList()){
+                if ( pElement->GetChildList()){
+                    XMLChildNode* tmp=NULL;
+                    for ( sal_uLong k = 0; k < pElement->GetChildList()->Count(); k++ ){
+				        tmp=pElement->GetChildList()->GetObject( k );
+                        Print( tmp, buffer , false);
+                    }
+				}			   
+			}
+        }
+        else{
+
+        switch( pCur->GetNodeType()) {
+			case XML_NODE_TYPE_ELEMENT: {
+				XMLElement *pElement = ( XMLElement * ) pCur;
+                
+                if(  !pElement->GetName().EqualsIgnoreCaseAscii( _COMMENT ) ){
+                    buffer.append( OUString::createFromAscii("\\<") ); 
+				    buffer.append( pElement->GetName() );
+				    if ( pElement->GetAttributeList()){
+					    for ( sal_uLong j = 0; j < pElement->GetAttributeList()->Count(); j++ ){
+						
+                            OUString aAttrName( *pElement->GetAttributeList()->GetObject( j ) );
+                            if( !aAttrName.equalsIgnoreAsciiCase( XML_LANG ) ) {
+                                buffer.append( OUString::createFromAscii(" ") );
+                                buffer.append( aAttrName );
+                                buffer.append( OUString::createFromAscii("=") );
+						        buffer.append( OUString::createFromAscii("\\\"") );
+					            buffer.append( pElement->GetAttributeList()->GetObject( j )->GetValue() ); 
+						        buffer.append( OUString::createFromAscii("\\\"") );
+                            }
+					    }
+                    }
+				    if ( !pElement->GetChildList())
+					    buffer.append( OUString::createFromAscii("/\\>") );
+				    else {
+					    buffer.append( OUString::createFromAscii("\\>") );
+                        XMLChildNode* tmp=NULL;
+                        for ( sal_uLong k = 0; k < pElement->GetChildList()->Count(); k++ ){
+						    tmp=pElement->GetChildList()->GetObject( k );
+                            Print( tmp, buffer , false);
+                        }
+					    buffer.append( OUString::createFromAscii("\\</") );
+				        buffer.append( pElement->GetName() );
+                        buffer.append( OUString::createFromAscii("\\>") );
+	                } 
+                }     
+			}
+			break;
+			case XML_NODE_TYPE_DATA: {
+				XMLData *pData = ( XMLData * ) pCur;
+				String sData = pData->GetData();
+                buffer.append( sData );
+			}
+			break;
+			case XML_NODE_TYPE_COMMENT: {
+				XMLComment *pComment = ( XMLComment * ) pCur;
+				buffer.append( OUString::createFromAscii("<!--") ); 
+			    buffer.append( pComment->GetComment() );
+			    buffer.append( OUString::createFromAscii("-->") );
+			}
+			break;
+			case XML_NODE_TYPE_DEFAULT: {
+				XMLDefault *pDefault = ( XMLDefault * ) pCur;
+				buffer.append( pDefault->GetDefault() );
+			}
+			break;
+		}
+        }
+    }else {
+        fprintf(stdout,"\n#+------Error: NULL Pointer in XMLELement::Print------+#\n");
+        return;
+    }
+}
+
+
+//
+// class XMLData
+//
+/*****************************************************************************/
+XMLData::XMLData(const XMLData& obj)
+/*****************************************************************************/
+	: XMLChildNode( obj ), 
+      sData( obj.sData ) , 
+      isNewCreated ( obj.isNewCreated ){}
+	 
+/*****************************************************************************/
+XMLData& XMLData::operator=(const XMLData& obj){
+/*****************************************************************************/
+	if( this!=&obj ){
+        XMLChildNode::operator=( obj );
+        sData           = obj.sData;
+        isNewCreated    = obj.isNewCreated;
+    }
+    return *this;
+}
+/*****************************************************************************/
+void XMLData::AddData( const String &rData) { 
+/*****************************************************************************/
+	sData += rData; 
+}
+
+/*****************************************************************************/
+sal_uInt16 XMLData::GetNodeType()
+/*****************************************************************************/
+{
+	return XML_NODE_TYPE_DATA;
+}
+
+//
+// class XMLComment
+//
+
+/*****************************************************************************/
+sal_uInt16 XMLComment::GetNodeType()
+/*****************************************************************************/
+{
+	return XML_NODE_TYPE_COMMENT;
+}
+/*****************************************************************************/
+XMLComment::XMLComment(const XMLComment& obj)
+/*****************************************************************************/
+	: XMLChildNode( obj ), 
+      sComment( obj.sComment ){}
+	 
+/*****************************************************************************/
+XMLComment& XMLComment::operator=(const XMLComment& obj){
+/*****************************************************************************/	
+	if( this!=&obj ){
+        XMLChildNode::operator=( obj );
+        sComment        = obj.sComment;
+    }
+    return *this;
+}
+
+//
+// class XMLDefault
+//
+
+/*****************************************************************************/
+sal_uInt16 XMLDefault::GetNodeType()
+/*****************************************************************************/
+{
+	return XML_NODE_TYPE_DEFAULT;
+}
+/*****************************************************************************/
+XMLDefault::XMLDefault(const XMLDefault& obj)
+/*****************************************************************************/
+	: XMLChildNode( obj ), 
+      sDefault( obj.sDefault){}
+	 
+/*****************************************************************************/
+XMLDefault& XMLDefault::operator=(const XMLDefault& obj){
+/*****************************************************************************/
+	if( this!=&obj ){
+        XMLChildNode::operator=( obj );
+        sDefault        = obj.sDefault;
+    }
+    return *this;
+}
+
+
+//
+// class SimpleXMLParser
+//
+
+#define XML_CHAR_TO_OUSTRING(x) OStringToOUString(OString(x), RTL_TEXTENCODING_UTF8)
+#define XML_CHAR_N_TO_OUSTRING(x,n) OStringToOUString(OString(x,n), RTL_TEXTENCODING_UTF8 )
+
+
+/*****************************************************************************/
+SimpleXMLParser::SimpleXMLParser()
+/*****************************************************************************/
+				: pXMLFile( NULL )
+{
+    aParser = XML_ParserCreate( NULL );
+	XML_SetUserData( aParser, this );
+	XML_SetElementHandler( aParser, (XML_StartElementHandler) StartElementHandler, (XML_EndElementHandler) EndElementHandler );
+	XML_SetCharacterDataHandler( aParser, (XML_CharacterDataHandler) CharacterDataHandler );
+	XML_SetCommentHandler( aParser, (XML_CommentHandler) CommentHandler );
+	XML_SetDefaultHandler( aParser, (XML_DefaultHandler) DefaultHandler );
+}
+
+/*****************************************************************************/
+SimpleXMLParser::~SimpleXMLParser()
+/*****************************************************************************/
+{
+	XML_ParserFree( aParser );
+}
+
+/*****************************************************************************/
+void SimpleXMLParser::StartElementHandler( 
+	void *userData, const XML_Char *name, const XML_Char **atts )
+/*****************************************************************************/
+{
+	(( SimpleXMLParser * ) userData )->StartElement( name, atts );
+}
+
+
+/*****************************************************************************/
+void SimpleXMLParser::EndElementHandler( 
+	void *userData, const XML_Char *name )
+/*****************************************************************************/
+{
+	(( SimpleXMLParser * ) userData )->EndElement( name );
+}
+
+/*****************************************************************************/
+void SimpleXMLParser::CharacterDataHandler( 
+	void *userData, const XML_Char *s, int len )
+/*****************************************************************************/
+{
+	(( SimpleXMLParser * ) userData )->CharacterData( s, len );
+}
+
+/*****************************************************************************/
+void SimpleXMLParser::CommentHandler( 
+	void *userData, const XML_Char *data )
+/*****************************************************************************/
+{
+	(( SimpleXMLParser * ) userData )->Comment( data );
+}
+
+/*****************************************************************************/
+void SimpleXMLParser::DefaultHandler( 
+	void *userData, const XML_Char *s, int len )
+/*****************************************************************************/
+{
+	(( SimpleXMLParser * ) userData )->Default( s, len );
+}
+
+/*****************************************************************************/
+void SimpleXMLParser::StartElement( 
+	const XML_Char *name, const XML_Char **atts )
+/*****************************************************************************/
+{
+	String sElementName = String( XML_CHAR_TO_OUSTRING( name ));
+	XMLElement *pElement = new XMLElement( sElementName, ( XMLParentNode * ) pCurNode );
+	pCurNode = pElement;
+	pCurData = NULL;
+
+	int i = 0;
+	while( atts[i] ) {
+		pElement->AddAttribute(
+			String( XML_CHAR_TO_OUSTRING( atts[ i ] )), 
+			String( XML_CHAR_TO_OUSTRING( atts[ i + 1 ] ))); 
+		i += 2;	
+	}
+}
+
+/*****************************************************************************/
+void SimpleXMLParser::EndElement( const XML_Char *name )
+/*****************************************************************************/
+{
+	// This variable is not used at all, but the the sax C interface can't be changed
+    // To prevent warnings this dummy assignment is used
+    // +++
+    (void) name;
+
+    pCurNode = pCurNode->GetParent();
+	pCurData = NULL;
+}
+
+/*****************************************************************************/
+void SimpleXMLParser::CharacterData( 
+	const XML_Char *s, int len )
+/*****************************************************************************/
+{
+	if ( !pCurData ){
+		String x=String( XML_CHAR_N_TO_OUSTRING( s, len ));
+		XMLUtil::UnQuotHTML(x);
+		pCurData = new XMLData( x , pCurNode );
+	}else{
+		String x=String( XML_CHAR_N_TO_OUSTRING( s, len ));
+		XMLUtil::UnQuotHTML(x);
+		pCurData->AddData( x );
+
+	}
+}
+
+/*****************************************************************************/
+void SimpleXMLParser::Comment(
+	const XML_Char *data )
+/*****************************************************************************/
+{
+	pCurData = NULL;
+		new XMLComment( String( XML_CHAR_TO_OUSTRING( data )), pCurNode );
+}
+
+/*****************************************************************************/
+void SimpleXMLParser::Default( 
+	const XML_Char *s, int len )
+/*****************************************************************************/
+{
+	pCurData = NULL;
+	new XMLDefault( 
+		String( XML_CHAR_N_TO_OUSTRING( s, len )), pCurNode ); 
+}
+
+/*****************************************************************************/
+XMLFile *SimpleXMLParser::Execute( const String &rFullFileName , const String &rFileName, XMLFile* pXMLFileIn )
+/*****************************************************************************/
+{
+//	printf("DBG: SimpleXMLParser::Execute( %s )", ByteString( rFileName , RTL_TEXTENCODING_ASCII_US ).GetBuffer() );
+    aErrorInformation.eCode = XML_ERROR_NONE;
+	aErrorInformation.nLine = 0;
+	aErrorInformation.nColumn = 0;
+	aErrorInformation.sMessage = String::CreateFromAscii( "ERROR: Unable to open file " );
+	aErrorInformation.sMessage += rFileName;
+
+	SvFileStream aStream( rFileName, STREAM_STD_READ );
+
+	if ( !aStream.IsOpen())
+		return NULL;
+
+	SvMemoryStream aMemStream;
+	aStream >> aMemStream;
+	aMemStream.Seek( 0 );
+
+	aStream.Close();
+
+    pXMLFile = pXMLFileIn;
+    pXMLFile->SetName( rFileName );
+    pXMLFile->SetFullName( rFullFileName );
+
+	return Execute( &aMemStream );
+}
+
+/*****************************************************************************/
+XMLFile *SimpleXMLParser::Execute( SvMemoryStream *pStream )
+/*****************************************************************************/
+{
+	if ( !pXMLFile )
+		pXMLFile = new XMLFile( String());
+
+	pCurNode = pXMLFile;	   
+	pCurData = NULL; 
+
+	sal_uLong nPos = pStream->Tell();
+	pStream->Seek( STREAM_SEEK_TO_END );
+
+	aErrorInformation.eCode = XML_ERROR_NONE;
+	aErrorInformation.nLine = 0;
+	aErrorInformation.nColumn = 0;
+	if ( pXMLFile->GetName().Len()) {
+		aErrorInformation.sMessage = String::CreateFromAscii( "File " );
+		aErrorInformation.sMessage += pXMLFile->GetName();
+		aErrorInformation.sMessage += String::CreateFromAscii( " parsed succesfully" );
+	}
+	else
+		aErrorInformation.sMessage = String::CreateFromAscii( "XML-File parsed successfully" );
+
+	if ( !XML_Parse(
+		aParser, ( char * ) pStream->GetData() + nPos, pStream->Tell() - nPos, sal_True ))
+	{
+		aErrorInformation.eCode = XML_GetErrorCode( aParser );
+		aErrorInformation.nLine = XML_GetErrorLineNumber( aParser );
+		aErrorInformation.nColumn = XML_GetErrorColumnNumber( aParser );
+
+		aErrorInformation.sMessage = String::CreateFromAscii( "ERROR: " );
+		if ( pXMLFile->GetName().Len()) 
+			aErrorInformation.sMessage += pXMLFile->GetName();
+		else
+			aErrorInformation.sMessage += String::CreateFromAscii( "XML-File" );
+		aErrorInformation.sMessage += String::CreateFromAscii( " (" );
+		aErrorInformation.sMessage += String::CreateFromInt64( aErrorInformation.nLine );
+		aErrorInformation.sMessage += String::CreateFromAscii( "," );
+		aErrorInformation.sMessage += String::CreateFromInt64( aErrorInformation.nColumn );
+		aErrorInformation.sMessage += String::CreateFromAscii( "): " );
+
+		switch( aErrorInformation.eCode ) {
+  			case XML_ERROR_NO_MEMORY: aErrorInformation.sMessage += String::CreateFromAscii( "No memory" ); break;
+  			case XML_ERROR_SYNTAX: aErrorInformation.sMessage += String::CreateFromAscii( "Syntax" ); break;
+  			case XML_ERROR_NO_ELEMENTS: aErrorInformation.sMessage += String::CreateFromAscii( "No elements" ); break;
+  			case XML_ERROR_INVALID_TOKEN: aErrorInformation.sMessage += String::CreateFromAscii( "Invalid token" ); break;
+  			case XML_ERROR_UNCLOSED_TOKEN: aErrorInformation.sMessage += String::CreateFromAscii( "Unclosed token" ); break;
+  			case XML_ERROR_PARTIAL_CHAR: aErrorInformation.sMessage += String::CreateFromAscii( "Partial char" ); break;
+  			case XML_ERROR_TAG_MISMATCH: aErrorInformation.sMessage += String::CreateFromAscii( "Tag mismatch" ); break;
+  			case XML_ERROR_DUPLICATE_ATTRIBUTE: aErrorInformation.sMessage += String::CreateFromAscii( "Dublicat attribute" ); break;
+  			case XML_ERROR_JUNK_AFTER_DOC_ELEMENT: aErrorInformation.sMessage += String::CreateFromAscii( "Junk after doc element" ); break;
+  			case XML_ERROR_PARAM_ENTITY_REF: aErrorInformation.sMessage += String::CreateFromAscii( "Param entity ref" ); break;
+  			case XML_ERROR_UNDEFINED_ENTITY: aErrorInformation.sMessage += String::CreateFromAscii( "Undefined entity" ); break;
+  			case XML_ERROR_RECURSIVE_ENTITY_REF: aErrorInformation.sMessage += String::CreateFromAscii( "Recursive entity ref" ); break;
+  			case XML_ERROR_ASYNC_ENTITY: aErrorInformation.sMessage += String::CreateFromAscii( "Async_entity" ); break;
+  			case XML_ERROR_BAD_CHAR_REF: aErrorInformation.sMessage += String::CreateFromAscii( "Bad char ref" ); break;
+  			case XML_ERROR_BINARY_ENTITY_REF: aErrorInformation.sMessage += String::CreateFromAscii( "Binary entity" ); break;
+  			case XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF: aErrorInformation.sMessage += String::CreateFromAscii( "Attribute external entity ref" ); break;
+  			case XML_ERROR_MISPLACED_XML_PI: aErrorInformation.sMessage += String::CreateFromAscii( "Misplaced xml pi" ); break;
+  			case XML_ERROR_UNKNOWN_ENCODING: aErrorInformation.sMessage += String::CreateFromAscii( "Unknown encoding" ); break;
+  			case XML_ERROR_INCORRECT_ENCODING: aErrorInformation.sMessage += String::CreateFromAscii( "Incorrect encoding" ); break;
+  			case XML_ERROR_UNCLOSED_CDATA_SECTION: aErrorInformation.sMessage += String::CreateFromAscii( "Unclosed cdata section" ); break;
+  			case XML_ERROR_EXTERNAL_ENTITY_HANDLING: aErrorInformation.sMessage += String::CreateFromAscii( "External entity handling" ); break;
+  			case XML_ERROR_NOT_STANDALONE: aErrorInformation.sMessage += String::CreateFromAscii( "Not standalone" ); break;
+            case XML_ERROR_NONE: break;
+            default:
+                break;
+
+		}
+		delete pXMLFile;
+		pXMLFile = NULL;
+	}
+	pStream->Seek( nPos );
+
+	return pXMLFile;
+}
+
+/*****************************************************************************/
+void XMLUtil::QuotHTML( String &rString )
+/*****************************************************************************/
+{
+	OUStringBuffer sReturn;
+	static const String LT(String::CreateFromAscii("<"));
+	static const String QLT(String::CreateFromAscii("&lt;"));
+	static const String GT(String::CreateFromAscii(">"));
+	static const String QGT(String::CreateFromAscii("&gt;"));
+	static const String QUOT(String::CreateFromAscii("\\"));
+	static const String QQUOT(String::CreateFromAscii("&quot;"));
+	static const String APOS(String::CreateFromAscii("\""));
+	static const String QAPOS(String::CreateFromAscii("&apos;"));
+	static const String AMP(String::CreateFromAscii("&"));
+	static const String QAMP(String::CreateFromAscii("&amp;"));
+	static const String SLASH(String::CreateFromAscii("\\"));
+
+	for ( sal_uInt16 i = 0; i < rString.Len(); i++) {
+		if ( i < rString.Len()) {
+			switch ( rString.GetChar( i )) {
+				case '\\': if( i+1 <= rString.Len() ){
+							switch( rString.GetChar( i+1 ) ){
+                             case '<':  sReturn.append( LT );i++;break;
+                             case '>':  sReturn.append( GT );i++;break;
+                             case '\\': sReturn.append( QUOT );i++;break;
+                             case '\"': sReturn.append( APOS );i++;break;
+                             //case '\'': sReturn += "\'";i++;break;
+                             //case '&' : sRetrun += "&";i++;break;
+                             default:   sReturn.append( SLASH );break;
+ 
+                           }
+                          }
+                        break; 
+                        
+                case '<':   
+                    sReturn.append( QLT );                                         
+					break;
+                
+				case '>':
+                    sReturn.append( QGT );
+					break;
+
+				case '\"':
+                    sReturn.append( QQUOT );
+					break;
+
+/*				case '\'':
+                    sReturn += "&apos;";
+					break;
+*/
+				case '&':
+					if (
+						  ( ( i + 4 ) < rString.Len()) &&
+						  ( String( rString.Copy( i, 5 ) ).Equals( QAMP ) )
+					   ) 
+						sReturn.append( rString.GetChar( i ) );
+					else
+						sReturn.append( QAMP );
+				break;
+
+				default:
+					sReturn.append( rString.GetChar( i ) );
+				break;
+			}
+		}
+	}
+	rString = String( sReturn.makeStringAndClear() );
+}
+
+void XMLUtil::UnQuotHTML( String &rString ){
+    UnQuotData( rString ); 
+}
+
+void XMLUtil::UnQuotData( String &rString_in ){
+	ByteString sReturn;
+    ByteString sString( rString_in , RTL_TEXTENCODING_UTF8 );
+	while ( sString.Len()) {
+	    if ( sString.Copy( 0, 1 ) == "\\" ) {
+			sReturn += "\\\\";
+			sString.Erase( 0, 1 );
+		}
+		else if ( sString.Copy( 0, 5 ) == "&amp;" ) {
+			sReturn += "&";
+			sString.Erase( 0, 5 );
+		}
+		else if ( sString.Copy( 0, 4 ) == "&lt;" ) {
+			sReturn += "<";
+			sString.Erase( 0, 4 );
+		}
+		else if ( sString.Copy( 0, 4 ) == "&gt;" ) {
+			sReturn += ">";
+			sString.Erase( 0, 4 );
+		}
+		else if ( sString.Copy( 0, 6 ) == "&quot;" ) {
+			sReturn += "\"";
+			sString.Erase( 0, 6 );
+		}
+		else if ( sString.Copy( 0, 6 ) == "&apos;" ) {
+			sReturn += "\'";
+			sString.Erase( 0, 6 );
+		}
+		else {
+			sReturn += sString.GetChar( 0 );
+			sString.Erase( 0, 1 );
+		}
+	}
+    rString_in = String(sReturn , RTL_TEXTENCODING_UTF8 );
+
+
+}
+
+XMLUtil::XMLUtil(){
+}
+
+
+/*****************************************************************************/
+void XMLUtil::dump(){
+/*****************************************************************************/
+	int cnt=1;
+    printf("size=%lu\n",static_cast<unsigned long>(lMap.size()));
+    for(HashMap::iterator pos = lMap.begin(); pos != lMap.end() ; ++pos){
+        fprintf(stdout,"key=%s , value=%d , no=%d\n",pos->first.GetBuffer(),pos->second,cnt++);
+    }
+}
+/*****************************************************************************/
+XMLUtil&  XMLUtil::Instance(){ 
+/*****************************************************************************/
+	static XMLUtil instance;
+	return instance;
+}
+/*****************************************************************************/
+XMLUtil::~XMLUtil(){}
+/*****************************************************************************/
+/*****************************************************************************/
+ByteString XMLUtil::GetIsoLangByIndex( sal_uInt16 nIndex )
+/*****************************************************************************/
+{
+	if(nIndex > 0 && MAX_LANGUAGES >= nIndex )
+		return isoArray[nIndex];
+	return "";
+}
+

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

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

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

Added: openoffice/branches/l10n/main/l10ntools/source/xrmlex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/xrmlex.l?rev=1437973&view=auto
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/xrmlex.l (added)
+++ openoffice/branches/l10n/main/l10ntools/source/xrmlex.l Thu Jan 24 12:21:38 2013
@@ -0,0 +1,244 @@
+%{
+/**************************************************************
+ * 
+ * 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 xml-property source files (*.xml)
+ *
+ */
+
+
+/* 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 Argument( char * );
+extern int InitXrmExport( char * , char * );
+extern int EndXrmExport();
+extern int GetError();
+extern int SetError();
+extern char *GetOutputFile( int argc, char* argv[]);
+extern FILE *GetXrmFile();
+extern int isQuiet();
+extern void removeTempFile();
+extern char* getFilename();
+
+/* forwards */
+void YYWarning();
+
+int bText=0;
+%}
+
+%p 24000
+%e 1200
+%n 500
+
+%%
+
+"<p "[^\>]*xml:lang[^\>]*\> {
+	WorkOnTokenSet( XRM_TEXT_START , yytext );
+}
+
+"</p>" {
+	WorkOnTokenSet( XRM_TEXT_END, yytext );
+}
+
+"<h1 "[^\>]*xml:lang[^\>]*\> {
+	WorkOnTokenSet( XRM_TEXT_START , yytext );
+}
+
+"</h1>" {
+	WorkOnTokenSet( XRM_TEXT_END, yytext );
+}
+"<h2 "[^\>]*xml:lang[^\>]*\> {
+	WorkOnTokenSet( XRM_TEXT_START , yytext );
+}
+
+"</h2>" {
+	WorkOnTokenSet( XRM_TEXT_END, yytext );
+}
+"<h3 "[^\>]*xml:lang[^\>]*\> {
+	WorkOnTokenSet( XRM_TEXT_START , yytext );
+}
+
+"</h3>" {
+	WorkOnTokenSet( XRM_TEXT_END, yytext );
+}
+"<h4 "[^\>]*xml:lang[^\>]*\> {
+	WorkOnTokenSet( XRM_TEXT_START , yytext );
+}
+
+"</h4>" {
+	WorkOnTokenSet( XRM_TEXT_END, yytext );
+}
+"<h5 "[^\>]*xml:lang[^\>]*\> {
+	WorkOnTokenSet( XRM_TEXT_START , yytext );
+}
+
+"</h5>" {
+	WorkOnTokenSet( XRM_TEXT_END, 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 );                          
+	}
+}
+
+.|\n {
+	if ( bText == 1 )
+		WorkOnTokenSet( XML_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: XRMEX[-p Prj][-r PrjRoot]-i FileIn [-o FileOut][-m DataBase][-e][-b][-u][-NOUTF8][-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, " -NOUTF8: disable UTF8 as language independent encoding\n" );
+		fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US,es...)\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,es...)\n" );
+		fprintf( stdout, "     Example: -L en-US,es=de\n" );
+		fprintf( stdout, "              Restriction to es and en-US, de will be fallback for 99\n" );
+//		fprintf( stdout, " -ISO99: IsoCode is the full qualified ISO language code for language 99" );
+		return 1;
+	}
+	pFile = GetXrmFile();
+	InitXrmExport( pOutput , getFilename() );
+
+    if ( !pFile )
+		return 1;
+
+   	yyin = pFile;
+
+	/* create global instance of class XmlExport */
+	//InitXrmExport( pOutput );
+
+	/* start parser */
+   	yylex();
+
+	/* get error info. and end export */
+	nRetValue = GetError();
+	EndXrmExport();
+
+    removeTempFile();
+	/* return error level */
+	return nRetValue;
+}

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



Mime
View raw message