kpresenter
KPrFreehandObject.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "KPrFreehandObjectIface.h"
00022 #include "KPrFreehandObject.h"
00023 #include "KPrUtils.h"
00024 #include <KoTextZoomHandler.h>
00025 #include <qpainter.h>
00026 #include <qwmatrix.h>
00027 #include <qdom.h>
00028
00029 #include <kdebug.h>
00030 #include <math.h>
00031 using namespace std;
00032
00033 KPrFreehandObject::KPrFreehandObject()
00034 : KPrPointObject()
00035 {
00036 }
00037
00038 KPrFreehandObject::KPrFreehandObject( const KoPointArray &_points, const KoSize &_size,
00039 const KoPen &_pen, LineEnd _lineBegin, LineEnd _lineEnd )
00040 : KPrPointObject( _pen, _lineBegin, _lineEnd )
00041 {
00042 points = KoPointArray( _points );
00043 ext = _size;
00044 }
00045
00046 KPrFreehandObject &KPrFreehandObject::operator=( const KPrFreehandObject & )
00047 {
00048 return *this;
00049 }
00050
00051 DCOPObject* KPrFreehandObject::dcopObject()
00052 {
00053 if ( !dcop )
00054 dcop = new KPrFreehandObjectIface( this );
00055 return dcop;
00056 }
00057
00058 bool KPrFreehandObject::saveOasisObjectAttributes( KPOasisSaveContext &sc ) const
00059 {
00060
00061 KoRect rect( getRect() );
00062 sc.xmlWriter.addAttribute("svg:viewBox", QString( "0 0 %1 %2" ).arg( int( rect.width() * 100 ) )
00063 .arg( int( rect.height() * 100 ) ) );
00064 unsigned int pointCount = points.count();
00065 unsigned int pos = 0;
00066
00067 QString d;
00068 d += QString( "M%1 %2" ).arg( int( points.at(pos).x() * 100 ) )
00069 .arg( int( points.at(pos).y() * 100 ) );
00070 ++pos;
00071
00072 while ( pos < pointCount )
00073 {
00074 d += QString( "L%1 %2" ).arg( int( points.at( pos ).x() * 100 ) )
00075 .arg( int( points.at( pos ).y() * 100 ) );
00076 ++pos;
00077 }
00078
00079 sc.xmlWriter.addAttribute( "svg:d", d );
00080
00081 return true;
00082 }
00083
00084 const char * KPrFreehandObject::getOasisElementName() const
00085 {
00086 return "draw:path";
00087 }
00088
00089 void KPrFreehandObject::loadOasis( const QDomElement &element, KoOasisContext & context, KPrLoadingInfo* info )
00090 {
00091 kdDebug(33001) << "KPrFreehandObject::loadOasis" << endl;
00092 KPrPointObject::loadOasis( element, context, info );
00093
00094
00095 loadOasisMarker( context );
00096 }
00097
00098 QDomDocumentFragment KPrFreehandObject::save( QDomDocument& doc,double offset )
00099 {
00100 return KPrPointObject::save( doc, offset );
00101 }
00102
00103 double KPrFreehandObject::load( const QDomElement &element )
00104 {
00105 return KPrPointObject::load( element );
00106 }
|