~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to karbon/core/vobject.cc

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2002, The Karbon Developers
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
18
*/
 
19
 
 
20
#include <qdom.h>
 
21
 
 
22
#include "vdocument.h"
 
23
#include "vfill.h"
 
24
#include "vobject.h"
 
25
#include "vobject_iface.h"
 
26
#include "vstroke.h"
 
27
 
 
28
 
 
29
VObject::VObject( VObject* parent, VState state ) : m_dcop( 0L )
 
30
{
 
31
        m_stroke = 0L;
 
32
        m_fill = 0L;
 
33
        
 
34
        m_parent = parent;
 
35
        m_state = state;
 
36
 
 
37
        invalidateBoundingBox();
 
38
}
 
39
 
 
40
VObject::VObject( const VObject& obj )
 
41
{
 
42
        m_stroke = 0L;
 
43
        m_fill = 0L;
 
44
        
 
45
        m_parent = obj.m_parent;
 
46
        m_state = obj.m_state;
 
47
 
 
48
        invalidateBoundingBox();
 
49
        m_dcop = 0L;
 
50
 
 
51
        if( obj.document() && !obj.document()->objectName( &obj ).isEmpty() )
 
52
                if( document() )
 
53
                        document()->setObjectName( this, obj.document()->objectName( &obj ) );
 
54
}
 
55
 
 
56
VObject::~VObject()
 
57
{
 
58
        delete( m_stroke );
 
59
        delete( m_fill );
 
60
        delete m_dcop;
 
61
}
 
62
 
 
63
DCOPObject *
 
64
VObject::dcopObject()
 
65
{
 
66
    if ( !m_dcop )
 
67
                m_dcop = new VObjectIface( this );
 
68
 
 
69
    return m_dcop;
 
70
}
 
71
 
 
72
void
 
73
VObject::setStroke( const VStroke& stroke )
 
74
{
 
75
        if( !m_stroke )
 
76
                m_stroke = new VStroke( this );
 
77
 
 
78
        *m_stroke = stroke;
 
79
}
 
80
 
 
81
void
 
82
VObject::setFill( const VFill& fill )
 
83
{
 
84
        if( !m_fill )
 
85
                m_fill = new VFill();
 
86
 
 
87
        *m_fill = fill;
 
88
}
 
89
 
 
90
void
 
91
VObject::save( QDomElement& element ) const
 
92
{
 
93
        if( m_stroke )
 
94
                m_stroke->save( element );
 
95
 
 
96
        if( m_fill )
 
97
                m_fill->save( element );
 
98
 
 
99
        if( document() && !document()->objectName( this ).isEmpty() )
 
100
                element.setAttribute( "ID", QString( document()->objectName( this ) ) );
 
101
}
 
102
 
 
103
void
 
104
VObject::load( const QDomElement& element )
 
105
{
 
106
        if( !m_stroke )
 
107
                m_stroke = new VStroke( this );
 
108
 
 
109
        if( !m_fill )
 
110
                m_fill = new VFill();
 
111
 
 
112
 
 
113
        if( element.tagName() == "STROKE" )
 
114
        {
 
115
                m_stroke->load( element );
 
116
        }
 
117
        else if( element.tagName() == "FILL" )
 
118
        {
 
119
                m_fill->load( element );
 
120
        }
 
121
 
 
122
        if( document() && !element.attribute( "ID" ).isEmpty() )
 
123
                document()->setObjectName( this, element.attribute( "ID" ) );
 
124
}
 
125
 
 
126
VDocument *
 
127
VObject::document() const
 
128
{
 
129
        VObject *obj = (VObject *)this;
 
130
        while( obj->parent() )
 
131
                obj = obj->parent();
 
132
        return dynamic_cast<VDocument *>( obj );
 
133
}
 
134
 
 
135
QString
 
136
VObject::name() const
 
137
{
 
138
        return document() ? document()->objectName( this ) : QString();
 
139
}
 
140
 
 
141
void
 
142
VObject::setName( const QString &s )
 
143
{
 
144
        if( document() )
 
145
                document()->setObjectName( this, s );
 
146
}
 
147