diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /lib/kformula/spaceelement.h | |
download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip |
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lib/kformula/spaceelement.h')
-rw-r--r-- | lib/kformula/spaceelement.h | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/lib/kformula/spaceelement.h b/lib/kformula/spaceelement.h new file mode 100644 index 00000000..52a666d1 --- /dev/null +++ b/lib/kformula/spaceelement.h @@ -0,0 +1,167 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Andrea Rizzi <rizzi@kde.org> + Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de> + Copyright (C) 2006 Alfredo Beaumont Sainz <alfredo.beaumont@gmail.com> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef SPACEELEMENT_H +#define SPACEELEMENT_H + +#include <qfont.h> +#include <qstring.h> + +#include "basicelement.h" + +class SymbolTable; + + +KFORMULA_NAMESPACE_BEGIN + +/** + * A element that represents a space. + */ +class SpaceElement : public BasicElement { + enum LineBreakType { + NoBreakType, + AutoBreak, + NewLineBreak, + IndentingNewLineBreak, + NoBreak, + GoodBreak, + BadBreak + }; + SpaceElement operator=( const SpaceElement& ) { return *this; } +public: + + SpaceElement( SpaceWidth space = THIN, bool tab=false, BasicElement* parent = 0 ); + SpaceElement( const SpaceElement& ); + + virtual SpaceElement* clone() { + return new SpaceElement( *this ); + } + + virtual bool accept( ElementVisitor* visitor ); + + /** + * @returns the type of this element. Used for + * parsing a sequence. + */ + //virtual TokenType getTokenType() const; + + /** + * @returns the character that represents this element. Used for + * parsing a sequence. + */ + virtual QChar getCharacter() const { return ' '; } + + // drawing + // + // Drawing depends on a conspace which knows the required properties like + // fonts, spaces and such. + // It is essential to calculate elements size with the same conspace + // before you draw. + + /** + * Calculates our width and height and + * our children's parentPosition. + */ + virtual void calcSizes( const ContextStyle& cstyle, + ContextStyle::TextStyle tstyle, + ContextStyle::IndexStyle istyle, + StyleAttributes& style ); + + /** + * Draws the whole element including its children. + * The `parentOrigin' is the point this element's parent starts. + * We can use our parentPosition to get our own origin then. + */ + virtual void draw( QPainter& painter, const LuPixelRect& r, + const ContextStyle& context, + ContextStyle::TextStyle tstyle, + ContextStyle::IndexStyle istyle, + StyleAttributes& style, + const LuPixelPoint& parentOrigin ); + + /** + * Moves the cursor away from the given child. The cursor is + * guaranteed to be inside this element. + */ + //virtual void childWillVanish(FormulaCursor*, BasicElement*) {} + + /** + * @returns the latex representation of the element and + * of the element's children + */ + virtual QString toLatex(); + +protected: + + //Save/load support + + /** + * @returns the tag name of this element type. + */ + virtual QString getTagName() const { return "SPACE"; } + + /** + * Appends our attributes to the dom element. + */ + virtual void writeDom(QDomElement element); + + /** + * Reads our attributes from the element. + * Returns false if it failed. + */ + virtual bool readAttributesFromDom(QDomElement element); + + /** + * Reads our content from the node. Sets the node to the next node + * that needs to be read. + * Returns false if it failed. + */ + virtual bool readContentFromDom(QDomNode& node); + + /** + * Reads our attributes from the MathML element. + * Returns false if it failed. + */ + virtual bool readAttributesFromMathMLDom(const QDomElement& element); + +private: + + virtual QString getElementName() const { return "mspace"; } + virtual void writeMathMLAttributes( QDomElement& element ) const ; + + /** + * Whether this space behaves like a tab. + */ + bool m_tab; + + // MathML Attributes, Section 3.2.7.2 + SizeType m_widthType; + double m_width; + SizeType m_heightType; + double m_height; + SizeType m_depthType; + double m_depth; + LineBreakType m_lineBreak; +}; + +KFORMULA_NAMESPACE_END + +#endif // SPACEELEMENT_H |