Exemple #1
0
// Accepts a full path to an HTML file.
// Reads the file, detects the encoding
// and returns the text converted to Unicode. 
QString HTMLEncodingResolver::ReadHTMLFile( const QString &fullfilepath )
{
    QFile file( fullfilepath );

    // Check if we can open the file
    if ( !file.open( QFile::ReadOnly ) ) 
    {
        boost_throw( CannotOpenFile() 
                     << errinfo_file_fullpath( file.fileName().toStdString() )
                     << errinfo_file_errorstring( file.errorString().toStdString() ) 
                   );
    }

    QByteArray data = file.readAll();

    return Utility::ConvertLineEndings( GetCodecForHTML( data ).toUnicode( data ) );
}
Exemple #2
0
void ExportEPUB::CreateEncryptionXML(const QString &fullfolderpath)
{
    QTemporaryFile file;

    if (!file.open()) {
        boost_throw(CannotOpenFile()
                    << errinfo_file_fullpath(file.fileName().toStdString())
                    << errinfo_file_errorstring(file.errorString().toStdString())
                   );
    }

    EncryptionXmlWriter enc(*m_Book, file);
    enc.WriteXML();
    // Write to disk immediately
    file.flush();
    QFile::copy(file.fileName(), fullfolderpath + "/" + ENCRYPTION_XML_FILE_NAME);
}