Dylan Smith : richedit: Properly restore style after end of rtf group.

Alexandre Julliard julliard at winehq.org
Mon Jul 20 07:36:51 CDT 2009


Module: wine
Branch: master
Commit: c6cf5677065e9d7aaf6495e26120120d40e3a2a7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c6cf5677065e9d7aaf6495e26120120d40e3a2a7

Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date:   Fri Jul 17 13:24:13 2009 -0400

richedit: Properly restore style after end of rtf group.

Rich text files have groupings of text, where styles are pushed onto
the stack when encountering a start of the group, then popped at the
end of the group.  This was being handled improperly before, because a
single styleChanged flag was being stored to keep track of whether the
style needed to be restored at the end of a group. This fails to work
properly since the single flag isn't keeping track of all the levels
of the stack, so some styles are not restored properly.

---

 dlls/riched20/editor.c |   19 ++++++++-----------
 dlls/riched20/reader.c |    4 ++++
 dlls/riched20/rtf.h    |    2 +-
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 14a7246..c3cd187 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1345,7 +1345,8 @@ static void ME_RTFReadHook(RTF_Info *info)
       {
         case rtfBeginGroup:
           if (info->stackTop < maxStack) {
-            info->stack[info->stackTop].fmt = info->style->fmt;
+            info->stack[info->stackTop].style = info->style;
+            ME_AddRefStyle(info->style);
             info->stack[info->stackTop].codePage = info->codePage;
             info->stack[info->stackTop].unicodeLength = info->unicodeLength;
           }
@@ -1354,7 +1355,6 @@ static void ME_RTFReadHook(RTF_Info *info)
           break;
         case rtfEndGroup:
         {
-          ME_Style *s;
           RTFFlushOutputBuffer(info);
           info->stackTop--;
           if (info->stackTop<=0) {
@@ -1362,15 +1362,12 @@ static void ME_RTFReadHook(RTF_Info *info)
             return;
           }
           assert(info->stackTop >= 0);
-          if (info->styleChanged)
-          {
-            /* FIXME too slow ? how come ? */
-            s = ME_ApplyStyle(info->style, &info->stack[info->stackTop].fmt);
-            ME_ReleaseStyle(info->style);
-            info->style = s;
-            info->codePage = info->stack[info->stackTop].codePage;
-            info->unicodeLength = info->stack[info->stackTop].unicodeLength;
-          }
+
+          ME_ReleaseStyle(info->style);
+          info->style = info->stack[info->stackTop].style;
+          ME_AddRefStyle(info->style);
+          info->codePage = info->stack[info->stackTop].codePage;
+          info->unicodeLength = info->stack[info->stackTop].unicodeLength;
           break;
         }
       }
diff --git a/dlls/riched20/reader.c b/dlls/riched20/reader.c
index 0462f71..a589a8e 100644
--- a/dlls/riched20/reader.c
+++ b/dlls/riched20/reader.c
@@ -442,7 +442,11 @@ static void RTFUngetToken(RTF_Info *info)
 	 * increment the value to compensate for it being decremented
 	 * twice due to the RTFUngetToken. */
 	if(RTFCheckCM (info, rtfGroup, rtfEndGroup))
+	{
+		info->stack[info->stackTop].style = info->style;
+		ME_AddRefStyle(info->style);
 		info->stackTop++;
+	}
 }
 
 
diff --git a/dlls/riched20/rtf.h b/dlls/riched20/rtf.h
index 3277301..d8ac323 100644
--- a/dlls/riched20/rtf.h
+++ b/dlls/riched20/rtf.h
@@ -1095,7 +1095,7 @@ typedef	void (*RTFFuncPtr) (RTF_Info *);		/* generic function pointer */
 
 /* RTF parser stack element */
 struct tagRTFState {
-        CHARFORMAT2W fmt;
+        ME_Style *style;
         int codePage;
         int unicodeLength;
 };




More information about the wine-cvs mailing list