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

« back to all changes in this revision

Viewing changes to karbon/core/vlayer.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) 2001, 2002, 2003 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 <klocale.h>
 
23
#include <koRect.h>
 
24
 
 
25
#include "vcomposite.h"
 
26
#include "vdocument.h"
 
27
#include "vgroup.h"
 
28
#include "vlayer.h"
 
29
#include "vobject.h"
 
30
#include "vtext.h"
 
31
#include "vvisitor.h"
 
32
#include "vlayer_iface.h"
 
33
#include <kdebug.h>
 
34
#include "vclipgroup.h"
 
35
#include "vfill.h"
 
36
#include "vstroke.h"
 
37
 
 
38
VLayer::VLayer( VObject* parent, VState state )
 
39
        : VGroup( parent, state )
 
40
{
 
41
        setName( "Layer" );
 
42
        // HACK : vlayer just shouldn't have fill/stroke at all
 
43
        delete m_fill;
 
44
        m_fill = 0L;
 
45
        delete m_stroke;
 
46
        m_stroke = 0L;
 
47
}
 
48
 
 
49
VLayer::VLayer( const VLayer& layer )
 
50
        : VGroup( layer )
 
51
{
 
52
}
 
53
 
 
54
VLayer::~VLayer()
 
55
{
 
56
}
 
57
 
 
58
DCOPObject* VLayer::dcopObject()
 
59
{
 
60
    if ( !m_dcop )
 
61
                m_dcop = new VLayerIface( this );
 
62
 
 
63
    return m_dcop;
 
64
}
 
65
 
 
66
void
 
67
VLayer::draw( VPainter* painter, const KoRect* rect ) const
 
68
{
 
69
        if(
 
70
                state() == deleted ||
 
71
                state() == hidden ||
 
72
                state() == hidden_locked )
 
73
        {
 
74
                return;
 
75
        }
 
76
 
 
77
        VObjectListIterator itr = m_objects;
 
78
 
 
79
        for ( ; itr.current(); ++itr )
 
80
                itr.current()->draw( painter, rect );
 
81
}
 
82
 
 
83
void
 
84
VLayer::bringToFront( const VObject& object )
 
85
{
 
86
        if( m_objects.getLast() == &object ) return;
 
87
 
 
88
        m_objects.remove( &object );
 
89
 
 
90
        m_objects.append( &object );
 
91
}
 
92
 
 
93
void
 
94
VLayer::upwards( const VObject& object )
 
95
{
 
96
        if( m_objects.getLast() == &object ) return;
 
97
 
 
98
        m_objects.remove( &object );
 
99
 
 
100
        if( m_objects.current() != m_objects.getLast() )
 
101
        {
 
102
                m_objects.next();
 
103
                m_objects.insert( m_objects.at(), &object );
 
104
        }
 
105
        else
 
106
                m_objects.append( &object );
 
107
}
 
108
 
 
109
void
 
110
VLayer::downwards( const VObject& object )
 
111
{
 
112
        if( m_objects.getFirst() == &object ) return;
 
113
 
 
114
        int index = m_objects.find( &object );
 
115
        bool bLast = m_objects.getLast() == &object;
 
116
        m_objects.remove( index );
 
117
 
 
118
        if( !bLast ) m_objects.prev();
 
119
 
 
120
        m_objects.insert( m_objects.at(), &object );
 
121
}
 
122
 
 
123
void
 
124
VLayer::sendToBack( const VObject& object )
 
125
{
 
126
        if( m_objects.getFirst() == &object ) return;
 
127
 
 
128
        m_objects.remove( &object );
 
129
 
 
130
        m_objects.prepend( &object );
 
131
}
 
132
 
 
133
void
 
134
VLayer::save( QDomElement& element ) const
 
135
{
 
136
        QDomElement me = element.ownerDocument().createElement( "LAYER" );
 
137
        element.appendChild( me );
 
138
 
 
139
        if( state() == normal || state() == normal_locked || state() == VObject::selected )
 
140
                me.setAttribute( "visible", 1 );
 
141
 
 
142
        // save objects:
 
143
        VObjectListIterator itr = m_objects;
 
144
        for ( ; itr.current(); ++itr )
 
145
                itr.current()->save( me );
 
146
 
 
147
        VObject::save( me );
 
148
}
 
149
 
 
150
void
 
151
VLayer::load( const QDomElement& element )
 
152
{
 
153
        setState( element.attribute( "visible" ) == 0 ? hidden : normal );
 
154
        VGroup::load( element );
 
155
}
 
156
 
 
157
 
 
158
VLayer*
 
159
VLayer::clone() const
 
160
{
 
161
        return new VLayer( *this );
 
162
}
 
163
 
 
164
void
 
165
VLayer::accept( VVisitor& visitor )
 
166
{
 
167
        visitor.visitVLayer( *this );
 
168
}
 
169