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

« back to all changes in this revision

Viewing changes to kontour/DuplicateCmd.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: DuplicateCmd.cc,v 1.14 2001/07/18 18:45:56 buis Exp $
4
 
 
5
 
  This file is part of KIllustrator.
6
 
  Copyright (C) 1998-99 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 <DuplicateCmd.h>
26
 
 
27
 
#include <klocale.h>
28
 
 
29
 
#include <GDocument.h>
30
 
#include "GPage.h"
31
 
#include <GObject.h>
32
 
#include <PStateManager.h>
33
 
 
34
 
bool DuplicateCmd::repeatCmd = false;
35
 
float DuplicateCmd::repOffX = 0.0;
36
 
float DuplicateCmd::repOffY = 0.0;
37
 
 
38
 
DuplicateCmd::DuplicateCmd (GDocument* doc)
39
 
  : Command(i18n("Duplicate"))
40
 
{
41
 
  document = doc;
42
 
  for (QListIterator<GObject> it(doc->activePage()->getSelection()); it.current(); ++it)
43
 
  {
44
 
    GObject* o = *it;
45
 
    if(o->isA("GPart"))
46
 
      continue;
47
 
    o->ref ();
48
 
    objects.append(o);
49
 
  }
50
 
}
51
 
 
52
 
DuplicateCmd::~DuplicateCmd () {
53
 
    GObject *o;
54
 
    for (o=objects.first(); o!=0L; o=objects.next())
55
 
        o->unref ();
56
 
    for (o=new_objects.first(); o!=0L; o=new_objects.next())
57
 
        o->unref ();
58
 
}
59
 
 
60
 
void DuplicateCmd::execute () {
61
 
  float xoff;
62
 
  float yoff;
63
 
 
64
 
  if (repeatCmd) {
65
 
    xoff = repOffX;
66
 
    yoff = repOffY;
67
 
  }
68
 
  else {
69
 
    xoff = PStateManager::instance ()->duplicateXOffset ();
70
 
    yoff = PStateManager::instance ()->duplicateYOffset ();
71
 
  }
72
 
  QWMatrix m;
73
 
  m.translate (xoff, yoff);
74
 
 
75
 
  document->activePage()->unselectAllObjects ();
76
 
  for (GObject *i=objects.first(); i!=0L;
77
 
       i=objects.next()) {
78
 
    GObject *o = i->copy ();
79
 
    o->ref ();
80
 
    o->transform (m, true);
81
 
    document->activePage()->insertObject (o);
82
 
    document->activePage()->selectObject (o);
83
 
    new_objects.append(o);
84
 
  }
85
 
}
86
 
 
87
 
void DuplicateCmd::unexecute () {
88
 
    document->activePage()->unselectAllObjects ();
89
 
    GObject *o;
90
 
    for (o=new_objects.first(); o!=0L; o=new_objects.next())
91
 
        document->activePage()->deleteObject(o);
92
 
    for (o = objects.first(); o!=0L; o=objects.next())
93
 
        document->activePage()->selectObject(o);
94
 
}
95
 
 
96
 
void DuplicateCmd::resetRepetition () {
97
 
    repeatCmd = false;
98
 
}
99
 
 
100
 
void DuplicateCmd::setRepetitionOffset (float dx, float dy) {
101
 
  repOffX = dx + PStateManager::instance ()->duplicateXOffset ();
102
 
  repOffY = dy + PStateManager::instance ()->duplicateYOffset ();
103
 
  repeatCmd = true;
104
 
}
105