21#include "KPrObjectIface.h"
24#include "KPrDocument.h"
29#include <tqpointarray.h>
35#include <tdeapplication.h>
36#include <KoOasisContext.h>
37#include "KoOasisStyles.h"
44#include <KoTextZoomHandler.h>
52const TQString &KPrObject::tagORIG=TDEGlobal::staticQString(
"ORIG");
53const TQString &KPrObject::attrX=TDEGlobal::staticQString(
"x");
54const TQString &KPrObject::attrY=TDEGlobal::staticQString(
"y");
55const TQString &KPrObject::tagSIZE=TDEGlobal::staticQString(
"SIZE");
56const TQString &KPrObject::attrWidth=TDEGlobal::staticQString(
"width");
57const TQString &KPrObject::attrHeight=TDEGlobal::staticQString(
"height");
58const TQString &KPrObject::tagSHADOW=TDEGlobal::staticQString(
"SHADOW");
59const TQString &KPrObject::attrDistance=TDEGlobal::staticQString(
"distance");
60const TQString &KPrObject::attrDirection=TDEGlobal::staticQString(
"direction");
61const TQString &KPrObject::attrColor=TDEGlobal::staticQString(
"color");
62const TQString &KPrObject::tagEFFECTS=TDEGlobal::staticQString(
"EFFECTS");
63const TQString &KPrObject::attrEffect=TDEGlobal::staticQString(
"effect");
64const TQString &KPrObject::attrEffect2=TDEGlobal::staticQString(
"effect2");
65const TQString &KPrObject::tagPRESNUM=TDEGlobal::staticQString(
"PRESNUM");
66const TQString &KPrObject::tagANGLE=TDEGlobal::staticQString(
"ANGLE");
67const TQString &KPrObject::tagDISAPPEAR=TDEGlobal::staticQString(
"DISAPPEAR");
68const TQString &KPrObject::attrDoit=TDEGlobal::staticQString(
"doit");
69const TQString &KPrObject::attrNum=TDEGlobal::staticQString(
"num");
70const TQString &KPrObject::tagFILLTYPE=TDEGlobal::staticQString(
"FILLTYPE");
71const TQString &KPrObject::tagGRADIENT=TDEGlobal::staticQString(
"GRADIENT");
72const TQString &KPrObject::tagPEN=TDEGlobal::staticQString(
"PEN");
73const TQString &KPrObject::tagBRUSH=TDEGlobal::staticQString(
"BRUSH");
74const TQString &KPrObject::attrValue=TDEGlobal::staticQString(
"value");
75const TQString &KPrObject::attrC1=TDEGlobal::staticQString(
"color1");
76const TQString &KPrObject::attrC2=TDEGlobal::staticQString(
"color2");
77const TQString &KPrObject::attrType=TDEGlobal::staticQString(
"type");
78const TQString &KPrObject::attrUnbalanced=TDEGlobal::staticQString(
"unbalanced");
79const TQString &KPrObject::attrXFactor=TDEGlobal::staticQString(
"xfactor");
80const TQString &KPrObject::attrYFactor=TDEGlobal::staticQString(
"yfactor");
81const TQString &KPrObject::attrStyle=TDEGlobal::staticQString(
"style");
83KPrStartEndLine::KPrStartEndLine( LineEnd _start, LineEnd _end )
84 : lineBegin( _start ), lineEnd( _end )
88void KPrStartEndLine::save( TQDomDocumentFragment &fragment, TQDomDocument& doc )
90 if (lineBegin!=L_NORMAL)
91 fragment.appendChild(KPrStartEndLine::createValueElement(
"LINEBEGIN",
static_cast<int>(lineBegin), doc));
92 if (lineEnd!=L_NORMAL)
93 fragment.appendChild(KPrStartEndLine::createValueElement(
"LINEEND",
static_cast<int>(lineEnd), doc));
96TQDomElement KPrStartEndLine::createValueElement(
const TQString &tag,
int value, TQDomDocument &doc)
98 TQDomElement elem=doc.createElement(tag);
99 elem.setAttribute(
"value", value);
104void KPrStartEndLine::load(
const TQDomElement &element )
106 TQDomElement e=element.namedItem(
"LINEBEGIN").toElement();
109 if(e.hasAttribute(
"value"))
110 tmp=e.attribute(
"value").toInt();
111 lineBegin=
static_cast<LineEnd
>(tmp);
113 e=element.namedItem(
"LINEEND").toElement();
116 if(e.hasAttribute(
"value"))
117 tmp=e.attribute(
"value").toInt();
118 lineEnd=
static_cast<LineEnd
>(tmp);
122void KPrStartEndLine::loadOasisMarkerElement( KoOasisContext & context,
const TQString & attr, LineEnd &_element )
126 KoStyleStack &styleStack = context.styleStack();
127 styleStack.setTypeProperties(
"graphic" );
128 if ( styleStack.hasAttributeNS( KoXmlNS::draw,attr.latin1() ) )
130 TQString style = styleStack.attributeNS( KoXmlNS::draw, attr.latin1() );
135 TQDomElement* draw = context.oasisStyles().drawStyles()[style];
139 if( draw->hasAttributeNS( KoXmlNS::svg,
"d" ))
141 TQString str = draw->attributeNS( KoXmlNS::svg,
"d", TQString() );
142 kdDebug()<<
" svg type = "<<str<<endl;
143 if ( str == lineEndBeginSvg( L_ARROW ) )
145 else if ( str == lineEndBeginSvg( L_CIRCLE ) )
147 else if ( str == lineEndBeginSvg( L_SQUARE ) )
149 else if ( str == lineEndBeginSvg( L_LINE_ARROW ) )
150 _element = L_LINE_ARROW;
151 else if ( str == lineEndBeginSvg( L_DIMENSION_LINE ) )
152 _element = L_DIMENSION_LINE;
153 else if ( str == lineEndBeginSvg( L_DOUBLE_ARROW ) )
154 _element = L_DOUBLE_ARROW;
155 else if ( str == lineEndBeginSvg( L_DOUBLE_LINE_ARROW ) )
156 _element = L_DOUBLE_LINE_ARROW;
159 kdDebug()<<
" element not defined :"<<str<<endl;
167void KPrStartEndLine::saveOasisMarkerElement( KoGenStyles& mainStyles, KoGenStyle &styleobjectauto )
const
169 if ( lineBegin != L_NORMAL )
171 styleobjectauto.addProperty(
"draw:marker-start", saveOasisMarkerStyle( mainStyles, lineBegin ) );
172 styleobjectauto.addProperty(
"draw:marker-start-width",
"0.25cm" );
174 if ( lineEnd != L_NORMAL )
176 styleobjectauto.addProperty(
"draw:marker-end", saveOasisMarkerStyle( mainStyles, lineEnd ) );
177 styleobjectauto.addProperty(
"draw:marker-end-width",
"0.25cm" );
181TQString KPrStartEndLine::saveOasisMarkerStyle( KoGenStyles &mainStyles,
const LineEnd &_element )
const
183 KoGenStyle marker( KPrDocument::STYLE_MARKER );
191 marker.addAttribute(
"svg:viewBox",
"0 0 20 30" );
194 marker.addAttribute(
"svg:viewBox",
"0 0 10 10" );
197 marker.addAttribute(
"svg:viewBox",
"0 0 1131 1131" );
200 marker.addAttribute(
"svg:viewBox",
"0 0 1122 2243" );
202 case L_DIMENSION_LINE:
203 marker.addAttribute(
"svg:viewBox",
"0 0 836 110" );
206 marker.addAttribute(
"svg:viewBox",
"0 0 1131 1918" );
208 case L_DOUBLE_LINE_ARROW:
215 marker.addAttribute(
"svg:d", lineEndBeginSvg( _element ));
217 return mainStyles.lookup( marker,
"marker" );
220KPrObject::KPrObject()
221 : orig(), ext(), shadowColor( TQt::gray )
228 m_appearSpeed = ES_MEDIUM;
229 m_disappearSpeed = ES_MEDIUM;
233 appearSoundEffect =
false;
234 disappearSoundEffect =
false;
235 a_fileName = TQString();
236 d_fileName = TQString();
237 objectName = TQString();
239 shadowDirection = SD_RIGHT_BOTTOM;
254KPrObject::~KPrObject()
259TQDomDocumentFragment KPrObject::save( TQDomDocument& doc,
double offset )
261 TQDomDocumentFragment fragment=doc.createDocumentFragment();
262 TQDomElement elem=doc.createElement(tagORIG);
263 elem.setAttribute(attrX, orig.x());
264 elem.setAttribute(attrY, TQString::number( orig.y() + offset,
'g', DBL_DIG ) );
265 fragment.appendChild(elem);
266 elem=doc.createElement(tagSIZE);
267 elem.setAttribute(attrWidth, ext.width());
268 elem.setAttribute(attrHeight, ext.height());
269 fragment.appendChild(elem);
270 if(shadowDistance!=0 || shadowDirection!=SD_RIGHT_BOTTOM || shadowColor!=TQt::gray) {
271 elem=doc.createElement(tagSHADOW);
272 elem.setAttribute(attrDistance, shadowDistance);
273 elem.setAttribute(attrDirection,
static_cast<int>( shadowDirection ));
274 elem.setAttribute(attrColor, shadowColor.name());
275 fragment.appendChild(elem);
277 if(effect!=EF_NONE || effect2!=EF2_NONE) {
278 elem=doc.createElement(tagEFFECTS);
279 elem.setAttribute(attrEffect,
static_cast<int>( effect ));
280 elem.setAttribute(attrEffect2,
static_cast<int>( effect2 ));
281 elem.setAttribute(
"speed",
static_cast<int>(m_appearSpeed) );
282 fragment.appendChild(elem);
285 fragment.appendChild(KPrObject::createValueElement(tagPRESNUM, appearStep, doc));
287 elem=doc.createElement(tagANGLE);
288 elem.setAttribute(attrValue, angle);
289 fragment.appendChild(elem);
291 if(effect3!=EF3_NONE || disappear) {
292 elem=doc.createElement(tagDISAPPEAR);
293 elem.setAttribute(attrEffect,
static_cast<int>( effect3 ));
294 elem.setAttribute(attrDoit,
static_cast<int>( disappear ));
295 elem.setAttribute(
"speed",
static_cast<int>(m_disappearSpeed) );
296 elem.setAttribute(attrNum, disappearStep);
297 fragment.appendChild(elem);
299 if(appearTimer!=1 || disappearTimer!=1) {
300 elem=doc.createElement(
"TIMER");
301 elem.setAttribute(
"appearTimer", appearTimer);
302 elem.setAttribute(
"disappearTimer", disappearTimer);
303 fragment.appendChild(elem);
305 if(appearSoundEffect || !a_fileName.isEmpty()) {
306 elem=doc.createElement(
"APPEARSOUNDEFFECT");
307 elem.setAttribute(
"appearSoundEffect",
static_cast<int>(appearSoundEffect));
308 elem.setAttribute(
"appearSoundFileName", a_fileName);
309 fragment.appendChild(elem);
311 if(disappearSoundEffect || !d_fileName.isEmpty()) {
312 elem=doc.createElement(
"DISAPPEARSOUNDEFFECT");
313 elem.setAttribute(
"disappearSoundEffect",
static_cast<int>(disappearSoundEffect));
314 elem.setAttribute(
"disappearSoundFileName", d_fileName);
315 fragment.appendChild(elem);
317 if( !objectName.isEmpty() ) {
318 elem=doc.createElement(
"OBJECTNAME");
319 elem.setAttribute(
"objectName", objectName);
320 fragment.appendChild(elem);
323 elem=doc.createElement(
"PROTECT");
324 elem.setAttribute(
"state" , protect);
325 fragment.appendChild(elem);
328 elem=doc.createElement(
"RATIO");
329 elem.setAttribute(
"ratio" , keepRatio);
330 fragment.appendChild(elem);
337void KPrObject::saveOasisPosObject( KoXmlWriter &xmlWriter,
int indexObj )
const
339 xmlWriter.addAttribute(
"draw:id",
"object" + TQString::number( indexObj ) );
341 xmlWriter.addAttributePt(
"svg:width", ext.width() );
342 xmlWriter.addAttributePt(
"svg:height", ext.height() );
344 if ( kAbs( angle ) > 1E-6 )
346 double angInRad = -angle * M_PI / 180.0;
347 TQWMatrix m( cos( angInRad ), -sin( angInRad ), sin( angInRad ), cos( angInRad ), 0, 0 );
348 KoPoint center( ext.width() / 2, ext.height() / 2 );
351 m.map( center.x(), center.y(), &rotX, &rotY );
352 KoPoint rot( rotX, rotY );
353 KoPoint trans( center - rot + orig );
356 transX.setNum( trans.x(),
'g', DBL_DIG );
358 transY.setNum( trans.y(),
'g', DBL_DIG );
359 TQString str = TQString(
"rotate(%1) translate(%2pt %3pt)" ).arg( angInRad ).arg( transX.data() ).arg( transY.data() );
360 xmlWriter.addAttribute(
"draw:transform", str );
364 xmlWriter.addAttributePt(
"svg:x", orig.x() );
365 xmlWriter.addAttributePt(
"svg:y", orig.y() );
369void KPrObject::saveOasisObjectProtectStyle( KoGenStyle &styleobjectauto )
const
373 styleobjectauto.addProperty(
"draw:move-protect",
"true" );
374 styleobjectauto.addProperty(
"draw:size-protect",
"true" );
378TQString KPrObject::getStyle( KPOasisSaveContext &sc )
const
380 kdDebug(33001) <<
"KPrObject::getStyle" << endl;
381 KoGenStyle styleObjectAuto;
382 KoGenStyles &mainStyles( sc.context.mainStyles() );
385 styleObjectAuto = KoGenStyle( KPrDocument::STYLE_PRESENTATIONSTICKYOBJECT,
"presentation" );
389 styleObjectAuto = KoGenStyle( KoGenStyle::STYLE_GRAPHICAUTO,
"graphic" );
391 fillStyle( styleObjectAuto, mainStyles );
394 return mainStyles.lookup( styleObjectAuto,
"pr" );
396 return mainStyles.lookup( styleObjectAuto,
"gr" );
399void KPrObject::fillStyle( KoGenStyle& styleObjectAuto, KoGenStyles& )
const
401 kdDebug(33001) <<
"KPrObject::fillStyle" << endl;
402 saveOasisObjectProtectStyle( styleObjectAuto );
403 saveOasisShadowElement( styleObjectAuto );
406bool KPrObject::saveOasisObjectAttributes( KPOasisSaveContext & )
const
408 kdDebug()<<
"bool saveOasisObjectAttributes not implemented";
412bool KPrObject::hasAnimation()
const
414 return effect != EF_NONE || appearTimer != 0 ||
415 effect3 != EF3_NONE || disappear ||
416 !a_fileName.isEmpty() || ! d_fileName.isEmpty() ||
420bool KPrObject::saveOasisObjectStyleShowAnimation( KoXmlWriter &animation,
int objectId )
422 if ( effect != EF_NONE || appearStep != 0 || !a_fileName.isEmpty() )
424 animation.startElement(
"presentation:show-shape" );
425 animation.addAttribute(
"draw:shape-id",
"object" + TQString::number( objectId ) );
426 animation.addAttribute(
"koffice:order-id", appearStep );
432 animation.addAttribute(
"presentation:effect",
"appear" );
435 animation.addAttribute(
"presentation:effect",
"move" );
436 animation.addAttribute(
"presentation:direction",
"from-right" );
439 animation.addAttribute(
"presentation:effect",
"move" );
440 animation.addAttribute(
"presentation:direction",
"from-left" );
443 animation.addAttribute(
"presentation:effect",
"move" );
444 animation.addAttribute(
"presentation:direction",
"from-top" );
447 animation.addAttribute(
"presentation:effect",
"move" );
448 animation.addAttribute(
"presentation:direction",
"from-bottom" );
450 case EF_COME_RIGHT_TOP:
451 animation.addAttribute(
"presentation:effect",
"move" );
452 animation.addAttribute(
"presentation:direction",
"from-upper-right" );
454 case EF_COME_RIGHT_BOTTOM:
455 animation.addAttribute(
"presentation:effect",
"move" );
456 animation.addAttribute(
"presentation:direction",
"from-lower-right" );
458 case EF_COME_LEFT_TOP:
459 animation.addAttribute(
"presentation:effect",
"move" );
460 animation.addAttribute(
"presentation:direction",
"from-upper-left" );
462 case EF_COME_LEFT_BOTTOM:
463 animation.addAttribute(
"presentation:effect",
"move" );
464 animation.addAttribute(
"presentation:direction",
"from-lower-left" );
467 animation.addAttribute(
"presentation:effect",
"fade" );
468 animation.addAttribute(
"presentation:direction",
"from-left" );
471 animation.addAttribute(
"presentation:effect",
"fade" );
472 animation.addAttribute(
"presentation:direction",
"from-right" );
475 animation.addAttribute(
"presentation:effect",
"fade" );
476 animation.addAttribute(
"presentation:direction",
"from-top" );
479 animation.addAttribute(
"presentation:effect",
"fade" );
480 animation.addAttribute(
"presentation:direction",
"from-bottom" );
484 if ( effect2 != EF2_NONE )
486 animation.addAttribute(
"koffice:by-paragraph",
"true" );
489 if ( m_appearSpeed == ES_SLOW )
491 animation.addAttribute(
"presentation:speed",
"slow" );
493 else if ( m_appearSpeed == ES_FAST )
495 animation.addAttribute(
"presentation:speed",
"fast" );
498 if ( appearTimer!=1 )
500 animation.addAttribute(
"presentation:animation-delay", saveOasisTimer( appearTimer ) );
502 if( !a_fileName.isEmpty() )
506 animation.startElement(
"presentation:sound" );
507 animation.addAttribute(
"xlink:href", a_fileName );
508 animation.addAttribute(
"xlink:type",
"simple" );
509 animation.addAttribute(
"xlink:show",
"new" );
510 animation.addAttribute(
"xlink:actuate",
"onRequest" );
511 animation.endElement();
513 animation.endElement();
518bool KPrObject::saveOasisObjectStyleHideAnimation( KoXmlWriter &animation,
int objectId )
522 if ( effect3 != EF3_NONE || disappearStep != 0 || !d_fileName.isEmpty())
524 animation.startElement(
"presentation:hide-shape" );
525 animation.addAttribute(
"draw:shape-id",
"object" + TQString::number( objectId ) );
526 animation.addAttribute(
"koffice:order-id", disappearStep );
531 animation.addAttribute(
"presentation:effect",
"hide" );
534 animation.addAttribute(
"presentation:effect",
"move" );
535 animation.addAttribute(
"presentation:direction",
"from-right" );
538 animation.addAttribute(
"presentation:effect",
"move" );
539 animation.addAttribute(
"presentation:direction",
"from-left" );
542 animation.addAttribute(
"presentation:effect",
"move" );
543 animation.addAttribute(
"presentation:direction",
"from-top" );
546 animation.addAttribute(
"presentation:effect",
"move" );
547 animation.addAttribute(
"presentation:direction",
"from-bottom" );
549 case EF3_GO_RIGHT_TOP:
550 animation.addAttribute(
"presentation:effect",
"move" );
551 animation.addAttribute(
"presentation:direction",
"from-upper-right" );
553 case EF3_GO_RIGHT_BOTTOM:
554 animation.addAttribute(
"presentation:effect",
"move" );
555 animation.addAttribute(
"presentation:direction",
"from-lower-right" );
557 case EF3_GO_LEFT_TOP:
558 animation.addAttribute(
"presentation:effect",
"move" );
559 animation.addAttribute(
"presentation:direction",
"from-upper-left" );
561 case EF3_GO_LEFT_BOTTOM:
562 animation.addAttribute(
"presentation:effect",
"move" );
563 animation.addAttribute(
"presentation:direction",
"from-lower-left" );
566 animation.addAttribute(
"presentation:effect",
"fade" );
567 animation.addAttribute(
"presentation:direction",
"from-left" );
570 animation.addAttribute(
"presentation:effect",
"fade" );
571 animation.addAttribute(
"presentation:direction",
"from-right" );
574 animation.addAttribute(
"presentation:effect",
"fade" );
575 animation.addAttribute(
"presentation:direction",
"from-top" );
577 case EF3_WIPE_BOTTOM:
578 animation.addAttribute(
"presentation:effect",
"fade" );
579 animation.addAttribute(
"presentation:direction",
"from-bottom" );
583 if ( m_disappearSpeed == ES_SLOW )
585 animation.addAttribute(
"presentation:speed",
"slow" );
587 else if ( m_disappearSpeed == ES_FAST )
589 animation.addAttribute(
"presentation:speed",
"fast" );
592 if ( disappearTimer!=1 )
594 animation.addAttribute(
"presentation:animation-delay", saveOasisTimer( disappearTimer ) );
596 if( !d_fileName.isEmpty() )
600 animation.startElement(
"presentation:sound" );
601 animation.addAttribute(
"xlink:href", a_fileName );
602 animation.addAttribute(
"xlink:type",
"simple" );
603 animation.addAttribute(
"xlink:show",
"new" );
604 animation.addAttribute(
"xlink:actuate",
"onRequest" );
606 animation.endElement();
608 animation.endElement();
613void KPrObject::loadOasis(
const TQDomElement &element, KoOasisContext & context,
KPrLoadingInfo *info)
615 if(element.hasAttributeNS( KoXmlNS::draw,
"name" ))
616 objectName = element.attributeNS( KoXmlNS::draw,
"name", TQString());
617 orig.setX( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg,
"x", TQString() ) ) );
618 orig.setY( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg,
"y", TQString() ) ) );
619 ext.setWidth(KoUnit::parseValue( element.attributeNS( KoXmlNS::svg,
"width", TQString() )) );
620 ext.setHeight(KoUnit::parseValue( element.attributeNS( KoXmlNS::svg,
"height", TQString() ) ) );
622 KoStyleStack &styleStack = context.styleStack();
623 styleStack.setTypeProperties(
"" );
624 if ( element.hasAttributeNS( KoXmlNS::draw,
"transform" ) )
628 TQString transform = element.attributeNS( KoXmlNS::draw,
"transform", TQString() );
629 kdDebug()<<
" transform action :"<<transform<<endl;
630 TQRegExp rx(
"rotate ?\\(([^)]+)\\) translate ?\\(([^ ]+) ([^)]+)\\)" );
631 if ( rx.search( transform ) != - 1 && rx.numCaptures() == 3 )
634 double angInRad = rx.cap( 1 ).toDouble( &ok );
637 angle = -angInRad * 180.0 / M_PI;
644 TQWMatrix m( cos( angInRad ), -sin( angInRad ), sin( angInRad ), cos( angInRad ), 0, 0 );
645 KoPoint center( ext.width() / 2, ext.height() / 2 );
648 m.map( center.x(), center.y(), &transX, &transY );
649 KoPoint diff( transX, transY );
650 KoPoint trans( KoUnit::parseValue( rx.cap( 2 ) ), KoUnit::parseValue( rx.cap( 3 ) ) );
651 orig = trans - center + diff;
652 kdDebug(33001) <<
"trans = " << trans <<
", center = " << center <<
", diff = " << diff <<
", orig = " << orig << endl;
655 TQDomElement *animation = 0L;
656 lstAnimation *tmp = 0L;
657 if( element.hasAttributeNS( KoXmlNS::draw,
"id"))
659 tmp = info->animationShowById(element.attributeNS( KoXmlNS::draw,
"id", TQString()) );
661 animation = tmp->element;
666 TQString effectStr = animation->attributeNS( KoXmlNS::presentation,
"effect", TQString());
667 TQString dir = animation->attributeNS( KoXmlNS::presentation,
"direction", TQString());
668 TQString speed = animation->attributeNS( KoXmlNS::presentation,
"speed", TQString() );
669 appearStep = tmp->order;
670 kdDebug()<<
" appear direction : "<<dir<<
" effect :"<< effectStr <<
" speed :"<<speed<<endl;
672 if ( speed ==
"medium" )
674 m_appearSpeed = ES_MEDIUM;
676 else if ( speed==
"slow" )
678 m_appearSpeed = ES_SLOW;
680 else if ( speed==
"fast" )
682 m_appearSpeed = ES_FAST;
685 kdDebug()<<
" speed argument is not defined :"<<speed<<endl;
687 if ( animation->hasAttributeNS( KoXmlNS::presentation,
"animation-delay" ) )
689 appearTimer = loadOasisTimer(animation->attributeNS( KoXmlNS::presentation,
"animation-delay", TQString() ) );
691 if (effectStr==
"fade")
693 if (dir==
"from-right")
694 effect = EF_WIPE_RIGHT;
695 else if (dir==
"from-left")
696 effect = EF_WIPE_LEFT;
697 else if (dir==
"from-top")
699 else if (dir==
"from-bottom")
700 effect = EF_WIPE_BOTTOM;
702 kdDebug(33001)<<
" dir not supported: " << dir << endl;
704 else if (effectStr==
"move")
706 if (dir==
"from-right")
707 effect = EF_COME_RIGHT;
708 else if (dir==
"from-left")
709 effect = EF_COME_LEFT;
710 else if (dir==
"from-top")
711 effect = EF_COME_TOP;
712 else if (dir==
"from-bottom")
713 effect = EF_COME_BOTTOM;
714 else if (dir==
"from-upper-right")
715 effect = EF_COME_RIGHT_TOP;
716 else if (dir==
"from-lower-right")
717 effect = EF_COME_RIGHT_BOTTOM;
718 else if (dir==
"from-upper-left")
719 effect = EF_COME_LEFT_TOP;
720 else if (dir==
"from-lower-left")
721 effect = EF_COME_LEFT_BOTTOM;
723 kdDebug(33001) <<
" dir not supported:" << dir << endl;
725 else if ( effectStr ==
"appear" )
731 kdDebug(33001) <<
" appear effect not supported: " << effectStr << endl;
735 TQString byParagaph = animation->attributeNS( KoXmlNS::koffice,
"by-paragraph", TQString() );
736 if ( byParagaph ==
"true" )
741 TQDomElement sound = KoDom::namedItemNS( *animation, KoXmlNS::presentation,
"sound" );
742 if ( !sound.isNull() )
744 kdDebug()<<
" object has sound effect \n";
745 if ( sound.hasAttributeNS( KoXmlNS::xlink,
"href" ) )
747 a_fileName =sound.attributeNS( KoXmlNS::xlink,
"href", TQString() );
748 appearSoundEffect =
true;
755 if( element.hasAttributeNS( KoXmlNS::draw,
"id"))
757 tmp = info->animationHideById(element.attributeNS( KoXmlNS::draw,
"id", TQString()) );
759 animation = tmp->element;
764 TQString effectStr = animation->attributeNS( KoXmlNS::presentation,
"effect", TQString());
765 TQString dir = animation->attributeNS( KoXmlNS::presentation,
"direction", TQString());
766 TQString speed = animation->attributeNS( KoXmlNS::presentation,
"speed", TQString() );
767 kdDebug()<<
" disappear direction : "<<dir<<
" effect :"<< effectStr <<
" speed :"<<speed<<endl;
768 disappearStep = tmp->order;
770 if ( speed ==
"medium" )
772 m_disappearSpeed = ES_MEDIUM;
774 else if ( speed==
"slow" )
776 m_disappearSpeed = ES_SLOW;
778 else if ( speed==
"fast" )
780 m_disappearSpeed = ES_FAST;
783 kdDebug()<<
" speed argument is not defined :"<<speed<<endl;
785 if ( animation->hasAttributeNS( KoXmlNS::presentation,
"animation-delay" ) )
787 disappearTimer = loadOasisTimer(animation->attributeNS( KoXmlNS::presentation,
"animation-delay", TQString() ) );
789 if (effectStr==
"fade")
791 if (dir==
"from-right")
792 effect3 = EF3_WIPE_RIGHT;
793 else if (dir==
"from-left")
794 effect3 = EF3_WIPE_LEFT;
795 else if (dir==
"from-top")
796 effect3 = EF3_WIPE_TOP;
797 else if (dir==
"from-bottom")
798 effect3 = EF3_WIPE_BOTTOM;
800 kdDebug(33001) <<
" dir not supported: " << dir << endl;
802 else if (effectStr==
"move")
804 if (dir==
"from-right")
805 effect3 = EF3_GO_RIGHT;
806 else if (dir==
"from-left")
807 effect3 = EF3_GO_LEFT;
808 else if (dir==
"from-top")
809 effect3 = EF3_GO_TOP;
810 else if (dir==
"from-bottom")
811 effect3 = EF3_GO_BOTTOM;
812 else if (dir==
"from-upper-right")
813 effect3 = EF3_GO_RIGHT_TOP;
814 else if (dir==
"from-lower-right")
815 effect3 = EF3_GO_RIGHT_BOTTOM;
816 else if (dir==
"from-upper-left")
817 effect3 = EF3_GO_LEFT_TOP;
818 else if (dir==
"from-lower-left")
819 effect3 = EF3_GO_LEFT_BOTTOM;
821 kdDebug(33001) <<
" dir not supported: " << dir << endl;
823 else if ( effectStr ==
"hide" )
829 kdDebug(33001) <<
" hide effect not supported: " << effectStr << endl;
835 TQDomElement sound = KoDom::namedItemNS( *animation, KoXmlNS::presentation,
"sound" );
836 if ( !sound.isNull() )
838 kdDebug()<<
" object has sound effect \n";
839 if ( sound.hasAttributeNS( KoXmlNS::xlink,
"href" ) )
841 d_fileName =sound.attributeNS( KoXmlNS::xlink,
"href", TQString() );
842 disappearSoundEffect =
true;
848 if ( !element.hasAttribute(
"type" ) ||
849 ( element.hasAttribute(
"type" ) && element.attribute(
"type" ) ==
"4" ) )
851 kdDebug()<<
" text document !!!!!\n";
852 if ( styleStack.hasAttributeNS( KoXmlNS::fo,
"text-shadow" ) &&
853 styleStack.attributeNS( KoXmlNS::fo,
"text-shadow" ) !=
"none" )
855 TQString distance = styleStack.attributeNS( KoXmlNS::fo,
"text-shadow" );
856 distance.truncate( distance.find(
' ' ) );
857 shadowDistance = (int)KoUnit::parseValue( distance );
858 shadowDirection = SD_RIGHT_BOTTOM;
859 shadowColor= TQColor(
"#a0a0a0" );
866 styleStack.setTypeProperties(
"graphic" );
867 if ( styleStack.hasAttributeNS( KoXmlNS::draw,
"move-protect" ) )
869 kdDebug()<<
" styleStack.attribute(draw:move-protect ) :"<<styleStack.attributeNS( KoXmlNS::draw,
"move-protect" )<<endl;
870 protect = ( styleStack.attributeNS( KoXmlNS::draw,
"move-protect" ) ==
"true" );
872 if ( styleStack.hasAttributeNS( KoXmlNS::draw,
"size-protect" ) )
874 kdDebug()<<
" styleStack.attribute(draw:size-protect ) :"<<styleStack.attributeNS( KoXmlNS::draw,
"size-protect" )<<endl;
875 protect = ( styleStack.attributeNS( KoXmlNS::draw,
"size-protect" ) ==
"true" );
879 if ( styleStack.hasAttributeNS( KoXmlNS::draw,
"textarea-vertical-align" ) )
881 kdDebug()<<
" styleStack.attribute(draw:textarea-vertical-align ) :"<<styleStack.attributeNS( KoXmlNS::draw,
"textarea-vertical-align" )<<endl;
883 if ( styleStack.hasAttributeNS( KoXmlNS::draw,
"textarea-horizontal-align") )
885 kdDebug()<<
" styleStack.attribute(draw:textarea-horizontal-align ) :"<<styleStack.attributeNS( KoXmlNS::draw,
"textarea-horizontal-align" )<<endl;
887 if ( styleStack.hasAttributeNS( KoXmlNS::draw,
"shadow" ) &&
888 styleStack.attributeNS( KoXmlNS::draw,
"shadow") ==
"visible" )
891 double x = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::draw,
"shadow-offset-x" ) );
892 double y = KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::draw,
"shadow-offset-y" ) );
893 kdDebug()<<
" shadow x : "<<x<<
" shadow y :"<<y<<endl;
894 if ( x < 0 && y < 0 )
896 shadowDirection = SD_LEFT_UP;
897 shadowDistance = (int) fabs ( x );
899 else if ( x == 0 && y < 0 )
901 shadowDirection = SD_UP;
902 shadowDistance = (int) fabs ( y );
904 else if ( x > 0 && y < 0 )
906 shadowDirection = SD_RIGHT_UP;
907 shadowDistance = (int) fabs ( x );
909 else if ( x > 0 && y == 0 )
911 shadowDirection = SD_RIGHT;
912 shadowDistance = (int) fabs ( x );
914 else if ( x > 0 && y > 0 )
916 shadowDirection = SD_RIGHT_BOTTOM;
917 shadowDistance = (int) fabs ( x );
919 else if ( x == 0 && y > 0 )
921 shadowDirection = SD_BOTTOM;
922 shadowDistance = (int) fabs ( y );
924 else if ( x < 0 && y > 0 )
926 shadowDirection = SD_LEFT_BOTTOM;
927 shadowDistance = (int) fabs ( x );
929 else if ( x < 0 && y == 0 )
931 shadowDirection = SD_LEFT;
932 shadowDistance = (int) fabs ( x );
934 if ( styleStack.hasAttributeNS( KoXmlNS::draw,
"shadow-color" ) )
935 shadowColor= TQColor(styleStack.attributeNS( KoXmlNS::draw,
"shadow-color" ) );
936 kdDebug()<<
" shadow color : "<<TQString(shadowColor.name())<<endl;
940bool KPrObject::saveOasisObject( KPOasisSaveContext &sc )
const
942 sc.xmlWriter.startElement( getOasisElementName() );
943 sc.xmlWriter.addAttribute( sc.onMaster ?
"presentation:style-name":
"draw:style-name", getStyle( sc ) );
944 saveOasisPosObject( sc.xmlWriter, sc.indexObj );
945 if( !objectName.isEmpty())
946 sc.xmlWriter.addAttribute(
"draw:name", objectName );
948 saveOasisObjectAttributes( sc );
950 sc.xmlWriter.endElement();
954void KPrObject::saveOasisShadowElement( KoGenStyle &styleobjectauto )
const
957 if(shadowDistance!=0 || shadowDirection!=SD_RIGHT_BOTTOM || shadowColor!=TQt::gray) {
958 styleobjectauto.addProperty(
"draw:shadow",
"visible" );
959 switch( shadowDirection )
962 styleobjectauto.addPropertyPt(
"draw:shadow-offset-x", ( -1.0 * shadowDistance ) );
963 styleobjectauto.addPropertyPt(
"draw:shadow-offset-y", ( -1.0 * shadowDistance ) );
966 styleobjectauto.addPropertyPt(
"draw:shadow-offset-x", 0.0 );
967 styleobjectauto.addPropertyPt(
"draw:shadow-offset-y", ( -1.0 * shadowDistance ) );
970 styleobjectauto.addPropertyPt(
"draw:shadow-offset-x", shadowDistance );
971 styleobjectauto.addPropertyPt(
"draw:shadow-offset-y", ( -1.0 * shadowDistance ) );
974 styleobjectauto.addPropertyPt(
"draw:shadow-offset-x", shadowDistance );
975 styleobjectauto.addPropertyPt(
"draw:shadow-offset-y", 0.0 );
977 case SD_RIGHT_BOTTOM:
978 styleobjectauto.addPropertyPt(
"draw:shadow-offset-x",shadowDistance );
979 styleobjectauto.addPropertyPt(
"draw:shadow-offset-y", shadowDistance );
982 styleobjectauto.addPropertyPt(
"draw:shadow-offset-x", 0.0 );
983 styleobjectauto.addPropertyPt(
"draw:shadow-offset-y",shadowDistance );
986 styleobjectauto.addPropertyPt(
"draw:shadow-offset-x", ( -1.0*shadowDistance ) );
987 styleobjectauto.addPropertyPt(
"draw:shadow-offset-y", shadowDistance );
990 styleobjectauto.addPropertyPt(
"draw:shadow-offset-x", ( -1.0 * shadowDistance ) );
991 styleobjectauto.addPropertyPt(
"draw:shadow-offset-y", 0.0 );
994 styleobjectauto.addProperty(
"draw:shadow-color", shadowColor.name() );
998double KPrObject::load(
const TQDomElement &element) {
1001 TQDomElement e=element.namedItem(tagORIG).toElement();
1003 if(e.hasAttribute(attrX))
1004 orig.setX(e.attribute(attrX).toDouble());
1005 if(e.hasAttribute(attrY))
1007 offset=e.attribute(attrY).toDouble();
1011 e=element.namedItem(tagSIZE).toElement();
1013 if(e.hasAttribute(attrWidth))
1014 ext.setWidth(e.attribute(attrWidth).toDouble());
1015 if(e.hasAttribute(attrHeight))
1016 ext.setHeight(e.attribute(attrHeight).toDouble());
1018 e=element.namedItem(tagSHADOW).toElement();
1020 if(e.hasAttribute(attrDistance))
1021 shadowDistance=e.attribute(attrDistance).toInt();
1022 if(e.hasAttribute(attrDirection))
1023 shadowDirection=
static_cast<ShadowDirection
>(e.attribute(attrDirection).toInt());
1024 shadowColor=retrieveColor(e);
1028 shadowDirection=SD_RIGHT_BOTTOM;
1029 shadowColor=TQt::gray;
1031 e=element.namedItem(tagEFFECTS).toElement();
1033 if(e.hasAttribute(attrEffect))
1034 effect=
static_cast<Effect
>(e.attribute(attrEffect).toInt());
1035 if(e.hasAttribute(attrEffect2))
1036 effect2=
static_cast<Effect2
>(e.attribute(attrEffect2).toInt());
1037 if(e.hasAttribute(
"speed"))
1039 m_appearSpeed=
static_cast<EffectSpeed
>(e.attribute(
"speed").toInt());
1041 m_appearSpeed = m_appearSpeed > ES_FAST ? ES_FAST : m_appearSpeed;
1048 e=element.namedItem(tagANGLE).toElement();
1050 if(e.hasAttribute(attrValue))
1051 angle=e.attribute(attrValue).toFloat();
1055 e=element.namedItem(tagPRESNUM).toElement();
1057 if(e.hasAttribute(attrValue))
1058 appearStep=e.attribute(attrValue).toInt();
1062 e=element.namedItem(tagDISAPPEAR).toElement();
1064 if(e.hasAttribute(attrEffect))
1065 effect3=
static_cast<Effect3
>(e.attribute(attrEffect).toInt());
1066 if(e.hasAttribute(attrDoit))
1067 disappear=
static_cast<bool>(e.attribute(attrDoit).toInt());
1068 if(e.hasAttribute(attrNum))
1069 disappearStep=e.attribute(attrNum).toInt();
1070 if(e.hasAttribute(
"speed"))
1072 m_disappearSpeed=
static_cast<EffectSpeed
>(e.attribute(
"speed").toInt());
1074 m_disappearSpeed = m_appearSpeed > ES_FAST ? ES_FAST : m_appearSpeed;
1082 e=element.namedItem(
"TIMER").toElement();
1084 if(e.hasAttribute(
"appearTimer"))
1085 appearTimer = e.attribute(
"appearTimer").toInt();
1086 if(e.hasAttribute(
"disappearTimer"))
1087 disappearTimer = e.attribute(
"disappearTimer").toInt();
1093 e=element.namedItem(
"APPEARSOUNDEFFECT").toElement();
1095 if(e.hasAttribute(
"appearSoundEffect"))
1096 appearSoundEffect =
static_cast<bool>(e.attribute(
"appearSoundEffect").toInt());
1097 if(e.hasAttribute(
"appearSoundFileName"))
1098 a_fileName = e.attribute(
"appearSoundFileName");
1101 appearSoundEffect =
false;
1102 a_fileName = TQString();
1104 e=element.namedItem(
"DISAPPEARSOUNDEFFECT").toElement();
1106 if(e.hasAttribute(
"disappearSoundEffect"))
1107 disappearSoundEffect =
static_cast<bool>(e.attribute(
"disappearSoundEffect").toInt());
1108 if(e.hasAttribute(
"disappearSoundFileName"))
1109 d_fileName = e.attribute(
"disappearSoundFileName");
1112 disappearSoundEffect =
false;
1113 d_fileName = TQString();
1115 e=element.namedItem(
"OBJECTNAME").toElement();
1117 if(e.hasAttribute(
"objectName"))
1118 objectName = e.attribute(
"objectName");
1121 objectName = TQString();
1123 e=element.namedItem(
"PROTECT").toElement();
1126 if(e.hasAttribute(
"state"))
1127 protect=
static_cast<bool>(e.attribute(
"state").toInt());
1130 e=element.namedItem(
"RATIO").toElement();
1133 if(e.hasAttribute(
"ratio"))
1134 keepRatio=
static_cast<bool>(e.attribute(
"ratio").toInt());
1140KoSize KPrObject::getRealSize()
const {
1143 if ( angle != 0.0 ) {
1144 float angInRad = angle * M_PI / 180;
1145 size.setWidth( ext.width() * fabs( cos( angInRad ) ) + ext.height() * fabs( sin( angInRad ) ) );
1146 size.setHeight( ext.width() * fabs( sin( angInRad ) ) + ext.height() * fabs( cos( angInRad ) ) );
1152KoPoint KPrObject::getRealOrig()
const {
1153 KoPoint origin = orig;
1155 if ( angle != 0.0 ) {
1156 KoSize dist( ( getRealSize() - ext ) / 2 );
1157 origin.setX( orig.x() - dist.width() );
1158 origin.setY( orig.y() - dist.height() );
1164KoRect KPrObject::getRealRect()
const {
1165 return KoRect( getRealOrig(), getRealSize() );
1168KoRect KPrObject::getRepaintRect()
const
1170 KoRect rect( getRealOrig(), getRealSize() );
1172 if ( shadowDirection == SD_LEFT ||
1173 shadowDirection == SD_LEFT_UP ||
1174 shadowDirection == SD_LEFT_BOTTOM )
1176 rect.setLeft( rect.left() - shadowDistance );
1178 if ( shadowDirection == SD_UP ||
1179 shadowDirection == SD_LEFT_UP ||
1180 shadowDirection == SD_RIGHT_UP )
1182 rect.setTop( rect.top() - shadowDistance );
1184 if ( shadowDirection == SD_RIGHT ||
1185 shadowDirection == SD_RIGHT_UP ||
1186 shadowDirection == SD_RIGHT_BOTTOM )
1188 rect.setRight( rect.right() + shadowDistance );
1190 if ( shadowDirection == SD_BOTTOM ||
1191 shadowDirection == SD_LEFT_BOTTOM ||
1192 shadowDirection == SD_RIGHT_BOTTOM )
1194 rect.setBottom( rect.bottom() + shadowDistance );
1199 double _dx = rect.x() - 1.0;
1200 double _dy = rect.y() - 1.0;
1201 double _dw = rect.width() + 2.0;
1202 double _dh = rect.height() + 2.0;
1203 rect.setRect( _dx, _dy, _dw, _dh );
1209void KPrObject::flip(
bool ) {
1212 angle = 360.0 - angle;
1216KoRect KPrObject::rotateRectObject()
const
1218 KoRect br = KoRect( 0,0, ext.width(), ext.height() );
1219 double pw = br.width();
1220 double ph = br.height();
1222 double yPos = -rr.y();
1223 double xPos = -rr.x();
1224 rr.moveTopLeft( KoPoint( -rr.width() / 2.0, -rr.height() / 2.0 ) );
1226 m.translate( pw / 2.0, ph / 2.0 );
1228 m.translate( rr.left() + xPos, rr.top() + yPos );
1229 KoRect r = KoRect::fromTQRect(m.mapRect( br.toTQRect() ));
1230 r.moveBy( orig.x() , orig.y() );
1234void KPrObject::rotateObject(TQPainter *paint,KoTextZoomHandler *_zoomHandler)
1236 KoRect rr = KoRect( 0, 0, ext.width(), ext.height() );
1237 rr.moveTopLeft( KoPoint( -ext.width() / 2.0, -ext.height() / 2.0 ) );
1239 m.translate( _zoomHandler->zoomItX(ext.width() / 2.0), _zoomHandler->zoomItY(ext.height() / 2.0 ));
1241 m.translate( _zoomHandler->zoomItX(rr.left()), _zoomHandler->zoomItY(rr.top()) );
1243 paint->setWorldMatrix( m,
true );
1246bool KPrObject::contains(
const KoPoint &point )
const
1248 return getRealRect().contains( point );
1251bool KPrObject::intersects(
const KoRect &rect )
const
1253 return getRealRect().intersects( rect );
1256TQCursor KPrObject::getCursor(
const KoPoint &_point, ModifyType &_modType,
1257 KPrDocument *doc )
const
1259 KoTextZoomHandler * zh = doc->zoomHandler();
1260 int px = zh->zoomItX(_point.x());
1261 int py = zh->zoomItY(_point.y());
1263 TQRect rect = zh->zoomRect( getRealRect() );
1264 int ox = rect.left();
1265 int oy = rect.top();
1266 int ow = rect.width();
1267 int oh = rect.height();
1269 bool headerFooter=doc->isHeaderFooter(
this);
1272 if ( px >= ox && py >= oy && px <= ox + TQMIN( ow / 3, sz ) && py <= oy + TQMIN( oh / 3, sz ) )
1274 _modType = MT_RESIZE_LU;
1276 return TQt::ForbiddenCursor;
1277 return TQt::sizeFDiagCursor;
1280 if ( px >= ox && py >= oy + oh / 2 - TQMIN( oh / 6, sz / 2 )
1281 && px <= ox + TQMIN( ow / 3, sz)
1282 && py <= oy + oh / 2 + TQMIN( oh / 6, sz / 2 ) )
1284 _modType = MT_RESIZE_LF;
1286 return TQt::ForbiddenCursor;
1287 return TQt::sizeHorCursor;
1290 if ( px >= ox && py >= oy + oh - TQMIN( oh / 3, sz ) && px <= ox + TQMIN( ow / 3, sz ) && py <= oy + oh )
1292 _modType = MT_RESIZE_LD;
1294 return TQt::ForbiddenCursor;
1295 return TQt::sizeBDiagCursor;
1298 if ( px >= ox + ow / 2 - TQMIN( ow / 6, sz / 2 ) && py >= oy
1299 && px <= ox + ow / 2 + TQMIN( ow / 6, sz / 2 )
1300 && py <= oy + TQMIN( oh / 3, sz ) )
1302 _modType = MT_RESIZE_UP;
1304 return TQt::ForbiddenCursor;
1305 return TQt::sizeVerCursor;
1308 if ( px >= ox + ow / 2 - TQMIN( ow / 6, sz / 2 ) && py >= oy + oh - TQMIN( oh / 3, sz )
1309 && px <= ox + ow / 2 + TQMIN( ow / 6, sz / 2 ) && py <= oy + oh )
1311 _modType = MT_RESIZE_DN;
1313 return TQt::ForbiddenCursor;
1314 return TQt::sizeVerCursor;
1317 if ( px >= ox + ow - TQMIN( ow / 3, sz ) && py >= oy && px <= ox + ow && py <= oy + TQMIN( oh / 3, sz) )
1319 _modType = MT_RESIZE_RU;
1321 return TQt::ForbiddenCursor;
1322 return TQt::sizeBDiagCursor;
1325 if ( px >= ox + ow - TQMIN( ow / 3, sz ) && py >= oy + oh / 2 - TQMIN( oh / 6, sz / 2 )
1326 && px <= ox + ow && py <= oy + oh / 2 + TQMIN( oh / 6, sz / 2) )
1328 _modType = MT_RESIZE_RT;
1330 return TQt::ForbiddenCursor;
1331 return TQt::sizeHorCursor;
1334 if ( px >= ox + ow - TQMIN( ow / 3, sz ) && py >= oy + oh - TQMIN( oh / 3, sz)
1335 && px <= ox + ow && py <= oy + oh )
1337 _modType = MT_RESIZE_RD;
1339 return TQt::ForbiddenCursor;
1340 return TQt::sizeFDiagCursor;
1347 return TQt::ForbiddenCursor;
1349 return TQt::sizeAllCursor;
1352void KPrObject::getShadowCoords(
double& _x,
double& _y )
const
1354 double sx = 0, sy = 0;
1356 switch ( shadowDirection )
1360 sx = _x - shadowDistance;
1361 sy = _y - shadowDistance;
1366 sy = _y - shadowDistance;
1370 sx = _x + shadowDistance;
1371 sy = _y - shadowDistance;
1375 sx = _x + shadowDistance;
1378 case SD_RIGHT_BOTTOM:
1380 sx = _x + shadowDistance;
1381 sy = _y + shadowDistance;
1386 sy = _y + shadowDistance;
1388 case SD_LEFT_BOTTOM:
1390 sx = _x - shadowDistance;
1391 sy = _y + shadowDistance;
1395 sx = _x - shadowDistance;
1403void KPrObject::paintSelection( TQPainter *_painter, KoTextZoomHandler *_zoomHandler, SelectionMode mode )
1405 if ( !selected || mode == SM_NONE )
1409 _painter->translate( _zoomHandler->zoomItX(orig.x()), _zoomHandler->zoomItY(orig.y()) );
1410 _painter->setPen( TQPen( TQt::black, 1, TQPen::SolidLine ) );
1411 _painter->setBrush( kapp->palette().color( TQPalette::Active, TQColorGroup::Highlight ) );
1413 KoRect r = getRealRect();
1415 int x = _zoomHandler->zoomItX( r.left() - orig.x());
1416 int y = _zoomHandler->zoomItY( r.top() - orig.y());
1419 int w = _zoomHandler->zoomItX(r.width()) - 6;
1420 int h = _zoomHandler->zoomItY(r.height()) - 6;
1422 if ( mode == SM_MOVERESIZE ) {
1423 _painter->drawRect( x, y, zX6, zY6 );
1424 _painter->drawRect( x, y + h / 2, zX6, zY6 );
1425 _painter->drawRect( x, y + h, zX6, zY6 );
1426 _painter->drawRect( x + w, y, zX6, zY6 );
1427 _painter->drawRect( x + w, y + h / 2, zX6, zY6 );
1428 _painter->drawRect( x + w, y + h, zX6, zY6 );
1429 _painter->drawRect( x + w / 2, y,zX6, zY6 );
1430 _painter->drawRect( x + w / 2, y + h, zX6, zY6 );
1432 else if ( mode == SM_PROTECT) {
1433 _painter->drawRect( x, y, zX6, zY6 );
1434 _painter->drawRect( x, y + h / 2, zX6, zY6 );
1435 _painter->drawRect( x, y + h, zX6, zY6 );
1436 _painter->drawRect( x + w, y, zX6, zY6 );
1437 _painter->drawRect( x + w, y + h / 2, zX6, zY6 );
1438 _painter->drawRect( x + w, y + h, zX6, zY6 );
1439 _painter->drawRect( x + w / 2, y,zX6, zY6 );
1440 _painter->drawRect( x + w / 2, y + h, zX6, zY6 );
1447 TQBrush brush=kapp->palette().color( TQPalette::Active,TQColorGroup::Base );
1448 _painter->fillRect( x, y, zX6, zY6, brush );
1449 _painter->fillRect( x, y + h / 2, zX6, zY6, brush);
1450 _painter->fillRect( x, y + h, zX6, zY6, brush );
1451 _painter->fillRect( x + w, y, zX6, zY6, brush );
1452 _painter->fillRect( x + w, y + h / 2, zX6, zY6, brush );
1453 _painter->fillRect( x + w , y + h , zX6 , zY6 , brush );
1454 _painter->fillRect( x + w / 2 , y ,zX6 , zY6 , brush );
1455 _painter->fillRect( x + w / 2, y + h , zX6 , zY6 , brush );
1457 else if ( mode == SM_ROTATE ) {
1458 _painter->drawEllipse( x, y, zX6, zY6 );
1459 _painter->drawEllipse( x, y + h, zX6, zY6 );
1460 _painter->drawEllipse( x + w, y, zX6, zY6 );
1461 _painter->drawEllipse( x + w, y + h, zX6, zY6 );
1464 _painter->restore();
1467void KPrObject::doDelete()
1469 if ( cmds == 0 && !inObjList )
1473DCOPObject* KPrObject::dcopObject()
1476 dcop =
new KPrObjectIface(
this );
1481void KPrObject::setupClipRegion( TQPainter *painter,
const TQRegion &clipRegion )
1483 TQRegion region = painter->clipRegion( TQPainter::CoordPainter );
1484 if ( region.isEmpty() )
1485 region = clipRegion;
1487 region.unite( clipRegion );
1489 painter->setClipRegion( region, TQPainter::CoordPainter );
1492TQDomElement KPrObject::createValueElement(
const TQString &tag,
int value, TQDomDocument &doc) {
1493 TQDomElement elem=doc.createElement(tag);
1494 elem.setAttribute(attrValue, value);
1498TQDomElement KPrObject::createGradientElement(
const TQString &tag,
const TQColor &c1,
const TQColor &c2,
1499 int type,
bool unbalanced,
int xfactor,
1500 int yfactor, TQDomDocument &doc) {
1501 TQDomElement elem=doc.createElement(tag);
1502 elem.setAttribute(attrC1, c1.name());
1503 elem.setAttribute(attrC2, c2.name());
1504 elem.setAttribute(attrType, type);
1505 elem.setAttribute(attrUnbalanced, (uint)unbalanced);
1506 elem.setAttribute(attrXFactor, xfactor);
1507 elem.setAttribute(attrYFactor, yfactor);
1511TQDomElement KPrObject::createPenElement(
const TQString &tag,
const KoPen &pen, TQDomDocument &doc) {
1513 TQDomElement elem=doc.createElement(tag);
1514 elem.setAttribute(attrColor, pen.color().name());
1515 elem.setAttribute(attrWidth, pen.pointWidth());
1516 elem.setAttribute(attrStyle,
static_cast<int>(pen.style()));
1520KoPen KPrObject::toPen(
const TQDomElement &element)
const {
1523 pen.setColor(retrieveColor(element));
1524 if(element.hasAttribute(attrStyle))
1525 pen.setStyle(
static_cast<TQt::PenStyle
>(element.attribute(attrStyle).toInt()));
1526 if(element.hasAttribute(attrWidth))
1527 pen.setPointWidth(element.attribute(attrWidth).toDouble());
1531TQDomElement KPrObject::createBrushElement(
const TQString &tag,
const TQBrush &brush, TQDomDocument &doc) {
1533 TQDomElement elem=doc.createElement(tag);
1534 elem.setAttribute(attrColor, brush.color().name());
1535 elem.setAttribute(attrStyle,
static_cast<int>(brush.style()));
1539TQBrush KPrObject::toBrush(
const TQDomElement &element)
const {
1542 brush.setColor(retrieveColor(element));
1543 if(element.hasAttribute(attrStyle))
1544 brush.setStyle(
static_cast<TQt::BrushStyle
>(element.attribute(attrStyle).toInt()));
1548TQColor KPrObject::retrieveColor(
const TQDomElement &element,
const TQString &cattr,
1549 const TQString &rattr,
const TQString &gattr,
const TQString &battr)
const {
1551 if(element.hasAttribute(cattr))
1552 ret.setNamedColor(element.attribute(cattr));
1554 int red=0, green=0, blue=0;
1555 if(element.hasAttribute(rattr))
1556 red=element.attribute(rattr).toInt();
1557 if(element.hasAttribute(gattr))
1558 green=element.attribute(gattr).toInt();
1559 if(element.hasAttribute(battr))
1560 blue=element.attribute(battr).toInt();
1561 ret.setRgb(red, green, blue);
1566void KPrObject::draw( TQPainter *_painter, KoTextZoomHandler*_zoomHandler,
1567 int , SelectionMode selectionMode,
bool drawContour )
1569 if ( selectionMode != SM_NONE && !drawContour )
1570 paintSelection( _painter, _zoomHandler, selectionMode );
1573KoPen KPrObject::getPen()
const
1579void KPrObject::getRealSizeAndOrigFromPoints( KoPointArray &points,
float angle,
1580 KoSize &size, KoPoint &orig )
1585 float angInRad = angle * M_PI / 180;
1586 float sinus = sin( angInRad );
1587 float cosinus = cos( angInRad );
1589 float mid_x = size.width() / 2;
1590 float mid_y = size.height() / 2;
1596 KoPointArray::ConstIterator it;
1597 for ( it = points.begin(); it != points.end(); ++it ) {
1598 KoPoint cord( mid_x - (*it).x(), (*it).y() - mid_y );
1599 float tmp_x = cord.x() * cosinus + cord.y() * sinus;
1600 float tmp_y = - cord.x() * sinus + cord.y() * cosinus;
1602 if ( tmp_x < min_x ) {
1605 else if ( tmp_x > max_x ) {
1609 if ( tmp_y < min_y ) {
1612 else if ( tmp_y > max_y ) {
1617 size.setWidth( max_x - min_x );
1618 size.setHeight( max_y - min_y );
1620 orig.setX( orig.x() + mid_x - max_x );
1621 orig.setY( orig.y() + mid_y + min_y );
1624void KPrObject::addSelfToGuides(TQValueList<double> &horizontalPos, TQValueList<double> &verticalPos )
1626 KoRect bounds = getRealRect();
1628 horizontalPos.append( bounds.top() );
1629 verticalPos.append( bounds.left() );
1630 horizontalPos.append( bounds.bottom() );
1631 verticalPos.append( bounds.right() );
1634KPrShadowObject::KPrShadowObject()
1639KPrShadowObject::KPrShadowObject(
const KoPen &_pen )
1640 : KPrObject(), pen( _pen )
1649TQDomDocumentFragment KPrShadowObject::save( TQDomDocument& doc,
double offset )
1651 TQDomDocumentFragment fragment=KPrObject::save(doc, offset);
1654 fragment.appendChild(KPrObject::createPenElement(tagPEN, pen, doc));
1658void KPrShadowObject::saveOasisStrokeElement( KoGenStyles& mainStyles, KoGenStyle &styleobjectauto )
const
1660 switch( pen.style() )
1663 styleobjectauto.addProperty(
"draw:stroke" ,
"none" );
1665 case TQt::SolidLine:
1666 styleobjectauto.addProperty(
"draw:stroke" ,
"solid" );
1670 case TQt::DashDotLine:
1671 case TQt::DashDotDotLine:
1672 styleobjectauto.addProperty(
"draw:stroke" ,
"dash" );
1674 styleobjectauto.addProperty(
"draw:stroke-dash", saveOasisStrokeStyle( mainStyles ) );
1679 if ( pen.style() != TQt::NoPen )
1681 styleobjectauto.addProperty(
"svg:stroke-color", pen.color().name() );
1682 styleobjectauto.addPropertyPt(
"svg:stroke-width", pen.pointWidth() );
1686TQString KPrShadowObject::saveOasisStrokeStyle( KoGenStyles& mainStyles )
const
1688 KoGenStyle stroke( KPrDocument::STYLE_STROKE );
1689 switch( pen.style() )
1694 case TQt::SolidLine:
1698 stroke.addAttribute(
"draw:style",
"rect" );
1699 stroke.addAttribute(
"draw:dots1",
"1" );
1700 stroke.addAttribute(
"draw:dots2",
"1" );
1701 stroke.addAttribute(
"draw:dots1-length",
"0.508cm" );
1702 stroke.addAttribute(
"draw:dots2-length",
"0.508cm" );
1703 stroke.addAttribute(
"draw:distance",
"0.508cm" );
1706 stroke.addAttribute(
"draw:style",
"rect" );
1707 stroke.addAttribute(
"draw:dots1",
"1" );
1708 stroke.addAttribute(
"draw:distance",
"0.257cm" );
1710 case TQt::DashDotLine:
1711 stroke.addAttribute(
"draw:style",
"rect" );
1712 stroke.addAttribute(
"draw:dots1",
"1" );
1713 stroke.addAttribute(
"draw:dots2",
"1" );
1714 stroke.addAttribute(
"draw:dots1-length",
"0.051cm" );
1715 stroke.addAttribute(
"draw:dots2-length",
"0.254cm" );
1716 stroke.addAttribute(
"draw:distance",
"0.127cm" );
1718 case TQt::DashDotDotLine:
1719 stroke.addAttribute(
"draw:style",
"rect" );
1720 stroke.addAttribute(
"draw:dots1",
"2" );
1721 stroke.addAttribute(
"draw:dots2",
"1" );
1722 stroke.addAttribute(
"draw:dots2-length",
"0.203cm" );
1723 stroke.addAttribute(
"draw:distance",
"0.203cm" );
1728 return mainStyles.lookup( stroke,
"stroke" );
1734 TQString listOfPoint;
1737 KoPointArray::ConstIterator it( points.begin() );
1738 KoPointArray::ConstIterator end( points.end() );
1739 for ( ; it != end; ++it )
1741 int tmpX = int( ( *it ).x() * 10000 );
1742 int tmpY = int( ( *it ).y() * 10000 );
1744 if ( !listOfPoint.isEmpty() )
1745 listOfPoint += TQString(
" %1,%2" ).arg( tmpX ).arg( tmpY );
1747 listOfPoint = TQString(
"%1,%2" ).arg( tmpX ).arg( tmpY );
1748 maxX = TQMAX( maxX, tmpX );
1749 maxY = TQMAX( maxY, tmpY );
1751 sc.xmlWriter.addAttribute(
"draw:points", listOfPoint );
1752 sc.xmlWriter.addAttribute(
"svg:viewBox", TQString(
"0 0 %1 %2" ).arg( maxX ).arg( maxY ) );
1759 Q_UNUSED( context );
1761 TQStringList ptList = TQStringList::split(
' ', element.attributeNS( KoXmlNS::draw,
"points", TQString()));
1763 unsigned int index = 0;
1764 for (TQStringList::Iterator it = ptList.begin(); it != ptList.end(); ++it)
1766 points.putPoints( index++, 1, ( *it ).section(
',', 0, 0 ).toInt(), ( *it ).section(
',', 1, 1 ).toInt() );
1775 kdDebug(33001) <<
"loadOasisApplayViewBox svg:viewBox = " << element.attributeNS( KoXmlNS::svg,
"viewBox", TQString() ) << endl;
1776 TQStringList viewBoxPoints = TQStringList::split(
' ', element.attributeNS( KoXmlNS::svg,
"viewBox", TQString() ) );
1779 if ( viewBoxPoints.size() == 4 )
1781 TQStringList::Iterator it = viewBoxPoints.begin();
1783 viewBox.setLeft( ( *it++ ).toInt() );
1784 viewBox.setTop( ( *it++ ).toInt() );
1785 viewBox.setRight( ( *it++ ).toInt() );
1786 viewBox.setBottom( ( *it ).toInt() );
1788 kdDebug(33001) <<
"viewBox supplied = " << viewBox << endl;
1793 KoPointArray::ConstIterator it( points.begin() );
1795 for ( ; it != points.end(); ++it )
1800 viewBox.setCoords( p.x(), p.y(), p.x(), p.y() );
1805 viewBox.setLeft( TQMIN( viewBox.left(), p.x() ) );
1806 viewBox.setRight( TQMAX( viewBox.right(), p.x() ) );
1807 viewBox.setTop( TQMIN( viewBox.top(), p.y() ) );
1808 viewBox.setBottom( TQMAX( viewBox.bottom(), p.y() ) );
1811 kdDebug(33001) <<
"viewBox calculated = " << viewBox << endl;
1814 if ( viewBox.width() != 0 && viewBox.height() != 0 )
1816 KoPointArray::Iterator it( points.begin() );
1817 for ( ; it != points.end(); ++it )
1820 p->setX( ( p->x() - viewBox.left() ) / viewBox.width() * ext.width() );
1821 p->setY( ( p->y() - viewBox.top() ) / viewBox.height() * ext.height() );
1826 kdDebug(33001) <<
"problem in viewBox: " << viewBox << endl;
1832void KPrShadowObject::fillStyle( KoGenStyle& styleObjectAuto, KoGenStyles& mainStyles )
const
1834 kdDebug(33001) <<
"KPrShadowObject::fillStyle" << endl;
1835 KPrObject::fillStyle( styleObjectAuto, mainStyles );
1836 saveOasisStrokeElement( mainStyles, styleObjectAuto );
1839void KPrShadowObject::loadOasis(
const TQDomElement &element, KoOasisContext & context,
KPrLoadingInfo *info)
1842 KPrObject::loadOasis(element, context, info);
1843 KoStyleStack &styleStack = context.styleStack();
1844 styleStack.setTypeProperties(
"graphic" );
1845 if ( styleStack.hasAttributeNS( KoXmlNS::draw,
"stroke" ))
1847 if ( styleStack.attributeNS( KoXmlNS::draw,
"stroke" ) ==
"none" )
1848 pen.setStyle(TQt::NoPen );
1849 else if ( styleStack.attributeNS( KoXmlNS::draw,
"stroke" ) ==
"solid" )
1850 pen.setStyle(TQt::SolidLine );
1851 else if ( styleStack.attributeNS( KoXmlNS::draw,
"stroke" ) ==
"dash" )
1853 TQString style = styleStack.attributeNS( KoXmlNS::draw,
"stroke-dash" );
1855 kdDebug()<<
" stroke style is : "<<style<<endl;
1858 TQDomElement* draw = context.oasisStyles().drawStyles()[style];
1859 kdDebug()<<
" stroke have oasis style defined :"<<draw<<endl;
1863 if ( draw->attributeNS( KoXmlNS::draw,
"style", TQString() )==
"rect" )
1865 if ( draw->attributeNS( KoXmlNS::draw,
"dots1", TQString() )==
"1" &&
1866 draw->attributeNS( KoXmlNS::draw,
"dots2", TQString() )==
"1" &&
1867 draw->attributeNS( KoXmlNS::draw,
"dots1-length", TQString() )==
"0.508cm" &&
1868 draw->attributeNS( KoXmlNS::draw,
"dots2-length", TQString() )==
"0.508cm" &&
1869 draw->attributeNS( KoXmlNS::draw,
"distance", TQString() )==
"0.508cm" )
1870 pen.setStyle(TQt::DashLine );
1871 else if ( draw->attributeNS( KoXmlNS::draw,
"dots1", TQString() )==
"1" &&
1872 draw->attributeNS( KoXmlNS::draw,
"distance", TQString() )==
"0.257cm" )
1873 pen.setStyle(TQt::DotLine );
1874 else if ( draw->attributeNS( KoXmlNS::draw,
"dots1", TQString() )==
"1" &&
1875 draw->attributeNS( KoXmlNS::draw,
"dots2", TQString() )==
"1" &&
1876 draw->attributeNS( KoXmlNS::draw,
"dots1-length", TQString() )==
"0.051cm" &&
1877 draw->attributeNS( KoXmlNS::draw,
"dots2-length", TQString() )==
"0.254cm" &&
1878 draw->attributeNS( KoXmlNS::draw,
"distance", TQString() )==
"0.127cm" )
1879 pen.setStyle(TQt::DashDotLine );
1880 else if ( draw->attributeNS( KoXmlNS::draw,
"dots1", TQString() )==
"2" &&
1881 draw->attributeNS( KoXmlNS::draw,
"dots2", TQString() )==
"1" &&
1882 draw->attributeNS( KoXmlNS::draw,
"dots2-length", TQString() )==
"0.203cm" &&
1883 draw->attributeNS( KoXmlNS::draw,
"distance", TQString() )==
"0.203cm" )
1884 pen.setStyle(TQt::DashDotDotLine );
1887 kdDebug()<<
" stroke style undefined \n";
1888 pen.setStyle(TQt::SolidLine );
1895 if ( styleStack.hasAttributeNS( KoXmlNS::svg,
"stroke-width" ) )
1896 pen.setPointWidth( KoUnit::parseValue( styleStack.attributeNS( KoXmlNS::svg,
"stroke-width" ) ) );
1897 if ( styleStack.hasAttributeNS( KoXmlNS::svg,
"stroke-color" ) )
1898 pen.setColor( styleStack.attributeNS( KoXmlNS::svg,
"stroke-color" ) );
1902 kdDebug()<<
"pen style :"<<pen<<endl;
1905double KPrShadowObject::load(
const TQDomElement &element)
1907 double offset=KPrObject::load(element);
1908 TQDomElement e=element.namedItem(tagPEN).toElement();
1910 setPen(KPrObject::toPen(e));
1916void KPrShadowObject::draw( TQPainter *_painter, KoTextZoomHandler*_zoomHandler,
1917 int pageNum, SelectionMode selectionMode,
bool drawContour )
1919 double ox = orig.x();
1920 double oy = orig.y();
1924 if ( shadowDistance > 0 && !drawContour )
1928 KoPen tmpPen( pen );
1929 pen.setColor( shadowColor );
1931 brush.setColor( shadowColor );
1935 getShadowCoords( sx, sy );
1937 _painter->translate( _zoomHandler->zoomItX( sx ), _zoomHandler->zoomItY( sy ) );
1941 rotateObject( _painter, _zoomHandler );
1944 paint( _painter, _zoomHandler, pageNum,
true, drawContour );
1947 _painter->restore();
1950 _painter->translate( _zoomHandler->zoomItX(ox), _zoomHandler->zoomItY(oy) );
1953 rotateObject(_painter,_zoomHandler);
1954 paint( _painter, _zoomHandler, pageNum,
false, drawContour );
1956 _painter->restore();
1958 KPrObject::draw( _painter, _zoomHandler, pageNum, selectionMode, drawContour );
1966void KPrShadowObject::paint(TQPainter* painter, KoTextZoomHandler* zoomHandler,
int pageNum,
bool drawingShadow,
bool drawContour) {
1968 Q_UNUSED(zoomHandler);
1970 Q_UNUSED(drawingShadow);
1971 Q_UNUSED(drawContour);
1974KPr2DObject::KPr2DObject()
1977 , m_redrawGradientPix( false )
1981KPr2DObject::KPr2DObject(
const KoPen &_pen,
const TQBrush &_brush, FillType _fillType,
1982 const TQColor &_gColor1,
const TQColor &_gColor2, BCType _gType,
1983 bool _unbalanced,
int _xfactor,
int _yfactor )
1985 , m_brush( _brush, _gColor1, _gColor2, _gType, _fillType, _unbalanced, _xfactor, _yfactor )
1987 , m_redrawGradientPix( false )
1989 if ( getFillType() == FT_GRADIENT )
1991 gradient =
new KPrGradient( getGColor1(), getGColor2(),
1992 getGType(), getGUnbalanced(),
1993 getGXFactor(), getGYFactor() );
1994 m_redrawGradientPix =
true;
1998void KPr2DObject::setFillType( FillType _fillType )
2000 m_brush.setFillType( _fillType );
2002 if ( _fillType == FT_BRUSH && gradient )
2007 if ( _fillType == FT_GRADIENT && !gradient )
2009 gradient =
new KPrGradient( getGColor1(), getGColor2(),
2010 getGType(), getGUnbalanced(),
2011 getGXFactor(), getGYFactor() );
2012 m_redrawGradientPix =
true;
2016TQDomDocumentFragment KPr2DObject::save( TQDomDocument& doc,
double offset )
2018 TQDomDocumentFragment fragment=KPrShadowObject::save(doc, offset);
2019 TQBrush brush = getBrush();
2020 if ( brush != TQBrush() )
2021 fragment.appendChild( KPrObject::createBrushElement( tagBRUSH, brush, doc ) );
2023 FillType fillType = getFillType();
2024 if ( fillType != FT_BRUSH )
2025 fragment.appendChild( KPrObject::createValueElement( tagFILLTYPE,
static_cast<int>(fillType), doc ) );
2026 TQColor gColor1 = getGColor1();
2027 TQColor gColor2 = getGColor2();
2028 BCType gType = getGType();
2029 bool unbalanced = getGUnbalanced();
2030 int xfactor = getGXFactor();
2031 int yfactor = getGYFactor();
2032 if ( gColor1!=TQt::red || gColor2!=TQt::green || gType!=BCT_GHORZ || unbalanced || xfactor != 100 || yfactor != 100 )
2033 fragment.appendChild( KPrObject::createGradientElement( tagGRADIENT, gColor1, gColor2,
static_cast<int>(gType),
2034 unbalanced, xfactor, yfactor, doc));
2038void KPr2DObject::fillStyle( KoGenStyle& styleObjectAuto, KoGenStyles& mainStyles )
const
2040 kdDebug(33001) <<
"KPr2DObject::fillStyle" << endl;
2041 KPrShadowObject::fillStyle( styleObjectAuto, mainStyles );
2042 m_brush.saveOasisFillStyle( styleObjectAuto, mainStyles );
2046void KPr2DObject::loadOasis(
const TQDomElement &element, KoOasisContext & context,
KPrLoadingInfo *info)
2048 kdDebug()<<
"void KPr2DObject::loadOasis(const TQDomElement &element)\n";
2051 KPrShadowObject::loadOasis(element, context, info);
2052 m_brush.loadOasisFillStyle( context,
"graphic" );
2053 setFillType( m_brush.getFillType() );
2056double KPr2DObject::load(
const TQDomElement &element)
2058 double offset=KPrShadowObject::load(element);
2060 TQDomElement e=element.namedItem(tagFILLTYPE).toElement();
2062 if(e.hasAttribute(attrValue))
2063 setFillType(
static_cast<FillType
>(e.attribute(attrValue).toInt()));
2066 setFillType(FT_BRUSH);
2068 e=element.namedItem(tagBRUSH).toElement();
2070 setBrush(KPrObject::toBrush(e));
2072 setBrush( TQBrush() );
2074 e=element.namedItem(tagGRADIENT).toElement();
2076 setGColor1( retrieveColor( e, attrC1,
"red1",
"green1",
"blue1" ) );
2077 setGColor2( retrieveColor( e, attrC2,
"red2",
"green2",
"blue2" ) );
2078 if( e.hasAttribute( attrType ) )
2079 setGType(
static_cast<BCType
>( e.attribute( attrType ).toInt() ) );
2080 if( e.hasAttribute( attrUnbalanced ) )
2081 setGUnbalanced(
static_cast<bool>( e.attribute( attrUnbalanced ).toInt() ) );
2082 if( e.hasAttribute( attrXFactor ) )
2083 setGXFactor( e.attribute( attrXFactor ).toInt() );
2084 if( e.hasAttribute( attrYFactor ) )
2085 setGYFactor( e.attribute( attrYFactor ).toInt() );
2087 gradient->setParameters(getGColor1(), getGColor2(), getGType(), getGUnbalanced(), getGXFactor(), getGYFactor() );
2090 setGColor1( TQt::red );
2091 setGColor2( TQt::green );
2092 setGType( BCT_GHORZ );
2093 setGUnbalanced(
false );
2100void KPr2DObject::draw( TQPainter *_painter, KoTextZoomHandler*_zoomHandler,
2101 int pageNum, SelectionMode selectionMode,
bool drawContour )
2103 double ox = orig.x();
2104 double oy = orig.y();
2108 if ( shadowDistance > 0 && !drawContour )
2111 KoPen tmpPen( pen );
2112 pen.setColor( shadowColor );
2113 TQBrush tmpBrush( m_brush.getBrush() );
2114 TQBrush shadowBrush( tmpBrush );
2115 shadowBrush.setColor( shadowColor );
2116 m_brush.setBrush( shadowBrush );
2120 getShadowCoords( sx, sy );
2122 _painter->translate( _zoomHandler->zoomItX( sx ), _zoomHandler->zoomItY( sy ) );
2126 rotateObject( _painter, _zoomHandler );
2129 paint( _painter, _zoomHandler, pageNum,
true, drawContour );
2132 m_brush.setBrush( tmpBrush );
2133 _painter->restore();
2136 _painter->translate( _zoomHandler->zoomItX(ox), _zoomHandler->zoomItY(oy) );
2139 rotateObject(_painter,_zoomHandler);
2140 paint( _painter, _zoomHandler, pageNum,
false, drawContour );
2142 _painter->restore();
2144 KPrObject::draw( _painter, _zoomHandler, pageNum, selectionMode, drawContour );
2147void KPr2DObject::flip(
bool horizontal ) {
2148 KPrObject::flip( horizontal );
2151 if ( getFillType() == FT_GRADIENT ) {
2152 BCType gType = getGType();
2153 if ( gType == BCT_GDIAGONAL1 ) {
2154 setGType( BCT_GDIAGONAL2 );
2156 else if ( gType == BCT_GDIAGONAL2 ) {
2157 setGType( BCT_GDIAGONAL1 );
2159 if ( ( ! horizontal && gType == BCT_GDIAGONAL1 ) ||
2160 ( ! horizontal && gType == BCT_GDIAGONAL2 ) ||
2161 ( ! horizontal && gType == BCT_GHORZ ) ||
2162 ( horizontal && gType == BCT_GVERT ) ) {
2164 gColorTemp = getGColor1();
2165 setGColor1( getGColor2() );
2166 setGColor2( gColorTemp );
2169 gradient =
new KPrGradient( getGColor1(), getGColor2(), gType, getGUnbalanced(), getGXFactor(), getGYFactor() );
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.