src/hbutils/document/hbdocumentloadersyntax_p.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 6 c3690ec91ef8
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    26 #include "hbdocumentloadersyntax_p.h"
    26 #include "hbdocumentloadersyntax_p.h"
    27 #include "hbdocumentloaderactions_p.h"
    27 #include "hbdocumentloaderactions_p.h"
    28 #include "hbdocumentloader_p.h"
    28 #include "hbdocumentloader_p.h"
    29 #include "hbdocumentloader.h"
    29 #include "hbdocumentloader.h"
    30 
    30 
    31 #include <hbicon.h>
       
    32 #include <hbfontspec.h>
    31 #include <hbfontspec.h>
       
    32 
       
    33 #include <QMetaEnum>
       
    34 #include <QTranslator>
       
    35 #include <QDataStream>
       
    36 
    33 #include <QDebug>
    37 #include <QDebug>
    34 #include <QMetaEnum>
       
    35 
       
    36 #include <QTranslator>
       
    37 #include <hbmainwindow.h>
       
    38 
    38 
    39 
    39 
    40 // Document loader version number
    40 // Document loader version number
    41 #define VERSION_MAJOR 1
    41 #define VERSION_MAJOR 1
    42 #define VERSION_MINOR 0
    42 #define VERSION_MINOR 1
    43 
    43 
    44 #define MIN_SUPPORTED_VERSION_MAJOR 0
    44 #define MIN_SUPPORTED_VERSION_MAJOR 0
    45 #define MIN_SUPPORTED_VERSION_MINOR 1
    45 #define MIN_SUPPORTED_VERSION_MINOR 1
       
    46 
       
    47 
       
    48 //#define LINE_DEBUGGING
       
    49 
       
    50 #ifdef LINE_DEBUGGING
       
    51 #include <QTime>
       
    52 static QTime lineDebugTime;
       
    53 
       
    54 #ifdef Q_OS_SYMBIAN
       
    55 #include <e32debug.h>
       
    56 #endif
       
    57 
       
    58 void doDebugPrint(const char* text)
       
    59 {
       
    60 #ifdef Q_OS_SYMBIAN
       
    61     RDebug::Printf(text);
       
    62 #else
       
    63     qDebug() << text;
       
    64 #endif
       
    65 }
       
    66 
       
    67 // Takes standard c-format.
       
    68 void debugPrint(const char* cformat, ...)
       
    69 {
       
    70     va_list ap;
       
    71     va_start(ap, cformat);
       
    72     QString str = QString().vsprintf(cformat, ap);
       
    73     va_end(ap);
       
    74     doDebugPrint(str.toAscii().constData());
       
    75 }
       
    76 
       
    77 #endif // LINE_DEBUGGING
       
    78 
       
    79 const char *ZValueProperty = "z";
       
    80 
       
    81 class AccessToMetadata : public QObject
       
    82     {
       
    83     public:
       
    84         int getEnumValue( const char *enumeration, const char *str )
       
    85             {
       
    86                 QMetaObject metaobject = staticQtMetaObject;
       
    87                 QMetaEnum e = metaobject.enumerator( metaobject.indexOfEnumerator( enumeration ) );
       
    88                 return e.keysToValue( str );
       
    89             }
       
    90     };
    46 
    91 
    47 /*
    92 /*
    48     \class HbDocumentLoaderSyntax
    93     \class HbDocumentLoaderSyntax
    49     \internal
    94     \internal
    50     \proto
    95     \proto
    51 */
    96 */
    52 
    97 
    53 HbDocumentLoaderSyntax::HbDocumentLoaderSyntax( HbDocumentLoaderActions *actions, const HbMainWindow *window )
    98 HbDocumentLoaderSyntax::HbDocumentLoaderSyntax( HbXmlLoaderAbstractActions *actions )
    54 : HbXmlLoaderAbstractSyntax( actions ), mRealActions( actions ), mMainWindow(window)
    99 : HbXmlLoaderBaseSyntax( actions )
    55 {
   100 {
    56 }
   101 }
    57 
   102 
    58 HbDocumentLoaderSyntax::~HbDocumentLoaderSyntax()
   103 HbDocumentLoaderSyntax::~HbDocumentLoaderSyntax()
    59 {
   104 {
    60 }
   105 }
    61 
   106 
       
   107 bool HbDocumentLoaderSyntax::scanForSections( QIODevice *device, QList<QString> &sectionsList )
       
   108 {
       
   109 #ifdef LINE_DEBUGGING
       
   110     lineDebugTime.restart();
       
   111     debugPrint("MYTRACE: DocML scanForSections, start");
       
   112 #endif
       
   113     bool ret = HbXmlLoaderBaseSyntax::scanForSections( device, sectionsList );
       
   114 #ifdef LINE_DEBUGGING
       
   115     debugPrint("MYTRACE: DocML scanForSections, end: %d", lineDebugTime.elapsed());
       
   116 #endif
       
   117     return ret;
       
   118 }
       
   119 
    62 bool HbDocumentLoaderSyntax::load( QIODevice *device, const QString &section )
   120 bool HbDocumentLoaderSyntax::load( QIODevice *device, const QString &section )
    63 {
   121 {
    64     mCurrentProfile = HbDeviceProfile::profile(mMainWindow);
   122 #ifdef LINE_DEBUGGING
    65     return HbXmlLoaderAbstractSyntax::loadDevice( device, section );
   123     lineDebugTime.restart();
       
   124     debugPrint("MYTRACE: DocML load, start");
       
   125 #endif
       
   126     bool ret = HbXmlLoaderBaseSyntax::loadDevice( device, section );
       
   127 #ifdef LINE_DEBUGGING
       
   128     debugPrint("MYTRACE: DocML load, end: %d", lineDebugTime.elapsed());
       
   129 #endif
       
   130     return ret;
    66 }
   131 }
    67 
   132 
    68 bool HbDocumentLoaderSyntax::readLayoutStartItem()
   133 bool HbDocumentLoaderSyntax::readLayoutStartItem()
    69 {
   134 {
    70     bool result = false;
   135     bool result = false;
    74             HB_DOCUMENTLOADER_PRINT( "GENERAL LAYOUT START ITEM: ANCHOR ITEM" );
   139             HB_DOCUMENTLOADER_PRINT( "GENERAL LAYOUT START ITEM: ANCHOR ITEM" );
    75             if( mReader.name() == lexemValue( AL_ANCHOR ) ) {
   140             if( mReader.name() == lexemValue( AL_ANCHOR ) ) {
    76 
   141 
    77                 const QString src = attribute( AL_SRC_NAME );
   142                 const QString src = attribute( AL_SRC_NAME );
    78                 const QString dst = attribute( AL_DST_NAME );
   143                 const QString dst = attribute( AL_DST_NAME );
    79                 const QString srcEdge = attribute( AL_SRC_EDGE );
   144                 const QString srcEdgeStr = attribute( AL_SRC_EDGE );
    80                 const QString dstEdge = attribute( AL_DST_EDGE );
   145                 const QString dstEdgeStr = attribute( AL_DST_EDGE );
    81                 const QString spacing = attribute( AL_SPACING );
   146                 const QString spacing = attribute( AL_SPACING );
    82                 const QString spacer = attribute( AL_SPACER );
   147                 const QString spacer = attribute( AL_SPACER );
    83                 qreal spacingVal = 0;
   148                 HbXmlLengthValue spacingVal;
    84                 result = true;
   149                 result = true;
    85                 if( !spacing.isEmpty() ) {
   150                 if( !spacing.isEmpty() ) {
    86                     result = toPixels( spacing, spacingVal );
   151                     result = toLengthValue( spacing, spacingVal );
    87                 }
   152                 }
    88                 if (result) {
   153                 Hb::Edge srcEdge, dstEdge;
    89                     result = mRealActions->addAnchorLayoutEdge( src, srcEdge, dst, dstEdge, spacingVal, spacer );
   154                 result &= getAnchorEdge( srcEdgeStr, srcEdge );
       
   155                 result &= getAnchorEdge( dstEdgeStr, dstEdge );
       
   156                 if ( result ) {
       
   157                     result = mActions->addAnchorLayoutEdge( src, srcEdge, dst, dstEdge, spacingVal, spacer );
    90                 }
   158                 }
    91             }
   159             }
    92             break;
   160             break;
    93         }
   161         }
    94         case LAYOUT_GRID:
   162         case LAYOUT_GRID:
    95         {
   163         {
    96             HB_DOCUMENTLOADER_PRINT( "GENERAL LAYOUT START ITEM: GRID ITEM" );
   164             HB_DOCUMENTLOADER_PRINT( "GENERAL LAYOUT START ITEM: GRID ITEM" );
    97             if( mReader.name() == lexemValue( GL_GRIDCELL ) ) {
   165             if( mReader.name() == lexemValue( GL_GRIDCELL ) ) {
    98 
   166 
    99                 const QString src = attribute( GL_ITEMNAME );
   167                 const QString src = attribute( GL_ITEMNAME );
   100 
       
   101                 const QString row = attribute( GL_ROW );
   168                 const QString row = attribute( GL_ROW );
   102                 const QString column = attribute( GL_COLUMN );
   169                 const QString column = attribute( GL_COLUMN );
   103                 const QString rowspan = attribute( GL_ROWSPAN );
   170                 const QString rowspan = attribute( GL_ROWSPAN );
   104                 const QString columnspan = attribute( GL_COLUMNSPAN );
   171                 const QString columnspan = attribute( GL_COLUMNSPAN );
   105                 const QString alignment = attribute( TYPE_ALIGNMENT );
   172                 const QString alignment = attribute( TYPE_ALIGNMENT );
   106                 result = mRealActions->addGridLayoutCell( src, row, column, rowspan, columnspan, alignment );
   173 
       
   174                 int rownum = row.toInt( &result );
       
   175                 if (!result) {
       
   176                     HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO ROW SPECIFIED" ) );
       
   177                     break;
       
   178                 }
       
   179 
       
   180                 int columnnum = column.toInt( &result );
       
   181                 if (!result) {
       
   182                     HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO COLUMN SPECIFIED" ) );
       
   183                     break;
       
   184                 }
       
   185 
       
   186                 int rowspannum;
       
   187                 int *rowspan_p = 0;
       
   188                 if (!rowspan.isEmpty()) {
       
   189                     rowspannum = rowspan.toInt( &result );
       
   190                     if (!result) {
       
   191                         HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INVALID ROWSPAN" ) );
       
   192                         break;
       
   193                     } else {
       
   194                         rowspan_p = &rowspannum;
       
   195                     }
       
   196                 }
       
   197 
       
   198                 int columnspannum;
       
   199                 int *columnspan_p = 0;
       
   200                 if (!columnspan.isEmpty()) {
       
   201                     columnspannum = columnspan.toInt( &result );
       
   202                     if (!result) {
       
   203                         HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INVALID ROWSPAN" ) );
       
   204                         break;
       
   205                     } else {
       
   206                         columnspan_p = &columnspannum;
       
   207                     }
       
   208                 }
       
   209 
       
   210                 Qt::Alignment align;
       
   211                 Qt::Alignment *align_p = 0;
       
   212                 if (!alignment.isEmpty()) {
       
   213                     AccessToMetadata myAccess;
       
   214                     int value = myAccess.getEnumValue( "Alignment", alignment.toLatin1().data() );
       
   215                     if (value == -1) {
       
   216                         HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO SUCH ALIGNMENT " ) + alignment );
       
   217                         result = false;
       
   218                         break;
       
   219                     } else {
       
   220                         align = (Qt::Alignment)value;
       
   221                         align_p = &align;
       
   222                     }
       
   223                 }
       
   224                 result = mActions->addGridLayoutCell( src, rownum, columnnum, rowspan_p, columnspan_p, align_p );
   107             } else if( mReader.name() == lexemValue( GL_GRIDROW ) ) {
   225             } else if( mReader.name() == lexemValue( GL_GRIDROW ) ) {
   108                 const QString row = attribute( GL_ROW );
   226                 const QString row = attribute( GL_ROW );
   109                 const QString stretchfactor = attribute( ATTR_STRETCHFACTOR );
   227                 const QString stretchfactor = attribute( ATTR_STRETCHFACTOR );
   110                 const QString alignment = attribute( TYPE_ALIGNMENT );
   228                 const QString alignment = attribute( TYPE_ALIGNMENT );
   111                 result = mRealActions->setGridLayoutRowProperties( row, stretchfactor, alignment );
   229 
       
   230                 const int rownum = row.toInt( &result );
       
   231                 if (!result) {
       
   232                     HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO ROW NUMBER SPECIFIED FOR STRETCH FACTOR" ) );
       
   233                     break;
       
   234                 }
       
   235 
       
   236                 int stretchnum;
       
   237                 int *stretch_p = 0;
       
   238                 if( !stretchfactor.isEmpty() ) {
       
   239                     stretchnum = stretchfactor.toInt( &result );
       
   240                     if (!result) {
       
   241                         HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: UNABLE TO PARSE ROW STRETCH FACTOR VALUE" ) );
       
   242                         break;
       
   243                     } else {
       
   244                         stretch_p = &stretchnum;
       
   245                     }
       
   246                 }
       
   247 
       
   248                 Qt::Alignment align;
       
   249                 Qt::Alignment *align_p = 0;
       
   250                 if( !alignment.isEmpty() ) {
       
   251                     AccessToMetadata myAccess;
       
   252 
       
   253                     int value = myAccess.getEnumValue( "Alignment", alignment.toLatin1().data() );
       
   254                     if( value == -1 ) {
       
   255                         HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO SUCH ROW ALIGNMENT " ) + alignment );
       
   256                         result = false;
       
   257                         break;
       
   258                     } else {
       
   259                         align = (Qt::Alignment)value;
       
   260                         align_p = &align;
       
   261                     }
       
   262                 }
       
   263 
       
   264                 result = mActions->setGridLayoutRowProperties( rownum, stretch_p, align_p );
   112                 if (result) {
   265                 if (result) {
   113                     result = processRowHeights( row );
   266                     result = processRowHeights( rownum );
   114                 }
   267                 }
   115             } else if( mReader.name() == lexemValue( GL_GRIDCOLUMN ) ) {
   268             } else if( mReader.name() == lexemValue( GL_GRIDCOLUMN ) ) {
   116                 const QString column = attribute( GL_COLUMN );
   269                 const QString column = attribute( GL_COLUMN );
   117                 const QString stretchfactor = attribute( ATTR_STRETCHFACTOR );
   270                 const QString stretchfactor = attribute( ATTR_STRETCHFACTOR );
   118                 const QString alignment = attribute( TYPE_ALIGNMENT );
   271                 const QString alignment = attribute( TYPE_ALIGNMENT );
   119                 result = mRealActions->setGridLayoutColumnProperties( column, stretchfactor, alignment );
   272 
       
   273                 const int columnnum = column.toInt( &result );
       
   274                 if (!result) {
       
   275                     HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO COLUMN NUMBER SPECIFIED FOR STRETCH FACTOR" ) );
       
   276                     break;
       
   277                 }
       
   278 
       
   279                 int stretchnum;
       
   280                 int *stretch_p = 0;
       
   281                 if (!stretchfactor.isEmpty()) {
       
   282                     stretchnum = stretchfactor.toInt( &result );
       
   283                     if (!result) {
       
   284                         HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: UNABLE TO PARSE COLUMN STRETCH FACTOR VALUE" ) );
       
   285                         break;
       
   286                     } else {
       
   287                         stretch_p = &stretchnum;
       
   288                     }
       
   289                 }
       
   290 
       
   291                 Qt::Alignment align;
       
   292                 Qt::Alignment *align_p = 0;
       
   293                 if (!alignment.isEmpty()) {
       
   294                     AccessToMetadata myAccess;
       
   295 
       
   296                     int value = myAccess.getEnumValue( "Alignment", alignment.toLatin1().data() );
       
   297                     if (value == -1) {
       
   298                         HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: NO SUCH COLUMN ALIGNMENT " ) + alignment );
       
   299                         result = false;
       
   300                         break;
       
   301                     } else {
       
   302                         align = (Qt::Alignment)value;
       
   303                         align_p = &align;
       
   304                     }
       
   305                 }
       
   306 
       
   307                 result = mActions->setGridLayoutColumnProperties( columnnum, stretch_p, align_p );
   120                 if (result) {
   308                 if (result) {
   121                     result = processColumnWidths( column );
   309                     result = processColumnWidths( columnnum );
   122                 }
   310                 }
   123             } else if( mReader.name() == lexemValue( TYPE_CONTENTSMARGINS ) ) {
   311             } else if( mReader.name() == lexemValue( TYPE_CONTENTSMARGINS ) ) {
   124                 result = processContentsMargins();
   312                 result = processContentsMargins();
   125             }
   313             }
   126             break;
   314             break;
   128         case LAYOUT_LINEAR:
   316         case LAYOUT_LINEAR:
   129         {
   317         {
   130             HB_DOCUMENTLOADER_PRINT( "GENERAL LAYOUT START ITEM: LINEAR ITEM" );
   318             HB_DOCUMENTLOADER_PRINT( "GENERAL LAYOUT START ITEM: LINEAR ITEM" );
   131             if( mReader.name() == lexemValue( LL_LINEARITEM ) ) {
   319             if( mReader.name() == lexemValue( LL_LINEARITEM ) ) {
   132                 result = true;
   320                 result = true;
       
   321                 const QString itemname = attribute( LL_ITEMNAME );
   133                 const QString index = attribute( LL_INDEX );
   322                 const QString index = attribute( LL_INDEX );
   134                 const QString itemname = attribute( LL_ITEMNAME );
       
   135                 const QString spacing = attribute( LL_SPACING );
       
   136                 const QString stretchfactor = attribute( ATTR_STRETCHFACTOR );
   323                 const QString stretchfactor = attribute( ATTR_STRETCHFACTOR );
   137                 const QString alignment = attribute( TYPE_ALIGNMENT );
   324                 const QString alignment = attribute( TYPE_ALIGNMENT );
   138                 
   325                 const QString spacing = attribute( LL_SPACING );
   139                 qreal spacingValue(0);
   326 
   140                 qreal *spacingPtr(0);
   327                 int indexnum;
   141                 if( !spacing.isEmpty() ) {
   328                 int *index_p = 0;
   142                     result = toPixels( spacing, spacingValue );
   329                 if (!index.isEmpty()) {
   143                     spacingPtr = &spacingValue;
   330                     indexnum = index.toInt( &result );
       
   331                     if (!result) {
       
   332                         HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: UNABLE TO PARSE ITEM INDEX" ) );
       
   333                         break;
       
   334                     } else {
       
   335                         index_p = &indexnum;
       
   336                     }
       
   337                 }
       
   338 
       
   339                 int stretchnum;
       
   340                 int *stretch_p = 0;
       
   341                 if (!stretchfactor.isEmpty()) {
       
   342                     stretchnum = stretchfactor.toInt( &result );
       
   343                     if (!result) {
       
   344                         HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: UNABLE TO PARSE STRETCH VALUE" ) );
       
   345                         break;
       
   346                     } else {
       
   347                         stretch_p = &stretchnum;
       
   348                     }
       
   349                 }
       
   350 
       
   351                 Qt::Alignment align;
       
   352                 Qt::Alignment *align_p = 0;
       
   353                 if (!alignment.isEmpty()) {
       
   354                     AccessToMetadata myAccess;
       
   355 
       
   356                     int value = myAccess.getEnumValue( "Alignment", alignment.toLatin1().data() );
       
   357                     if (value == -1) {
       
   358                         HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: NO SUCH ITEM ALIGNMENT " ) + alignment );
       
   359                         result = false;
       
   360                         break;
       
   361                     } else {
       
   362                         align = (Qt::Alignment)value;
       
   363                         align_p = &align;
       
   364                     }
       
   365                 }
       
   366 
       
   367                 HbXmlLengthValue spacingValue;
       
   368                 if (!spacing.isEmpty()) {
       
   369                     result = toLengthValue( spacing, spacingValue );
   144                 }
   370                 }
   145                 if (result) {
   371                 if (result) {
   146                     result = mRealActions->addLinearLayoutItem( itemname, index, stretchfactor, alignment, spacingPtr );
   372                     result = mActions->addLinearLayoutItem( itemname, index_p, stretch_p, align_p, spacingValue );
   147                 }
   373                 }
   148             } else if( mReader.name() == lexemValue( LL_STRETCH ) ) {
   374             } else if( mReader.name() == lexemValue( LL_STRETCH ) ) {
   149                 const QString index = attribute( LL_INDEX );
   375                 const QString index = attribute( LL_INDEX );
   150                 const QString stretchfactor = attribute( ATTR_STRETCHFACTOR );
   376                 const QString stretchfactor = attribute( ATTR_STRETCHFACTOR );
   151 
   377 
   152                 result = mRealActions->addLinearLayoutStretch( index, stretchfactor );
   378                 int indexnum;
       
   379                 int *index_p = 0;
       
   380                 if (!index.isEmpty()) {
       
   381                     indexnum = index.toInt( &result );
       
   382                     if (!result) {
       
   383                         HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: UNABLE TO PARSE STRETCH INDEX" ) );
       
   384                         break;
       
   385                     } else {
       
   386                         index_p = &indexnum;
       
   387                     }
       
   388                 }
       
   389 
       
   390                 int stretchnum;
       
   391                 int *stretch_p = 0;
       
   392                 if (!stretchfactor.isEmpty()) {
       
   393                     stretchnum = stretchfactor.toInt( &result );
       
   394                     if (!result) {
       
   395                         HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: UNABLE TO PARSE STRETCH VALUE" ) );
       
   396                         break;
       
   397                     } else {
       
   398                         stretch_p = &stretchnum;
       
   399                     }
       
   400                 }
       
   401 
       
   402                 result = mActions->addLinearLayoutStretch( index_p, stretch_p );
   153             } else if( mReader.name() == lexemValue( TYPE_CONTENTSMARGINS ) ) {
   403             } else if( mReader.name() == lexemValue( TYPE_CONTENTSMARGINS ) ) {
   154                 result = processContentsMargins();
   404                 result = processContentsMargins();
   155             }
   405             }
   156             break;
   406             break;
   157         }
   407         }
   161             if( mReader.name() == lexemValue( SL_STACKITEM ) ) {
   411             if( mReader.name() == lexemValue( SL_STACKITEM ) ) {
   162 
   412 
   163                 const QString index = attribute( SL_INDEX );
   413                 const QString index = attribute( SL_INDEX );
   164                 const QString itemname = attribute( SL_ITEMNAME );
   414                 const QString itemname = attribute( SL_ITEMNAME );
   165 
   415 
   166                 result =  mRealActions->addStackedLayoutItem( itemname, index );
   416                 int indexnum;
       
   417                 int *index_p = 0;
       
   418                 if( !index.isEmpty() ) {
       
   419                     indexnum = index.toInt( &result );
       
   420                     if( !result ) {
       
   421                         HB_DOCUMENTLOADER_PRINT( QString( "STACKEDLAYOUT: UNABLE TO PARSE ITEM INDEX" ) );
       
   422                         break;
       
   423                     } else {
       
   424                         index_p = &indexnum;
       
   425                     }
       
   426                 }
       
   427                 result = mActions->addStackedLayoutItem( itemname, index_p );
   167             }
   428             }
   168             break;
   429             break;
   169 
   430 
   170         }
   431         }
   171         case LAYOUT_NULL:
   432         case LAYOUT_NULL:
   176         default:
   437         default:
   177         {
   438         {
   178             qWarning() << "Internal error, wrong layout type, line " << mReader.lineNumber();
   439             qWarning() << "Internal error, wrong layout type, line " << mReader.lineNumber();
   179         }
   440         }
   180     }
   441     }
       
   442 #ifdef LINE_DEBUGGING
       
   443     debugPrint("MYTRACE: --- after line %d, time: %d", (int)mReader.lineNumber(), lineDebugTime.elapsed());
       
   444 #endif
   181     return result;
   445     return result;
   182 }
   446 }
   183 
   447 
   184 bool HbDocumentLoaderSyntax::processContentsMargins()
   448 bool HbDocumentLoaderSyntax::processContentsMargins()
   185 {
   449 {
   187     const QString topS = attribute( ATTR_TOP );
   451     const QString topS = attribute( ATTR_TOP );
   188     const QString rightS = attribute( ATTR_RIGHT );
   452     const QString rightS = attribute( ATTR_RIGHT );
   189     const QString bottomS = attribute( ATTR_BOTTOM );
   453     const QString bottomS = attribute( ATTR_BOTTOM );
   190 
   454 
   191     bool result = true;
   455     bool result = true;
   192     qreal left = 0, top = 0, right = 0, bottom = 0;
   456     HbXmlLengthValue left, top, right, bottom;
   193     if ( !leftS.isEmpty() ) {
   457     if ( !leftS.isEmpty() ) {
   194         result = toPixels(leftS, left);
   458         result = toLengthValue(leftS, left);
   195     }
   459     }
   196     if ( result && !topS.isEmpty() ) {
   460     if ( result && !topS.isEmpty() ) {
   197         result = toPixels(topS, top);
   461         result = toLengthValue(topS, top);
   198     }
   462     }
   199     if ( result && !rightS.isEmpty() ) {
   463     if ( result && !rightS.isEmpty() ) {
   200         result = toPixels(rightS, right);
   464         result = toLengthValue(rightS, right);
   201     }
   465     }
   202     if ( result && !bottomS.isEmpty() ) {
   466     if ( result && !bottomS.isEmpty() ) {
   203         result = toPixels(bottomS, bottom);
   467         result = toLengthValue(bottomS, bottom);
   204     }
   468     }
   205 
   469 
   206     if ( result ) {
   470     if ( result ) {
   207         result = mRealActions->setLayoutContentsMargins( left, top, right, bottom );
   471         result = mActions->setLayoutContentsMargins( left, top, right, bottom );
   208     }
   472     }
   209 
   473 
   210     if (!result) {
   474     if (!result) {
   211         qWarning() << "Invalid contents margins, line " << mReader.lineNumber();
   475         qWarning() << "Invalid contents margins, line " << mReader.lineNumber();
   212     }
   476     }
   213 
   477 
   214     return result;
   478     return result;
   215 }
   479 }
   216 
   480 
   217 bool HbDocumentLoaderSyntax::processRowHeights( const QString &row )
   481 bool HbDocumentLoaderSyntax::processRowHeights( int row )
   218 {
   482 {
   219     const QString minHeightS = attribute( GL_MINHEIGHT );
   483     const QString minHeightS = attribute( GL_MINHEIGHT );
   220     const QString maxHeightS = attribute( GL_MAXHEIGHT );
   484     const QString maxHeightS = attribute( GL_MAXHEIGHT );
   221     const QString prefHeightS = attribute( GL_PREFHEIGHT );
   485     const QString prefHeightS = attribute( GL_PREFHEIGHT );
   222     const QString fixedHeightS = attribute( GL_FIXEDHEIGHT );
   486     const QString fixedHeightS = attribute( GL_FIXEDHEIGHT );
   223     const QString rowSpacingS = attribute( GL_SPACING );
   487     const QString rowSpacingS = attribute( GL_SPACING );
   224     qreal minHeight = -1;
   488     HbXmlLengthValue minHeight, maxHeight, prefHeight, fixedHeight, rowSpacing;
   225     qreal maxHeight = -1;
       
   226     qreal prefHeight = -1;
       
   227     qreal fixedHeight = -1;
       
   228     qreal rowSpacing = -1;
       
   229 
   489 
   230     bool result = true;
   490     bool result = true;
   231     int propertyAvailable = 0;
       
   232 
   491 
   233     if ( !minHeightS.isEmpty() ) {
   492     if ( !minHeightS.isEmpty() ) {
   234         result = toPixels(minHeightS, minHeight);
   493         result = toLengthValue(minHeightS, minHeight);
   235         propertyAvailable |= HbDocumentLoaderActions::propertyMin;
       
   236     }
   494     }
   237 
   495 
   238     if ( result && !maxHeightS.isEmpty() ) {
   496     if ( result && !maxHeightS.isEmpty() ) {
   239         result = toPixels(maxHeightS, maxHeight);
   497         result = toLengthValue(maxHeightS, maxHeight);
   240         propertyAvailable |= HbDocumentLoaderActions::propertyMax;
       
   241     }
   498     }
   242 
   499 
   243     if ( result && !prefHeightS.isEmpty() ) {
   500     if ( result && !prefHeightS.isEmpty() ) {
   244         result = toPixels(prefHeightS, prefHeight);
   501         result = toLengthValue(prefHeightS, prefHeight);
   245         propertyAvailable |= HbDocumentLoaderActions::propertyPref;
       
   246     }
   502     }
   247 
   503 
   248     if ( result && !fixedHeightS.isEmpty() ) {
   504     if ( result && !fixedHeightS.isEmpty() ) {
   249         result = toPixels(fixedHeightS, fixedHeight);
   505         result = toLengthValue(fixedHeightS, fixedHeight);
   250         propertyAvailable |= HbDocumentLoaderActions::propertyFixed;
       
   251     }
   506     }
   252 
   507 
   253     if ( result && !rowSpacingS.isEmpty() ) {
   508     if ( result && !rowSpacingS.isEmpty() ) {
   254         result = toPixels(rowSpacingS, rowSpacing);
   509         result = toLengthValue(rowSpacingS, rowSpacing);
   255         propertyAvailable |= HbDocumentLoaderActions::propertySpacing;
   510     }
   256     }
   511 
   257 
   512     if ( result ) {
   258     if ( result && propertyAvailable ) {
   513         result = mActions->setGridLayoutRowHeights(
   259         result = mRealActions->setGridLayoutRowHeights( row, minHeight, maxHeight, 
   514             row, minHeight, maxHeight, prefHeight, fixedHeight, rowSpacing);
   260                                                         prefHeight, fixedHeight, 
       
   261                                                         rowSpacing, propertyAvailable);
       
   262     }
   515     }
   263 
   516 
   264     return result;
   517     return result;
   265 }
   518 }
   266 
   519 
   267 bool HbDocumentLoaderSyntax::processColumnWidths( const QString &column )
   520 bool HbDocumentLoaderSyntax::processColumnWidths( int column )
   268 {
   521 {
   269     const QString minWidthS = attribute( GL_MINWIDTH );
   522     const QString minWidthS = attribute( GL_MINWIDTH );
   270     const QString maxWidthS = attribute( GL_MAXWIDTH );
   523     const QString maxWidthS = attribute( GL_MAXWIDTH );
   271     const QString prefWidthS = attribute( GL_PREFWIDTH );
   524     const QString prefWidthS = attribute( GL_PREFWIDTH );
   272     const QString fixedWidthS = attribute( GL_FIXEDWIDTH );
   525     const QString fixedWidthS = attribute( GL_FIXEDWIDTH );
   273     const QString columnSpacingS = attribute( GL_SPACING );
   526     const QString columnSpacingS = attribute( GL_SPACING );
   274     qreal minWidth = -1;
   527     HbXmlLengthValue minWidth, maxWidth, prefWidth, fixedWidth, columnSpacing;
   275     qreal maxWidth = -1;
       
   276     qreal prefWidth = -1;
       
   277     qreal fixedWidth = -1;
       
   278     qreal columnSpacing = -1;
       
   279 
   528 
   280     bool result = true;
   529     bool result = true;
   281     int propertyAvailable = 0;
       
   282 
   530 
   283     if ( !minWidthS.isEmpty() ) {
   531     if ( !minWidthS.isEmpty() ) {
   284         result = toPixels(minWidthS, minWidth);
   532         result = toLengthValue(minWidthS, minWidth);
   285         propertyAvailable |= HbDocumentLoaderActions::propertyMin;
       
   286     }
   533     }
   287 
   534 
   288     if ( result && !maxWidthS.isEmpty() ) {
   535     if ( result && !maxWidthS.isEmpty() ) {
   289         result = toPixels(maxWidthS, maxWidth);
   536         result = toLengthValue(maxWidthS, maxWidth);
   290         propertyAvailable |= HbDocumentLoaderActions::propertyMax;
       
   291     }
   537     }
   292 
   538 
   293     if ( result && !prefWidthS.isEmpty() ) {
   539     if ( result && !prefWidthS.isEmpty() ) {
   294         result = toPixels(prefWidthS, prefWidth);
   540         result = toLengthValue(prefWidthS, prefWidth);
   295         propertyAvailable |= HbDocumentLoaderActions::propertyPref;
       
   296     }
   541     }
   297 
   542 
   298     if ( result && !fixedWidthS.isEmpty() ) {
   543     if ( result && !fixedWidthS.isEmpty() ) {
   299         result = toPixels(fixedWidthS, fixedWidth);
   544         result = toLengthValue(fixedWidthS, fixedWidth);
   300         propertyAvailable |= HbDocumentLoaderActions::propertyFixed;
       
   301     }
   545     }
   302 
   546 
   303     if ( result && !columnSpacingS.isEmpty() ) {
   547     if ( result && !columnSpacingS.isEmpty() ) {
   304         result = toPixels(columnSpacingS, columnSpacing);
   548         result = toLengthValue(columnSpacingS, columnSpacing);
   305         propertyAvailable |= HbDocumentLoaderActions::propertySpacing;
   549     }
   306     }
   550 
   307 
   551     if ( result ) {
   308     if ( result && propertyAvailable ) {
   552         result = mActions->setGridLayoutColumnWidths(
   309         result = mRealActions->setGridLayoutColumnWidths( column, minWidth, maxWidth, 
   553             column, minWidth, maxWidth, prefWidth, fixedWidth, columnSpacing);
   310                                                           prefWidth, fixedWidth, 
       
   311                                                           columnSpacing, propertyAvailable);
       
   312     }
   554     }
   313 
   555 
   314     return result;
   556     return result;
   315 }
   557 }
       
   558 
       
   559 bool HbDocumentLoaderSyntax::checkEndElementCorrectness()
       
   560 {
       
   561     return HbXmlLoaderBaseSyntax::checkEndElementCorrectness();
       
   562 }
       
   563 
       
   564 
   316 
   565 
   317 bool HbDocumentLoaderSyntax::readContainerStartItem()
   566 bool HbDocumentLoaderSyntax::readContainerStartItem()
   318 {
   567 {
   319     bool result = false;
   568     bool result = false;
   320     switch ( mCurrentElementType ) {
   569     switch ( mCurrentElementType ) {
   321          case PROPERTY:
   570          case HbXml::PROPERTY:
   322          {
   571          {
   323             HB_DOCUMENTLOADER_PRINT( "CONTAINER START ITEM: PROPERTY" );
   572             HB_DOCUMENTLOADER_PRINT( "CONTAINER START ITEM: PROPERTY" );
   324 
   573 
   325             switch( mCurrentContainerType ) {
   574             switch( mCurrentContainerType ) {
   326                 case CONTAINER_STRINGLIST:
   575                 case CONTAINER_STRINGLIST:
   357     return result;
   606     return result;
   358 }
   607 }
   359 
   608 
   360 bool HbDocumentLoaderSyntax::readContainerEndItem()
   609 bool HbDocumentLoaderSyntax::readContainerEndItem()
   361 {
   610 {
       
   611 
   362     bool result = false;
   612     bool result = false;
   363     QString currentPropertyName;
   613     QString currentPropertyName;
   364     QVariant variant;
   614     QVariant variant;
   365 
   615 
   366     switch( mCurrentElementType ) {
   616     switch( mCurrentElementType ) {
   367         case CONTAINER:
   617         case HbXml::CONTAINER:
   368         {
   618         {
   369             currentPropertyName = mCurrentContainer.back();
   619             currentPropertyName = mCurrentContainerNames.back();
   370             mCurrentContainer.removeLast();
   620             mCurrentContainerNames.removeLast();
   371 
   621 
   372             if (mRealActions->mCurrentContainer) {
   622             result = mActions->pushContainer(currentPropertyName.toLatin1(), mCurrentContainerType, mCurrentContainer);
   373                 // in order for the conversion to work, all of the contained types need to be suitable and equivalent, e.g. strings
       
   374                 QVariant variantContainer = QVariant(*(mRealActions->mCurrentContainer));
       
   375                 if (variantContainer.isValid()) {
       
   376                     switch(mCurrentContainerType) {
       
   377                         case CONTAINER_STRINGLIST:
       
   378                         {
       
   379                             QStringList list = variantContainer.toStringList();
       
   380                             variant = QVariant(list);
       
   381                             break;
       
   382                         }
       
   383                         default:
       
   384                         {
       
   385                             variant = variantContainer;
       
   386                             break;
       
   387                         }
       
   388                     }
       
   389                 }
       
   390             }
       
   391 
       
   392             result = mRealActions->pushProperty(currentPropertyName, variant);
       
   393 
   623 
   394             HB_DOCUMENTLOADER_PRINT( "CONTAINER END ITEM : SWITCHING TO GENERAL ITEM PROCESSING MODE" );
   624             HB_DOCUMENTLOADER_PRINT( "CONTAINER END ITEM : SWITCHING TO GENERAL ITEM PROCESSING MODE" );
   395             mElementState = ES_GENERAL_ITEM;
   625             mElementState = ES_GENERAL_ITEM;
   396 
       
   397             result = true;
       
   398             break;
   626             break;
   399         }
   627         }
   400         default:
   628         default:
   401         {
   629         {
   402             result = HbXmlLoaderAbstractSyntax::readGeneralEndItem();
   630             result = HbXmlLoaderBaseSyntax::readGeneralEndItem();
   403             break;
   631             break;
   404         }
   632         }
   405     }
   633     }
   406     return result;
   634     return result;
   407 }
   635 }
   408 
   636 
   409 bool HbDocumentLoaderSyntax::readGeneralStartItem()
   637 bool HbDocumentLoaderSyntax::readGeneralStartItem()
   410 {
   638 {
   411     bool result = false;
   639     bool result = false;
   412     switch( mCurrentElementType ) {
   640     switch( mCurrentElementType ) {
   413          case OBJECT:
   641          case HbXml::OBJECT:
   414          {
   642          {
   415             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: OBJECT" );
   643             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: OBJECT" );
   416             result = processObject();
   644             result = processObject();
   417             break;
   645             break;
   418          }
   646          }
   419          case WIDGET:
   647          case HbXml::WIDGET:
   420          {
   648          {
   421             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: WIDGET" );
   649             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: WIDGET" );
   422             result = processWidget();
   650             result = processWidget();
   423             break;
   651             break;
   424          }
   652          }
   425          case SPACERITEM:
   653          case HbXml::SPACERITEM:
   426          {
   654          {
   427             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: SPACERITEM" );
   655             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: SPACERITEM" );
   428             result = processSpacerItem();
   656             result = processSpacerItem();
   429             break;
   657             break;
   430          }
   658          }
   431          case CONNECT:
   659          case HbXml::CONNECT:
   432          {
   660          {
   433             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: CONNECT" );
   661             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: CONNECT" );
   434             result = processConnect();
   662             result = processConnect();
   435             break;
   663             break;
   436          }
   664          }
   437          case PROPERTY:
   665          case HbXml::PROPERTY:
   438          {
   666          {
   439             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: PROPERTY" );
   667             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: PROPERTY" );
   440             result = processProperty();
   668             result = processProperty();
   441             break;
   669             break;
   442          }
   670          }
   443          case REF:
   671          case HbXml::REF:
   444          {
   672          {
   445             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: REF" );
   673             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: REF" );
   446             result = processRef();
   674             result = processRef();
   447             break;
   675             break;
   448          }
   676          }
   449          case VARIABLE:
   677          case HbXml::VARIABLE:
   450          {
   678          {
   451             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: VARIABLE" );
   679             HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: VARIABLE" );
   452             result = processVariable();
   680             result = processVariable();
   453             break;
   681             break;
   454          }
   682          }
   455          case DEPRECATED:
   683          case HbXml::DEPRECATED:
   456          {
   684          {
   457              HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: DEPRECATED" );
   685              HB_DOCUMENTLOADER_PRINT( "GENERAL START ITEM: DEPRECATED" );
   458              result = true;
   686              result = true;
   459              break;
   687              break;
   460          }
   688          }
   461          default:
   689          default:
   462          {
   690          {
   463               result = HbXmlLoaderAbstractSyntax::readGeneralStartItem();
   691               result = HbXmlLoaderBaseSyntax::readGeneralStartItem();
   464          }
   692          }
   465     }
   693     }
       
   694 #ifdef LINE_DEBUGGING
       
   695     debugPrint("MYTRACE: --- after line %d, time: %d", (int)mReader.lineNumber(), lineDebugTime.elapsed());
       
   696 #endif
   466     return result;
   697     return result;
   467 }
   698 }
   468 
   699 
   469 bool HbDocumentLoaderSyntax::processDocument()
   700 bool HbDocumentLoaderSyntax::processDocument()
   470 {
   701 {
   499     if( ! res ) {
   730     if( ! res ) {
   500         qWarning() << "Not supported document version " + ver_str + ". Current parser version is: " + version();
   731         qWarning() << "Not supported document version " + ver_str + ". Current parser version is: " + version();
   501         return false;
   732         return false;
   502 
   733 
   503     }
   734     }
   504     return mRealActions->pushDocument( attribute( ATTR_CONTEXT ) );
   735     return mActions->pushDocument( attribute( ATTR_CONTEXT ) );
   505 }
   736 }
   506 
   737 
   507 bool HbDocumentLoaderSyntax::processObject()
   738 bool HbDocumentLoaderSyntax::processObject()
   508 {
   739 {
   509     const QString type = attribute( ATTR_TYPE );
   740     const QString type = attribute( ATTR_TYPE );
   510     const QString name = attribute( ATTR_NAME );
   741     const QString name = attribute( ATTR_NAME );
   511 
   742 
   512     if( !mRealActions->pushObject( type, name ) ) {
   743     bool pushOK = mActions->pushObject( type, name );
       
   744     if( !pushOK ) {
   513         qWarning() << "Error in object processing, line " << mReader.lineNumber();
   745         qWarning() << "Error in object processing, line " << mReader.lineNumber();
   514         return false;
   746         return false;
   515     }
   747     }
   516     return true;
   748     return true;
   517 }
   749 }
   520 {
   752 {
   521     const QString type = attribute( ATTR_TYPE );
   753     const QString type = attribute( ATTR_TYPE );
   522     const QString name = attribute( ATTR_NAME );
   754     const QString name = attribute( ATTR_NAME );
   523     const QString role = attribute( ATTR_ROLE );
   755     const QString role = attribute( ATTR_ROLE );
   524     const QString plugin = attribute( ATTR_PLUGIN );
   756     const QString plugin = attribute( ATTR_PLUGIN );
   525     if( !mRealActions->pushWidget( type, name, role, plugin) ) {
   757     bool pushOK = mActions->pushWidget( type, name, role, plugin);
       
   758     if( !pushOK ) {
   526         qWarning() << "Error in widget processing, line " << mReader.lineNumber();
   759         qWarning() << "Error in widget processing, line " << mReader.lineNumber();
   527         return false;
   760         return false;
   528     }
   761     }
   529     return true;
   762     return true;
   530 }
   763 }
   532 bool HbDocumentLoaderSyntax::processSpacerItem()
   765 bool HbDocumentLoaderSyntax::processSpacerItem()
   533 {
   766 {
   534     const QString name = attribute( ATTR_NAME );
   767     const QString name = attribute( ATTR_NAME );
   535     const QString widget = attribute( ATTR_WIDGET );
   768     const QString widget = attribute( ATTR_WIDGET );
   536 
   769 
   537     if( !mRealActions->pushSpacerItem( name, widget ) ) {
   770     bool pushOK = mActions->pushSpacerItem( name, widget );
       
   771     if( !pushOK ) {
   538         qWarning() << "Error in object processing, line " << mReader.lineNumber();
   772         qWarning() << "Error in object processing, line " << mReader.lineNumber();
   539         return false;
   773         return false;
   540     }
   774     }
   541     return true;
   775     return true;
   542 }
   776 }
   548     const QString widget = attribute( ATTR_WIDGET );
   782     const QString widget = attribute( ATTR_WIDGET );
   549 
   783 
   550     if( layout_type == lexemValue( LAYOUT_ANCHOR ) ) {
   784     if( layout_type == lexemValue( LAYOUT_ANCHOR ) ) {
   551 
   785 
   552         mCurrentLayoutType = LAYOUT_ANCHOR;
   786         mCurrentLayoutType = LAYOUT_ANCHOR;
   553         result = mRealActions->createAnchorLayout( widget );
   787         result = mActions->createAnchorLayout( widget );
   554 
   788 
   555     } else if( layout_type == lexemValue( LAYOUT_GRID ) ) {
   789     } else if( layout_type == lexemValue( LAYOUT_GRID ) ) {
   556 
   790 
   557         result = true;
   791         result = true;
   558         mCurrentLayoutType = LAYOUT_GRID;
   792         mCurrentLayoutType = LAYOUT_GRID;
   559         const QString spacing = attribute( GL_SPACING );
   793         const QString spacing = attribute( GL_SPACING );
   560         qreal spacingValue(0);
   794         HbXmlLengthValue spacingValue;
   561         qreal *spacingPtr(0);
       
   562         if( !spacing.isEmpty() ) {
   795         if( !spacing.isEmpty() ) {
   563             result = toPixels( spacing, spacingValue );
   796             result = toLengthValue( spacing, spacingValue );
   564             spacingPtr = &spacingValue;
       
   565         }
   797         }
   566         if (result) {
   798         if (result) {
   567             result = mRealActions->createGridLayout( widget, spacingPtr );
   799             result = mActions->createGridLayout( widget, spacingValue );
   568         }
   800         }
   569 
   801 
   570     } else if( layout_type == lexemValue( LAYOUT_LINEAR ) ) {
   802     } else if( layout_type == lexemValue( LAYOUT_LINEAR ) ) {
   571 
   803 
   572         result = true;
   804         result = true;
   573         mCurrentLayoutType = LAYOUT_LINEAR;
   805         mCurrentLayoutType = LAYOUT_LINEAR;
   574         const QString orientation = attribute( LL_ORIENTATION );
   806         const QString orientation = attribute( LL_ORIENTATION );
       
   807 
       
   808 
       
   809         Qt::Orientation orient;
       
   810         Qt::Orientation *orient_p = 0;
       
   811         if (!orientation.isEmpty()) {
       
   812             AccessToMetadata myAccess;
       
   813             int value = myAccess.getEnumValue( "Orientation", orientation.toLatin1().data() );
       
   814             if (value == -1) {
       
   815                 HB_DOCUMENTLOADER_PRINT( QString( "LINEARLAYOUT: NO SUCH ORIENTATION " ) + orientation );
       
   816                 result = false;
       
   817             } else {
       
   818                 orient = (Qt::Orientation)value;
       
   819                 orient_p = &orient;
       
   820             }
       
   821         }
       
   822 
   575         const QString spacing = attribute( LL_SPACING );
   823         const QString spacing = attribute( LL_SPACING );
   576         qreal spacingValue(0);
   824         HbXmlLengthValue spacingValue;
   577         qreal *spacingPtr(0);
   825         if( result && !spacing.isEmpty() ) {
   578         if( !spacing.isEmpty() ) {
   826             result = toLengthValue( spacing, spacingValue );
   579             result = toPixels( spacing, spacingValue );
       
   580             spacingPtr = &spacingValue;
       
   581         }
   827         }
   582         if (result) {
   828         if (result) {
   583             result = mRealActions->createLinearLayout( widget, orientation, spacingPtr );
   829             result = mActions->createLinearLayout( widget, orient_p, spacingValue );
   584         }
   830         }
   585 
   831 
   586     } else if( layout_type == lexemValue( LAYOUT_STACK ) ) {
   832     } else if( layout_type == lexemValue( LAYOUT_STACK ) ) {
   587 
   833 
   588         mCurrentLayoutType = LAYOUT_STACK;
   834         mCurrentLayoutType = LAYOUT_STACK;
   589         result = mRealActions->createStackedLayout( widget );
   835         result = mActions->createStackedLayout( widget );
   590 
   836 
   591     } else if( layout_type == lexemValue( LAYOUT_NULL ) ) {
   837     } else if( layout_type == lexemValue( LAYOUT_NULL ) ) {
   592 
   838 
   593         mCurrentLayoutType = LAYOUT_NULL;
   839         mCurrentLayoutType = LAYOUT_NULL;
   594         result = mRealActions->createNullLayout( widget );
   840         result = mActions->createNullLayout( widget );
   595 
   841 
   596     } else {
   842     } else {
   597         return HbXmlLoaderAbstractSyntax::processLayout();
   843         return HbXmlLoaderBaseSyntax::processLayout();
   598     }
   844     }
   599 
   845 
   600     if( !result ) {
   846     if( !result ) {
   601         qWarning() << "Unable to create layout, line " << mReader.lineNumber();
   847         qWarning() << "Unable to create layout, line " << mReader.lineNumber();
   602         return false;
   848         return false;
   609     const QString srcName = attribute( ATTR_SRC );
   855     const QString srcName = attribute( ATTR_SRC );
   610     const QString signalName = attribute( ATTR_SIGNAL );
   856     const QString signalName = attribute( ATTR_SIGNAL );
   611     const QString dstName = attribute( ATTR_DST );
   857     const QString dstName = attribute( ATTR_DST );
   612     const QString slotName = attribute( ATTR_SLOT );
   858     const QString slotName = attribute( ATTR_SLOT );
   613 
   859 
   614     if( !mRealActions->pushConnect( srcName, signalName, dstName, slotName ) ) {
   860     bool pushOK = mActions->pushConnect( srcName, signalName, dstName, slotName );
       
   861     if( !pushOK ) {
   615         qWarning() << "Error in connect processing, line " << mReader.lineNumber();
   862         qWarning() << "Error in connect processing, line " << mReader.lineNumber();
   616         return false;
   863         return false;
   617 
   864 
   618     }
   865     }
   619     return true;
   866     return true;
   620 }
   867 }
   621 
   868 
   622 bool HbDocumentLoaderSyntax::processContainer()
   869 bool HbDocumentLoaderSyntax::processContainer()
   623 {
   870 {
   624     bool result = false;
   871     bool result = true;
   625     const QString container_type = attribute( ATTR_TYPE );
   872     const QString container_type = attribute( ATTR_TYPE );
   626 
   873 
   627     if( container_type == lexemValue( CONTAINER_STRINGLIST ) ) {
   874     if( container_type == lexemValue( CONTAINER_STRINGLIST ) ) {
   628 
   875 
   629         mCurrentContainerType = CONTAINER_STRINGLIST;
   876         mCurrentContainerType = CONTAINER_STRINGLIST;
   630 
   877 
   631         const QString propertyName = attribute ( ATTR_NAME );
   878         const QString propertyName = attribute ( ATTR_NAME );
   632         mCurrentContainer << propertyName;
   879         if (propertyName.isEmpty()) {
   633         result = mRealActions->createContainer();
   880             qWarning() << "No property name defined, line " << mReader.lineNumber();
   634 
   881             result = false;
       
   882         }
       
   883         if (result) {
       
   884             mCurrentContainerNames << propertyName;
       
   885             mCurrentContainer.clear();
       
   886         }
   635     } else {
   887     } else {
   636         return HbXmlLoaderAbstractSyntax::processContainer();
   888         result = HbXmlLoaderBaseSyntax::processContainer();
   637     }
   889         if( !result ) {
   638 
   890             qWarning() << "Unable to create container, line " << mReader.lineNumber();
   639     if( !result ) {
   891             return false;
   640         qWarning() << "Unable to create container, line " << mReader.lineNumber();
   892         }
       
   893     }
       
   894     return result;
       
   895 }
       
   896 
       
   897 bool HbDocumentLoaderSyntax::processContainedProperty()
       
   898 {
       
   899     HbXmlVariable *variable = new HbXmlVariable();
       
   900     if ( !createVariable(*variable) ) {
       
   901         qWarning() << "Invalid property, line " << mReader.lineNumber();
       
   902         delete variable;
   641         return false;
   903         return false;
   642     }
   904     }
       
   905 
       
   906     mCurrentContainer.append(variable);
   643     return true;
   907     return true;
   644 }
   908 }
   645 
   909 
   646 bool HbDocumentLoaderSyntax::processContainedProperty()
   910 bool HbDocumentLoaderSyntax::processProperty()
   647 {
   911 {
   648     const QVariant value = decodeValue();
   912     HbXmlVariable variable;
   649     if( ! value.isValid() ) {
   913     if ( !createVariable(variable) ) {
   650         qWarning() << "Invalid property, line " << mReader.lineNumber();
   914         qWarning() << "Invalid property, line " << mReader.lineNumber();
   651         return false;
   915         return false;
   652     }
   916     }
   653 
   917 
   654     if( !mRealActions->appendPropertyToContainer( value ) ) {
   918     const QString propertyName = attribute( ATTR_NAME );
       
   919 
       
   920     if( propertyName.isEmpty() ) {
       
   921         qWarning() << "No property name defined, line " << mReader.lineNumber();
       
   922         return false;
       
   923     }
       
   924 
       
   925     bool pushOK = mActions->pushProperty( propertyName.toLatin1(), variable );
       
   926     if( !pushOK ) {
   655         qWarning() << "Unable to set property, line " << mReader.lineNumber();
   927         qWarning() << "Unable to set property, line " << mReader.lineNumber();
   656         return false;
   928         return false;
   657     }
   929     }
   658     return true;
   930     return true;
   659 }
   931 }
   660 
   932 
   661 bool HbDocumentLoaderSyntax::processProperty()
       
   662 {
       
   663     const QVariant value = decodeValue();
       
   664     if( ! value.isValid() ) {
       
   665         qWarning() << "Invalid property, line " << mReader.lineNumber();
       
   666         return false;
       
   667     }
       
   668 
       
   669     const QString propertyName = attribute( ATTR_NAME );
       
   670 
       
   671     if( !mRealActions->pushProperty( propertyName, value ) ) {
       
   672         qWarning() << "Unable to set property, line " << mReader.lineNumber();
       
   673         return false;
       
   674     }
       
   675     return true;
       
   676 }
       
   677 
       
   678 bool HbDocumentLoaderSyntax::processRef()
   933 bool HbDocumentLoaderSyntax::processRef()
   679 {
   934 {
   680     const QString objectName = attribute( ATTR_OBJECT );
   935     const QString objectName = attribute( ATTR_OBJECT );
   681     const QString role = attribute( ATTR_ROLE );
   936     const QString role = attribute( ATTR_ROLE );
   682 
   937 
   683     if( !mRealActions->pushRef( objectName, role ) ) {
   938     bool pushOK = mActions->pushRef( objectName, role );
       
   939     if( !pushOK ) {
   684         qWarning() << "Error in reference processing, line " << mReader.lineNumber();
   940         qWarning() << "Error in reference processing, line " << mReader.lineNumber();
   685         return false;
   941         return false;
   686     }
   942     }
   687     return true;
   943     return true;
   688 }
   944 }
   719         const QString topS = attribute( ATTR_TOP );
   975         const QString topS = attribute( ATTR_TOP );
   720         const QString rightS = attribute( ATTR_RIGHT );
   976         const QString rightS = attribute( ATTR_RIGHT );
   721         const QString bottomS = attribute( ATTR_BOTTOM );
   977         const QString bottomS = attribute( ATTR_BOTTOM );
   722 
   978 
   723         result = true;
   979         result = true;
   724         qreal left = 0, top = 0, right = 0, bottom = 0;
   980         HbXmlLengthValue left, top, right, bottom;
   725         if ( !leftS.isEmpty() ) {
   981         if ( !leftS.isEmpty() ) {
   726             result = toPixels(leftS, left);
   982             result = toLengthValue(leftS, left);
   727         }
   983         }
   728         if ( result && !topS.isEmpty() ) {
   984         if ( result && !topS.isEmpty() ) {
   729             result = toPixels(topS, top);
   985             result = toLengthValue(topS, top);
   730         }
   986         }
   731         if ( result && !rightS.isEmpty() ) {
   987         if ( result && !rightS.isEmpty() ) {
   732             result = toPixels(rightS, right);
   988             result = toLengthValue(rightS, right);
   733         }
   989         }
   734         if ( result && !bottomS.isEmpty() ) {
   990         if ( result && !bottomS.isEmpty() ) {
   735             result = toPixels(bottomS, bottom);
   991             result = toLengthValue(bottomS, bottom);
   736         }
   992         }
   737 
   993 
   738         if ( result ) {
   994         if ( result ) {
   739             result = mRealActions->setContentsMargins( left, top, right, bottom );
   995             result = mActions->setContentsMargins( left, top, right, bottom );
   740         }
   996         }
   741 
   997 
   742         if (!result) {
   998         if (!result) {
   743             qWarning() << "Invalid contents margins, line " << mReader.lineNumber();
   999             qWarning() << "Invalid contents margins, line " << mReader.lineNumber();
   744         }
  1000         }
   784                 }
  1040                 }
   785             }
  1041             }
   786         }
  1042         }
   787 
  1043 
   788         if ( result ) {
  1044         if ( result ) {
   789             result = mRealActions->setSizePolicy( hPol, vPol, hStretch, vStretch );
  1045             result = mActions->setSizePolicy( hPol, vPol, hStretch, vStretch );
   790         }
  1046         }
   791         delete hPol;
  1047         delete hPol;
   792         delete vPol;
  1048         delete vPol;
   793         delete hStretch;
  1049         delete hStretch;
   794         delete vStretch;
  1050         delete vStretch;
   804 
  1060 
   805         if (convertSizeHintType(attribute( ATTR_TYPE ), hint, fixed)) {
  1061         if (convertSizeHintType(attribute( ATTR_TYPE ), hint, fixed)) {
   806 
  1062 
   807             result = true;
  1063             result = true;
   808 
  1064 
   809             qreal *sizeHintWidth = 0;
  1065             HbXmlLengthValue sizeHintWidth;
   810             const QString width = attribute( ATTR_WIDTH );
  1066             const QString width = attribute( ATTR_WIDTH );
   811             if (!width.isEmpty()) {
  1067             if (!width.isEmpty()) {
   812                 qreal widthInPixels;
  1068                 result = toLengthValue(width, sizeHintWidth);
   813                 result = toPixels(width, widthInPixels);
  1069             }
   814                 if (result) {
  1070 
   815                     sizeHintWidth = new qreal;
  1071             HbXmlLengthValue sizeHintHeight;
   816                     *sizeHintWidth = widthInPixels;
       
   817                 }
       
   818             }
       
   819 
       
   820             qreal *sizeHintHeight = 0;
       
   821             const QString height = attribute( ATTR_HEIGHT );
  1072             const QString height = attribute( ATTR_HEIGHT );
   822             if (result && !height.isEmpty()) {
  1073             if (result && !height.isEmpty()) {
   823                 qreal heightInPixels;
  1074                 result = toLengthValue(height, sizeHintHeight);
   824                 result = toPixels(height, heightInPixels);
       
   825                 if (result) {
       
   826                     sizeHintHeight = new qreal;
       
   827                     *sizeHintHeight = heightInPixels;
       
   828                 }
       
   829             }
  1075             }
   830 
  1076 
   831             if (result) {
  1077             if (result) {
   832                 result = mRealActions->setSizeHint(hint, sizeHintWidth, sizeHintHeight, fixed);
  1078                 result = mActions->setSizeHint(hint, sizeHintWidth, sizeHintHeight, fixed);
   833             }
  1079             }
   834         }
  1080         }
   835 
  1081 
   836         if (!result) {
  1082         if (!result) {
   837             qWarning() << "Invalid size hint, line " << mReader.lineNumber();
  1083             qWarning() << "Invalid size hint, line " << mReader.lineNumber();
   838         }
  1084         }
   839     } else if ( type == lexemValue( TYPE_ZVALUE ) ) {
  1085     } else if ( type == lexemValue( TYPE_ZVALUE ) ) {
   840         const QString zValueAsString = attribute( ATTR_VALUE );
  1086         const QString value = attribute( ATTR_VALUE );
   841         if (!zValueAsString.isEmpty()) {
  1087         if (!value.isEmpty()) {
   842             qreal zValueAsReal;
  1088             HbXmlLengthValue *value_res = new HbXmlLengthValue();
   843             result = toReal(zValueAsString, zValueAsReal);
  1089             result = toLengthValue( value, *value_res );
   844             if ( result ) {
  1090             if( result ) {
   845                 result = mRealActions->setZValue( zValueAsReal );
  1091                 HbXmlVariable variable;
       
  1092                 variable.mType = HbXmlVariable::REAL;
       
  1093                 variable.mParameters.append( value_res );
       
  1094                 result = mActions->pushProperty( ZValueProperty, variable );
       
  1095             } else {
       
  1096                 delete value_res;
   846             }
  1097             }
   847         }
  1098         }
   848 
  1099 
   849         if (!result) {
  1100         if (!result) {
   850             qWarning() << "Invalid z value, line " << mReader.lineNumber();
  1101             qWarning() << "Invalid z value, line " << mReader.lineNumber();
   852     } else if ( type == lexemValue( TYPE_TOOLTIP ) ) {
  1103     } else if ( type == lexemValue( TYPE_TOOLTIP ) ) {
   853         const QString value = attribute( ATTR_VALUE );
  1104         const QString value = attribute( ATTR_VALUE );
   854         const QString comment = attribute( ATTR_COMMENT );
  1105         const QString comment = attribute( ATTR_COMMENT );
   855         const QString locId = attribute( ATTR_LOCID );
  1106         const QString locId = attribute( ATTR_LOCID );
   856 
  1107 
       
  1108         HbXmlVariable variable;
       
  1109 
       
  1110         QString *param1 = new QString();
       
  1111         QString *param2 = new QString();
       
  1112 
   857         if (!locId.isEmpty()) {
  1113         if (!locId.isEmpty()) {
   858             QByteArray locIdUtf8(locId.toUtf8());
  1114             variable.mType = HbXmlVariable::STRING;
   859             const QString translated = hbTrId(locIdUtf8);
  1115             *param1 = value;
   860             result = mRealActions->setToolTip( translated );
  1116             *param2 = locId;
   861         } else {
  1117         } else {
   862             const QString translated = mRealActions->translate( value, comment );
  1118             variable.mType = HbXmlVariable::LOCALIZED_STRING;
   863             result = mRealActions->setToolTip( translated );
  1119             *param1 = value;
   864         }
  1120             *param2 = comment;
       
  1121         }
       
  1122         variable.mParameters.append(param1);
       
  1123         variable.mParameters.append(param2);
       
  1124 
       
  1125         result = mActions->setToolTip(variable);
   865 
  1126 
   866         if (!result) {
  1127         if (!result) {
   867             qWarning() << "Invalid tooltip, line " << mReader.lineNumber();
  1128             qWarning() << "Invalid tooltip, line " << mReader.lineNumber();
   868         }
  1129         }
   869     }
  1130     }
   870 
  1131 
   871     return result;
  1132     return result;
   872 }
  1133 }
   873 
  1134 
   874 ElementType
  1135 HbXml::ElementType
   875     HbDocumentLoaderSyntax::elementType( QStringRef name ) const
  1136     HbDocumentLoaderSyntax::elementType( QStringRef name ) const
   876 {
  1137 {
   877     const QString stringName = name.toString();
  1138     const QString stringName = name.toString();
   878 
  1139 
   879     if( stringName == lexemValue(TYPE_DOCUMENT) ){
  1140     if( stringName == lexemValue(TYPE_DOCUMENT) ){
   880         return DOCUMENT;
  1141         return HbXml::DOCUMENT;
   881     }
  1142     }
   882     return HbXmlLoaderAbstractSyntax::elementType( name );
  1143     return HbXmlLoaderBaseSyntax::elementType( name );
   883 }
  1144 }
   884 
  1145 
   885 QVariant HbDocumentLoaderSyntax::decodeValue()
  1146 bool HbDocumentLoaderSyntax::createVariable( HbXmlVariable& variable )
   886 {
  1147 {
   887     QVariant result = QVariant::Invalid;
       
   888 
       
   889     const QString type = mReader.name().toString();
  1148     const QString type = mReader.name().toString();
   890 
  1149     bool ok = true;
   891     bool ok = false;
  1150 
   892     if( type == lexemValue( TYPE_INT ) ) {
  1151     if( type == lexemValue( TYPE_INT ) ) {
   893         const QString value = attribute( ATTR_VALUE );
  1152         const QString value = attribute( ATTR_VALUE );
   894         int int_res = value.toInt( &ok );
  1153         qint16 *int_res = new qint16();
   895         if( ok ) {
  1154         *int_res = value.toInt( &ok );
   896             result = int_res;
  1155         if ( ok ) {
       
  1156             variable.mType = HbXmlVariable::INT;
       
  1157             variable.mParameters.append(int_res);
       
  1158         } else {
       
  1159             delete int_res;
   897         }
  1160         }
   898     } else if( type == lexemValue( TYPE_REAL ) ) {
  1161     } else if( type == lexemValue( TYPE_REAL ) ) {
   899         const QString value = attribute( ATTR_VALUE );
  1162         const QString value = attribute( ATTR_VALUE );
   900         qreal qreal_res;
  1163         HbXmlLengthValue *value_res = new HbXmlLengthValue();
   901         ok = toPixels( value, qreal_res );
  1164         ok = toLengthValue( value, *value_res );
   902         if( ok ) {
  1165         if( ok ) {
   903             result = qreal_res;
  1166             variable.mType = HbXmlVariable::REAL;
       
  1167             variable.mParameters.append(value_res);
       
  1168         } else {
       
  1169             delete value_res;
   904         }
  1170         }
   905     } else if( type == lexemValue( TYPE_LOCALIZED_STRING ) ) {
  1171     } else if( type == lexemValue( TYPE_LOCALIZED_STRING ) ) {
   906         const QString value =
  1172         QString *value = new QString();
   907             mRealActions->translate( attribute( ATTR_VALUE ), attribute( ATTR_COMMENT ) );
  1173         QString *attr = new QString();
   908         result = value;
  1174         *value = attribute( ATTR_VALUE );
       
  1175         *attr = attribute( ATTR_COMMENT );
       
  1176         variable.mType = HbXmlVariable::LOCALIZED_STRING;
       
  1177         variable.mParameters.append(value);
       
  1178         variable.mParameters.append(attr);
   909     } else if( type == lexemValue( TYPE_STRING ) ) {
  1179     } else if( type == lexemValue( TYPE_STRING ) ) {
   910         const QString value = attribute( ATTR_VALUE );
  1180         QString *value = new QString();
   911         const QString locId = attribute( ATTR_LOCID );
  1181         QString *locId = new QString();
   912         if (!locId.isEmpty()) {
  1182         *value = attribute( ATTR_VALUE );
   913             QByteArray locIdUtf8(locId.toUtf8());
  1183         *locId = attribute( ATTR_LOCID );
   914             result = hbTrId(locIdUtf8);
  1184         variable.mType = HbXmlVariable::STRING;
   915         } else {
  1185         variable.mParameters.append(value);
   916             result = value;
  1186         variable.mParameters.append(locId);
   917         }
  1187     } else if( type == lexemValue( TYPE_ENUMS ) || type == lexemValue(TYPE_ALIGNMENT) || type == lexemValue(LL_ORIENTATION) ) {
   918     } else if( type == lexemValue( TYPE_ENUMS ) ) {
  1188         QString *value = new QString();
   919         result = attribute( ATTR_VALUE );
  1189         *value = attribute( ATTR_VALUE );
       
  1190         variable.mType = HbXmlVariable::ENUMS;
       
  1191         variable.mParameters.append(value);
   920     } else if ( type == lexemValue( TYPE_BOOL ) ) {
  1192     } else if ( type == lexemValue( TYPE_BOOL ) ) {
       
  1193         bool *boolVal = new bool();
   921         const QString value = attribute( ATTR_VALUE );
  1194         const QString value = attribute( ATTR_VALUE );
   922         if (value == lexemValue( VALUE_BOOL_TRUE ) ) {
  1195         if (value == lexemValue( VALUE_BOOL_TRUE ) ) {
   923             result = QVariant(true);
  1196             *boolVal = true;
   924         } else if (value == lexemValue( VALUE_BOOL_FALSE ) ) {
  1197         } else if (value == lexemValue( VALUE_BOOL_FALSE ) ) {
   925             result = QVariant(false);
  1198             *boolVal = false;
       
  1199         } else {
       
  1200             ok = false;
       
  1201         }
       
  1202         if (ok) {
       
  1203             variable.mType = HbXmlVariable::BOOL;
       
  1204             variable.mParameters.append(boolVal);
       
  1205         } else {
       
  1206             delete boolVal;
   926         }
  1207         }
   927     } else if ( type == lexemValue( TYPE_ICON ) ) {
  1208     } else if ( type == lexemValue( TYPE_ICON ) ) {
   928 
  1209 
   929         HbIcon icon;
  1210         QString *iconName = new QString(attribute( ATTR_ICONNAME ));
   930         ok = true;
  1211         HbXmlLengthValue *desiredWidth = new HbXmlLengthValue();
   931 
  1212         HbXmlLengthValue *desiredHeight = new HbXmlLengthValue();
   932         // Read optional iconName attribute (if not given, it's null icon)
       
   933         const QString iconName = attribute( ATTR_ICONNAME );
       
   934         if ( !iconName.isEmpty() ) {
       
   935             icon.setIconName( iconName );
       
   936         }
       
   937 
       
   938         qreal desiredWidth = 0;
       
   939         qreal desiredHeight = 0;
       
   940 
  1213 
   941         // Read optional width attribute
  1214         // Read optional width attribute
   942         const QString width = attribute( ATTR_WIDTH );
  1215         const QString width = attribute( ATTR_WIDTH );
   943         if (!width.isEmpty()) {
  1216         if (!width.isEmpty()) {
   944             ok = toPixels( width, desiredWidth );
  1217             ok = toLengthValue( width, *desiredWidth );
   945         }
  1218         }
   946 
  1219 
   947         // Read optional height attribute
  1220         // Read optional height attribute
   948         const QString height = attribute( ATTR_HEIGHT );
  1221         const QString height = attribute( ATTR_HEIGHT );
   949         if (ok && !height.isEmpty()) {
  1222         if (ok && !height.isEmpty()) {
   950             ok = toPixels( height, desiredHeight );
  1223             ok = toLengthValue( height, *desiredHeight );
   951         }
  1224         }
   952 
  1225 
   953         if (ok) {
  1226         if (ok) {
   954             if (!width.isEmpty() && !height.isEmpty()) {
  1227             variable.mType = HbXmlVariable::ICON;
   955                 icon.setSize(QSizeF(desiredWidth, desiredHeight));
  1228             variable.mParameters.append(iconName);
   956             } else if (!width.isEmpty()) {
  1229             variable.mParameters.append(desiredWidth);
   957                 icon.setWidth(desiredWidth);
  1230             variable.mParameters.append(desiredHeight);
   958             } else if (!height.isEmpty()) {
  1231         } else {
   959                 icon.setHeight(desiredHeight);
  1232             delete iconName;
   960             } else {
  1233             delete desiredWidth;
   961                 // neither defined.
  1234             delete desiredHeight;
   962             }
       
   963 
       
   964             result = icon;
       
   965         }
  1235         }
   966     } else if ( type == lexemValue(TYPE_SIZE) ) {
  1236     } else if ( type == lexemValue(TYPE_SIZE) ) {
   967 
  1237 
   968         const QString width = attribute( ATTR_WIDTH );
  1238         const QString width = attribute( ATTR_WIDTH );
   969         const QString height = attribute( ATTR_HEIGHT );
  1239         const QString height = attribute( ATTR_HEIGHT );
   970 
  1240 
   971         if (!width.isEmpty() && !height.isEmpty()) {
  1241         if (!width.isEmpty() && !height.isEmpty()) {
   972             ok = true;
  1242             HbXmlLengthValue *widthVal = new HbXmlLengthValue();
   973             QSizeF size;
  1243             HbXmlLengthValue *heightVal = new HbXmlLengthValue();
   974             qreal widthVal, heightVal;
  1244             ok = toLengthValue(width, *widthVal);
   975             ok = toPixels(width, widthVal);
       
   976             if (ok) {
  1245             if (ok) {
   977                 size.setWidth(widthVal);
  1246                 ok = toLengthValue(height, *heightVal);
   978                 ok = toPixels(height, heightVal);
       
   979             }
  1247             }
   980             if (ok) {
  1248             if (ok) {
   981                 size.setHeight(heightVal);
  1249                 variable.mType = HbXmlVariable::SIZE;
   982                 result = size;
  1250                 variable.mParameters.append(widthVal);
   983             }
  1251                 variable.mParameters.append(heightVal);
       
  1252             } else {
       
  1253                 delete widthVal;
       
  1254                 delete heightVal;
       
  1255             }
       
  1256         } else {
       
  1257             ok = false;
   984         }
  1258         }
   985 
  1259 
   986     } else if ( type == lexemValue(TYPE_RECT) ) {
  1260     } else if ( type == lexemValue(TYPE_RECT) ) {
   987 
  1261 
   988         const QString posx = attribute( ATTR_X );
  1262         const QString posx = attribute( ATTR_X );
   989         const QString posy = attribute( ATTR_Y );
  1263         const QString posy = attribute( ATTR_Y );
   990         const QString width = attribute( ATTR_WIDTH );
  1264         const QString width = attribute( ATTR_WIDTH );
   991         const QString height = attribute( ATTR_HEIGHT );
  1265         const QString height = attribute( ATTR_HEIGHT );
   992 
  1266 
   993         if (!width.isEmpty() && !height.isEmpty() && !posx.isEmpty() && !posy.isEmpty()) {
  1267         if (!width.isEmpty() && !height.isEmpty() && !posx.isEmpty() && !posy.isEmpty()) {
   994             ok = true;
  1268             HbXmlLengthValue *widthVal = new HbXmlLengthValue();
   995             QSizeF size;
  1269             HbXmlLengthValue *heightVal = new HbXmlLengthValue();
   996             QPointF point;
  1270             HbXmlLengthValue *posxVal = new HbXmlLengthValue();
   997             qreal widthVal, heightVal, posxVal, posyVal;
  1271             HbXmlLengthValue *posyVal = new HbXmlLengthValue();
   998             ok = toPixels(width, widthVal);
  1272             ok = toLengthValue(width, *widthVal);
   999             if (ok) {
  1273             if (ok) {
  1000                 size.setWidth(widthVal);
  1274                 ok = toLengthValue(height, *heightVal);
  1001                 ok = toPixels(height, heightVal);
       
  1002             }
  1275             }
  1003             if (ok) {
  1276             if (ok) {
  1004                 size.setHeight(heightVal);
  1277                 ok = toLengthValue(posx, *posxVal);
  1005                 ok = toPixels(posx, posxVal);
       
  1006             }
  1278             }
  1007             if (ok) {
  1279             if (ok) {
  1008                 point.setX(posxVal);
  1280                 ok = toLengthValue(posy, *posyVal);
  1009                 ok = toPixels(posy, posyVal);
       
  1010             }
  1281             }
  1011             if (ok) {
  1282             if (ok) {
  1012                 point.setY(posyVal);
  1283                 variable.mType = HbXmlVariable::RECT;
  1013                 result = QRectF(point, size);
  1284                 variable.mParameters.append(widthVal);
  1014             }
  1285                 variable.mParameters.append(heightVal);
       
  1286                 variable.mParameters.append(posxVal);
       
  1287                 variable.mParameters.append(posyVal);
       
  1288             } else {
       
  1289                 delete widthVal;
       
  1290                 delete heightVal;
       
  1291                 delete posxVal;
       
  1292                 delete posyVal;
       
  1293             }
       
  1294         } else {
       
  1295             ok = false;
  1015         }
  1296         }
  1016 
  1297 
  1017     } else if ( type == lexemValue(TYPE_POINT) ) {
  1298     } else if ( type == lexemValue(TYPE_POINT) ) {
  1018 
  1299 
  1019         const QString posx = attribute( ATTR_X );
  1300         const QString posx = attribute( ATTR_X );
  1020         const QString posy = attribute( ATTR_Y );
  1301         const QString posy = attribute( ATTR_Y );
  1021         if (!posx.isEmpty() && !posy.isEmpty()) {
  1302         if (!posx.isEmpty() && !posy.isEmpty()) {
  1022             ok = true;
  1303             HbXmlLengthValue *posxVal = new HbXmlLengthValue();
  1023             QPointF point;
  1304             HbXmlLengthValue *posyVal = new HbXmlLengthValue();
  1024             qreal posxVal, posyVal;
  1305             ok = toLengthValue(posx, *posxVal);
  1025             ok = toPixels(posx, posxVal);
       
  1026             if (ok) {
  1306             if (ok) {
  1027                 point.setX(posxVal);
  1307                 ok = toLengthValue(posy, *posyVal);
  1028                 ok = toPixels(posy, posyVal);
       
  1029             }
  1308             }
  1030             if (ok) {
  1309             if (ok) {
  1031                 point.setY(posyVal);
  1310                 variable.mType = HbXmlVariable::POINT;
  1032                 result = point;
  1311                 variable.mParameters.append(posxVal);
  1033             }
  1312                 variable.mParameters.append(posyVal);
  1034         }
  1313             } else {
  1035 
  1314                 delete posxVal;
  1036     } else if ( type == lexemValue(TYPE_ALIGNMENT) ) {
  1315                 delete posyVal;
  1037 
  1316             }
  1038         const QString alignment = attribute( ATTR_VALUE );
  1317         } else {
  1039         if (!alignment.isEmpty() ) {
  1318             ok = false;
  1040             result = alignment;
       
  1041         }
       
  1042 
       
  1043     } else if ( type == lexemValue(LL_ORIENTATION) ) {
       
  1044 
       
  1045         const QString orientation = attribute( ATTR_VALUE );
       
  1046         if (!orientation.isEmpty() ) {
       
  1047             result = orientation;
       
  1048         }
  1319         }
  1049 
  1320 
  1050     } else if ( type == lexemValue(TYPE_COLOR) ) {
  1321     } else if ( type == lexemValue(TYPE_COLOR) ) {
  1051 
  1322 
  1052         const QString curColor = attribute( ATTR_VALUE  );
  1323         const QString curColor = attribute( ATTR_VALUE  );
  1053         if (!curColor.isEmpty() ) {
  1324         if (!curColor.isEmpty() ) {
  1054             ok = true;
  1325             QColor *colorVal = new QColor(curColor);
  1055             result = QColor(curColor);
  1326             variable.mType = HbXmlVariable::COLOR;
       
  1327             variable.mParameters.append(colorVal);
       
  1328         } else {
       
  1329             ok = false;
  1056         }
  1330         }
  1057 
  1331 
  1058     } else if ( type == lexemValue(TYPE_FONTSPEC) ) {
  1332     } else if ( type == lexemValue(TYPE_FONTSPEC) ) {
  1059         QString roleString = attribute( ATTR_FONTSPECROLE );
  1333         QString roleString = attribute( ATTR_FONTSPECROLE );
  1060         HbFontSpec::Role role(HbFontSpec::Undefined);
  1334         HbFontSpec::Role role(HbFontSpec::Undefined);
  1061         ok = true;
       
  1062         if (!roleString.isEmpty()) {
  1335         if (!roleString.isEmpty()) {
  1063             ok = toFontSpecRole(roleString, role); // sets role if ok
  1336             ok = toFontSpecRole(roleString, role); // sets role if ok
  1064         }
  1337         }
  1065         if (ok) {
  1338         if (ok) {
  1066             HbFontSpec spec(role);
  1339             quint8 *role_b = new quint8();
       
  1340             *role_b = (quint8)role;
       
  1341             HbXmlLengthValue *height = new HbXmlLengthValue();
  1067             QString textHeightString = attribute( ATTR_TEXTHEIGHT );
  1342             QString textHeightString = attribute( ATTR_TEXTHEIGHT );
  1068             if (textHeightString.isEmpty()) {
  1343             if (textHeightString.isEmpty()) {
  1069                 // Deprecated.
  1344                 // Deprecated.
  1070                 textHeightString = attribute( ATTR_TEXTPANEHEIGHT );
  1345                 textHeightString = attribute( ATTR_TEXTPANEHEIGHT );
  1071             }
  1346             }
  1072             if (!textHeightString.isEmpty()) {
  1347             if (!textHeightString.isEmpty()) {
  1073                 qreal height(0);
  1348                 ok = toLengthValue(textHeightString, *height);
  1074                 ok = toPixels(textHeightString, height);
       
  1075                 if (ok) {
       
  1076                     spec.setTextHeight(qRound(height));
       
  1077                 }
       
  1078             }
  1349             }
  1079             if (ok) {
  1350             if (ok) {
  1080                 result = spec;
  1351                 variable.mType = HbXmlVariable::FONTSPEC;
       
  1352                 variable.mParameters.append(role_b);
       
  1353                 variable.mParameters.append(height);
       
  1354             } else {
       
  1355                 delete role_b;
       
  1356                 delete height;
  1081             }
  1357             }
  1082         }
  1358         }
  1083     }
  1359     }
  1084 
  1360 
  1085     else {
  1361     else {
  1086         // unknown property.
  1362         // unknown property.
  1087     }
  1363         ok = false;
  1088 
  1364     }
  1089     return result;
  1365     return ok;
  1090 }
  1366 }
  1091 
  1367 
  1092 bool HbDocumentLoaderSyntax::convertSizeHintType(
  1368 bool HbDocumentLoaderSyntax::convertSizeHintType(
  1093         const QString &type,
  1369         const QString &type,
  1094         Qt::SizeHint &resultHint,
  1370         Qt::SizeHint &resultHint,