19,28 → 19,30 |
|
|
template<typename T> |
class ApplyCharstyleHelper { |
PageItem* item; |
T value; |
class ApplyCharstyleHelper |
{ |
PageItem* m_item; |
T m_value; |
|
public: |
ApplyCharstyleHelper(PageItem* i, T v) : item(i), value(v) {} |
ApplyCharstyleHelper(PageItem* item, T v) : m_item(item), m_value(v) {} |
|
void apply(void (CharStyle::*f)(T), int p, int len) |
{ |
CharStyle cs; |
(cs.*f)(value); |
if (item->HasSel) |
(cs.*f)(m_value); |
if (m_item->HasSel) |
{ |
int max = qMax(p+len, item->itemText.length()); |
for (int b = p; b < max; b++) |
int max = qMax(p + len, m_item->itemText.length()); |
for (int i = p; i < max; i++) |
{ |
if (item->itemText.selected(b)) |
item->itemText.applyCharStyle(b, 1, cs); |
if (m_item->itemText.selected(i)) |
m_item->itemText.applyCharStyle(i, 1, cs); |
} |
} |
else |
{ |
item->itemText.applyCharStyle(p, len, cs); |
m_item->itemText.applyCharStyle(p, len, cs); |
} |
} |
|
53,22 → 55,22 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
if (it == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!(it->isTextFrame()) && !(it->isPathText())) |
if (!(item->isTextFrame()) && !(item->isPathText())) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get font size of non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
if (it->HasSel) |
if (item->HasSel) |
{ |
for (int b = 0; b < it->itemText.length(); b++) |
if (it->itemText.selected(b)) |
return PyFloat_FromDouble(static_cast<double>(it->itemText.charStyle(b).fontSize() / 10.0)); |
for (int b = 0; b < item->itemText.length(); b++) |
if (item->itemText.selected(b)) |
return PyFloat_FromDouble(static_cast<double>(item->itemText.charStyle(b).fontSize() / 10.0)); |
return nullptr; |
} |
return PyFloat_FromDouble(static_cast<double>(it->currentCharStyle().fontSize() / 10.0)); |
return PyFloat_FromDouble(static_cast<double>(item->currentCharStyle().fontSize() / 10.0)); |
} |
|
PyObject *scribus_getfont(PyObject* /* self */, PyObject* args) |
78,22 → 80,22 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
if (it == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!(it->isTextFrame()) && !(it->isPathText())) |
if (!(item->isTextFrame()) && !(item->isPathText())) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get font of non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
if (it->HasSel) |
if (item->HasSel) |
{ |
for (int b = 0; b < it->itemText.length(); b++) |
if (it->itemText.selected(b)) |
return PyString_FromString(it->itemText.charStyle(b).font().scName().toUtf8()); |
for (int b = 0; b < item->itemText.length(); b++) |
if (item->itemText.selected(b)) |
return PyString_FromString(item->itemText.charStyle(b).font().scName().toUtf8()); |
return nullptr; |
} |
return PyString_FromString(it->currentCharStyle().font().scName().toUtf8()); |
return PyString_FromString(item->currentCharStyle().font().scName().toUtf8()); |
} |
|
PyObject *scribus_gettextsize(PyObject* /* self */, PyObject* args) |
103,15 → 105,15 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!(i->isTextFrame()) && !(i->isPathText())) |
if (!(item->isTextFrame()) && !(item->isPathText())) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get text size of non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
return PyInt_FromLong(static_cast<long>(i->itemText.length())); |
return PyInt_FromLong(static_cast<long>(item->itemText.length())); |
} |
|
PyObject *scribus_gettextlines(PyObject* /* self */, PyObject* args) |
121,15 → 123,15 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!(i->isTextFrame()) && !(i->isPathText())) |
if (!(item->isTextFrame()) && !(item->isPathText())) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get number of lines of non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
return PyInt_FromLong(static_cast<long>(i->textLayout.lines())); |
return PyInt_FromLong(static_cast<long>(item->textLayout.lines())); |
} |
|
PyObject *scribus_gettextverticalalignment(PyObject* /* self */, PyObject* args) |
139,15 → 141,15 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get vertical alignment of non-text frame.", "python error").toLocal8Bit().constData()); |
return nullptr; |
} |
return PyInt_FromLong(static_cast<long>(i->verticalAlignment())); |
return PyInt_FromLong(static_cast<long>(item->verticalAlignment())); |
} |
|
PyObject *scribus_getcolumns(PyObject* /* self */, PyObject* args) |
157,15 → 159,15 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get column count of non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
return PyInt_FromLong(static_cast<long>(i->Cols)); |
return PyInt_FromLong(static_cast<long>(item->Cols)); |
} |
|
PyObject *scribus_getcolumngap(PyObject* /* self */, PyObject* args) |
175,15 → 177,15 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get column gap of non-text frame.", "python error").toLocal8Bit().constData()); |
return nullptr; |
} |
return PyFloat_FromDouble(PointToValue(static_cast<double>(i->ColGap))); |
return PyFloat_FromDouble(PointToValue(static_cast<double>(item->ColGap))); |
} |
|
PyObject *scribus_getfontfeatures(PyObject* /* self */, PyObject* args) |
193,22 → 195,22 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
if (it == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!(it->isTextFrame()) && !(it->isPathText())) |
if (!(item->isTextFrame()) && !(item->isPathText())) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get fontfeatures of non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
if (it->HasSel) |
if (item->HasSel) |
{ |
for (int b = 0; b < it->itemText.length(); b++) |
if (it->itemText.selected(b)) |
return PyString_FromString(it->itemText.charStyle(b).fontFeatures().toUtf8()); |
for (int b = 0; b < item->itemText.length(); b++) |
if (item->itemText.selected(b)) |
return PyString_FromString(item->itemText.charStyle(b).fontFeatures().toUtf8()); |
return nullptr; |
} |
return PyString_FromString(it->currentCharStyle().fontFeatures().toUtf8()); |
return PyString_FromString(item->currentCharStyle().fontFeatures().toUtf8()); |
} |
|
PyObject *scribus_getlinespace(PyObject* /* self */, PyObject* args) |
218,15 → 220,15 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->asTextFrame()) |
if (!item->asTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get line space of non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
return PyFloat_FromDouble(static_cast<double>(i->currentStyle().lineSpacing())); |
return PyFloat_FromDouble(static_cast<double>(item->currentStyle().lineSpacing())); |
} |
|
PyObject *scribus_gettextdistances(PyObject* /* self */, PyObject* args) |
236,19 → 238,19 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get text distances of non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
return Py_BuildValue("(dddd)", |
PointToValue(i->textToFrameDistLeft()), |
PointToValue(i->textToFrameDistRight()), |
PointToValue(i->textToFrameDistTop()), |
PointToValue(i->textToFrameDistBottom())); |
PointToValue(item->textToFrameDistLeft()), |
PointToValue(item->textToFrameDistRight()), |
PointToValue(item->textToFrameDistTop()), |
PointToValue(item->textToFrameDistBottom())); |
} |
|
PyObject *scribus_getframetext(PyObject* /* self */, PyObject* args) |
259,24 → 261,24 |
if (!checkHaveDocument()) |
return nullptr; |
QString text = ""; |
PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
if (it == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!(it->isTextFrame()) && !(it->isPathText())) |
if (!(item->isTextFrame()) && !(item->isPathText())) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get text of non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
for (int a = it->firstInFrame(); a <= it->lastInFrame(); ++a) |
for (int i = item->firstInFrame(); i <= item->lastInFrame(); ++i) |
{ |
if (it->HasSel) |
if (item->HasSel) |
{ |
if (it->itemText.selected(a)) |
text += it->itemText.text(a); |
if (item->itemText.selected(i)) |
text += item->itemText.text(i); |
} |
else |
{ |
text += it->itemText.text(a); |
text += item->itemText.text(i); |
} |
} |
return PyString_FromString(text.toUtf8()); |
290,10 → 292,10 |
if (!checkHaveDocument()) |
return nullptr; |
QString text = ""; |
PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
if (it == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!(it->isTextFrame()) && !(it->isPathText())) |
if (!(item->isTextFrame()) && !(item->isPathText())) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get text of non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
300,16 → 302,16 |
} |
|
// collect all chars from a storytext |
for (int a = 0; a < it->itemText.length(); a++) |
for (int i = 0; i < item->itemText.length(); i++) |
{ |
if (it->HasSel) |
if (item->HasSel) |
{ |
if (it->itemText.selected(a)) |
text += it->itemText.text(a); |
if (item->itemText.selected(i)) |
text += item->itemText.text(i); |
} |
else |
{ |
text += it->itemText.text(a); |
text += item->itemText.text(i); |
} |
} // for |
return PyString_FromString(text.toUtf8()); |
352,10 → 354,10 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
if (it == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!(it->isTextFrame()) && !(it->isPathText())) |
if (!(item->isTextFrame()) && !(item->isPathText())) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot insert text into non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
364,19 → 366,19 |
textData.replace("\r\n", SpecialChars::PARSEP); |
textData.replace(QChar('\n') , SpecialChars::PARSEP); |
PyMem_Free(Text); |
if ((pos < -1) || (pos > static_cast<int>(it->itemText.length()))) |
if ((pos < -1) || (pos > static_cast<int>(item->itemText.length()))) |
{ |
PyErr_SetString(PyExc_IndexError, QObject::tr("Insert index out of bounds.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
if (pos == -1) |
pos = it->itemText.length(); |
it->itemText.insertChars(pos, textData, true); |
it->Dirty = true; |
pos = item->itemText.length(); |
item->itemText.insertChars(pos, textData, true); |
item->Dirty = true; |
if (ScCore->primaryMainWindow()->doc->DoDrawing) |
{ |
// FIXME adapt to Qt-4 painting style |
it->Dirty = false; |
item->Dirty = false; |
} |
Py_RETURN_NONE; |
} |
394,12 → 396,12 |
return nullptr; |
} |
|
PageItem *it = GetUniqueItem(QString::fromUtf8(name)); |
if (it == nullptr) { |
PageItem *item = GetUniqueItem(QString::fromUtf8(name)); |
if (item == nullptr) { |
return nullptr; |
} |
|
if (!(it->isTextFrame()) && !(it->isPathText())) { |
if (!(item->isTextFrame()) && !(item->isPathText())) { |
PyErr_SetString(WrongFrameTypeError, |
QObject::tr("Cannot insert text into non-text frame.", |
"python error").toLocal8Bit().constData()); |
409,7 → 411,7 |
QString fileName = QString::fromUtf8(file); |
|
gtGetText gt(ScCore->primaryMainWindow()->doc); |
gt.launchImporter(-1, fileName, false, QString("utf-8"), false, true, it); |
gt.launchImporter(-1, fileName, false, QString("utf-8"), false, true, item); |
|
// FIXME: PyMem_Free() - are any needed?? |
Py_RETURN_NONE; |
428,10 → 430,10 |
PyErr_SetString(PyExc_ValueError, QObject::tr("Alignment out of range. Use one of the scribus.ALIGN_* constants.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->asTextFrame()) |
if (!item->asTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text alignment on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
438,8 → 440,8 |
} |
int Apm = ScCore->primaryMainWindow()->doc->appMode; |
ScCore->primaryMainWindow()->doc->m_Selection->clear(); |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i); |
if (i->HasSel) |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(item); |
if (item->HasSel) |
ScCore->primaryMainWindow()->doc->appMode = modeEdit; |
ScCore->primaryMainWindow()->setNewAlignment(alignment); |
ScCore->primaryMainWindow()->doc->appMode = Apm; |
461,10 → 463,10 |
PyErr_SetString(PyExc_ValueError, QObject::tr("direction out of range. Use one of the scribus.DIRECTION* constants.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->asTextFrame()) |
if (!item->asTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text direction on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
471,8 → 473,8 |
} |
int Apm = ScCore->primaryMainWindow()->doc->appMode; |
ScCore->primaryMainWindow()->doc->m_Selection->clear(); |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i); |
if (i->HasSel) |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(item); |
if (item->HasSel) |
ScCore->primaryMainWindow()->doc->appMode = modeEdit; |
ScCore->primaryMainWindow()->setNewDirection(direction); |
ScCore->primaryMainWindow()->doc->appMode = Apm; |
494,11 → 496,11 |
PyErr_SetString(PyExc_ValueError, QObject::tr("Font size out of bounds - must be 1 <= size <= 512.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
|
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set font size on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
505,8 → 507,8 |
} |
int Apm = ScCore->primaryMainWindow()->doc->appMode; |
ScCore->primaryMainWindow()->doc->m_Selection->clear(); |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i); |
if (i->HasSel) |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(item); |
if (item->HasSel) |
ScCore->primaryMainWindow()->doc->appMode = modeEdit; |
ScCore->primaryMainWindow()->doc->itemSelection_SetFontSize(qRound(size * 10.0)); |
ScCore->primaryMainWindow()->doc->appMode = Apm; |
524,11 → 526,11 |
if (!checkHaveDocument()) |
return nullptr; |
|
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
|
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set font feature on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
535,8 → 537,8 |
} |
int Apm = ScCore->primaryMainWindow()->doc->appMode; |
ScCore->primaryMainWindow()->doc->m_Selection->clear(); |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i); |
if (i->HasSel) |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(item); |
if (item->HasSel) |
ScCore->primaryMainWindow()->doc->appMode = modeEdit; |
ScCore->primaryMainWindow()->doc->itemSelection_SetFontFeatures(QString::fromUtf8(fontfeature)); |
ScCore->primaryMainWindow()->doc->appMode = Apm; |
553,10 → 555,10 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!(i->isTextFrame()) && !(i->isPathText())) |
if (!(item->isTextFrame()) && !(item->isPathText())) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set font on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
565,8 → 567,8 |
{ |
int Apm = ScCore->primaryMainWindow()->doc->appMode; |
ScCore->primaryMainWindow()->doc->m_Selection->clear(); |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i); |
if (i->HasSel) |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(item); |
if (item->HasSel) |
ScCore->primaryMainWindow()->doc->appMode = modeEdit; |
ScCore->primaryMainWindow()->SetNewFont(QString::fromUtf8(Font)); |
ScCore->primaryMainWindow()->doc->appMode = Apm; |
593,10 → 595,10 |
PyErr_SetString(PyExc_ValueError, QObject::tr("Line space out of bounds, must be >= 0.1.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set line spacing on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
604,14 → 606,14 |
|
int Apm = ScCore->primaryMainWindow()->doc->appMode; |
ScCore->primaryMainWindow()->doc->m_Selection->clear(); |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i); |
if (i->HasSel) |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(item); |
if (item->HasSel) |
ScCore->primaryMainWindow()->doc->appMode = modeEdit; |
ScCore->primaryMainWindow()->doc->itemSelection_SetLineSpacing(w); |
ScCore->primaryMainWindow()->doc->appMode = Apm; |
ScCore->primaryMainWindow()->view->Deselect(); |
|
// i->setLineSpacing(w); |
// item->setLineSpacing(w); |
Py_RETURN_NONE; |
} |
|
628,10 → 630,10 |
PyErr_SetString(PyExc_ValueError, QObject::tr("Line space mode invalid, must be 0, 1 or 2","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set line spacing mode on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
639,8 → 641,8 |
|
int Apm = ScCore->primaryMainWindow()->doc->appMode; |
ScCore->primaryMainWindow()->doc->m_Selection->clear(); |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i); |
if (i->HasSel) |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(item); |
if (item->HasSel) |
ScCore->primaryMainWindow()->doc->appMode = modeEdit; |
ScCore->primaryMainWindow()->doc->itemSelection_SetLineSpacingMode(w); |
ScCore->primaryMainWindow()->doc->appMode = Apm; |
662,15 → 664,15 |
PyErr_SetString(PyExc_ValueError, QObject::tr("Text distances out of bounds, must be positive.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text distances on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
i->setTextToFrameDist(ValueToPoint(l), ValueToPoint(r), ValueToPoint(t), ValueToPoint(b)); |
item->setTextToFrameDist(ValueToPoint(l), ValueToPoint(r), ValueToPoint(t), ValueToPoint(b)); |
|
Py_RETURN_NONE; |
} |
688,15 → 690,15 |
PyErr_SetString(PyExc_ValueError, QObject::tr("Column gap out of bounds, must be positive.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set column gap on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
i->ColGap = ValueToPoint(w); |
item->ColGap = ValueToPoint(w); |
|
Py_RETURN_NONE; |
} |
714,15 → 716,15 |
PyErr_SetString(PyExc_ValueError, QObject::tr("Column count out of bounds, must be > 1.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set number of columns on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
i->Cols = w; |
item->Cols = w; |
|
Py_RETURN_NONE; |
} |
762,24 → 764,24 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
if (it == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (selcount == -1) |
{ |
// user wants to select all after the start point -- CR |
selcount = it->itemText.length() - start; |
selcount = item->itemText.length() - start; |
if (selcount < 0) |
// user passed start that's > text in the frame |
selcount = 0; |
} |
// cr 2005-01-18 fixed off-by-one with end bound that made selecting the last char impossible |
if ((start < 0) || ((start + selcount) > static_cast<int>(it->itemText.length()))) |
if ((start < 0) || ((start + selcount) > static_cast<int>(item->itemText.length()))) |
{ |
PyErr_SetString(PyExc_IndexError, QObject::tr("Selection index out of bounds", "python error").toLocal8Bit().constData()); |
return nullptr; |
} |
if (!(it->isTextFrame()) && !(it->isPathText())) |
if (!(item->isTextFrame()) && !(item->isPathText())) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot select text in a non-text frame", "python error").toLocal8Bit().constData()); |
return nullptr; |
791,16 → 793,16 |
return nullptr; |
} |
*/ |
it->itemText.deselectAll(); |
item->itemText.deselectAll(); |
if (selcount == 0) |
{ |
it->HasSel = false; |
item->HasSel = false; |
// Py_INCREF(Py_None); |
// return Py_None; |
Py_RETURN_NONE; |
} |
it->itemText.select(start, selcount, true); |
it->HasSel = true; |
item->itemText.select(start, selcount, true); |
item->HasSel = true; |
|
Py_RETURN_NONE; |
} |
812,15 → 814,15 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
if (it == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!it->isTextFrame() && !it->isPathText()) |
if (!item->isTextFrame() && !item->isPathText()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot delete text from a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
PageItem_TextFrame* tf_item = it->asTextFrame(); |
PageItem_TextFrame* tf_item = item->asTextFrame(); |
if (tf_item) |
{ |
if (tf_item->HasSel) |
831,8 → 833,8 |
else |
{ |
//Path text cannot have selected text, :( FIXME |
if (it->isPathText()) |
it->itemText.clear(); |
if (item->isPathText()) |
item->itemText.clear(); |
} |
Py_RETURN_NONE; |
} |
845,27 → 847,27 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
if (it == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!it->isTextFrame() && !it->isPathText()) |
if (!item->isTextFrame() && !item->isPathText()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text fill on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
ApplyCharstyleHelper<QString>(it, QString::fromUtf8(Color)).apply(&CharStyle::setFillColor, 0, it->itemText.length()); |
// for (int b = 0; b < it->itemText.length(); b++) |
ApplyCharstyleHelper<QString>(item, QString::fromUtf8(Color)).apply(&CharStyle::setFillColor, 0, item->itemText.length()); |
// for (int b = 0; b < item->itemText.length(); b++) |
// { |
// //FIXME: doc method |
// if (it->HasSel) |
// if (item->HasSel) |
// { |
// if (it->itemText.selected(b)) |
// it->itemText.item(b)->setFillColor(QString::fromUtf8(Color)); |
// if (item->itemText.selected(b)) |
// item->itemText.item(b)->setFillColor(QString::fromUtf8(Color)); |
// } |
// else |
// it->itemText.item(b)->setFillColor(QString::fromUtf8(Color)); |
// item->itemText.item(b)->setFillColor(QString::fromUtf8(Color)); |
// } |
// it->TxtFill = QString::fromUtf8(Color); |
// item->TxtFill = QString::fromUtf8(Color); |
Py_RETURN_NONE; |
} |
|
877,27 → 879,27 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
if (it == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!it->isTextFrame() && !it->isPathText()) |
if (!item->isTextFrame() && !item->isPathText()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text stroke on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
ApplyCharstyleHelper<QString>(it, QString::fromUtf8(Color)).apply(&CharStyle::setStrokeColor, 0, it->itemText.length()); |
// for (int b = 0; b < it->itemText.length(); b++) |
ApplyCharstyleHelper<QString>(item, QString::fromUtf8(Color)).apply(&CharStyle::setStrokeColor, 0, item->itemText.length()); |
// for (int b = 0; b < item->itemText.length(); b++) |
// { |
// //FIXME:NLS use document method for this |
// if (it->HasSel) |
// if (item->HasSel) |
// { |
// if (it->itemText.selected(b)) |
// it->itemText.item(b)->setStrokeColor(QString::fromUtf8(Color)); |
// if (item->itemText.selected(b)) |
// item->itemText.item(b)->setStrokeColor(QString::fromUtf8(Color)); |
// } |
// else |
// it->itemText.item(b)->setStrokeColor(QString::fromUtf8(Color)); |
// item->itemText.item(b)->setStrokeColor(QString::fromUtf8(Color)); |
// } |
// it->TxtStroke = QString::fromUtf8(Color); |
// item->TxtStroke = QString::fromUtf8(Color); |
Py_RETURN_NONE; |
} |
|
915,10 → 917,10 |
PyErr_SetString(PyExc_ValueError, QObject::tr("Character scaling out of bounds, must be >= 10","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set character scaling on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
926,8 → 928,8 |
|
int Apm = ScCore->primaryMainWindow()->doc->appMode; |
ScCore->primaryMainWindow()->doc->m_Selection->clear(); |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i); |
if (i->HasSel) |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(item); |
if (item->HasSel) |
ScCore->primaryMainWindow()->doc->appMode = modeEdit; |
ScCore->primaryMainWindow()->doc->itemSelection_SetScaleH(qRound(sc * 10)); |
ScCore->primaryMainWindow()->doc->appMode = Apm; |
950,10 → 952,10 |
PyErr_SetString(PyExc_ValueError, QObject::tr("Character scaling out of bounds, must be >= 10","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
PageItem *i = GetUniqueItem(QString::fromUtf8(Name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set character scaling on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
961,8 → 963,8 |
|
int Apm = ScCore->primaryMainWindow()->doc->appMode; |
ScCore->primaryMainWindow()->doc->m_Selection->clear(); |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(i); |
if (i->HasSel) |
ScCore->primaryMainWindow()->doc->m_Selection->addItem(item); |
if (item->HasSel) |
ScCore->primaryMainWindow()->doc->appMode = modeEdit; |
ScCore->primaryMainWindow()->doc->itemSelection_SetScaleV(qRound(sc * 10)); |
ScCore->primaryMainWindow()->doc->appMode = Apm; |
983,27 → 985,27 |
if ((w < 0) || (w > 100)) |
Py_RETURN_NONE; |
|
PageItem *it = GetUniqueItem(QString::fromUtf8(Name)); |
if (it == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(Name)); |
if (item == nullptr) |
return nullptr; |
if (!it->isTextFrame() && !it->isPathText()) |
if (!item->isTextFrame() && !item->isPathText()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set text shade on a non-text frame.","python error").toLocal8Bit().constData()); |
return nullptr; |
} |
ApplyCharstyleHelper<double>(it, w).apply(&CharStyle::setFillShade, 0, it->itemText.length()); |
ApplyCharstyleHelper<double>(item, w).apply(&CharStyle::setFillShade, 0, item->itemText.length()); |
// //FIXME:NLS use document method for that |
// for (int b = 0; b < it->itemText.length(); ++b) |
// for (int b = 0; b < item->itemText.length(); ++b) |
// { |
// if (it->HasSel) |
// if (item->HasSel) |
// { |
// if (it->itemText.selected(b)) |
// it->itemText.item(b)->setFillShade(w); |
// if (item->itemText.selected(b)) |
// item->itemText.item(b)->setFillShade(w); |
// } |
// else |
// it->itemText.item(b)->setFillShade(w); |
// item->itemText.item(b)->setFillShade(w); |
// } |
// it->ShTxtFill = w; |
// item->ShTxtFill = w; |
Py_RETURN_NONE; |
} |
|
1192,15 → 1194,15 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *i = GetUniqueItem(QString::fromUtf8(name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Can only hyphenate text frame", "python error").toLocal8Bit().constData()); |
return nullptr; |
} |
ScCore->primaryMainWindow()->doc->docHyphenator->slotHyphenate(i); |
ScCore->primaryMainWindow()->doc->docHyphenator->slotHyphenate(item); |
return PyBool_FromLong(1); |
} |
|
1215,15 → 1217,15 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *i = GetUniqueItem(QString::fromUtf8(name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Can only dehyphenate text frame", "python error").toLocal8Bit().constData()); |
return nullptr; |
} |
ScCore->primaryMainWindow()->doc->docHyphenator->slotDeHyphenate(i); |
ScCore->primaryMainWindow()->doc->docHyphenator->slotDeHyphenate(item); |
return PyBool_FromLong(1); |
} |
|
1235,24 → 1237,24 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *i = GetUniqueItem(QString::fromUtf8(name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Can't set bookmark on a non-text frame", "python error").toLocal8Bit().constData()); |
return nullptr; |
} |
if (i->isBookmark == toggle) |
if (item->isBookmark == toggle) |
Py_RETURN_NONE; |
if (toggle) |
{ |
i->setIsAnnotation(false); |
ScCore->primaryMainWindow()->AddBookMark(i); |
item->setIsAnnotation(false); |
ScCore->primaryMainWindow()->AddBookMark(item); |
} |
else |
ScCore->primaryMainWindow()->DelBookMark(i); |
i->isBookmark = toggle; |
ScCore->primaryMainWindow()->DelBookMark(item); |
item->isBookmark = toggle; |
|
Py_RETURN_NONE; |
} |
1264,15 → 1266,15 |
return nullptr; |
if (!checkHaveDocument()) |
return nullptr; |
PageItem *i = GetUniqueItem(QString::fromUtf8(name)); |
if (i == nullptr) |
PageItem *item = GetUniqueItem(QString::fromUtf8(name)); |
if (item == nullptr) |
return nullptr; |
if (!i->isTextFrame()) |
if (!item->isTextFrame()) |
{ |
PyErr_SetString(WrongFrameTypeError, QObject::tr("Can't get info from a non-text frame", "python error").toLocal8Bit().constData()); |
return nullptr; |
} |
if (i->isBookmark) |
if (item->isBookmark) |
return PyBool_FromLong(1); |
return PyBool_FromLong(0); |
} |