libs/flake
KoPathShapeFactory.cppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "KoPathShapeFactory.h"
00020 #include "KoPathShape.h"
00021 #include "KoLineBorder.h"
00022 #include "KoImageCollection.h"
00023
00024 #include <klocale.h>
00025
00026 #include <KoXmlReader.h>
00027 #include <KoXmlNS.h>
00028
00029 KoPathShapeFactory::KoPathShapeFactory(QObject *parent, const QStringList&)
00030 : KoShapeFactory(parent, KoPathShapeId, i18n("Simple path shape"))
00031 {
00032 setToolTip(i18n("A simple path shape"));
00033 setIcon("pathshape");
00034 QStringList elementNames;
00035 elementNames << "path" << "line" << "polyline" << "polygon";
00036 setOdfElementNames(KoXmlNS::draw, elementNames);
00037 setLoadingPriority(0);
00038 }
00039
00040 KoShape * KoPathShapeFactory::createDefaultShape() const
00041 {
00042 KoPathShape* path = new KoPathShape();
00043 path->moveTo(QPointF(0, 50));
00044 path->curveTo(QPointF(0, 120), QPointF(50, 120), QPointF(50, 50));
00045 path->curveTo(QPointF(50, -20), QPointF(100, -20), QPointF(100, 50));
00046 path->normalize();
00047 path->setBorder(new KoLineBorder(1.0));
00048 return path;
00049 }
00050
00051 KoShape * KoPathShapeFactory::createShape(const KoProperties * params) const
00052 {
00053 Q_UNUSED(params);
00054 return createDefaultShape();
00055 }
00056
00057 bool KoPathShapeFactory::supports(const KoXmlElement & e) const
00058 {
00059 if (e.localName() == "path" && e.namespaceURI() == KoXmlNS::draw)
00060 return true;
00061 if (e.localName() == "line" && e.namespaceURI() == KoXmlNS::draw)
00062 return true;
00063 if (e.localName() == "polyline" && e.namespaceURI() == KoXmlNS::draw)
00064 return true;
00065 if (e.localName() == "polygon" && e.namespaceURI() == KoXmlNS::draw)
00066 return true;
00067
00068 return false;
00069 }
00070
00071 void KoPathShapeFactory::populateDataCenterMap(QMap<QString, KoDataCenter *> & dataCenterMap)
00072 {
00073
00074
00075
00076
00077 if (! dataCenterMap.contains("ImageCollection")) {
00078 KoImageCollection *imgCol = new KoImageCollection();
00079 dataCenterMap["ImageCollection"] = imgCol;
00080 }
00081 }
|