label: fix to merge two DEFAULT tag from format and style user 24/134524/2
authorYoungbok Shin <youngb.shin@samsung.com>
Mon, 19 Jun 2017 05:36:36 +0000 (14:36 +0900)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Wed, 28 Jun 2017 01:00:57 +0000 (01:00 +0000)
@tizen_fix

Change-Id: Ia027324b1fead60788b5073efedd02149f5d7957

src/lib/elm_label.c

index 390c61a..bd711f5 100644 (file)
@@ -90,10 +90,14 @@ _label_format_update(Evas_Object *edje_obj, Elm_Label_Data *sd)
 {
    char buf[LABEL_FORMAT_BUF_SIZE] = { 0 };
    const char *space = " ";
+   const char *default_tag_str = "DEFAULT='";
+   const char *default_tag_start;
    int limit = 0;
    int format_len = ((sd->format == NULL) ? 0 : strlen(sd->format));
    int text_style_user_len = ((sd->text_style_user == NULL) ? 0 : strlen(sd->text_style_user));
 
+   DBG("format_update: original format - [%s], text style user - [%s]", sd->format, sd->text_style_user);
+
    /* If there is no format text in sd->text_style_user, just set sd->format to label */
    if (text_style_user_len == 0)
      {
@@ -101,10 +105,22 @@ _label_format_update(Evas_Object *edje_obj, Elm_Label_Data *sd)
         return;
      }
 
+   default_tag_start = strstr(sd->text_style_user, default_tag_str);
+   if (default_tag_start)
+     default_tag_start += strlen(default_tag_str);
+
    /* If there is format text in sd->format, put sd->format and a space character to buffer. */
    if (format_len > 0)
      {
-        strncat(buf, sd->format, LABEL_FORMAT_BUF_SIZE - 1);
+        limit = LABEL_FORMAT_BUF_SIZE - 1;
+
+        /* Append format without "'" character from end of sd->format
+         * if there is default tag in text_style_user.
+         */
+        if (default_tag_start && ((format_len - 1) < limit))
+          limit = format_len - 1;
+
+        strncat(buf, sd->format, limit);
 
         limit = sizeof(buf) - strlen(buf) - 1;
         if (limit > 0)
@@ -114,8 +130,14 @@ _label_format_update(Evas_Object *edje_obj, Elm_Label_Data *sd)
    /* Append format text of test_style_user to buffer. */
    limit = sizeof(buf) - strlen(buf) - 1;
    if (limit > 0)
-     strncat(buf, sd->text_style_user, limit);
+     {
+        if (default_tag_start)
+          strncat(buf, default_tag_start, limit);
+        else
+          strncat(buf, sd->text_style_user, limit);
+     }
 
+   DBG("format_update: format result - [%s]", buf);
    _label_format_set(edje_obj, buf);
 }
 /* END */