From 5f5e7c5455d52826b0bd50f64fcffb7695ce970d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sat, 29 Jun 2013 12:56:53 +0200 Subject: Initial TQt conversion --- src/encoderlatex.cpp | 140 +++++++++++++++++++++++++-------------------------- 1 file changed, 70 insertions(+), 70 deletions(-) (limited to 'src/encoderlatex.cpp') diff --git a/src/encoderlatex.cpp b/src/encoderlatex.cpp index f111848..4dc0326 100644 --- a/src/encoderlatex.cpp +++ b/src/encoderlatex.cpp @@ -17,9 +17,9 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include +#include +#include +#include #include "encoderlatex.h" @@ -497,23 +497,23 @@ namespace BibTeX // nothing } - QString EncoderLaTeX::decode( const QString & text ) + TQString EncoderLaTeX::decode( const TQString & text ) { - const QString splitMarker = "|KBIBTEX|"; + const TQString splitMarker = "|KBIBTEX|"; /** start-stop marker ensures that each text starts and stops * with plain text and not with an inline math environment. * This invariant is exploited implicitly in the code below. */ - const QString startStopMarker="|STARTSTOP|"; - QString result = startStopMarker + text + startStopMarker; + const TQString startStopMarker="|STARTSTOP|"; + TQString result = startStopMarker + text + startStopMarker; /** Collect (all?) urls from the BibTeX file and store them in urls */ /** Problem is that the replace function below will replace * character sequences in the URL rendering the URL invalid. * Later, all URLs will be replaced back to their original * in the hope nothing breaks ... */ - QStringList urls; - QRegExp httpRegExp( "(ht|f)tp://[^\"} ]+" ); + TQStringList urls; + TQRegExp httpRegExp( "(ht|f)tp://[^\"} ]+" ); httpRegExp.setMinimal( false ); int pos = 0; while ( pos >= 0 ) @@ -522,7 +522,7 @@ namespace BibTeX if ( pos >= 0 ) { ++pos; - QString url = httpRegExp.cap( 0 ); + TQString url = httpRegExp.cap( 0 ); urls << url; } } @@ -530,8 +530,8 @@ namespace BibTeX decomposedUTF8toLaTeX( result ); /** split text into math and non-math regions */ - QStringList intermediate = QStringList::split( '$', result, true ); - QStringList::Iterator it = intermediate.begin(); + TQStringList intermediate = TQStringList::split( '$', result, true ); + TQStringList::Iterator it = intermediate.begin(); while ( it != intermediate.end() ) { /** @@ -544,7 +544,7 @@ namespace BibTeX */ if (( *it ).endsWith( "\\" ) ) { - QStringList::Iterator cur = it; + TQStringList::Iterator cur = it; ++it; ( *cur ).append( '$' ).append( *it ); intermediate.remove( it ); @@ -554,10 +554,10 @@ namespace BibTeX ++it; } - qApp->processEvents(); + tqApp->processEvents(); result = ""; - for ( QStringList::Iterator it = intermediate.begin(); it != intermediate.end(); ++it ) + for ( TQStringList::Iterator it = intermediate.begin(); it != intermediate.end(); ++it ) { if ( !result.isEmpty() ) result.append( splitMarker ); result.append( *it ); @@ -567,22 +567,22 @@ namespace BibTeX break; if (( *it ).length() > 256 ) - qDebug( "Very long math equation using $ found, maybe due to broken inline math: %s", ( *it ).left( 48 ).latin1() ); + tqDebug( "Very long math equation using $ found, maybe due to broken inline math: %s", ( *it ).left( 48 ).latin1() ); } - qApp->processEvents(); + tqApp->processEvents(); - for ( QValueList::ConstIterator cmit = m_charMapping.begin(); cmit != m_charMapping.end(); ++cmit ) + for ( TQValueList::ConstIterator cmit = m_charMapping.begin(); cmit != m_charMapping.end(); ++cmit ) result.replace(( *cmit ).regExp, ( *cmit ).unicode ); - qApp->processEvents(); + tqApp->processEvents(); - QStringList transformed = QStringList::split( splitMarker, result, true ); + TQStringList transformed = TQStringList::split( splitMarker, result, true ); - qApp->processEvents(); + tqApp->processEvents(); result = ""; - for ( QStringList::Iterator itt = transformed.begin(), iti = intermediate.begin(); itt != transformed.end() && iti != intermediate.end(); ++itt, ++iti ) + for ( TQStringList::Iterator itt = transformed.begin(), iti = intermediate.begin(); itt != transformed.end() && iti != intermediate.end(); ++itt, ++iti ) { result.append( *itt ); @@ -593,7 +593,7 @@ namespace BibTeX result.append( "$" ).append( *iti ).append( "$" ); } - qApp->processEvents(); + tqApp->processEvents(); /** Reinserting original URLs as explained above */ pos = 0; @@ -612,23 +612,23 @@ namespace BibTeX return result.replace( startStopMarker,"" ); } - QString EncoderLaTeX::encode( const QString & text ) + TQString EncoderLaTeX::encode( const TQString & text ) { - const QString splitMarker = "|KBIBTEX|"; + const TQString splitMarker = "|KBIBTEX|"; /** start-stop marker ensures that each text starts and stops * with plain text and not with an inline math environment. * This invariant is exploited implicitly in the code below. */ - const QString startStopMarker="|STARTSTOP|"; - QString result = startStopMarker + text + startStopMarker; + const TQString startStopMarker="|STARTSTOP|"; + TQString result = startStopMarker + text + startStopMarker; /** Collect (all?) urls from the BibTeX file and store them in urls */ /** Problem is that the replace function below will replace * character sequences in the URL rendering the URL invalid. * Later, all URLs will be replaced back to their original * in the hope nothing breaks ... */ - QStringList urls; - QRegExp httpRegExp( "(ht|f)tp://[^\"} ]+" ); + TQStringList urls; + TQRegExp httpRegExp( "(ht|f)tp://[^\"} ]+" ); httpRegExp.setMinimal( false ); int pos = 0; while ( pos >= 0 ) @@ -637,14 +637,14 @@ namespace BibTeX if ( pos >= 0 ) { ++pos; - QString url = httpRegExp.cap( 0 ); + TQString url = httpRegExp.cap( 0 ); urls << url; } } /** split text into math and non-math regions */ - QStringList intermediate = QStringList::split( '$', result, true ); - QStringList::Iterator it = intermediate.begin(); + TQStringList intermediate = TQStringList::split( '$', result, true ); + TQStringList::Iterator it = intermediate.begin(); while ( it != intermediate.end() ) { /** @@ -657,7 +657,7 @@ namespace BibTeX */ if (( *it ).endsWith( "\\" ) ) { - QStringList::Iterator cur = it; + TQStringList::Iterator cur = it; ++it; ( *cur ).append( '$' ).append( *it ); intermediate.remove( it ); @@ -667,10 +667,10 @@ namespace BibTeX ++it; } - qApp->processEvents(); + tqApp->processEvents(); result = ""; - for ( QStringList::Iterator it = intermediate.begin(); it != intermediate.end(); ++it ) + for ( TQStringList::Iterator it = intermediate.begin(); it != intermediate.end(); ++it ) { if ( !result.isEmpty() ) result.append( splitMarker ); result.append( *it ); @@ -680,22 +680,22 @@ namespace BibTeX break; if (( *it ).length() > 256 ) - qDebug( "Very long math equation using $ found, maybe due to broken inline math: %s", ( *it ).left( 48 ).latin1() ); + tqDebug( "Very long math equation using $ found, maybe due to broken inline math: %s", ( *it ).left( 48 ).latin1() ); } - qApp->processEvents(); + tqApp->processEvents(); - for ( QValueList::ConstIterator cmit = m_charMapping.begin(); cmit != m_charMapping.end(); ++cmit ) + for ( TQValueList::ConstIterator cmit = m_charMapping.begin(); cmit != m_charMapping.end(); ++cmit ) result.replace(( *cmit ).unicode, ( *cmit ).latex ); - qApp->processEvents(); + tqApp->processEvents(); - QStringList transformed = QStringList::split( splitMarker, result, true ); + TQStringList transformed = TQStringList::split( splitMarker, result, true ); - qApp->processEvents(); + tqApp->processEvents(); result = ""; - for ( QStringList::Iterator itt = transformed.begin(), iti = intermediate.begin(); itt != transformed.end() && iti != intermediate.end(); ++itt, ++iti ) + for ( TQStringList::Iterator itt = transformed.begin(), iti = intermediate.begin(); itt != transformed.end() && iti != intermediate.end(); ++itt, ++iti ) { result.append( *itt ); @@ -706,12 +706,12 @@ namespace BibTeX result.append( "$" ).append( *iti ).append( "$" ); } - qApp->processEvents(); + tqApp->processEvents(); /** \url accepts unquotet & and _ May introduce new problem tough */ if ( result.contains( "\\url{" ) ) - result.replace( "\\&", "&" ).replace( "\\_", "_" ).replace( QChar( 0x2013 ), "--" ).replace( "\\#", "#" ); + result.replace( "\\&", "&" ).replace( "\\_", "_" ).replace( TQChar( 0x2013 ), "--" ).replace( "\\#", "#" ); decomposedUTF8toLaTeX( result ); @@ -732,27 +732,27 @@ namespace BibTeX return result.replace( startStopMarker,"" ); } - QString EncoderLaTeX::encode( const QString &text, const QChar &replace ) + TQString EncoderLaTeX::encode( const TQString &text, const TQChar &replace ) { - QString result = text; - for ( QValueList::ConstIterator it = m_charMapping.begin(); it != m_charMapping.end(); ++it ) + TQString result = text; + for ( TQValueList::ConstIterator it = m_charMapping.begin(); it != m_charMapping.end(); ++it ) if (( *it ).unicode == replace ) result.replace(( *it ).unicode, ( *it ).latex ); return result; } - QString EncoderLaTeX::encodeSpecialized( const QString & text, const EntryField::FieldType fieldType ) + TQString EncoderLaTeX::encodeSpecialized( const TQString & text, const EntryField::FieldType fieldType ) { - QString result = encode( text ); + TQString result = encode( text ); switch ( fieldType ) { case EntryField::ftPages: - result.replace( QChar( 0x2013 ), "--" ); + result.replace( TQChar( 0x2013 ), "--" ); break; case EntryField::ftURL: - result.replace( "\\&", "&" ).replace( "\\_", "_" ).replace( QChar( 0x2013 ), "--" ).replace( "\\#", "#" ); + result.replace( "\\&", "&" ).replace( "\\_", "_" ).replace( TQChar( 0x2013 ), "--" ).replace( "\\#", "#" ); break; default: @@ -762,14 +762,14 @@ namespace BibTeX return result; } - QString& EncoderLaTeX::decomposedUTF8toLaTeX( QString &text ) + TQString& EncoderLaTeX::decomposedUTF8toLaTeX( TQString &text ) { - for ( QValueList::Iterator it = m_combinedMapping.begin(); it != m_combinedMapping.end(); ++it ) + for ( TQValueList::Iterator it = m_combinedMapping.begin(); it != m_combinedMapping.end(); ++it ) { int i = ( *it ).regExp.search( text ); while ( i >= 0 ) { - QString a = ( *it ).regExp.cap( 1 ); + TQString a = ( *it ).regExp.cap( 1 ); text = text.left( i ) + "\\" + ( *it ).latex + "{" + a + "}" + text.mid( i + 2 ); i = ( *it ).regExp.search( text, i + 1 ); } @@ -783,7 +783,7 @@ namespace BibTeX for ( int i = 0; i < decompositionscount; i++ ) { CombinedMappingItem item; - item.regExp = QRegExp( "(.)" + QString( QChar( decompositions[i].unicode ) ) ); + item.regExp = TQRegExp( "(.)" + TQString( TQChar( decompositions[i].unicode ) ) ); item.latex = decompositions[i].latexCommand; m_combinedMapping.append( item ); } @@ -795,9 +795,9 @@ namespace BibTeX for ( int i = 0; i < charmappingdatalatexcount; i++ ) { CharMappingItem charMappingItem; - charMappingItem.regExp = QRegExp( charmappingdatalatex[ i ].regexp ); - charMappingItem.unicode = QChar( charmappingdatalatex[ i ].unicode ); - charMappingItem.latex = QString( charmappingdatalatex[ i ].latex ); + charMappingItem.regExp = TQRegExp( charmappingdatalatex[ i ].regexp ); + charMappingItem.unicode = TQChar( charmappingdatalatex[ i ].unicode ); + charMappingItem.latex = TQString( charmappingdatalatex[ i ].latex ); m_charMapping.append( charMappingItem ); } @@ -808,11 +808,11 @@ namespace BibTeX for ( int j = 0; j < expansionscmdcount; ++j ) { CharMappingItem charMappingItem; - charMappingItem.regExp = QRegExp( QString( expansionsCmd[j] ).arg( commandmappingdatalatex[i].letters ) ); - charMappingItem.unicode = QChar( commandmappingdatalatex[i].unicode ); + charMappingItem.regExp = TQRegExp( TQString( expansionsCmd[j] ).arg( commandmappingdatalatex[i].letters ) ); + charMappingItem.unicode = TQChar( commandmappingdatalatex[i].unicode ); if ( charMappingItem.regExp.numCaptures() > 0 ) - charMappingItem.unicode += QString( "\\1" ); - charMappingItem.latex = QString( "{\\%1}" ).arg( commandmappingdatalatex[i].letters ); + charMappingItem.unicode += TQString( "\\1" ); + charMappingItem.latex = TQString( "{\\%1}" ).arg( commandmappingdatalatex[i].letters ); m_charMapping.append( charMappingItem ); } } @@ -820,8 +820,8 @@ namespace BibTeX /** encoding and decoding for letters such as \"a */ for ( int i = 0; i < modcharmappingdatalatexcount; ++i ) { - QString modifierRegExp = QString( modcharmappingdatalatex[i].modifier ); - QString modifier = modifierRegExp; + TQString modifierRegExp = TQString( modcharmappingdatalatex[i].modifier ); + TQString modifier = modifierRegExp; modifier.replace( "\\^", "^" ).replace( "\\\\", "\\" ); /** first batch of replacement rules, where no separator is required between modifier and character (e.g. \"a) */ @@ -829,9 +829,9 @@ namespace BibTeX for ( int j = 0; j < expansionsmod2count; ++j ) { CharMappingItem charMappingItem; - charMappingItem.regExp = QRegExp( QString( expansionsMod2[j] ).arg( modifierRegExp ).arg( modcharmappingdatalatex[i].letter ) ); - charMappingItem.unicode = QChar( modcharmappingdatalatex[i].unicode ); - charMappingItem.latex = QString( "{%1%2}" ).arg( modifier ).arg( modcharmappingdatalatex[i].letter ); + charMappingItem.regExp = TQRegExp( TQString( expansionsMod2[j] ).arg( modifierRegExp ).arg( modcharmappingdatalatex[i].letter ) ); + charMappingItem.unicode = TQChar( modcharmappingdatalatex[i].unicode ); + charMappingItem.latex = TQString( "{%1%2}" ).arg( modifier ).arg( modcharmappingdatalatex[i].letter ); m_charMapping.append( charMappingItem ); } @@ -839,9 +839,9 @@ namespace BibTeX for ( int j = 0; j < expansionsmod1count; ++j ) { CharMappingItem charMappingItem; - charMappingItem.regExp = QRegExp( QString( expansionsMod1[j] ).arg( modifierRegExp ).arg( modcharmappingdatalatex[i].letter ) ); - charMappingItem.unicode = QChar( modcharmappingdatalatex[i].unicode ); - charMappingItem.latex = QString( "%1{%2}" ).arg( modifier ).arg( modcharmappingdatalatex[i].letter ); + charMappingItem.regExp = TQRegExp( TQString( expansionsMod1[j] ).arg( modifierRegExp ).arg( modcharmappingdatalatex[i].letter ) ); + charMappingItem.unicode = TQChar( modcharmappingdatalatex[i].unicode ); + charMappingItem.latex = TQString( "%1{%2}" ).arg( modifier ).arg( modcharmappingdatalatex[i].letter ); m_charMapping.append( charMappingItem ); } } -- cgit v1.2.1