~ubuntu-branches/ubuntu/edgy/koffice/edgy-updates

« back to all changes in this revision

Viewing changes to lib/kofficecore/koClipart.cc

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20040509113300-xi5t1z4yxe7n03x7
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

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 David Faure <faure@kde.org>
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 "koClipart.h"
21
 
#include <qshared.h>
22
 
#include <qpicture.h>
23
 
#include <assert.h>
24
 
 
25
 
class KoClipartPrivate : public QShared
26
 
{
27
 
public:
28
 
    QPicture m_picture;
29
 
    KoClipartKey m_key;
30
 
};
31
 
 
32
 
 
33
 
KoClipart::KoClipart()
34
 
{
35
 
    d = 0;
36
 
}
37
 
 
38
 
KoClipart::KoClipart( const KoClipartKey &key, const QPicture &pic )
39
 
{
40
 
    d = new KoClipartPrivate;
41
 
    d->m_picture.setData( pic.data(), pic.size() ); // make a copy
42
 
    d->m_key = key;
43
 
}
44
 
 
45
 
KoClipart::KoClipart( const KoClipart &other )
46
 
{
47
 
    d = 0;
48
 
    (*this) = other;
49
 
}
50
 
 
51
 
KoClipart::~KoClipart()
52
 
{
53
 
    if ( d && d->deref() )
54
 
        delete d;
55
 
}
56
 
 
57
 
KoClipart &KoClipart::operator=( const KoClipart &_other )
58
 
{
59
 
    KoClipart &other = const_cast<KoClipart &>( _other );
60
 
 
61
 
    if ( other.d )
62
 
        other.d->ref();
63
 
 
64
 
    if ( d && d->deref() )
65
 
        delete d;
66
 
 
67
 
    d = other.d;
68
 
 
69
 
    return *this;
70
 
}
71
 
 
72
 
QPicture * KoClipart::picture() const
73
 
{
74
 
    if ( !d ) return 0L;
75
 
    return &d->m_picture;
76
 
}
77
 
 
78
 
KoClipartKey KoClipart::key() const
79
 
{
80
 
    if ( !d ) return KoClipartKey();
81
 
 
82
 
    return d->m_key;
83
 
}
84
 
 
85
 
bool KoClipart::isNull() const
86
 
{
87
 
    return d == 0 || d->m_picture.isNull();
88
 
}