32
/******************************************************************/
33
/* Class: KPTextObject */
34
/******************************************************************/
43
class KPrTextDocument;
36
class KPTextObject : public KP2DObject
48
class KPTextObject : public QObject, public KP2DObject
40
52
KPTextObject( KPresenterDoc *doc );
41
virtual ~KPTextObject() {}
43
virtual void setSize( int _width, int _height );
44
virtual void resizeBy( int _dx, int _dy );
53
virtual ~KPTextObject();
55
virtual DCOPObject* dcopObject();
57
virtual void setSize( double _width, double _height );
46
59
virtual void setDrawEditRect( bool b )
48
61
virtual void setDrawEmpty( bool b )
51
64
virtual ObjType getType() const
53
virtual int getSubPresSteps() const
54
{ return ktextobject.paragraphs() - 1; }
66
virtual QString getTypeString() const
67
{ return i18n("Text"); }
55
69
virtual bool getDrawEditRect() const
56
{ return drawEditRect; }
70
{ return drawEditRect; }
57
71
virtual bool getDrawEmpty() const
60
virtual KTextEdit* getKTextObject()
61
{ return &ktextobject; }
63
virtual QDomDocumentFragment save( QDomDocument& doc );
64
virtual void load(const QDomElement &element);
66
virtual void draw( QPainter *_painter, int _diffx, int _diffy );
68
virtual void activate( QWidget *_widget, int diffx, int diffy );
69
virtual void deactivate( KPresenterDoc *doc );
71
virtual void zoom( float _fakt );
72
virtual void zoomOrig();
74
virtual void extendObject2Contents( KPresenterView *view = 0 );
76
void recalcPageNum( KPresenterDoc *doc );
73
virtual int getSubPresSteps() const;
75
virtual QBrush getBrush() const;
77
virtual void setShadowParameter(int _distance,ShadowDirection _direction,const QColor &_color);
79
virtual QDomDocumentFragment save( QDomDocument& doc, double offset );
80
virtual double load(const QDomElement &element);
82
virtual void paint( QPainter *_painter, KoZoomHandler*_zoomHandler,
83
bool drawingShadow, bool drawContour );
84
void paint( QPainter *_painter, KoZoomHandler*_zoomHandler, bool onlyChanged, KoTextCursor* cursor,
85
bool resetChanged, bool drawContour );
86
void paintEdited( QPainter *_painter, KoZoomHandler*_zoomHandler,
87
bool onlyChanged, KoTextCursor* cursor, bool resetChanged );
89
void drawCursor( QPainter *p, KoTextCursor *cursor, bool cursorVisible, KPrCanvas* /*canvas*/ );
91
void recalcPageNum( KPrPage *page );
94
/** Return the contained text object */
95
KoTextObject * textObject() const { return m_textobj; }
96
virtual void addTextObjects( QPtrList<KoTextObject> &lst ) const {
97
if ( !isProtectContent() )
98
lst.append( m_textobj );
101
KPrTextDocument *textDocument() const;
103
KPresenterDoc* kPresenterDocument() const { return m_doc; }
105
KPTextView * createKPTextView( KPrCanvas * );
106
void applyStyleChange( StyleChangeDefMap changed );
108
void removeHighlight();
109
void highlightPortion( KoTextParag * parag, int index, int length, KPrCanvas *canvas, bool repaint, KDialogBase* dialog = 0 );
111
KCommand * pasteKPresenter( KoTextCursor * cursor, const QCString & data, bool removeSelected );
113
void saveParagraph( QDomDocument& doc,
115
QDomElement &parentElem,
116
int from /* default 0 */,
117
int to /* default length()-2 */ );
118
KoParagLayout loadParagLayout( QDomElement & parentElem, KPresenterDoc *doc, bool useRefStyle);
120
static KoTextFormat loadFormat( QDomElement &n, KoTextFormat * refFormat, const QFont & defaultFont,
121
const QString & defaultLanguage, bool hyphen );
123
void setEditingTextObj( bool _edit ) { editingTextObj = _edit; }
125
KCommand *textContentsToHeight();
126
KCommand *textObjectToContents();
127
void setProtectContent ( bool _protect ) { textObject()->setProtectContent(_protect);}
128
bool isProtectContent() const { return textObject()->protectContent();}
129
void loadVariable( QValueList<QDomElement> & listVariable,KoTextParag *lastParag, int offset=0 );
133
int availableHeight() const;
135
/** set left margin size */
136
void setBLeft( double b ) { bleft = b; }
137
/** set right margin size */
138
void setBRight( double b ) { bright = b; }
139
/** set top margin size */
140
void setBTop( double b ) { btop = b; }
141
/** set bottom margin size */
142
void setBBottom( double b ) { bbottom = b; }
144
/** get left margin size */
145
double bLeft()const { return bleft; }
146
/** get right margin size */
147
double bRight()const { return bright; }
148
/** get top margin size */
149
double bTop()const { return btop; }
150
/** get bottom margin size */
151
double bBottom()const { return bbottom; }
153
void setTextMargins( double _left, double _top, double right, double bottom);
155
KoRect innerRect() const;
156
double innerWidth() const;
157
double innerHeight() const;
158
void resizeTextDocument( bool widthChanged = true, bool heightChanged = true );
160
VerticalAlignmentType verticalAlignment() const { return m_textVertAlign; }
161
void setVerticalAligment( VerticalAlignmentType _type) ;
162
double alignmentValue() const { return alignVertical; }
163
virtual KPTextObject *nextTextObject() { return this;}
164
static void saveFormat( QDomElement & element, KoTextFormat*lastFormat );
166
void repaintChanged( KPTextObject* );
169
void slotFormatChanged(const KoTextFormat &);
170
void slotAfterFormatting( int, KoTextParag*, bool* );
171
void slotParagraphDeleted(KoTextParag*_parag);
79
173
virtual QDomElement saveKTextObject( QDomDocument& doc );
80
QDomElement saveHelper(const QString &tmpText, const QString &tmpFamily, const QString &tmpColor,
81
int tmpPointSize, unsigned int tmpBold, unsigned int tmpItalic,
82
unsigned int tmpUnderline, QDomDocument &doc);
84
virtual void loadKTextObject( const QDomElement &e, int type );
85
void drawParags( QPainter *p, int from, int to );
87
KTextEdit ktextobject;
88
bool drawEditRect, drawEmpty;
174
QDomElement saveHelper(const QString &tmpText,KoTextFormat*lastFormat ,QDomDocument &doc);
176
virtual void loadKTextObject( const QDomElement &e );
177
void drawText( QPainter* _painter, KoZoomHandler* zoomHandler, bool onlyChanged, KoTextCursor* cursor, bool resetChanged );
178
void drawParags( QPainter *p, KoZoomHandler* zoomHandler, const QColorGroup& cg, int from, int to );
179
void saveParagLayout( const KoParagLayout& layout, QDomElement & parentElem );
181
void recalcVerticalAlignment();
182
virtual QPen defaultPen() const;
184
void slotNewCommand( KCommand *cmd );
185
void slotAvailableHeightNeeded();
186
void slotRepaintChanged();
91
188
KPTextObject &operator=( const KPTextObject & );
189
void shadowCompatibility();
93
190
static const QString &tagTEXTOBJ, &attrLineSpacing, &attrParagSpacing,
94
&attrMargin, &attrBulletType1, &attrBulletType2,
95
&attrBulletType3, &attrBulletType4, &attrBulletColor1,
96
&attrBulletColor2, &attrBulletColor3, &attrBulletColor4,
97
&attrObjType, &tagP, &attrAlign, &attrType,
98
&attrDepth, &tagTEXT, &attrFamily, &attrPointSize,
99
&attrBold, &attrItalic, & attrUnderline, &attrColor, &attrWhitespace;
191
&attrMargin, &attrBulletType1, &attrBulletType2,
192
&attrBulletType3, &attrBulletType4, &attrBulletColor1,
193
&attrBulletColor2, &attrBulletColor3, &attrBulletColor4,
194
&attrObjType, &tagP, &attrAlign, &attrType,
195
&attrDepth, &tagTEXT, &attrFamily, &attrPointSize,
196
&attrBold, &attrItalic, & attrUnderline,& attrStrikeOut,
197
&attrColor, &attrWhitespace, &attrTextBackColor,
198
&attrVertAlign, &attrLinkName, &attrHrefName;
200
/** The contained text object */
201
KoTextObject *m_textobj;
202
KPresenterDoc *m_doc;
203
KoParagLayout m_paragLayout;
204
VerticalAlignmentType m_textVertAlign;
205
double bleft, bright, btop, bbottom; // margins
206
double alignVertical;
207
bool drawEditRect, drawEmpty;
212
class KPTextView : public KoTextView
216
KPTextView( KPTextObject * txtObj, KPrCanvas *_canvas );
217
virtual ~KPTextView();
219
virtual KoTextViewIface* dcopObject();
221
KoTextView * textView() { return this; }
222
KPTextObject * kpTextObject() const { return m_kptextobj; }
224
void keyPressEvent( QKeyEvent * );
225
void keyReleaseEvent( QKeyEvent * );
226
void mousePressEvent( QMouseEvent *, const QPoint &);
228
void mouseMoveEvent( QMouseEvent *, const QPoint & );
229
void mouseReleaseEvent( QMouseEvent *, const QPoint & );
230
void mouseDoubleClickEvent( QMouseEvent *, const QPoint &);
231
void dragEnterEvent( QDragEnterEvent * );
232
void dragMoveEvent( QDragMoveEvent *, const QPoint & );
233
void dropEvent( QDropEvent * );
235
void clearSelection();
236
void selectAll(bool select = true);
237
virtual void drawCursor( bool b );
239
const KoParagLayout & currentParagLayout() const { return m_paragLayout; }
240
void showPopup( KPresenterView *view, const QPoint &point, QPtrList<KAction> &actionList );
241
void insertVariable( int type, int subtype = 0 );
242
void insertCustomVariable( const QString &name);
243
void insertLink(const QString &_linkName, const QString & hrefName);
244
void insertVariable( KoVariable *var, KoTextFormat *format =0, bool removeSelectedText=true,
245
bool refreshCustomMenu =false /*don't refresh variable custom menu all the time */);
247
void terminate(bool removeSelection=true);
248
void insertComment(const QString &_note);
254
// Reimplemented from KoTextView
255
virtual void updateUI( bool updateFormat, bool force = false );
256
virtual void ensureCursorVisible();
260
virtual void startDrag();
262
KPrTextDrag * newDrag( QWidget * parent );
265
// Reimplemented from KoTextView
266
virtual void doAutoFormat( KoTextCursor* cursor, KoTextParag *parag, int index, QChar ch );
267
virtual bool doIgnoreDoubleSpace(KoTextParag * parag, int index,QChar ch );
269
virtual void doCompletion( KoTextCursor* cursor, KoTextParag *parag, int index );
271
virtual void showFormat( KoTextFormat *format ) ;
273
virtual bool pgUpKeyPressed();
274
virtual bool pgDownKeyPressed();
276
QPoint cursorPosition( const QPoint & pos );
278
KPTextObject *m_kptextobj;
280
KoParagLayout m_paragLayout;
281
QPtrList<KAction> m_actionList; // for the kodatatools