Back to index

scribus-ng  1.3.4.dfsg+svn20071115
oodrawimp.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #ifndef OODPLUG_H
00008 #define OODPLUG_H
00009 
00010 #include <qobject.h>
00011 #include <qdict.h>
00012 #include <qptrlist.h>
00013 #include "pluginapi.h"
00014 #include "loadsaveplugin.h"
00015 #include "../../formatidlist.h"
00016 #include "stylestack.h"
00017 #include "pageitem.h"
00018 #include "scribusstructs.h"
00019 
00020 class ScrAction;
00021 class ScribusDoc;
00022 class Selection;
00023 
00024 class PLUGIN_API OODrawImportPlugin : public LoadSavePlugin
00025 {
00026        Q_OBJECT
00027 
00028        public:
00029               // Standard plugin implementation
00030               OODrawImportPlugin();
00031               virtual ~OODrawImportPlugin();
00032               virtual const QString fullTrName() const;
00033               virtual const AboutData* getAboutData() const;
00034               virtual void deleteAboutData(const AboutData* about) const;
00035               virtual void languageChange();
00036               virtual bool fileSupported(QIODevice* file, const QString & fileName=QString::null) const;
00037               virtual bool loadFile(const QString & fileName, const FileFormat & fmt, int flags, int index = 0);
00038               virtual void addToMainWindowMenu(ScribusMainWindow *);
00039 
00040               // Special features - File->Import slot
00041        public slots:
00042               virtual bool import(QString target = QString::null, int flags = lfUseCurrentPage|lfInteractive);
00043 
00044        private:
00045               void registerFormats();
00046               ScrAction* importAction;
00047 };
00048 
00049 extern "C" PLUGIN_API int oodrawimp_getPluginAPIVersion();
00050 extern "C" PLUGIN_API ScPlugin* oodrawimp_getPlugin();
00051 extern "C" PLUGIN_API void oodrawimp_freePlugin(ScPlugin* plugin);
00052 
00053 class QWidget;
00054 class ScribusMainWindow;
00055 class ScribusDoc;
00056 class FPointArray;
00057 class QDomDocument;
00058 class QDomElement;
00059 
00060 class OODrawStyle
00061 {
00062 public:
00063        OODrawStyle() :
00064          fillColor("None"),
00065          strokeColor("None"),
00066          fillTrans(0.0),
00067          strokeTrans(0.0),
00068          strokeWidth(0.0),
00069          haveGradient(false),
00070          gradientType(0),
00071          gradientAngle(0.0),
00072          gradientPointX(0.0),
00073          gradientPointY(0.0)
00074          {}
00075        QString fillColor;
00076        QString strokeColor;
00077        double  fillTrans;
00078        double  strokeTrans;
00079        double  strokeWidth;
00080        QValueList<double> dashes;
00081        bool    haveGradient;
00082        int     gradientType;
00083        VGradient gradient;
00084        double  gradientAngle;
00085        double  gradientPointX;
00086        double  gradientPointY;
00087 };
00088 
00089 class OODPlug : public QObject
00090 {
00091        Q_OBJECT
00092 
00093 public:
00094 
00095        OODPlug(ScribusDoc* doc);
00096        ~OODPlug();
00097 
00099        bool unsupported;
00100        bool importFailed;
00101        bool importCanceled;
00102        bool import( QString fName, int flags );
00103        static double parseUnit(const QString &unit);
00104 
00105 protected:
00106 
00107        bool convert(int flags);
00108        QPtrList<PageItem> parseGroup(const QDomElement &e);
00109        QPtrList<PageItem> parseElement(const QDomElement &e);
00110        QPtrList<PageItem> parseRect(const QDomElement &e);
00111        QPtrList<PageItem> parseEllipse(const QDomElement &e);
00112        QPtrList<PageItem> parseLine(const QDomElement &e);
00113        QPtrList<PageItem> parsePolygon(const QDomElement &e);
00114        QPtrList<PageItem> parsePolyline(const QDomElement &e);
00115        QPtrList<PageItem> parsePath(const QDomElement &e);
00116        QPtrList<PageItem> parseTextBox(const QDomElement &e);
00117        QPtrList<PageItem> parseFrame(const QDomElement &e);
00118        QPtrList<PageItem> parseConnector(const QDomElement &e);
00119        void parseStyle(OODrawStyle& style, const QDomElement &e);
00120        void parseCharStyle(CharStyle& style, const QDomElement &e);
00121        void parseParagraphStyle(ParagraphStyle& style, const QDomElement &e);
00122        PageItem* parseTextP(const QDomElement& e, PageItem* item);
00123        PageItem* parseTextSpans(const QDomElement& elm, PageItem* item);
00124        PageItem* finishNodeParsing(const QDomElement &elm, PageItem* item, OODrawStyle& oostyle);
00125        void createStyleMap( QDomDocument &docstyles );
00126        void insertDraws( const QDomElement& styles );
00127        void insertStyles( const QDomElement& styles );
00128        void fillStyleStack( const QDomElement& object );
00129        void addStyles( const QDomElement* style );
00130        void storeObjectStyles( const QDomElement& object );
00131        QColor parseColorN( const QString &rgbColor );
00132        QString parseColor( const QString &s );
00133        void parseTransform(FPointArray *composite, const QString &transform);
00134        void parseViewBox( const QDomElement& object, double *x, double *y, double *w, double *h );
00135        void appendPoints(FPointArray *composite, const QDomElement& object);
00136        const char * getCoord( const char *ptr, double &number );
00137        bool parseSVG( const QString &s, FPointArray *ite );
00138        void calculateArc(FPointArray *ite, bool relative, double &curx, double &cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag);
00139        void svgClosePath(FPointArray *i);
00140        void svgMoveTo(double x1, double y1);
00141        void svgLineTo(FPointArray *i, double x1, double y1);
00142        void svgCurveToCubic(FPointArray *i, double x1, double y1, double x2, double y2, double x3, double y3);
00143 
00144        QDomDocument inpContents;
00145        QDomDocument inpStyles;
00146        QDomDocument inpMeta;
00147        QDict<QDomElement> m_styles, m_draws;
00148        StyleStack m_styleStack;
00149        QString stylePath;
00150        QString contentPath;
00151        QString metaPath;
00152        double CurrX, CurrY, StartX, StartY;
00153        int PathLen;
00154        bool FirstM, WasM, PathClosed, HaveMeta;
00155 
00156        bool interactive;
00157        ScribusDoc* m_Doc;
00158        Selection* tmpSel;
00159        QStringList importedColors;
00160 };
00161 
00162 #endif