Krita Source Code Documentation
Loading...
Searching...
No Matches
KoSvgTextShapeFactory Class Reference

#include <KoSvgTextShape.h>

+ Inheritance diagram for KoSvgTextShapeFactory:

Public Member Functions

KoShapecreateDefaultShape (KoDocumentResourceManager *documentResources=0) const override
 
KoShapecreateShape (const KoProperties *params, KoDocumentResourceManager *documentResources=0) const override
 
 KoSvgTextShapeFactory ()
 constructor
 
bool supports (const QDomElement &e, KoShapeLoadingContext &context) const override
 Reimplemented.
 
 ~KoSvgTextShapeFactory ()
 
- Public Member Functions inherited from KoShapeFactoryBase
virtual QList< KoShapeConfigWidgetBase * > createShapeOptionPanels ()
 
QString family () const
 
bool hidden () const
 
QString iconName () const
 
QString id () const
 
 KoShapeFactoryBase (const QString &id, const QString &name, const QString &deferredPluginName=QString())
 
int loadingPriority () const
 lower prio means the shape is more generic and will be checked later
 
QString name () const
 
virtual void newDocumentResourceManager (KoDocumentResourceManager *manager) const
 
QList< QPair< QString, QStringList > > odfElements () const
 
 Private (const QString &_id, const QString &_name, const QString &_deferredPluginName)
 
QList< KoShapeTemplatetemplates () const
 
QString toolTip () const
 
 ~KoShapeFactoryBase () override
 
 ~Private ()
 

Additional Inherited Members

- Public Attributes inherited from KoShapeFactoryBase
KoDeferredShapeFactoryBasedeferredFactory
 
QString deferredPluginName
 
QString family
 
bool hidden
 
QString iconName
 
const QString id
 
int loadingPriority
 
const QString name
 
QMutex pluginLoadingMutex
 
QList< QPointer< KoDocumentResourceManager > > resourceManagers
 
QList< KoShapeTemplatetemplates
 
QString tooltip
 
QList< QPair< QString, QStringList > > xmlElements
 
- Protected Member Functions inherited from KoShapeFactoryBase
void addTemplate (const KoShapeTemplate &params)
 
void setFamily (const QString &family)
 
void setHidden (bool hidden)
 
void setIconName (const char *iconName)
 
void setLoadingPriority (int priority)
 
void setToolTip (const QString &tooltip)
 
void setXmlElementNames (const QString &nameSpace, const QStringList &elementNames)
 
void setXmlElements (const QList< QPair< QString, QStringList > > &elementNamesList)
 

Detailed Description

Definition at line 804 of file KoSvgTextShape.h.

Constructor & Destructor Documentation

◆ KoSvgTextShapeFactory()

KoSvgTextShapeFactory::KoSvgTextShapeFactory ( )

constructor

Definition at line 2614 of file KoSvgTextShape.cpp.

2615 : KoShapeFactoryBase(KoSvgTextShape_SHAPEID, i18nc("Text label in SVG Text Tool", "Text"))
2616{
2617 setToolTip(i18n("SVG Text Shape"));
2618 setIconName(koIconNameCStr("x-shape-text"));
2621
2623 t.name = i18n("SVG Text");
2624 t.iconName = koIconName("x-shape-text");
2625 t.toolTip = i18n("SVG Text Shape");
2626 addTemplate(t);
2627}
QList< QString > QStringList
#define KoSvgTextShape_SHAPEID
void addTemplate(const KoShapeTemplate &params)
void setToolTip(const QString &tooltip)
void setLoadingPriority(int priority)
void setIconName(const char *iconName)
void setXmlElementNames(const QString &nameSpace, const QStringList &elementNames)
KoShapeFactoryBase(const QString &id, const QString &name, const QString &deferredPluginName=QString())
static const QString svg
Definition KoXmlNS.h:39
#define koIconNameCStr(name)
Definition kis_icon.h:28
#define koIconName(name)
Definition kis_icon.h:27
QString iconName
Icon name.
QString toolTip
The tooltip text for the template.
QString name
The name to be shown for this template.

References KoShapeFactoryBase::addTemplate(), KoShapeTemplate::iconName, koIconName, koIconNameCStr, KoShapeTemplate::name, KoShapeFactoryBase::setIconName(), KoShapeFactoryBase::setLoadingPriority(), KoShapeFactoryBase::setToolTip(), KoShapeFactoryBase::setXmlElementNames(), KoXmlNS::svg, and KoShapeTemplate::toolTip.

◆ ~KoSvgTextShapeFactory()

KoSvgTextShapeFactory::~KoSvgTextShapeFactory ( )
inline

Definition at line 810 of file KoSvgTextShape.h.

810{}

Member Function Documentation

◆ createDefaultShape()

KoShape * KoSvgTextShapeFactory::createDefaultShape ( KoDocumentResourceManager * documentResources = 0) const
overridevirtual

This method should be implemented by factories to create a shape that the user gets when doing a base insert. For example from a script. The created shape should have its values set to good defaults that the user can then adjust further if needed. Including the KoShape:setShapeId(), with the Id from this factory The default shape position is not relevant, it will be moved by the caller.

Parameters
documentResourcesthe resources manager that has all the document wide resources which can be used to create the object.
Returns
a new shape
See also
createShape() newDocumentResourceManager()

Reimplemented from KoShapeFactoryBase.

Definition at line 2629 of file KoSvgTextShape.cpp.

2630{
2631 Q_UNUSED(documentResources);
2632 debugFlake << "Create default svg text shape";
2633
2634 KoSvgTextShape *shape = new KoSvgTextShape();
2636 shape->insertText(0, i18nc("Default text for the text shape", "Placeholder Text"));
2637
2638 return shape;
2639}
#define debugFlake
Definition FlakeDebug.h:15
void setShapeId(const QString &id)
Definition KoShape.cpp:880
bool insertText(int pos, QString text)
insertText Insert a text somewhere in the KoTextShape.

References debugFlake, KoSvgTextShape::insertText(), KoSvgTextShape_SHAPEID, and KoShape::setShapeId().

◆ createShape()

KoShape * KoSvgTextShapeFactory::createShape ( const KoProperties * params,
KoDocumentResourceManager * documentResources = 0 ) const
overridevirtual

This method should be implemented by factories to create a shape based on a set of properties that are specifically made for this shape-type. This method should also set this factories shapeId on the shape using KoShape::setShapeId() The default implementation just ignores 'params' and calls createDefaultShape()

Returns
a new shape
Parameters
paramsthe parameters to use when creating the shape
documentResourcesthe resources manager that has all the document wide resources which can be used to create the object.
See also
createDefaultShape() newDocumentResourceManager() addTemplate()
KoShapeTemplate::properties

Reimplemented from KoShapeFactoryBase.

Definition at line 2641 of file KoSvgTextShape.cpp.

2642{
2643 KoSvgTextShape *shape = new KoSvgTextShape();
2645
2646 QString svgText = params->stringProperty("svgText", i18nc("Default text for the text shape", "<text>Placeholder Text</text>"));
2647 QString defs = params->stringProperty("defs" , "<defs/>");
2648 QRectF shapeRect = QRectF(0, 0, 200, 60);
2649 QVariant rect = params->property("shapeRect");
2650 QVariant origin = params->property("origin");
2651
2652#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
2653 if (rect.type()==QVariant::RectF) {
2654#else
2655 if (rect.typeId() == QMetaType::QRectF) {
2656#endif
2657 shapeRect = rect.toRectF();
2658 }
2659
2660 KoSvgTextShapeMarkupConverter converter(shape);
2661 converter.convertFromSvg(svgText,
2662 defs,
2663 shapeRect,
2664 documentResources->documentResolution());
2665#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
2666 if (origin.type() == QVariant::PointF) {
2667#else
2668 if (origin.typeId() == QMetaType::QPointF) {
2669#endif
2670 shape->setPosition(origin.toPointF());
2671 } else {
2672 shape->setPosition(shapeRect.topLeft());
2673 }
2675
2676 return shape;
2677}
QString stringProperty(const QString &name, const QString &defaultValue=QString()) const
bool property(const QString &name, QVariant &value) const
virtual void setPosition(const QPointF &position)
Set the position of the shape in pt.
Definition KoShape.cpp:268
@ Stroke
Definition KoShape.h:117
void setPaintOrder(PaintOrder first, PaintOrder second) override
setPaintOrder set the paint order. As there's only three entries in any given paintorder,...

References KoSvgTextShapeMarkupConverter::convertFromSvg(), KoDocumentResourceManager::documentResolution(), KoShape::Fill, KoSvgTextShape_SHAPEID, KoProperties::property(), KoSvgTextShape::setPaintOrder(), KoShape::setPosition(), KoShape::setShapeId(), KoProperties::stringProperty(), and KoShape::Stroke.

◆ supports()

bool KoSvgTextShapeFactory::supports ( const QDomElement & e,
KoShapeLoadingContext & context ) const
overridevirtual

Reimplemented.

Implements KoShapeFactoryBase.

Definition at line 2679 of file KoSvgTextShape.cpp.

2680{
2681 return false;
2682}

The documentation for this class was generated from the following files: