src/hbutils/document/hbdocumentloader_p.cpp
changeset 5 627c4a0fd0e7
parent 2 06ff229162e9
child 7 923ff622b8b9
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    28 #include "hbdocumentloadersyntax_p.h"
    28 #include "hbdocumentloadersyntax_p.h"
    29 #include "hbdocumentloader.h"
    29 #include "hbdocumentloader.h"
    30 
    30 
    31 #include <hbxmlloaderbinaryactions_p.h>
    31 #include <hbxmlloaderbinaryactions_p.h>
    32 #include <hbxmlloaderbinarysyntax_p.h>
    32 #include <hbxmlloaderbinarysyntax_p.h>
       
    33 
       
    34 #include <QDebug>
    33 
    35 
    34 #ifndef HB_BOOTSTRAPPED
    36 #ifndef HB_BOOTSTRAPPED
    35 
    37 
    36 #include <QGraphicsWidget>
    38 #include <QGraphicsWidget>
    37 #include <QCoreApplication>
    39 #include <QCoreApplication>
   108 #endif
   110 #endif
   109 }
   111 }
   110 
   112 
   111 bool HbDocumentLoaderPrivate::createBinary( QIODevice *srcDevice, QIODevice *dstDevice )
   113 bool HbDocumentLoaderPrivate::createBinary( QIODevice *srcDevice, QIODevice *dstDevice )
   112 {
   114 {
       
   115     qDebug() << "createBinary, 1";
   113     bool result = true;
   116     bool result = true;
   114     syntax->setActions( binaryactions );
   117     syntax->setActions( binaryactions );
   115 #ifdef DEBUG_TIMES
   118 #ifdef DEBUG_TIMES
   116     debugTime.restart();
   119     debugTime.restart();
   117     debugPrintX("MYTRACE: DocML create binary, start");
   120     debugPrintX("MYTRACE: DocML create binary, start");
   119     binaryactions->setOutputDevice( dstDevice );
   122     binaryactions->setOutputDevice( dstDevice );
   120     // TODO: Has to process all sections!
   123     // TODO: Has to process all sections!
   121     QList<QString> sectionsList;
   124     QList<QString> sectionsList;
   122     QHash< QString, qint64 > sectionsPositionList;
   125     QHash< QString, qint64 > sectionsPositionList;
   123     qint64 startPos = srcDevice->pos();
   126     qint64 startPos = srcDevice->pos();
       
   127     qDebug() << "createBinary, 2";
   124     if( syntax->scanForSections( srcDevice, sectionsList ) ) {
   128     if( syntax->scanForSections( srcDevice, sectionsList ) ) {
       
   129         qDebug() << "createBinary, 3";
   125         srcDevice->seek( startPos );
   130         srcDevice->seek( startPos );
       
   131         qDebug() << "createBinary, 4";
   126         result = syntax->load( srcDevice, "" );
   132         result = syntax->load( srcDevice, "" );
   127         if( !sectionsList.isEmpty() ) {
   133         if( !sectionsList.isEmpty() ) {
   128             for( int i = 0; i < sectionsList.size(); i++ ) {
   134             for( int i = 0; i < sectionsList.size(); i++ ) {
   129                 sectionsPositionList[ sectionsList.at( i ) ] = dstDevice->pos();
   135                 sectionsPositionList[ sectionsList.at( i ) ] = dstDevice->pos();
   130                 srcDevice->seek( startPos );
   136                 srcDevice->seek( startPos );
       
   137                 qDebug() << "createBinary, 5, " << i;
   131                 result &= syntax->load( srcDevice, sectionsList.at( i ) );
   138                 result &= syntax->load( srcDevice, sectionsList.at( i ) );
       
   139                 qDebug() << "createBinary, 6, " << i;
   132             }
   140             }
   133         }
   141         }
   134     } else {
   142     } else {
   135         result = false;
   143         result = false;
   136     }
   144     }
       
   145     qDebug() << "createBinary, 7";
   137     qint64 sectionsMetaDataPos = dstDevice->pos();
   146     qint64 sectionsMetaDataPos = dstDevice->pos();
   138     QDataStream stream( dstDevice );
   147     QDataStream stream( dstDevice );
   139     stream << sectionsPositionList;
   148     stream << sectionsPositionList;
   140     stream << sectionsMetaDataPos;
   149     stream << sectionsMetaDataPos;
   141 
   150 
       
   151     qDebug() << "createBinary, 8";
   142 
   152 
   143 #ifdef DEBUG_TIMES
   153 #ifdef DEBUG_TIMES
   144     debugPrintX("MYTRACE: DocML create binary, end: %d", debugTime.elapsed());
   154     debugPrintX("MYTRACE: DocML create binary, end: %d", debugTime.elapsed());
   145 #endif
   155 #endif
   146     return result;
   156     return result;