lib
creationstrategy.cc
00001 /* This file is part of the KDE project 00002 Copyright (C) 2003 Ulrich Kuettler <ulrich.kuettler@gmx.de> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #include <qdom.h> 00021 00022 #include "bracketelement.h" 00023 #include "creationstrategy.h" 00024 #include "elementtype.h" 00025 #include "fractionelement.h" 00026 #include "identifierelement.h" 00027 #include "indexelement.h" 00028 #include "matrixelement.h" 00029 #include "operatorelement.h" 00030 #include "rootelement.h" 00031 #include "sequenceelement.h" 00032 #include "spaceelement.h" 00033 #include "symbolelement.h" 00034 #include "textelement.h" 00035 #include "numberelement.h" 00036 00037 KFORMULA_NAMESPACE_BEGIN 00038 00039 BasicElement* OrdinaryCreationStrategy::createElement( QString type, const QDomElement& ) 00040 { 00041 if ( type == "TEXT" ) return new TextElement(); 00042 else if ( type == "EMPTY" ) return new EmptyElement(); 00043 else if ( type == "SPACE" ) return new SpaceElement(); 00044 else if ( type == "ROOT" ) return new RootElement(); 00045 else if ( type == "BRACKET" ) return new BracketElement(); 00046 else if ( type == "MATRIX" ) return new MatrixElement(); 00047 else if ( type == "INDEX" ) return new IndexElement(); 00048 else if ( type == "FRACTION" ) return new FractionElement(); 00049 else if ( type == "SYMBOL" ) return new SymbolElement(); 00050 else if ( type == "NAMESEQUENCE" ) return new NameSequence(); 00051 else if ( type == "OVERLINE" ) return new OverlineElement(); 00052 else if ( type == "UNDERLINE" ) return new UnderlineElement(); 00053 else if ( type == "MULTILINE" ) return new MultilineElement(); 00054 else if ( type == "SEQUENCE" ) { 00055 kdWarning() << "malformed data: sequence inside sequence." << endl; 00056 return 0; 00057 } 00058 return 0; 00059 } 00060 00061 00062 TextElement* OrdinaryCreationStrategy::createTextElement( const QChar& ch, bool symbol ) 00063 { 00064 return new TextElement( ch, symbol ); 00065 } 00066 00067 EmptyElement* OrdinaryCreationStrategy::createEmptyElement() 00068 { 00069 return new EmptyElement; 00070 } 00071 00072 NameSequence* OrdinaryCreationStrategy::createNameSequence() 00073 { 00074 return new NameSequence; 00075 } 00076 00077 BracketElement* OrdinaryCreationStrategy::createBracketElement( SymbolType lhs, SymbolType rhs ) 00078 { 00079 return new BracketElement( lhs, rhs ); 00080 } 00081 00082 OverlineElement* OrdinaryCreationStrategy::createOverlineElement() 00083 { 00084 return new OverlineElement; 00085 } 00086 00087 UnderlineElement* OrdinaryCreationStrategy::createUnderlineElement() 00088 { 00089 return new UnderlineElement; 00090 } 00091 00092 MultilineElement* OrdinaryCreationStrategy::createMultilineElement() 00093 { 00094 return new MultilineElement; 00095 } 00096 00097 SpaceElement* OrdinaryCreationStrategy::createSpaceElement( SpaceWidth width ) 00098 { 00099 return new SpaceElement( width ); 00100 } 00101 00102 FractionElement* OrdinaryCreationStrategy::createFractionElement() 00103 { 00104 return new FractionElement; 00105 } 00106 00107 RootElement* OrdinaryCreationStrategy::createRootElement() 00108 { 00109 return new RootElement; 00110 } 00111 00112 SymbolElement* OrdinaryCreationStrategy::createSymbolElement( SymbolType type ) 00113 { 00114 return new SymbolElement( type ); 00115 } 00116 00117 MatrixElement* OrdinaryCreationStrategy::createMatrixElement( uint rows, uint columns ) 00118 { 00119 return new MatrixElement( rows, columns ); 00120 } 00121 00122 IndexElement* OrdinaryCreationStrategy::createIndexElement() 00123 { 00124 return new IndexElement; 00125 } 00126 00127 IdentifierElement* OrdinaryCreationStrategy::createIdentifierElement() 00128 { 00129 return new IdentifierElement(); 00130 } 00131 00132 OperatorElement* OrdinaryCreationStrategy::createOperatorElement() 00133 { 00134 return new OperatorElement(); 00135 } 00136 00137 NumberElement* OrdinaryCreationStrategy::createNumberElement() 00138 { 00139 return new NumberElement(); 00140 } 00141 00142 00143 00144 KFORMULA_NAMESPACE_END