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

« back to all changes in this revision

Viewing changes to kontour/filter/EPSExport.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: EPSExport.cc,v 1.23 2001/05/21 13:12:48 neundorf 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
 
#ifdef HAVE_CONFIG_H
26
 
#include "config.h"
27
 
#endif
28
 
 
29
 
 
30
 
#include <stdio.h>
31
 
#include <unistd.h>
32
 
#include <stdlib.h>
33
 
#include <koprinter.h>
34
 
#include <qpainter.h>
35
 
#include <qglobal.h>
36
 
#include "GDocument.h"
37
 
#include "GPage.h"
38
 
#include "EPSExport.h"
39
 
 
40
 
EPSExport::EPSExport () {
41
 
}
42
 
 
43
 
EPSExport::~EPSExport () {
44
 
}
45
 
 
46
 
bool EPSExport::setup (GDocument *, const char* ) {
47
 
  return true;
48
 
}
49
 
 
50
 
bool EPSExport::exportToFile (GDocument* doc) {
51
 
  // compute bounding box
52
 
  Rect box = doc->activePage()->boundingBoxForAllObjects ();
53
 
 
54
 
  KPrinter printer;
55
 
  printer.setDocName (doc->fileName ());
56
 
  printer.setCreator ("KIllustrator");
57
 
  printer.setOutputFileName (outputFileName ());
58
 
  printer.setOutputToFile (true);
59
 
  printer.setFullPage (true);
60
 
  switch (doc->activePage()->pageLayout ().format) {
61
 
  case PG_DIN_A4:
62
 
    printer.setPageSize (KPrinter::A4);
63
 
    break;
64
 
  case PG_DIN_A5:
65
 
    printer.setPageSize (KPrinter::B5);
66
 
    break;
67
 
  case PG_US_LETTER:
68
 
    printer.setPageSize (KPrinter::Letter);
69
 
    break;
70
 
  case PG_US_LEGAL:
71
 
    printer.setPageSize (KPrinter::Legal);
72
 
    break;
73
 
  default:
74
 
    break;
75
 
  }
76
 
  printer.setOrientation (doc->activePage()->pageLayout().orientation == PG_PORTRAIT ?
77
 
                          KPrinter::Portrait : KPrinter::Landscape);
78
 
 
79
 
  QPainter paint;
80
 
  paint.begin (&printer);
81
 
#if 1
82
 
  // define the bounding box as clipping region
83
 
  paint.setClipRect (0, 0, static_cast<int>(box.width ()) + 2, static_cast<int>(box.height ()) + 2);
84
 
  // and move the objects to the origin
85
 
  paint.translate (-box.left () + 1, -box.top () + 1);
86
 
  // force update of cliping regions (only for gradient pixmaps)
87
 
#else
88
 
  paint.setClipRect (box.left (), box.top (),
89
 
                     box.width () + 2 + box.left (),
90
 
                     box.height () + 2 + box.top ());
91
 
#endif
92
 
  doc->activePage()->invalidateClipRegions ();
93
 
  doc->activePage()->drawContents (paint,false,false,true);
94
 
  doc->activePage()->invalidateClipRegions ();
95
 
  paint.end ();
96
 
  return true;
97
 
}