Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit d741afb

Browse files
committed
Updates after feedback #2
1 parent 8703027 commit d741afb

File tree

3 files changed

+197
-125
lines changed

3 files changed

+197
-125
lines changed

engine/src/fields.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ Exec_stat MCField::gettextatts(uint4 parid, Properties which, MCExecPoint &ep, M
11931193

11941194
// MW-2012-02-14: [[ FontRefs ]] Previously this process would open/close the
11951195
// paragraph, but this is unnecessary as it doesn't rely on anything active.
1196-
if (sptr->getatts(si, ei, t_text_style, tname, tsize, tstyle, tcolor, tbcolor, tshift, tspecstyle, tmixed))
1196+
if (sptr->getatts(si, ei, which, t_text_style, tname, tsize, tstyle, tcolor, tbcolor, tshift, tspecstyle, tmixed))
11971197
{
11981198
tspecstyle = MCF_istextstyleset(tstyle, t_text_style);
11991199

@@ -1261,32 +1261,36 @@ Exec_stat MCField::gettextatts(uint4 parid, Properties which, MCExecPoint &ep, M
12611261
ei = 0;
12621262
}
12631263
while (ei > 0);
1264+
1265+
if (!has)
1266+
{
1267+
if (effective)
1268+
{
1269+
// MW-2011-11-23: [[ Array TextStyle ]] Make sure we call the correct
1270+
// method for textStyle (its now an array property).
1271+
if (which != P_TEXT_STYLE)
1272+
return getprop(parid, which, ep, effective);
1273+
else
1274+
return getarrayprop(parid, which, ep, index, effective);
1275+
}
1276+
ep.clear();
1277+
return ES_NORMAL;
1278+
}
12641279

12651280
Exec_stat stat = ES_NORMAL;
12661281
switch (which)
12671282
{
12681283
case P_FORE_COLOR:
12691284
if (color == NULL)
1270-
{
1271-
// PM-2014-04-07: [[Bug 11933]] Make sure that effective textColor will not return empty value for styled text
1272-
if (effective)
1273-
return getprop(parid, which, ep, effective);
1274-
ep.clear();
1275-
}
1276-
1285+
ep.clear();
12771286
else if (mixed & MIXED_COLORS)
12781287
ep.setstaticcstring(MCmixedstring);
12791288
else
12801289
ep.setcolor(*color);
12811290
break;
12821291
case P_BACK_COLOR:
12831292
if (bcolor == NULL)
1284-
{
1285-
// PM-2014-04-07: [[Bug 11933]] Make sure that effective textColor will not return empty value for styled text
1286-
if (effective)
1287-
return getprop(parid, which, ep, effective);
12881293
ep.clear();
1289-
}
12901294
else if (mixed & MIXED_COLORS)
12911295
ep.setstaticcstring(MCmixedstring);
12921296
else

engine/src/paragraf.cpp

Lines changed: 179 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,15 +1122,22 @@ void MCParagraph::draw(MCDC *dc, int2 x, int2 y, uint2 fixeda,
11221122
}
11231123
}
11241124

1125-
Boolean MCParagraph::getatts(uint2 si, uint2 ei, Font_textstyle textstyle, const char *&fname,
1125+
// PM-2014-04-10: [[Bug 11933]] Added a "Properties which" parameter. Previously this function was
1126+
// returning True if any of the properties are set - rather than just the one that is being processed
1127+
// (as specified by which). This had as a result that when the "effective" property of a chunk was queried,
1128+
// empty was returned if the specified property was not set, instead of the nearest parent's property which has it set.
1129+
Boolean MCParagraph::getatts(uint2 si, uint2 ei, Properties which, Font_textstyle textstyle, const char *&fname,
11261130
uint2 &size, uint2 &fstyle, const MCColor *&color,
11271131
const MCColor *&backcolor, int2 &shift, bool& specstyle,
11281132
uint2 &mixed)
1129-
{
1130-
Boolean ahas = False;
1131-
Boolean chas = False;
1132-
Boolean bchas = False;
1133-
Boolean shas = False;
1133+
{
1134+
Boolean has_font = False;
1135+
Boolean has_size = False;
1136+
Boolean has_style = False;
1137+
Boolean has_forecolor = False;
1138+
Boolean has_backcolor = False;
1139+
Boolean has_shift = False;
1140+
11341141
const char *defname = fname;
11351142
uint2 defsize = size;
11361143
uint2 defstyle = fstyle;
@@ -1164,115 +1171,176 @@ Boolean MCParagraph::getatts(uint2 si, uint2 ei, Font_textstyle textstyle, const
11641171

11651172
do
11661173
{
1167-
const char *tname;
1168-
uint2 tsize;
1169-
uint2 tstyle;
1170-
bool tspecstyle;
1171-
1172-
// MW-2012-02-17: [[ SplitTextAttrs ]] Get any font attrs the block has.
1173-
if (bptr -> gettextfont(tname))
1174-
{
1175-
if (bptr == startptr)
1176-
fname = tname;
1177-
ahas = True;
1178-
}
1179-
else
1180-
tname = defname;
1181-
1182-
if (bptr -> gettextsize(tsize))
1183-
{
1184-
if (bptr == startptr)
1185-
size = tsize;
1186-
ahas = True;
1187-
}
1188-
else
1189-
tsize = defsize;
1190-
1191-
if (bptr -> gettextstyle(tstyle))
1192-
{
1193-
tspecstyle = MCF_istextstyleset(tstyle, textstyle);
1194-
if (bptr == startptr)
1195-
{
1196-
fstyle = tstyle;
1197-
specstyle = tspecstyle;
1198-
}
1199-
ahas = True;
1200-
}
1201-
else
1202-
tstyle = defstyle, tspecstyle = defspecstyle;
1203-
1204-
if (ahas)
1205-
{
1206-
if (fname != tname)
1207-
mixed |= MIXED_NAMES;
1208-
if (tsize != size)
1209-
mixed |= MIXED_SIZES;
1210-
if (tstyle != fstyle)
1211-
mixed |= MIXED_STYLES;
1212-
if (tspecstyle != specstyle)
1213-
mixed |= MIXED_SPEC_STYLE;
1214-
}
1215-
const MCColor *tcolor = color;
1216-
if (bptr->getcolor(tcolor))
1217-
if (chas)
1218-
{
1219-
if (tcolor->red != color->red || tcolor->green != color->green
1220-
|| tcolor->blue != color->blue)
1221-
mixed |= MIXED_COLORS;
1222-
}
1223-
else
1224-
{
1225-
if (bptr != startptr)
1226-
mixed |= MIXED_COLORS;
1227-
chas = True;
1228-
color = tcolor;
1229-
}
1230-
else
1231-
if (chas)
1232-
mixed |= MIXED_COLORS;
1233-
1234-
const MCColor *btcolor = color;
1235-
if (bptr->getbackcolor(btcolor))
1236-
if (bchas)
1237-
{
1238-
if (btcolor->red != backcolor->red
1239-
|| btcolor->green != backcolor->green
1240-
|| btcolor->blue != backcolor->blue)
1241-
mixed |= MIXED_COLORS;
1242-
}
1243-
else
1244-
{
1245-
if (bptr != startptr)
1246-
mixed |= MIXED_COLORS;
1247-
bchas = True;
1248-
backcolor = btcolor;
1249-
}
1250-
else
1251-
if (bchas)
1252-
mixed |= MIXED_COLORS;
1253-
int2 tshift;
1254-
if (bptr->getshift(tshift))
1255-
if (shas)
1256-
{
1257-
if (tshift != shift)
1258-
mixed |= MIXED_SHIFT;
1259-
}
1260-
else
1261-
{
1262-
if (bptr != startptr)
1263-
mixed |= MIXED_SHIFT;
1264-
shas = True;
1265-
shift = tshift;
1266-
}
1267-
else
1268-
if (shas)
1269-
mixed |= MIXED_SHIFT;
1174+
switch (which)
1175+
{
1176+
case P_TEXT_FONT:
1177+
{
1178+
const char *tname;
1179+
if (bptr -> gettextfont(tname))
1180+
{
1181+
if (bptr == startptr)
1182+
fname = tname;
1183+
has_font = True;
1184+
}
1185+
else
1186+
tname = defname;
1187+
1188+
if (has_font)
1189+
if (fname != tname)
1190+
mixed |= MIXED_NAMES;
1191+
}
1192+
break;
1193+
1194+
case P_TEXT_SIZE:
1195+
{
1196+
uint2 tsize;
1197+
if (bptr -> gettextsize(tsize))
1198+
{
1199+
if (bptr == startptr)
1200+
size = tsize;
1201+
has_size = True;
1202+
}
1203+
else
1204+
tsize = defsize;
1205+
1206+
if (has_size)
1207+
if (tsize != size)
1208+
mixed |= MIXED_SIZES;
1209+
}
1210+
break;
1211+
1212+
case P_TEXT_STYLE:
1213+
{
1214+
uint2 tstyle;
1215+
bool tspecstyle;
1216+
if (bptr -> gettextstyle(tstyle))
1217+
{
1218+
tspecstyle = MCF_istextstyleset(tstyle, textstyle);
1219+
if (bptr == startptr)
1220+
{
1221+
fstyle = tstyle;
1222+
specstyle = tspecstyle;
1223+
}
1224+
has_style = True;
1225+
}
1226+
else
1227+
tstyle = defstyle, tspecstyle = defspecstyle;
1228+
1229+
if (has_style)
1230+
{
1231+
if (tstyle != fstyle)
1232+
mixed |= MIXED_STYLES;
1233+
if (tspecstyle != specstyle)
1234+
mixed |= MIXED_SPEC_STYLE;
1235+
}
1236+
}
1237+
break;
1238+
1239+
case P_FORE_COLOR:
1240+
{
1241+
const MCColor *tcolor = color;
1242+
if (bptr->getcolor(tcolor))
1243+
if (has_forecolor)
1244+
{
1245+
if (tcolor->red != color->red || tcolor->green != color->green
1246+
|| tcolor->blue != color->blue)
1247+
mixed |= MIXED_COLORS;
1248+
}
1249+
else
1250+
{
1251+
if (bptr != startptr)
1252+
mixed |= MIXED_COLORS;
1253+
has_forecolor = True;
1254+
color = tcolor;
1255+
}
1256+
else
1257+
if (has_forecolor)
1258+
mixed |= MIXED_COLORS;
1259+
}
1260+
break;
1261+
1262+
case P_BACK_COLOR:
1263+
{
1264+
const MCColor *btcolor = color;
1265+
if (bptr->getbackcolor(btcolor))
1266+
if (has_backcolor)
1267+
{
1268+
if (btcolor->red != backcolor->red
1269+
|| btcolor->green != backcolor->green
1270+
|| btcolor->blue != backcolor->blue)
1271+
mixed |= MIXED_COLORS;
1272+
}
1273+
else
1274+
{
1275+
if (bptr != startptr)
1276+
mixed |= MIXED_COLORS;
1277+
has_backcolor = True;
1278+
backcolor = btcolor;
1279+
}
1280+
else
1281+
if (has_backcolor)
1282+
mixed |= MIXED_COLORS;
1283+
}
1284+
break;
1285+
1286+
case P_TEXT_SHIFT:
1287+
{
1288+
int2 tshift;
1289+
if (bptr->getshift(tshift))
1290+
if (has_shift)
1291+
{
1292+
if (tshift != shift)
1293+
mixed |= MIXED_SHIFT;
1294+
}
1295+
else
1296+
{
1297+
if (bptr != startptr)
1298+
mixed |= MIXED_SHIFT;
1299+
has_shift = True;
1300+
shift = tshift;
1301+
}
1302+
else
1303+
if (has_shift)
1304+
mixed |= MIXED_SHIFT;
1305+
}
1306+
break;
1307+
1308+
default:
1309+
break;
1310+
1311+
1312+
1313+
}
1314+
12701315
bptr->getindex(i, l);
12711316
bptr = bptr->next();
1272-
}
1317+
}
12731318
while (i + l < ei);
12741319

1275-
return ahas || chas || bchas || shas;
1320+
switch (which)
1321+
{
1322+
case P_TEXT_FONT:
1323+
return has_font;
1324+
1325+
case P_TEXT_SIZE:
1326+
return has_size;
1327+
1328+
case P_TEXT_STYLE:
1329+
return has_style;
1330+
1331+
case P_FORE_COLOR:
1332+
return has_forecolor;
1333+
1334+
case P_BACK_COLOR:
1335+
return has_backcolor;
1336+
1337+
case P_TEXT_SHIFT:
1338+
return has_shift;
1339+
1340+
default:
1341+
return False;
1342+
}
1343+
12761344
}
12771345

12781346
void MCParagraph::setatts(uint2 si, uint2 ei, Properties p, void *value, bool p_from_html)

engine/src/paragraf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ class MCParagraph : public MCDLlist
661661
// Called by:
662662
// MCField::finsert (for charset purposes)
663663
// MCField::gettextatts
664-
Boolean getatts(uint2 si, uint2 ei, Font_textstyle spec_style, const char *&fname, uint2 &size,
664+
Boolean getatts(uint2 si, uint2 ei, Properties which, Font_textstyle spec_style, const char *&fname, uint2 &size,
665665
uint2 &style, const MCColor *&color,
666666
const MCColor *&backcolor, int2 &shift, bool& specstyle, uint2 &mixed);
667667

0 commit comments

Comments
 (0)