~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to lib/kformula/formulaelement.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
     */
48
48
    FormulaElement(FormulaDocument* container);
49
49
 
 
50
    virtual FormulaElement* clone() { return 0; }
 
51
 
50
52
    /**
51
53
     * Returns the element the point is in.
52
54
     */
53
 
    BasicElement* goToPos(FormulaCursor*, const KoPoint& point);
 
55
    BasicElement* goToPos( FormulaCursor*, const LuPixelPoint& point );
 
56
 
 
57
    /**
 
58
     * Ordinary formulas are not write protected.
 
59
     */
 
60
    virtual bool readOnly( const BasicElement* /*child*/ ) const { return false; }
 
61
 
 
62
    /**
 
63
     * @returns whether its prohibited to change the sequence with this cursor.
 
64
     */
 
65
    virtual bool readOnly( const FormulaCursor* ) const { return false; }
54
66
 
55
67
    /**
56
68
     * Provide fast access to the rootElement for each child.
72
84
     * Gets called whenever something changes and we need to
73
85
     * recalc.
74
86
     */
75
 
    void changed();
 
87
    virtual void changed();
 
88
 
 
89
    /**
 
90
     * Gets called when a request has the side effect of moving the
 
91
     * cursor. In the end any operation that moves the cursor should
 
92
     * call this.
 
93
     */
 
94
    void cursorHasMoved( FormulaCursor* );
 
95
 
 
96
    void moveOutLeft( FormulaCursor* );
 
97
    void moveOutRight( FormulaCursor* );
 
98
    void moveOutBelow( FormulaCursor* );
 
99
    void moveOutAbove( FormulaCursor* );
 
100
 
 
101
    /**
 
102
     * Tell the user something has happened.
 
103
     */
 
104
    void tell( const QString& msg );
 
105
 
 
106
    /**
 
107
     * Gets called when the formula wants to vanish. The one who
 
108
     * holds it should create an appropriate command and execute it.
 
109
     */
 
110
    void removeFormula( FormulaCursor* );
 
111
 
 
112
    void insertFormula( FormulaCursor* );
 
113
 
 
114
    /**
 
115
     * Calculates our width and height and
 
116
     * our children's parentPosition.
 
117
     */
 
118
    virtual void calcSizes( const ContextStyle& context,
 
119
                            ContextStyle::TextStyle tstyle,
 
120
                            ContextStyle::IndexStyle istyle);
 
121
 
 
122
    /**
 
123
     * Draws the whole element including its children.
 
124
     * The `parentOrigin' is the point this element's parent starts.
 
125
     * We can use our parentPosition to get our own origin then.
 
126
     */
 
127
    virtual void draw( QPainter& painter, const LuPixelRect& r,
 
128
                       const ContextStyle& context,
 
129
                       ContextStyle::TextStyle tstyle,
 
130
                       ContextStyle::IndexStyle istyle,
 
131
                       const LuPixelPoint& parentOrigin );
76
132
 
77
133
    /**
78
134
     * Calculates the formulas sizes and positions.
82
138
    /**
83
139
     * Draws the whole thing.
84
140
     */
85
 
    void draw( QPainter& painter, const QRect& r, ContextStyle& context );
 
141
    void draw( QPainter& painter, const LuPixelRect& r, ContextStyle& context );
 
142
 
 
143
    /**
 
144
     * This is called by the container to get a command depending on
 
145
     * the current cursor position (this is how the element gets chosen)
 
146
     * and the request.
 
147
     *
 
148
     * @returns the command that performs the requested action with
 
149
     * the containers active cursor.
 
150
     */
 
151
    virtual KCommand* buildCommand( Container*, Request* );
86
152
 
87
153
    /**
88
154
     * @returns our documents symbol table
95
161
     */
96
162
    virtual QString toLatex();
97
163
 
98
 
    double getBaseSize() const { return baseSize; }
99
 
    void setBaseSize( double size ) { baseSize = size; }
 
164
    int getBaseSize() const { return baseSize; }
 
165
    void setBaseSize( int size );
 
166
 
 
167
    bool hasOwnBaseSize() const { return ownBaseSize; }
 
168
 
 
169
    virtual KCommand* input( Container* container, QKeyEvent* event );
 
170
 
 
171
    virtual void writeMathML( QDomDocument doc, QDomNode parent );
 
172
 
 
173
    /**
 
174
     * Appends our attributes to the dom element.
 
175
     */
 
176
    virtual void writeDom(QDomElement element);
 
177
 
 
178
    /**
 
179
     * For copy&paste we need to create an empty XML element.
 
180
     */
 
181
    QDomElement emptyFormulaElement( QDomDocument doc );
100
182
 
101
183
protected:
102
184
 
108
190
    virtual QString getTagName() const { return "FORMULA"; }
109
191
 
110
192
    /**
111
 
     * Appends our attributes to the dom element.
112
 
     */
113
 
    virtual void writeDom(QDomElement& element);
114
 
 
115
 
    /**
116
193
     * Reads our attributes from the element.
117
194
     * Returns false if it failed.
118
195
     */
119
 
    virtual bool readAttributesFromDom(QDomElement& element);
 
196
    virtual bool readAttributesFromDom(QDomElement element);
120
197
 
121
198
    /**
122
199
     * Reads our content from the node. Sets the node to the next node
129
206
private:
130
207
 
131
208
    /**
 
209
     * The introduction of 'NameSequence' changed the DOM.
 
210
     * However, we need to read the old version.
 
211
     */
 
212
    void convertNames( QDomNode node );
 
213
 
 
214
    /**
132
215
     * The document that owns (is) this formula.
133
216
     */
134
217
    FormulaDocument* document;
136
219
    /**
137
220
     * The base font size.
138
221
     */
139
 
    double baseSize;
 
222
    int baseSize;
 
223
 
 
224
    /**
 
225
     * Whether we want to use the default base size.
 
226
     */
 
227
    bool ownBaseSize;
140
228
};
141
229
 
142
230
KFORMULA_NAMESPACE_END