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) if (name() == ML::TagPieceLabel)
{ {
QXmlStreamAttributes attribs = attributes(); ReadPieceLabel(piece);
piece->SetPieceLabelRect(StringToPath(ReadAttributeEmptyString(attribs, ML::AttrShape)));
piece->SetPieceLabelData(ReadLabelLines());
} }
else if (name() == ML::TagPatternLabel) else if (name() == ML::TagPatternLabel)
{ {
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(); QXmlStreamAttributes attribs = attributes();
piece->SetPatternLabelRect(StringToPath(ReadAttributeEmptyString(attribs, ML::AttrShape))); piece->SetPatternLabelRect(StringToPath(ReadAttributeEmptyString(attribs, ML::AttrShape)));
while (readNextStartElement())
{
if (name() == ML::TagLines)
{
piece->SetPatternLabelData(ReadLabelLines()); piece->SetPatternLabelData(ReadLabelLines());
} }
else else
@ -695,7 +733,7 @@ void VPLayoutFileReader::ReadLabels(const VPPiecePtr &piece)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPLayoutFileReader::ReadLabelLines() -> VTextManager auto VPLayoutFileReader::ReadLabelLines() -> VTextManager
{ {
AssertRootTag(ML::TagLabels); AssertRootTag(ML::TagLines);
VTextManager text; VTextManager text;
QVector<TextLine> lines; QVector<TextLine> lines;

View File

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

View File

@ -128,13 +128,18 @@
<xs:sequence> <xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded"> <xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute type="xs:string" name="font" use="required"/> <xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="bold" use="optional"/> <xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" 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="alignment" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="fontSize" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
<xs:attribute type="xs:string" name="font"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
@ -149,13 +154,18 @@
<xs:sequence> <xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded"> <xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute type="xs:string" name="font" use="required"/> <xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="bold" use="optional"/> <xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" 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="alignment" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="fontSize" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
<xs:attribute type="xs:string" name="font"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
@ -285,13 +295,18 @@
<xs:sequence> <xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded"> <xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute type="xs:string" name="font" use="required"/> <xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="bold" use="optional"/> <xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/> <xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="AlignmentType" name="alignment" 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:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
<xs:attribute type="xs:string" name="font"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
@ -306,13 +321,18 @@
<xs:sequence> <xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded"> <xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute type="xs:string" name="font" use="required"/> <xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:boolean" name="bold" use="optional"/> <xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/> <xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="AlignmentType" name="alignment" 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:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
<xs:attribute type="xs:string" name="font"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>