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

Constructor & Destructor Documentation

◆ KoSvgTextShapeFactory()

KoSvgTextShapeFactory::KoSvgTextShapeFactory ( )

constructor

Definition at line 1765 of file KoSvgTextShape.cpp.

1766 : KoShapeFactoryBase(KoSvgTextShape_SHAPEID, i18nc("Text label in SVG Text Tool", "Text"))
1767{
1768 setToolTip(i18n("SVG Text Shape"));
1769 setIconName(koIconNameCStr("x-shape-text"));
1772
1774 t.name = i18n("SVG Text");
1775 t.iconName = koIconName("x-shape-text");
1776 t.toolTip = i18n("SVG Text Shape");
1777 addTemplate(t);
1778}
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 609 of file KoSvgTextShape.h.

609{}

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

1781{
1782 Q_UNUSED(documentResources);
1783 debugFlake << "Create default svg text shape";
1784
1785 KoSvgTextShape *shape = new KoSvgTextShape();
1787 shape->insertText(0, i18nc("Default text for the text shape", "Placeholder Text"));
1788
1789 return shape;
1790}
#define debugFlake
Definition FlakeDebug.h:15
void setShapeId(const QString &id)
Definition KoShape.cpp:1062
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 1792 of file KoSvgTextShape.cpp.

1793{
1794 KoSvgTextShape *shape = new KoSvgTextShape();
1796
1797 QString svgText = params->stringProperty("svgText", i18nc("Default text for the text shape", "<text>Placeholder Text</text>"));
1798 QString defs = params->stringProperty("defs" , "<defs/>");
1799 QRectF shapeRect = QRectF(0, 0, 200, 60);
1800 QVariant rect = params->property("shapeRect");
1801 QVariant origin = params->property("origin");
1802
1803 if (rect.type()==QVariant::RectF) {
1804 shapeRect = rect.toRectF();
1805 }
1806
1807 KoSvgTextShapeMarkupConverter converter(shape);
1808 converter.convertFromSvg(svgText,
1809 defs,
1810 shapeRect,
1811 documentResources->documentResolution());
1812 if (origin.type() == QVariant::PointF) {
1813 shape->setPosition(origin.toPointF());
1814 } else {
1815 shape->setPosition(shapeRect.topLeft());
1816 }
1818
1819 return shape;
1820}
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:295
@ Stroke
Definition KoShape.h:147
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 1822 of file KoSvgTextShape.cpp.

1823{
1824 return false;
1825}

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