1
/* This file is part of the KDE project
2
Copyright (C) 2002, The Karbon Developers
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
22
#include "vdocument.h"
25
#include "vobject_iface.h"
29
VObject::VObject( VObject* parent, VState state ) : m_dcop( 0L )
37
invalidateBoundingBox();
40
VObject::VObject( const VObject& obj )
45
m_parent = obj.m_parent;
46
m_state = obj.m_state;
48
invalidateBoundingBox();
51
if( obj.document() && !obj.document()->objectName( &obj ).isEmpty() )
53
document()->setObjectName( this, obj.document()->objectName( &obj ) );
67
m_dcop = new VObjectIface( this );
73
VObject::setStroke( const VStroke& stroke )
76
m_stroke = new VStroke( this );
82
VObject::setFill( const VFill& fill )
91
VObject::save( QDomElement& element ) const
94
m_stroke->save( element );
97
m_fill->save( element );
99
if( document() && !document()->objectName( this ).isEmpty() )
100
element.setAttribute( "ID", QString( document()->objectName( this ) ) );
104
VObject::load( const QDomElement& element )
107
m_stroke = new VStroke( this );
110
m_fill = new VFill();
113
if( element.tagName() == "STROKE" )
115
m_stroke->load( element );
117
else if( element.tagName() == "FILL" )
119
m_fill->load( element );
122
if( document() && !element.attribute( "ID" ).isEmpty() )
123
document()->setObjectName( this, element.attribute( "ID" ) );
127
VObject::document() const
129
VObject *obj = (VObject *)this;
130
while( obj->parent() )
132
return dynamic_cast<VDocument *>( obj );
136
VObject::name() const
138
return document() ? document()->objectName( this ) : QString();
142
VObject::setName( const QString &s )
145
document()->setObjectName( this, s );