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 797 of file KoSvgTextShape.h.

Constructor & Destructor Documentation

◆ KoSvgTextShapeFactory()

KoSvgTextShapeFactory::KoSvgTextShapeFactory ( )

constructor

Definition at line 2598 of file KoSvgTextShape.cpp.

2599 : KoShapeFactoryBase(KoSvgTextShape_SHAPEID, i18nc("Text label in SVG Text Tool", "Text"))
2600{
2601 setToolTip(i18n("SVG Text Shape"));
2602 setIconName(koIconNameCStr("x-shape-text"));
2605
2607 t.name = i18n("SVG Text");
2608 t.iconName = koIconName("x-shape-text");
2609 t.toolTip = i18n("SVG Text Shape");
2610 addTemplate(t);
2611}
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 803 of file KoSvgTextShape.h.

803{}

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 2613 of file KoSvgTextShape.cpp.

2614{
2615 Q_UNUSED(documentResources);
2616 debugFlake << "Create default svg text shape";
2617
2618 KoSvgTextShape *shape = new KoSvgTextShape();
2620 shape->insertText(0, i18nc("Default text for the text shape", "Placeholder Text"));
2621
2622 return shape;
2623}
#define debugFlake
Definition FlakeDebug.h:15
void setShapeId(const QString &id)
Definition KoShape.cpp:885
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 2625 of file KoSvgTextShape.cpp.

2626{
2627 KoSvgTextShape *shape = new KoSvgTextShape();
2629
2630 QString svgText = params->stringProperty("svgText", i18nc("Default text for the text shape", "<text>Placeholder Text</text>"));
2631 QString defs = params->stringProperty("defs" , "<defs/>");
2632 QRectF shapeRect = QRectF(0, 0, 200, 60);
2633 QVariant rect = params->property("shapeRect");
2634 QVariant origin = params->property("origin");
2635
2636 if (rect.type()==QVariant::RectF) {
2637 shapeRect = rect.toRectF();
2638 }
2639
2640 KoSvgTextShapeMarkupConverter converter(shape);
2641 converter.convertFromSvg(svgText,
2642 defs,
2643 shapeRect,
2644 documentResources->documentResolution());
2645 if (origin.type() == QVariant::PointF) {
2646 shape->setPosition(origin.toPointF());
2647 } else {
2648 shape->setPosition(shapeRect.topLeft());
2649 }
2651
2652 return shape;
2653}
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:267
@ 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 2655 of file KoSvgTextShape.cpp.

2656{
2657 return false;
2658}

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