~ubuntu-branches/debian/experimental/inkscape/experimental

« back to all changes in this revision

Viewing changes to src/sp-tref-reference.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * The reference corresponding to href of <tref> element.
 
3
 *
 
4
 * Copyright (C) 2007 Gail Banaszkiewicz
 
5
 *
 
6
 * This file was created based on sp-use-reference.cpp
 
7
 *
 
8
 * Released under GNU GPL, read the file 'COPYING' for more information.
 
9
 */
 
10
 
 
11
//#include "enums.h"
 
12
#include "sp-tref-reference.h"
 
13
 
 
14
#include "sp-text.h"
 
15
#include "sp-tref.h"
 
16
#include "sp-tspan.h"
 
17
 
 
18
 
 
19
 
 
20
bool SPTRefReference::_acceptObject(SPObject * const obj) const
 
21
{
 
22
    SPObject *owner = getOwner();
 
23
    if (SP_IS_TREF(owner))
 
24
        return sp_tref_reference_allowed(SP_TREF(getOwner()), obj);
 
25
    else
 
26
        return false;
 
27
}
 
28
 
 
29
 
 
30
void SPTRefReference::updateObserver()
 
31
{
 
32
    SPObject *referred = getObject();
 
33
 
 
34
    if (referred) {
 
35
        if (subtreeObserved) {
 
36
            subtreeObserved->removeObserver(*this);
 
37
            delete subtreeObserved;
 
38
        }
 
39
 
 
40
        subtreeObserved = new Inkscape::XML::Subtree(*SP_OBJECT_REPR(referred));
 
41
        subtreeObserved->addObserver(*this);
 
42
    }
 
43
}
 
44
 
 
45
 
 
46
void SPTRefReference::notifyChildAdded(Inkscape::XML::Node &/*node*/, Inkscape::XML::Node &/*child*/,
 
47
                                       Inkscape::XML::Node */*prev*/)
 
48
{
 
49
    SPObject *owner = getOwner();
 
50
 
 
51
    if (owner && SP_IS_TREF(owner)) {
 
52
        sp_tref_update_text(SP_TREF(owner));
 
53
    }
 
54
}
 
55
 
 
56
 
 
57
void SPTRefReference::notifyChildRemoved(Inkscape::XML::Node &/*node*/, Inkscape::XML::Node &/*child*/,
 
58
                                         Inkscape::XML::Node */*prev*/)
 
59
{
 
60
    SPObject *owner = getOwner();
 
61
 
 
62
    if (owner && SP_IS_TREF(owner)) {
 
63
        sp_tref_update_text(SP_TREF(owner));
 
64
    }
 
65
}
 
66
 
 
67
 
 
68
void SPTRefReference::notifyChildOrderChanged(Inkscape::XML::Node &/*node*/, Inkscape::XML::Node &/*child*/,
 
69
                                              Inkscape::XML::Node */*old_prev*/, Inkscape::XML::Node */*new_prev*/)
 
70
{
 
71
    SPObject *owner = getOwner();
 
72
 
 
73
    if (owner && SP_IS_TREF(owner)) {
 
74
        sp_tref_update_text(SP_TREF(owner));
 
75
    }
 
76
}
 
77
 
 
78
 
 
79
void SPTRefReference::notifyContentChanged(Inkscape::XML::Node &/*node*/,
 
80
                                           Inkscape::Util::ptr_shared<char> /*old_content*/,
 
81
                                           Inkscape::Util::ptr_shared<char> /*new_content*/)
 
82
{
 
83
    SPObject *owner = getOwner();
 
84
 
 
85
    if (owner && SP_IS_TREF(owner)) {
 
86
        sp_tref_update_text(SP_TREF(owner));
 
87
    }
 
88
}
 
89
 
 
90
 
 
91
void SPTRefReference::notifyAttributeChanged(Inkscape::XML::Node &/*node*/, GQuark /*name*/,
 
92
                                             Inkscape::Util::ptr_shared<char> /*old_value*/,
 
93
                                             Inkscape::Util::ptr_shared<char> /*new_value*/)
 
94
{
 
95
    // Do nothing - tref only cares about textual content
 
96
}
 
97
 
 
98
 
 
99
/*
 
100
  Local Variables:
 
101
  mode:c++
 
102
  c-file-style:"stroustrup"
 
103
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
104
  indent-tabs-mode:nil
 
105
  fill-column:99
 
106
  End:
 
107
*/
 
108
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :