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.
9
#include "undomanager.h"
10
#include "selection.h"
11
#include "scribusview.h"
13
ItemAPI::ItemAPI(PageItem* it) : QObject(COLLECTOR)
15
qDebug() << "ItemAPI loaded";
16
setObjectName("ItemAPI");
20
QString ItemAPI::name()
22
return item->itemName();
25
void ItemAPI::setName(QString name)
27
item->setItemName(name);
31
QString ItemAPI::fillColor()
33
return item->fillColor();
36
void ItemAPI::setFillColor(QString color)
38
item->setFillColor(color);
41
QString ItemAPI::lineColor()
43
return item->lineColor();
46
void ItemAPI::setLineColor(QString color)
48
item->setLineColor(color);
52
double ItemAPI::fillShade()
54
return item->fillShade();
57
void ItemAPI::setFillShade(double value)
59
item->setFillShade(value);
62
double ItemAPI::lineShade()
64
return item->lineShade();
67
void ItemAPI::setLineShade(double value)
69
item->setLineShade(value);
72
double ItemAPI::fillTransparency()
74
return item->fillTransparency();
77
void ItemAPI::setFillTransparency(double value)
79
item->setFillTransparency(value);
83
double ItemAPI::lineTransparency()
85
return item->lineTransparency();
88
void ItemAPI::setLineTransparency(double value)
90
item->setLineTransparency(value);
93
bool ItemAPI::locked()
95
return item->locked();
98
void ItemAPI::setLocked(bool value)
100
item->setLocked(value);
103
bool ItemAPI::sizeLocked()
105
return item->sizeLocked();
108
void ItemAPI::setSizeLocked(bool value)
110
item->setSizeLocked(value);
113
bool ItemAPI::imageFlippedV()
115
return item->imageFlippedV();
118
void ItemAPI::setImageFlippedV(bool value)
120
item->setImageFlippedV(value);
123
bool ItemAPI::imageFlippedH()
125
return item->imageFlippedH();
128
void ItemAPI::setImageFlippedH(bool value)
130
item->setImageFlippedH(value);
133
double ItemAPI::lineWidth()
135
return item->lineWidth();
138
void ItemAPI::setLineWidth(double value)
140
item->setLineWidth(value);
143
QString ItemAPI::customLineStyle()
145
return item->customLineStyle();
148
void ItemAPI::setCustomLineStyle(QString name)
150
item->setCustomLineStyle(name);
153
int ItemAPI::startArrowIndex()
155
return item->startArrowIndex();
158
void ItemAPI::setStartArrowIndex(int value)
160
item->setStartArrowIndex(value);
163
int ItemAPI::endArrowIndex()
165
return item->endArrowIndex();
168
void ItemAPI::setEndArrowIndex(int value)
170
item->setEndArrowIndex(value);
173
bool ItemAPI::printEnabled()
175
return item->printEnabled();
178
void ItemAPI::setPrintEnabled(bool value)
180
item->setPrintEnabled(value);
183
double ItemAPI::xPos()
188
void ItemAPI::setXPos(double value)
190
item->setXPos(value);
193
double ItemAPI::yPos()
198
void ItemAPI::setYPos(double value)
200
item->setYPos(value);
203
double ItemAPI::width()
205
return item->width();
208
void ItemAPI::setWidth(double value)
210
item->setWidth(value);
213
double ItemAPI::height()
215
return item->height();
218
void ItemAPI::setHeight(double value)
220
item->setHeight(value);
223
double ItemAPI::rotation()
225
return item->rotation();
228
void ItemAPI::setRotation(double rotation)
230
item->setRotation(rotation);
233
bool ItemAPI::reversed()
235
return false; // item->reversed(); FIXME
238
void ItemAPI::setReversed(bool value)
240
// item->setReversed(value); FIXME
243
double ItemAPI::cornerRadius()
245
return item->cornerRadius();
248
void ItemAPI::setCornerRadius(double value)
250
item->setCornerRadius(value);
253
double ItemAPI::columnGap()
255
return item->columnGap();
258
void ItemAPI::setColumnGap(double value)
260
if (!checkHaveDocument())
261
RAISE("No document open");
264
RAISE("Column gap out of bounds, must be positive.");
266
item->ColGap = ValueToPoint(value);
269
int ItemAPI::columns()
271
return item->columns();
274
void ItemAPI::setColumns(int value)
276
if (!checkHaveDocument())
277
RAISE("No document open");
280
RAISE("Column count out of bounds, must be > 1.");
290
void ItemAPI::move(double dx, double dy)
292
if (!checkHaveDocument())
296
// Grab the old selection - but use it only where is there any
297
Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection);
298
bool hadOrigSelection = (tempSelection.count() != 0);
300
ScCore->primaryMainWindow()->doc->m_Selection->clear();
301
// Clear the selection
302
ScCore->primaryMainWindow()->view->Deselect();
303
// Select the item, which will also select its group if
305
ScCore->primaryMainWindow()->view->SelectItem(item);
306
// Move the item, or items
307
if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
309
ScCore->primaryMainWindow()->view->startGroupTransaction(Um::Move, "", Um::IMove);
310
ScCore->primaryMainWindow()->doc->moveGroup(ValueToPoint(dx), ValueToPoint(dy));
311
ScCore->primaryMainWindow()->view->endGroupTransaction();
315
ScCore->primaryMainWindow()->doc->moveItem(ValueToPoint(dx), ValueToPoint(dy), item);
317
// Now restore the selection.
318
ScCore->primaryMainWindow()->view->Deselect();
319
if (hadOrigSelection)
320
*ScCore->primaryMainWindow()->doc->m_Selection=tempSelection;
324
void ItemAPI::moveAbs(double x, double y)
326
if (!checkHaveDocument())
330
// Grab the old selection - but use it only where is there any
331
Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection);
332
bool hadOrigSelection = (tempSelection.count() != 0);
334
// Clear the selection
335
ScCore->primaryMainWindow()->view->Deselect();
336
// Select the item, which will also select its group if
338
ScCore->primaryMainWindow()->view->SelectItem(item);
339
// Move the item, or items
340
if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
342
ScCore->primaryMainWindow()->view->startGroupTransaction(Um::Move, "", Um::IMove);
344
ScCore->primaryMainWindow()->doc->m_Selection->getGroupRect(&x2, &y2, &w, &h);
345
ScCore->primaryMainWindow()->doc->moveGroup(pageUnitXToDocX(x) - x2, pageUnitYToDocY(y) - y2);
346
ScCore->primaryMainWindow()->view->endGroupTransaction();
349
ScCore->primaryMainWindow()->doc->moveItem(pageUnitXToDocX(x) - item->xPos(), pageUnitYToDocY(y) - item->yPos(), item);
350
// Now restore the selection.
351
ScCore->primaryMainWindow()->view->Deselect();
352
if (hadOrigSelection)
353
*ScCore->primaryMainWindow()->doc->m_Selection=tempSelection;
356
void ItemAPI::resize(double width, double height)
358
if (!checkHaveDocument())
362
ScCore->primaryMainWindow()->doc->sizeItem(ValueToPoint(width), ValueToPoint(height), item);
365
void ItemAPI::rotate(double rot)
367
if (!checkHaveDocument())
371
ScCore->primaryMainWindow()->doc->rotateItem(item->rotation() - rot, item);
374
void ItemAPI::rotateAbs(double rot)
376
if (!checkHaveDocument())
380
ScCore->primaryMainWindow()->doc->rotateItem(rot * -1.0, item);
386
qDebug() << "ItemAPI deleted";
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.
9
#include "undomanager.h"
10
#include "selection.h"
11
#include "scribusview.h"
13
ItemAPI::ItemAPI(PageItem* it) : QObject(COLLECTOR)
15
qDebug() << "ItemAPI loaded";
16
setObjectName("ItemAPI");
20
QString ItemAPI::name()
22
return item->itemName();
25
void ItemAPI::setName(QString name)
27
item->setItemName(name);
31
QString ItemAPI::fillColor()
33
return item->fillColor();
36
void ItemAPI::setFillColor(QString color)
38
item->setFillColor(color);
41
QString ItemAPI::lineColor()
43
return item->lineColor();
46
void ItemAPI::setLineColor(QString color)
48
item->setLineColor(color);
52
double ItemAPI::fillShade()
54
return item->fillShade();
57
void ItemAPI::setFillShade(double value)
59
item->setFillShade(value);
62
double ItemAPI::lineShade()
64
return item->lineShade();
67
void ItemAPI::setLineShade(double value)
69
item->setLineShade(value);
72
double ItemAPI::fillTransparency()
74
return item->fillTransparency();
77
void ItemAPI::setFillTransparency(double value)
79
item->setFillTransparency(value);
83
double ItemAPI::lineTransparency()
85
return item->lineTransparency();
88
void ItemAPI::setLineTransparency(double value)
90
item->setLineTransparency(value);
93
bool ItemAPI::locked()
95
return item->locked();
98
void ItemAPI::setLocked(bool value)
100
item->setLocked(value);
103
bool ItemAPI::sizeLocked()
105
return item->sizeLocked();
108
void ItemAPI::setSizeLocked(bool value)
110
item->setSizeLocked(value);
113
bool ItemAPI::imageFlippedV()
115
return item->imageFlippedV();
118
void ItemAPI::setImageFlippedV(bool value)
120
item->setImageFlippedV(value);
123
bool ItemAPI::imageFlippedH()
125
return item->imageFlippedH();
128
void ItemAPI::setImageFlippedH(bool value)
130
item->setImageFlippedH(value);
133
double ItemAPI::lineWidth()
135
return item->lineWidth();
138
void ItemAPI::setLineWidth(double value)
140
item->setLineWidth(value);
143
QString ItemAPI::customLineStyle()
145
return item->customLineStyle();
148
void ItemAPI::setCustomLineStyle(QString name)
150
item->setCustomLineStyle(name);
153
int ItemAPI::startArrowIndex()
155
return item->startArrowIndex();
158
void ItemAPI::setStartArrowIndex(int value)
160
item->setStartArrowIndex(value);
163
int ItemAPI::endArrowIndex()
165
return item->endArrowIndex();
168
void ItemAPI::setEndArrowIndex(int value)
170
item->setEndArrowIndex(value);
173
bool ItemAPI::printEnabled()
175
return item->printEnabled();
178
void ItemAPI::setPrintEnabled(bool value)
180
item->setPrintEnabled(value);
183
double ItemAPI::xPos()
188
void ItemAPI::setXPos(double value)
190
item->setXPos(value);
193
double ItemAPI::yPos()
198
void ItemAPI::setYPos(double value)
200
item->setYPos(value);
203
double ItemAPI::width()
205
return item->width();
208
void ItemAPI::setWidth(double value)
210
item->setWidth(value);
213
double ItemAPI::height()
215
return item->height();
218
void ItemAPI::setHeight(double value)
220
item->setHeight(value);
223
double ItemAPI::rotation()
225
return item->rotation();
228
void ItemAPI::setRotation(double rotation)
230
item->setRotation(rotation);
233
bool ItemAPI::reversed()
235
return false; // item->reversed(); FIXME
238
void ItemAPI::setReversed(bool value)
240
// item->setReversed(value); FIXME
243
double ItemAPI::cornerRadius()
245
return item->cornerRadius();
248
void ItemAPI::setCornerRadius(double value)
250
item->setCornerRadius(value);
253
double ItemAPI::columnGap()
255
return item->columnGap();
258
void ItemAPI::setColumnGap(double value)
260
if (!checkHaveDocument())
261
RAISE("No document open");
264
RAISE("Column gap out of bounds, must be positive.");
266
item->ColGap = ValueToPoint(value);
269
int ItemAPI::columns()
271
return item->columns();
274
void ItemAPI::setColumns(int value)
276
if (!checkHaveDocument())
277
RAISE("No document open");
280
RAISE("Column count out of bounds, must be > 1.");
285
int ItemAPI::verticalAlignment()
287
return item->verticalAlignment();
290
void ItemAPI::setVerticalAlignment(int value)
292
if (!checkHaveDocument())
293
RAISE("No document open");
294
item->setVerticalAlignment(value);
302
void ItemAPI::move(double dx, double dy)
304
if (!checkHaveDocument())
308
// Grab the old selection - but use it only where is there any
309
Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection);
310
bool hadOrigSelection = (tempSelection.count() != 0);
312
ScCore->primaryMainWindow()->doc->m_Selection->clear();
313
// Clear the selection
314
ScCore->primaryMainWindow()->view->Deselect();
315
// Select the item, which will also select its group if
317
ScCore->primaryMainWindow()->view->SelectItem(item);
318
// Move the item, or items
319
if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
321
ScCore->primaryMainWindow()->view->startGroupTransaction(Um::Move, "", Um::IMove);
322
ScCore->primaryMainWindow()->doc->moveGroup(ValueToPoint(dx), ValueToPoint(dy));
323
ScCore->primaryMainWindow()->view->endGroupTransaction();
327
ScCore->primaryMainWindow()->doc->moveItem(ValueToPoint(dx), ValueToPoint(dy), item);
329
// Now restore the selection.
330
ScCore->primaryMainWindow()->view->Deselect();
331
if (hadOrigSelection)
332
*ScCore->primaryMainWindow()->doc->m_Selection=tempSelection;
336
void ItemAPI::moveAbs(double x, double y)
338
if (!checkHaveDocument())
342
// Grab the old selection - but use it only where is there any
343
Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection);
344
bool hadOrigSelection = (tempSelection.count() != 0);
346
// Clear the selection
347
ScCore->primaryMainWindow()->view->Deselect();
348
// Select the item, which will also select its group if
350
ScCore->primaryMainWindow()->view->SelectItem(item);
351
// Move the item, or items
352
if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
354
ScCore->primaryMainWindow()->view->startGroupTransaction(Um::Move, "", Um::IMove);
356
ScCore->primaryMainWindow()->doc->m_Selection->getGroupRect(&x2, &y2, &w, &h);
357
ScCore->primaryMainWindow()->doc->moveGroup(pageUnitXToDocX(x) - x2, pageUnitYToDocY(y) - y2);
358
ScCore->primaryMainWindow()->view->endGroupTransaction();
361
ScCore->primaryMainWindow()->doc->moveItem(pageUnitXToDocX(x) - item->xPos(), pageUnitYToDocY(y) - item->yPos(), item);
362
// Now restore the selection.
363
ScCore->primaryMainWindow()->view->Deselect();
364
if (hadOrigSelection)
365
*ScCore->primaryMainWindow()->doc->m_Selection=tempSelection;
368
void ItemAPI::resize(double width, double height)
370
if (!checkHaveDocument())
374
ScCore->primaryMainWindow()->doc->sizeItem(ValueToPoint(width), ValueToPoint(height), item);
377
void ItemAPI::rotate(double rot)
379
if (!checkHaveDocument())
383
ScCore->primaryMainWindow()->doc->rotateItem(item->rotation() - rot, item);
386
void ItemAPI::rotateAbs(double rot)
388
if (!checkHaveDocument())
392
ScCore->primaryMainWindow()->doc->rotateItem(rot * -1.0, item);
398
qDebug() << "ItemAPI deleted";