25#include "KoRichText.h"
26#include <KoTextView.h>
27#include <KoStyleCollection.h>
28#include <KoStyleStack.h>
51class KPrTextObject :
public TQObject,
public KPr2DObject,
public KoTextFlow
56 KPrTextObject( KPrDocument *doc );
57 virtual ~KPrTextObject();
59 virtual DCOPObject* dcopObject();
61 virtual void setSize(
double _width,
double _height );
63 virtual void setDrawEditRect(
bool b )
65 virtual void setDrawEmpty(
bool b )
68 virtual ObjType getType()
const
70 virtual TQString getTypeString()
const
71 {
return i18n(
"Text"); }
73 virtual bool getDrawEditRect()
const
74 {
return drawEditRect; }
75 virtual bool getDrawEmpty()
const
77 virtual int getSubPresSteps()
const;
79 virtual TQBrush getBrush()
const;
81 virtual void setShadowParameter(
int _distance,ShadowDirection _direction,
const TQColor &_color);
83 virtual TQDomDocumentFragment save( TQDomDocument& doc,
double offset );
84 virtual double load(
const TQDomElement &element);
85 virtual void loadOasis(
const TQDomElement &element, KoOasisContext& context,
KPrLoadingInfo *info);
86 virtual void saveOasisMarginElement( KoGenStyle &styleobjectauto )
const;
88 virtual void paint( TQPainter *_painter, KoTextZoomHandler*_zoomHandler,
89 int pageNum,
bool drawingShadow,
bool drawContour );
90 void paint( TQPainter *_painter, KoTextZoomHandler*_zoomHandler,
bool onlyChanged, KoTextCursor* cursor,
91 bool resetChanged,
bool drawContour );
92 void paintEdited( TQPainter *_painter, KoTextZoomHandler*_zoomHandler,
93 bool onlyChanged, KoTextCursor* cursor,
bool resetChanged );
95 void drawCursor( TQPainter *p, KoTextCursor *cursor,
bool cursorVisible,
KPrCanvas* );
97 void recalcPageNum( KPrPage *page );
99 TQPoint cursorPos(
KPrCanvas*, KoTextCursor *)
const;
103 KoTextObject * textObject()
const {
return m_textobj; }
104 virtual void addTextObjects( TQPtrList<KoTextObject> &lst )
const {
105 if ( !isProtectContent() )
106 lst.append( m_textobj );
111 KPrDocument* kPresenterDocument()
const {
return m_doc; }
113 KPrTextView * createKPTextView(
KPrCanvas *,
bool temp=
false );
114 void applyStyleChange( KoStyleChangeDefMap changed );
116 void removeHighlight();
117 void highlightPortion( KoTextParag * parag,
int index,
int length,
KPrCanvas *canvas,
bool repaint, KDialogBase* dialog = 0 );
119 KCommand * pasteOasis( KoTextCursor * cursor,
const TQByteArray & data,
bool removeSelected );
121 void saveParagraph( TQDomDocument& doc,
123 TQDomElement &parentElem,
126 KoParagLayout loadParagLayout( TQDomElement & parentElem, KPrDocument *doc,
bool useRefStyle);
128 static KoTextFormat loadFormat( TQDomElement &n, KoTextFormat * refFormat,
const TQFont & defaultFont,
129 const TQString & defaultLanguage,
bool hyphen );
131 void setEditingTextObj(
bool _edit ) { editingTextObj = _edit; }
133 KCommand *textContentsToHeight();
134 KCommand *textObjectToContents();
135 void setProtectContent (
bool _protect ) { textObject()->setProtectContent(_protect);}
136 bool isProtectContent()
const {
return textObject()->protectContent();}
137 void loadVariable( TQValueList<TQDomElement> & listVariable,KoTextParag *lastParag,
int offset=0 );
142 int availableHeight()
const;
145 void setBLeft(
double b ) { bleft = b; }
147 void setBRight(
double b ) { bright = b; }
149 void setBTop(
double b ) { btop = b; }
151 void setBBottom(
double b ) { bbottom = b; }
154 double bLeft()
const {
return bleft; }
156 double bRight()
const {
return bright; }
158 double bTop()
const {
return btop; }
160 double bBottom()
const {
return bbottom; }
162 void setTextMargins(
double _left,
double _top,
double right,
double bottom);
164 KoRect innerRect()
const;
165 double innerWidth()
const;
166 double innerHeight()
const;
167 void resizeTextDocument(
bool widthChanged =
true,
bool heightChanged =
true );
169 VerticalAlignmentType verticalAlignment()
const {
return m_textVertAlign; }
170 void setVerticalAligment( VerticalAlignmentType _type) ;
171 double alignmentValue()
const {
return alignVertical; }
172 virtual KPrTextObject *nextTextObject() {
return this;}
173 static void saveFormat( TQDomElement & element, KoTextFormat*lastFormat );
175 TQPoint viewToInternal(
const TQPoint & pos,
KPrCanvas* canvas )
const;
178 void repaintChanged( KPrTextObject* );
181 void slotFormatChanged(
const KoTextFormat &);
182 void slotAfterFormatting(
int, KoTextParag*,
bool* );
183 void slotParagraphDeleted(KoTextParag*_parag);
185 virtual const char * getOasisElementName()
const;
186 virtual bool saveOasisObjectAttributes( KPOasisSaveContext &sc )
const;
188 virtual TQDomElement saveKTextObject( TQDomDocument& doc );
189 TQDomElement saveHelper(
const TQString &tmpText,KoTextFormat*lastFormat ,TQDomDocument &doc);
191 virtual void fillStyle( KoGenStyle& styleObjectAuto, KoGenStyles& mainStyles )
const;
193 virtual void loadKTextObject(
const TQDomElement &e );
194 void drawText( TQPainter* _painter, KoTextZoomHandler* zoomHandler,
bool onlyChanged, KoTextCursor* cursor,
bool resetChanged );
195 void drawParags( TQPainter *p, KoTextZoomHandler* zoomHandler,
const TQColorGroup& cg,
int from,
int to );
196 void saveParagLayout(
const KoParagLayout& layout, TQDomElement & parentElem );
198 void recalcVerticalAlignment();
199 virtual KoPen defaultPen()
const;
201 void slotNewCommand( KCommand *cmd );
202 void slotAvailableHeightNeeded();
203 void slotRepaintChanged();
205 KPrTextObject &operator=(
const KPrTextObject & );
206 void shadowCompatibility();
207 static const TQString &tagTEXTOBJ, &attrLineSpacing, &attrParagSpacing,
208 &attrMargin, &attrBulletType1, &attrBulletType2,
209 &attrBulletType3, &attrBulletType4, &attrBulletColor1,
210 &attrBulletColor2, &attrBulletColor3, &attrBulletColor4,
211 &attrObjType, &tagP, &attrAlign, &attrType,
212 &attrDepth, &tagTEXT, &attrFamily, &attrPointSize,
213 &attrBold, &attrItalic, & attrUnderline,& attrStrikeOut,
214 &attrColor, &attrWhitespace, &attrTextBackColor,
215 &attrVertAlign, &attrLinkName, &attrHrefName;
218 KoTextObject *m_textobj;
220 KoParagLayout m_paragLayout;
221 VerticalAlignmentType m_textVertAlign;
222 double bleft, bright, btop, bbottom;
223 double alignVertical;
224 bool drawEditRect, drawEmpty;
229class KPrTextView :
public KoTextView
234 KPrTextView( KPrTextObject * txtObj,
KPrCanvas *_canvas,
bool temp=
false );
235 virtual ~KPrTextView();
237 virtual KoTextViewIface* dcopObject();
239 KoTextView * textView() {
return this; }
240 KPrTextObject * kpTextObject()
const {
return m_kptextobj; }
242 void keyPressEvent( TQKeyEvent * );
243 void keyReleaseEvent( TQKeyEvent * );
244 void imStartEvent( TQIMEvent * );
245 void imComposeEvent( TQIMEvent * );
246 void imEndEvent( TQIMEvent * );
247 void mousePressEvent( TQMouseEvent *,
const TQPoint &);
248 void mouseMoveEvent( TQMouseEvent *,
const TQPoint & );
249 void mouseReleaseEvent( TQMouseEvent *,
const TQPoint & );
250 void mouseDoubleClickEvent( TQMouseEvent *,
const TQPoint &);
251 void dragEnterEvent( TQDragEnterEvent * );
252 void dragMoveEvent( TQDragMoveEvent *,
const TQPoint & );
253 void dropEvent( TQDropEvent * );
255 void clearSelection();
256 void selectAll(
bool select =
true);
257 virtual void drawCursor(
bool b );
259 const KoParagLayout & currentParagLayout()
const {
return m_paragLayout; }
260 void showPopup( KPrView *view,
const TQPoint &point, TQPtrList<TDEAction> &actionList );
261 void insertVariable(
int type,
int subtype = 0 );
262 void insertCustomVariable(
const TQString &name);
263 void insertLink(
const TQString &_linkName,
const TQString & hrefName);
264 void insertVariable( KoVariable *var, KoTextFormat *format =0,
265 bool refreshCustomMenu =
false );
267 void terminate(
bool removeSelection=
true);
268 void insertComment(
const TQString &_note);
271 bool hasSelection()
const;
273 virtual void removeToolTipCompletion();
274 bool isLinkVariable(
const TQPoint &);
276 TQPoint viewToInternal(
const TQPoint & pos )
const;
283 virtual void updateUI(
bool updateFormat,
bool force =
false );
284 virtual void ensureCursorVisible();
288 virtual void startDrag();
291 bool canDecode( TQMimeSource *e );
292 TQDragObject * newDrag( TQWidget * parent );
294 virtual void doAutoFormat( KoTextCursor* cursor, KoTextParag *parag,
int index, TQChar ch );
295 virtual bool doIgnoreDoubleSpace(KoTextParag * parag,
int index,TQChar ch );
296 virtual bool doCompletion( KoTextCursor* cursor, KoTextParag *parag,
int index );
297 virtual bool doToolTipCompletion( KoTextCursor* , KoTextParag *,
int,
int );
298 virtual void showToolTipBox(KoTextParag *parag,
int index, TQWidget *widget,
const TQPoint &pos);
299 virtual void textIncreaseIndent();
300 virtual bool textDecreaseIndent();
301 virtual void showFormat( KoTextFormat *format ) ;
303 virtual bool pgUpKeyPressed();
304 virtual bool pgDownKeyPressed();
306 KPrTextObject *m_kptextobj;
308 KoParagLayout m_paragLayout;
309 TQPtrList<TDEAction> m_actionList;
Class KPCanvas - There is a single instance of this class for a given view.
Temporary information used only during loading.
This is our KoTextDocument reimplementation, to relate it to the textobject it's in.