creationstrategy.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2003 Ulrich Kuettler <ulrich.kuettler@gmx.de>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <tqdom.h>
21
22#include "bracketelement.h"
23#include "creationstrategy.h"
24#include "elementtype.h"
25#include "fractionelement.h"
26#include "identifierelement.h"
27#include "indexelement.h"
28#include "matrixelement.h"
29#include "operatorelement.h"
30#include "rootelement.h"
31#include "sequenceelement.h"
32#include "spaceelement.h"
33#include "symbolelement.h"
34#include "textelement.h"
35#include "numberelement.h"
36
37KFORMULA_NAMESPACE_BEGIN
38
39BasicElement* OrdinaryCreationStrategy::createElement( TQString type, const TQDomElement& )
40{
41 if ( type == "TEXT" ) return new TextElement();
42 else if ( type == "EMPTY" ) return new EmptyElement();
43 else if ( type == "SPACE" ) return new SpaceElement();
44 else if ( type == "ROOT" ) return new RootElement();
45 else if ( type == "BRACKET" ) return new BracketElement();
46 else if ( type == "MATRIX" ) return new MatrixElement();
47 else if ( type == "INDEX" ) return new IndexElement();
48 else if ( type == "FRACTION" ) return new FractionElement();
49 else if ( type == "SYMBOL" ) return new SymbolElement();
50 else if ( type == "NAMESEQUENCE" ) return new NameSequence();
51 else if ( type == "OVERLINE" ) return new OverlineElement();
52 else if ( type == "UNDERLINE" ) return new UnderlineElement();
53 else if ( type == "MULTILINE" ) return new MultilineElement();
54 else if ( type == "SEQUENCE" ) {
55 kdWarning() << "malformed data: sequence inside sequence." << endl;
56 return 0;
57 }
58 return 0;
59}
60
61
63{
64 return new TextElement( ch, symbol );
65}
66
67EmptyElement* OrdinaryCreationStrategy::createEmptyElement()
68{
69 return new EmptyElement;
70}
71
72NameSequence* OrdinaryCreationStrategy::createNameSequence()
73{
74 return new NameSequence;
75}
76
77BracketElement* OrdinaryCreationStrategy::createBracketElement( SymbolType lhs, SymbolType rhs )
78{
79 return new BracketElement( lhs, rhs );
80}
81
82OverlineElement* OrdinaryCreationStrategy::createOverlineElement()
83{
84 return new OverlineElement;
85}
86
87UnderlineElement* OrdinaryCreationStrategy::createUnderlineElement()
88{
89 return new UnderlineElement;
90}
91
92MultilineElement* OrdinaryCreationStrategy::createMultilineElement()
93{
94 return new MultilineElement;
95}
96
97SpaceElement* OrdinaryCreationStrategy::createSpaceElement( SpaceWidth width )
98{
99 return new SpaceElement( width );
100}
101
102FractionElement* OrdinaryCreationStrategy::createFractionElement()
103{
104 return new FractionElement;
105}
106
107RootElement* OrdinaryCreationStrategy::createRootElement()
108{
109 return new RootElement;
110}
111
112SymbolElement* OrdinaryCreationStrategy::createSymbolElement( SymbolType type )
113{
114 return new SymbolElement( type );
115}
116
118{
119 return new MatrixElement( rows, columns );
120}
121
122IndexElement* OrdinaryCreationStrategy::createIndexElement()
123{
124 return new IndexElement;
125}
126
127IdentifierElement* OrdinaryCreationStrategy::createIdentifierElement()
128{
129 return new IdentifierElement();
130}
131
132OperatorElement* OrdinaryCreationStrategy::createOperatorElement()
133{
134 return new OperatorElement();
135}
136
137NumberElement* OrdinaryCreationStrategy::createNumberElement()
138{
139 return new NumberElement();
140}
141
142
143
144KFORMULA_NAMESPACE_END
Basis of every formula element.
A left and/or right bracket around one child.
An element that represents an empty box.
The element with up to four indexes in the four corners.
Any number of lines.
The sequence thats a name.
virtual MatrixElement * createMatrixElement(uint rows, uint columns)
when this gets called the user has seen the matrix dialog and expects a matrix!
virtual TextElement * createTextElement(const TQChar &ch, bool symbol=false)
there must always be a TextElement, so this can never return 0
A line above the content.
A nice graphical root.
Definition rootelement.h:35
A element that represents a space.
A symbol is simply a piece of art.
An element that represents one char.
Definition textelement.h:37
A line below the content.