29#include "KPrGradient.h"
30#include "KoPointArray.h"
35#include <KoStyleStack.h>
36#include <KoOasisStyles.h>
37#include <KoXmlWriter.h>
38#include <KoGenStyles.h>
39#include "KPrLoadingInfo.h"
46class TQDomDocumentFragment;
49class KoTextZoomHandler;
55#define RAD_FACTOR 180.0 / M_PI
65 virtual DCOPObject* dcopObject();
67 virtual void setSelected(
bool _selected )
68 { selected = _selected; }
69 virtual void rotate(
float _angle )
71 virtual void setSize(
const KoSize & _size )
72 { setSize( _size.width(), _size.height() ); }
73 virtual void setSize(
double _width,
double _height )
74 { ext = KoSize( TQMAX( MIN_SIZE, _width ), TQMAX( MIN_SIZE, _height ) ); }
75 virtual void setOrig(
const KoPoint & _point )
77 virtual void setOrig(
double _x,
double _y )
78 { orig = KoPoint( _x, _y ); }
79 virtual void moveBy(
const KoPoint &_point )
80 { orig = orig + _point; }
81 virtual void moveBy(
double _dx,
double _dy )
82 { orig = orig + KoPoint( _dx, _dy ); }
83 virtual void resizeBy(
const KoSize & _size )
84 { resizeBy( _size.width(), _size.height() ); }
85 virtual void resizeBy(
double _dx,
double _dy )
86 { setSize( ext.width() + _dx, ext.height() + _dy ); }
88 virtual void setShadowParameter(
int _distance,ShadowDirection _direction,
const TQColor &_color)
90 shadowDistance = _distance;
91 shadowDirection = _direction;
95 virtual void setShadowDistance(
int _distance )
96 { shadowDistance = _distance; }
97 virtual void setShadowDirection( ShadowDirection _direction )
98 { shadowDirection = _direction; }
99 virtual void setShadowColor(
const TQColor & _color )
100 { shadowColor = _color; }
101 virtual void setEffect( Effect _effect )
102 { effect = _effect; }
103 virtual void setEffect2( Effect2 _effect2 )
104 { effect2 = _effect2; }
105 virtual void setAppearStep(
int _appearStep )
106 { appearStep = _appearStep; }
107 virtual void setDisappear(
bool b )
109 virtual void setDisappearStep(
int num )
110 { disappearStep = num; }
111 virtual void setEffect3( Effect3 _effect3)
112 { effect3 = _effect3; }
113 virtual void setAppearSpeed( EffectSpeed _speed )
114 { m_appearSpeed = _speed; }
115 virtual void setDisappearSpeed( EffectSpeed _speed )
116 { m_disappearSpeed = _speed; }
117 virtual void setAppearTimer(
int _appearTimer )
118 { appearTimer = _appearTimer; }
119 virtual void setDisappearTimer(
int _disappearTimer )
120 { disappearTimer = _disappearTimer; }
121 virtual void setAppearSoundEffect(
bool b )
122 { appearSoundEffect = b; }
123 virtual void setDisappearSoundEffect(
bool b )
124 { disappearSoundEffect = b; }
125 virtual void setAppearSoundEffectFileName(
const TQString & _a_fileName )
126 { a_fileName = _a_fileName; }
127 virtual void setDisappearSoundEffectFileName(
const TQString &_d_fileName )
128 { d_fileName = _d_fileName; }
130 virtual void setObjectName(
const TQString &_objectName )
131 { objectName = _objectName; }
132 virtual TQString getObjectName()
const
133 {
return objectName; }
135 virtual TQDomDocumentFragment save( TQDomDocument& doc,
double offset );
136 virtual double load(
const TQDomElement &element);
137 virtual void loadOasis(
const TQDomElement &element, KoOasisContext & context, KPrLoadingInfo *info);
139 struct KPOasisSaveContext
141 KPOasisSaveContext( KoXmlWriter &_xmlWriter, KoSavingContext &_context,
142 int &_indexObj,
int &_partIndexObj,
bool _onMaster )
143 : xmlWriter( _xmlWriter )
144 , context( _context )
145 , indexObj( _indexObj )
146 , partIndexObj( _partIndexObj )
147 , onMaster( _onMaster ) {};
149 KoXmlWriter &xmlWriter;
150 KoSavingContext &context;
156 virtual bool saveOasisObject( KPOasisSaveContext &sc )
const;
159 bool saveOasisObjectStyleShowAnimation( KoXmlWriter &animation,
int objectId );
160 bool saveOasisObjectStyleHideAnimation( KoXmlWriter &animation,
int objectId );
162 virtual void flip(
bool horizontal );
164 virtual ObjType getType()
const
165 {
return OT_UNDEFINED; }
166 virtual TQString getTypeString()
const
167 {
return TQString(); }
169 virtual bool isSelected()
const
171 virtual float getAngle()
const
173 virtual int getShadowDistance()
const
174 {
return shadowDistance; }
175 virtual ShadowDirection getShadowDirection()
const
176 {
return shadowDirection; }
177 virtual TQColor getShadowColor()
const
178 {
return shadowColor; }
179 virtual KoSize getSize()
const
181 virtual KoPoint getOrig()
const
183 KoRect getRect()
const
184 {
return KoRect( getOrig(), getSize() ); }
186 virtual KoSize getRealSize()
const;
187 virtual KoPoint getRealOrig()
const;
188 KoRect getRealRect()
const;
194 KoRect getRepaintRect()
const;
196 virtual Effect getEffect()
const
198 virtual Effect2 getEffect2()
const
200 virtual Effect3 getEffect3()
const
202 virtual EffectSpeed getAppearSpeed()
const
203 {
return m_appearSpeed; }
204 virtual EffectSpeed getDisappearSpeed()
const
205 {
return m_disappearSpeed; }
206 virtual int getAppearTimer()
const
207 {
return appearTimer; }
208 virtual int getDisappearTimer()
const
209 {
return disappearTimer; }
210 virtual bool getAppearSoundEffect()
const
211 {
return appearSoundEffect; }
212 virtual bool getDisappearSoundEffect()
const
213 {
return disappearSoundEffect; }
214 virtual TQString getAppearSoundEffectFileName()
const
215 {
return a_fileName; }
216 virtual TQString getDisappearSoundEffectFileName()
const
217 {
return d_fileName; }
221 virtual int getAppearStep()
const
222 {
return appearStep; }
223 virtual int getSubPresSteps()
const
225 virtual bool getDisappear()
const
226 {
return disappear; }
230 virtual int getDisappearStep()
const
231 {
return disappearStep; }
233 virtual void setOwnClipping(
bool _ownClipping )
234 { ownClipping = _ownClipping; }
235 virtual void setSubPresStep(
int _subPresStep )
236 { subPresStep = _subPresStep; }
237 virtual void doSpecificEffects(
bool _specEffects,
bool _onlyCurrStep =
true )
238 { specEffects = _specEffects; onlyCurrStep = _onlyCurrStep; }
241 virtual void draw( TQPainter *_painter, KoTextZoomHandler*_zoomHandler,
242 int , SelectionMode selectionMode,
bool drawContour =
false );
252 virtual bool contains(
const KoPoint &point )
const;
262 virtual bool intersects(
const KoRect & rect )
const;
264 virtual TQCursor getCursor(
const KoPoint &_point, ModifyType &_modType, KPrDocument *doc )
const;
266 KoRect rotateRectObject()
const;
267 void rotateObject(TQPainter *paint,KoTextZoomHandler *_zoomHandler);
269 virtual void removeFromObjList()
270 { inObjList =
false; }
271 virtual void addToObjList()
272 { inObjList =
true; }
273 virtual void incCmdRef()
275 virtual void decCmdRef()
276 { cmds--; doDelete(); }
278 virtual void setProtect(
bool b ) { protect = b; }
279 bool isProtect()
const {
return protect; }
281 virtual void setKeepRatio(
bool b ) { keepRatio = b; }
282 bool isKeepRatio()
const {
return keepRatio; }
284 static void setupClipRegion( TQPainter *painter,
const TQRegion &clipRegion );
286 void paintSelection( TQPainter *_painter,KoTextZoomHandler *_zoomHandler,
287 SelectionMode selectionMode );
294 virtual void addTextObjects( TQPtrList<KoTextObject> & )
const {}
296 virtual KPrTextObject *nextTextObject() {
return 0L;}
297 virtual void getAllObjectSelectedList(TQPtrList<KPrObject> &lst,
bool force =
false )
298 {
if (selected || force ) lst.append(
this );}
299 virtual KoPen getPen()
const;
301 bool hasAnimation()
const;
306 void addSelfToGuides( TQValueList<double> &horizontalPos, TQValueList<double> &verticalPos );
315 static void getRealSizeAndOrigFromPoints( KoPointArray &points,
float angle,
316 KoSize &size, KoPoint &orig );
321 void getShadowCoords(
double& _x,
double& _y )
const;
323 virtual void doDelete();
325 TQDomElement createValueElement(
const TQString &tag,
int value, TQDomDocument &doc);
326 TQDomElement createGradientElement(
const TQString &tag,
const TQColor &c1,
const TQColor &c2,
327 int type,
bool unbalanced,
int xfactor,
int yfactor, TQDomDocument &doc);
328 TQDomElement createPenElement(
const TQString &tag,
const KoPen &pen, TQDomDocument &doc);
329 KoPen toPen(
const TQDomElement &element)
const;
331 TQDomElement createBrushElement(
const TQString &tag,
const TQBrush &brush, TQDomDocument &doc);
332 TQBrush toBrush(
const TQDomElement &element)
const;
334 TQColor retrieveColor(
const TQDomElement &element,
const TQString &cattr=
"color",
335 const TQString &rattr=
"red",
const TQString &gattr=
"green",
336 const TQString &battr=
"blue")
const;
338 void saveOasisObjectProtectStyle( KoGenStyle &styleobjectauto )
const;
339 void saveOasisShadowElement( KoGenStyle &styleobjectauto )
const;
341 TQString getStyle( KPOasisSaveContext &sc )
const;
342 virtual void fillStyle( KoGenStyle& styleObjectAuto, KoGenStyles& mainStyles )
const;
346 virtual const char * getOasisElementName()
const = 0;
348 virtual bool saveOasisObjectAttributes( KPOasisSaveContext &sc )
const;
349 virtual void saveOasisPosObject( KoXmlWriter &xmlWriter,
int indexObj )
const;
355 ShadowDirection shadowDirection;
360 EffectSpeed m_appearSpeed;
361 EffectSpeed m_disappearSpeed;
362 int appearTimer, disappearTimer;
363 TQString a_fileName, d_fileName;
366 int appearStep, disappearStep;
369 bool appearSoundEffect:1;
370 bool disappearSoundEffect:1;
385 static const TQString &tagORIG, &attrX, &attrY,
386 &tagSIZE, &attrWidth, &attrHeight, &tagSHADOW,
387 &attrDistance, &attrDirection, &attrColor, &attrC1,
388 &attrC2, &attrType, &attrUnbalanced, &attrXFactor,
389 &attrYFactor, &attrStyle, &tagEFFECTS, &attrEffect,
390 &attrEffect2, &tagPRESNUM, &tagANGLE,
391 &tagDISAPPEAR, &attrDoit, &attrNum, &tagFILLTYPE,
392 &tagGRADIENT, &tagPEN, &tagBRUSH, &attrValue;
396 KPrObject(
const KPrObject &rhs);
397 KPrObject &operator=(
const KPrObject &rhs);
405class KPrShadowObject :
public KPrObject
409 KPrShadowObject(
const KoPen &_pen );
411 KPrShadowObject &operator=(
const KPrShadowObject & );
413 virtual void setPen(
const KoPen &_pen )
416 virtual KoPen getPen()
const
419 virtual TQDomDocumentFragment save( TQDomDocument& doc,
double offset );
420 virtual double load(
const TQDomElement &element);
421 virtual void loadOasis(
const TQDomElement &element, KoOasisContext & context,
KPrLoadingInfo *info);
422 virtual void draw( TQPainter *_painter, KoTextZoomHandler*_zoomHandler,
423 int pageNum, SelectionMode selectionMode,
bool drawContour =
false );
424 virtual void saveOasisStrokeElement( KoGenStyles& mainStyles, KoGenStyle &styleobjectauto )
const;
425 TQString saveOasisStrokeStyle( KoGenStyles& mainStyles )
const;
453 virtual void fillStyle( KoGenStyle& styleObjectAuto, KoGenStyles& mainStyles )
const;
473 virtual void paint( TQPainter* , KoTextZoomHandler* ,
474 int ,
bool drawingShadow,
bool =
false );
482 KPr2DObject(
const KoPen &_pen,
const TQBrush &_brush, FillType _fillType,
483 const TQColor &_gColor1,
const TQColor &_gColor2, BCType _gType,
484 bool _unbalanced,
int _xfactor,
int _yfactor );
485 virtual ~KPr2DObject() {
delete gradient; }
487 virtual void setFillType( FillType fillType );
488 virtual void setBrush(
const TQBrush &brush )
489 { m_brush.setBrush( brush ); }
490 virtual void setGColor1(
const TQColor &gColor1 )
491 {
if ( gradient ) gradient->setColor1( gColor1 ); m_brush.setGColor1( gColor1 ); m_redrawGradientPix =
true; }
492 virtual void setGColor2(
const TQColor &gColor2 )
493 {
if ( gradient ) gradient->setColor2( gColor2 ); m_brush.setGColor2( gColor2 ); m_redrawGradientPix =
true; }
494 virtual void setGType( BCType gType )
495 {
if ( gradient ) gradient->setBackColorType( gType ); m_brush.setGType( gType ); m_redrawGradientPix =
true; }
496 virtual void setGUnbalanced(
bool b )
497 {
if ( gradient ) gradient->setUnbalanced( b ); m_brush.setGUnbalanced( b ); m_redrawGradientPix =
true; }
498 virtual void setGXFactor(
int xfactor )
499 {
if ( gradient ) gradient->setXFactor( xfactor ); m_brush.setGXFactor( xfactor ); m_redrawGradientPix =
true; }
500 virtual void setGYFactor(
int yfactor )
501 {
if ( gradient ) gradient->setYFactor( yfactor ); m_brush.setGYFactor( yfactor ); m_redrawGradientPix =
true; }
503 virtual FillType getFillType()
const
504 {
return m_brush.getFillType(); }
505 virtual TQBrush getBrush()
const
506 {
return m_brush.getBrush(); }
507 virtual TQColor getGColor1()
const
508 {
return m_brush.getGColor1(); }
509 virtual TQColor getGColor2()
const
510 {
return m_brush.getGColor2(); }
511 virtual BCType getGType()
const
512 {
return m_brush.getGType(); }
513 virtual bool getGUnbalanced()
const
514 {
return m_brush.getGUnbalanced(); }
515 virtual int getGXFactor()
const
516 {
return m_brush.getGXFactor(); }
517 virtual int getGYFactor()
const
518 {
return m_brush.getGYFactor(); }
520 virtual TQDomDocumentFragment save( TQDomDocument& doc,
double offset );
521 virtual double load(
const TQDomElement &element);
522 virtual void loadOasis(
const TQDomElement &element, KoOasisContext & context, KPrLoadingInfo *info);
523 virtual void draw( TQPainter *_painter, KoTextZoomHandler*_zoomHandler,
524 int pageNum, SelectionMode selectionMode,
bool drawContour =
false );
526 virtual void flip(
bool horizontal );
529 virtual void fillStyle( KoGenStyle& styleObjectAuto, KoGenStyles& mainStyles )
const;
532 KPrGradient *gradient;
534 TQPixmap m_gradientPix;
535 bool m_redrawGradientPix;
541 KPrStartEndLine( LineEnd _start, LineEnd _end );
542 void save( TQDomDocumentFragment &fragment, TQDomDocument& doc );
543 void load(
const TQDomElement &element );
545 void saveOasisMarkerElement( KoGenStyles& mainStyles, KoGenStyle &styleobjectauto )
const;
546 TQString saveOasisMarkerStyle( KoGenStyles &mainStyles,
const LineEnd &_element )
const;
547 void loadOasisMarkerElement( KoOasisContext & context,
const TQString & attr, LineEnd &_element );
551 TQDomElement createValueElement(
const TQString &tag,
int value, TQDomDocument &doc);
553 LineEnd lineBegin, lineEnd;
Temporary information used only during loading.
Base class for objects with a pen and a brush, and which takes care of painting the shadow in draw() ...
bool loadOasisDrawPoints(KoPointArray &points, const TQDomElement &element, KoOasisContext &context, KPrLoadingInfo *info)
Helper method for loading draw:points.
virtual KoPen defaultPen() const
save() only saves if the pen is different from the default pen.
virtual void paint(TQPainter *, KoTextZoomHandler *, int, bool drawingShadow, bool=false)
This method is to be implemented by all KPShadowObjects, to draw themselves.
bool loadOasisApplyViewBox(const TQDomElement &element, KoPointArray &points)
Apply the svg:viewBox attribute to the points.
static bool saveOasisDrawPoints(const KoPointArray &points, KPOasisSaveContext &sc)
Helper method for saving draw:points.