Scribus
Open source desktop publishing at your fingertips
api_document.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 #ifndef API_DOCUMENT_H_
8 #define API_DOCUMENT_H_
9 
10 #include <QObject>
11 #include <QtDebug>
12 #include <QApplication>
13 
14 #include "scripterimpl.h"
15 
16 class DocumentAPI : public QObject
17 {
18  Q_OBJECT
19  Q_PROPERTY(QString name READ getName)
20  Q_PROPERTY(bool available READ available)
21  Q_PROPERTY(QObject* margins READ margins)
22  Q_PROPERTY(bool modified READ modified WRITE setModified)
23  Q_PROPERTY(QObject* activePage READ activePage)
24  Q_PROPERTY(int pageCount READ pageCount)
25  Q_PROPERTY(QObject* activeItem READ activeItem)
26  Q_PROPERTY(QObject* dimensions READ dimensions)
27  Q_PROPERTY(QList<QVariant> items READ items)
28  Q_PROPERTY(QList<QVariant> selection READ selection)
29  Q_PROPERTY(int selectionCount READ selectionCount)
30  Q_PROPERTY(QList<QVariant> colors READ colors)
31  Q_PROPERTY(QList<QVariant> layers READ layers)
32  Q_PROPERTY(QList<QVariant> masterPages READ masterPages)
33  Q_PROPERTY(QList<QVariant> styles READ styles)
34  Q_PROPERTY(QList<QVariant> pages READ pages)
35  Q_PROPERTY(int unit READ unit WRITE setUnit)
36 
37  public:
38  DocumentAPI();
39  virtual ~DocumentAPI();
40 
41  public slots:
42  bool check();
43  bool close();
44  bool save();
45  bool saveAs(QString name);
46  void setInformation(QString author, QString title, QString desc);
47 
48  QObject *newLayer(QString name);
49  void removeLayer(QString name);
50  QObject *getActiveLayer();
51  QString getActiveLayerName();
52  void setActiveLayer(QString name);
53 
54  QObject *newColorCMYK(QString name, int c, int m, int y, int k);
55  QObject *newColorRGB(QString name, int r, int g, int b);
56  QObject *getColor(QString name);
57 
58  QList<QVariant> supportedImageTypes();
59  bool exportAsImages(QString dirName, QString type, double scale, double quality, double dpi, bool overwrite);
60 
61  QObject* Printer();
62 
63  QList<QVariant> masterPages();
64  void createMasterPage(QString name);
65  void deleteMasterPage(QString name);
66  void closeMasterPage(QString name);
67  void editMasterPage(QString name);
68 
69  QList<QVariant> pages();
70  void setActivePage(int pageNumber);
71 
72  void loadStylesFromFile(QString name);
73 
74  void moveSelectionToFront()
75  {
76  ScCore->primaryMainWindow()->doc->bringItemSelectionToFront();
77  }
78 
79  void moveSelectionToBack()
80  {
81  ScCore->primaryMainWindow()->doc->sendItemSelectionToBack();
82  }
83 
84  QObject* selectItem(QString name);
85  void deleteItem(QString name);
86  bool itemExists(QString name);
87  void deselectItems();
88 
89  QString groupItems(QList<QVariant> list);
90  void unGroupItems(QString name);
91  void scaleGroup(double factor, QString name);
92 
93  private:
94  QObject *margins();
95  QString getName();
96  bool available();
97  bool modified();
98  void setModified(bool flag);
99  int unit();
100  void setUnit(int value);
101  QObject *activePage();
102  int pageCount();
103  QList<QVariant> selection();
104  int selectionCount();
105  QObject *activeItem();
106  QObject *dimensions();
107  QList<QVariant> colors();
108  QList<QVariant> styles();
109  QList<QVariant> items();
110  QList<QVariant> layers();
111 };
112 
113 
114 class Margins : public QObject
115 {
116  Q_OBJECT
117  Q_PROPERTY(double top READ top WRITE setTop)
118  Q_PROPERTY(double left READ left WRITE setLeft)
119  Q_PROPERTY(double right READ right WRITE setRight)
120  Q_PROPERTY(double bottom READ bottom WRITE setBottom)
121 
122  public:
123  Margins(QObject *parent);
124  virtual ~Margins()
125  {
126  qDebug() << "Margins deleted";
127  }
128 
129  public slots:
130  void set(double lr, double tpr, double btr, double rr);
131 
132  private:
133  double top();
134  void setTop(double value);
135  double left();
136  void setLeft(double value);
137  double right();
138  void setRight(double value);
139  double bottom();
140  void setBottom(double value);
141 
142 };
143 
144 
145 
146 class Dimensions : public QObject
147 {
148  Q_OBJECT
149  Q_PROPERTY(double width READ width)
150  Q_PROPERTY(double height READ height)
151 
152  public:
153  Dimensions(QObject *parent);
154 
155  virtual ~Dimensions()
156  {
157  qDebug() << "Dimensions deleted";
158  }
159 
160  private:
161  double width();
162  double height();
163  QList<QVariant> items;
164 };
165 
166 
167 #endif /*API_DOCUMENT_H_*/
bool check()
Definition: api_document.cpp:67
void createMasterPage(QString name)
Definition: api_document.cpp:496
QObject activePage
Definition: api_document.h:23
bool saveAs(QString name)
Definition: api_document.cpp:151
bool save()
Definition: api_document.cpp:138
Definition: api_document.h:146
QObject dimensions
Definition: api_document.h:26
ScribusDoc * doc
doc represents your actual document and is created only once. It keeps information such as filename a...
Definition: scribus.h:205
QList< QVariant > items
Definition: api_document.h:27
QList< QVariant > colors
Definition: api_document.h:30
Definition: api_document.h:16
void deleteMasterPage(QString name)
Definition: api_document.cpp:510
QObject activeItem
Definition: api_document.h:25
QObject margins
Definition: api_document.h:21
void set(double lr, double tpr, double btr, double rr)
Definition: api_document.cpp:832
Definition: api_document.h:114
bool available
Definition: api_document.h:20
Definition: objprinter.cpp:38
QList< QVariant > selection
Definition: api_document.h:28
int pageCount
Definition: api_document.h:24
bool close()
Definition: api_document.cpp:124