kpresenter

KPrFreehandObject.cpp

00001 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
00002 /* This file is part of the KDE project
00003    Copyright (C) 2001 Toshitaka Fujioka <fujioka@kde.org>
00004    Copyright (C) 2005-2006 Thorsten Zachmann <zachmann@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
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     // the rect for the view box have to be the rect and not the real rect
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     //load marker
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 }
KDE Home | KDE Accessibility Home | Description of Access Keys