Skip to content

Commit a47ed50

Browse files
gonwanu-235
authored andcommitted
Unify naming for chm internal files, no function change.
1 parent 8dcd215 commit a47ed50

2 files changed

Lines changed: 27 additions & 27 deletions

File tree

lib/libebook/ebook_chm.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ EBook_CHM::EBook_CHM()
5757
m_filename = m_font = QString();
5858

5959
m_textCodec = 0;
60-
m_textCodecForSpecialFiles = 0;
60+
m_textCodecForInternalFiles = 0;
6161
m_detectedLCID = 0;
6262
m_currentEncoding = "UTF-8";
6363
m_htmlEntityDecoder = 0;
@@ -84,7 +84,7 @@ void EBook_CHM::close()
8484
m_indexFile.clear();
8585

8686
m_textCodec = 0;
87-
m_textCodecForSpecialFiles = 0;
87+
m_textCodecForInternalFiles = 0;
8888
m_detectedLCID = 0;
8989
m_currentEncoding = "UTF-8";
9090
m_lookupTablesValid = false;
@@ -212,21 +212,6 @@ bool EBook_CHM::getFileContentAsBinary( QByteArray& data, const QUrl& url ) cons
212212
return getBinaryContent( data, urlToPath( url ) );
213213
}
214214

215-
bool EBook_CHM::getBinaryContent( QByteArray& data, const QString& url ) const
216-
{
217-
chmUnitInfo ui;
218-
219-
if ( !ResolveObject( url, &ui ) )
220-
return false;
221-
222-
data.resize( ui.length );
223-
224-
if ( RetrieveObject( &ui, ( unsigned char* ) data.data(), 0, ui.length ) )
225-
return true;
226-
227-
return false;
228-
}
229-
230215
bool EBook_CHM::getTextContent( QString& str, const QString& url, bool internal_encoding ) const
231216
{
232217
QByteArray buf;
@@ -248,6 +233,21 @@ bool EBook_CHM::getTextContent( QString& str, const QString& url, bool internal_
248233
return false;
249234
}
250235

236+
bool EBook_CHM::getBinaryContent( QByteArray& data, const QString& url ) const
237+
{
238+
chmUnitInfo ui;
239+
240+
if ( !ResolveObject( url, &ui ) )
241+
return false;
242+
243+
data.resize( ui.length );
244+
245+
if ( RetrieveObject( &ui, ( unsigned char* ) data.data(), 0, ui.length ) )
246+
return true;
247+
248+
return false;
249+
}
250+
251251
int EBook_CHM::getContentSize( const QString& url )
252252
{
253253
chmUnitInfo ui;
@@ -290,7 +290,7 @@ bool EBook_CHM::load( const QString& archiveName )
290290

291291
// Reset encoding
292292
m_textCodec = 0;
293-
m_textCodecForSpecialFiles = 0;
293+
m_textCodecForInternalFiles = 0;
294294
m_currentEncoding = "UTF-8";
295295

296296
// Get information from /#WINDOWS and /#SYSTEM files (encoding, title, context file and so)
@@ -892,7 +892,7 @@ bool EBook_CHM::changeFileEncoding( const QString& qtencoding )
892892
if ( p != -1 )
893893
{
894894
QString global = qtencoding.left( p );
895-
QString special = qtencoding.mid( p + 1 );
895+
QString internal = qtencoding.mid( p + 1 );
896896

897897
m_textCodec = QTextCodec::codecForName( global.toUtf8() );
898898

@@ -902,17 +902,17 @@ bool EBook_CHM::changeFileEncoding( const QString& qtencoding )
902902
return false;
903903
}
904904

905-
m_textCodecForSpecialFiles = QTextCodec::codecForName( special.toUtf8() );
905+
m_textCodecForInternalFiles = QTextCodec::codecForName( internal.toUtf8() );
906906

907-
if ( !m_textCodecForSpecialFiles )
907+
if ( !m_textCodecForInternalFiles )
908908
{
909-
qWarning( "Could not set up Text Codec for encoding '%s'", qPrintable( special ) );
909+
qWarning( "Could not set up Text Codec for encoding '%s'", qPrintable( internal ) );
910910
return false;
911911
}
912912
}
913913
else
914914
{
915-
m_textCodecForSpecialFiles = m_textCodec = QTextCodec::codecForName( qtencoding.toUtf8() );
915+
m_textCodecForInternalFiles = m_textCodec = QTextCodec::codecForName( qtencoding.toUtf8() );
916916

917917
if ( !m_textCodec )
918918
{

lib/libebook/ebook_chm.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,14 @@ class EBook_CHM : public EBook
248248
//! Or return as-is, if not.
249249
inline QString encodeInternalWithCurrentCodec( const QByteArray& str ) const
250250
{
251-
return ( m_textCodecForSpecialFiles ? m_textCodecForSpecialFiles->toUnicode( str.constData() ) : str );
251+
return ( m_textCodecForInternalFiles ? m_textCodecForInternalFiles->toUnicode( str.constData() ) : str );
252252
}
253253

254254
//! Encode the string from internal files with the currently selected text codec, if possible.
255255
//! Or return as-is, if not.
256256
inline QString encodeInternalWithCurrentCodec( const char* str ) const
257257
{
258-
return ( m_textCodecForSpecialFiles ? m_textCodecForSpecialFiles->toUnicode( str ) : ( QString ) str );
258+
return ( m_textCodecForInternalFiles ? m_textCodecForInternalFiles->toUnicode( str ) : ( QString ) str );
259259
}
260260

261261
//! Helper. Translates from Win32 encodings to generic wxWidgets ones.
@@ -264,8 +264,8 @@ class EBook_CHM : public EBook
264264
//! Parse the HHC or HHS file, and fill the context (asIndex is false) or index (asIndex is true) array.
265265
bool parseFileAndFillArray( const QString& file, QList< ParsedEntry >& data, bool asIndex ) const;
266266

267-
bool getBinaryContent( QByteArray& data, const QString& url ) const;
268267
bool getTextContent( QString& str, const QString& url, bool internal_encoding = false ) const;
268+
bool getBinaryContent( QByteArray& data, const QString& url ) const;
269269

270270
/*!
271271
* Parse binary TOC
@@ -328,7 +328,7 @@ class EBook_CHM : public EBook
328328

329329
//! Chosen text codec
330330
QTextCodec* m_textCodec;
331-
QTextCodec* m_textCodecForSpecialFiles;
331+
QTextCodec* m_textCodecForInternalFiles;
332332

333333
//! Current encoding
334334
QString m_currentEncoding;

0 commit comments

Comments
 (0)