XmlLabel* cleanup.
This commit is contained in:
+60
-63
@@ -169,33 +169,16 @@ namespace glabels
|
||||
parent.appendChild( node );
|
||||
|
||||
/* position attrs */
|
||||
XmlUtil::setLengthAttr( node, "x", object->x0() );
|
||||
XmlUtil::setLengthAttr( node, "y", object->y0() );
|
||||
createPositionAttrs( node, object );
|
||||
|
||||
/* size attrs */
|
||||
XmlUtil::setLengthAttr( node, "w", object->w() );
|
||||
XmlUtil::setLengthAttr( node, "h", object->h() );
|
||||
createSizeAttrs( node, object );
|
||||
|
||||
/* line attrs */
|
||||
XmlUtil::setLengthAttr( node, "line_width", object->lineWidth() );
|
||||
if ( object->lineColorNode().isField() )
|
||||
{
|
||||
XmlUtil::setStringAttr( node, "line_color_field", object->lineColorNode().key() );
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlUtil::setUIntAttr( node, "line_color", object->lineColorNode().rgba() );
|
||||
}
|
||||
createLineAttrs( node, object );
|
||||
|
||||
/* fill attrs */
|
||||
if ( object->fillColorNode().isField() )
|
||||
{
|
||||
XmlUtil::setStringAttr( node, "fill_color_field", object->fillColorNode().key() );
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlUtil::setUIntAttr( node, "fill_color", object->fillColorNode().rgba() );
|
||||
}
|
||||
createFillAttrs( node, object );
|
||||
|
||||
/* affine attrs */
|
||||
createAffineAttrs( node, object );
|
||||
@@ -213,33 +196,16 @@ namespace glabels
|
||||
parent.appendChild( node );
|
||||
|
||||
/* position attrs */
|
||||
XmlUtil::setLengthAttr( node, "x", object->x0() );
|
||||
XmlUtil::setLengthAttr( node, "y", object->y0() );
|
||||
createPositionAttrs( node, object );
|
||||
|
||||
/* size attrs */
|
||||
XmlUtil::setLengthAttr( node, "w", object->w() );
|
||||
XmlUtil::setLengthAttr( node, "h", object->h() );
|
||||
createSizeAttrs( node, object );
|
||||
|
||||
/* line attrs */
|
||||
XmlUtil::setLengthAttr( node, "line_width", object->lineWidth() );
|
||||
if ( object->lineColorNode().isField() )
|
||||
{
|
||||
XmlUtil::setStringAttr( node, "line_color_field", object->lineColorNode().key() );
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlUtil::setUIntAttr( node, "line_color", object->lineColorNode().rgba() );
|
||||
}
|
||||
createLineAttrs( node, object );
|
||||
|
||||
/* fill attrs */
|
||||
if ( object->fillColorNode().isField() )
|
||||
{
|
||||
XmlUtil::setStringAttr( node, "fill_color_field", object->fillColorNode().key() );
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlUtil::setUIntAttr( node, "fill_color", object->fillColorNode().rgba() );
|
||||
}
|
||||
createFillAttrs( node, object );
|
||||
|
||||
/* affine attrs */
|
||||
createAffineAttrs( node, object );
|
||||
@@ -257,23 +223,14 @@ namespace glabels
|
||||
parent.appendChild( node );
|
||||
|
||||
/* position attrs */
|
||||
XmlUtil::setLengthAttr( node, "x", object->x0() );
|
||||
XmlUtil::setLengthAttr( node, "y", object->y0() );
|
||||
createPositionAttrs( node, object );
|
||||
|
||||
/* size attrs */
|
||||
/* size attrs of line */
|
||||
XmlUtil::setLengthAttr( node, "dx", object->w() );
|
||||
XmlUtil::setLengthAttr( node, "dy", object->h() );
|
||||
|
||||
/* line attrs */
|
||||
XmlUtil::setLengthAttr( node, "line_width", object->lineWidth() );
|
||||
if ( object->lineColorNode().isField() )
|
||||
{
|
||||
XmlUtil::setStringAttr( node, "line_color_field", object->lineColorNode().key() );
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlUtil::setUIntAttr( node, "line_color", object->lineColorNode().rgba() );
|
||||
}
|
||||
createLineAttrs( node, object );
|
||||
|
||||
/* affine attrs */
|
||||
createAffineAttrs( node, object );
|
||||
@@ -291,15 +248,12 @@ namespace glabels
|
||||
parent.appendChild( node );
|
||||
|
||||
/* position attrs */
|
||||
XmlUtil::setLengthAttr( node, "x", object->x0() );
|
||||
XmlUtil::setLengthAttr( node, "y", object->y0() );
|
||||
createPositionAttrs( node, object );
|
||||
|
||||
/* size attrs */
|
||||
XmlUtil::setLengthAttr( node, "w", object->w() );
|
||||
XmlUtil::setLengthAttr( node, "h", object->h() );
|
||||
createSizeAttrs( node, object );
|
||||
|
||||
/* file attrs */
|
||||
XmlUtil::setLengthAttr( node, "line_width", object->lineWidth() );
|
||||
if ( object->filenameNode().isField() )
|
||||
{
|
||||
XmlUtil::setStringAttr( node, "src_field", object->filenameNode().data() );
|
||||
@@ -332,12 +286,10 @@ namespace glabels
|
||||
parent.appendChild( node );
|
||||
|
||||
/* position attrs */
|
||||
XmlUtil::setLengthAttr( node, "x", object->x0() );
|
||||
XmlUtil::setLengthAttr( node, "y", object->y0() );
|
||||
createPositionAttrs( node, object );
|
||||
|
||||
/* size attrs */
|
||||
XmlUtil::setLengthAttr( node, "w", object->w() );
|
||||
XmlUtil::setLengthAttr( node, "h", object->h() );
|
||||
createSizeAttrs( node, object );
|
||||
|
||||
/* color attr */
|
||||
if ( object->textColorNode().isField() )
|
||||
@@ -388,6 +340,51 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmlLabelCreator::createPositionAttrs( QDomElement &node, const LabelModelObject* object )
|
||||
{
|
||||
XmlUtil::setLengthAttr( node, "x", object->x0() );
|
||||
XmlUtil::setLengthAttr( node, "y", object->y0() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmlLabelCreator::createSizeAttrs( QDomElement &node, const LabelModelObject* object )
|
||||
{
|
||||
XmlUtil::setLengthAttr( node, "w", object->w() );
|
||||
XmlUtil::setLengthAttr( node, "h", object->h() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmlLabelCreator::createLineAttrs( QDomElement &node, const LabelModelObject* object )
|
||||
{
|
||||
XmlUtil::setLengthAttr( node, "line_width", object->lineWidth() );
|
||||
if ( object->lineColorNode().isField() )
|
||||
{
|
||||
XmlUtil::setStringAttr( node, "line_color_field", object->lineColorNode().key() );
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlUtil::setUIntAttr( node, "line_color", object->lineColorNode().rgba() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmlLabelCreator::createFillAttrs( QDomElement &node, const LabelModelObject* object )
|
||||
{
|
||||
if ( object->fillColorNode().isField() )
|
||||
{
|
||||
XmlUtil::setStringAttr( node, "fill_color_field", object->fillColorNode().key() );
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlUtil::setUIntAttr( node, "fill_color", object->fillColorNode().rgba() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmlLabelCreator::createAffineAttrs( QDomElement &node, const LabelModelObject* object )
|
||||
{
|
||||
|
||||
@@ -63,6 +63,10 @@ namespace glabels
|
||||
static void createObjectBarcodeNode( QDomElement &parent, const LabelModelBarcodeObject* object );
|
||||
static void createObjectTextNode( QDomElement &parent, const LabelModelTextObject* object );
|
||||
static void createPNode( QDomElement &parent, const QString& blockText );
|
||||
static void createPositionAttrs( QDomElement &node, const LabelModelObject* object );
|
||||
static void createSizeAttrs( QDomElement &node, const LabelModelObject* object );
|
||||
static void createLineAttrs( QDomElement &node, const LabelModelObject* object );
|
||||
static void createFillAttrs( QDomElement &node, const LabelModelObject* object );
|
||||
static void createAffineAttrs( QDomElement &node, const LabelModelObject* object );
|
||||
static void createShadowAttrs( QDomElement &node, const LabelModelObject* object );
|
||||
static void createMergeNode( QDomElement &parent, const LabelModel* label );
|
||||
|
||||
+71
-77
@@ -339,31 +339,16 @@ namespace glabels
|
||||
|
||||
|
||||
/* position attrs */
|
||||
object->setX0( XmlUtil::getLengthAttr( node, "x", 0.0 ) );
|
||||
object->setY0( XmlUtil::getLengthAttr( node, "y", 0.0 ) );
|
||||
parsePositionAttrs( node, object );
|
||||
|
||||
/* size attrs */
|
||||
object->setW( XmlUtil::getLengthAttr( node, "w", 0 ) );
|
||||
object->setH( XmlUtil::getLengthAttr( node, "h", 0 ) );
|
||||
parseSizeAttrs( node, object );
|
||||
|
||||
/* line attrs */
|
||||
object->setLineWidth( XmlUtil::getLengthAttr( node, "line_width", 1.0 ) );
|
||||
{
|
||||
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
||||
bool field_flag = !key.isEmpty();
|
||||
uint32_t color = XmlUtil::getUIntAttr( node, "line_color", 0 );
|
||||
|
||||
object->setLineColorNode( ColorNode( field_flag, color, key ) );
|
||||
}
|
||||
parseLineAttrs( node, object );
|
||||
|
||||
/* fill attrs */
|
||||
{
|
||||
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
||||
bool field_flag = !key.isEmpty();
|
||||
uint32_t color = XmlUtil::getUIntAttr( node, "fill_color", 0 );
|
||||
|
||||
object->setFillColorNode( ColorNode( field_flag, color, key ) );
|
||||
}
|
||||
parseFillAttrs( node, object );
|
||||
|
||||
/* affine attrs */
|
||||
parseAffineAttrs( node, object );
|
||||
@@ -382,31 +367,16 @@ namespace glabels
|
||||
|
||||
|
||||
/* position attrs */
|
||||
object->setX0( XmlUtil::getLengthAttr( node, "x", 0.0 ) );
|
||||
object->setY0( XmlUtil::getLengthAttr( node, "y", 0.0 ) );
|
||||
parsePositionAttrs( node, object );
|
||||
|
||||
/* size attrs */
|
||||
object->setW( XmlUtil::getLengthAttr( node, "w", 0 ) );
|
||||
object->setH( XmlUtil::getLengthAttr( node, "h", 0 ) );
|
||||
parseSizeAttrs( node, object );
|
||||
|
||||
/* line attrs */
|
||||
object->setLineWidth( XmlUtil::getLengthAttr( node, "line_width", 1.0 ) );
|
||||
{
|
||||
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
||||
bool field_flag = !key.isEmpty();
|
||||
uint32_t color = XmlUtil::getUIntAttr( node, "line_color", 0 );
|
||||
|
||||
object->setLineColorNode( ColorNode( field_flag, color, key ) );
|
||||
}
|
||||
parseLineAttrs( node, object );
|
||||
|
||||
/* fill attrs */
|
||||
{
|
||||
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
||||
bool field_flag = !key.isEmpty();
|
||||
uint32_t color = XmlUtil::getUIntAttr( node, "fill_color", 0 );
|
||||
|
||||
object->setFillColorNode( ColorNode( field_flag, color, key ) );
|
||||
}
|
||||
parseFillAttrs( node, object );
|
||||
|
||||
/* affine attrs */
|
||||
parseAffineAttrs( node, object );
|
||||
@@ -425,22 +395,14 @@ namespace glabels
|
||||
|
||||
|
||||
/* position attrs */
|
||||
object->setX0( XmlUtil::getLengthAttr( node, "x", 0.0 ) );
|
||||
object->setY0( XmlUtil::getLengthAttr( node, "y", 0.0 ) );
|
||||
parsePositionAttrs( node, object );
|
||||
|
||||
/* size attrs */
|
||||
/* size attrs of line */
|
||||
object->setW( XmlUtil::getLengthAttr( node, "dx", 0 ) );
|
||||
object->setH( XmlUtil::getLengthAttr( node, "dy", 0 ) );
|
||||
|
||||
/* line attrs */
|
||||
object->setLineWidth( XmlUtil::getLengthAttr( node, "line_width", 1.0 ) );
|
||||
{
|
||||
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
||||
bool field_flag = !key.isEmpty();
|
||||
uint32_t color = XmlUtil::getUIntAttr( node, "line_color", 0 );
|
||||
|
||||
object->setLineColorNode( ColorNode( field_flag, color, key ) );
|
||||
}
|
||||
parseLineAttrs( node, object );
|
||||
|
||||
/* affine attrs */
|
||||
parseAffineAttrs( node, object );
|
||||
@@ -459,33 +421,29 @@ namespace glabels
|
||||
|
||||
|
||||
/* position attrs */
|
||||
object->setX0( XmlUtil::getLengthAttr( node, "x", 0.0 ) );
|
||||
object->setY0( XmlUtil::getLengthAttr( node, "y", 0.0 ) );
|
||||
parsePositionAttrs( node, object );
|
||||
|
||||
/* size attrs */
|
||||
object->setW( XmlUtil::getLengthAttr( node, "w", 0 ) );
|
||||
object->setH( XmlUtil::getLengthAttr( node, "h", 0 ) );
|
||||
parseSizeAttrs( node, object );
|
||||
|
||||
/* file attrs */
|
||||
{
|
||||
QString key = XmlUtil::getStringAttr( node, "src_field", "" );
|
||||
bool field_flag = !key.isEmpty();
|
||||
QString filename = XmlUtil::getStringAttr( node, "src", "" );
|
||||
QString key = XmlUtil::getStringAttr( node, "src_field", "" );
|
||||
bool field_flag = !key.isEmpty();
|
||||
QString filename = XmlUtil::getStringAttr( node, "src", "" );
|
||||
|
||||
if ( field_flag )
|
||||
if ( field_flag )
|
||||
{
|
||||
object->setFilenameNode( TextNode( true, key ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( data.hasImage( filename ) )
|
||||
{
|
||||
object->setFilenameNode( TextNode( true, key ) );
|
||||
object->setImage( filename, data.getImage( filename ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( data.hasImage( filename ) )
|
||||
{
|
||||
object->setImage( filename, data.getImage( filename ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
object->setFilenameNode( TextNode( false, filename ) );
|
||||
}
|
||||
object->setFilenameNode( TextNode( false, filename ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,21 +471,17 @@ namespace glabels
|
||||
|
||||
|
||||
/* position attrs */
|
||||
object->setX0( XmlUtil::getLengthAttr( node, "x", 0.0 ) );
|
||||
object->setY0( XmlUtil::getLengthAttr( node, "y", 0.0 ) );
|
||||
parsePositionAttrs( node, object );
|
||||
|
||||
/* size attrs */
|
||||
object->setW( XmlUtil::getLengthAttr( node, "w", 0 ) );
|
||||
object->setH( XmlUtil::getLengthAttr( node, "h", 0 ) );
|
||||
parseSizeAttrs( node, object );
|
||||
|
||||
/* color attr */
|
||||
{
|
||||
QString key = XmlUtil::getStringAttr( node, "color_field", "" );
|
||||
bool field_flag = !key.isEmpty();
|
||||
uint32_t color = XmlUtil::getUIntAttr( node, "color", 0 );
|
||||
QString key = XmlUtil::getStringAttr( node, "color_field", "" );
|
||||
bool field_flag = !key.isEmpty();
|
||||
uint32_t color = XmlUtil::getUIntAttr( node, "color", 0 );
|
||||
|
||||
object->setTextColorNode( ColorNode( field_flag, color, key ) );
|
||||
}
|
||||
object->setTextColorNode( ColorNode( field_flag, color, key ) );
|
||||
|
||||
/* font attrs */
|
||||
object->setFontFamily( XmlUtil::getStringAttr( node, "font_family", "Sans" ) );
|
||||
@@ -582,6 +536,46 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmlLabelParser::parsePositionAttrs( const QDomElement &node, LabelModelObject* object )
|
||||
{
|
||||
object->setX0( XmlUtil::getLengthAttr( node, "x", 0.0 ) );
|
||||
object->setY0( XmlUtil::getLengthAttr( node, "y", 0.0 ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmlLabelParser::parseSizeAttrs( const QDomElement &node, LabelModelObject* object )
|
||||
{
|
||||
object->setW( XmlUtil::getLengthAttr( node, "w", 0 ) );
|
||||
object->setH( XmlUtil::getLengthAttr( node, "h", 0 ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmlLabelParser::parseLineAttrs( const QDomElement &node, LabelModelObject* object )
|
||||
{
|
||||
object->setLineWidth( XmlUtil::getLengthAttr( node, "line_width", 1.0 ) );
|
||||
|
||||
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
||||
bool field_flag = !key.isEmpty();
|
||||
uint32_t color = XmlUtil::getUIntAttr( node, "line_color", 0 );
|
||||
|
||||
object->setLineColorNode( ColorNode( field_flag, color, key ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmlLabelParser::parseFillAttrs( const QDomElement &node, LabelModelObject* object )
|
||||
{
|
||||
QString key = XmlUtil::getStringAttr( node, "line_color_field", "" );
|
||||
bool field_flag = !key.isEmpty();
|
||||
uint32_t color = XmlUtil::getUIntAttr( node, "fill_color", 0 );
|
||||
|
||||
object->setFillColorNode( ColorNode( field_flag, color, key ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XmlLabelParser::parseAffineAttrs( const QDomElement &node, LabelModelObject* object )
|
||||
{
|
||||
|
||||
@@ -64,6 +64,10 @@ namespace glabels
|
||||
static LabelModelBarcodeObject* parseObjectBarcodeNode( const QDomElement &node );
|
||||
static LabelModelTextObject* parseObjectTextNode( const QDomElement &node );
|
||||
static QString parsePNode( const QDomElement &node );
|
||||
static void parsePositionAttrs( const QDomElement &node, LabelModelObject* object );
|
||||
static void parseSizeAttrs( const QDomElement &node, LabelModelObject* object );
|
||||
static void parseLineAttrs( const QDomElement &node, LabelModelObject* object );
|
||||
static void parseFillAttrs( const QDomElement &node, LabelModelObject* object );
|
||||
static void parseAffineAttrs( const QDomElement &node, LabelModelObject* object );
|
||||
static void parseShadowAttrs( const QDomElement &node, LabelModelObject* object );
|
||||
static void parseMergeNode( const QDomElement &node, LabelModel* label );
|
||||
|
||||
Reference in New Issue
Block a user