r18085 by craig - #11345: Apply patch for setting/getting document units. Fix indenting. Fix void moveSelectionToFront() that was sending to back

scribus-commit scribus-commit at lists.scribus.net
Sat Jan 12 09:53:50 UTC 2013


Author: craig
Date: Sat Jan 12 09:53:49 2013
New Revision: 18085

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18085
Log:
#11345: Apply patch for setting/getting document units. Fix indenting. Fix void moveSelectionToFront() that was sending to back

Modified:
    trunk/Scribus/scribus/plugins/scripter/api_document.cpp
    trunk/Scribus/scribus/plugins/scripter/api_document.h

Modified: trunk/Scribus/scribus/plugins/scripter/api_document.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18085&path=/trunk/Scribus/scribus/plugins/scripter/api_document.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/api_document.cpp (original)
+++ trunk/Scribus/scribus/plugins/scripter/api_document.cpp Sat Jan 12 09:53:49 2013
@@ -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()

Modified: trunk/Scribus/scribus/plugins/scripter/api_document.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18085&path=/trunk/Scribus/scribus/plugins/scripter/api_document.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/api_document.h (original)
+++ trunk/Scribus/scribus/plugins/scripter/api_document.h Sat Jan 12 09:53:49 2013
@@ -13,130 +13,131 @@
 
 #include "scripterimpl.h"
 
-
-
 class DocumentAPI : public QObject
 {
-	Q_OBJECT
-    Q_PROPERTY(QString name READ getName)
-    Q_PROPERTY(bool available READ available)
-    Q_PROPERTY(QObject* margins READ margins)
-    Q_PROPERTY(bool modified READ modified WRITE setModified)
-    Q_PROPERTY(QObject* activePage READ activePage)
-    Q_PROPERTY(int pageCount READ pageCount)
-    Q_PROPERTY(QObject* activeItem READ activeItem)
-    Q_PROPERTY(QObject* dimensions READ dimensions)
-    Q_PROPERTY(QList<QVariant> items READ items)
-    Q_PROPERTY(QList<QVariant> selection READ selection)
-    Q_PROPERTY(int selectionCount READ selectionCount)
-    Q_PROPERTY(QList<QVariant> colors READ colors)
-    Q_PROPERTY(QList<QVariant> layers READ layers)
-    Q_PROPERTY(QList<QVariant> masterPages READ masterPages)
-    Q_PROPERTY(QList<QVariant> styles READ styles)
-    Q_PROPERTY(QList<QVariant> pages READ pages)
+		Q_OBJECT
+		Q_PROPERTY(QString name READ getName)
+		Q_PROPERTY(bool available READ available)
+		Q_PROPERTY(QObject* margins READ margins)
+		Q_PROPERTY(bool modified READ modified WRITE setModified)
+		Q_PROPERTY(QObject* activePage READ activePage)
+		Q_PROPERTY(int pageCount READ pageCount)
+		Q_PROPERTY(QObject* activeItem READ activeItem)
+		Q_PROPERTY(QObject* dimensions READ dimensions)
+		Q_PROPERTY(QList<QVariant> items READ items)
+		Q_PROPERTY(QList<QVariant> selection READ selection)
+		Q_PROPERTY(int selectionCount READ selectionCount)
+		Q_PROPERTY(QList<QVariant> colors READ colors)
+		Q_PROPERTY(QList<QVariant> layers READ layers)
+		Q_PROPERTY(QList<QVariant> masterPages READ masterPages)
+		Q_PROPERTY(QList<QVariant> styles READ styles)
+		Q_PROPERTY(QList<QVariant> pages READ pages)
+		Q_PROPERTY(int unit READ unit WRITE setUnit)
 
-public:
-	DocumentAPI();
-	virtual ~DocumentAPI();
+	public:
+		DocumentAPI();
+		virtual ~DocumentAPI();
+		
+	public slots:
+		bool check();
+		bool close();
+		bool save();
+		bool saveAs(QString name);
+		void setInformation(QString author, QString title, QString desc);
 
-public slots:
-	bool check();
-	bool close();
-	bool save();
-	bool saveAs(QString name);
-	void setInformation(QString author, QString title, QString desc);
+		QObject *newLayer(QString name);
+		void removeLayer(QString name);
+		QObject *getActiveLayer();
+		QString getActiveLayerName();
+		void setActiveLayer(QString name);
 
-	QObject *newLayer(QString name);
-	void removeLayer(QString name);
-	QObject *getActiveLayer();
-	QString getActiveLayerName();
-	void setActiveLayer(QString name);
+		QObject *newColorCMYK(QString name, int c, int m, int y, int k);
+		QObject *newColorRGB(QString name, int r, int g, int b);
+		QObject *getColor(QString name);
 
-	QObject *newColorCMYK(QString name, int c, int m, int y, int k);
-	QObject *newColorRGB(QString name, int r, int g, int b);
-	QObject *getColor(QString name);
-	
-	QList<QVariant> supportedImageTypes();
-	bool exportAsImages(QString dirName, QString type, double scale, double quality, double dpi, bool overwrite);
-	
-	QObject* Printer();
-	
-	QList<QVariant> masterPages();
-	void createMasterPage(QString name);
-	void deleteMasterPage(QString name);
-	void closeMasterPage(QString name);
-	void editMasterPage(QString name);
-	
-	QList<QVariant> pages();
-	void setActivePage(int pageNumber);
-	
-	void loadStylesFromFile(QString name);
+		QList<QVariant> supportedImageTypes();
+		bool exportAsImages(QString dirName, QString type, double scale, double quality, double dpi, bool overwrite);
 
-	void moveSelectionToFront()
-	{
-		ScCore->primaryMainWindow()->doc->sendItemSelectionToBack();
-	}
-	
-	void moveSelectionToBack()
-	{
-		ScCore->primaryMainWindow()->doc->sendItemSelectionToBack();
-	}
-	
-	QObject* selectItem(QString name);
-	void deleteItem(QString name);
-	bool itemExists(QString name);
-	void deselectItems();
+		QObject* Printer();
 
-	QString groupItems(QList<QVariant> list);
-	void unGroupItems(QString name);
-	void scaleGroup(double factor, QString name);
+		QList<QVariant> masterPages();
+		void createMasterPage(QString name);
+		void deleteMasterPage(QString name);
+		void closeMasterPage(QString name);
+		void editMasterPage(QString name);
 
-private:
-	QObject *margins();
-	QString getName();
-	bool available();
-	bool modified();
-	void setModified(bool flag);
-	QObject *activePage();
-	int pageCount();
-	QList<QVariant> selection();
-	int selectionCount();
-	QObject *activeItem();
-	QObject *dimensions();
-	QList<QVariant> colors();
-	QList<QVariant> styles();
-	QList<QVariant> items();
-	QList<QVariant> layers();
+		QList<QVariant> pages();
+		void setActivePage(int pageNumber);
+
+		void loadStylesFromFile(QString name);
+
+		void moveSelectionToFront()
+		{
+			ScCore->primaryMainWindow()->doc->bringItemSelectionToFront();
+		}
+
+		void moveSelectionToBack()
+		{
+			ScCore->primaryMainWindow()->doc->sendItemSelectionToBack();
+		}
+
+		QObject* selectItem(QString name);
+		void deleteItem(QString name);
+		bool itemExists(QString name);
+		void deselectItems();
+
+		QString groupItems(QList<QVariant> list);
+		void unGroupItems(QString name);
+		void scaleGroup(double factor, QString name);
+
+	private:
+		QObject *margins();
+		QString getName();
+		bool available();
+		bool modified();
+		void setModified(bool flag);
+		int unit();
+		void setUnit(int value);
+		QObject *activePage();
+		int pageCount();
+		QList<QVariant> selection();
+		int selectionCount();
+		QObject *activeItem();
+		QObject *dimensions();
+		QList<QVariant> colors();
+		QList<QVariant> styles();
+		QList<QVariant> items();
+		QList<QVariant> layers();
 };
 
 
 class Margins : public QObject
 {
-	Q_OBJECT
-    Q_PROPERTY(double top READ top WRITE setTop)
-    Q_PROPERTY(double left READ left WRITE setLeft)
-    Q_PROPERTY(double right READ right WRITE setRight)
-    Q_PROPERTY(double bottom READ bottom WRITE setBottom)
+		Q_OBJECT
+		Q_PROPERTY(double top READ top WRITE setTop)
+		Q_PROPERTY(double left READ left WRITE setLeft)
+		Q_PROPERTY(double right READ right WRITE setRight)
+		Q_PROPERTY(double bottom READ bottom WRITE setBottom)
 
-public:
-	Margins(QObject *parent);
-	virtual ~Margins()
-	{
-		qDebug() << "Margins deleted";
-    }
+	public:
+		Margins(QObject *parent);
+		virtual ~Margins()
+		{
+			qDebug() << "Margins deleted";
+		}
 
-public slots:
-	void set(double lr, double tpr, double btr, double rr);
+	public slots:
+		void set(double lr, double tpr, double btr, double rr);
 
-private:
-	double top();
-	void setTop(double value);
-	double left();
-	void setLeft(double value);
-	double right();
-	void setRight(double value);
-	double bottom();
-	void setBottom(double value);
+	private:
+		double top();
+		void setTop(double value);
+		double left();
+		void setLeft(double value);
+		double right();
+		void setRight(double value);
+		double bottom();
+		void setBottom(double value);
 
 };
 
@@ -144,22 +145,22 @@
 
 class Dimensions : public QObject
 {
-	Q_OBJECT
-    Q_PROPERTY(double width READ width)
-    Q_PROPERTY(double height READ height)
+		Q_OBJECT
+		Q_PROPERTY(double width READ width)
+		Q_PROPERTY(double height READ height)
 
-public:
-	Dimensions(QObject *parent);
+	public:
+		Dimensions(QObject *parent);
 
-    virtual ~Dimensions()
-	{
-		qDebug() << "Dimensions deleted";
-    }
+		virtual ~Dimensions()
+		{
+			qDebug() << "Dimensions deleted";
+		}
 
-private:
-	double width();
-	double height();
-	QList<QVariant> items;
+	private:
+		double width();
+		double height();
+		QList<QVariant> items;
 };
 
 




More information about the scribus-commit mailing list