Fix reading piece labels.

This commit is contained in:
Roman Telezhynskyi 2021-09-04 16:01:26 +03:00
parent d21546e397
commit 88508b102e
3 changed files with 87 additions and 27 deletions

View File

@ -672,16 +672,54 @@ void VPLayoutFileReader::ReadLabels(const VPPiecePtr &piece)
{
if (name() == ML::TagPieceLabel)
{
QXmlStreamAttributes attribs = attributes();
piece->SetPieceLabelRect(StringToPath(ReadAttributeEmptyString(attribs, ML::AttrShape)));
piece->SetPieceLabelData(ReadLabelLines());
ReadPieceLabel(piece);
}
else if (name() == ML::TagPatternLabel)
{
QXmlStreamAttributes attribs = attributes();
piece->SetPatternLabelRect(StringToPath(ReadAttributeEmptyString(attribs, ML::AttrShape)));
ReadPatternLabel(piece);
}
else
{
qCDebug(MLReader, "Ignoring tag %s", qUtf8Printable(name().toString()));
skipCurrentElement();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadPieceLabel(const VPPiecePtr &piece)
{
AssertRootTag(ML::TagPieceLabel);
QXmlStreamAttributes attribs = attributes();
piece->SetPieceLabelRect(StringToPath(ReadAttributeEmptyString(attribs, ML::AttrShape)));
while (readNextStartElement())
{
if (name() == ML::TagLines)
{
piece->SetPieceLabelData(ReadLabelLines());
}
else
{
qCDebug(MLReader, "Ignoring tag %s", qUtf8Printable(name().toString()));
skipCurrentElement();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadPatternLabel(const VPPiecePtr &piece)
{
AssertRootTag(ML::TagPatternLabel);
QXmlStreamAttributes attribs = attributes();
piece->SetPatternLabelRect(StringToPath(ReadAttributeEmptyString(attribs, ML::AttrShape)));
while (readNextStartElement())
{
if (name() == ML::TagLines)
{
piece->SetPatternLabelData(ReadLabelLines());
}
else
@ -695,7 +733,7 @@ void VPLayoutFileReader::ReadLabels(const VPPiecePtr &piece)
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutFileReader::ReadLabelLines() -> VTextManager
{
AssertRootTag(ML::TagLabels);
AssertRootTag(ML::TagLines);
VTextManager text;
QVector<TextLine> lines;

View File

@ -70,6 +70,8 @@ private:
void ReadMarkers(const VPPiecePtr &piece);
auto ReadMarker() -> VLayoutPlaceLabel;
void ReadLabels(const VPPiecePtr &piece);
void ReadPieceLabel(const VPPiecePtr &piece);
void ReadPatternLabel(const VPPiecePtr &piece);
auto ReadLabelLines() -> VTextManager;
auto ReadLabelLine() -> TextLine;

View File

@ -127,14 +127,19 @@
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:string" name="font" use="required"/>
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="alignment" use="optional"/>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="alignment" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="fontSize" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="font"/>
</xs:complexType>
</xs:element>
</xs:sequence>
@ -148,14 +153,19 @@
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:string" name="font" use="required"/>
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="alignment" use="optional"/>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="alignment" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="fontSize" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="font"/>
</xs:complexType>
</xs:element>
</xs:sequence>
@ -284,14 +294,19 @@
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:string" name="font" use="required"/>
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="AlignmentType" name="alignment" use="optional"/>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="AlignmentType" name="alignment" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="fontSize" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="font"/>
</xs:complexType>
</xs:element>
</xs:sequence>
@ -305,14 +320,19 @@
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:string" name="font" use="required"/>
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="AlignmentType" name="alignment" use="optional"/>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="AlignmentType" name="alignment" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="fontSize" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="font"/>
</xs:complexType>
</xs:element>
</xs:sequence>