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

« back to all changes in this revision

Viewing changes to kontour/UngroupCmd.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
 
/* -*- C++ -*-
2
 
 
3
 
  $Id: UngroupCmd.cc,v 1.19 2001/03/12 15:27:35 rm Exp $
4
 
 
5
 
  This file is part of KIllustrator.
6
 
  Copyright (C) 1998 Kai-Uwe Sattler (kus@iti.cs.uni-magdeburg.de)
7
 
 
8
 
  This program is free software; you can redistribute it and/or modify
9
 
  it under the terms of the GNU Library General Public License as
10
 
  published by
11
 
  the Free Software Foundation; either version 2 of the License, or
12
 
  (at your option) any later version.
13
 
 
14
 
  This program is distributed in the hope that it will be useful,
15
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
  GNU General Public License for more details.
18
 
 
19
 
  You should have received a copy of the GNU Library General Public License
20
 
  along with this program; if not, write to the Free Software
21
 
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
 
 
23
 
*/
24
 
 
25
 
#include <UngroupCmd.h>
26
 
 
27
 
#include <klocale.h>
28
 
#include <GDocument.h>
29
 
#include <GGroup.h>
30
 
#include "GPage.h"
31
 
 
32
 
UngroupCmd::UngroupCmd (GDocument* doc) : Command(i18n("Ungroup")) {
33
 
 
34
 
    groups.setAutoDelete(true);
35
 
    document = doc;
36
 
    for(QListIterator<GObject> it(doc->activePage()->getSelection()); it.current(); ++it) {
37
 
        GObject* o = *it;
38
 
        if (o->isA ("GGroup")) {
39
 
            GGroup* gobj = (GGroup *) o;
40
 
            gobj->ref ();
41
 
            GPair *p=new GPair;
42
 
            p->group=gobj;
43
 
            groups.append(p);
44
 
        }
45
 
    }
46
 
}
47
 
 
48
 
UngroupCmd::~UngroupCmd () {
49
 
    for (GPair *p=groups.first(); p!=0L; p=groups.next()) {
50
 
        p->group->unref ();
51
 
        for (GObject *o=p->members.first(); o!=0L; o=p->members.next())
52
 
            o->unref ();
53
 
    }
54
 
}
55
 
 
56
 
void UngroupCmd::execute () {
57
 
    for (GPair *p=groups.first(); p!=0L; p=groups.next()) {
58
 
        GGroup *group = p->group;
59
 
        int pos = document->activePage()->findIndexOfObject (group);
60
 
        if (pos != -1) {
61
 
            document->setAutoUpdate (false);
62
 
            // extract the members of the group
63
 
            QList <GObject> members = group->getMembers ();
64
 
            GObject *mo=members.first();
65
 
            for (int offs = 0; mo!=0L; mo=members.next(), offs++) {
66
 
                // transform it according to the group transformation matrix
67
 
                mo->transform (group->matrix (), true);
68
 
 
69
 
                // and insert it into the object list at the former position
70
 
                // of the group object
71
 
                document->activePage()->insertObjectAtIndex(mo, pos + offs);
72
 
                document->activePage()->selectObject (mo);
73
 
                p->members.append(mo);
74
 
                mo->ref ();
75
 
            }
76
 
            // remove the group object
77
 
            document->activePage()->deleteObject (group);
78
 
            document->setAutoUpdate (true);
79
 
        }
80
 
    }
81
 
}
82
 
 
83
 
void UngroupCmd::unexecute () {
84
 
  document->setAutoUpdate (false);
85
 
  document->activePage()->unselectAllObjects ();
86
 
  for (GPair *p=groups.first(); p!=0L; p=groups.next()) {
87
 
    QWMatrix m = p->group->matrix ().invert ();
88
 
 
89
 
    for (GObject *o=p->members.first(); o!=0L; o=p->members.next()) {
90
 
      o->transform (m, true);
91
 
      p->group->addObject (o);
92
 
      document->activePage()->deleteObject (o);
93
 
    }
94
 
    document->activePage()->insertObject (p->group);
95
 
    document->activePage()->selectObject (p->group);
96
 
  }
97
 
  document->setAutoUpdate (true);
98
 
}
99