@@ -38,6 +38,8 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3838
3939#include " exec-interface.h"
4040
41+ #include " stackfileformat.h"
42+
4143#define IMAGE_BLOCK_LEADING 2
4244static MCRectangle
4345MCBlockMakeRectangle (double x, double y,
@@ -181,7 +183,7 @@ IO_stat MCBlock::load(IO_handle stream, uint32_t version, bool is_ext)
181183 // is a font record to read.
182184 if (flags & F_FONT)
183185 {
184- if (version > 1300 )
186+ if (version > kMCStackFileFormatVersion_1_3 )
185187 {
186188 uint2 t_font_index;
187189 if ((stat = IO_read_uint2 (&t_font_index, stream)) != IO_NORMAL)
@@ -242,7 +244,7 @@ IO_stat MCBlock::load(IO_handle stream, uint32_t version, bool is_ext)
242244 atts->backcolor = new MCColor;
243245 if ((stat = IO_read_mccolor (*atts->backcolor , stream)) != IO_NORMAL)
244246 return checkloadstat (stat);
245- if (version < 2000 || flags & F_HAS_BACK_COLOR_NAME)
247+ if (version < kMCStackFileFormatVersion_2_0 || flags & F_HAS_BACK_COLOR_NAME)
246248 {
247249 // MW-2012-01-06: [[ Block Changes ]] We no longer use the backcolor name
248250 // so load, delete and unset the flag.
@@ -264,15 +266,15 @@ IO_stat MCBlock::load(IO_handle stream, uint32_t version, bool is_ext)
264266 if (flags & F_HAS_LINK)
265267 {
266268 // MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
267- if ((stat = IO_read_stringref_new (atts->linktext , stream, version >= 7000 )) != IO_NORMAL)
269+ if ((stat = IO_read_stringref_new (atts->linktext , stream, version >= kMCStackFileFormatVersion_7_0 )) != IO_NORMAL)
268270 return checkloadstat (stat);
269271 /* UNCHECKED */ MCValueInterAndRelease (atts -> linktext, atts -> linktext);
270272 }
271273
272274 if (flags & F_HAS_IMAGE)
273275 {
274276 // MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
275- if ((stat = IO_read_stringref_new (atts->imagesource , stream, version >= 7000 )) != IO_NORMAL)
277+ if ((stat = IO_read_stringref_new (atts->imagesource , stream, version >= kMCStackFileFormatVersion_7_0 )) != IO_NORMAL)
276278 return checkloadstat (stat);
277279 /* UNCHECKED */ MCValueInterAndRelease (atts -> imagesource, atts -> imagesource);
278280 }
@@ -282,7 +284,7 @@ IO_stat MCBlock::load(IO_handle stream, uint32_t version, bool is_ext)
282284 if (flags & F_HAS_METADATA)
283285 {
284286 // MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
285- if ((stat = IO_read_stringref_new (atts->metadata , stream, version >= 7000 )) != IO_NORMAL)
287+ if ((stat = IO_read_stringref_new (atts->metadata , stream, version >= kMCStackFileFormatVersion_7_0 )) != IO_NORMAL)
286288 return checkloadstat (stat);
287289 /* UNCHECKED */ MCValueInterAndRelease (atts -> metadata, atts -> metadata);
288290 }
@@ -340,7 +342,7 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part, uint32_t p_version)
340342 // MW-2012-03-04: [[ StackFile5500 ]] If the block has metadata and 5.5 stackfile
341343 // format has been requested then this is an extended block.
342344 bool t_is_ext;
343- if (p_version >= 5500 && getflag (F_HAS_METADATA))
345+ if (p_version >= kMCStackFileFormatVersion_5_5 && getflag (F_HAS_METADATA))
344346 t_is_ext = true ;
345347 else
346348 t_is_ext = false ;
@@ -369,7 +371,7 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part, uint32_t p_version)
369371
370372 // The "has unicode" flag depends on whether the paragraph is native
371373 bool t_is_unicode;
372- if (p_version < 7000 && MCStringIsNative (parent->GetInternalStringRef ()))
374+ if (p_version < kMCStackFileFormatVersion_7_0 && MCStringIsNative (parent->GetInternalStringRef ()))
373375 {
374376 t_is_unicode = false ;
375377 flags &= ~F_HAS_UNICODE;
@@ -381,7 +383,7 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part, uint32_t p_version)
381383 }
382384
383385 // SN-2014-12-04: [[ Bug 14149 ]] Add the F_HAS_TAB flag, for legacy saving
384- if (p_version < 7000 )
386+ if (p_version < kMCStackFileFormatVersion_7_0 )
385387 {
386388 if (segment && segment != segment -> next ())
387389 flags |= F_HAS_TAB;
@@ -438,11 +440,11 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part, uint32_t p_version)
438440 // strings.
439441 // MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
440442 if (flags & F_HAS_LINK)
441- if ((stat = IO_write_stringref_new (atts->linktext , stream, p_version >= 7000 )) != IO_NORMAL)
443+ if ((stat = IO_write_stringref_new (atts->linktext , stream, p_version >= kMCStackFileFormatVersion_7_0 )) != IO_NORMAL)
442444 return stat;
443445 // MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
444446 if (flags & F_HAS_IMAGE)
445- if ((stat = IO_write_stringref_new (atts->imagesource , stream, p_version >= 7000 )) != IO_NORMAL)
447+ if ((stat = IO_write_stringref_new (atts->imagesource , stream, p_version >= kMCStackFileFormatVersion_7_0 )) != IO_NORMAL)
446448 return stat;
447449
448450 // MW-2012-03-04: [[ StackFile5500 ]] If this is an extended block then emit the
@@ -451,7 +453,7 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part, uint32_t p_version)
451453 {
452454 // MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
453455 if (flags & F_HAS_METADATA)
454- if ((stat = IO_write_stringref_new (atts -> metadata, stream, p_version >= 7000 )) != IO_NORMAL)
456+ if ((stat = IO_write_stringref_new (atts -> metadata, stream, p_version >= kMCStackFileFormatVersion_7_0 )) != IO_NORMAL)
455457 return stat;
456458 }
457459
@@ -2073,7 +2075,7 @@ uint32_t measure_stringref(MCStringRef p_string, uint32_t p_version)
20732075 uint32_t t_additional_bytes = 0 ;
20742076
20752077
2076- if (p_version < 7000 )
2078+ if (p_version < kMCStackFileFormatVersion_7_0 )
20772079 t_encoding = kMCStringEncodingNative ;
20782080 else
20792081 t_encoding = kMCStringEncodingUTF8 ;
@@ -2084,7 +2086,7 @@ uint32_t measure_stringref(MCStringRef p_string, uint32_t p_version)
20842086 uint32_t t_length;
20852087 t_length = MCDataGetLength (*t_data);
20862088
2087- if (p_version < 7000 )
2089+ if (p_version < kMCStackFileFormatVersion_7_0 )
20882090 {
20892091 // Full string is written in 5.5 format:
20902092 // - length is written as a uint2
0 commit comments