scripter_unit.diff (1,620 bytes)
Index: scribus/plugins/scripter/api_document.h
===================================================================
--- scribus/plugins/scripter/api_document.h (revision 17926)
+++ scribus/plugins/scripter/api_document.h (working copy)
@@ -33,6 +33,7 @@
Q_PROPERTY(QList<QVariant> layers READ layers)
Q_PROPERTY(QList<QVariant> masterPages READ masterPages)
Q_PROPERTY(QList<QVariant> styles READ styles)
+ Q_PROPERTY(int unit READ unit WRITE setUnit)
public:
DocumentAPI();
@@ -95,6 +96,8 @@
bool available();
bool modified();
void setModified(bool flag);
+ int unit();
+ void setUnit(int value);
QObject *activePage();
int pageCount();
QList<QVariant> selection();
Index: scribus/plugins/scripter/api_document.cpp
===================================================================
--- scribus/plugins/scripter/api_document.cpp (revision 17926)
+++ scribus/plugins/scripter/api_document.cpp (working copy)
@@ -94,7 +94,26 @@
return ScCore->primaryMainWindow()->doc->isModified();
}
+/**
+ * Scripter.activeDocument.unit
+ * Property
+ * boolean flag current measurement unit of the document
+ *
+ * When starting a script you should query its current unit,
+ * Use your preferred unit during the script life and don't forget
+ * to set again the previous unit before finishing the script
+ */
+void DocumentAPI::setUnit(int value)
+{
+ if (!check()) return;
+ ScCore->primaryMainWindow()->doc->setUnitIndex(value);
+}
+int DocumentAPI::unit()
+{
+ if (!check()) return NULL;
+ return ScCore->primaryMainWindow()->doc->unitIndex();
+}
/**
* Scripter.activeDocument.close()