MCPcopy Create free account
hub / github.com/KDE/labplot / readFill

Method readFill

src/3rdparty/QXlsx/source/xlsxstyles.cpp:905–971  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

903}
904
905bool Styles::readFill(QXmlStreamReader &reader, Format &fill)
906{
907 Q_ASSERT(reader.name() == QLatin1String("fill"));
908
909 static const QMap<QString, Format::FillPattern> patternValues = {
910 {QStringLiteral("none"), Format::PatternNone},
911 {QStringLiteral("solid"), Format::PatternSolid},
912 {QStringLiteral("mediumGray"), Format::PatternMediumGray},
913 {QStringLiteral("darkGray"), Format::PatternDarkGray},
914 {QStringLiteral("lightGray"), Format::PatternLightGray},
915 {QStringLiteral("darkHorizontal"), Format::PatternDarkHorizontal},
916 {QStringLiteral("darkVertical"), Format::PatternDarkVertical},
917 {QStringLiteral("darkDown"), Format::PatternDarkDown},
918 {QStringLiteral("darkUp"), Format::PatternDarkUp},
919 {QStringLiteral("darkGrid"), Format::PatternDarkGrid},
920 {QStringLiteral("darkTrellis"), Format::PatternDarkTrellis},
921 {QStringLiteral("lightHorizontal"), Format::PatternLightHorizontal},
922 {QStringLiteral("lightVertical"), Format::PatternLightVertical},
923 {QStringLiteral("lightDown"), Format::PatternLightDown},
924 {QStringLiteral("lightUp"), Format::PatternLightUp},
925 {QStringLiteral("lightTrellis"), Format::PatternLightTrellis},
926 {QStringLiteral("gray125"), Format::PatternGray125},
927 {QStringLiteral("gray0625"), Format::PatternGray0625},
928 {QStringLiteral("lightGrid"), Format::PatternLightGrid}
929 };
930
931 while (!reader.atEnd() && !(reader.tokenType() == QXmlStreamReader::EndElement && reader.name() == QLatin1String("fill"))) {
932 reader.readNextStartElement();
933 if (reader.tokenType() == QXmlStreamReader::StartElement) {
934 if (reader.name() == QLatin1String("patternFill")) {
935 const auto& attributes = reader.attributes();
936 if (attributes.hasAttribute(QLatin1String("patternType"))) {
937 const auto& it = patternValues.constFind(attributes.value(QLatin1String("patternType")).toString());
938 fill.setFillPattern(it != patternValues.constEnd() ? it.value() : Format::PatternNone);
939
940 //parse foreground and background colors if they exist
941 while (!reader.atEnd() && !(reader.tokenType() == QXmlStreamReader::EndElement && reader.name() == QLatin1String("patternFill"))) {
942 reader.readNextStartElement();
943 if (reader.tokenType() == QXmlStreamReader::StartElement) {
944 if (reader.name() == QLatin1String("fgColor")) {
945 XlsxColor c;
946 if ( c.loadFromXml(reader) )
947 {
948 if (fill.fillPattern() == Format::PatternSolid)
949 fill.setProperty(FormatPrivate::P_Fill_BgColor, c);
950 else
951 fill.setProperty(FormatPrivate::P_Fill_FgColor, c);
952 }
953 } else if (reader.name() == QLatin1String("bgColor")) {
954 XlsxColor c;
955 if ( c.loadFromXml(reader) )
956 {
957 if (fill.fillPattern() == Format::PatternSolid)
958 fill.setProperty(FormatPrivate::P_Fill_FgColor, c);
959 else
960 fill.setProperty(FormatPrivate::P_Fill_BgColor, c);
961 }
962 }

Callers

nothing calls this directly

Calls 8

atEndMethod · 0.80
setFillPatternMethod · 0.80
fillPatternMethod · 0.80
nameMethod · 0.45
toStringMethod · 0.45
valueMethod · 0.45
loadFromXmlMethod · 0.45
setPropertyMethod · 0.45

Tested by

no test coverage detected