kpresenter

KPrFreehandObject.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001 Toshitaka Fujioka <fujioka@kde.org>
3 Copyright (C) 2005-2006 Thorsten Zachmann <zachmann@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20#include "KPrFreehandObjectIface.h"
21#include "KPrFreehandObject.h"
22#include "KPrUtils.h"
23#include <KoTextZoomHandler.h>
24#include <tqpainter.h>
25#include <tqwmatrix.h>
26#include <tqdom.h>
27
28#include <kdebug.h>
29#include <math.h>
30using namespace std;
31
32KPrFreehandObject::KPrFreehandObject()
33 : KPrPointObject()
34{
35}
36
37KPrFreehandObject::KPrFreehandObject( const KoPointArray &_points, const KoSize &_size,
38 const KoPen &_pen, LineEnd _lineBegin, LineEnd _lineEnd )
39 : KPrPointObject( _pen, _lineBegin, _lineEnd )
40{
41 points = KoPointArray( _points );
42 ext = _size;
43}
44
45KPrFreehandObject &KPrFreehandObject::operator=( const KPrFreehandObject & )
46{
47 return *this;
48}
49
50DCOPObject* KPrFreehandObject::dcopObject()
51{
52 if ( !dcop )
53 dcop = new KPrFreehandObjectIface( this );
54 return dcop;
55}
56
57bool KPrFreehandObject::saveOasisObjectAttributes( KPOasisSaveContext &sc ) const
58{
59 // the rect for the view box have to be the rect and not the real rect
60 KoRect rect( getRect() );
61 sc.xmlWriter.addAttribute("svg:viewBox", TQString( "0 0 %1 %2" ).arg( int( rect.width() * 100 ) )
62 .arg( int( rect.height() * 100 ) ) );
63 unsigned int pointCount = points.count();
64 unsigned int pos = 0;
65
66 TQString d;
67 d += TQString( "M%1 %2" ).arg( int( points.at(pos).x() * 100 ) )
68 .arg( int( points.at(pos).y() * 100 ) );
69 ++pos;
70
71 while ( pos < pointCount )
72 {
73 d += TQString( "L%1 %2" ).arg( int( points.at( pos ).x() * 100 ) )
74 .arg( int( points.at( pos ).y() * 100 ) );
75 ++pos;
76 }
77
78 sc.xmlWriter.addAttribute( "svg:d", d );
79
80 return true;
81}
82
83const char * KPrFreehandObject::getOasisElementName() const
84{
85 return "draw:path";
86}
87
88void KPrFreehandObject::loadOasis( const TQDomElement &element, KoOasisContext & context, KPrLoadingInfo* info )
89{
90 kdDebug(33001) << "KPrFreehandObject::loadOasis" << endl;
91 KPrPointObject::loadOasis( element, context, info );
92
93 //load marker
94 loadOasisMarker( context );
95}
96
97TQDomDocumentFragment KPrFreehandObject::save( TQDomDocument& doc,double offset )
98{
99 return KPrPointObject::save( doc, offset );
100}
101
102double KPrFreehandObject::load( const TQDomElement &element )
103{
104 return KPrPointObject::load( element );
105}
Temporary information used only during loading.