aknlayoutcompiler/inc/MLCompDataParse.h
changeset 0 f58d6ec98e88
child 1 b700e12870ca
equal deleted inserted replaced
-1:000000000000 0:f58d6ec98e88
       
     1 /*
       
     2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *    
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef MLCOMPDATAPARSE_H
       
    21 #define MLCOMPDATAPARSE_H
       
    22 
       
    23 // disable "identifier was truncated to '255' characters in the browser information" warning
       
    24 #pragma warning (disable:4786)
       
    25 
       
    26 #include "LayoutCompilerErr.h"
       
    27 #include "MLCompData.h"
       
    28 
       
    29 #include <avkon.hrh> // for logical font ids
       
    30 
       
    31 #include "SaxErrorHandler.h"
       
    32 
       
    33 #include <vector>
       
    34 #include <string>
       
    35 #include <iosfwd>
       
    36 #include <stack>
       
    37 
       
    38 using namespace std;
       
    39 
       
    40 
       
    41 //
       
    42 // defines
       
    43 //
       
    44 #define ELayoutCompilerFontCategoryUndefined KAknFontCategoryUndefined /* 0 */
       
    45 #define ELayoutCompilerFontCategoryPrimary KAknFontCategoryPrimary /* 1*/
       
    46 #define ELayoutCompilerFontCategorySecondary KAknFontCategorySecondary /* 2 */
       
    47 #define ELayoutCompilerFontCategoryTitle KAknFontCategoryTitle /* 3 */
       
    48 #define ELayoutCompilerFontCategoryPrimarySmall KAknFontCategoryPrimarySmall /* 4 */
       
    49 #define ELayoutCompilerFontCategoryDigital KAknFontCategoryDigital /* 5 */
       
    50 
       
    51 
       
    52 class MSaxLayoutHandler
       
    53 	{
       
    54 public:
       
    55 	typedef SAX::basic_Attributes<std::string> TAttribs;
       
    56 	virtual MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs) { return this; };
       
    57 	virtual void HandleSaxEnd(const std::string& aElement) { };
       
    58 	};
       
    59 
       
    60 
       
    61 // this corresponds to a "param" in the xml
       
    62 class TMLCompDataParseValues : public TMLCompDataValues, public MSaxLayoutHandler
       
    63 	{
       
    64 public:
       
    65 	TMLCompDataParseValues(TMLCompDataLine* aLine);
       
    66 	static int ConvertZoomStr(const std::string& aValueStr);
       
    67 public: // from MSaxLayoutHandler
       
    68 	MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
       
    69 private:
       
    70 	void HandleSaxEnd(const std::string& aElement);
       
    71 	void HandleSaxVariety(const std::string& aElement, const TAttribs& aAttribs);
       
    72 	void HandleSaxCalc(const std::string& aElement, const TAttribs& aAttribs);
       
    73 private:
       
    74 	void ConvertValueStr(std::string& aValueStr);
       
    75 private:
       
    76 	TMLCompDataZoomLevels* iSaxZoomLevels;
       
    77 	int iSaxVariety;
       
    78 	};
       
    79 
       
    80 // this corresponds to the contents of "ParentInfo" in the xml
       
    81 class TMLCompDataParseParentInfo : public TMLCompDataParentInfo, public MSaxLayoutHandler
       
    82 	{
       
    83 public:
       
    84 	TMLCompDataParseParentInfo(TMLCompDataLine* aLine);
       
    85 public: // from MSaxLayoutHandler
       
    86 	MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
       
    87 private:
       
    88 	void HandleSaxEnd(const std::string& aElement);
       
    89 	void HandleSaxParent(const std::string& aElement, const TAttribs& aAttribs);
       
    90 	void HandleSaxVariety(const std::string& aElement, const TAttribs& aAttribs);
       
    91 private:
       
    92 	TMLCompDataParentInfoSelector* iSaxParentInfoSelector;
       
    93 	int iSaxVariety;
       
    94 	};
       
    95 
       
    96 
       
    97 class TMLCompDataParseAttributeInfo;
       
    98 
       
    99 // this corresponds to a "component" in the xml
       
   100 class TMLCompDataParseLayoutLine : public TMLCompDataLine, public MSaxLayoutHandler
       
   101 	{
       
   102 public:
       
   103 	TMLCompDataParseLayoutLine();
       
   104 	string ShortParamName(string& aName);
       
   105 public: // from MSaxLayoutHandler
       
   106 	MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
       
   107 private:
       
   108 	void HandleSaxEnd(const std::string& aElement);
       
   109 	void HandleSaxAttributes(const TAttribs& aAttribs);
       
   110 	MSaxLayoutHandler* HandleSaxParent(const std::string& aElement, const TAttribs& aAttribs);
       
   111 	MSaxLayoutHandler* HandleSaxParam(const std::string& aElement, const TAttribs& aAttribs);
       
   112 	MSaxLayoutHandler* HandleSaxAttributeInfo(const std::string& aElement, const TAttribs& aAttribs);
       
   113 private:
       
   114 	TMLCompDataParseValues* iSaxValues;
       
   115 	TMLCompDataParseParentInfo* iSaxParentInfo;
       
   116 	TMLCompDataParseAttributeInfo* iSaxAttributeInfo;
       
   117 	};
       
   118 
       
   119 // this corresponds to the contents of "AttributeInfo" in the xml
       
   120 class TMLCompDataParseAttributeInfo : public TMLCompDataAttributeInfo, public MSaxLayoutHandler
       
   121 	{
       
   122 public:
       
   123 	TMLCompDataParseAttributeInfo(TMLCompDataLine* aLine);
       
   124 public: // from MSaxLayoutHandler
       
   125 	MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
       
   126 private:
       
   127 	void HandleSaxEnd(const std::string& aElement);
       
   128 	void HandleSaxVariety(const std::string& aElement, const TAttribs& aAttribs);
       
   129 	void HandleSaxAttributeSet(const std::string& aElement, const TAttribs& aAttribs);
       
   130 private:
       
   131 	TMLCompDataAttributeInfoSelector* iSaxAttributeInfoSelector;
       
   132 	int iSaxVariety;
       
   133 	};
       
   134 
       
   135 
       
   136 
       
   137 // this corresponds to a common parent component, and therefore does
       
   138 // not correspond directly to a structure in the xml, although in general
       
   139 // there is one per non-leaf component
       
   140 class TMLCompDataParseLayoutTable : public TMLCompDataTable, public MSaxLayoutHandler
       
   141 	{
       
   142 public:
       
   143 	TMLCompDataParseLayoutTable(TMLCompData* aTables);
       
   144 public: // from MSaxLayoutHandler
       
   145 	MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
       
   146 	};
       
   147 
       
   148 // this corresponds to a layout in the xml
       
   149 class TMLCompDataParseLayout : public TMLCompData, public MSaxLayoutHandler
       
   150 	{
       
   151 public:
       
   152 	static auto_ptr<TMLCompDataParseLayout> Parse(const string& aLayName);
       
   153 public: // from MSaxLayoutHandler
       
   154 	MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
       
   155 	};
       
   156 
       
   157 
       
   158 class TLayoutSaxParser : private SAX::basic_DefaultHandler<std::string>
       
   159 	{
       
   160 private:
       
   161 	typedef stack<MSaxLayoutHandler*> TSaxHandlerStack;
       
   162 	typedef SAX::basic_ErrorHandler<std::string>::SAXParseExceptionT TException;
       
   163 
       
   164 public:
       
   165 	TLayoutSaxParser(MSaxLayoutHandler* aHandler);
       
   166 	void Parse(const std::string& aFileName);
       
   167 
       
   168 private: // from basic_DefaultHandler
       
   169 	void startElement(const std::string& namespaceURI, const std::string& localName, const std::string& qName, const SAX::basic_Attributes<std::string>& atts);
       
   170 	void endElement(const std::string& namespaceURI, const std::string& localName, const std::string& qName);
       
   171 
       
   172 	void warning(const TException& aException);
       
   173 	void error(const TException& aException);
       
   174 	void fatalError(const TException& aException);
       
   175 
       
   176 private:
       
   177 	TSaxHandlerStack iStack;	// stack content not owned
       
   178 	};
       
   179 
       
   180 
       
   181 #endif // MLCOMPDATAPARSE_H
       
   182 
       
   183 // End of File