46 #define UNICODE_BOM_LITTLE_ENDIAN 0xFFFE 47 #define UNICODE_BOM_BIG_ENDIAN 0xFEFF 60 void MHEG5textPrint(
MHEG5Text *text,
char *out)
63 MHEG5visiblePrint(&text->visible, out);
66 if (text->originalFont.referenced || text->originalFont.ref.included.len)
69 MHEG_PRINT(out,
":OrigFont ");
70 MHEG5fontBodyPrint(text->originalFont, out);
74 if (text->originalFontAttributes.len)
77 MHEG_PRINT(out,
":FontAttributes ");
78 MHEG5stringPrint(text->originalFontAttributes, out);
99 if (text->characterSet)
102 MHEG_PRINT(out,
":CharacterSet ");
103 MHEG5intPrint(text->characterSet, out);
107 if (text->horizontalJustification != HJUSTIFICATION_START)
110 MHEG_PRINT(out,
":HJustification ");
111 switch (text->horizontalJustification)
113 case HJUSTIFICATION_END: MHEG_PRINT(out,
"end");
break;
114 case HJUSTIFICATION_CENTRE: MHEG_PRINT(out,
"centre");
break;
115 case HJUSTIFICATION_JUSTIFIED: MHEG_PRINT(out,
"justified");
break;
121 if (text->verticalJustification != VJUSTIFICATION_START)
124 MHEG_PRINT(out,
":VJustification ");
125 switch (text->verticalJustification)
127 case VJUSTIFICATION_END: MHEG_PRINT(out,
"end");
break;
128 case VJUSTIFICATION_CENTRE: MHEG_PRINT(out,
"centre");
break;
129 case VJUSTIFICATION_JUSTIFIED: MHEG_PRINT(out,
"justified");
break;
135 if (text->verticalLineOrientation)
138 MHEG_PRINT(out,
":LineOrientation vertical");
142 if (text->startCorner != 0)
145 MHEG_PRINT(out,
":StartCorner ");
146 switch (text->startCorner)
148 case 1: MHEG_PRINT(out,
"upper-right");
break;
149 case 2: MHEG_PRINT(out,
"lower-left");
break;
150 case 3: MHEG_PRINT(out,
"lower-right");
break;
156 if (!text->originalTextColour.indirect && text->originalTextColour.type)
159 MHEG_PRINT(out,
":TextColour ");
160 MHEG5colourPrint(text->originalTextColour, out);
164 if (!text->originalBackgroundColour.indirect && text->originalBackgroundColour.type)
167 MHEG_PRINT(out,
":BackgroundColour ");
168 MHEG5colourPrint(text->originalBackgroundColour, out);
172 if (text->textWrapping)
175 MHEG_PRINT(out,
":TextWrapping TRUE");
210 if (text->originalFont.referenced)
212 if (text->originalFont.ref.referenced.grp.len != 0)
222 MHEG5colourDestruct(&text->originalTextColour);
223 MHEG5colourDestruct(&text->originalBackgroundColour);
238 if (destination != NULL)
240 memset( destination, 0,
sizeof(
MHEG5Text));
241 destination->visible.ingredient.root.clazz = MHEG5TEXT;
245 destination->originalFont.referenced = source->originalFont.referenced;
246 if (source->originalFont.referenced)
248 if (source->originalFont.ref.referenced.grp.len != 0)
251 name.len = source->originalFont.ref.referenced.grp.len;
252 name.data = source->originalFont.ref.referenced.grp.ptr.name;
254 destination->originalFont.ref.referenced.grp.len = name.len;
255 destination->originalFont.ref.referenced.grp.ptr.name = name.data;
259 destination->originalFont.ref.referenced.grp.len = 0;
260 destination->originalFont.ref.referenced.grp.ptr.group = source->originalFont.ref.referenced.grp.ptr.group;
262 destination->originalFont.ref.referenced.id = source->originalFont.ref.referenced.id;
266 destination->originalFont.ref.included =
MHEG5stringCopy(source->originalFont.ref.included);
268 destination->originalFontAttributes =
MHEG5stringCopy(source->originalFontAttributes);
269 MHEG5genericCopy(&destination->originalTextColour, &source->originalTextColour);
270 MHEG5genericCopy(&destination->originalBackgroundColour, &source->originalBackgroundColour);
271 destination->characterSet = source->characterSet;
272 destination->horizontalJustification = source->horizontalJustification;
273 destination->verticalJustification = source->verticalJustification;
274 destination->verticalLineOrientation = source->verticalLineOrientation;
275 destination->startCorner = source->startCorner;
276 destination->textWrapping = source->textWrapping;
296 text->font.referenced = text->originalFont.referenced;
297 if (text->font.referenced)
299 if (text->originalFont.ref.referenced.grp.len != 0)
301 text->font.ref.referenced.grp = text->originalFont.ref.referenced.grp;
305 text->font.ref.referenced.grp.len = 0;
306 text->font.ref.referenced.grp.ptr.group = text->originalFont.ref.referenced.grp.ptr.group;
308 text->font.ref.referenced.id = text->originalFont.ref.referenced.id;
312 text->font.ref.included =
MHEG5stringCopy(text->originalFont.ref.included);
333 if (!text->visible.ingredient.root.availabilityStatus)
351 if (text->visible.graphic_data != NULL)
354 text->visible.graphic_data = NULL;
369 if (text->font.referenced)
371 if (text->font.ref.referenced.grp.len != 0)
382 MHEG5colourDestruct(&text->textColour);
383 MHEG5colourDestruct(&text->backgroundColour);
388 if (((
MHEG5Root *)text)->clazz == MHEG5ENTRYFIELD)
392 else if (((
MHEG5Root *)text)->clazz == MHEG5HYPERTEXT)
398 MHEG5drawText( text );
427 if ((target->clazz != MHEG5TEXT) &&
428 (target->clazz != MHEG5HYPERTEXT) &&
429 (target->clazz != MHEG5ENTRYFIELD))
430 return MHEG5ERR_WRONGTARGET;
433 return MHEG5ERR_WRONGNUMBEROFPARAMS;
434 MHEG5resolveORef(params, &tVar);
436 return MHEG5ERR_WRONGNUMBEROFPARAMS;
437 if (!tVar->runningStatus)
438 return MHEG5ERR_PARAMNOTACTIVE;
446 if (tVar->clazz != MHEG5CONTENTREFVARIABLE)
447 return MHEG5ERR_WRONGPARAM;
453 if (tVar->clazz != MHEG5OCTETSTRINGVARIABLE)
454 return MHEG5ERR_WRONGPARAM;
458 return MHEG5ERR_NOERROR;
476 if ((target->clazz != MHEG5TEXT) && (target->clazz != MHEG5HYPERTEXT) && (target->clazz != MHEG5ENTRYFIELD))
478 return MHEG5ERR_WRONGTARGET;
483 return MHEG5ERR_WRONGNUMBEROFPARAMS;
486 MHEG5resolveORef(params, &tVar);
490 return MHEG5ERR_WRONGNUMBEROFPARAMS;
493 if (!tVar->runningStatus)
495 return MHEG5ERR_PARAMNOTACTIVE;
498 if (tVar->clazz != MHEG5OCTETSTRINGVARIABLE)
500 return MHEG5ERR_WRONGPARAM;
505 if ((target->clazz == MHEG5TEXT) || (target->clazz == MHEG5HYPERTEXT))
508 if (mheg_trace_debug & TACTIONS)
511 strcpy(buff, T_NL
"MHEG5getTextData ");
512 MHEG5stringTrace(((
MHEG5Text *) target)->textDataRaw, buff, 0, 120 );
535 return MHEG5ERR_NOERROR;
551 MHEG5Bool invalidString;
556 if ((target->clazz != MHEG5TEXT) && (target->clazz != MHEG5HYPERTEXT) && (target->clazz != MHEG5ENTRYFIELD))
558 return MHEG5ERR_WRONGTARGET;
563 return MHEG5ERR_WRONGNUMBEROFPARAMS;
565 if (invalidString == MHEG5TRUE)
566 return MHEG5ERR_NOERROR;
572 return MHEG5ERR_NOERROR;
592 if ((target->clazz != MHEG5TEXT) && (target->clazz != MHEG5HYPERTEXT) && (target->clazz != MHEG5ENTRYFIELD))
594 return MHEG5ERR_WRONGTARGET;
599 return MHEG5ERR_WRONGNUMBEROFPARAMS;
600 MHEG5resolveGenericGeneric(params, &newTextColour);
602 MHEG5colourDestruct(&text->textColour);
607 return MHEG5ERR_NOERROR;
627 if ((target->clazz != MHEG5TEXT) && (target->clazz != MHEG5HYPERTEXT) && (target->clazz != MHEG5ENTRYFIELD))
629 return MHEG5ERR_WRONGTARGET;
634 return MHEG5ERR_WRONGNUMBEROFPARAMS;
635 MHEG5resolveGenericGeneric(params, &newBackgroundColour);
641 return MHEG5ERR_NOERROR;
662 if ((target->clazz != MHEG5TEXT) && (target->clazz != MHEG5HYPERTEXT) && (target->clazz != MHEG5ENTRYFIELD))
664 return MHEG5ERR_WRONGTARGET;
669 return MHEG5ERR_WRONGNUMBEROFPARAMS;
670 MHEG5resolveGenericGeneric(params, &g);
671 if (g.type == MHEG5OBJECTREF)
673 if (text->font.referenced)
681 text->font.referenced = MHEG5TRUE;
682 if (g.value.o.gref.len != 0)
685 name.len = g.value.o.gref.len;
686 name.data = g.value.o.gref.ptr.name;
688 text->font.ref.referenced.grp.len = name.len;
689 text->font.ref.referenced.grp.ptr.name = name.data;
693 text->font.ref.referenced.grp = g.value.o.gref;
695 text->font.ref.referenced.id = g.value.o.id;
697 else if (g.type == MHEG5OCTETSTRING)
699 if (text->font.referenced)
707 text->font.referenced = MHEG5FALSE;
713 return MHEG5ERR_NOERROR;
721 static MHEG5Int getMarkupLength(
unsigned char *data, MHEG5Int len)
725 if (*data >= 0x40 && *data <= 0x5e)
728 MHEG5Int paramLength;
732 paramLength = data[1];
742 return paramLength + 2;
745 if (*data >= 0x60 && *data <= 0x7e)
769 unsigned short *adaptedData;
772 text->visible.ingredient.data = 0;
773 text->visible.ingredient.dataLen = 0;
776 adaptedData = MHEG5getMem(len *
sizeof(
unsigned short));
778 if (adaptedData == NULL)
780 ERROR_PRINT((
"ERROR : MHEG5textContentAdapt out of memory\n"));
788 if (data[pos] == 0x1b)
791 unsigned int markupLength;
793 adaptedData[adaptedDataLen] = data[pos];
797 markupLength = getMarkupLength(&data[pos], len - pos);
799 while (markupLength > 0)
801 adaptedData[adaptedDataLen] = data[pos];
828 if ((data[pos] & 0x80) == 0x00)
831 adaptedData[adaptedDataLen] = data[pos];
833 else if ((data[pos] & 0xe0) == 0xc0)
842 adaptedData[adaptedDataLen] = (data[pos] & 0x1F) << 6;
844 adaptedData[adaptedDataLen] |= (data[pos] & 0x3F);
846 else if ((data[pos] & 0xf0) == 0xe0)
855 adaptedData[adaptedDataLen] = (data[pos] & 0x0F) << 12;
857 adaptedData[adaptedDataLen] |= (data[pos] & 0x3F) << 6;
859 adaptedData[adaptedDataLen] |= (data[pos] & 0x3F);
861 else if ((data[pos] & 0xf8) == 0xf0)
870 adaptedData[adaptedDataLen] = 0;
876 adaptedData[adaptedDataLen] = 0;
883 if (((
MHEG5Root *)text)->clazz == MHEG5ENTRYFIELD)
892 if (adaptedDataLen == len)
897 text->visible.ingredient.data = (
unsigned char *)adaptedData;
898 text->visible.ingredient.dataLen = adaptedDataLen;
905 text->visible.ingredient.data = MHEG5getMem(adaptedDataLen *
sizeof(
unsigned short));
906 if (text->visible.ingredient.data != 0)
908 memcpy(text->visible.ingredient.data, adaptedData,
909 adaptedDataLen *
sizeof(
unsigned short));
910 text->visible.ingredient.dataLen = adaptedDataLen;
914 MHEG5freeMem(adaptedData);
917 if (((
MHEG5Root *)text)->clazz != MHEG5ENTRYFIELD)
927 text->textDataRaw.data = STR_DataAlloc( len );
928 if (text->textDataRaw.data == NULL)
930 ERROR_PRINT((
"ERROR : MHEG5textContentAdapt out of memory\n"));
935 memcpy(text->textDataRaw.data, data, len);
936 text->textDataRaw.len = len;
937 #ifdef DRAW_IN_ADVANCE 938 if (((
MHEG5Root *)text)->clazz == MHEG5HYPERTEXT)
963 unsigned char *p_data, *p_end;
964 int is_little_endian;
966 unsigned short *p_adpt, tmp_adpt;
968 tmp_adpt = (data[0] << 8) | data[1];
969 text->byteOrderMark = BOM_NONE;
972 case UNICODE_BOM_LITTLE_ENDIAN:
973 is_little_endian = 1;
976 text->byteOrderMark = BOM_LITTLE_ENDIAN;
979 case UNICODE_BOM_BIG_ENDIAN:
982 text->byteOrderMark = BOM_BIG_ENDIAN;
986 is_little_endian = 0;
992 if (is_little_endian)
994 while (p_data < p_end)
998 tmp_adpt |= *p_data << 8;
1001 if (tmp_adpt == 0x001B)
1003 m_len = getMarkupLength(p_data, p_end - p_data);
1011 while (p_data < p_end)
1013 tmp_adpt = *p_data << 8;
1015 tmp_adpt |= *p_data;
1018 if (tmp_adpt == 0x001B)
1020 m_len = getMarkupLength(p_data, p_end - p_data);
1028 p_adpt = MHEG5getMem(adpt_len *
sizeof(
unsigned short));
1032 ERROR_PRINT((
"ERROR : MHEG5textContentAdapt out of memory\n"));
1036 text->visible.ingredient.data = (
unsigned char *)p_adpt;
1037 text->visible.ingredient.dataLen = adpt_len;
1040 if (is_little_endian)
1042 while (p_data < p_end)
1046 *p_adpt |= *p_data << 8;
1048 if (*p_adpt == 0x001B)
1051 m_len = getMarkupLength(p_data, p_end - p_data);
1054 *p_adpt++ = *p_data++;
1065 while (p_data < p_end)
1067 *p_adpt = *p_data << 8;
1071 if (*p_adpt == 0x001B)
1074 m_len = getMarkupLength(p_data, p_end - p_data);
1078 *p_adpt++ = *p_data++;
1089 if (((
MHEG5Root *)text)->clazz == MHEG5ENTRYFIELD)
1098 if (((
MHEG5Root *)text)->clazz != MHEG5ENTRYFIELD)
1108 text->textDataRaw.data = STR_DataAlloc( len );
1109 if (text->textDataRaw.data == NULL)
1111 ERROR_PRINT((
"ERROR : MHEG5textContentAdapt out of memory\n"));
1116 memcpy(text->textDataRaw.data, data, len);
1117 text->textDataRaw.len = len;
1118 #ifdef DRAW_IN_ADVANCE 1119 if (((
MHEG5Root *)text)->clazz == MHEG5HYPERTEXT)
1147 unsigned char *unadaptedData;
1148 unsigned short *data;
1154 data = (
unsigned short *)text->visible.ingredient.data;
1155 dataLen = text->visible.ingredient.dataLen;
1157 if ((data == 0) || (dataLen == 0))
1167 unadaptedData = MHEG5getMem( text->visible.ingredient.dataLen * 3 );
1169 if (unadaptedData == NULL)
1172 ERROR_PRINT((
"ERROR: MHEG5textContentUnadapt out of memory\n"));
1178 while (pos < dataLen)
1180 if (data[pos] == 0x1b)
1183 unsigned int markupLength;
1185 if ((data[pos + 1] >= 0x40) && (data[pos + 1] <= 0x5e))
1187 markupLength = data[pos + 2] + 3;
1189 else if ((data[pos + 1] >= 0x60) && (data[pos + 1] <= 0x7e))
1198 while (markupLength > 0)
1200 assert(data[pos] <= 0xff);
1201 unadaptedData[unadaptedLen] = (
unsigned char)data[pos];
1210 if (data[pos] <= 0x7f)
1215 unadaptedData[unadaptedLen++] = (
unsigned char)data[pos];
1217 else if (data[pos] <= 0x7ff)
1222 unadaptedData[unadaptedLen++] = (
unsigned char)((data[pos] & 0x07c0) >> 6) | 0xc0;
1223 unadaptedData[unadaptedLen++] = (
unsigned char)(data[pos] & 0x003f) | 0x80;
1230 unadaptedData[unadaptedLen++] = ((data[pos] & 0xf000) >> 12) | 0xe0;
1231 unadaptedData[unadaptedLen++] = ((data[pos] & 0x0fc0) >> 6) | 0x80;
1232 unadaptedData[unadaptedLen++] = (data[pos] & 0x003f) | 0x80;
1242 *utf8Data = STR_DataAlloc( unadaptedLen );
1245 memcpy(*utf8Data, unadaptedData, unadaptedLen);
1246 *utf8Len = unadaptedLen;
1250 MHEG5freeMem(unadaptedData);
1265 unsigned char *unadaptedData;
1266 unsigned short *data;
1272 data = (
unsigned short *)text->visible.ingredient.data;
1273 dataLen = text->visible.ingredient.dataLen;
1275 if ((data == 0) || (dataLen == 0))
1285 unadaptedData = MHEG5getMem( text->visible.ingredient.dataLen * 3 );
1287 if (unadaptedData == NULL)
1290 ERROR_PRINT((
"ERROR: MHEG5textContentUnadapt out of memory\n"));
1296 if (text->byteOrderMark == BOM_LITTLE_ENDIAN)
1298 unadaptedData[0] = 0xFF;
1299 unadaptedData[1] = 0xFE;
1302 else if (text->byteOrderMark == BOM_BIG_ENDIAN)
1304 unadaptedData[0] = 0xFE;
1305 unadaptedData[1] = 0xFF;
1313 while (pos < dataLen)
1315 if (data[pos] == 0x1b)
1318 unsigned int markupLength;
1320 if ((data[pos + 1] >= 0x40) && (data[pos + 1] <= 0x5e))
1322 markupLength = data[pos + 2] + 3;
1324 else if ((data[pos + 1] >= 0x60) && (data[pos + 1] <= 0x7e))
1333 while (markupLength > 0)
1335 assert(data[pos] <= 0xff);
1336 unadaptedData[unadaptedLen] = (
unsigned char)data[pos];
1345 if (text->byteOrderMark == BOM_LITTLE_ENDIAN)
1347 unadaptedData[unadaptedLen++] = data[pos] & 0xff;
1348 unadaptedData[unadaptedLen++] = (data[pos] >> 8) & 0xff;
1352 unadaptedData[unadaptedLen++] = (data[pos] >> 8) & 0xff;
1353 unadaptedData[unadaptedLen++] = data[pos] & 0xff;
1361 *utf16Data = STR_DataAlloc( unadaptedLen );
1362 if (*utf16Data != 0)
1364 memcpy(*utf16Data, unadaptedData, unadaptedLen);
1365 *utf16Len = unadaptedLen;
1369 MHEG5freeMem(unadaptedData);
void MHEG5textUtf8Content(MHEG5Text *text, unsigned char *data, int len)
Adapt new content for Text objects. Content is encoded using UTF8 - this is converted to 16 bit unico...
void MHEG5visibleActivate(MHEG5Visible *visible)
Apply the activation behaviour of the visible class. Apply the activation behaviour off the visible c...
void MHEG5textUtf16Content(MHEG5Text *text, unsigned char *data, int len)
Content for Text objects is encoded using UTF16.
MHEG5Text * MHEG5textClone(MHEG5Text *source)
Copy a text object with original values.
void MHEG5textActivate(MHEG5Text *text)
Apply the activation behaviour of the text class. As this class has no own activation behaviour this ...
Implement the MHEG5 Text Class 36 Text Class Defines attributes and behaviour of pieces of textual in...
void MHEG5visibleFree(MHEG5Visible *visible)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
void MG_FreeData(void *data)
free surface buffer
void MHEG5genericCopy(MHEG5Generic *dest, MHEG5Generic *src)
Copy a MHEG5Generic.
MHEG5ErrorCode MHEG5setBackgroundColour(MHEG5Root *target, MHEG5GList *params)
The effect of this action is to set the BackgroundColour to the given colour. Implementation of the M...
MHEG5ErrorCode MHEG5setTextColour(MHEG5Root *target, MHEG5GList *params)
The effect of this action is to set the TextColour to the given colour. Implementation of the MHEG5se...
void MHEG5visiblePrepare(MHEG5Visible *visible)
Apply the preparation behaviour off the visible class Apply the preparation behaviour of the visible ...
MHEG5String MHEG5stringCopy(MHEG5String source)
<Function description>="">
Implement the MHEG5 Variable Class 21 Variable Class Defines a variable within the context of a Group...
void MHEG5stringDestruct(MHEG5String *item)
Destruct a MHEG5String.
void MHEG5visibleDestruct(MHEG5Visible *visible)
Destruct a visible object.
void MHEG5textFree(MHEG5Text *text)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
MHEG5ErrorCode MHEG5setFontAttributes(MHEG5Root *target, MHEG5GList *params)
The effect of this action is to set the FontAttributes to the given attributes. Implementation of the...
void MHEG5textPrepare(MHEG5Text *text)
Apply the preparation behaviour of the text class Apply the preparation behaviour of the text class...
This file defines the profile for the MHEG engine.
MHEG5GList * MHEG5resolveGenericOctetString(MHEG5GList *params, MHEG5String *value, MHEG5Bool *invalidString)
Resolve a parameter reference to a generic octet string. The reference can be either direct or indire...
MHEG5ErrorCode MHEG5getTextContent(MHEG5Root *target, MHEG5GList *params)
The effect of this action is to transfer the data of the content attribute of the text to the variabl...
void MHEG5textInit(MHEG5Text *text)
Initialise a text object with default values.
void MHEG5textContentUnadaptUTF16(MHEG5Text *text, MHEG5Byte **utf16Data, MHEG5Int *utf16Len)
Undo the adaption of content for Text objects. Adapted content is stored as 16 bit unicode - this is ...
Implement functions to retrieve MHEG5objects by GroupID and ID.
Implementation of the MHEG5 Application Class Defines a set of Ingredient objects, which are shared within an application scope. Base class: Group Subclasses: None Status: Concrete class.
Mheg5 logging and debug printing.
MHEG class interface to graphics text render.
void MHEG5textContentUnadapt(MHEG5Text *text, MHEG5Byte **utf8Data, MHEG5Int *utf8Len)
Undo the adaption of content for Text objects. Adapted content is stored as 16 bit unicode - this is ...
void MHEG5visibleClone(MHEG5Visible *destination, MHEG5Visible *source)
Copy a visible object with original values.
MHEG5ErrorCode MHEG5getTextData(MHEG5Root *target, MHEG5GList *params)
Set the Variable referenced by TextDataVar to the value of the TextData attribute. Implementation of the GetTextData (Target, TextDataVar) action of the text class.
Implement generic MHEG5-display functions - independent from the OSD These are generic functions used...
void MHEG5visibleDeactivate(MHEG5Visible *visible)
Apply the deactivation behaviour of the visible class. As this class has no own deactivation behaviou...
void MHEG5textDestruct(MHEG5Text *text)
Destruct a text object.
void MHEG5textDeactivate(MHEG5Text *text)
Apply the deactivation behaviour of the text class. As this class has no own deactivation behaviour t...
MHEG5ErrorCode MHEG5setFontRef(MHEG5Root *target, MHEG5GList *params)
The effect of this action is to change the character font used to preset a text. Implementation of th...
void MHEG5visibleInit(MHEG5Visible *visible)
Initialise a visible object with default values.
void MHEG5textClearTextData(MHEG5Text *text)
Clear text data.
Implement the MHEG5 EntryField Class. Defines an interaction widget used by the final user to edit an...